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

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

r = []

if A%10 != 0:
    r.append(10 - A%10)
    A += 10 - A%10
if B%10 != 0:
    r.append(10 - B%10)
    B += 10 - B%10
if C%10 != 0:
    r.append(10 - C%10)
    C += 10 - C%10
if D%10 != 0:
    r.append(10 - D%10)
    D += 10 - D%10
if E%10 != 0:
    r.append(10 - E%10)
    E += 10 - E % 10

if r:
    print(A+B+C+D+E-max(r))
else:
    print(A+B+C+D+E)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

r = []

if A%10 != 0:
    r.append(10 - A%10)
    A += 10 - A%10
if B%10 != 0:
    r.append(10 - B%10)
    B += 10 - B%10
if C%10 != 0:
    r.append(10 - C%10)
    C += 10 - C%10
if D%10 != 0:
    r.append(10 - D%10)
    D += 10 - D%10
if E%10 != 0:
    r.append(10 - E%10)
    E += 10 - E % 10

print(A+B+C+D+E-max(r))
Problem p03282 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    if K >= 1e3:
        K = 105

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    c = 0
    for i in range(len(S)):
        if S[i] == '1':
            c += 1
        else:
            break
    if c >= 1 and K <= c:
        print(1)

    T = S.replace('1', '')
    print(T[0])


if __name__ == '__main__':
    main()
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
s = [input() for i in range(H)]

# 四隅
# 左上
if s[0][0] == '#':
    if s[0][1] == '.' and s[1][0] == '.':
        print('No')
        exit()
# 右上
if s[0][W - 1] == '#':
    if s[0][W - 2] == '.' and s[1][W - 1] == '.':
        print('No')
        exit()
# 左下
if s[H - 1][0] == '#':
    if s[H - 1][1] == '.' and s[H - 2][0] == '.':
        print('No')
        exit()
# 右下
if s[H - 1][W - 1] == '#':
    if s[H - 1][W - 2] == '.' and s[H - 2][W - 1] == '.':
        print('No')
        exit()

# 上辺
for i in range(1, W - 1):
    if s[0][i] == '#':
        if s[0][i - 1] == '.' and s[0][i + 1] == '.' and s[1][i] == '.':
            print('No')
            exit()

# 下辺
for i in range(1, W - 1):
    if s[H - 1][i] == '#':
        if s[H - 1][i - 1] == '.' and s[H - 1][i + 1] == '.' and s[H - 2][i] == '.':
            print('No')
            exit()

# 左辺
for i in range(1, H - 1):
    if s[i][0] == '#':
        if s[i - 1][0] == '.' and s[i + 1][0] == '.' and s[i][1] == '.':
            print('No')
            exit()

# 右辺
for i in range(1, H - 1):
    if s[i][W - 1] == '#':
        if s[i - 1][W - 1] == '.' and s[i + 1][W - 1] == '.' and s[i][W - 2] == '.':
            print('No')
            exit()

# 中央
for h in range(1, H - 1):
    for w in range(1, W - 1):
        if s[h][w] == '#':
            if s[h - 1][w] == '.' and s[h + 1][w] == '.' and s[h][w - 1] == '.' and s[h][w + 1] == '.':
                print('No')
                exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
zero_pad = '.' * W
s = []
s.append(zero_pad)
for i in range(H):
    s.append('.' + input() + '.')
s.append(zero_pad)

for h in range(1, H + 1):
    for w in range(1, W + 1):
        if s[h][w] == '#':
            if s[h - 1][w] == '.' and s[h + 1][w] == '.' and s[h][w - 1] == '.' and s[h][w + 1] == '.':
                print('No')
                exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = ['.' * W]
s.append('.' + input() + '.' for i in range(H))
s.append('.' * W)

for h in range(1, H + 1):
    for w in range(1, W + 1):
        if s[h][w] == '#':
            if s[h - 1][w] == '.' and s[h + 1][w] == '.' and s[h][w - 1] == '.' and s[h][w + 1] == '.':
                print('No')
                exit()

print('Yes')
Problem p03435 (python)

Fixed submission:
c = []
for i in range(3):
    x, y, z = map(int, input().split())
    c.append(x)
    c.append(y)
    c.append(z)

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = c[0] - a1
            b2 = c[1] - a1
            b3 = c[2] - a1
            if c[3] == a2 + b1 and c[4] == a2 + b2 and c[5] == a2 + b3 and c[6] == a3 + b1 and c[7] == a3 + b2 and c[8] == a3 + b3:
                print('Yes')
                exit()
print('No')

Buggy submission (verdict: Runtime Error):
c = []
for i in range(3):
    x, y, z = map(int, input().split())
    c.append(x)
    c.append(y)
    c.append(z)

