Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(str(n))

ans = 0

for i in range(len(a)-3):
    for j in range(len(a)-3-i):
        k = a[i:i+4+j]
        if len(k)==4 and int(k[0])%2 !=0:
            continue
        elif len(k)==4 and k[0]=="2" and k[1]!= "0":
            continue
        elif len(k)==5 and int(k[1])%2 != 0:
            continue
        elif len(k)==6 and int(k[2])%2 == 0:
            continue
        elif int("".join(map(str, k)))%2019 == 0:
            ans = ans + 1

print(ans)

Fixed submission:
s = input()[::-1]
#sは文字列 逆向きにしている
sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10         #dを１０倍
    d %= 2019       #dを2019で割る（2019は10と素なので意味はないかも）
    cnts[sum_of_digits] += 1
    #cntは2019個ある　modの値が同じごとに個数を計算して足したもの

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2  
                    #cnt conbination 2
                    #mod ごとに m(m − 1)/2
        
#(i, j)が条件をみたすのはTi−1 == Tj (mod2019)のとき
#Ti−1 - Tj == 0 (mod2019) と等価 Ti−1 == Tj (mod2019)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(str(n))

ans = 0

for i in range(len(a)-3):
    for j in range(len(a)-3-i):
        k = a[i:i+4+j]
        if len(k)==4 and int(k[0])%2 !=0:
            continue
        elif len(k)==4 and k[0]=="2" and k[1]!= "0":
            continue
        elif int("".join(map(str, k)))%2019 == 0:
            ans = ans + 1

print(ans)

Fixed submission:
s = input()[::-1]
#sは文字列 逆向きにしている
sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10         #dを１０倍
    d %= 2019       #dを2019で割る（2019は10と素なので意味はないかも）
    cnts[sum_of_digits] += 1
    #cntは2019個ある　modの値が同じごとに個数を計算して足したもの

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2  
                    #cnt conbination 2
                    #mod ごとに m(m − 1)/2
        
#(i, j)が条件をみたすのはTi−1 == Tj (mod2019)のとき
#Ti−1 - Tj == 0 (mod2019) と等価 Ti−1 == Tj (mod2019)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = list(str(n))

ans = 0

for i in range(len(a)-3):
    for j in range(len(a)-3-i):
        k = a[i:i+4+j]
        if int("".join(map(str, k)))%2019 == 0:
            ans = ans + 1

print(ans)

Fixed submission:
s = input()[::-1]
#sは文字列 逆向きにしている
sum_of_digits = 0

cnts = [0] * 2019

cnts[0] = 1

d = 1

for c in s:
    sum_of_digits += int(c) * d
    sum_of_digits %= 2019
    d *= 10         #dを１０倍
    d %= 2019       #dを2019で割る（2019は10と素なので意味はないかも）
    cnts[sum_of_digits] += 1
    #cntは2019個ある　modの値が同じごとに個数を計算して足したもの

ans = 0
    
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2  
                    #cnt conbination 2
                    #mod ごとに m(m − 1)/2
        
#(i, j)が条件をみたすのはTi−1 == Tj (mod2019)のとき
#Ti−1 - Tj == 0 (mod2019) と等価 Ti−1 == Tj (mod2019)

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

a = 0

for i in range(n):
  if s[i]=='R':
    for j in range(n):
      if s[j]=='G':
        for k in range(n):
          if s[k]=='B':
            if i<j<k:
              if (j-i)!=(k-j):
                a = a + 1
            elif i<k<j:
              if (k-i)!=(j-k):
                a = a + 1
            elif j<i<k:
              if (i-j)!=(k-i):
                a = a + 1
            elif j<k<i:
              if (k-j)!=(i-k):
                a = a + 1
            elif k<i<j:
              if (i-k)!=(j-i):
                a = a + 1
            elif k<j<i:
              if (j-k)!=(i-j):
                a = a + 1
          
print(a)	

Fixed submission:
n = int(input())

a = list(map(int, list(str(n))))

if a[0]==7 or a[1]==7 or a[2]==7:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import functools
n = int(input())

def gcd(nums):
    return functools.reduce(euclid, nums)

a = 0

for i in range(n):
  for j in range(n):
    for k in range(n):
      num = [i+1, j+1, k+1]
      a = a + gcd(num)
      
print(a)

Fixed submission:
import math
n = int(input())

a = 0
 
for i in range(n):
  for j in range(n):
    for k in range(n):
      t = math.gcd(i+1, j+1)
      a = a + math.gcd(t, k+1)
      
print(a)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())

