Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while max(a) != 0:
  # print(a,cnt)
  for i in range(n):
    if a[i] != 0:
      a[i] -= 1
      betweenZero = False
    elif betweenZero == False:
      cnt += 1
      betweenZero = True
  if betweenZero == False:
    cnt += 1
  betweenZero = True
print(cnt)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while max(a) != 0:
  # print(a,cnt)
  betweenZero = True
  for i in range(len(a)):
    if a[i] != 0:
      a[i] -= 1
      betweenZero = False
    elif betweenZero == False:
      cnt += 1
      betweenZero = True
  if betweenZero == False:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
c = []
hold = False
for y in range(h):
    for x in list(range(w))[::-1+(y % 2 == 0)*2]:
        # print((y + 1, x + 1))
        if hold:
            c.append((*back, y + 1, x + 1))
            if a[y][x] % 2 == 1:
                hold = False
                continue
        if not hold and a[y][x] % 2 == 1:
            hold = True
        back = (y + 1, x + 1)
print(len(c))
for i in range(len(c)):
    print(*c[i])


Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
c = []
hold = False
for y in range(h):
    for x in list(range(w))[::-1+(y % 2 == 0)*2]:
        # print((y + 1, x + 1))
        if hold:
            c.append((back[0], back[1], y + 1, x + 1))
            if a[y][x] % 2 == 1:
                hold = False
                continue
        if not hold and a[y][x] % 2 == 1:
            hold = True
        back = (y + 1, x + 1)
print(len(c))
for i in range(len(c)):
    print(*c[i])
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
if s[0] == "1":
  if s[:k] == "1"*k:
    print(s[0])
  else:
    print(s[k-1])
else:
  print(s[0])

Fixed submission:
s = input()
k = int(input())
front1 = 0
if s == "1":
  print(1)
  exit()
for i in range(len(s)):
  if s[i] == "1":
    front1 += 1
  else:
    break
print(s[min(k-1, front1)])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
pop = 0
for i in set(a):
    if a.count(i) < i:
        pop += a.count(i)
    elif a.count(i) > i:
        pop += a.count(i) - i
print(pop)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
n = {}
pop = 0
for ai in a:
    n[ai] = n.get(ai, 0) + 1
for ni in n:
    if ni < n[ni]:
        pop += n[ni] - ni
    elif ni > n[ni]:
        pop += n[ni]
print(pop)
Buggy python submission (verdict: Runtime Error):
q, h, s, d = map(int, input().split())
n = int(input())
n4 = n * 4
# jリットルになるようにしたi番目までの総和最小値
# dp[i][j] = 
w = [1, 2, 4, 8]
v = [q, h, s, d]
dp = [[10**8+1]*(n4+1) for i in range(4)]
for i in range(4):
  dp[i][0] = 0
for i in range(4):
  for j in range(n4+1):
    if j >= w[i] and i >= 1:
      dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[3][n4])

