Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
icase=0
if icase==0:
    n=int(input())  #数値入力 「N」だけの入力のとき
    a=[]
    b=[]
    c=[]
    for i in range(n):
       ai,bi,ci=map(int, input().split())
       a.append(ai)
       b.append(bi)
       c.append(ci)
elif icase==1:
    n=2
    a=[1,5]
    b=[2,4]
    c=[3,6]
elif icase==2:
    n=6
    a=[3, 14, 159, 2, 6, 53]
    b=[58, 9, 79, 323, 84, 6]
    c=[2643, 383, 2, 79, 50, 288]
    
a.sort()
b.sort()
c.sort()
   
icnt=0
ast=0
cst=0
for i in range(n):
    if a[n-1]<=b[i]:
        ast=n
#        print("a1:",ast-1,a[ast-1],i,b[i])
    else:
        while a[ast]<b[i] and ast<n-1:
            ast=ast+1
#            print("a2:",ast-1,a[ast-1],i,b[i])
    if b[i]<c[0]:
        cst=0 
#        print("c1:",cst,c[cst],i,b[i])
    else:
        while b[i]>=c[cst] and cst<n-1:
            cst=cst+1
#            print("c2:",cst-1,c[cst-1],i,b[i])
#    print(ast,i,n-cst)
    icnt=icnt+(ast)*(n-cst)
    
print(icnt)

Fixed submission:
icase=0
if icase==0:
    n=int(input())  #数値入力 「N」だけの入力のとき
    a=list(map(int, input().split()))
    b=list(map(int, input().split()))
    c=list(map(int, input().split()))
elif icase==1:
    n=2
    a=[1,5]
    b=[2,4]
    c=[3,6]
elif icase==2:
    n=6
    a=[3, 14, 159, 2, 6, 53]
    b=[58, 9, 79, 323, 84, 6]
    c=[2643, 383, 2, 79, 50, 288]
    
a.sort()
b.sort()
c.sort()
   
icnt=0
ast=0
cst=0
for i in range(n):
    if a[n-1]<=b[i]:
        ast=n
#        print("a1:",ast-1,a[ast-1],i,b[i])
    elif a[0]>=b[i]:
        ast=0
#        print("a1:",ast-1,a[ast-1],i,b[i])
    else:
        while a[ast]<b[i] and ast<n-1:
            ast=ast+1
#            print("a2:",ast-1,a[ast-1],i,b[i])
    if b[i]<c[0]:
        cst=0 
    elif b[i]>=c[n-1]:
        cst=n 
#        print("c1:",cst,c[cst],i,b[i])
    else:
        while b[i]>=c[cst] and cst<n-1:
            cst=cst+1
#            print("c2:",cst-1,c[cst-1],i,b[i])
#    print(ast,i,n-cst)
    icnt=icnt+(ast)*(n-cst)
    
print(icnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

icase=0
if icase==0:
    n=int(input())
    a=[[0]*n for i in range(n)]
    for i in range(n):
        a[i]=list(map(int,input().split()))
elif icase==1:
    n=3
    a=[[0, 1, 3], [1, 0, 2], [3, 2, 0]]
#    a=[[0, 1, 3], [1, 0, 1], [3, 1, 0]]

dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i]=a[i].copy()
    
c=[[0]*n for i in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if dp[i][j]>dp[i][k]+dp[k][j]:
                dp[i][j]=dp[i][k]+dp[k][j]
            if dp[i][j]==dp[i][k]+dp[k][j] and i!=k and j!=k:
                c[i][j]=1                
                

icnt=0
for i in range(0,n-1):
    for j in range(i+1,n):
        if a[i][j]!=dp[i][j]:
            print(-1)
            sys.exit()
        elif c[i][j]==0:
            icnt+=dp[i][j]
print(icnt)

Fixed submission:
import sys

icase=0
if icase==0:
    n=int(input())
    a=[[0]*n for i in range(n)]
    for i in range(n):
        a[i]=list(map(int,input().split()))
elif icase==1:
    n=3
    a=[[0, 1, 3], [1, 0, 2], [3, 2, 0]]
#    a=[[0, 1, 3], [1, 0, 1], [3, 1, 0]]

dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i]=a[i].copy()
    
