Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())  
A = [int(x) for x in input().split()]

index = 0
value = abs(A[0] - X)
up_list = [0]*(N+1)
down_list = [0]*(N+1)

for i in range(N):
  if abs(A[i] - X ) < N+1:
    if A[i] - X >= 0:
      up_list[A[i]-X] = 1
    if A[i] - X <= 0:
      down_list[abs(A[i]- X)] = 1

j = 0
while True:
  if down_list[j] == 0:
    print(X-j)
    break
  if up_list[j] ==0:
    print(X+j)
    break
  if j>N+1:
    print('fail')
    break
  j+=1
  
    

Fixed submission:
X, N = map(int, input().split())
if not N ==0:
  A = [int(x) for x in input().split()]
  index = 0
  value = abs(A[0] - X)
  up_list = [0]*(N+1)
  down_list = [0]*(N+1)

  for i in range(N):
    if abs(A[i] - X ) < N+1:
      if A[i] - X >= 0:
        up_list[A[i]-X] = 1
      if A[i] - X <= 0:
        down_list[abs(A[i]- X)] = 1

  j = 0
  while True:
    if down_list[j] == 0:
      print(X-j)
      break
    if up_list[j] ==0:
      print(X+j)
      break
    if j>N+1:
      print('fail')
      break
    j+=1

else:
  print(X)

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())  
A = [int(x) for x in input().split()]

index = 0
value = abs(A[0] - X)
up_list = [0]*(N+1)
down_list = [0]*(N+1)

for i in range(N):
  if abs(A[i] - X ) < N+1:
    if A[i] - X >= 0:
      up_list[A[i]-X] = 1
    if A[i] - X <= 0:
      down_list[abs(A[i]- X)] = 1

j = 0
while True:
  if up_list[j] ==0:
    print(X+j)
    break
  if down_list[j] == 0:
    print(X-j)
    break
  if j>N+1:
    print('fail')
    break
  j+=1
  

Fixed submission:
X, N = map(int, input().split())
if not N ==0:
  A = [int(x) for x in input().split()]
  index = 0
  value = abs(A[0] - X)
  up_list = [0]*(N+1)
  down_list = [0]*(N+1)

  for i in range(N):
    if abs(A[i] - X ) < N+1:
      if A[i] - X >= 0:
        up_list[A[i]-X] = 1
      if A[i] - X <= 0:
        down_list[abs(A[i]- X)] = 1

  j = 0
  while True:
    if down_list[j] == 0:
      print(X-j)
      break
    if up_list[j] ==0:
      print(X+j)
      break
    if j>N+1:
      print('fail')
      break
    j+=1

else:
  print(X)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(1,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print('-1')
else:
    print(sum0)

Fixed submission:
N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

N = int(input())

str_list = list(map(int,input().split()))

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print('-1')
else:
    print(sum0)

Fixed submission:
N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

N = int(input())

str_list = list(map(int,input().split()))

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print(-1)
else:
    print(sum0)

Fixed submission:
N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
L = []

N = int(input())

str_list = list(map(int,input().split()))

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print(-1)
else:
    print(sum0)

Fixed submission:
N = int(input())

str_list = list(map(int,input().split()))

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)
Buggy python submission (verdict: Runtime Error):
L = []

while True:
    l = list(map(int, input().split()))
    if l:
        L.append(l)
    else:
        break

print(L)

N = L[0][0]
K = L[0][1]

Num = list(range(1, N + 1, 1))

new_L = L[2::2]

new_LL = sum(new_L, [])
for n in new_LL:
    if n in Num:
        Num.remove(n)

print(len(Num))

Fixed submission:
import sys

L = []
"""
while True:
    l = input()
    if l == "":
        break
    else:
        L.append(list(map(int,l.split())))
        print(L)
"""
N,K = list(map(int,input().split()))

#print(N,K)

for a in range(2 * K):
    n = list(map(int,input().split()))
    L.append(n)

#print("End",L)

Num = list(range(1, N + 1, 1))
#print(Num)
new_L = L[1::2]
#print(new_L)

new_LL = sum(new_L, [])
for n in new_LL:
    if n in Num:
        Num.remove(n)

print(len(Num))

Buggy python submission (verdict: Runtime Error):
L = []
while True:
    l = list(map(int, input().split()))
    if l:
        L.append(l)
    else:
        break

N = L[0][0]
K = L[0][1]

Num = list(range(1,N+1,1))

