code1 stringlengths 16 24.5k | code2 stringlengths 16 24.5k | similar int64 0 1 | pair_id int64 2 181,637B ⌀ | question_pair_id float64 3.71M 180,628B ⌀ | code1_group int64 1 299 | code2_group int64 1 299 |
|---|---|---|---|---|---|---|
N, A, B=map(int, input().split(" "))
result=A*(N//(A+B))+min(N%(A+B), A)
print(result) | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1,... | 0 | null | 39,647,989,982,562 | 202 | 151 |
k=int(input())
s,m,c,a=input(),10**9+7,1,1
for i in range(k):c*=25*(k+len(s)-i)*pow(i+1,m-2,m)%m;c%=m;a+=c
print(a%m) | K = int(input())
S = input()
MAX = 2 * 10 ** 6 + 1
MOD = 10 ** 9 + 7
# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
fac[i] = fac[i - 1] * i % MOD
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
f... | 1 | 12,742,486,694,178 | null | 124 | 124 |
n = int(input())
a = list(map(int,input().split()))
b = [None] *n
for idx,person in enumerate(a):
b[person-1] = idx+1
for j in b:
print(j,end=' ') | D = input()
W = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7 - W.index(D))
| 0 | null | 156,915,769,696,948 | 299 | 270 |
x = int(input())
a = int(x/500) * 1000 + x % 500 - x % 5
print(a) | x=list(map(int, input().split()))
L=x[0]
R=x[1]
d=x[2]
res=0
while L<=R:
if L%d==0:
res+=1
L+=1
print(res) | 0 | null | 25,056,147,962,652 | 185 | 104 |
A = input().split()
a = A.count(A[0])
b = A.count(A[1])
c = A.count(A[2])
if a == 2 or b == 2 or c == 2:
print("Yes")
else:
print("No")
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n = int(input())
def bs(ok, ng, solve):
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if solve(mid):
ok = mid
else:
ng = mid
return ok
ans = bs(n, 0, lambda x: x * 1.08 >= n)
if int(ans * 1.08)... | 0 | null | 96,632,290,416,650 | 216 | 265 |
n = int(input())
x = list(map(float, input().split(' ')))
y = list(map(float, input().split(' ')))
p1 = 0.0
p2 = 0.0
p3 = 0.0
pm = 0.0
i = 0
while i < n:
p1 += abs(x[i] - y[i])
p2 += pow(abs(x[i] - y[i]), 2)
p3 += pow(abs(x[i] - y[i]), 3)
pm = max(pm, abs(x[i] - y[i]))
i += 1
p2 = pow(p2, 0.5)
p3 = ... | def main():
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for answer in calc(n, x, y):
print("{:.6f}".format(answer))
def calc(n, x, y):
ret = []
patterns = [1, 2, 3]
for pattern in patterns:
sum = 0
for i in range(0, n):
... | 1 | 215,179,408,168 | null | 32 | 32 |
n, m, L = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]
q = int(input())
st = [list(map(int, input().split())) for _ in range(q)]
d = [[float('inf') for _ in range(n)] for _ in range(n)]
for a, b, c in abc:
if c > L:
continue
d[a-1][b-1] = c
d[b-1][a-1] = c
de... | import sys
input=sys.stdin.readline
N=int(input())
S=input()
Q=int(input())
D={}
A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
D[A[i]]=i
n=1
while n<N:
n*=2
seg=[0 for i in range(n*2)]
#print(seg)
for i in range(N):
seg[n-1+... | 0 | null | 118,223,889,727,222 | 295 | 210 |
a, b = map(int, input().split())
def base10to(n, b):
if (int(n/b)):
return base10to(int(n/b), b) + str(n%b)
return str(n%b)
print(len(base10to(a,b))) | import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
c_p = 0
c_q = 0
count = 0
for i in itertools.permutations(sorted(p),len(p)):
if p == list(i):
c_p = count
if q == list(i):
c_q = count
count += 1
print(abs(c_p - c_q)) | 0 | null | 82,220,906,233,700 | 212 | 246 |
num = map(int, raw_input().split())
for i in range(0,2):
for j in range(0,2):
if num[j] > num[j+1]:
tmp_box = num[j]
num[j] = num[j+1]
num[j+1] = tmp_box
sort = map(str, num)
print sort[0] + " " + sort[1] + " " + sort[2] | A, B = map(int, input().split())
if A > 9 or B > 9:
ans = -1
else:
ans = A*B
print(ans)
| 0 | null | 78,914,512,807,142 | 40 | 286 |
k, n = map(int, input().split())
a = list(map(int, input().split()))
a += [k + a[0]]
print(k - max([a[i + 1] - a[i] for i in range(n)])) | K, N = map(int,input().split())
L = list(map(int,input().split()))
d = [L[i+1]-L[i] for i in range(N-1)]
d.append(L[0] - (L[-1]-K))
m = max(d)
ans = sum(d) - m
print(ans) | 1 | 43,535,887,993,610 | null | 186 | 186 |
N=int(input())
print(int((N+2-1)/2))
| n=input()
a=(int(n)+1)//2
print(a)
| 1 | 58,970,412,047,998 | null | 206 | 206 |
from math import ceil
a,b,c,d = map(int,input().split())
if ceil(c/b) <= ceil(a/d):
print("Yes")
else:
print("No") | #!/usr/bin/env python3
YES = "Yes" # type: str
NO = "No" # type: str
def solve(A: int, B: int, C: int, D: int):
while True:
# 高橋
C -= B
if C <= 0:
return YES
# 青木
A -= D
if A <= 0:
return NO
def main():
A, B, C, D = map(int, input().... | 1 | 29,772,212,505,430 | null | 164 | 164 |
i = 1
a = input()
while a != 0:
print "Case %d: %d" % (i, a)
i = i + 1
a = input() | x = 0
while True:
x += 1
n = input()
if int(n) == 0:
break
print("Case " + str(x) + ": " + n) | 1 | 472,519,537,952 | null | 42 | 42 |
X, N = map(int, input().split())
ps = list(map(int, input().split()))
bgr, smr = X, X
while bgr <= 100:
if bgr not in ps:
break
bgr += 1
while smr >= 1:
if smr not in ps:
break
smr -= 1
print(bgr) if bgr - X < X - smr else print(smr)
| def Euclidean(input_list):
# print input_list
x = input_list[1]
y = input_list[0]
r = x % y
if r != 0:
list = [r, y]
list.sort()
return Euclidean(list)
else:
return y
list = map(int, raw_input().split(" "))
list.sort()
print Euclidean(list) | 0 | null | 6,974,256,763,320 | 128 | 11 |
#!/usr/bin/env python3
import sys
def solve(N: int, A: "List[int]"):
dp = [[0,0] for _ in range(N+1)]
dp[2] = [A[0],A[1]]
for i in range(2,N):
if (i+1)%2 ==0:
dp[i+1][0] = dp[i-1][0]+A[i-1]
else:
dp[i+1][0] = max(dp[i])
dp[i+1][1] = max(dp[i-1])+A[i]
... | import sys
sys.setrecursionlimit(500000)
N = int(input())
#道を双方向に記録する。
g = [[] for _ in range(N)]
for i in range(N-1): #木の辺の数はN-1
#iが辺のID
a,b = map(int,input().split())
a -= 1; b -= 1 #ここで引いて頂点を0スタートにしないとオーバーフロー
g[a].append((b,i))
g[b].append((a,i))
#これが答え。
ans = [-1 for _ in range(N-1)]
#vという頂点からpという親にc... | 0 | null | 87,065,217,179,986 | 177 | 272 |
x,y,xx,yy=map(float, input().split())
print('%5f'%((x-xx)**2+(y-yy)**2)**0.5) | while True:
x = input()
if int(x) == 0: break
print(sum([int(i) for i in x])) | 0 | null | 874,967,002,400 | 29 | 62 |
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq
def ri():
return int(input())
def rl():
return list(map(int, input().split()))
def solve():
k = ri()
a, b = rl()
for i in range(k, 1001, k):
if a <= i <= b:
print ("OK")
... | def main():
N = int(input())
A = {input() for i in range(N)}
print(len(A))
if __name__ == '__main__':
main()
| 0 | null | 28,380,993,579,460 | 158 | 165 |
x = int(input())
a = x // 100
b = x - a * 100
while b > 5:
b = b - 5
a -= 1
if a>=1:
print(1)
else:
print(0) | n = int(input())
s = input()
ans = 0
for i in range(1000):
i = str(i).zfill(3)
f = True
x = -1
for j in range(3):
x = s.find(i[j],x+1)
f = f and bool(x >= 0)
ans += f
print(ans)
| 0 | null | 128,039,297,049,440 | 266 | 267 |
import collections
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT() : return int(input())
def MAP() : return map(int,input().split())
def LIST() : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
K=int(input())
if K%2==0 or... | K = int(input())
s = 7
flg = False
cnt = 0
for i in range(K+1):
cnt += 1
if s % K == 0:
flg = True
break
s *= 10
s %= K
s += 7
if flg:
print(cnt)
else:
print(-1)
| 1 | 6,147,922,725,920 | null | 97 | 97 |
(x, y, a, b, c), p, q, r = [map(int, o.split()) for o in open(0)]
print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + list(r))[-x-y:])) | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# . ' Udit Gupta @luctivud ,
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## ## ####### # # ... | 1 | 45,025,920,189,296 | null | 188 | 188 |
def main():
s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())
if s == u:
print(a-1, b)
else:
print(a, b-1)
if __name__ == "__main__":
main()
| N = int(input())
A = list(map(int, input().split()))
LN = max(A) + 1
L = [0 for i in range(LN)]
count = 0
for i in A:
for j in range(i, LN, i):
L[j] += 1
for i in A:
if L[i] == 1:
count += 1
print(count) | 0 | null | 43,201,846,813,594 | 220 | 129 |
from math import *
n=int(input())
a=[]
for i in range(n):
s=input()
a.append(s)
s=set(a)
print(len(s)) | # coding: utf-8
list = []
while True:
num = input().rstrip().split(" ")
if (int(num[0]) == 0) and (int(num[1]) == 0):
break
list.append(num)
for i in range(len(list)):
for j in range(int(list[i][0])):
if (j == 0) or (j == (int(list[i][0])-1)):
print("#"*int(list[i][1]))
... | 0 | null | 15,483,435,976,928 | 165 | 50 |
N = int(input())
from itertools import permutations
P=tuple(map(int, input().split()))
Q=tuple(map(int, input().split()))
A=list(permutations([i for i in range(1, N+1)]))
a=A.index(P)
b=A.index(Q)
print(abs(a-b)) | from itertools import permutations
n=int(input())
p=tuple(int(i)for i in input().split())
q=tuple(int(i)for i in input().split())
permutation_n=list(permutations(range(1,n+1)))
a=b=0
for i in permutation_n:
if i<p:a+=1
if i<q:b+=1
print(abs(a-b)) | 1 | 100,266,597,729,180 | null | 246 | 246 |
n,m=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
t=[[]for i in range(n)]
ans=0
for i in range(m):
a,b=[int(x) for x in input().split()]
t[a-1].append(b-1)
t[b-1].append(a-1)
for i in range(n):
if t[i]==[]:
ans+=1
else:
c=[]
for j in t[i]:
... | K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
if i%K==0:
print('OK')
exit()
print('NG') | 0 | null | 25,930,215,099,540 | 155 | 158 |
from decimal import *
import math
A, B = input().split()
a = Decimal(A)
b = Decimal(B)
ib = Decimal(100*b)
print(math.floor((a*ib)/Decimal(100))) | import sys
while(1):
H, W = map(int, raw_input().split())
if(H == 0 and W == 0):
break
else:
for i in range(H):
for j in range(W):
if(i%2==0 and j%2==0):
sys.stdout.write("#")
elif(i%2==0 and j%2==1):
sys.st... | 0 | null | 8,787,764,727,238 | 135 | 51 |
import copy
a = [int(c) for c in input().split()]
K = a[0]
N = a[1]
A = [int(c) for c in input().split()]
B = list(map(lambda x: x+K,copy.deepcopy(A)))
A = A+B
l = 0
tmp = 0
cnt = 0
for i in range(N):
tmp = A[i+1]-A[i]
if tmp > l :
cnt = i
l = tmp
print(K-l)
| # -*- coding: utf-8 -*-
k, n = map(int, input().split())
a = list(map(int, input().split()))
fst = a[0]
a.append(k+fst)
dis= []
for i in range(n):
dis.append(a[i+1]-a[i])
print(sum(dis)-max(dis)) | 1 | 43,577,883,913,850 | null | 186 | 186 |
N, X, Y = map(int, input().split())
ans = [0] * (N + 1)
for i in range(1, N):
for j in range(i+1, N+1):
dis1 = j-i
dis2 = abs(X-i) + 1 + abs(Y - j)
dis3 = abs(Y-i) + 1 + abs(X - j)
d = min(dis1,dis2,dis3)
ans[d] += 1
for i in range(1, N):
print(ans[i]) | import sys
sys.setrecursionlimit(10000000)
n,x,y=map(int,input().split())
x-=1
y-=1
res=[0]*n
for i in range(n):
for j in range(i+1,n):
m = min(j-i, abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)
res[m]+=1
for i in range(1,n):
print(res[i]) | 1 | 44,297,956,937,660 | null | 187 | 187 |
import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N,X,Y=MI()
X-=1
Y-=1
ans=[0]*N
for i in range(N):
for j in range(i+1,N):
if j<=X:... | # -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = 0
for i in range(N):
if N == 1:
break
minj = i
for j in range(i, N):
if A[j] < A[minj]:
minj = j
flag = 1
if flag == 1:
A[i], A[minj] = A[minj], A[i]
... | 0 | null | 21,911,032,033,352 | 187 | 15 |
import math
A, B, H, M = map(int, input().split())
SP_HOUR = 360 / (12 * 60)
SP_MIN = 360 / 60
angle = (H * 60 + M) * SP_HOUR - M * SP_MIN
if angle < 0:
angle += 360
# print(math.cos(0))
# print(math.cos(3.14))
# print("angle", angle)
# print("angle in radian", math.radians(angle))
#Law of cosines
ans_squ = A *... | li =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(input())
a-=1
print(li[a])
| 0 | null | 34,875,465,333,480 | 144 | 195 |
S = input()
ans = S.replace("hi", "")
if ans == "":
print("Yes")
else:
print("No")
| s=input()
if len(s)%2==0:
for i in range(len(s)//2):
if s[2*i:2*i+2]=="hi":
continue
print("No")
break
else:
print("Yes")
else:
print("No") | 1 | 53,368,137,971,770 | null | 199 | 199 |
line1 = input()
line2 = input()
aryLine1 = line1.split()
arystrLine2 = line2.split()
K = int(aryLine1[0]);
N = int(aryLine1[1]);
aryLine2 = [int(s) for s in arystrLine2]
#print(aryLine2)
aryLine2.sort()
#print(aryLine2)
ans = K
for i in range(0, N):
temp1 = int(aryLine2[i])
if i == N - 1:
temp2 = ... | N = int(input())
S = input()
ans = 0
for i in range(10):
for j in range(10):
for k in range(10):
nums = [str(x) for x in [i, j, k]]
for s in S:
if s == nums[0]:
nums = nums[1:]
if len(nums) == 0:
ans += 1... | 0 | null | 86,052,473,592,668 | 186 | 267 |
N = int(input())
A = list(map(int, input().split()))
nSwap = 0
for i in range(N):
for j in range(N-1, i, -1):
if A[j] < A[j-1]:
A[j-1], A[j] = A[j], A[j-1]
nSwap += 1
print(' '.join(map(str, A)))
print(nSwap) | import collections
from math import factorial
def permutations_count(n, r):
''' 順列 '''
return factorial(n) // factorial(n - r)
def combinations_count(n, r):
''' 組み合わせ '''
return factorial(n) // (factorial(n - r) * factorial(r))
S = input()
lis = []
amari = 1
lis.append(int(S[-1]))
for i in range(2... | 0 | null | 15,548,609,984,072 | 14 | 166 |
bank = 100
x = int(input())
i = 1
while 1:
bank += bank // 100
if bank >= x:
break
i += 1
print(i) | X = int(input())
money = 100
ans = 0
while money < X:
tax = money // 100
money += tax
ans += 1
print(ans) | 1 | 27,011,867,252,978 | null | 159 | 159 |
from sys import stdin
input = stdin.readline
from collections import Counter
def solve():
n = int(input())
verdict = [ inp for inp in stdin.read().splitlines()]
c = Counter(verdict)
print(f'AC x {c["AC"]}')
print(f'WA x {c["WA"]}')
print(f'TLE x {c["TLE"]}')
print(f'RE x {c["RE"]}')
if _... | N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(N):
a = input()
if a == "AC":
ac += 1
if a == "WA":
wa += 1
if a == "TLE":
tle += 1
if a =="RE":
re += 1
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}") | 1 | 8,683,837,431,492 | null | 109 | 109 |
import sys
input = sys.stdin.readline
n = int(input())
plus = []
minus = []
for _ in range(n):
min_s = 0
ts = 0
s = input().strip()
for c in s:
ts += 1 if c == '(' else -1
min_s = min(ts, min_s)
if ts >= 0:
plus.append((-min_s, ts))
else:
minus.append((-(min_s -... | A,B = map(int,input().split())
print(A*B,2*(A+B))
| 0 | null | 11,941,897,506,380 | 152 | 36 |
import math
R=int(input())
cir=2*math.pi*R
print(cir) | a=int(input())
print(2*3.1416*a) | 1 | 31,365,011,186,850 | null | 167 | 167 |
import sys
for line in sys.stdin:
l = map(int, line.split())
print len(str(l[0]+l[1])) | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 21:02:43 2020
@author: liang
"""
K = int(input())
ans = ""
for i in range(K):
ans += "ACL"
print(ans) | 0 | null | 1,092,488,834,620 | 3 | 69 |
#
# author sidratul Muntaher
# date: Aug 19 2020
#
n = int(input())
from math import pi
print(pi* (n*2))
| H = int(input())
W = int(input())
N = int(input())
print(-(-N//max(H,W))) | 0 | null | 60,316,167,203,852 | 167 | 236 |
import math
def dist(a,b,n):
s=0
m=0
for i in range(len(a)):
d=math.fabs(b[i]-a[i])
m=max(m,d)
s+=d**n
return (s**(1/n),m)
n=int(input())
a=list(map(float,input().split()))
b=list(map(float,input().split()))
print('%.6f'%(dist(a,b,1)[0]))
print('%.6f'%(dist(a,b,2)[0]))
print('%.... | n=eval(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
def minkowski(p,x_1,x_2,n):
if p==0:
return float(max([abs(x_1[i]-x_2[i]) for i in range(n)]))
else:
return sum([(abs(x_1[i]-x_2[i]))**p for i in range(n)])**(1/p)
for i in range(4):
print(minkowski((i+1)%4,x,y... | 1 | 216,803,601,472 | null | 32 | 32 |
# coding: utf-8
n = int(input())
R = [ int(input()) for i in range(n)]
MIN = R[0]
MAXdiff = R[1]-R[0]
for i in range(1,n):
MAXdiff = max(MAXdiff,R[i]-MIN)
MIN = min(MIN,R[i])
print(MAXdiff)
| n = int(input())
ans = float("-INF")
min_v = int(input())
for _ in range(n-1):
r = int(input())
ans = max(ans, r - min_v)
min_v = min(min_v, r)
print(ans)
| 1 | 13,831,629,690 | null | 13 | 13 |
def Warshall_Floyd(dist,n,restoration=False):
next_point = [[j for j in range(n)] for _ in range(n)]
for i in range(n):
for j in range(n):
for k in range(n):
if dist[j][k] > dist[j][i] + dist[i][k]:
next_point[j][k] = next_point[j][i]
d... | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
from collections import defaultdict
n, m, l = map(int, readline().split())
dist = [[INF] * n for _ in range(n)]
for _ in range(m):
a, b, c = map(int, readline().split())
... | 1 | 174,294,994,702,818 | null | 295 | 295 |
import math
n=int(input())
x=100000
for i in range(n):
x=x*1.05
# print('5%',x)
x=x/1000
#print('/1000',x)
x=math.ceil(x)
#print('cut',x)
x=x*1000
#print('*1000',x)
print(x) | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
week = int(input())
base = 100000
x = base
for i in range(week):
x = round(x * 1.05)
if x % 1000 > 0:
x = (x // 1000) *1000 +1000
print(x)
if __name__ == '__main__':
main() | 1 | 955,211,820 | null | 6 | 6 |
nums = input().split()
a = int(nums[0])
b = int(nums[1].replace('.', ''))
result = str(a * b)
if len(result) < 3:
print(0)
else:
print(result[:-2]) | import sys
def insertionSort(A, N):
for n in range(N-1):
print (A[n], end=" ")
print(A[N-1])
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j = j - 1
A[j + 1] = v
for n in range(N-1):
... | 0 | null | 8,207,886,762,976 | 135 | 10 |
import itertools
import math
N = int(input())
L = [list(map(int,input().split())) for n in range(N)]
I = list(itertools.permutations(L))
sum = 0
for i in I:
for n in range(N-1):
sum += math.sqrt((i[n+1][0]-i[n][0])**2+(i[n+1][1]-i[n][1])**2)
print(sum/len(I)) | a,b,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[list(map(int,input().split())) for _ in range(m)]
ans=min(a)+min(b)
for i in range(m):
ans=min(ans,(a[x[i][0]-1]+b[x[i][1]-1]-x[i][2]))
print(ans)
| 0 | null | 101,022,495,781,492 | 280 | 200 |
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
if a > b:
bf = a
a = b
b = bf
if b > c:
bf = b
b = c
c = bf
if a > b:
bf = a
a = b
b = bf
print(str(a) + " " + str(b) + " " + str(c)) | n = int(input())
ans = [0]*n
for i in range(1,101):
for j in range(1,101):
for k in range(1,101):
l = i**2 + j**2 + k**2 + i*j + j*k + k*i
if l <= n:
ans[l-1] += 1
for m in range(n):
print(ans[m]) | 0 | null | 4,243,308,214,880 | 40 | 106 |
n=int(input())
if n>=400 and n<=599:
print("8")
elif n>=600 and n<=799:
print("7")
elif n>=800 and n<=999:
print("6")
elif n>=1000 and n<=1199:
print("5")
elif n>=1200 and n<=1399:
print("4")
elif n>=1400 and n<=1599:
print("3")
elif n>=1600 and n<=1799:
print("2")
elif n>=1800 and n<=1999:
... | def main():
N, K = map(int, input().split())
R, S, P = map(int, input().split())
d = {'r': R, 's': S, 'p': P}
T = input()
scores = []
for t in T:
if t == 'r':
scores.append('p')
elif t == 's':
scores.append('r')
else:
scores.append('s')... | 0 | null | 56,876,660,344,922 | 100 | 251 |
n,a,b = map(int,input().split())
m = 10**9 + 7
comb_a = 1
comb_b = 1
a_num = list(range(1,a+1))
j = 0
for i in range(1,a+1):
comb_a *= (n-i+1)
comb_a *= pow(a_num[i-1],m-2,m)
comb_a = comb_a % m
b_num = list(range(1,b+1))
j = 0
for i in range(1,b+1):
comb_b *= (n-i+1)
comb_b *= pow(b_num[i-1],m-2,... | import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
s = ins()
if s == "AAA" or s == "BBB":
print("No")
else:
print("Yes") | 0 | null | 60,675,226,015,690 | 214 | 201 |
n, m = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for y in range(n)]
b = [int(input()) for x in range(m)]
c = [0 for i in range(n)]
for i in range(n):
c[i] = sum([a[i][x] * b[x] for x in range(m)])
for i in c:
print(i) | M1, D1=input().split()
M2, D2=input().split()
M1=int(M1)
M2=int(M2)
if M1==M2:
print(0)
else:
print(1) | 0 | null | 62,803,535,155,140 | 56 | 264 |
H = int(input())
W = int(input())
N = int(input())
HW =H*W
ans =H+W
for h in range(0,H+1):
for w in range(0,W+1):
cntB = HW - (H-h)*(W-w)
if cntB>=N:
ans = min(ans, h+w)
print(ans) | a,b,c=map(int,input().split())
if a+b+c>21:print('bust')
else:print('win') | 0 | null | 104,022,926,757,900 | 236 | 260 |
# -*- coding: utf-8 -*-
'import sys'
input()
a=[int(i) for i in input().split()]
a.reverse()
f=0
for i in range(len(a)):
if f: print(" ",end="")
print("{}".format(a[i]),end="")
f=1
print("") | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.sort()
return divisors
n = int(input())
ans = len(make_divisors(n - 1)) - 1
for x in make_divisors(n)... | 0 | null | 21,215,883,362,670 | 53 | 183 |
#!/usr/bin/env python3
s = input()
l = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
if s == 'SUN':
print(7)
else:
print(6 - l.index(s)) | a = input()
arr = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
p = arr.index(a)
print(7-p) | 1 | 133,728,185,479,648 | null | 270 | 270 |
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [a for a, b in AB]
B = [b for a, b in AB]
A.sort()
B.sort()
if N % 2:
ma = B[N // 2]
mi = A[N // 2]
else:
ma = B[N // 2 - 1] + B[N // 2]
mi = A[N // 2 - 1] + A[N // 2]
print(ma - mi + 1) | def main():
n = int(input())
A = [0]*n
B = [0]*n
for i in range(n):
a,b = map(int,input().split())
A[i] = a
B[i] = b
A.sort()
B.sort()
if n%2 == 0:
m1 = (A[n//2-1]+A[n//2])/2
m2 = (B[n//2-1]+B[n//2])/2
print(int(2*(m2-m1))+1)
else:
... | 1 | 17,235,471,162,348 | null | 137 | 137 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return lis... | import numpy as np
import math
import collections
N = int(input())
A = list(map(int, input().split()))
ans = 0
node_num = 1
pre_node_num = 1
B = [1 - A[0]]
ruisekiA = [0 for i in range(N + 2)]
ruisekiA[N] = A[N]
ruisekiA[N + 1] = 0
for i in range(N - 1, -1, -1):
ruisekiA[i] = ruisekiA[i + 1] + A[i]
for i in ra... | 1 | 18,829,687,241,442 | null | 141 | 141 |
# https://atcoder.jp/contests/abc163/tasks/abc163_d
def main():
MOD = 10**9 + 7
n, k = [int(i) for i in input().strip().split()]
table = [0] * (n + 2)
table[1] = 1
for i in range(2, n + 1):
table[i] = table[i - 1] + i
ans = 0
for i in range(k, n + 1):
_min = table[i - 1]
... | import sys
from collections import deque
input = sys.stdin.readline
def bfs(S, sh, sw, dist):
dist[sh][sw] = 0
queue = deque([(sh, sw)])
while queue:
h, w = queue.popleft()
for i, j in ((0, 1), (0, -1), (1, 0), (-1, 0)):
y, x = h + i, w + j
if S[y][x] == "#":
... | 0 | null | 63,852,165,287,560 | 170 | 241 |
A,B,N=map(int,input().split())
if N<B:
x=N
elif N==B:
x=N-1
else:
x=(N//B)*B-1
ans=(A*x/B)//1-A*(x//B)
print(int(ans)) | a=int(input())
b=int(input())
v=[1,2,3]
for i in v:
if a!=i and b!=i:
print(i)
break | 0 | null | 69,585,719,518,468 | 161 | 254 |
s = input()
t = s[::-1]
n = len(s)
resid = [0] * 2019
resid[0] = 1
csum = 0
powoften = 1
for i in range(n):
csum = (csum + int(t[i]) * powoften) % 2019
powoften = (10 * powoften) % 2019
resid[csum] += 1
ans = 0
for i in range(2019):
ans += resid[i] * (resid[i] - 1) // 2
print(ans) | from collections import Counter
S = list(input())
S.reverse()
MOD = 2019
t = [0]
r = 1
for i in range(len(S)):
q = (t[-1] + (int(S[i]) * r)) % MOD
t.append(q)
r *= 10
r %= MOD
cnt = Counter(t)
cnt_mc = cnt.most_common()
ans = 0
for _, j in cnt_mc:
if j >= 2:
ans += j * (j - 1) // 2
... | 1 | 30,950,962,763,840 | null | 166 | 166 |
n = int(input())
a = 0
for i in range(10):
for j in range(10):
if i*j == n:
a +=1
if a == 0:
print("No")
else:
print("Yes") | N=int(input())
for num in range(1,10):
if (N/num).is_integer() and 1<=(N/num)<=9:
print("Yes")
break
else:
print("No") | 1 | 159,447,062,754,460 | null | 287 | 287 |
X=int(input())
while True:
flg = True
for i in range(2,int(X**1/2)+1):
if X%i == 0:
flg = False
break
if flg == True:
print(X)
break
else:
X += 1
| X = int(input())
if X <= 2:
print(2)
exit()
S = [2]
for i in range(3, 10**6, 2):
f = True
for s in S:
if s > i**(0.5): break
if i % s == 0:
f = False
break
if f:
S.append(i)
if i >= X:
print(i)
break
| 1 | 105,296,113,390,310 | null | 250 | 250 |
N=int(input())
u="ACL"
print(u*N)
| result = []
while True:
(m, f, r) = [int(i) for i in input().split()]
sum = m + f
if m == f == r == -1:
break
if m == -1 or f == -1:
result.append('F')
elif sum >= 80:
result.append('A')
elif sum >= 65:
result.append('B')
elif sum >= 50:
result.appen... | 0 | null | 1,738,717,152,030 | 69 | 57 |
list = []
x = 1
while x > 0:
x = input()
if x > 0:
list.append(x)
for i,j in enumerate(list):
print "Case " + str(i+1) + ": " + str(j) | flag = "go"
cnt = 0
while flag == "go":
cnt += 1
x = int(input())
if x == 0:
flag = "stop"
else:
print("Case " + str(cnt) + ": " + str(x))
| 1 | 494,539,368,830 | null | 42 | 42 |
n=int(input())
for i in range(1,361):
if (n*i)%360==0:
print(i);exit() | tmp = input()
array = tmp.split(' ')
a = int(array[0])
b = int(array[1])
print(str(a*b) + " " + str((a*2)+(b*2)))
| 0 | null | 6,657,657,199,310 | 125 | 36 |
x = int(input())
ans = x // 500 * 1000
x = x % 500
ans += x // 5 * 5
print(ans) | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter... | 0 | null | 71,956,233,050,440 | 185 | 247 |
X = int(input())
if (X < 30):
print('No')
else:
print('Yes') | x = int(input())
if x >= 30:
ans = 'Yes'
else:
ans = 'No'
print(ans) | 1 | 5,686,149,600,002 | null | 95 | 95 |
N = int(input())
X = list(map(int, input().split()))
ans = 1000000000
for i in range(1, max(X)+1):
l = 0
for j in range(N):
l += (i - X[j]) ** 2
ans = min(ans, l)
print(ans) | x, y = map(int, input().split())
prise_dict = {3: 100000, 2: 200000, 1: 300000}
ans = 0
if x in prise_dict.keys():
ans += prise_dict[x]
if y in prise_dict.keys():
ans += prise_dict[y]
if x == y == 1:
ans += 400000
print(ans)
| 0 | null | 102,615,496,887,958 | 213 | 275 |
S = input()
T = input()
ans = 1001
for i in range(len(S)-len(T)+1):
ans = min(ans, sum(S[i+j] != T[j] for j in range(len(T))))
print(ans) | import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): r... | 0 | null | 3,357,153,700,208 | 82 | 77 |
print ((int(raw_input()))**3) | import numpy as np
R=int(input())
circle=float(R*2*np.pi)
print(circle)
| 0 | null | 15,813,696,293,450 | 35 | 167 |
def expect(n):
return (n+1)/2
nk = input().split()
N = int(nk[0])
K = int(nk[1])
p = input().split()
tmp = 0
for i in range (K):
tmp += expect(int(p[i]))
tmpMax = tmp
for i in range(N - K):
tmp -= expect(int(p[i]))
tmp += expect(int(p[i+K]))
tmpMax = max(tmpMax, tmp)
print(tmpMax)
|
n = int(input())
s = [list(input()) for i in range(n)]
r = []
l = []
ans = 0
for i in s:
now = 0
c = 0
for j in i:
if j =="(":
now += 1
else:
now -= 1
c = min(c,now)
if c == 0:
ans += now
elif now >= 0:
l.append([c,now])
else:
... | 0 | null | 49,478,113,532,640 | 223 | 152 |
import math
n = int(input())
folia = list(map(int, input().split()))
#print(n, folia)
#_1 木の一番下から順に各深さの頂点数[min, max]を取得
seq = [[folia[-1], folia[-1]]]
for i in range(n): # 深さ'n'分
tmp = folia[-(i+2)]
sml = math.ceil(seq[i][0] / 2) + tmp
big = seq[i][1] + tmp
seq += [[sml, big]]
#print(seq)
#_2 一番根本の頂... | k=int(input())
l=['ACL']*k
print(*l,sep='')
| 0 | null | 10,624,858,250,370 | 141 | 69 |
N = int(input())
def answer(N: int) -> str:
x = 0
for i in range(1, 10):
for j in range(1, 10):
if N == i * j:
x = 1
return 'Yes'
if x == 0:
return 'No'
print(answer(N)) | N=int(input())
resurt=''
for i in range(1,10):
if N%i ==0 and N//i<=9:
result='Yes'
break
else:
result='No'
print(result) | 1 | 159,541,837,273,280 | null | 287 | 287 |
def main():
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
res = 0
for i in T:
if i in S:
res += 1
print(res)
if __name__ == '__main__':
main()
| n = int(input())
s = list(map(int,input().split()))
q = int(input())
r = list(map(int,input().split()))
cou = 0
for i in range(q):
for j in range(n):
if(s[j] == r[i]):
cou += 1
break
print(cou)
| 1 | 67,554,556,410 | null | 22 | 22 |
result = []
def combination(n, x):
count = 0
for i in range(1, n + 1):
for j in range(1,i):
for k in range(1, j):
if i + j + k == x:
count += 1
result.append(count)
while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0:
... | # -*- coding: utf-8 -*-
while True:
n, x = map(int, raw_input().split())
if n == x == 0:
break
count = 0
for a in range(1, n+1):
for b in range(a+1, n+1):
for c in range(b+1, n+1):
if a+b+c == x:
count += 1
break
pr... | 1 | 1,292,281,797,170 | null | 58 | 58 |
n = int(input())
a = list(map(int, input().split()))
MOD = 1000000007
dic = {}
dic[0] = 3
for i in range(1,n+1):
dic[i] = 0
ans = 1
for i in range(n):
ans = ans * dic[a[i]] % MOD
dic[a[i]] -= 1
dic[a[i] + 1] += 1
print(ans) | N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
color = [0]*3
ans = 1
for i in range(N):
if A[i] not in color:
ans = 0
break
ind = color.index(A[i])
ans *= len([c for c in color if c == A[i]])
ans %= mod
color[ind] += 1
#ans = rec(color,0)
print(ans) | 1 | 130,080,401,591,660 | null | 268 | 268 |
H,W,M=map(int,input().split())
HSum=[0 for _ in range(H)]
WSum=[0 for _ in range(W)]
bombs = set()
for _ in range(M):
hi,wi = map(lambda x:int(x)-1,input().split())
HSum[hi] += 1
WSum[wi] += 1
bombs.add( (hi,wi) )
# print(HSum)
# print(WSum)
curMax = 0
## 計算量多すぎ。。
# for h in range(H):
# for w in range(W):
... | MOD = 10 ** 9 + 7
N = int(input())
Sall = pow(10, N, MOD)
S0 = S9 = pow(9, N, MOD)
S09 = pow(8, N, MOD)
ans = (Sall - (S0 + S9 - S09)) % MOD
print(ans) | 0 | null | 3,876,874,125,216 | 89 | 78 |
from collections import deque
LIM=200004
L=[0]*LIM
def bin_sum(Y):
S=bin(Y)[2:]
count=0
for i in range(len(S)):
count+=int(S[i])
return count
def bin_sum2(Y):
count=0
for i in range(len(Y)):
count+=int(Y[i])
return count
for i in range(1,LIM):
L[i]+=bin_sum(i)
def pop... | def popcount(x):
xb = bin(x)
return xb.count("1")
def solve(x, count_1):
temp = x %count_1
if(temp == 0):
return 1
else:
return 1 + solve(temp, popcount(temp))
n = int(input())
x = input()
x_b = int(x, 2)
mod = x.count("1")
xm1 = x_b %(mod+1)
if(mod != 1):
xm2 = x_b %(mod-1)
for ... | 1 | 8,271,369,539,352 | null | 107 | 107 |
import numpy as np
n = int(input())
s = np.array(input().split(), np.int64)
mod = 10 ** 9 + 7
res = 0
po2 = 1
for i in range(61):
bit = (s >> i) & 1
x = np.count_nonzero(bit)
y = n - x
res += x * y % mod * po2
res %= mod
po2 *= 2 % mod
print(res)
| import sys
X, Y = map(int, input().split())
mod = int(1e9) + 7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
# 組み合わせ(1e9+7で割る場合)
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % ... | 0 | null | 135,883,894,170,508 | 263 | 281 |
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
x,y=0,10**9
while y>x+1:
m = (x+y)//2
c=0
for i in l:
c+=(i-1)//m
if c<=k:
y=m
else:
x=m
print(y) | s=input()
for _ in range(int(input())):
a=input().split()
if a[0][0]=='p':print(s[int(a[1]):int(a[2])+1])
else:
t=a[3]if'p'==a[0][2]else s[int(a[1]):int(a[2])+1][::-1]
s=s[0:int(a[1])]+t+s[int(a[2])+1:] | 0 | null | 4,334,222,453,540 | 99 | 68 |
N=int(input())
S=input()
l=[]
for i in range(N-1):
if S[i]!=S[i+1]:
l.append(S[i])
l.append(S[N-1])
print(len(l)) | N, M = map(int, input().split(' '))
result = 0
if N > 1:
result += N * (N - 1) / 2
if M > 1:
result += M * (M - 1) / 2
print(int(result)) | 0 | null | 107,699,340,724,768 | 293 | 189 |
N, M = map(int, input().split())
A = list(set(map(int, input().split(" "))))
G = A.copy()
while not any(x % 2 for x in G):
G = [i // 2 for i in G]
if not all(x % 2 for x in G):
print(0)
exit(0)
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b //... | # coding: utf-8
a, b = map(str,input().split())
a = int(a)
b = int(b.replace(".", ""))
print(a*b//100) | 0 | null | 59,351,686,888,660 | 247 | 135 |
N, M = map(int, input().split())
A = list(map(int, input().split()))
A1 = sum(A)
if N - A1 >= 0:
print(N - A1)
else:
print("-1") | N, M = map(int, input().split())
A = map(int, input().split())
A_sum = sum(A)
if (N - A_sum) >= 0:
print(N - A_sum)
else:
print(-1) | 1 | 31,764,726,592,180 | null | 168 | 168 |
if sum(list(map(int,input().split())))>21:
print("bust")
else:
print("win")
| a,b,c= (int(x) for x in input().split())
A = int(a)
B = int(b)
C = int(c)
if A+B+C >= 22:
print("bust")
else:
print("win") | 1 | 118,451,192,268,710 | null | 260 | 260 |
(h,n),*t=[[*map(int,t.split())]for t in open(0)]
d=[0]*9**8
for i in range(h):d[i+1]=min(b+d[i-a+1]for a,b in t)
print(d[h]) | def chmin(dp, i, *x):
dp[i] = min(dp[i], *x)
INF = float("inf")
# dp[i] := min 消耗する魔力 to H -= i
h, n = map(int, input().split())
dp = [0] + [INF]*h
for _ in [None]*n:
a, b = map(int, input().split())
for j in range(h + 1):
chmin(dp, min(j + a, h), dp[j] + b)
print(dp[h]) | 1 | 81,035,956,075,840 | null | 229 | 229 |
k, a, b = map(int, open(0).read().split())
print("OK" if b // k * k >= a else "NG") | from bisect import bisect_right
N, M = map(int, input().split())
S = [N - i for i, s in enumerate(input()) if s == '0']
S = S[::-1]
ans = []
now = 0
while now < N:
i = bisect_right(S, now + M) - 1
if S[i] == now:
print('-1')
exit()
ans.append(S[i] - now)
now = S[i]
print(*ans[::-1])... | 0 | null | 82,478,821,548,800 | 158 | 274 |
import sys
import itertools
input = sys.stdin.readline
def SI(): return str(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
H, W, K = MI()
grid = [SI().rstrip('\n') for _ in range(H)]
n = H + W
ans = 0
for i in itertools.p... | import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *
sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7
def mint():
return map(int,input().split())
def... | 0 | null | 28,279,034,759,470 | 110 | 192 |
#coding:utf-8
import math
def isPrime(n):
if n == 2:
return True
elif n % 2 == 0:
return False
else:
for i in range(3,math.ceil(math.sqrt(n))+1,2):
if n % i == 0:
return False
return True
n = int(input())
c = 0
for i in range(n):
if isPrime(i... | N1=int(input())
array1=input().split()
N2=int(input())
array2=input().split()
c=0
for n2 in range(N2):
if array2[n2] in array1:
c+=1
print(c)
| 0 | null | 36,544,275,822 | 12 | 22 |
H,W=map(int,input().split())
import math
A=[0,math.ceil(W/2)]
if (H-1)*(W-1)!=0:
c=W*math.floor(H/2)+A[H%2]
else:
c=1
print(c) | #ABC 174 C
k = int(input())
sevens = [0] * k
sevens[0] = 7 % k
if k == 7 or k == 1:
print(1)
else:
for i in range(1, k):
new = (sevens[i - 1] * 10 + 7) % k
sevens[i] = new
if new == 0:
print(i + 1)
break
else:
print(-1) | 0 | null | 28,489,028,660,960 | 196 | 97 |
N,M = map(int,input().split())
A = [0]*M
B = [0]*M
for i in range(M):
A[i],B[i] = map(int,input().split())
from collections import deque
links = [[] for _ in range(N+1)]
for i in range(M):
links[A[i]].append(B[i])
links[B[i]].append(A[i])
result = [-1]*(N+1)
q = deque([1])
while q:
i = q.popleft()
... | n,m=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(m):
a,b=map(int,input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
sign=[-1]*n
sign[0]=0
work=[]
work_next=graph[0]
for x in work_next:
sign[x]=0
while work_next:
work=work_next[:]
work_next=[]
for x in ... | 1 | 20,709,063,645,664 | null | 145 | 145 |
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
acum=[[0]*w for _ in range(h)]
def count(x1,y1,x2,y2): #事前に求めた2次元累積和を用いて左上の点が(x1,y1)、右下の点(x2,y2)の長方形に含まれる1の個数を数える
ret=acum[y2][x2]
if x1!=0:
ret-=acum[y2][x1-1]
if y1!=0:
ret-=acum[y1-1][x2]
if x1!=0 and y1!=0:
ret+=acum[y1-1][x... | import sys
#UnionFindTreeクラスの定義
class UnionFind():
#クラスコンストラクタ
#selfはインスタンス自身
def __init__(self, n):
#親ノードを-1に初期化する
self.parents = [-1] * n
#根を探す(再帰関数)
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self... | 0 | null | 25,362,638,815,318 | 193 | 70 |
print(['bust','win'][sum(map(int,input().split()))<22]) | a, b, c = [int(x) for x in input().split()]
if a + b + c >= 22:
print("bust")
else:
print("win")
| 1 | 118,861,727,624,498 | null | 260 | 260 |
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for ... | s = list(input())
t = list(input())
leng = len(s)
if s[0:leng] == t[0:leng]:
print("Yes")
else:
print("No") | 0 | null | 91,474,359,951,520 | 288 | 147 |
def sep():
return map(int,input().strip().split(" "))
def lis():
return list(sep())
a,b=sep()
for i in range(1,10005):
if (i*8)//100==a and (i*10)//100==b:
print(i)
quit()
print(-1) | import sys
input = sys.stdin.readline
def check(s):
h = 0
for p in s:
b = h + p[0]
if b < 0: return False
h += p[1]
return True
N = int(input())
S = [input().strip() for i in range(N)]
total = 0
ps, ms = [], []
for s in S:
h, b = 0, 0
for c in s:
if c == '(':
... | 0 | null | 39,965,031,046,500 | 203 | 152 |
# input
n, q = map(int, raw_input().split())
procs = [raw_input().split() for i in xrange(n)]
procs = list(reversed(procs))
# procsessing
cnt, lack = 0, 1
while lack > 0:
lack = 0
tprocs = []
for i in xrange(n):
proc = procs.pop()
t = int(proc[1])
if t <= q:
cnt += t
... | n,x,y = map(int, input().split())
g = [0]*(n)
for i in range(1,n+1):
for j in range(1,i):
e = abs(y-i)+1+abs(x-j)
f = i-j
g[min(e,f)]+=1
for i in g[1:]:
print(i) | 0 | null | 22,210,935,756,412 | 19 | 187 |
D = 100000
N = int(raw_input())
for i in xrange(N):
D += D/20
if D % 1000 > 0:
D += 1000-D%1000
print D | from math import factorial as fac
x,y=map(int,input().split())
a=(2*y-x)/3
b=(2*x-y)/3
mod=10**9+7
if a>=0 and b>=0 and a==int(a) and b==int(b):
a=int(a)
b=int(b)
a1=1
a2=1
n3=10**9+7
for i in range(a):
a1*=a+b-i
a2*=i+1
a1%=n3
a2%=n3
a2=pow(a2,n3-2,n3)
print((a1*a2)%n3)
else:
print(... | 0 | null | 74,815,914,846,802 | 6 | 281 |
ans = 0
x, y = map(int,input().split())
ans += 100000*max((4-x),0)
ans += 100000*max((4-y),0)
if x == y == 1:
ans += 400000
print(ans) | while True:
card = str(input())
if card == '-':
break
S = int(input())
for i in range(S):
h = int(input())
card = card[h:] + card[:h]
print(card)
| 0 | null | 71,127,558,893,248 | 275 | 66 |
from itertools import combinations
N,M = map(int,input().split())
a=["A" for i in range(0,N)]
b=["B" for i in range(0,M)]
tmp1=(len(list(combinations(a,2))))
tmp2=(len(list(combinations(b,2))))
print(tmp1+tmp2) | N, M = map(int, input().split())
import math
print(math.comb(N, 2)+math.comb(M, 2)) | 1 | 45,462,651,441,570 | null | 189 | 189 |
i = 1
while True:
n = input()
if n != 0:
print 'Case %s: %s' % (str(i), str(n))
i = i + 1
else:
break | #coding:utf-8
#1_7_B 2015.4.5
while True:
n,x = map(int,input().split())
if n == x == 0:
break
count = 0
for i in range(1 , n + 1):
for j in range(1 , n + 1):
if i < j < (x - i - j) <= n:
count += 1
print(count) | 0 | null | 880,195,871,744 | 42 | 58 |
K=int(input());S=""
for i in range(K):
S=S+"ACL"
print(S) | n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [True] * n
for _ in range(m):
a, b = map(int, input().split())
if h[a-1] > h[b-1]:
ab[b-1] = False
elif h[b-1] > h[a-1]:
ab[a-1] = False
else:
ab[a-1] = False
ab[b-1] = False
print(ab.count(True)) | 0 | null | 13,558,094,371,000 | 69 | 155 |
import collections
hoge = collections.defaultdict(lambda: 'no')
num = int(input())
for _ in range(num):
command, key = input().split()
if command == 'insert':
hoge[key] = 'yes'
else:
print(hoge[key])
| def main():
n = int(input())
d = set([])
for i in range(n):
command, string = input().split()
if (command == 'insert'):
d.add(string)
elif (command == 'find'):
if string in d:
print('yes')
else:
print('no')
if __n... | 1 | 79,483,772,550 | null | 23 | 23 |
n = int(input())
x = 0
if n%2 == 0:
x = 1
print(n // 2 - x) |
n=int(input())
a=list(map(int,input().split()))
res=1000
for i in range(1,n):
if a[i]>a[i-1]:
t=(res//a[i-1])*a[i]+res%a[i-1]
res=t
print(res) | 0 | null | 80,484,630,157,752 | 283 | 103 |
while True:
m,f,r=map(int,input().split())
if m==f and f==r and r==-1:
break
if m==-1 or f==-1:
print("F")
elif (m+f)>=80:
print("A")
elif 65<=(m+f):
print("B")
elif 50<=(m+f) or r>=50:
print("C")
elif 30<=(m+f):
print("D")
else:
pr... | while(True):
m, f, r = map(int, input().split(" "))
if (m == -1) and (f == -1) and (r == -1):
exit()
if (m == -1) or (f == -1):
print("F")
elif (m + f >= 80):
print("A")
elif (m + f >= 65) and (m + f < 80):
print("B")
elif (m + f >= 50) and (m + f < 65):
... | 1 | 1,240,058,041,372 | null | 57 | 57 |
n = int(input())
sum = 0
for i in range(n + 1):
if i % 3 != 0 and i % 5 != 0 and i % 15 != 0:
sum += i
print(sum) | def input_int():
return(int(input()))
def input_int_list():
return(list(map(int,input().split())))
def input_int_map():
return(map(int,input().split()))
def run():
S = list(input())
left = [0] * (len(S) + 1)
right = [0] * (len(S) + 1)
for i in range(len(S)):
if S[i] == '<':
... | 0 | null | 95,834,647,323,172 | 173 | 285 |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 19