c=[[0]*n for i in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if dp[i][j]>dp[i][k]+dp[k][j]:
                dp[i][j]=dp[i][k]+dp[k][j]
            if dp[i][j]==dp[i][k]+dp[k][j] and i!=k and j!=k:
                c[i][j]=1                
                

icnt=0
for i in range(0,n-1):
    for j in range(i+1,n):
        if a[i][j]!=dp[i][j]:
            print(-1)
            sys.exit()
        elif c[i][j]==0:
            icnt+=dp[i][j]
print(icnt)
Buggy python submission (verdict: Runtime Error):
c=[1]*(10**9)
a=[]
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    a.append(ai)
    
icnt=0
for i in range(n):
  if c[a[i]]==0:
      icnt=icnt+1
      
print(icnt)


Fixed submission:
dicc=dict()

n=int(input())
for i in range(n):
    ai=input()
    if ai in dicc:
        dicc[ai]=1-dicc[ai]
    else:
        dicc[ai]=1
        
icnt=0    
for i in dicc.values():
    icnt=icnt+i
      
print(icnt)

Buggy python submission (verdict: Runtime Error):
nmax=10**9+1
c=[1]*nmax
a=[]
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    a.append(ai)
    
icnt=0
for i in range(n):
  if c[a[i]]==0:
      icnt=icnt+1
      
print(icnt)
    

Fixed submission:
dicc=dict()

n=int(input())
for i in range(n):
    ai=input()
    if ai in dicc:
        dicc[ai]=1-dicc[ai]
    else:
        dicc[ai]=1
        
icnt=0    
for i in dicc.values():
    icnt=icnt+i
      
print(icnt)

Buggy python submission (verdict: Runtime Error):
c=[1]*100000
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    
icnt=0
for i in range(100000):
  if c[i]==0:
      icnt=icnt+1
      
print(icnt)
    

Fixed submission:
dicc=dict()

n=int(input())
for i in range(n):
    ai=input()
    if ai in dicc:
        dicc[ai]=1-dicc[ai]
    else:
        dicc[ai]=1
        
icnt=0    
for i in dicc.values():
    icnt=icnt+i
      
print(icnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
r=[[] for i in range(n+1)]
#r=[]*(n+1)
for i in range(m):
    ai,bi=map(int,input().split())
    if not bi in r[ai]:
        r[ai].append(bi)
        r[bi].append(ai)
yn=""
for i in range(2,n):
    if (i in r[1]) and (i in r[n]):
        print("POSSIBLE")
        yn="POSSIBLE"
        break
if yn=="":
    print("IMPOSSIBLE")

Fixed submission:

n,m=map(int,input().split())
a1=set()
an=set()
for i in range(m):
    ai,bi=map(int,input().split())
    if ai==1:
        a1.add(bi)
    elif bi==n:
        an.add(ai)

if len(a1&an)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a1=[]
an=[]
for i in range(m):
    ai,bi=map(int,input().split())
    if ai==1:
        a1.append(bi)
    elif bi==n:
        an.append(ai)

a1.sort()
an.sort()

flag = False

for i in range(len(a1)):
    if a1[i] in an:
        flag = True
        break
  
if flag==True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:

n,m=map(int,input().split())
a1=set()
an=set()
for i in range(m):
    ai,bi=map(int,input().split())
    if ai==1:
        a1.add(bi)
    elif bi==n:
        an.add(ai)

if len(a1&an)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a1=[]
an=[]
for i in range(m):
    ai,bi=map(int,input().split())
    if ai==1:
        a1.append(bi)
    elif bi==n:
        an.append(ai)

a1.sort()
an.sort()

flag = False

for i in range(len(a1)):
    for j in range(len(an)):
        if a1[i]==an[j]:
            flag = True
            break
    if flag==True:
        break

if flag==True:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
    

Fixed submission:

n,m=map(int,input().split())
a1=set()
an=set()
for i in range(m):
    ai,bi=map(int,input().split())
    if ai==1:
        a1.add(bi)
    elif bi==n:
        an.add(ai)

if len(a1&an)==0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n=int(input())
a=list(map(int,input().split()))
#n=6
#a=[1,2,3,4,5,6]

if n==2:
    print(abs(a[1]-a[0]))
else:
#    for i in range(n):
#        if a[i]<0:
#            a[i]=-a[i]
#        else:
#            break
#    a.sort(reverse=True)
    asum=sum(a)
#    print("asum:",asum)
# itertools 使用 bit全探索
    xmin=asum
    for ip in itertools.product([0,1], repeat=n):
        xsum=sum([a[i] for i in range(len(ip)) if ip[i]==1])
#        xsum=0
#        for i in range(len(ip)):
#            if ip[i]==1:
#                xsum=xsum+a[i]
#        print("xsum:",xsum,ip)
        xmin=min(xmin,abs(asum-2*xsum)) 
    print(xmin)


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

if n==2:
    print(abs(a[1]-a[0]))
else:
    asum=sum(a)
    xsum=0
    xmin=n*(10**9)+1
    for i in range(n-1):
        xsum=xsum+a[i]
        xmin=min(xmin,abs(asum-2*xsum))
    print(xmin)

Buggy python submission (verdict: Time Limit Exceeded):

import itertools

n=int(input())
a=list(map(int,input().split()))
#n=6
#a=[1,2,3,4,5,6]

if n==2:
    print(abs(a[1]-a[0]))
else:
    for i in range(n):
        if a[i]<0:
            a[i]=-a[i]
        else:
            break
    a.sort(reverse=True)
    asum=sum(a)
#    print("asum:",asum)
# itertools 使用 bit全探索
    xmin=asum
    for ip in itertools.product([0,1], repeat=n):
        xsum=sum([a[i] for i in range(len(ip)) if ip[i]==1])
#        xsum=0
#        for i in range(len(ip)):
#            if ip[i]==1:
#                xsum=xsum+a[i]
#        print("xsum:",xsum,ip)
        xmin=min(xmin,abs(asum-2*xsum)) 
    print(xmin)


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

if n==2:
    print(abs(a[1]-a[0]))
else:
    asum=sum(a)
    xsum=0
    xmin=n*(10**9)+1
    for i in range(n-1):
        xsum=xsum+a[i]
        xmin=min(xmin,abs(asum-2*xsum))
    print(xmin)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

#      0  1  2  3  evn odd
# kevn +  -  +  -   +   -
# kodd -  +  -  +   -   +
def kf(a,flag):
    a0=a[0]*flag
    if a0<=0:
        kevn=1-a0
        sevn=1
    elif a0>0:
        kevn=0
        sevn=a0

    for i in range(1,n):
        ai=a[i]*flag
        if i%2==0:
            if sevn+ai<=0:
                kevn=kevn+1-(ai+sevn)
                sevn=1
            elif sevn+ai>0:
                kevn=kevn
                sevn=sevn+ai
        elif i%2==1:
            if sevn+ai<0:
                kevn=kevn
                sevn=sevn+ai
            elif sevn+ai>=0:
                kevn=kevn+1+(ai+sevn)
                sevn=-1
    return kevn

kevn1=kf(a,1,n)
kevn=kf(a,-1,n)

kevn=min(kevn,kevn1)

print(kevn)

Fixed submission:
n=int(input())

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

kp=0
asum=0
flag=-1
for i in range(n):
    asum=asum+a[i]
    if flag==-1:
        if asum>=0:
            kp=kp+asum+1
            asum=-1
    else:
        if asum<=0:
            kp=kp+1-asum
            asum=1
    flag=-flag
#    print(asum)
#print("-----",kp)            
km=0
asum=0
flag=1
for i in range(n):
    asum=asum+a[i]
    if flag==-1:
        if asum>=0:
            km=km+asum+1
            asum=-1
    else:
        if asum<=0:
            km=km+1-asum
            asum=1
    flag=-flag
#    print(asum)
#print("-----",km)            

print(min(kp,km))
Buggy python submission (verdict: Runtime Error):
icase=0
if icase==0:
    w,h=map(int,input().split())
#    xy=[[1]*w for i in range(2*h)]
    for i in range(h):
        cij=input()
        print(cij)
        print(cij)
        

Fixed submission:
icase=0
if icase==0:
    h,w=map(int,input().split())
#    xy=[[1]*w for i in range(2*h)]
    for i in range(h):
        cij=input()
        print(cij)
        print(cij)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=1
b=1
for i in range(n):
    ti,ai=map(int,input().split())
    m=1
    while a>m*ti or b>m*ai:
        m=m+1
#        print(m,a,m*ti,b,m*ai)
#    print(m,a,m*ti,b,m*ai)
    a=m*ti
    b=m*ai
#    print(a,b,m)
print(a+b)    

Fixed submission:
icase=0
if icase==0:
    n=int(input())
    t=[0]*n
    a=[0]*n

    for i in range(n):
        t[i],a[i]=map(int,input().split())
elif icase==1:
    n=5
    t=[3,48,31,231,3]
    a=[10,17,199,23,2]
    ans=6930

ti=t[0]
ai=a[0]
dt=1
for i in range(n-1):
    if ti/t[i+1]>ai/a[i+1]:
        ii=max((ti-dt)//t[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]
    else:
        ii=max((ai-dt)//a[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]

print(ai+ti)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
t=[]
a=[]

for i in range(n):
    ti,ai=map(int,input().split())
    t.append(ti)
    a.append(ai)
    
ti=t[0]
ai=a[0]

for i in range(n-1):
    ta=a[i+1]*t[i+1]
    for ii in range(1,10000000):
        if ta*ii//a[i+1]>=ti and ta*ii//t[i+1]>=ai:
            ti=ta*ii//a[i+1]
            ai=ta*ii//t[i+1]
            break
            
print(ai+ti)

Fixed submission:
icase=0
if icase==0:
    n=int(input())
    t=[0]*n
    a=[0]*n

    for i in range(n):
        t[i],a[i]=map(int,input().split())
elif icase==1:
    n=5
    t=[3,48,31,231,3]
    a=[10,17,199,23,2]
    ans=6930

ti=t[0]
ai=a[0]
dt=1
for i in range(n-1):
    if ti/t[i+1]>ai/a[i+1]:
        ii=max((ti-dt)//t[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]
    else:
        ii=max((ai-dt)//a[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]

print(ai+ti)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
#from math import gcd

n=int(input())
t=[]
a=[]
for i in range(n):
    ti,ai=map(int,input().split())
    t.append(ti)
    a.append(ai)
    
ti=t[0]
ai=a[0]
for i in range(n-1):
    ta=gcd(t[i+1],a[i+1])*a[i+1]*t[i+1]
    for ii in range(1,10000000):
        if ta*ii//a[i+1]>=ti and ta*ii//t[i+1]>=ai:
            ti=ta*ii//a[i+1]
            ai=ta*ii//t[i+1]
#            print(i,ii,ti,ai,ta)
            break
            
print(ai+ti)
         
    

Fixed submission:
icase=0
if icase==0:
    n=int(input())
    t=[0]*n
    a=[0]*n

    for i in range(n):
        t[i],a[i]=map(int,input().split())
elif icase==1:
    n=5
    t=[3,48,31,231,3]
    a=[10,17,199,23,2]
    ans=6930

ti=t[0]
ai=a[0]
dt=1
for i in range(n-1):
    if ti/t[i+1]>ai/a[i+1]:
        ii=max((ti-dt)//t[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]
    else:
        ii=max((ai-dt)//a[i+1]+1,1)
        ti=ii*t[i+1]
        ai=ii*a[i+1]

print(ai+ti)
Buggy python submission (verdict: Runtime Error):
import sys
import math
X,K,D = map(int, input().split()) 
X1=abs(X)
syou=math.floor(X1/D)
amari=math.floor(K/syou)
ans=0
if amari==0:
    ans=X1-D*K
else:
    ya=math.floor(K/amari)
    ans=X1-ya*D
    if ya%2==0:
        print(ans)
        sys.exit()
    if abs(ans+D)>abs(ans-D):
        ans=ans-D
    else:
        ans=ans+D
print(abs(ans))

Fixed submission:
import sys

S=input()
ans=0
ans=S.count("R")
if ans==2 and S[1]=="S":
    print("1")
    sys.exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))
#AA=A.sort()
if A.count(0)>0:
    ans=0
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)

Fixed submission:
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))
#AA=A.sort()
if A.count(0)>0:
    ans=0
elif N>30 and A.count(1)<10:
    ans=-1
    
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)

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

for i in range(N):
    ans*=A[i]
    if A.count(0)>0:
        ans=0
        break
    if ans>10**18:
        ans=-1
        break
    

print(ans)

Fixed submission:
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))
#AA=A.sort()
if A.count(0)>0:
    ans=0
