Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03129 (python)

Fixed submission:
N, K = map(int, input().split())
if (N-1) >= (K-1)*2:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
if (N-1)//(K-1) >= 2:
  print("YES")
else:
  print("NO")
Problem p03145 (python)

Fixed submission:
N = list(map(int, input().split()))
N.sort()
print(N[0]*N[1]//2)

Buggy submission (verdict: Runtime Error):
N = list(int, input().split())
N.sort()
print(N[0]*N[1]//2)
Problem p03147 (python)

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
h.append(0)

res = 0
while True:
    if max(h) == 0:
        break
    for i in range(N):
        if h[i] > 0:
            l = i
            break
    for j in range(i+1, N+1):
        if h[j] == 0:
            r = j
            break
    
    x = min(h[l:r])
    for i in range(l, r):
        h[i] -= x
    res += x

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
h.append(0)

res = 0
while True:
    for i in range(N):
        if h[i] > 0:
            l = i
            break
    for j in range(i+1, N+1):
        if h[j] == 0:
            r = j
            break
    
    x = min(h[l:r])
    for i in range(l, r):
        h[i] -= x
    res += x

    if max(h) == 0:
        break

print(res)
Problem p03161 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, K = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*(N)

for i in range(1,N):
    now = h[i]
    dp[i] = min([abs(now-h[j])+dp[j] for j in range(max(i-K,0),i)])

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
h = list(map(int,input().split()))

cost = [0]

for i in range(1,N):
    cost.append(1000)
    for j in range(max(i,K)):
        cost[i] = min(cost[i],cost[i-j]+abs(h[i]-h[i-j]))

print(cost[N])
Problem p03162 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
ABC = [list(map(int,input().split())) for i in range(N)]

dp = [[0]*3 for i in range(N+1)]

for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][j] = max(dp[i-1][k]+ABC[i-1][j],dp[i][j])

print(max(dp[N]))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
ABC = [list(map(int,input().split())) for i in range(N)]

dp = [0]*(N+1)

for i in range(1,N+1):
    dp[i] = [max([dp[i-1][k]+ABC[i-1][j] for k in range(3) if j != k]) for j in range(3)]

print(max(dp[N]))
Problem p03164 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int,input().split())

n = (N+1)*max(v)

inf = 10**14

dp = [[inf]*n for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    dp[i+1][0] = 0
    for j in range(n-2,0,-1):
        dp[i+1][j] = min(dp[i+1][j+1], dp[i][j], dp[i][j-v[i]]+w[i])

ans = 0
for i in range(n):
    if dp[N][i] <= W:
        ans = i
    else:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
wv = [list(map(int,input().split())) for i in range(N)]

wv.sort()
wv.reverse()

dp = [[0]*(W+1) for i in range(N+1)]

for i, x in enumerate(wv,1):
    w = x[0]
    v = x[1]
    for j in range(w,W+1):
        dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)
        
print(dp[N][W])
Problem p03197 (python)

Fixed submission:
N = int(input())
a = [int(input()) for _ in range(N)]
print('second' if all(a[i] % 2 == 0 for i in range(N)) else 'first')

Buggy submission (verdict: Runtime Error):
print('second' if all(a[i] % 2 == 0 for i in range(N)) else 'first')
Problem p03238 (python)

Fixed submission:
if input() == "1":
    print("Hello World")
else:
    print(int(input())+int(input()))

Buggy submission (verdict: Runtime Error):
if input() == "1":
    print("Hello World")
else:
    print(int(input()+int(input())))
Problem p03240 (python)

Fixed submission:
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c >= 1:
        xt = a
        yt = b
        ht = c

for Cx in range(101):
    for Cy in range(101):
        H = max(ht + abs(Cx - xt) + abs(Cy - yt), 0)
        for i in range(N):
            Z = max(H - abs(Cx - x[i]) - abs(Cy - y[i]), 0)
            if h[i] != Z:
                break
        else:
            res = [str(Cx), str(Cy), str(H)]

print(" ".join(res))

