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

Fixed submission:
from fractions import gcd
n,m=map(int,input().split())
print(3*(n-gcd(n,m)))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n,m=map(int,input().split())
print(3*(n-gcd(n,m))
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))
for i in range(5):
  if x[i] == 0:
    print(i+1)
    break

Buggy submission (verdict: Runtime Error):
x = list(int, input().split())
for i in range(5):
  if x[i] == 0:
    print(i)
    break
Problem p02658 (python)

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

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a = sort(a)
if a[0] == 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > 10^(18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
result = 1
while result <= 10^(18):
  result *= a[i] for i in range(n)
else:
  print(-1)
    
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
result = 1
while result <= 10^(18):
  result *= a[i]
else:
  print(-1)
    
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map((int, input().split()))
result = 1
for i in range(n):
         result *= a[i]
if result > 10^(18):
         result = -1
print(result)
Problem p02713 (python)

Fixed submission:
from math import gcd
K = int(input())
sum_gcd = [0]*201
ans = 0
 
for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += sum_gcd[i]*gcd(i,k)

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
K = int(iniput())
sum_gcd = [0]*201
ans = 0
 
for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += sum_gcd[i]*gcd(i,k)
 
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
K = int(iniput())
sum_gcd = [0]*201
ans = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += GCD[i]*gcd(i,k)

print(ans)

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

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      gcd = math.gcd(math.gcd(a, b), c) 
      sum_gcd += gcd

print(sum_gcd)

Buggy submission (verdict: Runtime Error):
import math
sum_gcd = 0
K = int(input())

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      gcd = math.gcd(a, b, c) 
      sum_gcd += gcd

print(sum_gcd)

Buggy submission (verdict: Runtime Error):
import math

K = int(input())

for a in range(K):
  for b in range(K):
    for c in range(K):
      gcd = math.gcd(a, b, c)
      
      sum_gcd += gcd

print(sum_gcd)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()

ri = [i for i, x in enumerate(s) if x=='R']
gi = [i for i, x in enumerate(s) if x=='G']
bi = [i for i, x in enumerate(s) if x=='B']

ans = len(ri) * len(gi) * len(bi)

for i in range(n):
    for d in range(n):
        j=i+d
        k=i+2*d
        if k>=n:
            break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())

ri = [i for i, x in enumerate(s) if x=='R']
gi = [i for i, x in enumerate(s) if x=='G']
bi = [i for i, x in enumerate(s) if x=='B']

ans = len(ri) * len(gi) * len(bi)

for i in range(n):
    for d in range(n):
        j=i+d
        k=i+2*d
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)

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

r_i = [i for i, x in enumerate(s) if x=='R']
g_i = [i for i, x in enumerate(s) if x=='G']
b_i = [i for i, x in enumerate(s) if x=='B']

ans = 0

for i in len(r_i):
    for j in len(g_i):
        for k in len(b_i):
            if r_i[i]!=g_i[j] and g_i[j]!=b_i[k] and b_i[k]!=r_i[i]:
                ans += 1

print(ans)

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

r_i = [i for i, x in enumerate(s) if x=='R']
g_i = [i for i, x in enumerate(s) if x=='G']
b_i = [i for i, x in enumerate(s) if x=='B']

ans = 0

for i in len(r_i):
    for j in len(g_i):
        for k in len(b_i):
            if r_i[i]!=g_i[j] and g_i[j]!=b_i[k] and b_i[k]!=r_i[i]:
                ans += 1

print(ans)
Problem p02718 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
sumA = sum(A[i] for i in range(N))

s = sum(A[i] / sumA >= 1 / (4 * M) for i in range(N))

if s >= M:
  print('Yes')
else:
  print('No')

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

s = sum(A[i] >= 1 / (4 * M) for i in N)

if s >= M:
  print('Yes')
else:
  print('No')
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())

m = n % k
m1 = k - m

if m > m1:
  ans = m1
else:
  ans = m
print(ans)

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

N = [abs(n - i*k) for i in range(n)]
ans = min(N)
print(ans)

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

N = [abs(n - ik) for i in range(n)]
ans = min(N)
print(ans)
Problem p02732 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(max(a)+1)]
for x in a:
    b[x] += 1
