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

dp=[[0 for i in range(13)]for j in range(len(S)+1)]
dp[0][0]=1

for i in range(len(S)):
    if S[i]=="?":
        for j in range(13):
            
            for k in range(10):
                dp[i+1][(10*j+k)%13]+=dp[i][j]
                dp[i+1][(10*j+k)%13]%=(10**9+7)
    else:
        for j in range(13):
            dp[i+1][(10*j+int(S[i]))%13]+=dp[i][j]
            dp[i+1][(10*j+int(S[i]))%13]%=(10**9+7)
print(dp[-1][5])

Fixed submission:
S=list(input())

dp=[[0 for i in range(13)]for j in range(len(S)+1)]
dp[0][0]=1

for i in range(len(S)):
    if S[i]=="?":
        for j in range(13):
            
            for k in range(10):
                dp[i+1][(10*j+k)%13]+=dp[i][j]
                dp[i+1][(10*j+k)%13]%=(10**9+7)
    else:
        for j in range(13):
            dp[i+1][(10*j+int(S[i]))%13]+=dp[i][j]
            dp[i+1][(10*j+int(S[i]))%13]%=(10**9+7)
print(dp[-1][5])
Buggy python submission (verdict: Runtime Error):
import math

S=int(input())

if S==0:
    ans=[0,0,0,0,0,0]
elif S==10**18:
    ans==[0,0,10**9,0,10**9,10**9]
else:
    ans=[0,0,10**9,1]
    ans.append(10**9-S%(10**9))
    ans.append(math.ceil(S/(10**9)))
print(*ans)

Fixed submission:
import math

S=int(input())

if S==0:
    ans=[0,0,0,0,0,0]
elif S==10**18:
    ans=[0,0,10**9,0,10**9,10**9]
elif S%(10**9)==0:
    ans=[0,0,10**9,0,0]
    ans.append(S//(10**9))
else:
    ans=[0,0,10**9,1]
    ans.append(10**9-S%(10**9))
    ans.append(math.ceil(S/(10**9)))
print(*ans)
Buggy python submission (verdict: Runtime Error):
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]


for i in range(1,N+1):
    cnt=0
    n=N+1-i
    for j in range(1,10**5):
        #print(n,n*j)
        if n*j>N:
            break
        else:
            if B[n*j]==1:
                cnt+=1
    if cnt%2!=A[n]:
        B[n]+=1
        ans.append(n)
ans.sort()
print(len(ans))
print(*ans)


Fixed submission:
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    #print(i)
    cnt=0
    for j in range(i,N+1,i):
        #print(i,j)
        if B[j]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)
#print(A)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import sys
input=sys.stdin.readline

N,Q=map(int,input().split())
H=[]
for i in range(N):
    s,t,x=map(int,input().split())
    H.append([s-x,t-x,x])
H.sort()
#print(H)
P=0
q=[]
heapq.heapify(q)
for i in range(Q):
    n=int(input())
    #print("A",len(q))
    if P<N:
        while H[P][0]<=n:
            heapq.heappush(q,[H[P][2],H[P][0],H[P][1]])
            P+=1
            if P==N:
                break
    #print("B",i,len(q))
    if len(q)>0:
        while q[0][2]<=n:
            heapq.heappop(q)
            if len(q)==0:
                break
    if len(q)==0:
        print(-1)
    else:
        print(q[0][0])

Fixed submission:
import heapq
import sys
input=sys.stdin.readline

N,Q=map(int,input().split())
H=[]
for i in range(N):
    s,t,x=map(int,input().split())
    H.append([s-x,t-x,x])
H.sort()
#print(H)
P=0
q=[]
heapq.heapify(q)
for i in range(Q):
    n=int(input())
    #print("A",len(q))
    if P<N:
        while H[P][0]<=n:
            heapq.heappush(q,[H[P][2],H[P][0],H[P][1]])
            P+=1
            if P==N:
                break
    #print("B",i,len(q))
    if len(q)>0:
        while q[0][2]<=n:
            heapq.heappop(q)
            if len(q)==0:
                break
    if len(q)==0:
        print(-1)
    else:
        print(q[0][0])
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
ans=0
for r in range(N+1):
    if r*R>N:
        break
    else:
        for g in range(N+1):
            if ((r*R)+(g*G))>N:
                break
            else:
                if (N-(r*R)-(g*G))%B==0:
                    ans+=1