Buggy submission (verdict: Runtime Error):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):
            if xyh[i][2] >= 1:
                H = xyh[0][2] + abs(Cx-xyh[0][0]) + abs(Cy-xyh[0][1])
                break
        for i in range(N):
            if xyh[i][2] != max(H-abs(xyh[i][0]-Cx)-abs(xyh[i][1]-Cy), 0):
                break
        else:
            res = [str(Cx), str(Cy), str(H)]

print(" ".join(res))

Buggy submission (verdict: Runtime Error):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H = xyh[0][2] + abs(Cx-xyh[0][0]) + abs(Cy-xyh[0][1])
        for i in range(1, N):
            if xyh[i][2] != max(H-abs(xyh[i][0]-Cx)-abs(xyh[i][1]-Cy), 0):
                break
        else:
            res = [str(Cx), str(Cy), str(H)]

print(" ".join(res))
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())

for i in range(len(S)):
    if S[i] != "1":
        break

if K > i:
    print(S[i])
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

i = 0
while True:
    if S[i] != "1":
        print(S[i])
        break
    if i == K:
        print(S[i])
        break
    i += 1
Problem p03323 (python)

Fixed submission:
A,B = list(map(int,input().split()))
 
if A <= 8 and B <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))

if A <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
Problem p03502 (python)

Fixed submission:
N = input()
if int(N) % sum(map(int, N)):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = input()
if N % sum(map(int, N)):
    print("No")
else:
    print("Yes")
Problem p03545 (python)

Fixed submission:
A, B, C, D = map(int, input())
if A+B+C+D==7:
    a = "+"
    b = "+"
    c = "+"
elif A+B+C-D==7:
    a = "+"
    b = "+"
    c = "-"
elif A+B-C+D==7:
    a = "+"
    b = "-"
    c = "+"
elif A+B-C-D==7:
    a = "+"
    b = "-"
    c = "-"
elif A-B+C+D==7:
    a = "-"
    b = "+"
    c = "+"
elif A-B+C-D==7:
    a = "-"
    b = "+"
    c = "-"
elif A-B-C+D==7:
    a = "-"
    b = "-"
    c = "+"
elif A-B-C-D==7:
    a = "-"
    b = "-"
    c = "-"

print(str(A)+a+str(B)+b+str(C)+c+str(D)+"=7")

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input())
if A+B+C+D==7:
    a = "+"
    b = "+"
    c = "+"
elif A+B+C-D==7:
    a = "+"
    b = "+"
    c = "-"
elif A+B-C+D==7:
    a = "+"
    b = "-"
    c = "+"
elif A+B-C-D==7:
    a = "+"
    b = "-"
    c = "-"
elif A-B+C+D==7:
    a = "-"
    b = "+"
    c = "+"
elif A-B+C-D==7:
    a = "-"
    b = "+"
    c = "-"
elif A-B-C+D==7:
    a = "-"
    b = "-"
    c = "+"
elif A-B-C-D==7:
    a = "-"
    b = "-"
    c = "-"

print(f"{A}{a}{B}{b}{C}{c}{D}=7")
Problem p03564 (python)

Fixed submission:
N = int(input())
K = int(input())
a = 1
for _ in range(N):
    a = min(a*2, a+K)
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
a = 1
for _ in range(N):
    a = min(a*2, a+k)
print(a)
Problem p03573 (python)

Fixed submission:
l = list(map(int, input().split()))
for ll in l:
    if l.count(ll)==1:
        print(ll)
        break

Buggy submission (verdict: Runtime Error):
l = liet(map(int, input().split()))
for ll in l:
    if l.count(ll)==1:
        print(ll)
        break
Problem p03657 (python)

Fixed submission:
A, B = map(int, input().split())
if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
print("YNeos"[notA%3==0orB%3==0or(A+B)%3==0::2])
Problem p03712 (python)

Fixed submission:
H, W = map(int, input().split())
a = [input()for _ in range(H)]
print("#"*(W+2))
for r in a:
    print("#"+r+"#")
print("#"*(W+2))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = [input()for _ in range(H)]
print("#"*(W+2))
for r in a:
    print(f"#{r}#")
