buggy stringlengths 1 618k | fixed stringlengths 16 618k | buggy_submission_id stringlengths 10 10 | fixed_submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | lang stringclasses 1
value | buggy_verdict stringclasses 2
values |
|---|---|---|---|---|---|---|
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
kita = [0.5*(i+1) for i in range(max(p)+1)]
kitai = [kita[i] for i in p]
maxn = 0
for i in range(n-k+1):
kt = 0
for j in range(k):
kt += kitai[i+j]
if kt > maxn:
maxn = kt
print(maxn) | n,k = map(int,input().split())
p = list(map(int,input().split()))
maxn = 0
sum = 0
for i in range(n-k+1):
if i == 0:
for j in range(k):
sum += p[j]
maxn = sum
else:
sum -= p[i-1]
sum += p[i+k-1]
if maxn < sum:
maxn = sum
print(0.5*(maxn+k)) | s335729433 | s222257577 | p02780 | python | Time Limit Exceeded |
#!/usr/bin/env python3
'''
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
shi = []
for i in range(max(p)):
if i == 0:
shi.append(1)
else:
shi.append(i+1+shi[i-1])
kitai = [shi[i]/(i+1) for i in range(len(shi))]
max = 0
for i in range(n-k+1):
kt = 0
... | n,k = map(int,input().split())
p = list(map(int,input().split()))
maxn = 0
sum = 0
for i in range(n-k+1):
if i == 0:
for j in range(k):
sum += p[j]
maxn = sum
else:
sum -= p[i-1]
sum += p[i+k-1]
if maxn < sum:
maxn = sum
print(0.5*(maxn+k)) | s863442912 | s222257577 | p02780 | python | Time Limit Exceeded |
#!/usr/bin/env python3
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]
shi = []
for i in range(max(p)):
if i == 0:
shi.append(1)
else:
shi.append(i+1+shi[i-1])
kitai = [shi[i]/(i+1) for i in range(len(shi))]
max = 0
for i in range(n-k+1):
kt = 0
for... | n,k = map(int,input().split())
p = list(map(int,input().split()))
maxn = 0
sum = 0
for i in range(n-k+1):
if i == 0:
for j in range(k):
sum += p[j]
maxn = sum
else:
sum -= p[i-1]
sum += p[i+k-1]
if maxn < sum:
maxn = sum
print(0.5*(maxn+k)) | s864375573 | s222257577 | p02780 | python | Time Limit Exceeded |
arr = [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]
k = int(input())
print(arr[k]) | arr = [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]
k = int(input())
print(arr[k-1]) | s070402696 | s581329764 | p02741 | python | Runtime Error |
n, a, b = map(int, input().split())
s = 'b'*a + 'r'*b
s_len = len(s)
ret = 0
ret = n // s_len * a
if n % s_len < a:
ret += n% s_len
else:
ret += a
print(ret) | n, a, b = map(int, input().split())
s_len = a+b
ret = 0
ret = n // s_len * a
if n % s_len < a:
ret += n% s_len
else:
ret += a
print(ret) | s421431626 | s921413414 | p02754 | python | Runtime Error |
s = input()
q = int(input())
rev = 0
for i in range(q):
tmp = input().split()
if len(tmp) == 1:
rev += 1
else:
if tmp[1] == '1':
if rev % 2 == 0:
s = tmp[2] + s
else:
s = s + tmp[2]
else:
if rev % 2 == 0:
s = s + tmp[2]
else:
s = tmp[2] + s
if re... | import collections
s = collections.deque(input())
q = int(input())
rev = 0
for i in range(q):
tmp = input().split()
if len(tmp) == 1:
rev += 1
else:
if tmp[1] == '1':
if rev % 2 == 0:
s.appendleft(tmp[2])
else:
s.append(tmp[2])
else:
if rev % 2 == 0:
s.append... | s789134634 | s209519535 | p02756 | python | Time Limit Exceeded |
n = (int)(input)
print((n-1)*n)//2 | n = (int)(input())
print((n-1)*n//2) | s744687276 | s154171079 | p02924 | python | Runtime Error |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s382902266 | s331846103 | p02756 | python | Runtime Error |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
cnt = 0
back = []
head = []
for idx, value in enumerate(Query):
if int(value[0]) == 1:
cnt +=1
else:
if int(value[1]) == 1:
if cnt % 2 != 0:
... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s643029179 | s331846103 | p02756 | python | Time Limit Exceeded |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
cnt = 0
last = []
head = []
for i in range(Qlen):
if int(Query[i][0]) == 1:
cnt +=1
else:
if int(Query[i][1]) == 1: #頭につける
if cnt % 2 != 0: #逆さ
... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s064850606 | s331846103 | p02756 | python | Time Limit Exceeded |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
cnt = 0
last = []
head = []
for i in range(Qlen):
if int(Query[i][0]) == 1:
cnt +=1
else:
if int(Query[i][1]) == 1: #頭につける
if cnt % 2 != 0: #逆さ
... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s022266197 | s331846103 | p02756 | python | Runtime Error |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
cnt = 0
last = []
head = []
for i in range(Qlen):
if int(Query[i][0]) == 1:
cnt +=1
else:
if int(Query[i][1]) == 1: #頭につける
if cnt % 2 != 0: #逆さ
... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s284623891 | s331846103 | p02756 | python | Runtime Error |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
cnt = 0
last = []
head = []
for i in range(Qlen):
if int(Query[i][0]) == 1:
cnt +=1
else:
if int(Query[i][1]) == 1: #頭につける
if cnt % 2 != 0: #逆さ
... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s647655725 | s331846103 | p02756 | python | Runtime Error |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
cnt = 0
for i in range(Qlen):
if int(Query[i][0]) == 1:
cnt +=1
else:
if int(Query[i][1]) == 1:
if cnt % 2 != 0:
Slist = Slist + [... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s336679895 | s331846103 | p02756 | python | Time Limit Exceeded |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
for i in range(Qlen):
if int(Query[i][0]) == 1:
Slist= Slist[::-1]
else:
if int(Query[i][1]) == 1:
Slist = [Query[i][2]] + Slist
else:
... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s738174982 | s331846103 | p02756 | python | Time Limit Exceeded |
S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
for idx, value in enumerate(Query):
if int(value[0]) == 1:
Slist= Slist[::-1]
else:
if int(value[1]) == 1:
Slist = [value[2]] + Slist
else:
Slist.a... | S = input()
Slist = [S[i] for i in range(len(S))]
Q = int(input())
Query = [list(input().split()) for i in range(Q)]
Qlen = len(Query)
reverse = False
back = []
head = []
for idx, value in enumerate(Query):
if value[0] == "1":
reverse ^= True
head, back = back, head
else:
if value[1] ==... | s554749755 | s331846103 | p02756 | python | Time Limit Exceeded |
H = int(input())
i = 1
result = 0
while True:
H //= 2
result += 2**i
i += 1
if H == 1:
break
print(result+1) | H = int(input())
i = 0
result = 0
while True:
result += 2**i
H //= 2
i += 1
if H == 0:
break
print(result) | s204845923 | s610690894 | p02786 | python | Time Limit Exceeded |
H = int(input())
i = 1
result = 0
while True:
H //= 2
result += 2**i
i += 1
if H == 1:
break
print(result+1) | H = int(input())
i = 0
result = 0
while True:
result += 2**i
H //= 2
i += 1
if H == 0:
break
print(result) | s367283771 | s610690894 | p02786 | python | Time Limit Exceeded |
H = int(input())
i = 0
while True:
H //= 2
i += 1
if H == 1:
break
result = 0
for i in range(i+1):
result += 2**i
print(result) | H = int(input())
i = 0
result = 0
while True:
result += 2**i
H //= 2
i += 1
if H == 0:
break
print(result) | s417904919 | s610690894 | p02786 | python | Time Limit Exceeded |
H = int(input())
i = 0
while True:
H //= 2
i += 1
if H == 1:
break
suretu = [None] * (i + 1)
for i in range(i+1):
suretu[i] = 2**i
result = sum(suretu)
print(result) | H = int(input())
i = 0
result = 0
while True:
result += 2**i
H //= 2
i += 1
if H == 0:
break
print(result) | s149765271 | s610690894 | p02786 | python | Time Limit Exceeded |
N = int(input())
array = list(map(int, input().split()))
cnt = 0
for i in range(0, N):
array2 = list(array[0:i+1])
array2.sort()
if array2[0] == array[i]:
cnt += 1
print(cnt) | N = int(input())
array = list(map(int, input().split()))
cnt = 1
minv = array[0]
for i in range(1, N):
if minv > array[i]:
minv = array[i]
cnt += 1
print(cnt) | s864231830 | s732631727 | p02791 | python | Time Limit Exceeded |
from functools import lru_cache
@lru_cache(maxsize = None)
N = int(input())
array = list(map(int, input().split()))
cnt = 0
for i in range(0, N):
for j in range(0, i):
if array[i] > array[j]:
break
else:
cnt += 1
print(cnt) | N = int(input())
array = list(map(int, input().split()))
cnt = 1
minv = array[0]
for i in range(1, N):
if minv > array[i]:
minv = array[i]
cnt += 1
print(cnt) | s306041313 | s732631727 | p02791 | python | Runtime Error |
N = int(input())
array = list(map(int, input().split()))
cnt = 0
for i in range(0, N):
flag = 0
for j in range(0, i):
if array[i] > array[j]:
break
else:
cnt += 1
print(cnt) | N = int(input())
array = list(map(int, input().split()))
cnt = 1
minv = array[0]
for i in range(1, N):
if minv > array[i]:
minv = array[i]
cnt += 1
print(cnt) | s976396711 | s732631727 | p02791 | python | Time Limit Exceeded |
N = int(input())
array = list(map(int, input().split()))
cnt = 0
for i in range(0, N):
flag = 0
for j in range(0, i):
if array[i] > array[j]:
flag = 1
break
if not flag == 1:
cnt += 1
print(cnt)
| N = int(input())
array = list(map(int, input().split()))
cnt = 1
minv = array[0]
for i in range(1, N):
if minv > array[i]:
minv = array[i]
cnt += 1
print(cnt) | s903151432 | s732631727 | p02791 | python | Time Limit Exceeded |
K, X = map(int, input().split())
total = 500 * K
if total >= X:
print("Yes")
else:
prnt("No") | K, X = map(int, input().split())
total = 500 * K
if total >= X:
print("Yes")
else:
print("No") | s149889745 | s148546725 | p02811 | python | Runtime Error |
X = int(input())
while True:
flag = 0
for i in range(2, X+1): #2からXまでのループ
if (X+1) % i == 0: #対象はX+1という数
flag = 1
break
if flag == 1:
X += 1
continue
break
print(X + 1)
| S, T = input().split()
print(T + S) | s026689255 | s832516631 | p02817 | python | Runtime Error |
S, T = input()
print(T + S) | S, T = input().split()
print(T + S) | s636343257 | s832516631 | p02817 | python | Runtime Error |
A, B, K = map(int, input().split())
count = 0
while count < K:
if A > 0:
A -= 1
count += 1
continue
elif B > 0:
B -= 1
count += 1
continue
else:
count += 1
continue
print(A, B) | A, B, K = map(int, input().split())
if A > K:
print(A-K, B)
if A <= K < A + B:
print(0, A+B-K)
if A + B <= K:
print(0, 0) | s581195028 | s408259367 | p02818 | python | Time Limit Exceeded |
A, B, K = map(int, input().split())
count = 0
while count < K:
if A > 0:
A -= 1
count += 1
continue
if B > 0:
B -= 1
count += 1
continue
if A == 0 and B == 0:
count += 1
continue
print(A, B) | A, B, K = map(int, input().split())
if A > K:
print(A-K, B)
if A <= K < A + B:
print(0, A+B-K)
if A + B <= K:
print(0, 0) | s113501145 | s408259367 | p02818 | python | Time Limit Exceeded |
N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K]*N
for i in range(Q):
who_answered[i] = int(input()) - 1
participants[who_answered[i]] += 1
for j in range(N):
participants[j] -= 1
for i in range(N):
if participants[i] > 0:
print('Yes')
else:
pr... | N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K-Q]*N
for i in range(Q):
who_answered[i] = int(input()) - 1
participants[who_answered[i]] += 1
for i in range(N):
if participants[i] > 0:
print('Yes')
else:
print('No') | s137244727 | s377451779 | p02911 | python | Time Limit Exceeded |
N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K]*N
for i in range(Q):
who_answered[i] = int(input()) - 1
for who in who_answered:
for i in range(N):
participants[i] -= 1
participants[who] += 1
for i in range(N):
if participants[i] > 0:
print('Yes')
... | N, K, Q = map(int, input().split())
who_answered = [None]*Q
participants = [K-Q]*N
for i in range(Q):
who_answered[i] = int(input()) - 1
participants[who_answered[i]] += 1
for i in range(N):
if participants[i] > 0:
print('Yes')
else:
print('No') | s743741507 | s377451779 | p02911 | python | Time Limit Exceeded |
N = int(input())
masu = list(map(int, input().split()))
masu2 = [None] * N
cnt_max = 0
for i in range(N):
cnt = 0
for j in range(i, N-1):
if masu[j] < masu[j+1]:
break
cnt += 1
masu2[i] = cnt
print(max(masu2)) | N = int(input())
masu = list(map(int, input().split()))
cnt = 0
masu2 = []
for i in range(N-1):
if masu[i] < masu[i+1]:
masu2.append(cnt)
cnt = 0
else:
cnt += 1
else:
masu2.append(cnt)
print(max(masu2)) | s385405939 | s591998191 | p02923 | python | Time Limit Exceeded |
N = int(input())
masu = list(map(int, input().split()))
cnt_max = 0
for i in range(N):
cnt = 0
for j in range(i, N-1):
if masu[j] < masu[j+1]:
break
cnt += 1
if cnt_max < cnt:
cnt_max = cnt
print(cnt_max) | N = int(input())
masu = list(map(int, input().split()))
cnt = 0
masu2 = []
for i in range(N-1):
if masu[i] < masu[i+1]:
masu2.append(cnt)
cnt = 0
else:
cnt += 1
else:
masu2.append(cnt)
print(max(masu2)) | s674839986 | s591998191 | p02923 | python | Time Limit Exceeded |
N = int(input())
job = [list(map(int, input().split())) for i in range(N)]
job.sort(key = lambda x: x[1]
time = 0
flag = 0
for i in range(N):
time += job[i][0]
if time > job[i][1]:
flag = 1
if flag == 0:
print('Yes')
else:
print('No') | from operator import itemgetter
N = int(input())
job = [list(map(int, input().split())) for i in range(N)]
job.sort(key = itemgetter(1))
time = 0
flag = 0
for i in range(N):
time += job[i][0]
if time > job[i][1]:
flag = 1
if flag == 0:
print('Yes')
else:
print('No') | s610944230 | s728348375 | p02996 | python | Runtime Error |
from operatpr import itemgetter
N = int(input())
job = [list(map(int, input().split())) for i in range(N)]
job.sort(key = itemgetter(1))
time = 0
flag = 0
for i in range(N):
time += job[i][0]
if time > job[i][1]:
flag = 1
print(flag)
if flag == 0:
print('Yes')
else:
print('No') | from operator import itemgetter
N = int(input())
job = [list(map(int, input().split())) for i in range(N)]
job.sort(key = itemgetter(1))
time = 0
flag = 0
for i in range(N):
time += job[i][0]
if time > job[i][1]:
flag = 1
if flag == 0:
print('Yes')
else:
print('No') | s458942928 | s728348375 | p02996 | python | Runtime Error |
X, H, x, y = map(int, input().split())
S = X * H
max_small = S / 2
print(max_small, end=' ')
if x == w/2 and y == H/2:
print('1')
else:
print('0') | X, H, x, y = map(int, input().split())
S = X * H
max_small = S / 2
print(max_small, end=' ')
if x == (X/2) and y == (H/2):
print('1')
else:
print('0') | s198698716 | s344241930 | p03001 | python | Runtime Error |
N, M = map(int, input().split())
a = [False] * (N+1)
for i in range(M):
a[int(input())] = True
memo = [None] * (N+1)
memo[0] = 0 #0番目にたどり着く方法は0通りと定義する。
memo[1] = 1 if not a[1] else 0
if a[2] != True:
if memo[1] == 0:
memo[2] = 1
else:
memo[2] = 2
else:
memo[2] = 0
for i in range(3, N+1):
memo[i]... | N, M = map(int, input().split())
a = [False] * (N+1)
for i in range(M):
a[int(input())] = True
memo = [None] * (N+1)
memo[0] = 1 #0番目にたどり着く方法は1通りと定義する。
memo[1] = 1 if not a[1] else 0
for i in range(2, N+1):
memo[i] = memo[i-1] + memo[i-2] if not a[i] else 0
print(memo[N] % 1000000007) | s655637697 | s635558891 | p03013 | python | Runtime Error |
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
def d(n: int) -> int:
if n == N or n == N-1:
return 1
if not(n+1 in a) and not(n+2 in a):
return d(n+1) + d(n+2)
elif n+1 in a and not (n+2 in a):
return d(n+2)
else:
return d(n+1)
flag = 0
for i... | N, M = map(int, input().split())
a = [False] * (N+1)
for i in range(M):
a[int(input())] = True
memo = [None] * (N+1)
memo[0] = 1 #0番目にたどり着く方法は1通りと定義する。
memo[1] = 1 if not a[1] else 0
for i in range(2, N+1):
memo[i] = memo[i-1] + memo[i-2] if not a[i] else 0
print(memo[N] % 1000000007) | s268511032 | s635558891 | p03013 | python | Runtime Error |
S = str(input())
if "hi" = S:
print("Yes")
elif "hihi" = S:
print("Yes")
elif "hihihi" = S:
print("Yes")
elif "hihihihi" = S:
print("Yes")
else:
print("No")
| S = str(input())
if "hi" == S:
print("Yes")
elif "hihi" == S:
print("Yes")
elif "hihihi" == S:
print("Yes")
elif "hihihihi" == S:
print("Yes")
elif "hihihihihi" == S:
print("Yes")
else:
print("No") | s491058808 | s258740641 | p02747 | python | Runtime Error |
Card=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
for i in range(N):
for j in range(3):
for k in range(3):
if A[j][k]==b[i]:
A[j][k]=0
if (A[0][0]==A[0][1]==A[0][2]==0) or (A[1][0]==A[1][1]==A[1][2]==0) or (A[2][0]==A[2][1]=... | card=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
for i in range(N):
for j in range(3):
for k in range(3):
if card[j][k]==b[i]:
card[j][k]=0
if (card[0][0]==card[0][1]==card[0][2]==0) or (card[1][0]==card[1][1]==card[1][2]==... | s351358878 | s745553995 | p02760 | python | Runtime Error |
a = int(input())
array = list(map(int, input().split()))
ans = "APPROVED"
nu = 0
for i in range a:
nu = array[i]
if nu % 2 == 0:
if nu % 3 == 0 or nu % 5 == 0:
pass
else:
ans = "DENIED"
print(ans) | a = int(input())
array = list(map(int, input().split()))
ans = "APPROVED"
nu = 0
for i in range (a):
nu = array[i]
if nu % 2 == 0:
if nu % 3 == 0 or nu % 5 == 0:
pass
else:
ans = "DENIED"
print(ans)
| s293944092 | s559612467 | p02772 | python | Runtime Error |
import collections
N = int(input())
s = [input() for i in range(N)]
counter = collections.Counter(s)
max_k_list = [kv[0] for kv in dict(counter).items() if kv[1] == max(dict(counter).values())]
for i in range (len(max_k_list)):
print(sorted(max_k_list)[i]) | import collections
N = int(input())
s = [input() for i in range(N)]
counter = collections.Counter(s)
max = max(dict(counter).values())
keys = [k for k, v in dict(counter).items() if v == max]
ans = sorted(keys)
for i in range (len(keys)):
print(ans[i]) | s323054361 | s503048679 | p02773 | python | Time Limit Exceeded |
N = int(input())
S = str(input())
cou = 0
for i in range(N):
if i <= N-2:
if S[i] == "A" and S[i+1] == "B" and S[i+2]== "C":
cou += 1
print(cou) | N = int(input())
S = str(input())
cou = 0
for i in range(N-2):
if S[i:i+3] == "ABC":
cou += 1
print(cou)
| s881845955 | s753450657 | p02812 | python | Runtime Error |
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q)
print(p-q) | import itertools
N = int(input())
LN = []
for i in range(N):
LN.append(i+1)
LLN=list(itertools.permutations(LN))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
print(abs(LLN.index(tuple(P))-LLN.index(tuple(Q)))) | s995672230 | s823348164 | p02813 | python | Runtime Error |
permutations = list(itertools.permutations(range(1, N+1)))
p = permutations.index(P)
q = permutations.index(Q) | import itertools
N = int(input())
LN = []
for i in range(N):
LN.append(i+1)
LLN=list(itertools.permutations(LN))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
print(abs(LLN.index(tuple(P))-LLN.index(tuple(Q)))) | s256740532 | s823348164 | p02813 | python | Runtime Error |
N, M= map(int, input().split())
a =[str(input()) for _ in range(M)]
DP = [0]*(N+2)
num = 1000000007
DP[0] = 1
for i in range(N):
if str(i) in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
DP[i+2] += DP[i]
print(DP[-2]%num)
| N, M, = map(int, input().split())
a = set([int(input()) for _ in range(M)])
DP = [0]*(N+2)
num = 1000000007
DP[0] = 1
for i in range(N):
if i in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
DP[i+2] += DP[i]
print(DP[-2]%num)
| s794929199 | s436069369 | p03013 | python | Time Limit Exceeded |
N, M= map(int, input().split())
a =[str(input()) for _ in range(M)]
DP = [0]*(N+2)
num = 1000000007
DP[0] = 1
for i in range(N):
if str(i) in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
DP[i+2] += DP[i]
print(DP[-2]%num) | N, M, = map(int, input().split())
a = set([int(input()) for _ in range(M)])
DP = [0]*(N+2)
num = 1000000007
DP[0] = 1
for i in range(N):
if i in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
DP[i+2] += DP[i]
print(DP[-2]%num)
| s992005227 | s436069369 | p03013 | python | Time Limit Exceeded |
N, M= map(int, input().split())
a =[str(input()) for _ in range(M)]
DP = [0]*(N+1)
num = 1000000007
DP[0] = 1
for i in range(N):
if str(i) in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
if i < N-1:
DP[i+2] += DP[i]
print(DP[-1]%num) | N, M, = map(int, input().split())
a = set([int(input()) for _ in range(M)])
DP = [0]*(N+2)
num = 1000000007
DP[0] = 1
for i in range(N):
if i in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
DP[i+2] += DP[i]
print(DP[-2]%num)
| s387068505 | s436069369 | p03013 | python | Time Limit Exceeded |
N, M= map(int, input().split())
a =[str(input()) for _ in range(M)]
DP = [0]*(N+1)
num = 1000000007
DP[0] = 1
for i in range(N):
if str(i) in a:
DP[i] = 0
else:
if i < N:
DP[i+1] += DP[i] % num
if i < N-1:
DP[i+2] += DP[i] % num
print(DP[-1]%num) | N, M, = map(int, input().split())
a = set([int(input()) for _ in range(M)])
DP = [0]*(N+2)
num = 1000000007
DP[0] = 1
for i in range(N):
if i in a:
DP[i] = 0
else:
DP[i] = DP[i] % num
if i < N:
DP[i+1] += DP[i]
DP[i+2] += DP[i]
print(DP[-2]%num)
| s866797903 | s436069369 | p03013 | python | Time Limit Exceeded |
N = int(input())
h = list(map(int, input().split()))
DP = [10000]*7
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(N-1):
DP[i+1] = abs(h[i+1]-h[i])+DP[i]
if i > 0:
DP[i+1] = min(abs(h[i+1]-h[i])+DP[i], abs(h[i+1]-h[i-1])+DP[i-1])
print(DP[N-1]) | N = int(input())
h = list(map(int, input().split()))
DP = [10000]*N
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(N-1):
DP[i+1] = abs(h[i+1]-h[i])+DP[i]
if i > 0:
DP[i+1] = min(abs(h[i+1]-h[i])+DP[i], abs(h[i+1]-h[i-1])+DP[i-1])
print(DP[N-1])
| s195891358 | s175110347 | p03160 | python | Runtime Error |
N = int(input())
h = list(map(int, input().split()))
DP = [10000]*7
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(N-1):
DP[i+1] = abs(h[i+1]-h[i])+DP[i]
if i > 0:
DP[i+1] = min(abs(h[i+1]-h[i])+DP[i], abs(h[i+1]-h[i-1])+DP[i-1])
print(DP) | N = int(input())
h = list(map(int, input().split()))
DP = [10000]*N
DP[0] = 0
DP[1] = abs(h[1]-h[0])
for i in range(N-1):
DP[i+1] = abs(h[i+1]-h[i])+DP[i]
if i > 0:
DP[i+1] = min(abs(h[i+1]-h[i])+DP[i], abs(h[i+1]-h[i-1])+DP[i-1])
print(DP[N-1])
| s681776850 | s175110347 | p03160 | python | Runtime Error |
N, K= map(int, input().split())
h = list(map(int, input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N-1):
for j in range(min(K,N-1-i)):
DP[i+j+1] = min(DP[i+j+1], DP[i] + abs(h[i+j+1] - h[i]))
print(DP[-1])
| N, K= map(int, input().split())
h = list(map(int, input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N-1):
L = N-1-i
for j in range(min(K,L)):
DP[i+j+1] = min(DP[i+j+1], DP[i] + abs(h[i+j+1] - h[i]))
print(DP[-1])
| s453127447 | s667551928 | p03161 | python | Time Limit Exceeded |
N, K= map(int, input().split())
h = list(map(int, input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N-1):
for j in range(min(K,N-1-i)):
DP[i+j+1] = min(DP[i+j+1], DP[i] + abs(h[i+j+1] - h[i]))
print(DP[-1]) | N, K= map(int, input().split())
h = list(map(int, input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N-1):
L = N-1-i
for j in range(min(K,L)):
DP[i+j+1] = min(DP[i+j+1], DP[i] + abs(h[i+j+1] - h[i]))
print(DP[-1])
| s665631888 | s667551928 | p03161 | python | Time Limit Exceeded |
def temp(H):
ans = - H *0.006
return ans
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
TE = list(map(temp,H))
TLA = list(map(lambda x: abs(T + x -A) , TE))
ans=TLA.index(min(TLA))
print(ans+1)
| import math
n = int(input())
counter = False
#for n in range (0,100):
for i in range (math.ceil((n+1) / 4) ):
for j in range (math.ceil((n+1) / 7) ):
#print(n, i,j)
if i*4 + j*7 == n:
counter = True
if counter == True:
print("Yes")
else:
print("No")
| s726972179 | s433791106 | p03285 | python | Runtime Error |
D, N = map(int,input().split())
if D == 2:
if N < 100:
print(N*10000)
else:
print(1010000)
elif D == 1:
if N < 100:
print(N*100)
else:
print(10100)
else:
if N < 100:
print(N)
else:
print(101)
| def time2(n):
ans = 0
while n % 2 == 0:
n /= 2
ans += 1
return ans
N = int(input())
LA = list(map(int, input().split()))
sum = sum(map(time2, LA))
print(sum)
| s912410814 | s272652665 | p03325 | python | Runtime Error |
import math
N, X = map(int, input().split())
s = 0
cake =[]
for i in range (N):
s = int(input())
cake.append(s)
ans = N + (X - sum(cake)) / min(cake)
print(math.floor(ans))
| s = input()
count = 700
for i in range (len(s)):
if s[i] == 'o':
count += 100
else:
pass
print(count)
| s014214077 | s327214192 | p03369 | python | Runtime Error |
A, B, C =map(int, input().split())
if A + B => C:
print("Yes")
else:
print("No")
| A, B, C =map(int, input().split())
if A + B < C:
print("No")
else:
print("Yes")
| s290261778 | s331864898 | p03407 | python | Runtime Error |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
cout << 48-a << endl;
}
| M = int(input())
print(48-M) | s242494605 | s779965038 | p03473 | python | Runtime Error |
R, G = map(int, input().split())
print(2*G-R) | R = int(input())
G = int(input())
print(2*G-R) | s755739141 | s230801572 | p03563 | python | Runtime Error |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, A;
cin >> N >> A;
cout << N*N-A << endl;
}
| N = int(input())
A = int(input())
print(N**2-A) | s979492754 | s962750486 | p03597 | python | Runtime Error |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, A;
cin >> N >> A;
cout << N*N-A << endl;
}
| N = int(input())
A = int(input())
print(N**2-A) | s769927602 | s962750486 | p03597 | python | Runtime Error |
N = str(input())
ans = "None"
for l in "abcdefghijklmnopqrstuvwxyz":
if l not in N:
ans = letter
break
print(ans) | N = str(input())
ans = None
for l in "abcdefghijklmnopqrstuvwxyz":
if l not in N:
ans = l
break
print(ans) | s450412210 | s616733503 | p03624 | python | Runtime Error |
N = input()
ans = None
for l in "abcdefghijklmnopqrstuvwxyz":
if l not in N:
ans = letter
break
print(ans) | N = str(input())
ans = None
for l in "abcdefghijklmnopqrstuvwxyz":
if l not in N:
ans = l
break
print(ans) | s355740031 | s616733503 | p03624 | python | Runtime Error |
8 8
1 2
3 4
1 5
2 8
3 7
5 2
4 1
6 8 | N, M = map(int,input().split())
a = []
for i in range(M):
K,S = map(int, input().split())
a.append(K)
a.append(S)
for i in range(N):
print(a.count(i+1)) | s632310765 | s831211622 | p03720 | python | Runtime Error |
a, b, c = map(int, input().split())
if 4*a*b < (c-a-b)**2 ans c > a+b:
print("Yes")
else:
print("No") | a, b, c = map(int, input().split())
if 4*a*b < (c-a-b)**2 and c > a+b:
print("Yes")
else:
print("No")
| s892489063 | s377649824 | p02743 | python | Runtime Error |
a, b, c = map(int, input().split())
if 4*a*b < (c-a-b)**2 ans c > a+b:
print("Yes")
else:
print("No") | a, b, c = map(int, input().split())
if 4*a*b < (c-a-b)**2 and c > a+b:
print("Yes")
else:
print("No")
| s320195739 | s377649824 | p02743 | python | Runtime Error |
a, b, c = map(int, input().split())
if a == b and a != c:
print("Yes")
elif a == c and a != b:
print("Yes")
elif b == c and a != b:
print("Yes")
ese:
print("No")
| a, b, c = map(int, input().split())
if a == b and a != c:
print("Yes")
elif a == c and a != b:
print("Yes")
elif b == c and a != b:
print("Yes")
else:
print("No")
| s149767949 | s156331672 | p02771 | python | Runtime Error |
N, M = map(int, input().split())
p = [0]*M
k = [""] * M
for i in range(M):
p[i], k[i] = input().split()
p[i] = int(p[i])
ans = [0]*N
pen = [0]*N
accept = 0
pena = 0
for i in range(M):
if k[i] == "WA" and ans[p[i]] == 0:
pen[p[i]] += 1
elif k[i] == "AC" and ans[p[i]] == 0:
pena +=... | N, M = map(int, input().split())
p = [0] * M
k = [""] * M
for i in range(M):
p[i], k[i] = input().split()
p[i] = int(p[i])-1
ans = [0]*N
pen = [0]*N
accept = 0
pena = 0
for i in range(M):
if k[i] == "WA" and ans[p[i]] == 0:
pen[p[i]] += 1
elif k[i] == "AC" and ans[p[i]] == 0:
pen... | s559364863 | s314219373 | p02802 | python | Runtime Error |
if a%2 == 0:
print("0.5")
else:
print((a//2+1)/a) | a = int(input())
if a%2 == 0:
print("0.5")
else:
print((a//2+1)/a) | s783126735 | s626241290 | p02897 | python | Runtime Error |
N=int(input())
print(int(N*(N-1)//2)) | s = input()
t = input()
ans = 0
for i in range(len(s)):
if s[i] == t[i]:
ans+=1
print(ans) | s602174886 | s017524711 | p02921 | python | Runtime Error |
N=int(input())
if N%2 == 0:
print(round(N/2*(N-1)))
else:
print(round((N-1)/2*N))) | N=int(input())
print(int(N*(N-1)//2)) | s780624922 | s691329694 | p02924 | python | Runtime Error |
n = int(input())
if n < 10:
print(n)
elif n < 100:
print("9")
elif n < 1000:
print(n-90)
elif n < 10000:
print("909")
elif n < 100000
print(n-9090)
else:
print("90909") | n = int(input())
if n < 10:
print(n)
elif n < 100:
print("9")
elif n < 1000:
print(n-90)
elif n < 10000:
print("909")
elif n < 100000:
print(n-9090)
else:
print("90909") | s015319518 | s588305739 | p02952 | python | Runtime Error |
L, R = map(int, input().split())
minimam = 2019
for i in range(L, R):
for j in range(i+1, R+1):
if (i*j) % 2019 < minimam:
minimam = (i*j) % 2019
print(minimam) | L, R = map(int, input().split())
minimam = 2019
for i in range(L, min(R, L+2019)):
for j in range(i+1, min(R+1, L+2019)):
if (i*j) % 2019 < minimam:
minimam = (i*j) % 2019
print(minimam) | s369187061 | s185014894 | p02983 | python | Time Limit Exceeded |
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i in range(N):
for j in range(N):
if i <= j:
B[i] += A[j]*(-1)**(j-i)
else:
B[i] += A[j]*(-1)**(i-j+1)
print(B[i])
| N = int(input())
A = list(map(int, input().split()))
ans = 0
for j in range(N):
ans += A[j]*(-1)**j
print(ans)
for i in range(1, N):
ans = 2*A[i-1]-ans
print(ans)
| s614179865 | s177684867 | p02984 | python | Time Limit Exceeded |
N, M = map(int, input().split())
a = [0]*M
for i in range(M):
a[i] = int(input())
now = 0
ans = 1
j = 0
for i in range(M):
if now == a[i] - 1:
now = a[i] + 1
elif now == a[i]:
ans = 0
break
else:
j = (a[i] - 1) - now
k1 = 0
k2 = 1
k3 = 1
f... | N, M = map(int, input().split())
a = [0]*M
for i in range(M):
a[i] = int(input())
now = 0
ans = 1
j = 0
for i in range(M):
if now == a[i] - 1:
now = a[i] + 1
elif now == a[i]:
ans = 0
break
else:
j = (a[i] - 1) - now
k1 = 0
k2 = 1
k3 = 1
f... | s958267785 | s381764015 | p03013 | python | Runtime Error |
n = int(input())
a = [0]*n
a = list(map(int, input().split()))
a.sort()
i = 0
while a[i+1] < -a[i]:
a[i+1] *= -1
a[i] *= -1
a.sort()
sum = 0
for i in range(n):
sum += a[i]
print(sum) | n = int(input())
a = [0]*n
a = list(map(int, input().split()))
a.sort()
i = 0
tmp = 0
while i + 1 < n and a[i+1] < 0:
a[i] *= -1
a[i+1] *= -1
i += 2
a.sort()
if a[1] < -a[0]:
a[1] *= -1
a[0] *= -1
sum = 0
for i in range(n):
sum += a[i]
print(sum) | s529544569 | s954353847 | p03062 | python | Time Limit Exceeded |
s=input()
i=0;
found=False;
h=0;
k=0;
if(len(s)%2!=0):
found=False
else:
while(i<len(s)):
if(s[i]=='h' or s[i]=='i'):
if(i%2==0 and s[i]=='h'):
found=True
if(i%2!=0 and s[i]=='i'):
found=True
if(i%2!=0 and s[i]=='h'):
found=False
if(i%2==0 and s[i]=='i'):
found=False
else:
found... | s=input()
i=0;
found=False;
h=0;
k=0;
if(len(s)%2!=0):
found=False
else:
while(i<len(s)):
if(s[i]=='h' or s[i]=='i'):
if(i%2==0 and s[i]=='h'):
found=True
if(i%2!=0 and s[i]=='i'):
found=True
if(i%2!=0 and s[i]=='h'):
found=False
if(i%2==0 and s[i]=='i'):
found=False
else:
found... | s222307505 | s737629357 | p02747 | python | Runtime Error |
H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)
DP = [0]*(H+A_max)
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP[i] = dp
print(... | H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)
DP = [0]*(H+A_max)
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP[i] = dp
print(... | s507855800 | s700682654 | p02787 | python | Time Limit Exceeded |
H, N = (int(i) for i in input().split())
A = []
B = []
for i in range(N):
a, b = (int(j) for j in input().split())
A.append(a)
B.append(b)
A_max = max(A)
DP = [0]
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP.appe... | H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)
DP = [0]*(H+A_max)
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP[i] = dp
print(... | s651602016 | s700682654 | p02787 | python | Time Limit Exceeded |
A = []
B = []
for i in range(N):
a, b = (int(j) for j in input().split())
A.append(a)
B.append(b)
A_max = max(A)
DP = [0]
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP.append(dp)
print(min(DP[H:])) | H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)
DP = [0]*(H+A_max)
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP[i] = dp
print(... | s848169989 | s700682654 | p02787 | python | Runtime Error |
import math
input_func = input
H, N = (int(i) for i in input_func().split())
A = []
B = []
for i in range(N):
a, b = (int(j) for j in input_func().split())
A.append(a)
B.append(b)
A_max = max(A)
DP = [0]
for i in range(1, H+A_max):
dp = math.inf
for a, b in zip(A,B):
if i-a>=0:
... | H, N = (int(i) for i in input().split())
A = [0]*N
B = [0]*N
for i in range(N):
A[i], B[i] = (int(j) for j in input().split())
A_max = max(A)
DP = [0]*(H+A_max)
for i in range(1, H+A_max):
dp = float('inf')
for a, b in zip(A,B):
if i-a>=0:
dp = min(dp, DP[i-a] + b)
DP[i] = dp
print(... | s794969744 | s700682654 | p02787 | python | Runtime Error |
import math
def main():
def lcm(x, y):
return (x * y) // math.gcd(x, y)
A,B = map(int, input().split())
print(lcm(A,B))
if __name__ == '__main__':
main() | def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(x, y):
return (x * y) // gcd(x, y)
def main():
A,B = map(int, input().split())
print(lcm(A,B))
if __name__ == '__main__':
main() | s603926055 | s633305928 | p02831 | python | Runtime Error |
def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
A,B=map(int, input().split())
gcd_ab = gcd(A,B)
ans={1}
i = 2
while i <= gcd_ab:
if gcd_ab % i == 0:
ans.add(i)
gcd_ab //= i
else:
i += 1
print(len(ans))
if __name__... | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr... | s029630152 | s733648908 | p02900 | python | Time Limit Exceeded |
def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
A,B=map(int, input().split())
gcd_ab = gcd(A,B)
ans={1}
i = 2
while (A>=i and B>=i) and (i <= gcd_ab):
if A % i == 0 and B % i == 0:
ans.add(i)
A //= i
B //= i
gcd_ab... | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr... | s734191197 | s733648908 | p02900 | python | Time Limit Exceeded |
def main():
A,B=map(int, input().split())
ans={1}
i = 2
while (A>=i and B>=i):
if A % i == 0 and B % i == 0:
ans.add(i)
A //= i
B //= i
else:
i += 1
print(len(ans))
if __name__ == '__main__':
main() | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr... | s578848516 | s733648908 | p02900 | python | Time Limit Exceeded |
def gcd(a, b):
while b:
a, b = b, a % b
return a
def main():
A,B=map(int, input().split())
gcd_ab = gcd(A,B)
ans={1}
i = 2
while (A>=i and B>=i) and (i <= gcd_ab):
if A % i == 0 and B % i == 0:
ans.add(i)
A //= i
B //= i
gcd_ab... | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr... | s451806328 | s733648908 | p02900 | python | Time Limit Exceeded |
import fractions as math
def main():
A,B=map(int, input().split())
gcd_ab = math.gcd(A,B)
ans={1}
i = 2
while (A>=i and B>=i) and (i <= gcd_ab):
if A % i == 0 and B % i == 0:
ans.add(i)
A //= i
B //= i
gcd_ab = math.gcd(A,B)
else:
... | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr... | s646499918 | s733648908 | p02900 | python | Time Limit Exceeded |
import fractions as math
def main():
A,B=map(int, input().split())
gcd_ab = math.gcd(A,B)
ans={1}
i = 2
while (A>1 and B>1) and (i <= gcd_ab):
if A % i == 0 and B % i == 0:
ans.add(i)
A //= i
B //= i
gcd_ab = math.gcd(A,B)
else:
... | def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr... | s473277654 | s733648908 | p02900 | python | Time Limit Exceeded |
from collections import deque
def main():
N=int(input())
A = [deque(map(int, input().split())) for _ in range(N)]
days = 0
changed = True
played = set()
while changed:
played.clear()
changed = False
for i in range(N-1):
if len(A[i]) == 0:
cont... | S=input()
T=input()
ans=0
for s,t in zip(S,T):
if s==t:
ans+=1
print(ans)
| s921781939 | s158917727 | p02921 | python | Runtime Error |
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s293026899 | s876253828 | p02941 | python | Time Limit Exceeded |
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
while A!=B:
b = True
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
if B[i] > d > 0:
b = False
c ... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s839267210 | s876253828 | p02941 | python | Time Limit Exceeded |
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
while A!=B:
b = True
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
if B[i] > d > 0:
b = False
c ... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s429287089 | s876253828 | p02941 | python | Time Limit Exceeded |
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
while A!=B:
b = True
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
if B[i] > d:
b = False
c = B[... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s943864280 | s876253828 | p02941 | python | Runtime Error |
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
while A!=B:
b = True
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
if B[i] > d:
b = False
c = B[... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s663565447 | s876253828 | p02941 | python | Runtime Error |
from collections import deque
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
q = deque()
cq = deque()
q.appendleft(B)
cq.appendleft(0)
while len(q) > 0:
b = q.pop()
c = cq.pop()
if b == A:
print(c)
... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s256243510 | s876253828 | p02941 | python | Time Limit Exceeded |
from collections import deque
def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
q = deque()
cq = deque()
q.appendleft(B)
cq.appendleft(0)
while len(q) > 0:
b = q.pop()
c = cq.pop()
if b == A:
print(c)
... | def main():
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
count = 0
prev_count = -1
while count!=prev_count:
prev_count = count
for i in range(N):
d = B[i-1 if i>=1 else N-1] + B[i+1 if i<N-1 else 0]
c = (B[i]-A[i]) //... | s706140341 | s876253828 | p02941 | python | Time Limit Exceeded |
import collections
N=int(input())
S=[collections.Counter(list(input())) for i in range(N)]
count = 0
for i in range(len(S)):
for j in range(i+1, len(S)):
if S[i] == S[j]:
count += 1
print(count)
| N=int(input())
S=["".join(sorted(input())) for i in range(N)]
dic = {}
for s in S:
if s in dic.keys():
dic[s] += 1
else:
dic[s] = 1
count = 0
for k in dic.keys():
c = dic[k]
count += (c * (c - 1)) // 2
print(count)
| s275427354 | s190888549 | p02947 | python | Time Limit Exceeded |
from math import factorial
def ncr(n,r):
return int((factorial(n)) / (factorial(r)) / (factorial(n - r)))
DIV=10**9+7
N,K=map(int, input().split())
R=N-K
for i in range(1,K+1):
print(ncr(R+1, i) * ncr(K-1,i-1) % DIV)
| # 組み合わせの計算は下記サイトから引用
# https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
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
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元... | s322036323 | s640409183 | p02990 | python | Runtime Error |
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
A,B,C,D=map(int, input().split())
CD = lcm(C, D)
c_first = 0
c_last = 0
d_first = 0
d_last = 0
cd_first = 0
cd_last = 0
for i in range(A,B+1,1):
if c_first == 0 and i % C == 0:
c_first = i // C
if d_first ==... | def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
A,B,C,D=map(int, input().split())
CD = lcm(C, D)
c_first = 0
c_last = 0
d_first = 0
d_last = 0
cd_first = 0
cd_last = 0
c_first = (A-1) // C
c_last = B // C
d_first = (A-1) // D
d_last = B // D
cd_first = (A-1) // C... | s408993578 | s154103164 | p02995 | python | Time Limit Exceeded |
OK = 0
BRO = 1
N,M=map(int, input().split())
Broken=[int(input()) for i in range(M)]
#K = "".join(list(BRO if i in Broken else OK for i in range(N+1)))
K = list(0 for i in range(N+1))
for i in range(M):
K[Broken[i]] = 1
if BRO+BRO in K:
print(0)
else:
c=[0 for i in range(N+1)]
if K[N-1]==OK:
c[1]=1
if... | OK = 0
BRO = 1
MOD = 1000000007
N,M=map(int, input().split())
Broken=[int(input()) for i in range(M)]
#K = "".join(list(BRO if i in Broken else OK for i in range(N+1)))
K = list(0 for i in range(N+1))
for i in range(M):
K[Broken[i]] = 1
dp=[0 for i in range(N+1)]
dp[0]=1
for i in range(N):
for j in range(i+1,mi... | s913878774 | s783968940 | p03013 | python | Runtime Error |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.