print(ans)


Fixed submission:
R,G,B,N=map(int,input().split())
ans=0
for r in range(N+1):
    if r*R>N:
        break
    else:
        for g in range(N+1):
            if ((r*R)+(g*G))>N:
                break
            else:
                if (N-(r*R)-(g*G))%B==0:
                    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB=[]
for i in range(len(A)):
    for j in range(len(B)):
        AB.append(A[i]+B[j])
AB.sort(reverse=True)

AB=AB[:min(3000,len(A)*len(B))]
ABC=[]
for i in range(len(AB)):
    for j in range(len(C)):
        ABC.append(AB[i]+C[j])

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB=[]
for i in range(len(A)):
    for j in range(len(B)):
        AB.append(A[i]+B[j])
AB.sort(reverse=True)

AB=AB[:min(3000,len(A)*len(B))]
ABC=[]
for i in range(len(AB)):
    for j in range(len(C)):
        ABC.append(AB[i]+C[j])

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

par=[i for i in range(M)]
size=[1 for i in range(M)]

def find(X):
    if par[X]==X:
        return X
    else:
        return find(par[X])

def union(X,Y):
    if size[X]>=size[Y]:
        par[Y]=par[X]
        size[X]+=size[Y]
    elif size[Y]>size[X]:
        par[X]=par[Y]
        size[Y]+=size[X]
    
L=[]
for i in range(M):
    a,b=map(int,input().split())
    L.append([a-1,b-1])
    
L=L[::-1]

A=[]
for i in range(M):
    if find(L[i][0])==find(L[i][1]):
        A.append(0)
    else:
        A.append(size[find(L[i][0])]*size[find(L[i][1])])
        union(par[find(L[i][0])],par[find(L[i][1])])
        
A=A[::-1]
ans=0
for i in range(len(A)):
    ans+=A[i]
    print(ans)

Fixed submission:
N,M=map(int,input().split())

par=[i for i in range(N)]
size=[1 for i in range(N)]

def find(X):
    if par[X]==X:
        return X
    else:
        return find(par[X])

def union(X,Y):
    if size[X]>=size[Y]:
        par[Y]=par[X]
        size[X]+=size[Y]
    elif size[Y]>size[X]:
        par[X]=par[Y]
        size[Y]+=size[X]
    
L=[0 for i in range(M)]
for i in range(M):
    a,b=map(int,input().split())
    L[i]=[a-1,b-1]

L=L[::-1]

A=[]
for i in range(M):
    if find(L[i][0])==find(L[i][1]):
        A.append(0)
    else:
        A.append(size[find(L[i][0])]*size[find(L[i][1])])
        union(par[find(L[i][0])],par[find(L[i][1])])
        
A=A[::-1]
ans=0
for i in range(len(A)):
    ans+=A[i]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)

for i in range(1,10**6):
    if max(L)>=i and i%z==0:
        print(i)
        exit()
print(z)

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



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)
ans=10000000000
for i in range(len(L)):
    if L[i]%z==0:
        pass
    elif L[i]%z<ans:
        ans=L[i]%z

if ans==10000000000:
    print(z)
else:
    print(ans)

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



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)

for i in range(1,10**6):
    if max(L)>=i and i%z==0:
        print(i)
        exit()
print(z)

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



def f(l, s):
    return s if l % s == 0 else f(s, l % s)
    
z = f(max(L), min(L))

for i in L:
    z=f(i,z)
ans=10000000000
for i in range(len(L)):
    if L[i]%z==0:
        pass
    elif L[i]%z<ans:
        ans=L[i]%z

if ans==10000000000:
    print(z)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

L=[[]for i in range(N+1)]
p=[0 for i in range(N+1)]