new_L = L[2::2]

new_LL = sum(new_L,[])
for n in new_LL:
    if n in Num:
        Num.remove(n)

print(len(Num))


Fixed submission:
import sys

L = []
"""
while True:
    l = input()
    if l == "":
        break
    else:
        L.append(list(map(int,l.split())))
        print(L)
"""
N,K = list(map(int,input().split()))

#print(N,K)

for a in range(2 * K):
    n = list(map(int,input().split()))
    L.append(n)

#print("End",L)

Num = list(range(1, N + 1, 1))
#print(Num)
new_L = L[1::2]
#print(new_L)

new_LL = sum(new_L, [])
for n in new_LL:
    if n in Num:
        Num.remove(n)

print(len(Num))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
lst2 =[]
maxval2 = 0
flag = 0
maxval = max(lst)
for _ in range(n-1):
  lst.pop(lst.index(maxval))
  maxval2 = max(lst)
  if maxval == maxval2:
    print('NO')
    flag = 1
    break
  maxval = maxval2
if flag == 0:
  print('YES')


Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flag = 0
lst.sort()
for i in range(n-1):
  if lst[i] == lst[i+1]:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
lst2 = []
flag = 0
for _ in range(max(lst)):
  lst2.append(0)
for i in range(n):
  if lst2[lst[i]-1] == 0:
    lst2[lst[i]-1] += 1
  else:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flag = 0
lst.sort()
for i in range(n-1):
  if lst[i] == lst[i+1]:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
k = 1
flag = 0
for i in range(n):
  lst2 = list(map(lambda x: x-lst[i], lst))
  lst2.pop(i)
  for j in lst2:
    k *= j
  if k == 0:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flag = 0
lst.sort()
for i in range(n-1):
  if lst[i] == lst[i+1]:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
k = 1
flag = 0
for i in range(n):
  lst2 = list(map(lambda x: x-lst[i], lst))
  lst2.pop(i)
  for j in lst2:
    k *= j
  if k == 0:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flag = 0
lst.sort()
for i in range(n-1):
  if lst[i] == lst[i+1]:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
flag = 0
for i in range(n):
  for j in range(i):
    if lst[i] == lst[j]:
      print('NO')
      flag = 1
      break
  if flag == 1:
    break
  if i == n-1:
    flag = 2
if flag == 2:
  print('YES')

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flag = 0
lst.sort()
for i in range(n-1):
  if lst[i] == lst[i+1]:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list(map(int, input().split()))
flag = 0
for i in range(n):
  for j in range(i):
    if lst[i] == lst[j]:
      print('NO')
      flag = 1
      break
  if flag == 1:
    break
  if i == n-1:
    flag = 2
if flag == 2:
  print('YES')

Fixed submission:
n = int(input())
lst = list(map(int, input().split()))
flag = 0
lst.sort()
for i in range(n-1):
  if lst[i] == lst[i+1]:
    print('NO')
    flag = 1
    break
if flag == 0:
  print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
max = 0
a = 0
for i in range(n-k+1):
  for j in range(k):
    a += lst[i+j]
  if max < a:
    max = a
  a = 0
print((max+k)/2)

Fixed submission:
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
sum = 0
for j in range(k):
  sum += lst[j]
max = sum
for i in range(n-k):
  sum = sum-lst[i]+lst[i+k]
  if max < sum:
    max = sum