while N>=K:
  N = N - K

while N!=0:
  if N>=np.abs(N-K):
    N = N-K
    if N<0:
      N = N * -1
  elif N==0:
    break
  else:
    break            
print(N)

Fixed submission:
N, K = map(int, input().split())
if N>=K:
  N = N%K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break  
  else:
    break
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

while N>=K:
  N = N - K

while N!=0:
  if N>=abs(N-K):
    N = N-K
    if N<0:
      N = N * -1
  elif N==0:
    break
  else:
    break            
print(N)

Fixed submission:
N, K = map(int, input().split())
if N>=K:
  N = N%K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break  
  else:
    break
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

while N>=K:
  N = N - K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break
  else:
    break            
print(N)

Fixed submission:
N, K = map(int, input().split())
if N>=K:
  N = N%K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break  
  else:
    break
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())


while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break
  else:
    break
            
print(N)

Fixed submission:
N, K = map(int, input().split())
if N>=K:
  N = N%K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break  
  else:
    break
print(N)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

if K==0:
    print(N)
else:
    while N!=0:
        if N>=abs(N-K):
            N = abs(N-K)
        elif N==0:
            break
        else:
            break
            
print(N)

Fixed submission:
N, K = map(int, input().split())
if N>=K:
  N = N%K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break  
  else:
    break
print(N)
Buggy python submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())
X -= 1
Y -= 1　　#１のところを０にするなど一つずつずらす
 
def dist(a, b):
  return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))
 #＋１は間の一つ繋がっている分

ANS = [0] * N  　　　#0がN個のリストを作成。一つ目はk=0の時（同じところ）
for i in range(N):
  for j in range(i):
    ANS[dist(i, j)] += 1　　#0にずらしたことで０から始まるi,jに対応できている
        
        #i,jの最小値のindexに１ずつ足していく
        
for a in ANS[1:]:　#indexが１以降（数字の差が１以上）のものを一つづつ出力
  print(a)
  


Fixed submission:
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
 
def dist(a, b):
  return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))

ANS = [0] * N
for i in range(N):
  for j in range(i):
    ANS[dist(i, j)] += 1

        
for a in ANS[1:]:
  print(a)

Buggy python submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())
X -= 1
Y -= 1　　#１のところを０にするなど一つずつずらす
 
def dist(a, b):
    return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))
 #＋１は間の一つ繋がっている分
 
ANS = [0] * N  　　　#0がN個のリストを作成。一つ目はk=0の時（同じところ）
for i in range(N):
    for j in range(i):
        ANS[dist(i, j)] += 1　　#0にずらしたことで０から始まるi,jに対応できている
        
        #i,jの最小値のindexに１ずつ足していく
        
for a in ANS[1:]:　#indexが１以降（数字の差が１以上）のものを一つづつ出力
  print(a)

Fixed submission:
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
 
def dist(a, b):
  return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))

ANS = [0] * N
for i in range(N):
  for j in range(i):
    ANS[dist(i, j)] += 1

        
for a in ANS[1:]:
  print(a)

Buggy python submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())
X -= 1
Y -= 1　　#１のところを０にするなど一つずつずらす
 
def dist(a, b):
    return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))
 #＋１は間の一つ繋がっている分

ANS = [0] * N  　　　#0がN個のリストを作成。一つ目はk=0の時（同じところ）
for i in range(N):
    for j in range(i):
        ANS[dist(i, j)] += 1　　#0にずらしたことで０から始まるi,jに対応できている
        
        #i,jの最小値のindexに１ずつ足していく
 
for a in ANS[1:]:　#indexが１以降（数字の差が１以上）のものを一つづつ出力
    print(a)

Fixed submission:
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
 
def dist(a, b):
  return min(abs(b-a), abs(X-a) + 1 + abs(b-Y), abs(Y-a) + 1 + abs(b-X))

ANS = [0] * N
for i in range(N):
  for j in range(i):
    ANS[dist(i, j)] += 1

        
for a in ANS[1:]:
  print(a)
Buggy python submission (verdict: Runtime Error):
c = sorted(list(map(int, input())))

if c[0]==A and c[2]==B:
  print('Yes')
else:
  print('No')



Fixed submission:
c = sorted(input())
 
if c[0]=='A' and c[2]=='B':
  print('Yes')
else:
  print('No')
Buggy python 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)]
flag = False
for i in range(3):
    if all(a[i][j] in b for j in range(3)): #bの中にa[i][j]があるかどうか
        flag = True
    if all(a[j][i] in b for j in range(3)):
        flag = True