elif N>30 and A.count(1)<10:
    ans=-1
    
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)

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

for i in range(N):
    ans*=A[i]
    if A.count(0)>0:
        ans=0
        break
    if ans>10**18:
        ans=-1
        break
    

print(ans)

Fixed submission:
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))
#AA=A.sort()
if A.count(0)>0:
    ans=0
elif N>30 and A.count(1)<10:
    ans=-1
    
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A = list(map(int, input().split()))
ans=1
for i in range(N):
    ans*=A[i]
    
if ans>10**18:
    ans=-1
print(ans)

Fixed submission:
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))
#AA=A.sort()
if A.count(0)>0:
    ans=0
elif N>30 and A.count(1)<10:
    ans=-1
    
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)
Buggy python submission (verdict: Runtime Error):
T=input()
T_len=len(T)
S=list(T)
if S[0]=="?":
    S[0]="D"

for i in range(T_len):
    if S[i]=="?":
        if S[i-1]=="D" and (S[i+1]=="D" or S[i+1]=="?"):
            S[i]="P"
        else:
            S[i]="D"
str_changed = "".join(S)
print(str_changed)

Fixed submission:
T=input()
T_len=len(T)
S=list(T)
if S[0]=="?":
    S[0]="D"
if S[-1]=="?":
    S[-1]="D"