c = sum([x*(x-1)//2 for x in b])
for i in range(n):
    print(c-b[a[i]]+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N+1)

for i in A:
    B[i] += 1
sum_original = sum(j*(j-1)//2 for j in B)
for k in range(N):
    print(sum_original - (B[A[k]]+1)

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

for k in range(N):
    del A[k]
    ans = 0
    
    for i in range(1,N+1):
        n = A.count(i)
        nc2 = n * (n-1) / 2
        ans += nc2
    print(ans)

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

for k in range(N):
    del A[k]
    ans = 0
    
    for i in range(1,N+1):
        n = A.count(i)
        nc2 = n * (n-1) / 2
        ans += nc2
    print(ans)

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

for k in range(N):
    del A[k]
    ans = 0
    
    for i in range(1,N+1):
        n = sum(A[j] == i for j in range(N-1))
        nc2 = n * (n-1) / 2
        ans += nc2
    print(ans)

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

for k in range(N):
         del A[k]
         ans = 0
         for i in range(1,N+1):
         	n = sum(A[j] == i for j in range(1,N))
         	nc2 = n * (n-1) / 2
         	ans += nc2
         
         print(ans)

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

for k in range(1, N+1):
         A = A.remove(k)
         ans = 0
         for i in range(1,N+1):
         	n = sum(A[j] == i for j in range(1,N))
         	nc2 = n * (n-1) / 2
         	ans += nc2
         
         print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
N = list(range(1,N+1))
A = list(map(int, input().split())

for k in range(1, N+1):
         A = A.remove(A[k])
         ans = 0
         for i in range(1,N+1):
         	n = sum(A[j] == i for j in range(1,N))
         	nc2 = n * (n-1) / 2
         	ans += nc2
         
         print(ans)
Problem p02755 (python)

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

from math import ceil

a1 = ceil(a / 0.08)
a2 = ceil((a+1) / 0.08)
b1 = ceil(b / 0.1)
b2 = ceil((b+1) / 0.1)

m = min([a1,b1])

if m == a1:
    if b1 in range(a1,a2):
        ans = b1
        print(ans)
    else:
        print('-1')

else:
    if a1 in range(b1,b2):
        ans = a1
        print(ans)
    else:
        print('-1')

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

from math import ceil

a1 = ceil(a / 0.08)
a2 = ceil((a+1) / 0.08)
b1 = ceil(b / 0.1)
b2 = ceil((b+1) / 0.1)

m = min([a1,b1])

if m == a1:
    if b1 in range(a1,a2):
        ans = b1
    else:
        print('-1')

if m == b1:
    if a1 in range(b1,b2):
        ans = a1
    else:
        print('-1')

print(ans)
Problem p02760 (python)

Fixed submission:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0
ans = 'No'
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0: ans = 'Yes'
    if a[0][i] + a[1][i] + a[2][i] == 0: ans = 'Yes'
if a[0][0] + a[1][1] + a[2][2] == 0: ans = 'Yes'
if a[0][2] + a[1][1] + a[2][0] == 0: ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input9())
r = []
for _ in range(3):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0
ans = 'No'
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0: ans = 'Yes'
    if a[0][i] + a[1][i] + a[2][i] == 0: ans = 'Yes'
if a[0][0] + a[1][1] + a[2][2] == 0: ans = 'Yes'
if a[0][2] + a[1][1] + a[2][0] == 0: ans = 'Yes'
print(ans)
Problem p03102 (python)

Fixed submission:
n,m,c=map(int,input().split())
b=list(map(int,input ().split()))
num=0
for _ in range(n):
  a=list(map(int,input().split()))
  hoge=0
  for i in range(m):
    hoge+=a[i]*b[i]
  if hoge+c>0:
    num+=1
print(num)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m,c=map(int,input().split())
b=list(map(int,input ().split()))
num=0
for i in range(n):
  a=list(map(int,input().split()))
  hoge=np.dot(b*a)+c
  if hoge>0:
    num+=1
print(num)
Problem p03456 (python)

Fixed submission:
a,b=input().split()
c=int(a+b)
d=c**0.5
if float.is_integer(d):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b=input().split()
c=a+b
d=np.sqrt(c)
if isinstance(d,int):
  print('Yes')
else:
  print('No')
Problem p03971 (python)

Fixed submission:
n,a,b=map(int, input().split())
s=list(input())
num=0
num_f=0
qual=[]
for i in range(n):
  if num<a+b:
    if s[i]=='a':
      num+=1
      qual.append('Yes')     
    elif s[i]=='b' and num_f<b:
      num+=1
      num_f+=1
      qual.append('Yes')
    else:
      qual.append('No')   
  else:
    qual.append('No')
for i in range(n):
  print(qual[i])

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
s=list(input())
num=0
qual=[]
s_b=[i for i,x in enumerate(s) if x=='b']
for i in range(n):
  if num<a+b:
    if s[i]=='c':
      qual.append('No')
    elif s[i]=='a':
      num+=1
      qual.append('Yes')     
    else:
      if s_b.index(i)<b:
        num+=1
        qual.append('Yes')
      else:
        qual.append('No')   
  else:
    qual.append('No')
print(qual, split='\n')

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
s=input()
num=0
s_b=[i for i,x in s if x=='b']
for i in range(n):
  if s[i]=='c':
    print('No')
  elif s[i]=='a':
    if i <=(a+b):
      num+=1
      print('Yes')
    else:
      print('No')
  else:
    if s_b.index(i)<=b:
      num+=1
      print('Yes')
    else:
      print('No')   
  if num==a+b:
    break

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
s=list(input())
num=0
s_b=[i for i,x in s if x=='b']
for i in range(n):
  if s[i]=='c':
    print('No')
  elif s[i]=='a':
    if i <=(a+b):
      num+=1
      print('Yes')
    else:
      print('No')
  else:
    if s_b.index(i)<=b:
      num+=1
      print('Yes')
    else:
      print('No')   
  if num==a+b:
    break

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
s=list(map(input().split()))
num=0
s_b=[i for i,x in s if x=='b']
for i in range(n):
  if s[i]=='c':
    print('No')
  elif s[i]=='a':
    if i <=(a+b):
      num+=1
      print('Yes')
    else:
      print('No')
  else:
    if s_b.index(i)<=b:
      num+=1
      print('Yes')
    else:
      print('No')   
  if num==a+b:
    break
Problem p02783 (python)

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

if h%a == 0:
  print((int)(h/a))
else:
  print((int)(h/a)+1)

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

if h%a == 0:
  print((int))h/a))
else:
  print((int)(h/a)+1)

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

if h%a == 0:
  print((int))h/a))