if all(a[i][i] in b for i in range(3)) or all(a[i][2-i] in b for i in range(3)):
    flag = True
 
if flag:
    print("Yes")
else:
  

Fixed submission:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
flag = False
for i in range(3):
    if all(a[i][j] in b for j in range(3)): #bの中にa[i][j]があるかどうか
        flag = True
    if all(a[j][i] in b for j in range(3)):
        flag = True
if all(a[i][i] in b for i in range(3)) or all(a[i][2-i] in b for i in range(3)):
    flag = True
 
if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,x= list(map(int, input().split()))

L=list(map(int, input().split()))
d=0

for i in range(1,n):
    d+=L[i-1]
    if d>x:
        ans=i
        break
print(ans)

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

L=list(map(int, input().split()))
D=[0]
for i in range(0,n):
    D.append(D[i]+L[i])
ans=0
for i in range(n+1):
    if D[i]<=x:
        ans+=1
    else:
        break

print(ans)

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

L=list(map(int, input().split()))
d=0

for i in range(1,n+2):
    d+=L[i-1]
    if d>x:
        ans=i
        break
print(ans)

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

L=list(map(int, input().split()))
D=[0]
for i in range(0,n):
    D.append(D[i]+L[i])
ans=0
for i in range(n+1):
    if D[i]<=x:
        ans+=1
    else:
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
n, q = list(map(int, input().split()))
s = input()
for i in range(q):
    l, r = list(map(int, input().split()))
    print(len(s[l - 1:r].split("AC")) - 1)


Fixed submission:
b=input()

if b=="A":
    print("T")
elif b=="T":
    print("A")
elif b=="C":
    print("G")
else:
    print("C")
Buggy python submission (verdict: Runtime Error):
s = input()
ans = []
c=0
for st in s:
    if st in ["A","T","C","G"]:
        c+=1
    else:
        ans.append(c)
        c=0
print(max(ans))


Fixed submission:
s = input()+"E"
ans = []
c=0
for st in s:
    if st in ["A","T","C","G"]:
        c+=1
    else:
        ans.append(c)
        c=0
print(max(ans))

Buggy python submission (verdict: Runtime Error):
import re

s = input()
ans = []
while len(s) > 0:
    ans.append(len(re.match("[ATCG]*", s)[0]))
    s = s[1:-1]
print(max(ans))