for i in range(T_len):
    if S[i]=="?":
        if S[i-1]=="D" and (S[i+1]=="D" or S[i+1]=="?"):
            S[i]="P"
        else:
            S[i]="D"
str_changed = "".join(S)
print(str_changed)
Buggy python submission (verdict: Runtime Error):
S=input()
S1=int(S)
#print(len(S))
S_count=len(S)
sum=0
sum1=0
ii=0
jj=4
SSSS=int(S_count)
for i in range(S_count):
  sum1+=i
#print(sum1)
for i in range(sum1):
  if ii==int(S_count-1):
    break
  SS=S[ii:jj]
  #print(SS)
  SSS=int(SS)
  if SSS%2019==0:
    sum+=1
  jj+=1
  if jj==int(S_count+1):
    ii+=1
    if ii>=4:
      jj=ii+1
    else:
      jj=4
  
print(sum)

Fixed submission:
S,W=map(int,input().split())
if(S<=W):
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
import math  
from itertools import product  

x = int(input())  

s = 0  
for a, b, c in product(range(1, x+1), repeat=3):  
  s += math.gcd(math.gcd(a, b), c)  
print(s)  

Fixed submission:
import math  
from itertools import product  

x = int(input())  

s = 0  
for a, b, c in product(range(1, x+1), repeat=3):  
  s += math.gcd(math.gcd(a, b), c)  
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum=0
i1=1
i2=1
i3=1
gc=0
K=int(input())
for i in range(K):
  if i2==(K+1):
        i2=1
  for j in range(K):
    if i1==(K+1):
        i1=1
    for z in range(K):
      
      #print(i)
      sum+=gcd(i1,i2,i3)
      i1+=1
      
    i2+=1
    
  i3+=1
      
