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

Fixed submission:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(7):
    b.append(int(input()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(7):
    b.append(int(input()))

for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        print('Yes')
        quit()

for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        print('Yes')
        quit()
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    quit()
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print('Yes')
    quit()
print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(7):
    b.append(int(input()))
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        print('Yes')
        quit()

for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        print('Yes')
        quit()
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    quit()
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print('Yes')
    quit()
print('No')
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
if n == 3:
    l = range(100, 1000)
if n == 2:
    l = range(10, 100)
if n == 1:
    l = range(0, 10)
flag = False
for i in l:
    num = str(i)
    if all([num[s-1] == str(c) for s, c in sc]):
        #print(num)
        #exit()
        flag = True
        ans = num
        break
if flag:
    print(num)
else:
    print(-1)
#print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
first = True
for i in s:
    if i == 0 and first and len(s) != 1:
        ans += str(1)
        first = False
        continue
    ans += str(i)
if len(ans) != len(str(int(s))):
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
first = True
for i in s:
    if i == 0 and first and len(s) != 1:
        ans += str(1)
        first = False
        continue
    ans += str(i)
if len(ans) != 1 and len(str(int(s))):
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
s = [0] * n
for i in sc:
    s[i[0]-1] = str(i[1])
ans = ""
cnt = True
for i in s:
    #print(i)
    if i == '0' and cnt and len(s) != 1:
        ans += str(1)
        cnt = False
    ans += str(i)
#print(ans)
if len(ans) != len(int(ans)):
    print(-1)
else:
    print(ans)
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
def mod_comb(n, r, mod):
    ans = 1
    for i in range(1, r + 1):
        ans *= n - (i - 1)
        ans %= mod
        ans *= inv[i]
        ans %= mod
    return int(ans)
p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
def mod_comb(n, r, mod):
    ans = 1
    for i in range(1, r + 1):
        ans *= n - (i - 1)
        ans %= mod
        ans *= inv[i]
        ans %= mod
    return int(ans)
 p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
def cmb(n, r, p):
    ans = 1
    for i in range(1, r + 1):
        ans *= 
        ans /= i
        ans %= mod
    return int(ans)
 p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)
Problem p02786 (python)

Fixed submission:
H = int(input())
s = 1
while H!=0:
    H = divmod(H, 2)[0]
    s *= 2
s = s / 2
p = s - 1
print(int(s + p))

Buggy submission (verdict: Runtime Error):
H = int(input())
s = 1
while H!=0:
    H = divmod(H, 2)[0]
    s *= 2
s = s / 2
print(int(s + p))
Problem p02813 (python)

Fixed submission:
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

junretu = [i + 1 for i in range(N)]
cnt = 0
for i in itertools.permutations(junretu, N):
    cnt += 1
    if i == p:
        a = cnt
        #cnt += 1
    if i == q:
        b = cnt
        #cnt += 1
    #cnt += 1
print(abs(a - b))

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

junretu = [i + 1 for i in range(N)]
cnt = 0
for i in itertools.permutations(junretu, N):
    cnt += 1
    if i == p:
        a = cnt
        #cnt += 1
    elif i == q:
        b = cnt
        #cnt += 1
    #cnt += 1
print(abs(a - b))
Problem p02830 (python)

Fixed submission:
n = int(input())
s, t = input().split()
ans = ""
for i, j in zip(s, t):
    ans += i + j
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s, t = input().split(
ans = ""
for i, j in zip(s, t):
    ans += i + j
print(ans)
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())
h = x / (a ** 2)
s = x / a
if h > b / 2:
    ans = math.atan((b - h) * 2 / a)
    print(math.degrees(ans))
else:
    ans = math.atan(b ** 2 / (2 * s))
    print(math.degrees(ans))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
h = x / (a ** 2)
s = x / s
if h > b / 2:
    ans = math.atan((b - h) * 2 / a)
    print(math.degrees(ans))
else:
    ans = math.atan(b ** 2 / (2 * s))
    print(math.degrees(ans))
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(0, a - 2 * b))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()
from bisect import bisect_left
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        ans += bisect_left(A, A[i] + A[j]) - bisect_left(A, A[j]) - 1
print(ans)
Problem p02900 (python)