print("#"*(W+2))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
print("#"*(W+2))
for _ in range(H):
    print(f"#{input()}#")
print("#"*(W+2))
Problem p03730 (python)

Fixed submission:
import fractions
A, B, C = map(int, input().split())
if C % fractions.gcd(A, B) == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import math
A, B, C = map(int, input().split())
if C%math.gcd(A, B) == 0:
    print("YES")
else:
    print("NO")
Problem p03860 (python)

Fixed submission:
print("".join(s[0] for s in input().split()))

Buggy submission (verdict: Runtime Error):
print("".join(s[0] for s in input()split()))
Problem p03997 (python)

Fixed submission:
print((int(input())+int(input()))*int(input())//2)

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input()))*int(input()//2)
Problem p02555 (python)

Fixed submission:
class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], mod - 2, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], -1, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)
Problem p02605 (python)

Fixed submission:
_, *a = map(str.split, open(0))
U, R, D, L = "URDL"
INF = float("inf")
d = {}
for *z, u in a:
  d.setdefault(u, []).append([*map(int, z)])
N = INF
for A, B, S in [(U, D, "x, y"), (R, L, "y, x"), 
                (R, U, "x+y, x-y"), (D, L, "x+y, x-y"), 
                (U, L, "x-y, x+y"), (R, D, "x-y, x+y")]:
  n = p = -INF
  L = eval(f"[({S}, Q) for P, Q in [(A, 1), (B, 0)] for x, y in d.get(P, [])]")
  for x, y, r in sorted(L):
    if x != n:
      if r:n = x;p = y
    elif r:p = y
    else:N = min(N, (y - p)*5)
print("SAFE" if N == INF else N)

Buggy submission (verdict: Runtime Error):
I=N=9**9
P,M,L,R,U='x+y','x-y',[],[],[]
for t in[*open(0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],')
for*A,S,D in(D,U,*'xy'),(L,R,*'yx'),(U,R,P,M),(L,D,P,M),(L,U,M,P),(D,R,M,P):
 n=p=-I
 for x,y,r in eval(f"sorted(({S},{D},Q)for Q,P in enumerate(A)for x,y in P)"):
  if r:n,p=x,y  
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')
Problem p02620 (python)

Fixed submission:
def P(s):
  L = [0] * 26
  R = P = 0
  for i in range(D):
    t = I[i + D][0] - 1
    R += I[i][t]
    P += s - (i + 1 - L[t]) * C[t]
    R -= P
    L[t] = i + 1
  return R
(D,), C, *I = [list(map(int, o.split())) for o in open(0)]
for d, q in I[2*D + 1:]:
  I[d - 1 + D][0] = q
  print(P(sum(C)))

Buggy submission (verdict: Runtime Error):
def P(s):
 R,P,*L=[0]*28
 for i in range(1,366):t=I[i+364][0]-1;P+=s-(i-L[t])*C[t];R+=I[i-1][t]-P;L[t]=i
 return R
_,C,*I=[[*map(int,t.split())]for t in open(0)]
for d,q in I[701:]:I[d+364][0]=q;print(P(sum(C)))

Buggy submission (verdict: Runtime Error):
def P(s):
 R,P,*L=[0]*28
 for i in range(365):t=I[i+365][0]-1;P+=s-(i+1-L[t])*C[t];R+=I[i][t]-P;L[t]=i+1
 return R
_,C,*I=[[*map(int,t.split())]for t in open(0)]
for d,q in I[701:]:I[d+364][0]=q;print(P(sum(C)))
Problem p02681 (python)

Fixed submission:
#!/usr/bin/env python3
print("YNeos"[input()!=input()[:-1]::2])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
n, k, *a = map(int, open(0).read().split())
F = [0 for _ in range(n)]  # 来た？
T = [None for _ in range(n)]  # いつ来た？
def main(now, time, K):
    time += 1
    if F[now-1]:
        P = T[now-1]
        print(T.index(P + (K - time + 1) % (time - P)) + 1)
        exit()
    F[now-1] = 1
    T[now-1] = time
    main(a[now-1], time, K)
    if time == K:
        print(now)
        exit()

main(1, 0, k)
Problem p02684 (python)

Fixed submission:
n, k, *a = map(int, open(0).read().split())
a = [0] + a
p = 1
while k:
    if k % 2:
        p = a[p]
    a = [a[b] for b in a]
    k //= 2
print(p)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, k, *a = map(int, open(0).read().split())
F = [0 for _ in range(n)]  # 来た？
T = [None for _ in range(n)]  # いつ来た？
def main(now, time, K):
    time += 1
    if F[now-1]:
        P = T[now-1]
        print(T.index(P + (K - time + 1) % (time - P)) + 1)
        exit()
    F[now-1] = 1
    T[now-1] = time
    main(a[now-1], time, K)

main(1, 0, k)
Problem p02690 (python)

Fixed submission:
x = int(input())

for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i ** 5 - j ** 5 == x:
            print(i,j)
            quit()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = 1
x = int(input())
while True:
    bz = (x-a**5)**.2
    if float.is_integer(bz):
        print(int(bz), -a)
        exit()
    a += 1
Problem p02727 (python)

Fixed submission:
(x, y, a, b, c), p, q, r = [map(int, o.split()) for o in open(0)]
print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + list(r))[-x-y:]))