#sum+=gcd(K,K,K)
print(sum)
#print(gcd(5,10,20))

Fixed submission:
import math  
from itertools import product  

x = int(input())  

s = 0  
for a, b, c in product(range(1, x+1), repeat=3):  
  s += math.gcd(math.gcd(a, b), c)  
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N,K=map(int,input().split())
ZET=N
b=(10**18)
c=N
b1=N
for i in range(int(b)):
  if K==1:
    b1=0
    break
  if K==2:
    if N%2==0:
      b1=0
    else:
      b1=1
    break
  c=abs(b1-K)
  if int(b)<=c:
    break
  b1=c
  b=c
print(b1)

Fixed submission:
import sys

N,K=map(int,input().split())
ZET=N
b=(10**18)
c=N
b1=N
for i in range(int(b)):
  if K==1:
    b1=0
    break
  if N>10**17 and K<10**9:
    b1=N%K
    c=abs(b1-K)
    if b1>c:
      b1=c
    break
  c=abs(b1-K)
  if int(b)<=c:
    break
  b1=c
  b=c
print(b1)

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

N,K=map(int,input().split())
ZET=N
b=(10**18)
c=N
b1=N
for i in range(int(b)):
  if K==1:
    b1=0
    break
  c=abs(b1-K)
  if int(b)<=c:
    break
  b1=c
  b=c
print(b1)

Fixed submission:
import sys

N,K=map(int,input().split())
ZET=N
b=(10**18)
c=N
b1=N
for i in range(int(b)):
  if K==1:
    b1=0
    break
  if N>10**17 and K<10**9:
    b1=N%K
    c=abs(b1-K)
    if b1>c:
      b1=c
    break
  c=abs(b1-K)
  if int(b)<=c:
    break
  b1=c
  b=c
print(b1)

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

N,K=map(int,input().split())
ZET=N
b=(10**18)
c=N
b1=N
for i in range(int(b)):
  if K==1:
    b1=0
    break
  c=abs(b1-K)
  if int(b)<c:
    break
  b1=c
  b=c