for a1 in range(100):
    for a2 in range(100):
        for a3 in range(100):
            b1 = c[0] - a1
            b2 = c[1] - a2
            b3 = c[2] - a3
            if c[4] == a2 + b1 and c[5] == a2 + b2 and c[6] == a2 + b3 and c[7] == a3 + b1 and c[8] == a3 + b2 and c[9] == a3 + b3:
                print('Yes')
                exit()
print('No')
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if int(a*b) % 2 == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a*b % 2 == 0:
  print('Even')
else:
  print('Odd)
Problem p03548 (python)

Fixed submission:
x, y, z = map(int, input().split())

x -= z
y += z
print(x // y)

Buggy submission (verdict: Runtime Error):
64145 123 456
Problem p03695 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    a = list(map(int, input().split()))

    l = [0] * 9
    for i in range(N):
        n = a[i] // 400
        if n > 8:
            n = 8
        l[n] += 1

    ans_min = 0
    for i in range(8):
        if l[i] > 0:
            ans_min += 1



    gold = l[8]

    ans_max = ans_min
    ans_max += gold

    if ans_min == 0:
        ans_min = 1

    print(ans_min, ans_max)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    a = list(map(int, input().split()))

    l = [0] * 9
    for i in range(N):
        l[a[i] // 400] += 1

    ans_min = 0
    for i in range(8):
        if l[i] > 0:
            ans_min += 1

    gold = l[8]
    if gold > 8:
        gold = 8

    if ans_min == 0:
        ans_min = 1

    ans_max = ans_min
    non_color = l.count(0)
    if gold >= non_color:
        ans_max = 8
    else:
        ans_max += gold

    print(ans_min, ans_max)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))

c = [0] * 9
for i in a:
    c[i // 400] += + 1

ans_min = 0
for i in range(8):
    if c[i] > 0:
        ans_min += 1

ans_max = ans_min
if c[-1] == 0:
    pass
else:
    f = c[-1]
    g = c.count(0)
    ans_max += min(f, g)

print(ans_min, ans_max)
Problem p02733 (python)

Fixed submission:
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=0;t=j=w;d=[0]*h
 while j:
  i=c=0;j-=1
  while h-i:
   d[c]+=s[i][j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;r+=1;t,j=j,j+(t>j);i=h
 m+=r+c,
print(min(m))

Buggy submission (verdict: Runtime Error):
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=512
while b:
  b-=1;r=t=j=0;d=[0]*h
  while w-j:
    i=c=0
    while h-i:
      d[c]+=s[i][j]>'0';f=d[c]>k
      if(t<j)&f: r+=1;t=j;d[0]*h;break
      r+=h*w*f;c+=b>>i&1;i+=1
    else:j+=1;v=c
  m+=r+v
print(min(m))

Buggy submission (verdict: Runtime Error):
x,*s=open(0)
h,w,k,*m=map(int,x.split())
for b in range(512):
  r=t=j=0;d[0]*h
  while w-j:
    i=c=0
    while(h-i):
      d[c]+=s[i][j]>'0'; x=d[c]>k
      if(t<j)&x:r+=1;t=j;d=[0]*h;break
      r+=h*w*x;c+=b>>i&1;i+=1
      else:j+=1
  m+=r+bin(b).count('1'),
print(min(m))
Problem p02755 (python)

Fixed submission:
a,b = map(int,input().split())
for i in range(1, 1001):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    print(i)
    break
else:
  print('-1')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
for i in range(1, 1001):
  if floor(i * 0.08) == a and floor(i * 0.1) == b:
    print(i)
else:
  print('-1')
Problem p02760 (python)

Fixed submission:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0　or a[2][0] == a[1][1] == a[0][2]:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0　and a[2][0] == a[1][1] == a[0][2]:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')
Problem p02767 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
ans = list()
for p in range(1,101):
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  ans.append(v_sum)
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  ans.append(v_sum)
print(ans.min())

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  	ans.append(v_sum)
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - x)**2
  	ans.append(v_sum)
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - x)**2
  	ans.append(v_sum)
print(ans.min())
Problem p02772 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
for a in A:
  if a % 2 == 0:
    if a % 5 != 0 and a % 3 != 0:
      print('DENIED')
      break
else:
  print('APPROVED')

Buggy submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
  a = int(input())
  if a % 2 == 0:
    if a % 5 != 0 or a % 3 != 0:
      print('DENIED')
      break
else:
  print('APPROVED')
Problem p02778 (python)

Fixed submission:
s = input()
print('x' * len(s))

Buggy submission (verdict: Runtime Error):
S = input()
T = ''
for _ in len(S):
  T += 'x'
print(T)

Buggy submission (verdict: Runtime Error):
S = input()
for _ in len(S):
  print('x')
Problem p02791 (python)

Fixed submission:
n = int(input())
P = list(map(int,input().split()))
ans = 0
mi = P[0]
for i in range(n):
    if P[i] <= mi:
        mi = P[i]
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(n):
    m == min(P[0:i+1])
    if P[i] == m:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
P = [int(input()) for _ in range(n)]
c = 0 
for i in range(n):
  for j in range(0,i):
    if P[i] ＞ P[j]:
      break
  else:
    c += 1
print(c)
Problem p02865 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N//2+1):
  if i != N-i:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1,N/2+1):
  if i != N-i:
    ans += 1