Buggy submission (verdict: Runtime Error):
(x, y, a, b, c), p, q, r = [map(int, o.split()) for o in open(0)]
print(sum(sorted(sorted(p)[-x:] + sorted(q)[-y:] + r)[-x-y:]))
Problem p02732 (python)

Fixed submission:
from collections import Counter
_, *a = map(int, open(0).read().split())
c = Counter(a)
s = sum(c*~-c // 2 for c in c.values())
for k in a:
    print(s - c[k] + 1)

Buggy submission (verdict: Runtime Error):
r=range;_,*s=open(0)
h,w,k=map(int,_.split())
m=9e9
for i in r(1<<h-1):
  t,v,l=[],-1,1
  for j in r(h):
    if i>>j&1:t+=j+1,;l+=1
  t+=h,
  c=[0]*l
  for i in r(w):
    b=f=g=0;u=[]
    for j in r(l):d,b=sum(s[j][i]>"0"for j in r(b,t[j])),t[j];u+=d,;g|=d>k;c[j]+=d;f|=c[j]>k
    v+=f
    if f:c=u
  if not g:m=min(m,v+l)
print(m)
Problem p02744 (python)

Fixed submission:
k = "a",
for _ in range(int(input()) - 1):
  k = {a + b for a in k for b in a + chr(ord(max(a)) + 1)}
print(*sorted(k), sep='\n')

Buggy submission (verdict: Runtime Error):
k = "a",
for _ in range(int(input()) - 1):
  k = {a + b for a in r for b in a + chr(ord(max(a)) + 1)}
print(*sorted(k), sep='\n')
Problem p02756 (python)

Fixed submission:
#!/usr/bin/env python3
s, _, *q = open(0)
g = ""
s = s.strip()
for q in q:
  q = q.strip().split()
  if q[0] == "1":
    g, s = s, g
  else:
    if q[1] == "1":
      g += q[2]
    else:
      s += q[2]
print(g[::-1] + s)

Buggy submission (verdict: Runtime Error):
s, _, q = open(0)
g = ""
for q in q:
  p, f, c = q.split()
  if p == "1":
    g, s = s, g
  else:
    if f == "1":
      g += c
    else:
      s += c
print(g[::-1] + s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
for _ in range(q):
    l = input()
    if ipt == "1":
        s = s[::-1]
    else:
        t, f, c = l.split()
        if f == "1":
            st = c + st
        else:
            st += c
print(st)

Buggy submission (verdict: Runtime Error):
def input(): return sys.stdin.readline().strip()
st = input()
q = int(input())
for i in range(q):
    ipt = input()
    if ipt == "1":
        st = st[::-1]
    else:
        _, f, c = input().split()
        if f == "1":
            st = st + c
        else:
            st = c + st
print(st)
Problem p02760 (python)

Fixed submission:
# Atcoder ABC 157
# Problem B

a = []
for i in range(3):
  a.append(list(map(int, input().split())))

n = int(input())

for _ in range(n):  #b_n roop
   b = int(input())
   for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] = 0  #make a 0
        
for i in range(3):
    bingo = False
    if sum(a[i]) == 0: #横チェック
     print("Yes")
     exit()
    if sum([a[0][i], a[1][i], a[2][i]]) == 0: #縦チェック
     print("Yes")
     exit()

if sum([a[0][0], a[1][1], a[2][2]]) == 0: #斜めチェック
    print("Yes")
    exit()

if sum([a[2][0], a[1][1], a[0][2]]) == 0: #逆斜めチェック
    print("Yes")
    exit()

#n(Yes)=0のとき
print("No")

Buggy submission (verdict: Runtime Error):
# Atcoder ABC 157
# Problem B

a = []
 for i in range(3):
  a.append(list(map(int, input().split())))

n = int(input())

for _ in range(n):  #b_n roop
   b = int(input())
   for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] = 0  #make a 0
        