Fixed submission:
a, b = map(int, input().split())
import fractions
gcd = fractions.gcd(a, b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    #arr.append([1, 1])
    return arr
if a == 1 or b == 1:
    print(len(factorization(gcd)))
    quit()
print(len(factorization(gcd)) + 1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
import math
gcd = math.gcd(A, B)
#gcd
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
# n == 1のとき、[1, 1]を返す
def factorization(n):
    
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if gcd == 1:
    print(1)
else:
    ans = len(factorization(gcd)) + 1
    print(ans)
Problem p02911 (python)

Fixed submission:
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

all_score = [k - q for _ in range(n)]
for ai in a:
    all_score[ai - 1] += 1
for j in all_score:
    if j > 0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
import numpy as np

all_score = np.array([k for _ in range(n)])
for i in a:
    all_score -= 1
    all_score[i - 1] += 1

print(np.where(all_score > 0)[0].tolist()[0])
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
rela = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    rela[a].append(b)
    rela[b].append(a)
hoge = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    hoge[p] += x
from collections import deque
que = deque([0])
while que:
    cur = que.pop()
    for new in rela[cur]:
      	if new == cur:
          continue
        hoge[new] += hoge[cur]
        que.append(new)
print(*hoge)
Problem p02972 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        s[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if s[j] == 1:
                cnt += 1
        if cnt % 2 == a[i]:
            s[i] = 0
        else:
            s[i] = 1
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        ans[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if ans[j] == 1:
                cnt += 1
        #ans[i] = cnt % 2 + a[i]
        if cnt % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1 
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
import numpy as np
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

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

import numpy
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i+2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)

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

import numpy
p = np.array(p)
cnt = 0
for i in range(1, n-1):
    pi = np.array(p[i-1:i +2])
    #print(pi)
    if np.argsort(pi)[1] == 1:
        cnt += 1
print(cnt)
Problem p02995 (python)

Fixed submission:
A, B, C, D = map(int, input().split())

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
div_c = B // C
div_d = B // D
cd = lcm(C, D)
div_cd = B // cd
B_ = B - (div_c + div_d - div_cd)

A -= 1
div_c2 = A // C
div_d2 = A // D
div_cd2 = A // cd
A_ = A - (div_c2 + div_d2 - div_cd2)

print(B_ - A_)

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

import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
div_c = B // C
div_d = B // D
cd = lcm(C, D)
div_cd = B // cd
B_ = B - (div_c + div_d - div_cd)

div_c2 = A // C
div_d2 = A // D
div_cd2 = A // cd
A_ = A - (div_c2 + div_d2 - div_cd2)

print(B_ - A_)
Problem p03086 (python)

Fixed submission:
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
cnt = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
for si in s:
    if si in acgt:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
    #print(ans)
print(ans)
Problem p03160 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
dp = [float('Inf')] * n
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
x = list(map(int, input().split()))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(abs(gcd(*x)))

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

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(gcd(*x))
Problem p03282 (python)

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

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == K - 1:
            print(1)
            break
        else:
            continue

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

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == N - 1:
            print(1)
            break
        else:
            continue

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

for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        break
    else:
        if i == N - 1:
            print(1)
            break
        else:
            continue
Problem p03289 (python)

Fixed submission:
S = input()

C_S = S[2 : len(S) - 1]

#flag = True
if S[0] != 'A':
    #flag = False
    print('WA')
    quit()
    #break
if not 'C' in C_S and C_S.count('C') != 1:
    #flag = False
    #break
    print('WA')
    quit()
c_index = S.index('C')
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(S)):
    if i == 0 or i == c_index:
        continue
    elif S[i] not in alpha:
        #flag = False
        #break
        print('WA')
        quit()
    else:
        continue
print('AC')

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

#c_index = S.index('C')
if S[0] != 'A':
    print('WA')
    quit()
elif S.count('C') != 1:
    print('WA')
    quit()
c_index = S.index('C')
elif 2 > c_index or c_index > len(S) - 2:
    print('WA')
    quit()
else:
    disc = S[1:c_index] + S[c_index + 1:]
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(disc)):
    if not disc[i] in alpha:
        print('WA')
        quit()
    else:
        continue
print('AC')

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

c_index = S.index('C')
if S[0] != 'A':
    print('WA')
    quit()
elif S.count('C') != 1:
    print('WA')
    quit()
#c_index = S.index('C')
elif 2 > c_index or c_index > len(S) - 2:
    print('WA')
    quit()
else:
    disc = S[1:c_index] + S[c_index + 1:]
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(disc)):
    if not disc[i] in alpha:
        print('WA')
        quit()
    else:
        continue
print('AC')
#print(disc)

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

flag = False
if S[0] != 'A':
    print('WA')
    quit()
elif S.count('C') != 1:
    print('WA')
    quit()