Fixed submission:
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
d = min(s*2, d)
if n % 2 == 0:
  print(min(s*n, d*(n//2)))
else:
  print(min(s*n, d*(n//2)+s))

Buggy python submission (verdict: Runtime Error):
q, h, s, d = map(int, input().split())
n = int(input())
n4 = n * 4
# jリットルになるようにしたi番目までの総和最小値
# dp[i][j] = 
w = [1, 2, 4, 8]
v = [q, h, s, d]
dp = [[10**9]*(n4+1) for i in range(4)]
for i in range(4):
  dp[i][0] = 0
for i in range(4):
  for j in range(n4+1):
    if j >= w[i]:
      dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[3][n4])

Fixed submission:
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
d = min(s*2, d)
if n % 2 == 0:
  print(min(s*n, d*(n//2)))
else:
  print(min(s*n, d*(n//2)+s))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
ans = ""
l = 26
for i in range(len(s)-1):
    if l - (ord(s[i]) - 97) <= k:
        k -= l - (ord(s[i]) - 97)
        ans += "a"
    else:
        ans += s[i]
ans += chr(((ord(s[-1]) - 97) + k + l**100) % l + 97)
print(ans)

Fixed submission:
s = input()
k = int(input())
ans = ""
l = 26
for i in range(len(s)-1):
    if l - ord(s[i]) + 97 <= k and s[i] != "a":
        k -= l - ord(s[i]) + 97
        ans += "a"
    else:
        ans += s[i]
ans += (chr(((ord(s[-1]) - 97) + k + l) % l + 97))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
ans = ""
alpha = "abcdefghijklmnopqrstuvwxyz"
l = len(alpha)
for i in range(len(s)-1):
    if l - alpha.index(s[i]) <= k:
        k -= l - alpha.index(s[i])
        ans += "a"
    else:
        ans += s[i]
ans += alpha[(alpha.index(s[-1]) + k + l**100) % l]
print(ans)

Fixed submission:
s = input()
k = int(input())
ans = ""
l = 26
for i in range(len(s)-1):
    if l - ord(s[i]) + 97 <= k and s[i] != "a":
        k -= l - ord(s[i]) + 97
        ans += "a"
    else:
        ans += s[i]
ans += (chr(((ord(s[-1]) - 97) + k + l) % l + 97))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = []
for i in range(n):
  c += [i+1]*int(input())
cnt = 0
paired = False
for i in range(len(c)-1):
  if paired:
    paired = False
    continue
  if c[i+1] - c[i] <= 1 and not paired:
    cnt += 1
    paired = True
print(cnt)

Fixed submission:
n = int(input())
a = []
cnt = 0
for i in range(n):
  a.append(int(input()))
stack = -1
for i in range(n):
  if i+1 - stack <= 1 and a[i] > 0:
    cnt += 1
    a[i] -= 1
    stack = -1
  cnt += a[i] // 2
  if a[i] % 2 == 1:
    stack = i+1
  else:
    stack = -1
print(cnt)
Buggy python submission (verdict: Runtime Error):
(h,w,m),*s=[[*map(int,i.split())]for i in open(0)]
r,c=[0]*-~h,[0]*-~w
for x,y in s:
    r[x]+=1
    c[y]+=1
print((R:=max(r))+(C:=max(c))-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s)))


Fixed submission:
#!/usr/bin/env python3
h, w, m = map(int, input().split())
r = [0] * (h + 1)
c = [0] * (w + 1)
s = []
for _ in range(m):
    x, y = map(int, input().split())
    r[x] += 1
    c[y] += 1
    s.append([x, y])
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = 0
for x, y in s:
    count += x in nr and y in nc
print(R + C - (len(nr) * len(nc) == count))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
h, w, m = map(int, input().split())
r = [0] * h
c = [0] * w
s = set()
for _ in range(m):
    x, y = map(lambda i: int(i) - 1, input().split())
    r[x] += 1
    c[y] += 1
    s.add((x, y))
R = max(r)
C = max(c)
ans = {(i, j)
       for i, p in enumerate(r) for j, q in enumerate(c) if p == R and q == C}
print(R + C - (len(ans - (ans & s)) == 0))


Fixed submission:
#!/usr/bin/env python3
h, w, m = map(int, input().split())
r = [0] * (h + 1)
c = [0] * (w + 1)
s = []
for _ in range(m):
    x, y = map(int, input().split())
    r[x] += 1
    c[y] += 1
    s.append([x, y])
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = 0
for x, y in s:
    count += x in nr and y in nc
print(R + C - (len(nr) * len(nc) == count))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np

h, w, m = map(int, input().split())
a = np.zeros((h, w), dtype=np.int64)
b = [[*map(lambda x: int(x) - 1, input().split())] for _ in range(m)]
for x, y in b:
    a[x, :] += 1
    a[:, y] += 1
    a[x][y] -= 1
print(np.max(a))


Fixed submission:
#!/usr/bin/env python3
h, w, m = map(int, input().split())
r = [0] * (h + 1)
c = [0] * (w + 1)
s = []
for _ in range(m):
    x, y = map(int, input().split())
    r[x] += 1
    c[y] += 1
    s.append([x, y])
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = 0
for x, y in s:
    count += x in nr and y in nc
print(R + C - (len(nr) * len(nc) == count))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np

h, w, m = map(int, input().split())
a = np.zeros((h, w), dtype=np.int64)
b = [[*map(lambda x: int(x) - 1, input().split())] for _ in range(m)]
for x, y in b:
    c = np.zeros((h, w), dtype=np.int64)
    c[x, :] = 1
    c[:, y] = 1
    a = a + c
print(np.max(a))


Fixed submission:
#!/usr/bin/env python3
h, w, m = map(int, input().split())
r = [0] * (h + 1)
c = [0] * (w + 1)
s = []
for _ in range(m):
    x, y = map(int, input().split())
    r[x] += 1
    c[y] += 1
    s.append([x, y])
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = 0
for x, y in s:
    count += x in nr and y in nc
print(R + C - (len(nr) * len(nc) == count))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 0:
    print(-1)
else:
    c = 1
    mod = 7 % k
    mop = 7 % k
    while mod > 0:
        mop = mop*10%k
        mod += mop
        mod %= k
        c += 1
    print(c)


Fixed submission:
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 1:
    print(-1)
else:
    c = 1
    mod = 7 % k
    mop = 7 % k
    while mod > 0:
        mop = mop*10%k
        mod += mop
        mod %= k
        c += 1
    print(c)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 0:
    print(-1)
else:
    c = len(str(k))
    mod = int("7" * c) % k
    while mod > 0:
        mod += pow(10, c, k) * 7
        mod %= k
        c += 1
    print(c)


Fixed submission:
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 1:
    print(-1)
else:
    c = 1
    mod = 7 % k
    mop = 7 % k
    while mod > 0:
        mop = mop*10%k
        mod += mop
        mod %= k
        c += 1
    print(c)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 0:
    print(-1)
else:
    c = 1
    mod = 7 % k
    while mod > 0:
        mod += pow(10, c, k)*7
        mod %= k
        c += 1
    print(c)


Fixed submission:
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 1:
    print(-1)
else:
    c = 1
    mod = 7 % k
    mop = 7 % k
    while mod > 0:
        mop = mop*10%k
        mod += mop
        mod %= k
        c += 1
    print(c)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
input()
a = [*map(int, input().split())]
s = sum(a)
b = [[*map(int,input().split())] for _ in range(int(input()))]
c = defaultdict(int)
for i in a:
    c[i]+=1
for i,j in b:
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)


Fixed submission:
def base(n, b):
    d="abcdefghijklmnopqrstuvwxyz"
    s = []
    while True:
        s.append(d[n % b])
        n = n//b -1
        if n < 0:
          break
    return ''.join(reversed(s))
print(base(int(input())-1,26))
Buggy python submission (verdict: Time Limit Exceeded):
import collections 
_ = input()
a = [*map(int, input().split())]
q = int(input())
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    c[j]+=c[i]
    c[i] = 0
    print(sum(k*v for k,v in c.items()))

Fixed submission:
import collections
_ = input()
a = [*map(int, input().split())]
q = int(input())
s = sum(a)
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)

Buggy python submission (verdict: Runtime Error):
import collections 
_ = input()
a = [*map(int, input().split())]
q = int(input())
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    c[j]+=c[i]
    c.pop(i)
    print(sum(k*v for k,v in c.items()))

Fixed submission:
import collections
_ = input()
a = [*map(int, input().split())]
q = int(input())
s = sum(a)
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
_ = input()
a = [*map(int, input().split())]
q = int(input())
b = [[*map(int,input().split())] for _ in range(q)]
n,c = np.unique(a,return_counts=True)
for i,j in b:
    d = np.where(n==i)
    n[d] = j
    print(sum(n*c))

Fixed submission:
import collections
_ = input()
a = [*map(int, input().split())]
q = int(input())
s = sum(a)
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = input()
a = np.array([*map(int, input().split())])
q = int(input())
b = [[*map(int,input().split())] for _ in range(q)]
for i,j in b:
    a = np.where(a==i, j, a)
    print(sum(a))

Fixed submission:
import collections
_ = input()
a = [*map(int, input().split())]
q = int(input())
s = sum(a)
b = [[*map(int,input().split())] for _ in range(q)]
c = collections.Counter(a)
for i,j in b:
    if j not in c:
        c[j] = 0
    if i not in c:
        c[i] = 0
    s += (j-i)*c[i]
    c[j]+=c[i]
    c[i] = 0
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
_,*a = open(0).read().split()
for n,m in enumerate(a):
    b = a + []
    del b[n]
    print(eval("^".join(b)),end=" ")

Fixed submission:
_,*a = open(0).read().split()
x = eval("^".join(a))
for i in a:
    print(x^int(i),end=" ")
Buggy python submission (verdict: Runtime Error):
_, *a = map(int, open(0).read().split())
a.sort()
m = -~a[-1]
c = [0] * m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]for i in a))

Fixed submission:
print(input().split().index("0")+1)

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
i = 0
while a:
    if a.count(a[0]) == 1:
        i+=1
    a = list(filter(lambda x: x%a[0] >0,a))
print(i)

Fixed submission:
print(input().split().index("0")+1)
Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
a.sort()
for i in a:
    s *= i
    if s > 1e18:
        print(-1)
        exit()
print(s)

Fixed submission:
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=i
    if  s > 1e18:
        print(-1)
        exit()
print(s)

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=a
    if  s > 10**18:
        print(-1)
        exit()
print(s)

Fixed submission:
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=i
    if  s > 1e18:
        print(-1)
        exit()
print(s)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=eval(input().replace(" ", "*"))
print([-1,s][s<=10**18])

Fixed submission:
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=i
    if  s > 1e18:
        print(-1)
        exit()
print(s)
Buggy python submission (verdict: Runtime Error):
s=eval(input().replace(" ", "*").replace(".",""))
print(s//100)

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b.replace(".",""))
print((a*b)//100)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = set()
for i in [0]*k:
    _ = input()
    a.add(*map(int, input().split()))
print(n - len(a))

Fixed submission:
(n,k),*p = [[*map(int, i.split())] for i in open(0)]
a = sum([p[2*i+1] for i in range(k)],[])
print(n - len(set(a)))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = set()
for i in [0]*k:
    _ = input()
    a.add(*map(int, input().split()))
    print(a)
print(n - len(a))

Fixed submission:
(n,k),*p = [[*map(int, i.split())] for i in open(0)]
a = sum([p[2*i+1] for i in range(k)],[])
print(n - len(set(a)))
Buggy python submission (verdict: Time Limit Exceeded):
(n, m), h, *r = [[*map(int, i.split())] for i in open(0)]
c = 0
for i in range(n):
    if i + 1 not in sum(r, []):
        c += 1
        continue
    l = [j * (i + 1 in j) for j in r]
    if h[i] > max(h[j-1] for j in set(sum(l, []))-{i + 1}):
        c += 1
print(c)

Fixed submission:
(n, m), h, *r = [[*map(int, i.split())] for i in open(0)]
g =[] + h

for i in r:
    g[i[0]-1] *= h[i[0]-1] > h[i[1]-1]
    g[i[1]-1] *= h[i[1]-1] > h[i[0]-1]
print(len([i for i in g if i !=0]))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from functools import reduce
from itertools import product
from math import gcd

k = int(input())
p = list(product(range(1, k + 1), repeat=3))
print(sum(reduce(gcd, i) for i in p))


Fixed submission:
#!/usr/bin/env python3
from functools import reduce
from itertools import combinations
from math import gcd

K = int(input())

sum = K * (K + 1) // 2

for i in combinations(range(1, K + 1), 2):
    sum += 6 * reduce(gcd, i)

for i in combinations(range(1, K + 1), 3):
    sum += 6 * reduce(gcd, i)

print(sum)
Buggy python submission (verdict: Runtime Error):
(k,n),*a = [list(map(int,i.split())) for i in open(0)]
a.append(a[0]+k)
print(k - min(a[i+1]-a[i] for i in range(n)))

Fixed submission:
(k,n),(*a,) = [list(map(int,i.split())) for i in open(0)]
a.append(a[0]+k)
print(k - max(a[i+1]-a[i] for i in range(n)))

Buggy python submission (verdict: Runtime Error):
(k,n),*a = [[*map(int,i.split())] for i in open(0)]
a.append(a[0]+k)
print(k - min(a[i+1]-a[i] for i in range(n)))

Fixed submission:
(k,n),(*a,) = [list(map(int,i.split())) for i in open(0)]
a.append(a[0]+k)
print(k - max(a[i+1]-a[i] for i in range(n)))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import Counter

from scipy.special import comb

_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(comb(i, 2, exact=True) for i in c.values())
for i in a:
    print(s - c[i] + 1)


Fixed submission:
#!/usr/bin/env python3
from collections import Counter

from scipy.special import comb

_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(comb(i, 2, exact=True) for i in c.values())
for i in a:
    print(s - c[i] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from collections import deque

h, w = map(int, input().split())
maze = [[i == "#" for i in input()] for _ in range(h)]

dx = [1, 0]
dy = [0, 1]

que = deque([])
que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0))
count = 10**5

while que:
    x, y, b, c = que.pop()
    if x == h - 1 and y == w - 1:
        count = min(count, c)
    elif c < count:
        for i in range(2):
            nx = x + dx[i]
            ny = y + dy[i]

            if not (0 <= nx < h and 0 <= ny < w):
                continue
            que.append((nx, ny, maze[nx][ny], c + (not b and maze[nx][ny])))
print(count)


Fixed submission:
#!/usr/bin/env python3
from collections import deque

h, w = map(int, input().split())
maze = [[i == "#" for i in input()] for _ in range(h)]

dx = [1, 0]
dy = [0, 1]

que = deque([])
que.append((0, 0, maze[0][0], 1 if maze[0][0] else 0))
count = [[h + w] * w for _ in range(h)]

while que:
    x, y, b, c = que.pop()
    if c >= count[x][y]:
        continue
    count[x][y] = c
    if x == h - 1 and y == w - 1:
        continue
    for i in range(2):
        nx = x + dx[i]
        ny = y + dy[i]

        if not (0 <= nx < h and 0 <= ny < w):
            continue
        que.append((nx, ny, maze[nx][ny], c + (not b and maze[nx][ny])))
print(count[h - 1][w - 1])
Buggy python submission (verdict: Runtime Error):
a =[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]
print(a[int(input())-1]


Fixed submission:
a =[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]
print(a[int(input())-1])

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
print([1,sum(divmod(h*w, 2))][h>1<w])


Fixed submission:
a =[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]
print(a[int(input())-1])
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
print([1,sum(divmod(h*w), 2)][h>0<w])

Fixed submission:
h,w=map(int,input().split())
print([1,sum(divmod(h*w, 2))][h>1<w])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n, k, *p = map(int, open(0).read().split())
ans = float()
for i in range(n - k + 1):
    ans = max(ans, (sum(p[i:k + i]) + k) / 2)
print(ans)


Fixed submission:
#!/usr/bin/env python3
n, k, *P = map(int, open(0).read().split())
p = [(i + 1) / 2 for i in P]
c = sum(p[:k])
ans = c
for i in range(n - k):
    c = c + p[i + k] - p[i]
    ans = max(c, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
print(~-(1<<len(bin(int(input()))[2:])))

Fixed submission:
#!/usr/bin/env python3
n, k, *h = map(int, open(0).read().split())
print(sum(sorted(h)[-k-1::-1]))
Buggy python submission (verdict: Runtime Error):
print(~-1<<len(bin(int(input()))-3))

Fixed submission:
print(~-(1<<len(bin(int(input()))[2:])))
Buggy python submission (verdict: Time Limit Exceeded):
(h, n), *m = [[*map(int, i.split())] for i in open(0)]
dp = [0] * 20001
for i in range(1, h + 1):
    dp[i] = 10**9
    for a, b in m:
        dp[i] = min(dp[i], dp[i-a]+b)
print(dp[h])


Fixed submission:
(h, n), *m = [[*map(int, i.split())] for i in open(0)]
dp = [0] + [10**9] * h
for i in range(1, h + 1):
    for a, b in m:
        dp[i] = min(dp[i], dp[max(i-a,0)]+b)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
(h, n), *m = [[*map(int, i.split())] for i in open(0)]
dp = [0] + [10**9] * h
for i in range(1, h + 1):
    for a, b in m:
        dp[i] = min(dp[i], dp[max(i-a,0)]+b)
print(dp[-1])


Fixed submission:
(h, n), *m = [[*map(int, i.split())] for i in open(0)]
dp = [0] + [10**9] * h
for i in range(1, h + 1):
    for a, b in m:
        dp[i] = min(dp[i], dp[max(i-a,0)]+b)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
(h, n), *m = [[*map(int, i.split())] for i in open(0)]
dp = [0] + [10**9] * h
for i in range(1, h + 1):
    dp[i] = min(dp[max(i - a, 0)] + b for a, b in m)
print(dp[-1])


Fixed submission:
(h, n), *m = [[*map(int, i.split())] for i in open(0)]
dp = [0] + [10**9] * h
for i in range(1, h + 1):
    for a, b in m:
        dp[i] = min(dp[i], dp[max(i-a,0)]+b)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
(n, ), *r = [[*map(int, i.split())] for i in open(0)]
s = sorted([[x + l, x - l] for x, l in r])
c = 0
p = 0
while s:
    c += 1
    p = s[0][0]
    s = [i for i in s if i[1] >= p]
print(c)


Fixed submission:
#!/usr/bin/env python3
(n, ), *r = [[*map(int, i.split())] for i in open(0)]
s = sorted([[x + l, x - l] for x, l in r])
c = 1
p = s[0][0]
for i in s[1:]:
    if i[1] >= p:
        c += 1
        p = i[0]
print(c)
Buggy python submission (verdict: Runtime Error):
import math
n,p,q=[list(map(int, i.split())) for i in open(0)]
def ps(l):
    s=0
    t=list(range(1,n+1))
    for i in range(n):
        s+=t.index(l[i])*math.factorial(n-i-1)
        t.remove(l[i])
print(abs(ps(p)-ps(q)))

Fixed submission:
import itertools
(n,),p,q=[tuple(map(int, i.split())) for i in open(0)]
j=list(itertools.permutations(range(1, -~n)))
print(abs(j.index(p) - j.index(q)))
Buggy python submission (verdict: Time Limit Exceeded):
x= int(input())
a = [2]
n = 2
while a[-1] < x:
    n += 1
    if all(n%i for i in a):
        a.append(n)
print(n)

Fixed submission:
def f(n):
    if n==2:return 2
    for i in range(2,[n, 5][n>5]):
        if i**n%n != i:
            return f(n+1)
    return n
print(f(int(input())))