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 |
|---|---|---|---|---|---|---|
import fractions
import functools
MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
def lcm(a, b):
gcd = fractions.gcd(a, b)
return (a * b) // gcd
LCM = functools.reduce(lcm, A)
ans = sum([(LCM // a) % MOD for a in A]) % MOD
print(ans)
| import functools
import fractions
MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
L = functools.reduce(lambda a, b: a // fractions.gcd(a, b) * b, A) % MOD
ans = 0
for a in A:
ans += L * pow(a, MOD - 2, MOD)
ans %= MOD
print(ans)
| s900374177 | s518692965 | p02793 | python | Time Limit Exceeded |
import fractions
import functools
MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
def lcm(a, b):
gcd = fractions.gcd(a, b)
return (a * b) // gcd
LCM = functools.reduce(lcm, A)
ans = sum([(LCM // a) % MOD for a in A]) % MOD
print(ans)
| import functools
import fractions
MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
L = functools.reduce(lambda a, b: a // fractions.gcd(a, b) * b, A) % MOD
ans = 0
for a in A:
ans += L * pow(a, MOD - 2, MOD)
ans %= MOD
print(ans)
| s409934270 | s518692965 | p02793 | python | Time Limit Exceeded |
MOD = 10**9 + 7
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
A_r = list(reversed(A))
factorial = {0: 1, 1: 1}
for i in range(2, N + 1):
factorial[i] = factorial[i - 1] * i
ans = 0
for i, j in zip(A, A_r):
if N < K:
break
C = (factorial[N - 1] / factorial[... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s291720379 | s691882062 | p02804 | python | Runtime Error |
import itertools
import operator
MOD = 10**9 + 7
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
A_r = list(reversed(A))
factorial = [1] + list(itertools.accumulate(range(1, N + 1), operator.mul)) # factorial[n] = n!
ans = 0
for i, j in zip(A, A_r):
if N < K:
break... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s443231352 | s691882062 | p02804 | python | Runtime Error |
import itertools
import operator
MOD = 10**9 + 7
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
A_r = list(reversed(A))
factorial = [1] + list(itertools.accumulate(range(1, N + 1), operator.mul)) # factorial[n] = n!
ans = 0
for i, j in zip(A, A_r):
if N < K:
break... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s144338540 | s691882062 | p02804 | python | Runtime Error |
MOD = 10**9 + 7
def comb(n,k,p):
"""power_funcを用いて(nCk) mod p を求める"""
from math import factorial
if n<0 or k<0 or n<k:
return 0
if n==0 or k==0:
return 1
a=factorial(n) %p
b=factorial(k) %p
c=factorial(n-k) %p
return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def p... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s746340339 | s691882062 | p02804 | python | Time Limit Exceeded |
MOD = 10**9 + 7
def framod(n, mod, a=1):
for i in range(1,n+1):
a=a * i % mod
return a
def power(n, r, mod):
if r == 0: return 1
if r%2 == 0:
return power(n*n % mod, r//2, mod) % mod
if r%2 == 1:
return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
a=framod(n, m... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s106692356 | s691882062 | p02804 | python | Runtime Error |
import sys
from operator import mul
from functools import reduce
sys.setrecursionlimit(100000000000)
MOD = 10**9 + 7
def cmb(n,r):
r = min(n-r, r)
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
N, K = [int(i) for i i... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s607310160 | s691882062 | p02804 | python | Runtime Error |
from operator import mul
from functools import reduce
MOD = 10**9 + 7
def cmb(n,r):
r = min(n-r, r)
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input()... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s076406556 | s691882062 | p02804 | python | Runtime Error |
from operator import mul
from functools import reduce
MOD = 10**9 + 7
def cmb(n,r):
r = min(n-r, r)
if r == 0:
return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1, r + 1))
return over // under
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input()... | N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10 ** 9 + 7
def combination(mod=MOD):
fact = [1] * (N + 1)
inv_fact = [1] * (N + 1)
r = 1
for i in range(1, N + 1):
fact[i] = r = r * i % mod
inv_fact[N] = r = pow(fact[N], mod - 2, mod)
for i... | s980768553 | s691882062 | p02804 | python | Time Limit Exceeded |
def main():
N, A, B = [int(i) for i in input().split()]
diff = B - A
if diff % 2 == 0:
ans = diff // 2
else:
ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 (diff - 1) // 2)
print(ans)
if __name__ == '__main__':
main()
| def main():
N, A, B = [int(i) for i in input().split()]
diff = B - A
if diff % 2 == 0:
ans = diff // 2
else:
ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 + (diff - 1) // 2)
print(ans)
if __name__ == '__main__':
main()
| s158682603 | s894744399 | p02823 | python | Runtime Error |
def main():
N, A, B = [int(i) for i in input().split()]
diff = B - A
if diff % 2 == 0:
ans = diff // 2
else:
ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 (diff - 1) // 2)
print(ans)
if __name__ == '__main__':
main()
| def main():
N, A, B = [int(i) for i in input().split()]
diff = B - A
if diff % 2 == 0:
ans = diff // 2
else:
ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 + (diff - 1) // 2)
print(ans)
if __name__ == '__main__':
main()
| s818579800 | s894744399 | p02823 | python | Runtime Error |
def index(l, x, default=None):
if x in l:
return l.index(x)
else:
return default
def main():
N = int(input())
a = [int(i) for i in input().split()]
b = []
ans = -1
tmp_index = 0
for i in range(N):
if index(a[tmp_index:], i + 1) is None:
break
... | def main():
N = int(input())
A = [int(i) for i in input().split()]
counter = 0
for a in A:
if a == counter + 1:
counter += 1
if counter == 0:
ans = -1
else:
ans = N - counter
print(ans)
if __name__ == "__main__":
main()
| s149125728 | s737473968 | p02832 | python | Time Limit Exceeded |
import itertools
MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
def main():
ans = sum([a ^ b for (a, b) in itertools.combinations(A, 2)]) % MOD
print(ans)
if __name__ == '__main__':
main()
| import itertools
MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
def main():
count_1 = [0] * 61
for i in range(60):
tmp = 0
for j, a in enumerate(A):
tmp += (a >> i) & 1
count_1[i] += tmp
ans = 0
for i, c1 in enumerate(count_1):
c0 = ... | s933703157 | s262222250 | p02838 | python | Time Limit Exceeded |
a, b, c, d = [int(i) for i in input().split()]
n = {i for i in range(a, b+1) if i % c != 0 and i % d != 0}
ans = len(n)
print(ans) | import fractions
def anti_division(n, d1, d2):
g = fractions.gcd(d1, d2)
l = (d1 * d2) // g
ret = n - (n//d1 + n//d2) + n//l
return ret
a, b, c, d = [int(i) for i in input().split()]
ans = anti_division(b, c, d) - anti_division(a - 1, c, d)
print(ans) | s324627427 | s330803042 | p02995 | python | Time Limit Exceeded |
a, b, c, d = [int(i) for i in input().split()]
n = {i for i in range(a, b+1) if i % c != 0 and i % d != 0}4 9 2 3
ans = len(n)
print(ans) | import fractions
def anti_division(n, d1, d2):
g = fractions.gcd(d1, d2)
l = (d1 * d2) // g
ret = n - (n//d1 + n//d2) + n//l
return ret
a, b, c, d = [int(i) for i in input().split()]
ans = anti_division(b, c, d) - anti_division(a - 1, c, d)
print(ans) | s132351159 | s330803042 | p02995 | python | Runtime Error |
import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = {int(input()) for _ in range(m)}
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = {int(input()) for _ in range(m)}
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | s149234520 | s737959087 | p03013 | python | Runtime Error |
import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = {int(input()) for _ in range(m)}
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | s760404878 | s737959087 | p03013 | python | Time Limit Exceeded |
import sys
input = sys.stdin.readline
MOD = 1000000007
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
steps[next_] += steps[now]
... | import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = {int(input()) for _ in range(m)}
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | s804350317 | s737959087 | p03013 | python | Time Limit Exceeded |
MOD = 1000000007
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
steps[next_] += steps[now]
steps[next_] %= MOD
print(steps[-1]... | import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = {int(input()) for _ in range(m)}
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | s192250546 | s737959087 | p03013 | python | Time Limit Exceeded |
MOD = 1000000007
n, m = [int(i) for i in input().split()]
a = [int(input()) for _ in range(m)]
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
steps[next_] += steps[now]
steps[next_] %= MOD
print(steps[-1]... | import sys
input = sys.stdin.readline
MOD = 1000000007
def main():
n, m = [int(i) for i in input().split()]
a = {int(input()) for _ in range(m)}
steps = [0] * (n + 1)
steps[0] = 1
for now in range(n):
for next_ in range(now + 1, min(now + 2, n) + 1):
if next_ not in a:
... | s216644901 | s737959087 | p03013 | python | Time Limit Exceeded |
S = input()
head = int(S[:2])
tail = int(s[2:])
ans = "NA"
if 1 <= head <= 12:
if 1 <= tail <= 12:
ans = "AMBIGUOUS"
else:
"YYMM"
elif 1 <= tail <= 12:
ans = "MMYY"
print(ans) | S = input()
head = int(S[:2])
tail = int(S[2:])
ans = "NA"
if 1 <= head <= 12:
if 1 <= tail <= 12:
ans = "AMBIGUOUS"
else:
ans = "MMYY"
elif 1 <= tail <= 12:
ans = "YYMM"
print(ans)
| s327491322 | s154247741 | p03042 | python | Runtime Error |
import math
n, k = [int(i) for i in input().split()]
prob = 0
for i in range(1, n + 1):
if i >= k:
exp = 0
else:
exp = math.ceil(math.log2(k) - math.log2(i))
prob += (1 / n) * (1 / 2) ** exp
print(prob)
| import math
n, k = [int(i) for i in input().split()]
prob = 0
for i in range(1, n + 1):
if i >= k:
exp = 0
else:
exp = math.ceil(math.log2(k) - math.log2(i))
prob += (1 / n) * (1 / 2) ** exp
print(prob)
| s472088058 | s704438823 | p03043 | python | Runtime Error |
from itertools import product
from collections import deque
H, W = [int(i) for i in input().split()]
grid = [list(input()) for _ in range(H)]
reached = [[0] * W for _ in range(H)]
queue = deque()
for y, x in product(range(H), range(W)):
if grid[y][x] == "#":
queue.append((y, x, 0))
if len(queue) == H * W... | from itertools import product
from collections import deque
H, W = [int(i) for i in input().split()]
grid = [list(input()) for _ in range(H)]
reached = [[0] * W for _ in range(H)]
queue = deque()
for y, x in product(range(H), range(W)):
if grid[y][x] == "#":
queue.append((y, x, 0))
if len(queue) == H * W... | s418084024 | s373604859 | p03053 | python | Time Limit Exceeded |
import fractions
import functools
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n):
m = functools.reduce(fractions.gcd, a[:i] + a[i+1:])
ans = max(ans, m)
print(ans)
| import fractions
import functools
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
# a_0 ~ a_i の 最大公約数
l_gcd = [0]
l_append = l_gcd.append
# a_i ~ a_n-1 の最大公約数
r_gcd = []
r_append = r_gcd.append
for i, a_i in enumerate(a):
if i == 0:
l_append(a_i)
else:
l_append(fractions.gcd(a... | s560729192 | s498381659 | p03061 | python | Time Limit Exceeded |
N = int(input())
H = [int(i) for i in input().split()]
viewable = []
max_h = h[0]
for h in H:
if h >= max_h:
viewable.append(1)
else:
viewable.append(0)
max_h = max(max_h, h)
ans = sum(viewable)
print(ans) | N = int(input())
H = [int(i) for i in input().split()]
viewable = []
max_h = H[0]
for h in H:
if h >= max_h:
viewable.append(1)
else:
viewable.append(0)
max_h = max(max_h, h)
ans = sum(viewable)
print(ans) | s956663315 | s945777387 | p03072 | python | Runtime Error |
n, q = [int(i) for i in input().split()]
s = input()
count = [0] * (n + 1)
for i in range(n):
count[i+1] += count[i]
if s[i:i+2] == "AC":
count[i+1] += 1
for i in range(q):
l, r = [int(i) for i in input().split()]
print(count(r-1) - count(l-1))
| n, q = [int(i) for i in input().split()]
s = input()
count = [0] * (n + 1)
for i in range(n):
count[i+1] += count[i]
if s[i:i+2] == "AC":
count[i+1] += 1
for i in range(q):
l, r = [int(i) for i in input().split()]
print(count[r-1] - count[l-1])
| s776627096 | s763155350 | p03087 | python | Runtime Error |
import re
import sys
input = sys.stdin.readline
n, q = [int(i) for i in input().strip().split()]
s = input().strip()
for i in range(q):
l, r = [int(i) for i in input().strip().split()]
l -= 1
substr = s[l:r]
print(len(re.findall(r"AC", substr)))
| n, q = [int(i) for i in input().split()]
s = input()
count = [0] * (n + 1)
for i in range(n):
count[i+1] += count[i]
if s[i:i+2] == "AC":
count[i+1] += 1
for i in range(q):
l, r = [int(i) for i in input().split()]
print(count[r-1] - count[l-1])
| s488157566 | s763155350 | p03087 | python | Time Limit Exceeded |
import re
n, q = [int(i) for i in input().split()]
s = input()
for i in range(q):
l, r = [int(i) for i in input().split()]
l -= 1
substr = s[l:r]
print(len(re.findall(r"AC", substr)))
| n, q = [int(i) for i in input().split()]
s = input()
count = [0] * (n + 1)
for i in range(n):
count[i+1] += count[i]
if s[i:i+2] == "AC":
count[i+1] += 1
for i in range(q):
l, r = [int(i) for i in input().split()]
print(count[r-1] - count[l-1])
| s479212271 | s763155350 | p03087 | python | Time Limit Exceeded |
from fractions import gcd
A, B, K = [int(i) for i in input()]
count = 0
for i in range(gcd(a, b), 0, -1):
if A % i == 0 and B % i == 0:
count += 1
if count == K:
print(i)
break
| from fractions import gcd
A, B, K = [int(i) for i in input().split()]
count = 0
for i in range(gcd(A, B), 0, -1):
if A % i == 0 and B % i == 0:
count += 1
if count == K:
print(i)
break
| s114641291 | s277700308 | p03106 | python | Runtime Error |
from fractions import gcd
A, B, K = [int(i) for i in input()]
gcd_ = gcd(A, B)
count = 0
flg = 0
for n in range(gcd_, 0, -1):
if flg:
break
if A % n == 0 and B % n == 0:
count += 1
if count == K:
print(n)
flg = 1
break
| from fractions import gcd
A, B, K = [int(i) for i in input().split()]
count = 0
for i in range(gcd(A, B), 0, -1):
if A % i == 0 and B % i == 0:
count += 1
if count == K:
print(i)
break
| s470352329 | s277700308 | p03106 | python | Runtime Error |
h, w, _ = [int(i) for i in input()]
ans = h * w // 2
print(ans)
| h, w, _ = [int(i) for i in input().split()]
ans = h * w // 2
print(ans)
| s129162499 | s619669861 | p03145 | python | Runtime Error |
n, w = [int(i) for i in input().split()]
wv = [[int(i) for i in input().split()] for _ in range(n)]
# i番目以降の品物で、容量がjのときの価値の最大値
def value(i, j):
# もう品物がない
if i == n:
ret = 0
# 品物が入らない
elif j < wv[i][0]:
ret = value(i+1, j)
# 品物を入れない場合と入れる場合
else:
ret = max(value(i+1, j)... | import collections
Item = collections.namedtuple("Item", ("weight", "value"))
def main():
N, W = [int(i) for i in input().split()]
items = [Item(int(i), int(j))for (i, j) in [input().split() for _ in range(N)]]
# 選択肢をn番目の品物まで、重さを最大wとしたときの価値の最大値
dp = [[0] * (W + 1) for _ in range(N + 1)]
# n番目の品... | s668934277 | s075890501 | p03163 | python | Time Limit Exceeded |
import collections
MAX_N = 110
MAX_V = 100100
Item = collections.namedtuple("Item", ("weight", "value"))
def main():
N, W = [int(i) for input().split()]
items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]]
dp = [[float('inf')] * MAX_V for _ in range(MAX_N)]
dp[0][0] = 0... | import collections
MAX_N = 110
MAX_V = 100100
Item = collections.namedtuple("Item", ("weight", "value"))
def main():
N, W = [int(i) for i in input().split()]
items = [Item(int(i), int(j)) for (i, j) in [input().split() for _ in range(N)]]
dp = [[float('inf')] * MAX_V for _ in range(MAX_N)]
dp[0][0... | s804137752 | s994404373 | p03164 | python | Runtime Error |
import sys
sys.setrecursionlimit(2 << 30)
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
x, y = [int(i) for i in input().split()]
al[x-1].add(y-1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
ret = 0
for nv in al[v]:
ret = max... | import sys
sys.setrecursionlimit(2 << 28)
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
x, y = [int(i) for i in input().split()]
al[x-1].add(y-1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
ret = 0
for nv in al[v]:
ret = max... | s230768497 | s020792332 | p03166 | python | Runtime Error |
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
x, y = [int(i) for i in input().split()]
al[x-1].add(y-1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
ret = 0
for nv in al[v]:
ret = max(ret, rec(nv) + 1)
dp[v] = ret
retu... | import sys
sys.setrecursionlimit(2 << 28)
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
x, y = [int(i) for i in input().split()]
al[x-1].add(y-1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
ret = 0
for nv in al[v]:
ret = max... | s997526977 | s020792332 | p03166 | python | Runtime Error |
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
x, y = [int(i) for i in input().split()]
al[x-1].add(y-1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
ret = 0
for nv in al[v]:
ret = max(ret, rec(nv) + 1)
dp[v] = ret
retu... | import sys
sys.setrecursionlimit(2 << 28)
n, m = [int(i) for i in input().split()]
al = [set() for _ in range(n)]
for _ in range(m):
x, y = [int(i) for i in input().split()]
al[x-1].add(y-1)
dp = [-1] * n
def rec(v):
if dp[v] != -1:
return dp[v]
ret = 0
for nv in al[v]:
ret = max... | s561014318 | s020792332 | p03166 | python | Runtime Error |
import collections
City = collections.namedtuple("City", ("number", "pref", "year"))
n, m = [int(i) for i in input().split()]
cities = []
for i in range(m):
pref, year = input().split()
city = City(i, int(pref), int(year))
cities.append(city)
id_numbers = []
cities.sort(key=lambda x: x.year)
cities.sort(ke... | import collections
City = collections.namedtuple("City", ("number", "pref", "year"))
n, m = [int(i) for i in input().split()]
cities = []
for i in range(m):
pref, year = input().split()
city = City(i, int(pref), int(year))
cities.append(city)
id_numbers = []
cities.sort(key=lambda x: x.year)
cities.sort(ke... | s933661088 | s276611798 | p03221 | python | Runtime Error |
N, T = [int(i) for i in input().split()]
min_cost = 1001
for c, t in [input().split() for _ in range(N)]
c, t = int(c), int(t)
if t > T:
continue
min_cost = min(min_cost, c)
ans = min_cost if min_cost < 1001 else "TLE"
print(ans) | N, T = [int(i) for i in input().split()]
min_cost = 1001
for c, t in [input().split() for _ in range(N)]:
c, t = int(c), int(t)
if t > T:
continue
min_cost = min(min_cost, c)
ans = min_cost if min_cost < 1001 else "TLE"
print(ans) | s402465165 | s116434927 | p03239 | python | Runtime Error |
s = inpit()
ans = 0
for c in s:
if c == "+":
ans += 1
else:
ans -= 1
print(ans) | s = input()
ans = 0
for c in s:
if c == "+":
ans += 1
else:
ans -= 1
print(ans)
| s681349983 | s510913618 | p03315 | python | Runtime Error |
s = input()
k = int(input())
ss = set()
for i in range(len(s)):
for j in range(i+1, len(s)+1):
ss.add(s[i:j])
for i, s in enumerate(sorted(ss), start=1):
if i == k:
print(s)
break
| s = input()
k = int(input())
ss = set()
for i in range(len(s)):
for j in range(i+1, min(i+6, len(s)+1)):
ss.add(s[i:j])
for i, s in enumerate(sorted(ss), start=1):
if i == k:
print(s)
break
| s403811258 | s571376976 | p03353 | python | Time Limit Exceeded |
x, y = int(input())
if x < y:
print("<")
elif x > y:
print(">")
else:
print("=") | x, y = input().split()
if x < y:
print("<")
elif x > y:
print(">")
else:
print("=") | s577664091 | s843929315 | p03547 | python | Runtime Error |
print(max(int(input())-int(input()), 0)) | x, t = [int(i) for i in input().split()]
ans = max(x-t, 0)
print(ans) | s249329005 | s491850415 | p03609 | python | Runtime Error |
N = int(input())
a = {i+1: int(input()) for i in range(N)}
on = 1
ans = -1
count = 0
while True:
on = a[on]
count += 1
if on == 2:
ans = count
break
if on == 1:
break
print(ans)
| N = int(input())
a = {i+1: int(input()) for i in range(N)}
on = 1
history = {1}
ans = -1
count = 0
while True:
on = a[on]
count += 1
if on == 2:
ans = count
break
if on in history:
break
history.add(on)
print(ans)
| s597298802 | s362580770 | p03680 | python | Time Limit Exceeded |
x, y = [int(i) for i in input().split()]
if x == y == 2:
print("Yes")
elif x in (4, 6, 9, 11) and y in (4, 6, 9, 11):
print("Yes")
elif x in (1, 3, 5, 7, 8, 10, 12) and y in (1, 3, 5, 7, 8, 10, 12):
print("Yes")
else:
print("No") | x, y = [int(i) for i in input().split()]
if x == y == 2:
print("Yes")
elif x in (4, 6, 9, 11) and y in (4, 6, 9, 11):
print("Yes")
elif x in (1, 3, 5, 7, 8, 10, 12) and y in (1, 3, 5, 7, 8, 10, 12):
print("Yes")
else:
print("No")
| s236558126 | s593071141 | p03711 | python | Runtime Error |
from itertools import zip_longest
odds, evens = [input() for _ in range(2)]
if len(odds) > len(evens):
evens.append("")
chars = []
for odd, even in zip_longest(odd, even, fillvalue=""):
chars.append(odd)
chars.append(even)
ans = "".join(chars)
print(ans) | from itertools import zip_longest
odds, evens = [input() for _ in range(2)]
chars = []
for odd, even in zip_longest(odds, evens, fillvalue=""):
chars.append(odd)
chars.append(even)
ans = "".join(chars)
print(ans) | s847919172 | s238795437 | p03760 | python | Runtime Error |
odds, evens = input().split()
chars = []
for odd, even in zip(odds, evens):
chars.append(odd)
chars.append(even)
ans = "".join(chars)
print(ans) | from itertools import zip_longest
odds, evens = [input() for _ in range(2)]
chars = []
for odd, even in zip_longest(odds, evens, fillvalue=""):
chars.append(odd)
chars.append(even)
ans = "".join(chars)
print(ans) | s307907299 | s238795437 | p03760 | python | Runtime Error |
from itertools import permutations
N, M = [int(i) for i in input().split()]
adjacent = [[0] * N for _ in range(N)]
for _ in range(N):
a, b = [int(i) for i in input().split()]
adjacent[a - 1][b - 1] = 1
adjacent[b - 1][a - 1] = 1
ans = 0
for p in permutations(range(N), r=N):
if p[0] != 0:
conti... | import itertools
def main():
n, m = [int(i) for i in input().split()]
path_matrix = [[False] * n for _ in range(n)]
for _ in range(m):
a, b = [int(i) for i in input().split()]
a -= 1
b -= 1
path_matrix[a][b] = True
path_matrix[b][a] = True
ans = 0
for path ... | s413331363 | s276404053 | p03805 | python | Runtime Error |
from itertools import permutations
N, M = [int(i) for i in input().split()]
adjacent = [[0] * N for _ in range(N)]
for _ in range(N):
a, b = [int(i) for i in input().split()]
adjacent[a - 1][b - 1] = 1
adjacent[b - 1][a - 1] = 1
ans = 0
for p in permutations(range(1, N), r=N-1):
start, end = 0, p[0]
... | import itertools
def main():
n, m = [int(i) for i in input().split()]
path_matrix = [[False] * n for _ in range(n)]
for _ in range(m):
a, b = [int(i) for i in input().split()]
a -= 1
b -= 1
path_matrix[a][b] = True
path_matrix[b][a] = True
ans = 0
for path ... | s136277475 | s276404053 | p03805 | python | Runtime Error |
import sys
sys.setrecursionlimit(10 ** 9)
def dfs(v, n, graph, visited):
all_visited = 1
for i in range(n):
if visited[i] == 0:
all_visited = 0
break
if all_visited:
return 1
n_paths = 0
for i in range(0, n):
if not graph[v][i]:
conti... | import itertools
def main():
n, m = [int(i) for i in input().split()]
path_matrix = [[False] * n for _ in range(n)]
for _ in range(m):
a, b = [int(i) for i in input().split()]
a -= 1
b -= 1
path_matrix[a][b] = True
path_matrix[b][a] = True
ans = 0
for path ... | s009329329 | s276404053 | p03805 | python | Runtime Error |
import sys
sys.setrecursionlimit(10 ** 9)
def dfs(v, n, graph, visited):
all_visited = 1
for i in range(n):
if visited[i] == 0:
all_visited = 0
break
if all_visited:
return 1
n_paths = 0
for i in range(0, n):
if not graph[v][i]:
conti... | import itertools
def main():
n, m = [int(i) for i in input().split()]
path_matrix = [[False] * n for _ in range(n)]
for _ in range(m):
a, b = [int(i) for i in input().split()]
a -= 1
b -= 1
path_matrix[a][b] = True
path_matrix[b][a] = True
ans = 0
for path ... | s285920431 | s276404053 | p03805 | python | Runtime Error |
def dfs(v, n, graph, visited):
all_visited = 1
for i in range(n):
if visited[i] == 0:
all_visited = 0
break
if all_visited:
return 1
n_paths = 0
for i in range(0, n):
if not graph[v][i]:
continue
if visited[i]:
conti... | import itertools
def main():
n, m = [int(i) for i in input().split()]
path_matrix = [[False] * n for _ in range(n)]
for _ in range(m):
a, b = [int(i) for i in input().split()]
a -= 1
b -= 1
path_matrix[a][b] = True
path_matrix[b][a] = True
ans = 0
for path ... | s147363631 | s276404053 | p03805 | python | Runtime Error |
from collections import deque, defaultdict
from functools import reduce
from operator import mul
N = int(input())
MOD = 10**9 + 7
# 素数の一覧
prime_nums = set([2]) if N > 1 else set()
prime_nums = prime_nums.union(set(range(3, N+1, 2)))
queue = deque([i for i in prime_nums if i*i <= N+1])
while queue:
num = queue.pop... | from collections import deque, defaultdict
from functools import reduce
from operator import mul
N = int(input())
MOD = 10**9 + 7
# 素数の一覧
prime_nums = set([2]) if N > 1 else set()
prime_nums = prime_nums.union(set(range(3, N+1, 2)))
queue = deque([i for i in prime_nums if i*i <= N+1])
while queue:
num = queue.pop... | s853632090 | s144515059 | p03830 | python | Runtime Error |
_, s, _ = input().split()
print(f"A{s[0]}C") | _, s, _ = input().split()
print("A{}C".format(s[0])) | s870392836 | s408546764 | p03860 | python | Runtime Error |
N, _ = [int(i) for i in input().split()]
S = [input() for _ in range(N)]
ans = "".join(sorted(s))
print(ans) | N, _ = [int(i) for i in input().split()]
S = [input() for _ in range(N)]
ans = "".join(sorted(S))
print(ans) | s821024177 | s284506286 | p04044 | python | Runtime Error |
# -*- coding: utf-8 -*-
def readInts():
return [int(s) for s in input().split(" ")]
MOD = 10 ** 9 + 7
def main():
S = input()
dp = [[0 for _ in range(13)] for _a in range(len(S)+1)]
coef = 1
dp[0][0] = 1
for i in range(len(S)):
c = S[len(S) - 1 - i]
if c == '?':
for n in range(10):
... | # -*- coding: utf-8 -*-
def readInts():
return [int(s) for s in input().split(" ")]
MOD = 10 ** 9 + 7
def main():
S = input()
dp = [[0 for _ in range(13)] for _a in range(len(S)+1)]
coef = 1
dp[0][0] = 1
for i in range(len(S)):
c = S[len(S) - 1 - i]
if c == '?':
for n in range(10):
... | s698662820 | s193517837 | p02960 | python | Time Limit Exceeded |
# -*- coding: utf-8 -*-
def readInts():
return [int(s) for s in input().split(" ")]
def root(groups, n):
while groups[n] != n:
n = groups[n]
return n
def union(groups, x, y):
rx = root(groups, x)
ry = root(groups, y)
if rx != ry:
groups[ry] = rx
def main():
N, M = readInts()
groups = [i for ... | # -*- coding: utf-8 -*-
def readInts():
return [int(s) for s in input().split(" ")]
def root(groups, n):
i = n
while groups[i] != i:
i = groups[i]
groups[n] = i
return i
def union(groups, x, y):
rx = root(groups, x)
ry = root(groups, y)
if rx != ry:
groups[ry] = rx
def main():
N, M = readI... | s669776356 | s632666034 | p03045 | python | Time Limit Exceeded |
# -*- coding: utf-8 -*-
def readInts():
return [int(s) for s in input().split(" ")]
def gcd(m, n):
m, n = max(m, n), min(m, n)
if n == 0:
return m
return gcd(n, m % n)
def gcds(A):
ret = A[0]
for n in A[1:]:
ret = gcd(ret, n)
return ret
def main():
N = readInts()[0]
A = readInts()
m = 1... | # -*- coding: utf-8 -*-
def readInts():
return [int(s) for s in input().split(" ")]
def gcd(m, n):
m, n = max(m, n), min(m, n)
if n == 0:
return m
return gcd(n, m % n)
def gcds(A):
ret = A[0]
for n in A[1:]:
ret = gcd(ret, n)
return ret
def main():
N = readInts()[0]
A = readInts()
lgcds... | s406763721 | s296744182 | p03061 | python | Time Limit Exceeded |
S = input()
Q = int(input())
rev_flag = False
for i in range(Q):
in_ = input()
if len(in_) > 1:
_, f, c = in_.split()
f = int(f)
if rev_flag:
if f==1:
S = S + c
elif f==2:
S = c+S
else:
if f==2:
S = S + c
elif f==1:
S = c + S
else... | S = input()
Q = int(input())
rev_flag = False
heads = []
tails = []
for i in range(Q):
in_ = input()
if len(in_) > 1:
_, f, c = in_.split()
f = int(f)
if rev_flag:
if f==1:
#S = S + c
tails.append(c)
elif f==2:
#S = c+S
heads.append(c)
else:
... | s345922804 | s241278426 | p02756 | python | Time Limit Exceeded |
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
negative_A = - np.array(A)
ki_idx = [i for i in range(N) if i % 2 == 1]
A_sum = sum(A)
ans = []
for idx, dam in enumerate(A):
ans.append(str(A_sum - 2*sum(A[ki_idx])))
A = np.roll(A, -1)
print(" ".join(ans)) | N = int(input())
A = list(map(int, input().split()))
irekae_sum = 0
for idx, a in enumerate(A):
if idx % 2 == 0:
irekae_sum += a
else:
irekae_sum -= a
ans = []
for i in range(N):
ans.append(str(irekae_sum))
irekae_sum = - irekae_sum + 2*A[i]
print(" ".join(ans)... | s420059329 | s969818980 | p02984 | python | Time Limit Exceeded |
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
negative_A = - np.array(A)
gu_idx = [i for i in range(N) if i % 2 == 0]
ki_idx = [i for i in range(N) if i % 2 == 1]
ans = []
for idx, dam in enumerate(A):
# print(A[gu_idx])
ans.append(str(sum(A[gu_idx]) + sum(negative_A[ki_idx... | N = int(input())
A = list(map(int, input().split()))
irekae_sum = 0
for idx, a in enumerate(A):
if idx % 2 == 0:
irekae_sum += a
else:
irekae_sum -= a
ans = []
for i in range(N):
ans.append(str(irekae_sum))
irekae_sum = - irekae_sum + 2*A[i]
print(" ".join(ans)... | s825424747 | s969818980 | p02984 | python | Time Limit Exceeded |
N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
card = []
card_num = []
for a in A_list:
card.append(a)
card_num.append(1)
for _ in range(M):
B, C = list(map(int, input().split()))
card.append(C)
card_num.append(B)
union = zip(card, card_num)
sorted_union ... | N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
card = []
card_num = []
for a in A_list:
card.append(a)
card_num.append(1)
for _ in range(M):
B, C = list(map(int, input().split()))
card.append(C)
card_num.append(B)
union = zip(card, card_num)
sorted_un... | s539685645 | s935971990 | p03038 | python | Runtime Error |
import numpy as np
N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
card_num = np.zeros(10**9+1)
max_num = -1
for a in A_list:
card_num[a] += 1
if max_num < a:
max_num = a
for _ in range(M):
B, C = list(map(int, input().split()))
card_num[C] += B
if max_num <... | N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
card = []
card_num = []
for a in A_list:
card.append(a)
card_num.append(1)
for _ in range(M):
B, C = list(map(int, input().split()))
card.append(C)
card_num.append(B)
union = zip(card, card_num)
sorted_un... | s700921378 | s935971990 | p03038 | python | Runtime Error |
N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
cards = A_list
for _ in range(M):
B, C = list(map(int, input().split()))
cards.extend([C]*B)
ans = sum(sorted(cards)[-1::-1][:N])
print(ans) | N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
card = []
card_num = []
for a in A_list:
card.append(a)
card_num.append(1)
for _ in range(M):
B, C = list(map(int, input().split()))
card.append(C)
card_num.append(B)
union = zip(card, card_num)
sorted_un... | s213527369 | s935971990 | p03038 | python | Time Limit Exceeded |
R,G,B,N = list(map(int, input().split()))
ans = 0
for r in range(int(N/R)+1):
for g in range(int(N/G)+1):
for b in range(int(N/B)+1):
if r*R+g*G+b*B == N:
ans += 1
print(ans)
| R,G,B,N = list(map(int, input().split()))
ans = 0
for r in range(N//R+1):
for g in range((N-r*R)//G+1):
if (N-r*R-g*G) % B == 0:
ans += 1
print(ans) | s494333578 | s348456894 | p03048 | python | Time Limit Exceeded |
N = int(input())
A_list = list(map(int, input().split()))
import fractions
import copy
from functools import reduce
def gcd(numbers):
return reduce(fractions.gcd, numbers)
max_gcd = 0
for idx in range(N):
cleaned = copy.copy(A_list)
del cleaned[idx]
gcd_value = gcd(tuple(cleaned))
if max_gcd < g... | import numpy as np
def gcd(a,b):
if a < b:
a, b = b, a
if b == 0:
return a
c = a % b
return gcd(b, c)
N = int(input())
A_list = list(map(int, input().split()))
# =====
# initialize L and R
# =====
L = np.zeros(N+1)
R = np.zeros(N+1)
for idx, element in enumerate(A_list):
... | s671552761 | s382252274 | p03061 | python | Time Limit Exceeded |
N = int(input())
A_list = list(map(int, input().split()))
import math
import copy
from functools import reduce
def gcd(numbers):
return reduce(math.gcd, numbers)
max_gcd = 0
for idx in range(N):
cleaned = copy.copy(A_list)
del cleaned[idx]
gcd_value = gcd(tuple(cleaned))
if max_gcd < gcd_value:
... | import numpy as np
def gcd(a,b):
if a < b:
a, b = b, a
if b == 0:
return a
c = a % b
return gcd(b, c)
N = int(input())
A_list = list(map(int, input().split()))
# =====
# initialize L and R
# =====
L = np.zeros(N+1)
R = np.zeros(N+1)
for idx, element in enumerate(A_list):
... | s805828289 | s382252274 | p03061 | python | Runtime Error |
N = int(input())
S = input() ... | N = int(input())
S = input()
S = list(map(lambda x: 0 if x=="." else 1, S))
#all_white
# all_white = sum(S)
# all_black = len(S) - all_white
# white, black, white
ans_list = []
for thresh in range(len(S)):
if thresh == 0:
ans = len(S) - sum(S)
ans_list.append(ans)
else:
ans... | s272373957 | s501196093 | p03069 | python | Time Limit Exceeded |
N = int(input())
S = input()
S = list(map(lambda x: 0 if x=="." else 1, S))
#all_white
# all_white = sum(S)
# all_black = len(S) - all_white
# white, black, white
ans_list = []
for thresh in range(len(S)+1):
ans = sum(S[:thresh]) + (len(S[thresh:])-sum(S[thresh:]))
ans_list.append(ans)
print(min(ans_list)) | N = int(input())
S = input()
S = list(map(lambda x: 0 if x=="." else 1, S))
#all_white
# all_white = sum(S)
# all_black = len(S) - all_white
# white, black, white
ans_list = []
for thresh in range(len(S)):
if thresh == 0:
ans = len(S) - sum(S)
ans_list.append(ans)
else:
ans... | s572106541 | s501196093 | p03069 | python | Time Limit Exceeded |
b = inout()
if b == "A":
print("T")
elif b == "C":
print("G")
elif b == "T":
print("A")
else:
print("C") | b = input()
if b == "A":
print("T")
elif b == "C":
print("G")
elif b == "T":
print("A")
else:
print("C")
| s396422650 | s735231239 | p03085 | python | Runtime Error |
#B
A,B,K = map(int, input().split())
waru = []
for i in range(1, max(A,B)+1, 1):
if len(waru) == K-1:
break
if A%i == 0 and B%i == 0:
waru.append(i)
print(waru[-1])
| #B
A,B,K = map(int, input().split())
waru = []
for i in range(1, max(A,B)+1, 1):
if A%i == 0 and B%i == 0:
waru.append(i)
print(waru[-K])
| s840463279 | s047073430 | p03106 | python | Runtime Error |
#c
S = input()
def clean(seq):
# print("seq: ", seq)
if len(seq) == 1:
return seq
def get_removee_left(cand_seq):
if len(cand_seq) == 1:
return -1
for idx, s in enumerate(cand_seq[:-1]):
if int(s) + int(cand_seq[idx+1]) == 1:
return idx
... | S = input()
save = []
flag = False
modori_flag = False
count = 0
for idx, s in enumerate(S):
if modori_flag:
modori_flag = False
elif flag:
flag = False
continue
this_ = int(s)
if len(save) > 0 and this_ + save[-1] == 1:
modori_flag = True
del save[-... | s229510835 | s395185568 | p03107 | python | Runtime Error |
#c
S = input()
def clean(seq):
if len(seq) == 1:
return seq
cleaned_seq = []
remove_flag = False
for idx, s in enumerate(seq):
if remove_flag:
remove_flag = False
continue
if idx == len(seq)-1:
cleaned_seq.append(s)
... | S = input()
save = []
flag = False
modori_flag = False
count = 0
for idx, s in enumerate(S):
if modori_flag:
modori_flag = False
elif flag:
flag = False
continue
this_ = int(s)
if len(save) > 0 and this_ + save[-1] == 1:
modori_flag = True
del save[-... | s293728293 | s395185568 | p03107 | python | Time Limit Exceeded |
class UnionFind():
def __init__(self, size):
# self.group holds a list of idx for parant node of i-th node
# if self.group[i] = i, i-th node is a root.
# if self.group[i] = j, j-th node is a paranet of i-th node.
self.group = [i for i in range(size)]
# self.height h... | class UnionFind():
def __init__(self, size):
# self.parent holds a list of idx for parant node of i-th node
# if i-th node is a root, self.parent[i] holds the - (number of nodes) in the parent.
# if self.parent[i] = j, j-th node is a paranet of i-th node.
self.parent = [-1 for _ in ... | s221634133 | s252416621 | p03108 | python | Time Limit Exceeded |
class UnionFind():
def __init__(self, size):
# self.group holds a list of idx for parant node of i-th node
# if self.group[i] = i, i-th node is a root.
# if self.group[i] = j, j-th node is a paranet of i-th node.
self.group = [i for i in range(size)]
# self.height h... | class UnionFind():
def __init__(self, size):
# self.parent holds a list of idx for parant node of i-th node
# if i-th node is a root, self.parent[i] holds the - (number of nodes) in the parent.
# if self.parent[i] = j, j-th node is a paranet of i-th node.
self.parent = [-1 for _ in ... | s967182986 | s252416621 | p03108 | python | Time Limit Exceeded |
class UnionFind():
def __init__(self, size):
# self.group holds a list of idx for parant node of i-th node
# if self.group[i] = i, i-th node is a root.
# if self.group[i] = j, j-th node is a paranet of i-th node.
self.group = [i for i in range(size)]
# self.height h... | class UnionFind():
def __init__(self, size):
# self.parent holds a list of idx for parant node of i-th node
# if i-th node is a root, self.parent[i] holds the - (number of nodes) in the parent.
# if self.parent[i] = j, j-th node is a paranet of i-th node.
self.parent = [-1 for _ in ... | s769272887 | s252416621 | p03108 | python | Time Limit Exceeded |
import numpy as np
N, M = map(int, input().split())
ab_list = [list(map(int, input().split())) for _ in range(M)]
a_list = np.array(ab_list)[:, 0][-1::-1]
b_list = np.array(ab_list)[:, 1][-1::-1]
huben = [int((N) * (N-1) * 0.5)]
class UnionFind():
def __init__(self, size):
# self.group holds a list of id... | class UnionFind():
def __init__(self, size):
# self.parent holds a list of idx for parant node of i-th node
# if i-th node is a root, self.parent[i] holds the - (number of nodes) in the parent.
# if self.parent[i] = j, j-th node is a paranet of i-th node.
self.parent = [-1 for _ in ... | s757485843 | s252416621 | p03108 | python | Time Limit Exceeded |
T, X = map(int, input(),split())
print(T/X) | T, X = map(int, input().split())
print(T/X) | s232497550 | s127749151 | p03135 | python | Runtime Error |
N = int(input())
L_list = list(map(int, input().split()))
max_ = max(L_list)
L_list.remove(max_)
if max_ < np.sum(L_list):
print("Yes")
else:
print("No") | import numpy as np
N = int(input())
L_list = list(map(int, input().split()))
max_ = max(L_list)
L_list.remove(max_)
if max_ < np.sum(L_list):
print("Yes")
else:
print("No") | s263362881 | s457496724 | p03136 | python | Runtime Error |
N = int(input())
L_list = list(map(int, input().split()))
max_ = max(L_list)
L_list.remove(max_)
if max_ < np.sum(L_list):
print("Yes")
else:
print("No") | import numpy as np
N = int(input())
L_list = list(map(int, input().split()))
max_ = max(L_list)
L_list.remove(max_)
if max_ < np.sum(L_list):
print("Yes")
else:
print("No") | s369861677 | s457496724 | p03136 | python | Runtime Error |
n, m, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
if(max(x, X) < min(y, Y)):
print("No War")
else:
print("War") | n, m, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
if(max(max(x), X) < min(min(y), Y)):
print("No War")
else:
print("War") | s984372233 | s965169566 | p03251 | python | Runtime Error |
#C - Skip
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
residual = [abs(x - X) for x in x_list]
def gcd(a,b):
if(b==0):
return a
else:
return gcd(b, a%b)
max_ = 0
for i in range(len(residual)):
if(i == 0):
max_ = gcd(residual[i], residual[i+1])
... | #C - Skip
import sys
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
residual = [abs(x - X) for x in x_list]
def gcd(a,b):
if(b==0):
return a
else:
return gcd(b, a%b)
max_ = 0
for i in range(len(residual)):
if(N==1):
print(residual[0])
br... | s772442329 | s881312384 | p03262 | python | Runtime Error |
#C - Skip
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
residual = [abs(x - X) for x in x_list]
def gcd(a,b):
if(b==0):
return a
else:
gcd(b, a%b)
max_ = 0
for i in range(len(residual)):
if(i == 0):
max_ = gcd(residual[i], residual[i+1])
eli... | #C - Skip
import sys
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
residual = [abs(x - X) for x in x_list]
def gcd(a,b):
if(b==0):
return a
else:
return gcd(b, a%b)
max_ = 0
for i in range(len(residual)):
if(N==1):
print(residual[0])
br... | s951915195 | s881312384 | p03262 | python | Runtime Error |
a, b = map(int, input().split())
while n*(a-1)+1 < b:
n += 1
print(n) | n = 0
a, b = map(int, input().split())
while n*(a-1)+1 < b:
n += 1
print(n) | s026536119 | s229852883 | p02922 | python | Runtime Error |
def min_cost(i, total):
if i < 1:
return 0
total += min_cost(i - 1, abs(h[i] - h[i - 1]))
total += min_cost(i - 2, abs(h[i] - h[i - 2]))
return total
def chmin(a, b):
if a > b:
return b
else:
return a
N = int(input())
H = list(map(int, input().split(' ')))
dp ... | N = int(input())
H = list(map(int, input().split(' ')))
dp = [100000000] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print(dp[N - 1])
| s964428724 | s236011086 | p03160 | python | Runtime Error |
def min_cost(i, total):
if i < 1:
return 0
total += min_cost(i - 1, abs(h[i] - h[i - 1]))
total += min_cost(i - 2, abs(h[i] - h[i - 2]))
return total
def chmin(a, b):
if a > b:
return b
else:
return a
N = int(input())
H = list(map(int, input().split(' ')))
dp = [10... | N = int(input())
H = list(map(int, input().split(' ')))
dp = [100000000] * N
dp[0] = 0
dp[1] = abs(H[0] - H[1])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print(dp[N - 1])
| s541431115 | s236011086 | p03160 | python | Runtime Error |
import math
N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
pits = []
cost = 0
for i in range(0, N+1):
pits.append(i)
half = int(len(pits) / 2)
if X == half:
cost_r = 0
cost_l = 0
for a in A:
# 右側
if X < a:
cost_r += 1
# 左側
... | N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
r_count = 0
l_count = 0
tmp_1 = X
tmp_2 = X
while tmp_1 != N:
tmp_1 += 1
if tmp_1 in A:
r_count += 1
while tmp_2 != 0:
tmp_2 -= 1
if tmp_2 in A:
l_count += 1
res = min(l_count, r_count)
print(res)
| s180330943 | s808813816 | p03378 | python | Runtime Error |
import math
N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
pits = []
cost = 0
for i in range(0, N+1):
pits.append(i)
half = int(len(pits) / 2)
# 真ん中
if X == half:
cost_r = 0
cost_l = 0
for a in A:
# 右側
if X < a:
cost_r += 1
# 左側
... | N, M, X = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
r_count = 0
l_count = 0
tmp_1 = X
tmp_2 = X
while tmp_1 != N:
tmp_1 += 1
if tmp_1 in A:
r_count += 1
while tmp_2 != 0:
tmp_2 -= 1
if tmp_2 in A:
l_count += 1
res = min(l_count, r_count)
print(res)
| s748937729 | s808813816 | p03378 | python | Runtime Error |
H,W = map(int, input().split())
if H == 1:
print(1)
elif W == 1:
print(1)
else:
ans = H*(W // 2)
if H % 2 == 1:
if W % 2 == 0:
ans += W // 2
else:
ans += W // 2 + 1
print(ans)
| H, W = map(int, input().split())
if W == 1:
print(1)
elif H == 1:
print(1)
else:
ans = W * (H // 2)
if H % 2 == 1:
if W % 2 == 0:
ans += W // 2
else:
ans += W // 2 + 1
print(ans)
| s749898596 | s259433858 | p02742 | python | Runtime Error |
N = int(input())
X = List(map(int, input().split()))
def D(x, a):
ans = 0
for i in range(len(a)):
ans += (x - a[i])**2
return ans
for i in range(0, 101):
if D(x, X) < D(i+1, X):
print(D(i, X))
break
| N=int(input())
X=list(map(int,input().split()))
def D(x,a):
ans=0
for i in range(len(a)):
ans+=(x-a[i])**2
return ans
for i in range(0,101):
if D(i,X)<D(i+1,X):
print(D(i,X))
break
| s794309866 | s358735854 | p02767 | python | Runtime Error |
N = int(input())
X = list(map(int, input().split()))
def D(X,a):
ans = 0
for i in range(len(a)):
ans += (x - a[i])**2
return ans
for i in range(0,101):
if D(i,X) < D(i+1,X):
print(D(i,X))
break | N=int(input())
X=list(map(int,input().split()))
def D(x,a):
ans=0
for i in range(len(a)):
ans+=(x-a[i])**2
return ans
for i in range(0,101):
if D(i,X)<D(i+1,X):
print(D(i,X))
break
| s124923638 | s358735854 | p02767 | python | Runtime Error |
N = int(input())
X = list(map(int, input().split())
def D(X,a):
ans = 0
for i in range(len(a)):
ans += (x - a[i])**2
return ans
for i in range(0,101):
if D(i,X) < D(i+1,X):
print(D(i,X))
break | N=int(input())
X=list(map(int,input().split()))
def D(x,a):
ans=0
for i in range(len(a)):
ans+=(x-a[i])**2
return ans
for i in range(0,101):
if D(i,X)<D(i+1,X):
print(D(i,X))
break
| s302354288 | s358735854 | p02767 | python | Runtime Error |
N = int(input())
for i in raNge(N+1):
if int(i*1.08)==N:
primt(i)
exit()
print(':(')
| n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | s625500549 | s247003523 | p02842 | python | Runtime Error |
N = int(input())
for i in range(N+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(')
| n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | s265766516 | s247003523 | p02842 | python | Runtime Error |
N = int(input())
for i in range(N+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(')
| n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | s893171587 | s247003523 | p02842 | python | Runtime Error |
n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | s789528402 | s247003523 | p02842 | python | Runtime Error |
n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | n=int(input())
for i in range(n+1):
if int(i*1.08)==n:
print(i)
exit()
print(':(') | s160337170 | s247003523 | p02842 | python | Runtime Error |
A, B = map(int, input().split())
ans = 0
consent = 1
while consent < B
ans += 1
consent -= 1
consent -= A
print(ans)
| A, B = map(int, input().split())
ans = 0
consent = 1
while consent < B:
ans += 1
consent -= 1
consent += A
print(ans)
| s903127665 | s024653941 | p02922 | python | Runtime Error |
zA, B = map(int, input().split())
ans = 0
consent = 1
while consent < B:
ans += 1
consent -= 1
consent += A
print(ans) | A, B = map(int, input().split())
ans = 0
consent = 1
while consent < B:
ans += 1
consent -= 1
consent += A
print(ans)
| s479932507 | s024653941 | p02922 | python | Runtime Error |
A, B = map(int, intput().split())
K = 1
ans = 0
while(K < B):
K -= 1
L += A
ans += 1
print(ans) | A, B = map(int, input().split())
ans = 0
consent = 1
while consent < B:
ans += 1
consent -= 1
consent += A
print(ans)
| s725140878 | s024653941 | p02922 | python | Runtime Error |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.