for i in range(N+M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    p[b]=1
    

for i in range(1,N+1):
    if p[i]==0:
        P=i
#print(P)
p[P]=[0,0]
A=[]
for i in L[P]:
    A.append([i,P,1])
for i in range(10**6):
    if i==len(A):
        break
    else:
        p[A[i][0]]=[A[i][1],A[i][2]]
        for j in L[A[i][0]]:
            A.append([j,A[i][0],A[i][2]+1])
    #print(p)
    #print(A)
for i in range(1,N+1):
    print(p[i][0])

Fixed submission:
import sys
input=sys.stdin.readline
N,M=map(int,input().split())

L=[[]for i in range(N+1)]

I=[0 for i in range(N+1)]
for i in range(N+M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    I[b]+=1
    
#print(L)
#print(I)
P=[-1 for i in range(N+1)]
S=-1
for i in range(1,N+1):
    if I[i]==0:
        P[i]=0
        S=i
        break

B=[]
cnt=0
for i in L[S]:
    if I[i]==1:
        B.append(i)
        P[i]=S
    else:
        I[i]-=1

for i in range(10**6):
    if cnt==len(B):
        break
    for j in L[B[cnt]]:
        if I[j]==1:
            B.append(j)
            P[j]=B[cnt]
        else:
            I[j]-=1
    cnt+=1
for i in range(1,N+1):
    print(P[i])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
p=list(map(float,input().split()))

DP=[0 for i in range(N+1)]
DP[0]=10**12
for i in range(N):
    #DP[0]=1
    for j in range(N+1):
        if DP[N-j]>0:
            DP[N-j+1]+=DP[N-j]*p[i]
            DP[N-j]*=(1-p[i])
    #print(DP)
print(sum(DP[N//2+1:])/(10**12))

Fixed submission:
N=int(input())
p=list(map(float,input().split()))

DP=[0 for i in range(N+1)]
DP[0]=10**12
for i in range(N):
    #DP[0]=1
    for j in range(N+1):
        if DP[N-j]>0:
            DP[N-j+1]+=DP[N-j]*p[i]
            DP[N-j]*=(1-p[i])
    #print(DP)
print(sum(DP[N//2+1:])/(10**12))
Buggy python submission (verdict: Runtime Error):
Pat=[1]
for p in range(51):
    Pat.append(Pat[p]*2+1)
    
All=[1]
for a in range(51):
    All.append(All[a]*2+3)
    
N,X=map(int,input().split())
    
def saiki(n,x):
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<n:
        return 0
    elif x<(All[n]+1)//2-1:
        return saiki(n-1,x-1)
    elif x==(All[n-1]+2):
        return Pat[n-1]+1
    elif x<=All[n]:
        return Pat[n-1]+1+saiki(n-1,x-2-All[n-1])
    
print(saiki(N,X))



Fixed submission:
Pat=[1]
All=[1]
for i in range(51):
    Pat.append(Pat[i]*2+1)
    All.append(All[i]*2+3)

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

def saiki(N,X):
    if N==0:
        if X<=0:
            return 0
        else:
            return 1
    elif X<=All[N-1]+1:
        return saiki(N-1,X-1)
    elif X<=All[N]-1:
        return Pat[N-1]+1+saiki(N-1,X-2-All[N-1])
    else:
        return Pat[N]
        
print(saiki(N,X))

Buggy python submission (verdict: Runtime Error):
Pat=[1]
for p in range(51):
    Pat.append(Pat[p]*2+1)
    
All=[1]
for a in range(51):
    All.append(All[a]*2+3)
    
N,X=map(int,input().split())
    
def saiki(n,x):
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<n:
        return 0
    elif x<(All[n]+1)//2-1:
        return saiki(n-1,x-1)
    elif x==(All[n-1]+2):
        return Pat[n-1]+1
    elif x<All[n]:
        return Pat[n-1]+1+saiki(n-1,x-2-All[n-1])
    
print(saiki(N,X))

Fixed submission:
Pat=[1]
All=[1]
for i in range(51):
    Pat.append(Pat[i]*2+1)
    All.append(All[i]*2+3)

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

def saiki(N,X):
    if N==0:
        if X<=0:
            return 0
        else:
            return 1
    elif X<=All[N-1]+1:
        return saiki(N-1,X-1)
    elif X<=All[N]-1:
        return Pat[N-1]+1+saiki(N-1,X-2-All[N-1])
    else:
        return Pat[N]
        
print(saiki(N,X))
Buggy python submission (verdict: Runtime Error):
import math

SO=[0 for i in range(101)]

N=int(input())
for i in range(2,N+1):
    NUM=i
    for j in range(2,100):
        while NUM%j==0:
            SO[j]+=1
            NUM=NUM/j
A74=0
A24=0
A14=0
A04=0
A02=0
for j in range(len(SO)):
    if SO[j]>=74:
        A74+=1
    if SO[j]>=24:
        A24+=1
    if SO[j]>=14:
        A14+=1
    if SO[j]>=4:
        A04+=1
    if SO[j]>=2:
        A02+=1
#print(SO)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

#3*5*5
ans=(A02-2)*combinations_count(A04,2)
#3*25
ans+=(A02-1)*A24
#5*15
ans+=(A04-1)*A14
#74
ans+=A74

print(ans)

Fixed submission:
import math

SO=[0 for i in range(101)]

N=int(input())
for i in range(2,N+1):
    NUM=i
    for j in range(2,100):
        while NUM%j==0:
            SO[j]+=1
            NUM=NUM/j
A74=0
A24=0
A14=0
A04=0
A02=0
for j in range(len(SO)):
    if SO[j]>=74:
        A74+=1
    if SO[j]>=24:
        A24+=1
    if SO[j]>=14:
        A14+=1
    if SO[j]>=4:
        A04+=1
    if SO[j]>=2:
        A02+=1
#print(SO)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

#74
ans=A74
#3*5*5
if A04>=2:
    ans+=(A02-2)*combinations_count(A04,2)
#3*25
ans+=(A02-1)*A24
#5*15
ans+=(A04-1)*A14


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[[]for i in range(N)]
L=[]

for i in range(M):
    P,Y=map(int,input().split())
    A[P-1].append(Y)
    L.append([P-1,Y])
#print(A)
#print(L)

for j in range(N):
    A[j].sort()
#print(A)

for k in range(len(L)):
    ans1=str((L[k][0]+1)+1000000)
    ans1=ans1[1:]
    ans2=A[L[k][0]].index(L[k][1])
    ans2=str(ans2+1+1000000)
    ans2=ans2[1:]
    print(ans1+ans2)

Fixed submission:
import bisect
N,M=map(int,input().split())
A=[[]for i in range(N)]
L=[]

for i in range(M):
    P,Y=map(int,input().split())
    A[P-1].append(Y)
    L.append([P-1,Y])
#print(A)
#print(L)

for j in range(N):
    A[j].sort()
#print(A)

for k in range(len(L)):
    ans1=str((L[k][0]+1)+1000000)
    ans1=ans1[1:]
    ans2=bisect.bisect_left(A[L[k][0]],L[k][1])
    ans2=str(ans2+1+1000000)
    ans2=ans2[1:]
    print(ans1+ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
list1=[[]for i in range(N)]
list2=[]
for i in range(M):
    A=input()
    A=A.rstrip().split()
    P=int(A[0])
    Y=int(A[1])
    list1[P-1].append(Y)
    list2.append([P,Y])
#print(list1)
for j in range(N):
    list1[j].sort()
#print(list1)
for k in range(M):
    ansP="0"*(6-len(str(list2[k][0])))+str(list2[k][0])
    ansY="0"*(6-len(str(list1[list2[k][0]-1].index(list2[k][1])+1)))+str(list1[list2[k][0]-1].index(list2[k][1])+1)
    ans=ansP+ansY
    print(ans)

Fixed submission:
import bisect
N,M=map(int,input().split())
A=[[]for i in range(N)]
L=[]

for i in range(M):
    P,Y=map(int,input().split())
    A[P-1].append(Y)
    L.append([P-1,Y])
#print(A)
#print(L)

for j in range(N):
    A[j].sort()
#print(A)

for k in range(len(L)):
    ans1=str((L[k][0]+1)+1000000)
    ans1=ans1[1:]
    ans2=bisect.bisect_left(A[L[k][0]],L[k][1])
    ans2=str(ans2+1+1000000)
    ans2=ans2[1:]
    print(ans1+ans2)
Buggy python submission (verdict: Runtime Error):
import bisect
N,M=map(int,input().split())

X=max(N,M)
Y=min(N,M)
while X%Y!=0:
    X,Y=Y,X%Y

lcm=(N*M)//Y

#print(lcm)

s=[i*lcm//N for i in range(N)]
t=[i*lcm//M for i in range(M)]
t.append(10000000)
S=input()
T=input()

for i in range(len(s)):
    if t[bisect.bisect_left(t,s[i])]==s[i]:
        if T[bisect.bisect_left(t,s[i])]==S[i]:
            pass
        else:
            print(-1)
            exit()
print(lcm)


Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    return x*y // gcd(x, y)


N_len_S, M_len_T = map(int, input().split())
S = input()
T = input()
g = gcd(N_len_S, M_len_T)
l = lcm(N_len_S, M_len_T)

ans = l
for k in range(g):
    # S[i]. T[j] : 文字列 X を構成したとき重なる文字。これらが等しければよい数字。
    i = N_len_S // g * k
    j = M_len_T // g * k
    if S[i] != T[j]:
        ans = -1
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect
N,M=map(int,input().split())

X=max(N,M)
Y=min(N,M)
while X%Y!=0:
    X,Y=Y,X%Y

lcm=(N*M)//Y

#print(lcm)

s=[i*lcm//N for i in range(N)]
t=[i*lcm//M for i in range(M)]
t.append(10000000)
S=input()
T=input()

for i in range(len(s)):
    if t[bisect.bisect_left(t,s[i])]==s[i]:
        if T[bisect.bisect_left(t,s[i])]==S[i]:
            pass
        else:
            print(-1)
            exit()
print(lcm)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    return x*y // gcd(x, y)


N_len_S, M_len_T = map(int, input().split())
S = input()
T = input()
g = gcd(N_len_S, M_len_T)
l = lcm(N_len_S, M_len_T)

ans = l
for k in range(g):
    # S[i]. T[j] : 文字列 X を構成したとき重なる文字。これらが等しければよい数字。
    i = N_len_S // g * k
    j = M_len_T // g * k
    if S[i] != T[j]:
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

for i in range(int(M/N)):
    if M%(int(M/N)-i)==0:
        print((int(M/N-i)))
        exit()

Fixed submission:
N,M=map(int,input().split())
ans=0
for i in range(1,10**5):
    if M%i==0:
        a=max(M//i,i)
        b=min(M//i,i)
        if M//a>=N and ans<a:
            ans=a
        if M//b>=N and ans<b:
            ans=b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
for i in range(int(M/N)):
    if M%(int(M/N)-i)==0:
        ans=int(M/N)-i
        print(ans)
        break


Fixed submission:
N,M=map(int,input().split())
ans=0
for i in range(1,10**5):
    if M%i==0:
        a=max(M//i,i)
        b=min(M//i,i)
        if M//a>=N and ans<a:
            ans=a
        if M//b>=N and ans<b:
            ans=b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
ans=1
if M%N==0:
    print(int(M/N))
else:
    
    for i in range(2,int(M/N)+1):
        if (M-((N-1)*i))%i==0:
            ans=i
    print(ans)

Fixed submission:
N,M=map(int,input().split())
ans=0
for i in range(1,10**5):
    if M%i==0:
        a=max(M//i,i)
        b=min(M//i,i)
        if M//a>=N and ans<a:
            ans=a
        if M//b>=N and ans<b:
            ans=b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
ans=1
for i in range(2,int(M/N)+1):
    if (M-((N-1)*i))%i==0:
        ans=i
print(ans)


Fixed submission:
N,M=map(int,input().split())
ans=0
for i in range(1,10**5):
    if M%i==0:
        a=max(M//i,i)
        b=min(M//i,i)
        if M//a>=N and ans<a:
            ans=a
        if M//b>=N and ans<b:
            ans=b
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
A=list(map(int,input().split()))

A1=[]
A2=[]
for i in range(len(A)):
    if i%2==0:
        A1.append(A[i])
    else:
        A2.append(A[i])
        
B1=collections.Counter(A1)
B2=collections.Counter(A2)


if B1.most_common(2)[0][1]==B2.most_common(2)[0][1] and B1.most_common(2)[0][1]==int(N/2):
    print(int(N/2))
else:
    
    if B1.most_common(1)==B2.most_common(1):
        if B1.most_common(2)[1][1]>=B2.most_common(2)[1][1]:
            ans=N-B1.most_common(2)[1][1]-B2.most_common(2)[0][1]
        else:
            ans=N-B2.most_common(2)[1][1]-B1.most_common(2)[0][1]
    elif B1.most_common(2)[0][0]==B2.most_common(2)[0][0]:
        if B1.most_common(2)[0][1]>=B1.most_common(2)[0][1]:
            ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[1][1]
        else:
            ans=N-B2.most_common(2)[0][1]-B1.most_common(2)[1][1]
    else:
        ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[0][1]
    print(ans)

Fixed submission:
n=input()
N=[]
for i in range(3):
    N.append(n[i])
for j in range(3):
    if N[j]=="1":
        N[j]="9"
    else:
        N[j]="1"
print("".join(N))
Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
A=list(map(int,input().split()))

A1=[]
A2=[]
for i in range(len(A)):
    if i%2==0:
        A1.append(A[i])
    else:
        A2.append(A[i])
        
B1=collections.Counter(A1)
B2=collections.Counter(A2)

if N==2:
    print(0)

#elif B1.most_common(2)[0][1]==B2.most_common(2)[0][1] and B1.most_common(2)[0][1]==int(N/2):
    #print(int(N/2))
else:
    
    
    if B1.most_common(1)==B2.most_common(1):
        if B1.most_common(2)[1][1]>=B2.most_common(2)[1][1]:
            ans=N-B1.most_common(2)[1][1]-B2.most_common(2)[0][1]
        else:
            ans=N-B2.most_common(2)[1][1]-B1.most_common(2)[0][1]
    elif B1.most_common(2)[0][0]==B2.most_common(2)[0][0]:
        if B1.most_common(2)[0][1]>=B2.most_common(2)[0][1]:
            ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[1][1]
        else:
            ans=N-B2.most_common(2)[0][1]-B1.most_common(2)[1][1]
    else:
        ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[0][1]
    print(ans)


Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))

A1=[]
A2=[]
for i in range(len(A)):
    if i%2==0:
        A1.append(A[i])
    else:
        A2.append(A[i])
        
B1=collections.Counter(A1)
B2=collections.Counter(A2)

if N==2:
    print(0)

elif B1.most_common(2)[0][1]==B2.most_common(2)[0][1] and B1.most_common(2)[0][1]==int(N/2):
    if B1.most_common(1)==B2.most_common(1):
        print(int(N/2))
    else:
        print(0)
else:
    
    
    if B1.most_common(1)==B2.most_common(1):
        
        if B1.most_common(2)[1][1]>=B2.most_common(2)[1][1]:
            ans=N-B1.most_common(2)[1][1]-B2.most_common(2)[0][1]
        else:
            ans=N-B2.most_common(2)[1][1]-B1.most_common(2)[0][1]
    elif B1.most_common(2)[0][0]==B2.most_common(2)[0][0]:
        if B1.most_common(2)[0][1]>=B2.most_common(2)[0][1]:
            ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[1][1]
        else:
            ans=N-B2.most_common(2)[0][1]-B1.most_common(2)[1][1]
    else:
        ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[0][1]
    print(ans)
Buggy python submission (verdict: Runtime Error):
import functools
import math

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

A=list(map(int,input().split()))
B=[]
for i in range(len(A)):
    B.append(A[i]-X)
#print(B)

gcd = functools.reduce(math.gcd, B)
print(gcd)

Fixed submission:
N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(abs(A[i]-X))


a=B[0]

for j in range(1,N):
    b=B[j]
    if b<a:
        a,b=b,a
    while b!=0:
        a,b=b,a%b
print(a)
Buggy python submission (verdict: Runtime Error):
import math
import fractions



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

A=list(map(int,input().split()))
B=[]
for i in range(len(A)):
    B.append(A[i]-X)
print(gcd(B))


Fixed submission:
H,W=map(int,input().split())
L=[]

for i in range(H):
    L1=list(map(int,input().split()))
    L.append(L1)
ans=[]
cnt=0
for a in range(H):
    for b in range(W):
        if a%2==0:
            if b<W-1:
                if L[a][b]%2==1:
                    L[a][b]-=1
                    L[a][b+1]+=1
                    ans.append([a+1,b+1,a+1,b+2])
                    cnt+=1
            if b==W-1:
                if a<H-1:
                    if L[a][b]%2==1:
                        L[a][b]-=1
                        L[a+1][b]+=1
                        ans.append([a+1,b+1,a+2,b+1])
                        cnt+=1
        if a%2==1:
            if b<W-1:
                if L[a][W-1-b]%2==1:
                    L[a][W-1-b]-=1
                    L[a][W-1-b-1]+=1
                    ans.append([a+1,W-b,a+1,W-1-b])
                    cnt+=1
            if b==W-1:
                if a<H-1:
                    if L[a][W-1-b]%2==1:
                        L[a][W-1-b]-=1
                        L[a+1][W-1-b]+=1
                        ans.append([a+1,W-b,a+2,W-b])
                        cnt+=1
print(cnt)
for x in range(len(ans)):
    print(ans[x][0],ans[x][1],ans[x][2],ans[x][3])