print(ans)
Problem p03024 (python)

Fixed submission:
S=input()
cnt=0
for c in S:
   cnt+=c=='o'
if cnt+15-len(S)>=8:
   print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
S=input()
cnt=0
for c in S:
   cnt+=c=='o'
if cnt＞=8:
   print('YES')
else:
  print('NO')
Problem p03047 (python)

Fixed submission:
N,K=map(int,input().split())
print(N-K+1)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans = 0
if N == K:
  print(1)
  exit()
for _ in range(N-K):
  ans++
print(ans)
Problem p03437 (python)

Fixed submission:
X,Y = map(int,input().split())
if X%Y == 0:
  print(-1)
else:
  print(X*(Y-1))

Buggy submission (verdict: Runtime Error):
X,Y = map(int.input().split())
if X%Y == 0:
  print(-1)
else:
  print(X*Y-1)
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print((x-a)%b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
print(count)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if (a*b) % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [map(int,input().split()) for i in range(n)]
t,x,y = (0,0,0)
for next_pos in s:
    t_next,x_next,y_next = next_pos
    dist = abs(x_next - x) + abs(y_next - y)
    dt = t_next - t
    if dist > t_next - t:
        print('No')
        break
    elif dt % 2 == dist % 2:
        t,x,y = t_next,x_next,y_next
    else:
        print('No')
        break
else:
    print('Yes')
Problem p03477 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
L = a+b
R = c+d
if L > R:
  print('Left')
elif L < R:
  print('Right')
else:
  print('Balanced')

Buggy submission (verdict: Runtime Error):
def somesum(n):
    sum = 0
    x = n
    while int(x / 10) > 0:
        sum += x % 10
        x = int(x / 10)
    sum += x % 10
    return sum
    
n,a,b = map(int,input().split())
sum = 0
for val in range(1,n+1):
    if somesum(val) >= a and somesum(val) <= b:
        sum += val
print(sum)
Problem p03493 (python)

Fixed submission:
s = input()
n = 0
for a in s:
    if a == '1':
        n += 1
print(n)

Buggy submission (verdict: Runtime Error):
m = int(input())
number_list = list(map(int,input().split()))
n = 0
while 1:
    f = False
    for i in range(0,m):
        if number_list[i] % 2 != 0:
            f = True
    if f == True:
        break
    for i in range(0,m):
        number_list[i] = number_list[i] / 2
    n += 1
print(n)

Buggy submission (verdict: Runtime Error):
m = int(input())
number_list = list(map(int,input().split()))
n = 0
while 1:
    f = False
    for i in range(0,m):
        if number_list[i] % 2 != 0:
            f = True
    if f == True:
        break
    for i in range(0,m):
        number_list[i] = number_list[i] / 2
    n += 1
print(n)
Problem p03545 (python)

Fixed submission:
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print(e[:-1]+'=7')
        break

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e) == 7:
        print('{}=7'.format(e))
        break

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e) == 7:
        print(e)
        break
Problem p03970 (python)

Fixed submission:
S = input()
T = 'CODEFESTIVAL2016'
ans = 0
for i in range(16):
  ans += S[i] != T[i]
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = 'CODEFESTIVAL2016'
ans = 0
for _ in range(16):
  ans += S[i] != T[i]
print(ans)
Problem p04001 (python)

Fixed submission:
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j]
    ans += eval(e)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    eval = ''
    for j in range(l):
        if ((i >> j) & 1):
            eval += s[j] + '+'
        else:
            eval += s[j]
    ans += eval(eval)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(s):
  ans += int(s[0:i]) + int(s[i:len(s)])
ans += int(s)
print(ans)
Problem p02574 (python)

Fixed submission:
import math as m

N=int(input())
As=list(map(int,input().split()))


D=[0]*(10**6+1)
for i in range(2,int(m.sqrt(10**6))+2):
    if D[i]!=0:
        continue
    j=2*i
    while j < 10**6+1:
        D[j]=i
        j+=i

P=[0]*10**6
pc=True
g=As[0]
for n in range(N):
    A=As[n]
    g=m.gcd(g,A)
    if A==1:
        continue
    ppre=1
    while True:
        p=D[A] if D[A]!=0 else A
        if ppre != p:
            if P[p] > 0:
                pc=False
            P[p]+=1
            ppre=p
        A=A//p
        if A==1:
            break