for i in range(3):
    if sum(a[i]) == 0: #横チェック
     print("Yes")
     exit()
    if sum([a[0][i], a[1][i], a[2][i]]) == 0: #縦チェック
     print("Yes")
     exit()

if sum([a[0][0], a[1][1], a[2][2]]) == 0: #斜めチェック
    print("Yes")
    exit()

if sum([a[2][0], a[1][1], a[0][2]]) == 0: #逆斜めチェック
    print("Yes")
    exit()

#n(Yes)=0のとき

Buggy submission (verdict: Runtime Error):
# Atcoder ABC 157
# Problem B

a = []
 for i in range(3):
  a.append(list(map(int,input().split())))

n = int(input())

for _ in range(n):  #b_n roop
   b = int(input())
   for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] = 0  #make a 0
        
for i in range(3):
    if sum(a[i]) == 0: #横チェック
     print("Yes")
     exit()
    if sum(a[0][i],a[1][i],a[2][i]) == 0: #縦チェック
     print("Yes")
     exit()

if sum(a[0][0],a[1][1],a[2][2]) == 0: #斜めチェック
    print("Yes")
    exit()

if sum(a[2][0],a[1][1],a[0][2]) == 0: #逆斜めチェック
    print("Yes")
    exit()

#n(Yes)=0のとき
print("No")

Buggy submission (verdict: Runtime Error):
# Atcoder ABC 157
# Problem B

a = []
 for i in range(3):
  a.append(list(map(int,input().split())))

n = int(input())

for _ in range(n):  #b_n roop
   b = int(input())
   for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] == 0  #make a 0
        
for i in range(3):
    if sum(a[i]) == 0: #横チェック
     print("Yes")
     exit()
    if sum(a[0][i],a[1][i],a[2][i]) == 0: #縦チェック
     print("Yes")
     exit()

if sum(a[0][0],a[1][1],a[2][2]) == 0: #斜めチェック
    print("Yes")
    exit()

if sum(a[2][0],a[1][1],a[0][2]) == 0: #逆斜めチェック
    print("Yes")
    exit()

#n(Yes)=0のとき
print("No")
Problem p02761 (python)

Fixed submission:
#Problem C
n, m = map(int, input().split())
L = [list(map(int,input().split())) for _ in range(m)] #s_i, c_i

for i in range(10**n): #ぜんぶやる
    st = str(i)
    if len(st) == n and all(st[s-1] == str(c) for s, c in L): #長さ＝桁数がiで、かつ全てにおいて[s=c]すなわち[stのs番目の文字＝c]となるとき
        print(i)
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
#Problem C
n, m = map(int, input().split())
L = [list(map(int,input().split())) for _ in range(m)] #s_i, c_i

for i in range(10**n): #ぜんぶやる
    st = str(i)
    if len(i) == n and all(st[s-1] == str(c) for s, c in L): #長さ＝桁数がiで、かつ全てにおいて[s=c]すなわち[stのs番目の文字＝c]となるとき
        print(i)
        exit()