else:
  print((int)(h/a)+1)

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

if h%a == 0:
  print((int)h/a)
else:
  print((int)(h/a)+1)

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

if h%a == 0:
  print(h/a)
else:
  print((int)(h/a)+1)

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

print(int(h/a))

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

print(h%a+1)
Problem p02784 (python)

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

a.sort(reverse=True)

sum=0
for i in range(n):
  sum += a[i]
  
if sum>=h:
  print("Yes")
else:
  print("No")

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

a.sort(reverse=True)

sum=0
for i in range(n):
  sum += a[i]
  
if sum>=h:
  print("Yes")
else:
  print("No")

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

a.sort(reverse=True)

sum=0
for i in Range(N):
  sum += a[i]
  
if sum>=h:
  print("Yes")
else:
  print("No")
Problem p02658 (python)

Fixed submission:
def solve(A):
    if 0 in A:
        return 0

    product = 1

    for a in A:
        product *= a

        if product > 10 ** 18:
            return -1

    return product


n = int(input())
A = list(map(int, input().split()))

print(solve(A))

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

if 0 in A:
  return 0

product = 1

for a in A:
  product *= a

  if product > 10 ** 18:
    return -1

  return product
Problem p02694 (python)

Fixed submission:
import math


def actual(x):
    amount = 100

    count = 0

    while True:
        amount *= 1.01
        amount = math.floor(amount)

        count += 1

        if amount >= x:
            return count

x = int(input())
print(actual(x))

Buggy submission (verdict: Runtime Error):
def actual(x):
    amount = 100

    count = 0

    while True:
        amount *= 1.01
        amount = math.floor(amount)

        count += 1

        if amount >= x:
            return count

x = int(input())
print(actual(x))
Problem p02705 (python)

Fixed submission:
import math


def actual(r):
    return 2 * r * math.pi

r = int(input())
print(actual(r))

Buggy submission (verdict: Runtime Error):
def actual(r):
    return 2 * r * math.pi

r = int(input())
print(actual(r))
Problem p02706 (python)

Fixed submission:
def actual(n, m, a_list):
    a_sum = sum(a_list)

    if n >= a_sum:
        return n - a_sum

    return -1

n, m = map(int, input().split())
a_list = map(int, input().split())

print(actual(n, m, a_list))

Buggy submission (verdict: Runtime Error):
def actual(n, m, a_list):
    a_sum = sum(a_list)

    if n >= a_sum:
        return n - a_sum

    return -1

N, M = map(int, input().split())
a_list = map(int, input().split())

print(actual(n, m, a_list))
Problem p03085 (python)

Fixed submission:
b = raw_input()
if b=="A":
	print("T")
elif b=="T":
	print("A")
elif b=="G":
	print("C")
elif b=="C":
	print("G")

Buggy submission (verdict: Runtime Error):
b = raw_input()
if b=="A":
	print("T")
elif b=="T":
	print("A")
elif b=="G":
	print("C")