if pc:
    print('pairwise coprime')
elif g==1:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
import math as m

N=int(input())
As=list(map(int,input().split()))


D=[0]*(10**6+1)
D[1]=1
for i in range(2,int(m.sqrt(10**6))+2):
    if D[i]!=0:
        continue
    j=i
    while j < 10**6+1:
        D[j]=i
        j+=i

P=[0]*10**6
pc=True
g=As[0]
for n in range(N):
    A=As[n]
    ppre=1
    while True:
        p=D[A]
        if ppre != p:
            if P[p] > 0:
                pc=False
            P[p]+=1
            ppre=p
        A=A//p
        if A==1:
            break
    g=m.gcd(g,A)

if pc:
    print('pairwise coprime')
elif g==1:
    print('setwise coprime')
else:
    print('not coprime')
Problem p02698 (python)

Fixed submission:
import collections
import bisect
import sys

sys.setrecursionlimit(10 ** 8)

def f(v):
    state[v] = 1
    a=As[v]
    idx = bisect.bisect_left(D,a)
    stack.append( (idx,D[idx]) ) # push
    D[idx] = a
    
    ans[v] = bisect.bisect_left(D,float('inf'))

    for u in V[v]:
        if state[u] == 0:
            f(u)

    # 巻き戻し
    i_pre,d_pre=stack.pop()
    D[i_pre] = d_pre



N=int(input())
As=list(map(int,input().split()))

D=[float('inf')]*N
stack=collections.deque([])
ans=[0]*N
state=[0]*N

V=[[] for _ in range(N)]
for _ in range(N-1):
    u,v=map(int,input().split())
    V[u-1].append(v-1)
    V[v-1].append(u-1)

f(0)

print(*ans,sep='\n')

Buggy submission (verdict: Runtime Error):
import collections
import bisect

def f(v):
    #state[v] = 1
    a=As[v]
    idx = bisect.bisect_left(D,a)
    stack.append( (idx,D[idx]) ) # push
    D[idx] = a
    
    ans[v] = bisect.bisect_left(D,float('inf'))

    for u in V[v]:
        # if state[u] == 1: 木構造なので不要
        len_pre=len(stack)
        
        f(u)

        # 巻き戻し
        while len(stack) > len_pre:
            i_pre,d_pre=stack.pop()
            D[i_pre] = d_pre



N=int(input())
As=list(map(int,input().split()))

D=[float('inf')]*N
stack=collections.deque([])
ans=[0]*N
#state=[0]*N

V=[[] for _ in range(N)]
for _ in range(N-1):
    u,v=map(int,input().split())
    V[u-1].append(v-1)

f(0)

print(*ans,sep='\n')
Problem p02945 (python)

Fixed submission:
A,B=[int(e) for e in input().split(' ')]
print(max([A+B,A-B,A*B]))

Buggy submission (verdict: Runtime Error):
A,B=[int(e) for r in input().split(' ')]
print(max([A+B,A-B,A*B]))
Problem p03071 (python)

Fixed submission:
A,B=[int(e) for e in input().split(' ')]
print(max([A+A-1,A+B,B+B-1]))

Buggy submission (verdict: Runtime Error):
A,B=[int(e) for e in input()]
print(max([A+A-1,A+B,B+B-1]))
Problem p02632 (python)

Fixed submission:
def main():
    k = int(input())
    s = input()
    n = len(s)

    def cmb1(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7
    N = 2*10**6
    fac = [1]*(N+1)
    finv = [1]*(N+1)
    for i in range(N):
        fac[i+1] = fac[i] * (i+1) % mod
    finv[-1] = pow(fac[-1], mod-2, mod)
    for i in reversed(range(N)):
        finv[i] = finv[i+1] * (i+1) % mod

    def cmb1(n, r, mod):
        if r <0 or r > n:
            return 0
        r = min(r, n-r)
        return fac[n] * finv[r] * finv[n-r] % mod

    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res

    ans = 0
    for i in range(k+1):
        temp = power(25, i, mod)
        temp *= cmb1(i+n-1, n-1, mod)
        temp %= mod
        temp *= power(26, k-i, mod)
        temp %= mod
        ans += temp
    print(ans%mod)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    k = int(input())
    s = input()
    n = len(s)

    def cmb1(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res

    ans = 0
    for i in range(k+1):
        temp = power(25, i, mod)
        temp *= cmb1(i+n-1, n-1, mod)
        temp %= mod
        temp *= power(26, k-i, mod)
        temp %= mod
        ans += temp
    print(ans%mod)

if __name__ == '__main__':
    main()