print(-1)
Problem p02767 (python)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
t = round(sum(x) / n)
p = 0
for i in x:
    p += ((i-t)**2)
print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
t = round(sum(x) / N)
p = 0
for i in x:
    p += ((i-t)**2)
print(p)
Problem p02783 (python)

Fixed submission:
h, a = map(int, input().split())
print(-(-h//a))

Buggy submission (verdict: Runtime Error):
(h,n),*t=[list(map(int,o.split()))for o in open(0)]
d=[0]*(h+10100)
for i in range(1,h+1):d[i]=min(d[i-a]+b for a,b in t)
print(d[h])
Problem p02787 (python)

Fixed submission:
def chmin(dp, i, *x):
  dp[i] = min(dp[i], *x)
INF = float("inf")

# dp[i] := min 消耗する魔力 to H -= i
h, n = map(int, input().split())
dp = [0] + [INF]*h
for _ in [None]*n:
  a, b = map(int, input().split())
  for j in range(h + 1):
    chmin(dp, min(j + a, h), dp[j] + b)
print(dp[h])

Buggy submission (verdict: Runtime Error):
(h,n),*t=[list(map(int,o.split()))for o in open(0)]
d=[0]*(h+100)
for i in range(1,h+1):d[i]=min(d[i-a]+b for a,b in t)
print(d[h])

Buggy submission (verdict: Runtime Error):
(h,n),*t=[list(map(int,o.split()))for o in open(0)]
d=[0]*-~h
for i in range(1,h+1):d[i]=min(d[i-a]+b for a,b in t)
print(d[h])

Buggy submission (verdict: Runtime Error):
(h,n),*t=[map(int,o.split())for o in open(0)]
dp=[0]*(h+10100)
for i in range(1,h+1):dp[i]=min(dp[i-a]+b for a,b in t)
print(dp[h])
Problem p02802 (python)

Fixed submission:
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split()
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)

Buggy submission (verdict: Runtime Error):
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
print("Yes" if K * 500 >= X else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if int(input()) * 500 >= int(input()) else "No")
Problem p02837 (python)

Fixed submission:
#!/usr/bin/env python3
from itertools import*
I = input
n = int(I())
c = 0;z = []
for i in range(n):
    for j in range(int(I())):
        z += [[i] + list(map(int, I().split()))]
for j in product([0,1], repeat=n):
    if all(j[i] == 0 or j[x-1] - y == 0 for i, x, y in z):
        c = max(c, sum(j))
print(c)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from itertools import*
n = int(input())
c = 0
z = [eval("[i] + list(map(int, input().split())),"*int(input())) for i in range(n)]
for j in product([0,1], repeat=n):
    if all(j[i] == 0 or j[x-1] - y == 0 for i, x, y in chain.from_iterable(z)):
        c = max(c, sum(j))
print(c)
Problem p02838 (python)

Fixed submission:
n, *a = map(int, open(0).read().split())
MOD = 10**9 + 7
c = 0
for i in range(61):
  i = 2**i
  t = sum(i & b and 1 for b in a)
  c = (c + t * (n - t) * i) % MOD
print(c)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split());c=0;i=1
for _ in[0]*61:i**=2;t=sum(i&b and 1for b in a);c+=t*(n-t)*i;c%=10**9+7
print(c
Problem p02845 (python)

Fixed submission:
_, a = open(0)
mod = 10**9+7
c = 1
l = [3] + [0]*10**6

for a in a.split():
  a = int(a)
  c = c * l[a] % mod
  l[a] -= 1
  l[a+1] += 1
print(c)

Buggy submission (verdict: Runtime Error):
_, a = open(0)
mod = 10**9+7
c = 1
l = [3] + [0]*10**6

for a in a.split():
  a = int(a)
  c = c * l[a] % mod
  d[a] -= 1
  d[a] += 1
print(c)

Buggy submission (verdict: Runtime Error):
_, *a = open(0)
mod = 10**9+7
c = 1
l = [3] + [0]*10**6

for a in a.split():
  a = int(a)
  c = c * l[a] % mod
  d[a] -= 1
  d[a] += 1
print(c)