print((max+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
max = 0
a = 0
for i in range(n-k+1):
  for j in range(k):
    a += lst[i+j]
  if max < a:
    max = a
  a = 0
print((max+k)/2)

Fixed submission:
n, k = list(map(int, input().split()))
lst = list(map(int, input().split()))
sum = 0
for j in range(k):
  sum += lst[j]
max = sum
for i in range(n-k):
  sum = sum-lst[i]+lst[i+k]
  if max < sum:
    max = sum
print((max+k)/2)
Buggy python submission (verdict: Runtime Error):
h, n = list(map(int, input().split()))
lst = list(map(int, input().split()))
sum = 0
for _ in range(n):
  sum += lst[_]
if sum >= h:
  print('Yes')
else:
  print('No')

Fixed submission:
h, a = list(map(int, input().split()))
b = int(h/a)
if b == h/a:
  print(b)
else:
  print(b + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if lst[i] == min(lst[:i+1]):
    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
lst = list(map(int, input().split()))
cnt = 0
tempmin = lst[0]
for i in range(N):
  if lst[i] <= tempmin:
    cnt += 1
    tempmin = lst[i]
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = list(map(int, input().split()))
cnt = 0
for i in range(N):
  if lst[i] == min(lst[:i+1]):
    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
lst = list(map(int, input().split()))
cnt = 0
tempmin = lst[0]
for i in range(N):
  if lst[i] <= tempmin:
    cnt += 1
    tempmin = lst[i]
print(cnt)
Buggy python submission (verdict: Runtime Error):
primes=[2]
x = int(input())
if x == 2:
  print(x)
else:
  i = 3
  while True:
    for p in primes:
      if i % p == 0:
        break
    else:
      primes.append(i)
      if x <= i:
        break
    i+=1
  print(primes[-1])

Fixed submission:
a, b = input().split()
print(b+a)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = [int(x) for x in input().split()]
while k > 0:
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  k -= 1
print(a, b)

Fixed submission:
a, b, k = [int(x) for x in input().split()]
if a > k:
  a-=k
else:
  k-=a
  a = 0
  if b > k:
    b-=k
  else:
    b=0
print(a, b)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = [int(x) for x in input().split()]
while k > 0:
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  k -= 1
print(a, b)

Fixed submission:
a, b, k = [int(x) for x in input().split()]
if a > k:
  a-=k
else:
  k-=a
  a = 0
  if b > k:
    b-=k
  else:
    b=0
print(a, b)
Buggy python submission (verdict: Runtime Error):
i = int(input()) 
s = input()
if i >= 1 and 100 >= i and i % 2 == 0 and i == len(s) and s.isalpha() and s.islower():
  t_0 = s[0]
  t_1 = s[i/2]
    for j in range(1, i/2):
      t_0 += s[j]
    for k in range(i/2 + 1, i):
      t_1 += s[k]
    if t_0 == t_1:
      print("Yes")
    else:
      print("No")


Fixed submission:
i = int(input()) 
s = input()
if i >= 1 and 100 >= i and i % 2 == 0 and i == len(s) and s.isalpha() and s.islower():
  n = (int)(i/2)
  t_0 = s[0]
  t_1 = s[n]
  for j in range(1, n):
    t_0 += s[j]
  for k in range(n + 1, i):
    t_1 += s[k]
  if t_0 == t_1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
i = int(input())
if i >= 1 and 100 >= i and i % 2 == 0:  
  s = input()
    if i == len(s) and s.isalpha() and s.islower():  
      t_0 = s[0]
      t_1 = s[i/2]
	  for j in range(1, i/2):
	    t_0 += s[j]
      for k in range(i/2 + 1, i):
        t_1 += s[k]
      if t_0 == t_1:
        print("Yes")
      else:
        print("No")


Fixed submission:
i = int(input()) 
s = input()
if i >= 1 and 100 >= i and i % 2 == 0 and i == len(s) and s.isalpha() and s.islower():
  n = (int)(i/2)
  t_0 = s[0]
  t_1 = s[n]
  for j in range(1, n):
    t_0 += s[j]
  for k in range(n + 1, i):
    t_1 += s[k]
  if t_0 == t_1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
i = int(input())
if i >= 1 and 100 >= i and i % 2 == 0:  
  s = input()
if i == len(s) and s.isalpha() and s.islower():  
  t_0 = s[0]
  t_1 = s[i/2]
	for j in range(1, i/2):
	  t_0 = t_0 + s[j]
    for k in range(i/2 + 1, i):
      t_1 = t_1 + s[k]
  if t_0 == t_1:
    print("Yes")
  else:
    print("No")

Fixed submission:
i = int(input()) 
s = input()
if i >= 1 and 100 >= i and i % 2 == 0 and i == len(s) and s.isalpha() and s.islower():
  n = (int)(i/2)
  t_0 = s[0]
  t_1 = s[n]
  for j in range(1, n):
    t_0 += s[j]
  for k in range(n + 1, i):
    t_1 += s[k]
  if t_0 == t_1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
i = int(input())
if ( i >= 0 and 100 >= i and (i % 2 == 0) ):  
  s = input()
  t_0 = s[0]
  t_1 = s[i/2]
	for j in range(1, i/2):
	  t_0 = t_0 + s[j]
    for k in range(i/2 + 1, i):
      t_1 = t_1 + s[k]
  if (t_0 == t_1):
    print('Yes')
  else:
    print('No')

Fixed submission:
i = int(input()) 
s = input()
if i >= 1 and 100 >= i and i % 2 == 0 and i == len(s) and s.isalpha() and s.islower():
  n = (int)(i/2)
  t_0 = s[0]
  t_1 = s[n]
  for j in range(1, n):
    t_0 += s[j]
  for k in range(n + 1, i):
    t_1 += s[k]
  if t_0 == t_1:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
ans=1
for i in a:
    ans*=i
    #print(ans)
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n=int(input())
a=sorted(list(map(int, input().split())))
ans=1
f=True
for i in a:
    ans*=i
    if ans>10**18:
        f=False
        break
if f:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = map(int, input().split())

if abs(x)//d >= k:
  print(abs(abs(x) - k*d))

else:
  a = 1
  while abs(x) - d*a >=0:
    a += 1
  if (k-(a-1)) % 2 ==0:
    print(abs(abs(x) - (a-1)*d))
  else:
    print(abs(abs(x) - a*d))


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

if abs(x)//d >= k:
  print(abs(abs(x) - k*d))

else:
#  a = 1
  y = abs(x)//d
  a = y + 1
#  while abs(x) - d*a >=0:
#    a += 1
  if (k-(a-1)) % 2 ==0:
    print(abs(abs(x) - (a-1)*d))
  else:
    print(abs(abs(x) - a*d))
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n[0] ==7 or n[1] ==7 or n[2] ==7:
  print('Yes')
else:
  print('No')


Fixed submission:
n = str(input())

if n[0] =='7' or n[1] =='7' or n[2] =='7':
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n = int(input())

sum = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      sum += gcd(i, j, k)
      
print(sum)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
n = int(input())

sum = 0
for i in range(1,n+1):
  for j in range(i,n+1):
    for k in range(j,n+1):
#      print(i, j, k)
      if i ==j and i == k:
        sum += gcd(i, j, k)
      elif i == j or j == k or i == k:
        sum += gcd(i, j, k)*3
      else: 
        sum += gcd(i, j, k)*6
#      print(sum)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n, b, r = map(int, input().split())

num = 0
res_b = 0
cnt = n//2 + n%2

for _ in range(cnt):
  num += b
  if num > n:
    res_b += b - (num - n)
  else:
    res_b += b
      
  num += r

  if num > n:
    break
  
print(res_b)

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

cnt_blk = n // (b+r)
res_b = cnt_blk*b
num = cnt_blk*(b+r) + b

if num > n:
  res_b += b - (num - n)
else:
  res_b += b
      
print(res_b)

Buggy python submission (verdict: Time Limit Exceeded):
n, b, r = map(int, input().split())

num = 0
count = 0
res_b = 0
res_r = 0

for _ in range(n):
  if count % 2 == 0:
    num += b
    if num > n:
      res_b += b - (num - n)
    else:
      res_b += b
      
  else:
    num += r

  count += 1

  if num > n:
    break
  
print(res_b)

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

cnt_blk = n // (b+r)
res_b = cnt_blk*b
num = cnt_blk*(b+r) + b

if num > n:
  res_b += b - (num - n)
else:
  res_b += b
      
print(res_b)

Buggy python submission (verdict: Time Limit Exceeded):
n, b, r = map(int, input().split())

num = 0
count = 0
res_b = 0
res_r = 0

while num <= n:
  if count % 2 == 0:
    num += b
    if num > n:
      res_b += b - (num - n)
    else:
      res_b += b
      
  else:
    num += r
#    if num > n:
#      res_r += r - (num - n)
#    else:
#      res_r += r

  count += 1

print(res_b)

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

cnt_blk = n // (b+r)
res_b = cnt_blk*b
num = cnt_blk*(b+r) + b

if num > n:
  res_b += b - (num - n)
else:
  res_b += b
      
print(res_b)

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

num = 0
count = 0
res = ''

while num <= n:
  if count % 2 == 0:
    res += 'b'*b
    num += b
  else:
    res += 'r'*r
    num += r
  count += 1

ans = 0
for i in range(n):
  if res[i] == 'b':
    ans += 1
print(ans)

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

cnt_blk = n // (b+r)
res_b = cnt_blk*b
num = cnt_blk*(b+r) + b

if num > n:
  res_b += b - (num - n)
else:
  res_b += b
      
print(res_b)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

ans = list('0'*m)

for i in range(m):
  a, b = map(int, input().split())
  
  if a==1 and b ==0:
    print(-1)
    exit()
  if ans[a-1] != '0' and ans[a-1] != str(b):
    print(-1)
    exit()
    
  ans[a-1] = str(b)

ans = int(''.join(ans))
print(ans)


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

ans = list(' '*n)

for i in range(m):
  a, b = map(int, input().split())
  
  if n != 1 and a==1 and b ==0:
    print(-1)
    exit()
  if ans[a-1] != ' ' and ans[a-1] != str(b):
    print(-1)
    exit()
    
  ans[a-1] = str(b)

if ans[0] == ' ' and n != 1:
  ans[0] = '1'
ans = ''.join(ans)

print(int(ans.replace(' ', '0')))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

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

min_ = min(list)
max_ = max(list)

total = []
for i in range(min_, max_):
  length = 0
  for j in range(n):
  	length += (list[j] - i)**2
  total.append(length)
print(min(total))

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

min_ = min(list)
max_ = max(list)

total = []
if min_ == max_:
  print(0)
else:
  for i in range(min_, max_):
    length = 0
    for j in range(n):
  	  length += (list[j] - i)**2
    total.append(length)
  print(min(total))

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

min_ = min(list)
max_ = max(list)

total = []
for i in range(min_, max_):
  length = 0
  for j in range(n):
  	length += (list[j] - i)**2
  total.append(length)
print(min(total))

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

min_ = min(list)
max_ = max(list)

total = []
if min_ == max_:
  print(0)
else:
  for i in range(min_, max_):
    length = 0
    for j in range(n):
  	  length += (list[j] - i)**2
    total.append(length)
  print(min(total))
Buggy python submission (verdict: Time Limit Exceeded):
# t=int(input())
# for _ in range(t):
#     n=int(input())
#     arr=[int(x) for x in input().split()]
def sumall(n):
    sum=0
    while n:
        #print(n%10)
        sum+=n%10
        n=n//10
    #print(sum)
    return sum
    
n=int(input())
if sumall(n)%9 == 0:
    print("Yes")
else:
    print("No")
#print(t*need)

Fixed submission:
# t=int(input())
# for _ in range(t):
#     n=int(input())
#     arr=[int(x) for x in input().split()]
n=int(input())
if n%9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
#include<iostream>
using namespace std;
int main(){
    long int n;
    cin>>n;
    long int a=0,w=0,r=0,t=0;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC")
        a+=1;
        else if(s=="WA")
        w+=1;
        else if(s=="TLE")
        t+=1;
        else
        r+=1;
    }
    cout<<"AC "<<"* "<<a<<endl;
    cout<<"WA "<<"* "<<w<<endl;
    cout<<"TLE "<<"* "<<t<<endl;
    cout<<"RA "<<"* "<<r<<endl;
    return 0;
}


Fixed submission:
# cook your dish here
n=int(input())
if n%1000==0 :
    print(0)
else :
    print(1000-(n%1000))
Buggy python submission (verdict: Runtime Error):
res, prev, count = 0, '', 0
for s in S:
  if s == 'R':
    count += 1
  else:
    res = max(res, count)
    count = 0
res = max(res, count)
return res

Fixed submission:
S = input()
res, prev, count = 0, '', 0
for s in S:
  if s == 'R':
    count += 1
  else:
    res = max(res, count)
    count = 0
print(max(res, count))
Buggy python submission (verdict: Runtime Error):
S = input()
if len(S) == 1:
  print("No")
else:
  while (len(S) != 0):
    if S[0] == 'h' and S[1] == 'i':
      S = S[2:]
    else:
      break
  if len(S) != 0:
    print("No")
  else:
    print("Yes")

Fixed submission:
S = input()
if len(S) % 2 == 1:
  print("No")
else:
  while (len(S) != 0):
    if S[0] == 'h' and S[1] == 'i':
      S = S[2:]
    else:
      break
  if len(S) != 0:
    print("No")
  else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
S = input();
while (len(S) != 0):
  if S[0] == 'h' and S[1] == 'i':
    S = S[2:]
  else:
    break
if len(S) != 0:
  print("No")
else:
  print("Yes")


Fixed submission:
S = input()
if len(S) % 2 == 1:
  print("No")
else:
  while (len(S) != 0):
    if S[0] == 'h' and S[1] == 'i':
      S = S[2:]
    else:
      break
  if len(S) != 0:
    print("No")
  else:
    print("Yes")