Fixed submission:
s = input()+"E"
ans = []
c=0
for st in s:
    if st in ["A","T","C","G"]:
        c+=1
    else:
        ans.append(c)
        c=0
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = list(map(int, input().split()))
s = input()
for i in range(q):
    l, r = list(map(int, input().split()))
    print(len(s[l - 1:r].split("AC")) - 1)


Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = (1 if s[i:i + 2] == "AC" else 0) + t[i]
for i in range(q):
    l, r = list(map(int, input().split()))
    print(t[r - 1] - t[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=list(map(int,input().split()))
s=input()
lr=[list(map(int,input().split())) for i in range(q)]
for l,r in lr:
    print(len(s[l-1:r].split("AC"))-1)

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = (1 if s[i:i + 2] == "AC" else 0) + t[i]
for i in range(q):
    l, r = list(map(int, input().split()))
    print(t[r - 1] - t[l - 1])
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = n * (n - 1) // 2
result = [ans]
leader = [-1] * n
size = [1] * n


def leader_check(i):
    if leader[i] == -1:
        return i
    ln = leader_check(leader[i])
    leader[i] = ln
    return ln


for a, b in ab[:0:-1]:
    a, b = a - 1, b - 1
    la = leader_check(a)
    lb = leader_check(b)
    if la != lb:
        leader[la] = lb
        ans -= size[la] * size[lb]
        size[lb] += size[la]
    result.append(ans)

for i in result[::-1]:
    print(i)


Fixed submission:
a,b,c=list(map(int,input().split()))
if b>a*c:
    print(c)
else:
    print(int(b/a))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
b=len(s)
while "01" in s or "10" in s:
        s=s.replace("01","")
        s=s.replace("10","")
print(b-len(s))

Fixed submission:
s=input()
c0=s.count("0")
c1=s.count("1")
print(len(s)-abs(c0-c1))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=[int(i) for i in input().split()]
count=0
while c > 0:
    c -= 1
    count += 1
    if b > 0:
        b -= 1
        count += 1
    elif a>0:
        a -= 1
    else:
        break
if b>0:
    count+=b
print(count)

Fixed submission:
a,b,c=[int(i) for i in input().split()]
if c<b or c<=a+b:
    print(b+c)
else:
    print(a+b*2+1)
Buggy python submission (verdict: Runtime Error):
s, t = map(str, input().split())
l = len(t)-1
print('Yes') if s == t[:l] else print('No')

Fixed submission:
s = input()
t = input()
l = len(t)-1
if s == t[:l]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
if a < k:
    print(k)
else if a+b <= k:
    print(a)
else :
    print(a-(k-a-b))

Fixed submission:
a,b,c,k = map(int,input().split())
if a+b >= k:
    if a > k:
        print(k)
    else:
        print(a)
else :
    print(a-(k-a-b))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
k = int(input())
if a + b >= k:
    print(a)
else :
    print(a-(k-a-b))

Fixed submission:
a,b,c,k = map(int,input().split())
if a+b >= k:
    if a > k:
        print(k)
    else:
        print(a)
else :
    print(a-(k-a-b))
Buggy python submission (verdict: Runtime Error):
import math
import fractions

k = input()

sum = 0
for a in range(k):
    for b in range(k):
        x = fractions.gcd(a+1, b+1)
        for c in range(k):
            y = fractions.gcd(x, c+1)
            sum += y
print(sum)


Fixed submission:
import math
import fractions

k = input()

sum = 0
for a in range(int(k)):
    for b in range(int(k)):
        x = math.gcd(a+1, b+1)
        for c in range(int(k)):
            y = math.gcd(x, c+1)
            sum += y
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
r, g, b = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    if s[i] == 'G':
        g += 1
    if s[i] == 'B':
        b += 1
ans = r*g*b


def rgb(k, i):
    se = set([s[i], s[i+k], s[i+2*k]])
    if len(se) == 3:
        return True
    return False


for k in range(1, n//2+1):
    for i in range(n):
        if i+2*k >= n:
            break
        if rgb(k, i):
            ans -= 1
print(ans)


Fixed submission:
n = int(input())
s = str(input())
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
r, g, b = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    if s[i] == 'G':
        g += 1
    if s[i] == 'B':
        b += 1
ans = r*g*b


def rgb(k, i):
    se = set()
    se.add(s[i])
    se.add(s[i+k])
    se.add(s[i+2*k])
    if len(se) == 3:
        return True
    return False


for k in range(1, n//2+1):
    for i in range(n):
        if i+2*k >= n:
            break
        if rgb(k, i):
            ans -= 1
print(ans)


Fixed submission:
n = int(input())
s = str(input())
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
r, g, b = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    if s[i] == 'G':
        g += 1
    if s[i] == 'B':
        b += 1
ans = r*g*b


def rgb(k, i):
    se = set()
    se.add(s[i])
    se.add(s[i+k])
    se.add(s[i+2*k])
    if len(se) == 3:
        return True
    return False


for k in range(1, n):
    for i in range(n):
        if i+2*k >= n:
            break
        if rgb(k, i):
            ans -= 1
print(ans)


Fixed submission:
n = int(input())
s = str(input())
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b

for k in range(1, n//2+1):
    for i in range(n):
        if i+2*k >= n:
            break
        if s[i] != s[i+k] and s[i] != s[i+2*k] and s[i+k] != s[i+2*k]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [str(input()) for i in range(n)]
dic = {}
m = 1
for a in s:
    if not a in dic:
        dic[a] = 1
    else:
        dic[a] += 1
        cnt = dic[a]
        m = max(m, cnt)
l = []
for a in s:
    if not a in l and dic[a] == m:
        l.append(a)
l.sort()
for i in range(len(l)):
    print(l[i])

Fixed submission:
n = int(input())
s = [str(input()) for i in range(n)]
dic = {}
m = 1
for a in s:
    if not a in dic:
        dic[a] = 1
    else:
        dic[a] += 1
        cnt = dic[a]
        m = max(m, cnt)
se = set()
for a in s:
    if dic[a] == m:
        se.add(a)
l = ['a'] * len(se)
for i in range(len(se)):
    l[i] = se.pop()
l.sort()
for i in range(len(l)):
    print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#print(a)
lm = [0]
rm = [0]

for i in range(n-1):
    lm.append(max(a[i], lm[i]))

for i in range(n-1, 0, -1):
    rm.insert(0, (max(a[i], rm[n-i-1])))

#print(lm)
#print(rm)

for i in range(n):
    print(max(lm[i], rm[i]))

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#print(a)
lm = [0] * n
rm = [0] * n

for i in range(1, n):
    lm[i] = max(a[i-1], lm[i-1])

for i in range(n-2, -1, -1):
    rm[i] = max(a[i+1], rm[i+1])


for i in range(n):
    print(max(lm[i], rm[i]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#print(a)
lm = [0]
rm = [0]

for i in range(n-1):
    lm.append(max(a[i], lm[i]))

for i in range(n-1, 0, -1):
    rm.insert(0, (max(a[i], rm[n-i-1])))

#print(lm)
#print(rm)

for i in range(n):
    print(max(lm[i], rm[i]))

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#print(a)
lm = [0] * n
rm = [0] * n

for i in range(1, n):
    lm[i] = max(a[i-1], lm[i-1])

for i in range(n-2, -1, -1):
    rm[i] = max(a[i+1], rm[i+1])


for i in range(n):
    print(max(lm[i], rm[i]))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split()))
l = [a[0]] * n
r = [a[n-1]] * n
for i in range(1, n):
    l[i] = math.gcd(l[i-1], a[i-1])
for i in range(n-2, -1, -1):
    r[i] = math.gcd(r[i+1], a[i+1])
l[0] = r[0]
r[n-1] = l[n-1]
ans = 0
for i in range(n):
    ans = max(ans, math.gcd(l[i], r[i]))
print(ans)

Fixed submission:
def gcd(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    while b != 0:
        a, b = b, a%b
    return a

n = int(input())
a = list(map(int, input().split()))
l = [a[0]] * n
r = [a[n-1]] * n
for i in range(1, n):
    l[i] = gcd(l[i-1], a[i-1])
for i in range(n-2, -1, -1):
    r[i] = gcd(r[i+1], a[i+1])
l[0] = r[0]
r[n-1] = l[n-1]
ans = 0
for i in range(n):
    ans = max(ans, gcd(l[i], r[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
x, n  = map(int, input().split())
p = map(int, intput().split())

m = -1
for a in p:
  if m == -1 or (abs(a - x) < abs(m - x)) or (abs(a - x) == abs(m - x) and a < m):
    m = a

print(m)

Fixed submission:
x, n  = map(int, input().split())
if n > 0:
  p = set(map(int, input().split()))
  i = 0
  while True:
    if x - i not in p:
      print(x-i)
      break
    if x + i not in p:
      print(x+i)
      break
    i += 1
else:
  print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))
a = 1
if 0 in li:
    print(0)
else:
    for i in li:
         a *= i
    if a >= 10**18+1:
        print('-1')
    else:
        print(a)


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
a = 1
if 0 in li:
    print(0)
else:
    li = sorted(li, reverse=True)
    for i in li:
        if a >= 10**18+1:
            break
        else:
            a *= i
    if a >= 10**18 + 1:
        print('-1')
    else:
        print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int,input().split()))
a = 1
for i in li:
        a *= i
if a >= 10**18+1:
    print('-1')
else:
    print(a)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
a = 1
if 0 in li:
    print(0)
else:
    li = sorted(li, reverse=True)
    for i in li:
        if a >= 10**18+1:
            break
        else:
            a *= i
    if a >= 10**18 + 1:
        print('-1')
    else:
        print(a)
Buggy python submission (verdict: Runtime Error):
a=int(input())
x,y = map(int,input().split())	

b = x//a
c = y//a

if c-b <= 1:
    print('NG')
elif:
    print('OK')

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

c = b // k
d = k*c

if a <= d and d <= b:
    print('OK')
else:
    print('NG')

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

b = x//a
c = y//a

if c-b <= 1:
    print('NG')
elif:
    print('OK')


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

c = b // k
d = k*c

if a <= d and d <= b:
    print('OK')
else:
    print('NG')

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

b = x//a
c = y//a

if c-b <= 1:
    print('NG')
elif:
    print('OK')


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

c = b // k
d = k*c

if a <= d and d <= b:
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Runtime Error):
import math
a,b,c = map(int,input().split())

x = math.sqrt(a)
y = math.sqrt(b)
z = math.sqrt(c)

x += y

if x < z:
    print('Yes')
else:
    print('No')

Fixed submission:
arr = [1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
k=int(input())

k -= 1
print(arr[k])
Buggy python submission (verdict: Runtime Error):
 N, A, B = map(int, input().split())
 ans = N // (A + B) * A
 rem = N % (A + B)
 ans += min(rem, A)
 print(ans)


Fixed submission:
n,a,b = map(int,input().split())
ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = n//(a+b)*a
rem = n%(a+b)
ans +=(rem,a)
print(ans)

Fixed submission:
n,a,b = map(int,input().split())
ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem,a)
print(ans)