print(b1)

Fixed submission:
import sys

N,K=map(int,input().split())
ZET=N
b=(10**18)
c=N
b1=N
for i in range(int(b)):
  if K==1:
    b1=0
    break
  if N>10**17 and K<10**9:
    b1=N%K
    c=abs(b1-K)
    if b1>c:
      b1=c
    break
  c=abs(b1-K)
  if int(b)<=c:
    break
  b1=c
  b=c
print(b1)
Buggy python submission (verdict: Runtime Error):
s1,s2,s3,s4,s5,s6=input()
#print(S)
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)

Fixed submission:
s1,s2,s3,s4,s5,s6=input()
#print(S)
ans='No'
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)

Buggy python submission (verdict: Runtime Error):
s1,s2,s3,s4,s5,s6=input()
#print(S)
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)


Fixed submission:
s1,s2,s3,s4,s5,s6=input()
#print(S)
ans='No'
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)

Buggy python submission (verdict: Runtime Error):
s1,s2,s3,s4,s5,s6=input()
#print(S)
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)


Fixed submission:
s1,s2,s3,s4,s5,s6=input()
#print(S)
ans='No'
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)

Buggy python submission (verdict: Runtime Error):
s1,s2,s3,s4,s5,s6=input()
#print(S)
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)


Fixed submission:
s1,s2,s3,s4,s5,s6=input()
#print(S)
ans='No'
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)

Buggy python submission (verdict: Runtime Error):
s1,s2,s3,s4,s5,s6=input()
#print(S)
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)

Fixed submission:
s1,s2,s3,s4,s5,s6=input()
#print(S)
ans='No'
if(s3==s4):
  if(s5==s6):
    ans='Yes'
else:
  ans='No'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
r,g,b,n = map(int, input().split())
count=0
hiku=0
for i in range(n+1):
    for j in range(n+1):
        hiku=n-r*i-g*j
        if hiku%b==0 and hiku>=0:
            count+=1
print(count)

Fixed submission:
import math
import sys
r,g,b,n = map(int, input().split())
count=0
hiku=0
for i in range(n+1):
    for j in range(n+1):
        hiku=n-r*i-g*j
        if hiku%b==0 and hiku>=0:
            count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools

S=input()
ans=0
Wcount=0
SS=S
#print(S[0])
#S=S.split()
#print(S[0])

for i in range(len(S)):
    SS=S[i:]
    s=collections.Counter(SS)
    if S[i]=="B":
        #print(S)
        Wcount=s["W"]
        ans+=Wcount
    if s["B"]==0:
        break
    #s=collections.Counter(S)
    #if s["W"]==0:
        #print(ans)
        #sys.exit()
print(ans)

Fixed submission:
s=input()
ans=0
count=0
for i in range(len(s)):
    if s[i]=="W":
        ans+=i-count
        count+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools

S=input()
ans=0
Wcount=0
SS=S
#print(S[0])
#S=S.split()
#print(S[0])

for i in range(len(S)):
    if S[i]=="B":
        SS=S[i:]
        s=collections.Counter(SS)
        #print(S)
        Wcount=s["W"]
        ans+=Wcount
    #s=collections.Counter(S)
    #if s["W"]==0:
        #print(ans)
        #sys.exit()
print(ans)

Fixed submission:
s=input()
ans=0
count=0
for i in range(len(s)):
    if s[i]=="W":
        ans+=i-count
        count+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import sys
import collections
n,k = map(int, input().split())
A = list(map(int, input().split()))
count=len(A)
Adel=list(set(A))
ans=len(Adel)-k
#print(Adel)
if ans<0:
    ans=0
    print(ans)
    sys.exit()
newA=collections.Counter(A)
ans=len(Adel)
Aans=n
for i in range(k+1):
    count=newA.most_common()[i][i]
    #print(count)
    ans=ans-1
    Aans=Aans-count
    if ans==k:
        print(n-Aans)
        sys.exit()
    #print(count)
#print(newA)
#print(A)

Fixed submission:
import math
import sys
import collections
n,k = map(int, input().split())
A = list(map(int, input().split()))
count=len(A)
Adel=list(set(A))
ans=len(Adel)-k
#print(Adel)
if ans<0:
    ans=0
    print(ans)
    sys.exit()
newA=collections.Counter(A)
count=list(newA.values())
count.sort()
#print(count)
ans=sum(count[:-k])
print(ans)