elif b=="C":
	print("G")

Buggy submission (verdict: Runtime Error):
if b=="A":
	print("T")
elif b=="T":
	print("A")
elif b=="G":
	print("C")
elif b=="C":
	print("G")

Buggy submission (verdict: Runtime Error):
b = raw_input()
if b=="A":
	print("T")
elif b=="T":
	print("A")
elif b=="G":
	print("C")
elif b=="C":
	print("G")

Buggy submission (verdict: Runtime Error):
b = input()
if b=="A":
  print("T")
else if b=="T":
  print("A")
else if b=="G":
  print("C")
else if b=="c":
  print("G")
Problem p02630 (python)

Fixed submission:
# import sys
# input = sys.stdin.readline
# import re
# import itertools
import collections

def main():
    n = int(input())
    s = input_list()
    sc = collections.Counter(s)
    q = int(input())
    data = []
    for i in range(q):
        b, c = input_list()
        sc[c] += sc[b]
        if i > 0:
            data.append(c*sc[b] - b * sc[b])
        if b in sc:
            sc.pop(b)
    ans = 0
    for k, v in sc.items():
        ans += k*v
    aa = [ans]
    for i, v in enumerate(data[::-1]):
        aa.append(aa[i] - v)
    for a in aa[::-1]:
        print(a)


def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# import sys
# input = sys.stdin.readline
# import re
# import itertools
import collections

def main():
    n = int(input())
    s = input_list()
    sc = collections.Counter(s)
    q = int(input())
    ans = []
    for i in range(q):
        b, c = input_list()
        sc[c] += sc[b]
        sc.pop(b)
        a = 0
        for k, v in sc.items():
            a += k*v
        ans.append(a)
    for a in ans:
        print(a)


def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

Fixed submission:
def main():
  a = []
  n = int(input())
  print((n/3)**3)

  
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math
import fractions
import collections
from functools import reduce
main()

Buggy submission (verdict: Runtime Error):
def main():
  a = []
  n = int(input())
  for x in range(1, n+1):
    for y in range(1, n+1):
      z = n - (x+y)
      if z <= 0:
        continue
      a.append(x*y*z)
  print(max(a))
          
  
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math
import fractions
import collections
from functools import reduce
main()
Problem p02767 (python)

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

max_x = max(x)
min_x = min(x)

ans = []
for i in range(1, 101):
  a = 0
  for xi in x:
    a += (xi - i)*(xi - i)
  ans.append(a)
  
print(min(ans))

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

max_x = max(x)
min_x = min(x)

ans = []
for i in range(min_x, max_x):
  a = 0
  for xi in x:
    a += (xi - (i+1))*(xi - (i+1))
  ans.append(a)
  
print(min(ans))
Problem p02844 (python)

Fixed submission:
n = int(input())
a = input()

r = 0
for i in range(10):
  s = a.find(str(i))
  if s == -1:
    continue
  for j in range(10):
    s2 = a.find(str(j), s + 1)
    if s2 == -1:
      continue
    for k in range(10):
      if a.find(str(k), s2 + 1) != -1:
        r += 1
print(r)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(input())

r = 0
for i in range(1000):
  t = str(i).zfill(3)
  ti = 0
  if t[ti] > a[0]:
    a = a[1:]
  for si in range(len(a)):
    if a[si] == t[ti]:
      ti += 1
      if ti == 3:
        break
  if ti == 3:
    r += 1

print(r)
Problem p02936 (python)

Fixed submission:
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1): #木グラフの隣接リストを作成
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q): #各頂点についてcount[v]を計算
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1) #DFSのスタックによる実装、まずスタックに始点1を積む
checked=[0]*(n+1) #各頂点を見たかどうかのフラグを持っておく
while q:
  v=q.pop()
  checked[v]=1 #頂点を見たかどうかのフラグを更新す
  for u in g[v]:
    if checked[u]==1: #vの子ノードuについて、まだ見ていない頂点であればcount[u]をcount[u]+=count[v]として更新する
      continue
    cnt[u]+=cnt[v]
    q.append(u) #スタックに子ノードuを積む
print(*cnt[1:]) #各頂点のcountが答えとなる

Buggy submission (verdict: Runtime Error):
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)
  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 child in tree_index[cur]:
    if child == par:
      continue
    ans[child] += ans[cur]
    dfs(child, cur)
dfs(0, -1)
print(*ans)

Buggy submission (verdict: Runtime Error):
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)
  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 child in tree_index[cur]:
    if child == par:
      continue
    ans[child] += ans[cur]
    dfs(child, cur)
dfs(0, -1)
print(*ans)