elif S[2] == 'C' or S[-2] == 'C':
    c_index = S.index('C')
    if c_index == 2:
        disc = S[1] + S[3:]
    else:
        disc = S[1:len(S) - 1] + S[-1]
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(disc)):
    if not disc[i] in alpha:
        print('WA')
        quit()
    else:
        continue
print('AC')
#print(disc)

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

flag = False
if S[0] != 'A':
    print('WA')
    quit()
elif S.count('C') != 1:
    print('WA')
    quit()
elif S[2] == 'C' or S[-2] == 'C':
    c_index = S.index('C')
    if c_index == 2:
        disc = S[1] + S[3:]
    elif c_index == len(S) - 2:
        disc = S[1:len(S) - 2] + S[-1]
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(disc)):
    if not disc[i] in alpha:
        print('WA')
        quit()
    else:
        continue
print('AC')
#print(disc)
Problem p03436 (python)

Fixed submission:
from collections import deque

def bfs():
    flag = False
    d = [[float('inf')] * W for i in range(H)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((0, 0))
    d[0][0] = 0

    while que:
        p = que.popleft()
        if p[0]==H-1 and p[1]==W-1:
            flag = True
            break

        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            if 0<=nx<W and 0<=ny<H and maze[ny][nx]!='#' and d[ny][nx]==float("inf"):
                que.append((ny, nx))
                d[ny][nx] = d[p[0]][p[1]] + 1

    if flag==False:
        return False

    return d[H-1][W-1]

def notcount(H, W, maze):
    cnt = 0

    for i in range(H):
        for j in range(W):
            if maze[i][j]=='#':
                cnt += 1

    return cnt

H, W = map(int, input().split())
maze = [list(input()) for i in range(H)]
if bfs()==False:
    print(-1)
else:
    s = (H * W - notcount(H, W, maze)) - (bfs() + 1)
    #bfs()
    print(s)

Buggy submission (verdict: Runtime Error):
from collections import deque
def bfs(maze, sy, sx, gy, gx):
    d = [[-1] * w for _ in range(h)]
    que = deque([[sy, sx]])
    #print(que)
    d[sy][sx] = 0
    while que:
        y, x = que.popleft()
        if y == gy and x == gx:
            break
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ny, nx = y + j, x + k
            if 0 <= nx < w  and 0 <= ny < h  and d[ny][nx] == -1 and maze[ny][nx] != "#":
                d[ny][nx] = d[y][x] + 1
                que.append([ny, nx])
                
    return d
gx, gy = w - 1, h - 1
def counting(maze, h, w, aim):
    cnt = 0
    for i in range(h):
        for j in range(w):
            if maze[i][j] == aim:
                cnt += 1
    return cnt
a = bfs(maze, 0, 0, gy, gx)
if a[gy][gx] == -1:
    print(-1)
else:
    print(h * w - (counting(maze, h, w, '#') + (a[gy][gx] + 1)))
Problem p03449 (python)

Fixed submission:
N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]

dp = [[0] * N for _ in range(2)]

dp[0][0] = maze[0][0]
for j in range(1, N):
    dp[0][j] = dp[0][j - 1] + maze[0][j]

dp[1][0] = dp[0][0] + maze[1][0]

for i in range(1, N):
    dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])

print(dp[1][N - 1])

Buggy submission (verdict: Runtime Error):
N = int(input())
#maze = [[0] * (N + 10) for _ in range(2)]
maze = [list(map(int, input().split())) for _ in range(2)]

dp = [[0] * N for _ in range(2)]

dp[0][0] = maze[0][0]
for j in range(1, N):
    dp[0][j] = dp[0][j - 1] + maze[0][j]]

dp[1][0] = dp[0][0] + maze[1][0]
for i in range(1, N):
    dp[1][i] = max(dp[0][i] + maze[1][i], dp[1][i - 1] + maze[1][i])

print(dp[1][N - 1])
Problem p03633 (python)

Fixed submission:
import fractions
def multi_lcm(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

N = int(input())
T = [int(input()) for _ in range(N)]
print(multi_lcm(T))

Buggy submission (verdict: Runtime Error):
import math
def multi_lcm(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = ans * a[i] // fractions.gcd(ans, a[i])
    return ans

N = int(input())
T = [int(input()) for _ in range(N)]
print(multi_lcm(T))
Problem p03673 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        #print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))

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

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])

print(' '.join([str(i) for i in b]))

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

from collections import deque
b = deque([])
if len(a) % 2 == 0:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.appendleft(a[i - 1])
        else:
            b.append(a[i - 1])
else:
    for i in range(1, N + 1):
        print(b)
        if i % 2 == 0:
            b.append(a[i - 1])
        else:
            b.appendleft(a[i - 1])