Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
1count=0
ncount=0
for i in range(x):
    if a.count(i)==1:
        1count+=1
for i in range(x,n+1):
    if a.count(i)==1:
        ncount+=1
print(min(1count,ncount))


Fixed submission:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
counta=0
countb=0
for i in range(x):
    if a.count(i)==1:
        counta+=1
for i in range(x,n+1):
    if a.count(i)==1:
        countb+=1
print(min(counta,countb))
Buggy python submission (verdict: Runtime Error):
n=int(input())
d,x=map(int,input().split())
ans=x
a=[int(input()) for _ in range(n)]
for i in range(n):
    ans+=((d-1)//a[i])+1
print(ans)


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b)+min(c,d))
Buggy python submission (verdict: Runtime Error):
n=int(input()
d,x=map(int,input().split())
ans=x
a=[int(input()) for _ in range(n)]
for i in range(n):
    ans+=((d-1)//a[i])+1
print(ans)


Fixed submission:
n=int(input())
d,x=map(int,input().split())
ans=x
a=[int(input()) for _ in range(n)]
for i in range(n):
    ans+=((d-1)//a[i])+1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(map(input().split()))
if s.count("Y")==0:
    print("Three")
else:
    print("Four")


Fixed submission:
n=int(input())
s=list(input().split())
if s.count("Y")==0:
    print("Three")
else:
    print("Four")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int,input().split())
queue=deque()
s=[list(input()) for _ in range(h)]
seen=[[False]*w for _ in range(h)]
queue.append([0,0])
ans=[[10000000]*w for _ in range(h)]
ans[0][0]=1
for i in range(h*w*1000):
    if len(queue)==0:
        break
    cnt=queue.popleft()
    seen[cnt[0]][cnt[1]]=True
    if cnt[0]!=0:
        if seen[cnt[0]-1][cnt[1]]==False and s[cnt[0]-1][cnt[1]]==".":
            queue.append([cnt[0]-1,cnt[1]])
            ans[cnt[0]-1][cnt[1]]=min(ans[cnt[0]-1][cnt[1]],ans[cnt[0]][cnt[1]]+1)
    if cnt[1]!=0:
        if seen[cnt[0]][cnt[1]-1]==False and s[cnt[0]][cnt[1]-1]==".":
            queue.append([cnt[0],cnt[1]-1])
            ans[cnt[0]][cnt[1]-1]=min(ans[cnt[0]][cnt[1]-1],ans[cnt[0]][cnt[1]]+1)
    if cnt[0]!=h-1:
        if seen[cnt[0]+1][cnt[1]]==False and s[cnt[0]+1][cnt[1]]==".":
            queue.append([cnt[0]+1,cnt[1]])
            ans[cnt[0]+1][cnt[1]]=min(ans[cnt[0]+1][cnt[1]],ans[cnt[0]][cnt[1]]+1)
    if cnt[1]!=w-1:
        if seen[cnt[0]][cnt[1]+1]==False and s[cnt[0]][cnt[1]+1]==".":
            queue.append([cnt[0],cnt[1]+1])
            ans[cnt[0]][cnt[1]+1]=min(ans[cnt[0]][cnt[1]+1],ans[cnt[0]][cnt[1]]+1)
cnt2=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            cnt2+=1
if seen[-1][-1]==False:
    print(-1)
else:
    print(cnt2-ans[-1][-1])


Fixed submission:
from collections import deque
h,w=map(int,input().split())
queue=deque()
s=[list(input()) for _ in range(h)]
seen=[[False]*w for _ in range(h)]
queue.append([0,0])
ans=[[1000000000]*w for _ in range(h)]
seen[0][0]=True
ans[0][0]=1
for i in range(h*w*10):
    if len(queue)==0:
        break
    cnt=queue.popleft()
    if cnt[0]!=0:
        if seen[cnt[0]-1][cnt[1]]==False and s[cnt[0]-1][cnt[1]]==".":
            queue.append([cnt[0]-1,cnt[1]])
            ans[cnt[0]-1][cnt[1]]=ans[cnt[0]][cnt[1]]+1
            seen[cnt[0]-1][cnt[1]]=True
    if cnt[1]!=0:
        if seen[cnt[0]][cnt[1]-1]==False and s[cnt[0]][cnt[1]-1]==".":
            queue.append([cnt[0],cnt[1]-1])
            ans[cnt[0]][cnt[1]-1]=ans[cnt[0]][cnt[1]]+1
            seen[cnt[0]][cnt[1]-1]=True
    if cnt[0]!=h-1:
        if seen[cnt[0]+1][cnt[1]]==False and s[cnt[0]+1][cnt[1]]==".":
            queue.append([cnt[0]+1,cnt[1]])
            ans[cnt[0]+1][cnt[1]]=ans[cnt[0]][cnt[1]]+1
            seen[cnt[0]+1][cnt[1]]=True
    if cnt[1]!=w-1:
        if seen[cnt[0]][cnt[1]+1]==False and s[cnt[0]][cnt[1]+1]==".":
            queue.append([cnt[0],cnt[1]+1])
            ans[cnt[0]][cnt[1]+1]=ans[cnt[0]][cnt[1]]+1
            seen[cnt[0]][cnt[1]+1]=True
cnt2=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            cnt2+=1
if seen[-1][-1]==False:
    print(-1)
else:
    print(cnt2-ans[-1][-1])
Buggy python submission (verdict: Runtime Error):
s=input()
str=["A","K","I","H","A","B","A","R","A"]
count=0
ans=0
for i in range(9):
    if s[count]!=str[i] and str[i]!="A":
        ans=1
        break
    else:
        if s[count]==str[i]:
            count+=1
if ans==1:
    print("NO")
else:
    print("YES")


Fixed submission:
s=input()
str=["A","K","I","H","A","B","A","R","A"]
count=0
ans=0
for i in range(9):
    if count==len(s) and i<8:
        ans=1
        break
    elif count==len(s):
        break
    if s[count]==str[i]:
        count+=1
    elif s[count]!=str[i] and str[i]!="A":
        ans=1
        break
if len(s)>9:
    ans=1
if ans==1:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
s=list(input())
a=s.count("a")
b=s.count("b")
c=s.count("c")
if min(a,b,c)!=0 and max(a,b,c)-min(a,b,c)<=1:
    print("YES")
elif a+b+c=max(a,b,c) and max(a,b,c)==1:
    print("YES")
else:
    print("NO")


Fixed submission:
s=list(input())
a=s.count("a")
b=s.count("b")
c=s.count("c")
l1=[a,b,c]
l1.sort()
if l1[0]==0 and l1[1]==1 and l1[2]==1:
    print("YES")
elif min(a,b,c)!=0 and max(a,b,c)-min(a,b,c)<=1:
    print("YES")
elif a+b+c==max(a,b,c) and max(a,b,c)==1:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
s=list(input())
s2=[]
for i in range(len(s)):
    if s[-i-1]!="x":
        num=i+1
        break
s3=["O"]*num
for i in range(len(s)):
    if s[i]!="x":
        s2.append(s[i])
        if i!=len(s)-1:
            if s[i+1]!="x":
                s3.append("O")
    else:
        s3.append("x")
num=0
for i in range(len(s2)//2):
    if s2[i]!=s2[-1-i]:
        num=1
        break
if num==1:
    print(-1)
else:
    ans=0
    for i in range(len(s3)//2):
        if s3[i]!=s3[-i-1]:
            ans+=1
    print(ans)


Fixed submission:
s=list(input())
ans=0
for i in range(len(s)):
    if len(s)<=1:
        break
    if s[0]==s[-1]:
        del s[0]
        del s[-1]
    else:
        if s[0]=="x":
            ans+=1
            del s[0]
        elif s[-1]=="x":
            ans+=1
            del s[-1]
        else:
            ans=-1
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
num=[]
def ap(num1):
    num.append(num1)
def rm(num2):
    num.remove(num2)
for i in range(n):
    a=int(input())
    str=a in num
    if str==True:
        rm(a)
    else:
        ap(a)
print(len(num))


Fixed submission:
n=int(input())
num=[]
def ap(num1):
    num.append(num1)
for i in range(n):
    a=int(input())
    ap(a)
num.sort()
num1=num[0]
num2=1
ans=0
for i in range(n-1):
    if num[i+1]==num1:
        num2+=1
    else:
        num1=num[i+1]
        if num2%2==1:
            ans+=1
        num2=1
if num2%2==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
num=[]
for i in range(n):
    a=int(input())
    str=a in num
    if str==True:
        num.remove(a)
    else:
        num.append(a)
print(len(num))


Fixed submission:
n=int(input())
num=[]
def ap(num1):
    num.append(num1)
for i in range(n):
    a=int(input())
    ap(a)
num.sort()
num1=num[0]
num2=1
ans=0
for i in range(n-1):
    if num[i+1]==num1:
        num2+=1
    else:
        num1=num[i+1]
        if num2%2==1:
            ans+=1
        num2=1
if num2%2==1:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
num=[0]*(max(a)+1)
for i in range(n):
    num[a[i]]+=1
ans=0
for i in range(1,len(a)-1):
    num2=num[i-1]+num[i]+num[i+1]
    if ans<num2:
        ans=num2
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
num=[0]*(max(a)+1)
for i in range(n):
    num[a[i]]+=1
ans=0
if max(a)<3:
    ans=sum(num)
else:
    for i in range(1,max(a)):
        num2=num[i-1]+num[i]+num[i+1]
        if ans<num2:
            ans=num2
print(ans)
Buggy python submission (verdict: Runtime Error):
o=input()
e=input()
ans=""
for i in range(len(e)):
    ans+=o[i]
    ans+=e[i]
if len(o)!=len(e):
    ans+=o[len(o)-1]
print(ans)


Fixed submission:
a,b,c=map(int,input().split())
if b-a==c-b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a=="H" and b=="H":
    print("H")
elif a=="D" and b=="D":
    print("H")
else:
    print("D")


Fixed submission:
a,b=input().split()
if a=="H" and b=="H":
    print("H")
elif a=="D" and b=="D":
    print("H")
else:
    print("D")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (a=="H" and b=="H") or (a=="D" and b=="D"):
    print("H")
else:
    print("D")


Fixed submission:
a,b=input().split()
if a=="H" and b=="H":
    print("H")
elif a=="D" and b=="D":
    print("H")
else:
    print("D")
Buggy python submission (verdict: Runtime Error):
x=int(input())
count=0
for i in range(1,x**2):
    count+=i
    if count>=x:
        break
print(i)


Fixed submission:
x=int(input())
count=0
for i in range(1,x**2+3):
    count+=i
    if count>=x:
        break
print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
a=[]
b=[]
ans=[]
yn=0
count=1
count2=0
count3=0
for i in range(n):
    check=i*n+((n-i-1)*(n-i))//2
    if check+i+1<x[i] or x[i]<((i+2)*(i+1))//2:
        yn+=1
        break
lena=len(a)
if yn==1:
    print("No")
else:
    print("Yes")
    for i in range(n):
        for j in range(i):
            a.append(i+1)
    for i in range(n):
        for j in range(n-i-1):
            b.append(i+1)
    for i in range(n*n):
        if x.count(i+1)==1:
            ans.append(count)
            count+=1
        else:
            if count2<lena:
                ans.append(a[count2])
                count2+=1
            else:
                ans.append(b[count3])
                count3+=1
    print(*ans)


Fixed submission:
x,y=map(int,input().split())
if x>0 and y>0:
    if x<=y:
        print(y-x)
    else:
        print(x-y+2)
elif x<0 and y<0:
    if x<=y:
        print(y-x)
    else:
        print(x-y+2)
else:
    if y==0 or x==0:
        if y<0 or x>0:
            print(abs(y)+abs(x)+1)
        else:
            print(abs(y)+abs(x))
    else:
        print(abs(abs(x)-abs(y))+1)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
d=list[a,b,c]
for i in range(2):
    if d.count(d[i])!=1:
        del d[i]
print(len(d))


Fixed submission:
a,b,c=input().split()
d=[a,b,c]
for i in range(2):
    if d.count(d[i])!=1:
        del d[i]
print(len(d))

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=list[a,b,c]
for i in range(2):
    if d.count(d[i])!=1:
        del d[i]
print(len(d))


Fixed submission:
a,b,c=input().split()
d=[a,b,c]
for i in range(2):
    if d.count(d[i])!=1:
        del d[i]
print(len(d))
Buggy python submission (verdict: Runtime Error):
inp=raw_input().split()
a=int(inp[0])
b=int(inp[1])
c=int(inp[2])
if(c<=(a+b)):
	print(b+c)
else:
	print(a+b+b+1)


Fixed submission:
inp=raw_input().split()
a=int(inp[0])
b=int(inp[1])
c=int(inp[2])
if(c<=(a+b)):
	print(b+c)
else:
	print(a+b+b+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
nowbl=(n-2)**2
mu=[n-1]*n 
mh= [n-1]*n 

nowu=n-1 ; nowh=n-1
for i in range(q):
    a,b=map(int,input().split())
    a-=1;b-=1
    if a==0:
        if mu[b]==1:
            continue
        nowbl-= mu[b]-1
        mu[b]=0
        if nowu< b:
            continue
        nowu=b
        for i in range(1,nowh):
            mh[i]= min(mh[i],b)
        
    if a==1:
        a=b
        if mh[a]==1:
            continue
        nowbl-= mh[a]-1
        mh[a]=0
        if nowh< a:
            continue
        nowh= a 
        for i in range(1,nowu):
            mu[i]= min(mu[i],a)
print(nowbl)
        
        


Fixed submission:
n,q=map(int,input().split())
x= n-2
y= n-2
dx={}
dy={}

for _ in range(q):
    a,b=map(int,input().split())
    b-=1
    if a==1:
        if y< b:
            dy[b]=0;continue
        # y= b-1
        for i in range(b+1,y+1):
            dy[i] = x
        y=b-1

    if a==2:
        if x < b:
            dx[b]=0;continue
        # x=b-1
        for i in range(b+1,x+1):
            dx[i] =y
        x=b-1
print(x*y + sum(dx.values()) + sum(dy.values()) )
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
j=0 ;bef=-1
for i in range(n):
    if A[i]==B[i]:
        if bef!=A[i]:j=0
        while j<n:
            if A[i]!=B[j] and A[i]!=A[j]:
                B[i],B[j]= B[j],B[i]
                break
            j+=1
        else:
            print("No");exit()

print("Yes")
print(*B)

Fixed submission:
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
j=0 ;bef=-1
for i in range(n):
    if bef!=A[i]:j=0
    if A[i]==B[i]:
        
        while j<n:
            if A[i]!=B[j] and A[i]!=A[j]:
                B[i],B[j]= B[j],B[i]
                break
            j+=1
        else:
            print("No");exit()
    bef=A[i]

print("Yes")
print(*B)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
A=[0]*h ; B=[0]*w ;G=[]
for i in range(m):
    x,y=map(int,input().split())
    A[x-1]+=1 ; B[y-1]+=1
    G.append([x-1,y-1])

q=max(A) ; e=max(B)
Q=[i for i in range(h) if A[i]==q] 
W=[j for j in range(w) if B[j]==e];#print(A,B,Q,W)
grid={}
for i in Q:
    for j in W:
        grid[ (i,j) ]=0



for i in range(m):
    x,y=G[i]
    if A[x]==q and B[y]==e:
        grid[(x,y)]=1
#print(grid)
if 0 in grid.values():
    print(q+e)
else:
    print(q+e-1)

Fixed submission:
h,w,m=map(int,input().split())
A=[0]*h ; B=[0]*w ;G=[]
for i in range(m):
    x,y=map(int,input().split())
    A[x-1]+=1 ; B[y-1]+=1
    G.append([x-1,y-1])

q=max(A) ; e=max(B)
Q=[i for i in range(h) if A[i]==q] 
W=[j for j in range(w) if B[j]==e];#print(A,B,Q,W)
cnt=len(Q)*len(W)



for i in range(m):
    x,y=G[i]
    if A[x]==q and B[y]==e:
        cnt-=1
#print(grid)
if cnt==0:
    print(q+e-1)
else:
    print(q+e)
Buggy python submission (verdict: Runtime Error):
n=int(input())
from decimal import Decimal as D
# A=[]
excel=[[0]*20 for i in range(50)]
query=[]
for i in range(n):
    q=input()
    q=D(q)
    q=int(q*10**9)
    num2=0 ;num5=0
    k=q
    for i in range(50):
        if k%2==0:
            k//=2
            num2+=1
        else:break
    k=q
    for i in range(20):
        if k%5==0:
            k//=5
            num5+=1
        else:break
    excel[num2][num5]+=1
    query.append([max(0,18-num2),max(0,18-num5)])

A=[[0] * 20 for i in range(50)] #累積和
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i==49 and j==19:
            A[i][j]=excel[i][j]
        elif i==49:
            A[i][j]=A[i][j+1]+excel[i][j]
        elif j==19:
            A[i][j]=A[i+1][j] + excel[i][j]
        else:
            A[i][j]=excel[i][j]+ A[i+1][j]+A[i][j+1]-A[i+1][j+1]

ans=0
for l in query:
    num2,num5=l
    if num2<=9 and num5<=9:
        ans+=A[num2][num5]-1
    else:a
        ans+=A[num2][num5]

#for i in range(50):
 #   print(excel[:][i] , A[:][i])
print(ans//2)


Fixed submission:
n=int(input())
from decimal import Decimal as D
# A=[]
excel=[[0]*20 for i in range(50)]
query=[]
for i in range(n):
    q=input()
    q=D(q)
    q=int(q*10**9)
    num2=0 ;num5=0
    k=q
    for i in range(50):
        if k%2==0:
            k//=2
            num2+=1
        else:break
    k=q
    for i in range(20):
        if k%5==0:
            k//=5
            num5+=1
        else:break
    excel[num2][num5]+=1
    query.append([max(0,18-num2),max(0,18-num5)])

A=[[0] * 20 for i in range(50)] #累積和
for i in range(49,-1,-1):
    for j in range(19,-1,-1):
        if i==49 and j==19:
            A[i][j]=excel[i][j]
        elif i==49:
            A[i][j]=A[i][j+1]+excel[i][j]
        elif j==19:
            A[i][j]=A[i+1][j] + excel[i][j]
        else:
            A[i][j]=excel[i][j]+ A[i+1][j]+A[i][j+1]-A[i+1][j+1]

ans=0
for l in query:
    num2,num5=l
    if num2<=9 and num5<=9:
        ans+=A[num2][num5]-1
    else:
        ans+=A[num2][num5]

#for i in range(50):
 #   print(excel[:][i] , A[:][i])
print(ans//2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
from collections import Counter
A=[]
for i in range(n):
  A.append(int(input()))
C=Counter(A)
print(f"""AC x {C["AC"]}
WA x {C["WA"]}
TLE x {C["TLE"]}
RE x {C["RE"]}""")

Fixed submission:
n=int(input())
from collections import Counter
A=[]
for i in range(n):
  A.append((input()))
C=Counter(A)
print(f"""AC x {C["AC"]}
WA x {C["WA"]}
TLE x {C["TLE"]}
RE x {C["RE"]}""")
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(a+a**2+a**3)

Fixed submission:
a=int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
ans=0
for i,j in a,b:
  if i != j:
    ans+=1
print(ans)

Fixed submission:
a=input()
b=input()
ans=0
for i,j in zip(a,b):
  if i != j:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
now=0
for i in range(1,n+1):
    now+=sum([j for j in range(1,n+1) if j%i==0])
print(now)

Fixed submission:
n=int(input())
now=0
for i in range(1,n+1):
    now+=(i+(i*(n//i)))*(n//i)//2
print(now)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(b*100*a//100)

Fixed submission:
from decimal import Decimal as D
a,b=map(str,input().split())
print(int(D(a)*D(b)))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=len(s)
ans=0
ruiseki=[int(s[-1]) for i in range(t)]
for i in range(1,t):
    ruiseki[i]=(ruiseki[i-1]+int(s[-1-i])*pow(10,i,2019))%2019

ans+=ruiseki.count(0)
for i in range(2019):
    o=ruiseki.count(i)
    ans+=o*(o-1)//2
print(ans)




Fixed submission:
s=input()
t=len(s)
ans=0
ruiseki=[int(s[-1]) for i in range(t)]
for i in range(1,t):
    ruiseki[i]=(ruiseki[i-1]+int(s[-1-i])*pow(10,i,2019))%2019
from collections import Counter
ans+=ruiseki.count(0)
C=Counter(ruiseki)
for x in C.values():
    ans+=x*(x-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=len(s)
ans=0
ruiseki=[int(s[-1]) for i in range(t)]
for i in range(1,t):
    ruiseki[i]=(ruiseki[i-1]+int(s[-1-i])*pow(10,i,2019))%2019

ans+=ruiseki.count(0)
for i in range(2019):
    o=ruiseki.count(i)
    ans+=o*(o-1)//2
print(ans)




Fixed submission:
s=input()
t=len(s)
ans=0
ruiseki=[int(s[-1]) for i in range(t)]
for i in range(1,t):
    ruiseki[i]=(ruiseki[i-1]+int(s[-1-i])*pow(10,i,2019))%2019
from collections import Counter
ans+=ruiseki.count(0)
C=Counter(ruiseki)
for x in C.values():
    ans+=x*(x-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)


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

Fixed submission:
n=int(input())
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)


ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+= gcd(i,gcd(j,k))
print(ans)
Buggy python submission (verdict: Runtime Error):
k,n=map(int,input().split())
A-list(map(int,input().split()))
ans=-1
for i in range(n-1):
  ans=max(ans,A[i+1]-A[i])
print(sum(A)- max(ans,k-(A[n-1]-A[0])))

Fixed submission:
k,n=map(int,input().split())
A=list(map(int,input().split()))
ans=-1
for i in range(n-1):
  ans=max(ans,A[i+1]-A[i])
print(k- max(ans,k-(A[n-1]-A[0])))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
from collections import Counter
C=Counter(A)
Q=C.values()
def qq(F):
    n=len(F)
    ans=0
    for i in range(n):
        ans+= F[i]*(F[i]-1)//2
    return ans
    
for i in range(n):
    j=A[i]
    C[j]-=1
    print(qq(list(C.values())))
    C[j]+=1

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
from collections import Counter
C=Counter(A)
Q=list(C.values())
def qq(F):
    n=len(F)
    ans=0
    for i in range(n):
        ans+= F[i]*(F[i]-1)//2
    return ans
ans=qq(Q)
for i in range(n):
    print(ans-C[A[i]]+1)
Buggy python submission (verdict: Runtime Error):
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict, OrderedDict
#すべてのkeyが用意されてる defaultdict(int)で初期化
#順序を保ったdict
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n=int(input())
s=input()
A=[int(i)-1 for i in s]

RUI2=[pow(2,i) for i in range(21)]
import bisect as bi
@lru_cache(maxsize=10**10)
def tan(n):
    if n==0:return [1]
    if n==1:return [1,1]
    if n==2:return [1,0,1]
    i= bi.bisect_right(RUI2,n)-1
    return tan(n-pow(2,i)) + [0]*(pow(2,i+1)-n-1) + tan(n-pow(2,i))


for i in range(n-1):
    if A[i]==A[i+1]: A[i]=0
    elif (A[i]^A[i+1])&1 : A[i]=1
    else:A[i]=2
for i in range(n-2):
    if (A[i]^A[i+1])&1 : A[i]=1
    else:A[i]=0

# print(A[:-2],tan(n-3))
a=[i&j for i,j in zip(A[:-2],tan(n-3))]
# print(a)
print(1 if sum(a)%2==1 else 0)


Fixed submission:
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict, OrderedDict
#すべてのkeyが用意されてる defaultdict(int)で初期化
#順序を保ったdict
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n=int(input())
s=input()
A=[int(i)-1 for i in s]

RUI2=[pow(2,i) for i in range(21)]
import bisect as bi
@lru_cache(maxsize=10**10)
def tan(n):
    if n==0:return [1]
    if n==1:return [1,1]
    if n==2:return [1,0,1]
    i= bi.bisect_right(RUI2,n)-1
    return tan(n-pow(2,i)) + [0]*(pow(2,i+1)-n-1) + tan(n-pow(2,i))


# for i in range(n-1):
#     if A[i]==A[i+1]: A[i]=0
#     elif (A[i]^A[i+1])&1 : A[i]=1
#     else:A[i]=2
# for i in range(n-2):
#     if (A[i]^A[i+1])&1 : A[i]=1
#     else:A[i]=0

# print(A[:-2],tan(n-3))
if A.count(1)!=0:
    A=[i%2!=1 for i in A]
    a=[i&j for i,j in zip(A,tan(n-1))]
    # print(a)
    print(1 if sum(a)%2==1 else 0)
else:
    a=[(i//2)&j for i,j in zip(A,tan(n-1))]
    #print(a,tan(4))
    print(2 if sum(a)%2==1 else 0)
Buggy python submission (verdict: Runtime Error):
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=1162513825187421
for _ in range(m):
    i,j,c=map(int,input().split())
    ans=min(ans, A[i-1]+B[i-1]-c)
print(ans)

Fixed submission:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for _ in range(m):
    i,j,c=map(int,input().split())
    ans=min(ans, A[i-1]+B[j-1]-c)
print(ans)