Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print(*ans[1:])


Fixed submission:
a=int(input())
print(input() if a>=3200 else "red")
Buggy python submission (verdict: Runtime Error):
from heapq import heappop,heappush
n,m=map(int,input().split())
work=[set() for _ in range(m+1)]
for _ in range(n):
    a,b=map(int,input().split())
    if a<=m: work[a].add(b)

ans=0
q=[]
for i in range(1,m+1):
    for x in work[i]:
        heappush(q,-x)
    if q!=[]: ans+=heappop(q)
print(-ans)

Fixed submission:
a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
import sys
def cur(i):
    if p[i]!=False: return p[i]
    if s[i]=="R":
        if s[i+1]=="L": p[i]=1
        else: p[i]=cur(i+1)+1
    if s[i]=="L":
        if s[i-1]=="R": p[i]=-1
        else: p[i]=cur(i-1)-1 
    return p[i]

s=input()
n=len(s)
p=[False for _ in range(n)]

for i in range(n):
    cur(i)
sys.exit()
ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else: ans[i+p[i]+p[i]%2]+=1
print(*ans)

Fixed submission:
import sys
s=input()
n=len(s)
p=[0 for _ in range(n)]

for i in range(n):
    if s[i]=="L": p[i]=p[i-1]-1 if s[i-1]=="L" else -1
for i in range(n-1,-1,-1):
    if s[i]=="R": p[i]=p[i+1]+1 if s[i+1]=="R" else 1

ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else:
        if p[i]%2==0: ans[i+p[i]]+=1
        else: ans[i+p[i]+1]+=1
print(*ans)

Buggy python submission (verdict: Runtime Error):
def cur(i):
    if p[i]!=False: return p[i]
    if s[i]=="R":
        if s[i+1]=="L": p[i]=1
        else: p[i]=cur(i+1)+1
    if s[i]=="L":
        if s[i-1]=="R": p[i]=-1
        else: p[i]=cur(i-1)-1 
    return p[i]

s=input()
n=len(s)
p=[False for _ in range(n)]

for i in range(n):
    cur(i)

ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else: ans[i+p[i]+p[i]%2]+=1
print(*ans)

Fixed submission:
import sys
s=input()
n=len(s)
p=[0 for _ in range(n)]

for i in range(n):
    if s[i]=="L": p[i]=p[i-1]-1 if s[i-1]=="L" else -1
for i in range(n-1,-1,-1):
    if s[i]=="R": p[i]=p[i+1]+1 if s[i+1]=="R" else 1

ans=[0]*n
for i in range(n):
    if p[i]>0:
        ans[i+(p[i]//2)*2]+=1
    else:
        if p[i]%2==0: ans[i+p[i]]+=1
        else: ans[i+p[i]+1]+=1
print(*ans)
Buggy python submission (verdict: Runtime Error):
import heapq
import sys
sys.setrecursionlimit(10 ** 7)

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

event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append([s-x,1,x])
    event.append([t-x,-1,x])

for i in range(q):
    event.append([int(input()),2,i])
event.sort()

ans=[0]*q

stop=set()
hq=[]
for e in event:
    t,op,x=map(lambda x:x,e)
    if op==1:
        heapq.heappush(hq,x)
        stop.add(x)
    elif op==-1:
        stop.remove(x)

    else:
        while hq and hq[0] not in stop:
            heapq.heappop(hq) 
        ans[x]=hq[0] if hq else -1
    
for x in ans:
    print(x)

Fixed submission:
import sys

A,P=map(int,input().split())
print((A*3+P)//2)
Buggy python submission (verdict: Runtime Error):
import bisect
import heapq 

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
l,r=[-que[1]],[que[1]]
heapq.heapify(l)
heapq.heapify(r)
a=0
tmp=que[1]
j=1
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        b+=que[2]
        q1=que[1]
        if j%2==0:
            if q1<-l[0]:
                heapq.heappushpop(l,-q1)
            else:
                heapq.heappushpop(r,q1)

        else:
            if q1<-l[0]:
                heapq.heappush(r, -heapq.heappushpop(l,-q1))
            else:
                heapq.heappush(l, -heapq.heappushpop(r,q1))
        
        if -l[0]!=r[0]: a+=abs(tmp-q1)
        else: a+=abs(tmp-q1)-abs(-l[0]-tmp)
        tmp=-l[0]

    elif que[0]==2:
        print(tmp,a+b)

Fixed submission:
A,B=map(int,input().split())

if A>12: print(B)
elif A>5: print(B//2)
else: print(0)

Buggy python submission (verdict: Runtime Error):
import bisect
import heapq 

Q=int(input())

que=list(map(int,input().split()))
b=que[2]
a=[que[1]]
l,r=[-que[1]],[que[1]]
heapq.heapify(l)
heapq.heapify(r)
min=0
j=1
tmp=que[1]
for i in range(Q-1):
    que=list(map(int,input().split()))
    if que[0]==1:
        j+=1
        q1=que[1]
        b+=que[2]
        tmp=-l[0]
        if j%2==0:
            if q1<=-l[0]:
                heapq.heappushpop(l,-q1)
            else:
                heapq.heappushpop(r,q1)

        else:
            if q1<=-l[0]:
                heapq.heappush(r, -heapq.heappushpop(l,-q1))
            else:
                heapq.heappush(l, -heapq.heappushpop(r,q1))
        
        if -l[0]!=r[0]: min+=abs(tmp-q1)
        else: min+=abs(tmp-q1)-abs(-l[0]-tmp)
        tmp=-l[0]

    elif que[0]==2:
        print(tmp,min+b)

Fixed submission:
A,B=map(int,input().split())

if A>12: print(B)
elif A>5: print(B//2)
else: print(0)
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=0
M=math.ceil(N**0.5+2)
for i in range(1,M):
    if N%i==0 and N//i-i>1: ans+=N//i-1

print(ans)

Fixed submission:
import math

N=int(input())
ans=0
M=math.ceil(N**0.5+2)
for i in range(1,M):
    if N%i==0 and N//i-i>1: ans+=N//i-1

print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a


def cul(n,x):
    l=len(x)
    b=[x[i] for i in range(l)]
    b.pop(n)
    tmp=b[0]
    for i in range(1,l-1):
        tmp=gcd(tmp,b[i])
    return tmp

import sys
import math
p=10
N=int(input())
a=list(map(int,input().split()))
if N<=p:
    ans=0
    
    for i in range(N):
        tmp=cul(i,a)        
        if tmp>ans: ans=tmp
    print(ans)
    sys.exit()
        
M=a[0]
for i in range(1,p):
    M=gcd(M,a[i])

ans=0
for i in range(1,math.ceil(M**0.5)+1 ):
    if M%i==0:
        cnt=0
        for j in range(p,N):
            if a[i]%i!=0:
                cnt+=1
                if cnt==2: break
            elif i==N-1 and i>ans: ans=i
        
        x=M//i
        cnt=0
        for j in range(p,N):
            if a[i]%x!=0:
                cnt+=1
                if cnt==2: break
            elif i==N-1 and x>ans: ans=x



print(ans)

Fixed submission:
A,B,T=map(int,input().split())
ans=(T+0.5)//A
ans*=B
print(int(ans))
Buggy python submission (verdict: Runtime Error):
import math
import sys

X,Y,Z,K=map(int,input().split())

x=sorted(list(map(int,input().split())),reverse=True)
y=sorted(list(map(int,input().split())),reverse=True)
z=sorted(list(map(int,input().split())),reverse=True)



"""
if X*Y*Z<=3000:
    ans=[]
    for i in range(X):
        for j in range(Y):
            for k in range(Z):  ans.append(x[i]+y[j]+z[k])
    ans.sort()
    for i in range(min(3000,X*Y*Z)):
        print(ans[i])
    sys.exit()
"""

yz=[]
for i in range(Y):
    yz=yz+[ y[i]+z[j] for j in range(Z)]

yz.sort(reverse=True)

if len(yz)>K:
    yz=yz[:K]


n=len(yz)
ans=[]

for i in range(X):
    tmp=[yz[j]+x[i] for j in range(len(yz))]
    ans =ans+tmp

ans.sort(reverse=True)


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


Fixed submission:
import math
import sys

a=[int(input()) for i in range(5)]
k=int(input())

for i in range(5):
        for j in range(5):
                if a[i]-a[j]>k:
                        print(":(")
                        sys.exit()

print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
def cul(i,x):
    if tmp[i][x]==-1:
        tmp[i][x]=( cul(i+1,x)*(N-1-i) + cul(i+1,x%a[i]) )%MOD
    return tmp[i][x]

MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort(reverse=True)
tmp= [[-1 for j in range(x+1)] for i in range(N)] + [[j for j in range(x+1)]]
for i in range(N-1,-1,-1):
    for j in range(x+1):
        tmp[i][j]=( tmp[i+1][j]*(N-1-i) + tmp[i+1][j%a[i]] )  % MOD

print(tmp[0][x])

Fixed submission:
import math

def cul(i,x):
    if tmp[i][x]==-1:
        tmp[i][x]=( cul(i+1,x)*(N-1-i) + cul(i+1,x%a[i]) )%MOD
    return tmp[i][x]

MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort(reverse=True)
tmp= [[-1 for j in range(x+1)] for i in range(N)] + [[j for j in range(x+1)]]

print(cul(0,x))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

MOD=10**9+7
N,x=map(int,input().split())
 
a=list(map(int,input().split()))
a.sort()
a.reverse()
table=np.arange(x+1)


for i in range(N-1,-1,-1):
	tmp=table.copy()
	for j in range(x+1):
		table[j]=( tmp[j]*(N-1-i) + tmp[j%a[i]] ) % MOD
 
print(int(table[x]))

Fixed submission:
import math

def cul(i,x):
    if tmp[i][x]==-1:
        tmp[i][x]=( cul(i+1,x)*(N-1-i) + cul(i+1,x%a[i]) )%MOD
    return tmp[i][x]

MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort(reverse=True)
tmp= [[-1 for j in range(x+1)] for i in range(N)] + [[j for j in range(x+1)]]

print(cul(0,x))

Buggy python submission (verdict: Time Limit Exceeded):
MOD=10**9+7
N,x=map(int,input().split())
 
a=list(map(int,input().split()))
a.sort()
a.reverse()
table=[[0 for i in range(N+1)] for j in range(x+1)]
for i in range(x+1):
	table[i][N]=i
 
for i in range(N-1,-1,-1):
	for j in range(x+1):
		table[j][i]=(table[j][i+1]*(N-1-i)+table[j%a[i]][i+1]) % MOD
 
print(table[x][0])

Fixed submission:
import math

def cul(i,x):
    if tmp[i][x]==-1:
        tmp[i][x]=( cul(i+1,x)*(N-1-i) + cul(i+1,x%a[i]) )%MOD
    return tmp[i][x]

MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort(reverse=True)
tmp= [[-1 for j in range(x+1)] for i in range(N)] + [[j for j in range(x+1)]]

print(cul(0,x))

Buggy python submission (verdict: Time Limit Exceeded):
MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort()
a.reverse()
table=[[0 for i in range(N+1)] for j in range(x+1)]
for i in range(x+1):
	table[i][N]=i

for i in range(N-1,-1,-1):
	for x in range(x+1):
		table[x][i]=(table[x][i+1]*(N-1-i)+table[x%a[i]][i+1]) % MOD 

print(table[x][0])

Fixed submission:
import math

def cul(i,x):
    if tmp[i][x]==-1:
        tmp[i][x]=( cul(i+1,x)*(N-1-i) + cul(i+1,x%a[i]) )%MOD
    return tmp[i][x]

MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort(reverse=True)
tmp= [[-1 for j in range(x+1)] for i in range(N)] + [[j for j in range(x+1)]]

print(cul(0,x))
Buggy python submission (verdict: Runtime Error):
import sys

def chk(i,j):
    tmp=[p[i][k] for k in range(M)]
    tmp[j]=p[i][j]+1
    for k in range(M-1,-1,-1):
        if tmp[k] > p[i+x[j]][k] :
            p[i+x[j]]=[tmp[k] for k in range(M)]

N,M=map(int,input().split())
x=[0,2,5,5,4,5,6,3,7,6]
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(M):
    for j in range(M):
        if x[a[j]]==x[a[i]]: tmp=j
    b.append(a[tmp]) 

a=list(set(b))
a.sort()
M=len(a)
x=[ x[a[i]] for i in range(M) ]


p=[-100 for i in range(N+10)]
p[0]=0
for i in range(N):
    if p[i]>-1:
        for j in range(M):
            p[i+x[j]]=max(p[i+x[j]],p[i]+1)

ans=""
while N>0:
    for j in range(M-1,-1,-1):
        if p[N]==p[N-x[j]]+1:
            ans+=str(a[j])
            N-=x[j]
            break
print(ans)




Fixed submission:
N,K=map(int,input().split())
print(N+K if K%N==0 else K-N)
Buggy python submission (verdict: Runtime Error):
import math

N=int(input())
HP=list(map(int,input().split()))
 
tmp=HP[0]
 
for i in range(0,N):
    tmp=math.gcd(tmp,HP[i])
    
print(tmp)

Fixed submission:
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    gcd=a
    return gcd

    
N=int(input())
HP=list(map(int,input().split()))

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    tmp=egcd(tmp,HP[i+1])
    
print(tmp)

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

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    
print(tmp)

Fixed submission:
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    gcd=a
    return gcd

    
N=int(input())
HP=list(map(int,input().split()))

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    tmp=egcd(tmp,HP[i+1])
    
print(tmp)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
x=[0,2,5,5,4,5,6,3,7,6]
a=list(map(int,input().split()))
a.sort()
x=[ x[a[i]] for i in range(M) ]

p=[[-1 for j in range(M)] for i in range(N+10)]
p[0]=[0 for j in range(M)]

for i in range(N+1):
    for j in range(M):
        if p[i][0]>-1 and sum(p[i])+1>sum(p[i+x[j]]):
            p[i+x[j]]=[p[i][k] for k in range(M)]
            p[i+x[j]][j]+=1

        elif p[i][0]>-1 and sum(p[i])+1==sum(p[i+x[j]]):
            tmp=[p[i][k] for k in range(M)]
            tmp[j]+=1
            for k in range(M-1,-1,-1) and tmp!=p[i+x[j]]:
                if tmp[k] > p[i+x[j]][k] :
                    p[i+x[j]]=[tmp[k] for k in range(M)]
                    break


for i in range(M-1,-1,-1):
    for j in range(p[N][i]):
        print(a[i],end="")

Fixed submission:
import sys

def chk(i,j):
    tmp=[p[i][k] for k in range(M)]
    tmp[j]=p[i][j]+1
    for k in range(M-1,-1,-1):
        if tmp[k] > p[i+x[j]][k] :
            p[i+x[j]]=[tmp[k] for k in range(M)]

N,M=map(int,input().split())
x=[0,2,5,5,4,5,6,3,7,6]
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(M):
    for j in range(M):
        if x[a[j]]==x[a[i]]: tmp=j
    b.append(a[tmp]) 

a=list(set(b))
a.sort()
M=len(a)
x=[ x[a[i]] for i in range(M) ]

p=[-100 for i in range(N+10)]
p[0]=0
for i in range(N):
    if p[i]>-1:
        for j in range(M):
            p[i+x[j]]=max(p[i+x[j]],p[i]+1)

ans=""
while N>0:
    for j in range(M-1,-1,-1):
        if p[N]==p[N-x[j]]+1:
            ans+=str(a[j])
            N-=x[j]
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappop
from heapq import heappush
from heapq import heappushpop


FIN=10**10
N,K=map(int,input().split())

a=[list(map(int,input().split()))[::-1] for i in range(N) ]
a.sort(reverse=True)

l=[]
dic1={}
dic2={}

for i in range(K):
    p=a[i][1]
    if p in dic1:
        if a[i][0]>dic2[p]:
            heappush(l,dic2[p])
            dic2[p]=a[i][0]
        else: heappush(l,a[i][0])

    else: 
        dic1[p]=1
        dic2[p]=a[i][0]


s=sum(l)+sum(dic2.values())
x=len(dic1)
ans=s+x**2

for i in range(K,N):
    if not a[i][1] in dic1:
        dic1[a[i][1]]=1
        s+=a[i][0]-heappop(l)
        x+=1
        ans=max(ans,s+x**2) 

    if l==[]: break

print(ans)
        

Fixed submission:
from heapq import heappop
from heapq import heappush
from heapq import heappushpop

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

a=[list(map(int,input().split()))[::-1] for i in range(N) ]
a.sort(reverse=True)

l=[]
dic1={}
dic2={}

for i in range(K):
    [d,t]=a[i]
    if t in dic1:
        if d>dic2[t]:
            heappush(l,dic2[t])
            dic2[t]=d
        else: heappush(l,d)

    else: 
        dic1[t]=1
        dic2[t]=d


s=sum(l)+sum(dic2.values())
x=len(dic1)
ans=s+x**2

for i in range(K,N):
    if l==[]: break
        
    [d,t]=a[i]
    if not t in dic1:
        dic1[t]=1
        s+=d-heappop(l)
        x+=1
        ans=max(ans,s+x**2) 

    

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
ans=0
for i in len(s):
    if s[i]=="2": ans+=1
print(ans)

Fixed submission:
s=input()
ans=0
for i in range(len(s)):
    if s[i]=="2": ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
def f(level,x):
    if level==0: return x

    if x in [1,0]:
        return 0
    elif x==b[level][0]:
        return b[level][1]
    elif 2<=x<b[level-1][0]+2:
        return f(level-1,x-1)
    elif x==b[level-1][0]+2:
        return b[level-1][1]+1
    elif b[level-1][0]+2<x<b[level][0]:
        return b[level-1][1]+1+f( level-1, x-(b[level-1][0]+2))

N,X=map(int,input().split())
b=[[1,1] for i in range(N+1)]
for i in range(1,N+1):
    b[i][0]=b[i-1][0]*2+3
    b[i][1]=b[i-1][1]*2+1

print(f(N,X))

Fixed submission:
n=int(input())

dic={22:"Christmas Eve Eve Eve",23:"Christmas Eve Eve",24:"Christmas Eve",25:"Christmas"}

print(dic[n])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[False]*(n+1)
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    x[p].sort()
    for j in range(len(x[p])):
        ans[x[p][j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(n+1):
    print(ans[i])

Fixed submission:
N,M=map(int,input().split())
a=[[i]+list(map(int,input().split())) for i in range(M)]
a.sort(key=lambda x:(x[1],x[2]))

j=0
for i in range(M):
    if j!=a[i][1]:
        j=a[i][1]
        k=1
    s=format(a[i][1],'0>6') + format(k,'0>6')
    a[i].append(s)
    k+=1

a.sort()
for i in range(M):
    print(a[i][3])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[False]*(n+1)
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    x[p].sort()
    for j in range(len(x[p])):
        ans[x[p][j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(n+1):
    print(ans[i])

Fixed submission:
N,M=map(int,input().split())
a=[[i]+list(map(int,input().split())) for i in range(M)]
a.sort(key=lambda x:(x[1],x[2]))

j=0
for i in range(M):
    if j!=a[i][1]:
        j=a[i][1]
        k=1
    s=format(a[i][1],'0>6') + format(k,'0>6')
    a[i].append(s)
    k+=1

a.sort()
for i in range(M):
    print(a[i][3])
Buggy python submission (verdict: Time Limit Exceeded):
import math

N,M=map(int,input().split())
dic={}
for i in range(2,int(M**0.5)+1):
    if M%i==0:
        dic.setdefault(i,1)
        M//=i
        while M%i==0:
            dic[i]+=1
            M//=i
    if M==1: break

if M!=1: dic[M]=1


ans=1
for k in dic.keys():
    x=(dic[k]+N-1)
    ans*=math.factorial(dic[k]+N-1)//(math.factorial(dic[k])*math.factorial(N-1))

print(ans%1000000007)

Fixed submission:
import math

N,M=map(int,input().split())
dic={}
for i in range(2,int(M**0.5)+1):
    if M%i==0:
        dic.setdefault(i,1)
        M//=i
        while M%i==0:
            dic[i]+=1
            M//=i
    if M==1: break

if M!=1: dic[M]=1


ans=1
for k in dic.keys():
    x=dic[k]
    tmp=1
    for i in range (N,x+N):
        tmp*=i
    ans*=tmp//math.factorial(x)
    ans%=1000000007
print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
N=int(input())
print("No" if N in [1,2,3,5,6,9,10,13,17] else "Yes")

Fixed submission:
N,K=map(int,input().split())
print(0 if N%K==0 else 1)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()

a=[1,0,0,0]

for i in range(len(s)):
    c=s[i]
    if c=="A":
        a[1]+=a[0]
    elif c=="B":
        a[2]+=a[1]
    elif c=="C":
        a[3]+=a[2]
    elif c=="?":
        tmp=[a[i] for i in range(4)]
        a[0]=tmp[0]*3
        for j in range(3):
            a[j+1]=tmp[j+1]*3+tmp[j]

print(a[3]%1000000007)

Fixed submission:
s=input()

a=[1,0,0,0]

for i in range(len(s)):
    c=s[i]
    if c=="A":
        a[1]+=a[0]
    elif c=="B":
        a[2]+=a[1]
    elif c=="C":
        a[3]+=a[2]
    elif c=="?":
        tmp=[a[i] for i in range(4)]
        a[0]=tmp[0]*3
        for j in range(3):
            a[j+1]=tmp[j+1]*3+tmp[j]

    a=[a[i]%1000000007 for i in range(4)]

print(a[3])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate as acc
from bisect import bisect_left as bl

def ans(n):
    tmp=0
    for i in range(N):
        tmp+=abs(a[i]-a[n-1])
    return tmp


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

ans=10**18
p=0
q=2
for j in range(1,N-2):
    q=min(q,j+1)
    while p<j-1 and abs(a[j]-a[p]*2)>abs(a[j]-a[p+1]*2):
        p+=1
    while q<N-2 and abs(a[j]+a[N-1]-a[q]*2)>abs(a[j]+a[N-1]-a[q+1]*2):
        q+=1

    P,Q,R,S=a[p], a[j]-a[p], a[q]-a[j], a[N-1]-a[q]
    ans=min(ans, max(P,Q,R,S)-min(P,Q,R,S))

print(ans)

Fixed submission:
from itertools import accumulate as acc
from bisect import bisect_left as bl

def ans(n):
    tmp=0
    for i in range(N):
        tmp+=abs(a[i]-a[n-1])
    return tmp


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

ans=10**18
for j in range(1,N-2):
    x=a[j]/2
    p=bl(a,x)
    if p==j: p-=1
    elif p>0 and x-a[p-1]<a[p]-x: p-=1

    y=(a[j]+a[N-1])/2

    q=bl(a,y)
    if q==N-1: q-=1
    elif q>j+1 and y-a[q-1]<a[q]-y: q-=1

    P,Q,R,S=a[p], a[j]-a[p], a[q]-a[j], a[N-1]-a[q]
    ans=min(ans, max(P,Q,R,S)-min(P,Q,R,S))

print(ans)
Buggy python submission (verdict: Runtime Error):
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

sunuke=[]
for i in range(100):
    for j in range(2,11):
        sunuke.append(j*(10**i)-1)
L=len(sunuke)
tmp1,tmp2=sunuke[L-1],f(sunuke[L-1])
ans=[sunuke[L-1]]
for i in range(len(sunuke)-2,-1,-1):
    x=sunuke[i]
    if x*tmp2<=tmp1*f(x):
        ans.append(x)
        tmp1,tmp2=x,f(x)

ans.sort()

    

for i in range(int(input())):
    print(ans[i])


Fixed submission:
s=input()
ans=0
for i in range(4):
    if s[i]=="+": ans+=1
    else: ans-=1

print(ans)
Buggy python submission (verdict: Runtime Error):
N,C=map(int,input().split())

D=[list(map(int,input().split())) for i in range(C)]
grid=[list(map(int,input().split())) for i in range(N)]

a=[[0]*C for i in range(3)]


for i in range(N):
    tmp=i%3
    for j in range(N):
        a[tmp][grid[i][j]-1]+=1
        tmp=(tmp+1)%3

b=[[0]*C for i in range(3)]
for i in range(3):
    for j in range(C):
        b[i][j]=sum([ D[k][j] * a[i][k] for k in range(C)])

b=[ sorted([ [b[i][j],j] for j in range(C)]) for i in range(3)]

ans=1000000000
for i in range(3):
    for j in range(3):
        for k in range(3):
            if b[0][i][1]!=b[1][j][1] and b[1][j][1]!=b[2][k][1] and b[2][k][1]!=b[0][i][1]:
                ans=min(ans,b[0][i][0]+b[1][j][0]+b[2][k][0])

print(ans)

Fixed submission:
n=int(input())
print("ABC" if n<1000 else "ABD")
Buggy python submission (verdict: Runtime Error):
a=[0]
tmp=0
for i in range(1,101):
    tmp+=i
    a.append(tmp)

A,B=map(int,input().split())
print(a[B-A]-B)

Fixed submission:
from itertools import accumulate as acc
a=[i for i in range(1000)]
a=list(acc(a))

A,B=map(int,input().split())
print(a[B-A]-B)
Buggy python submission (verdict: Runtime Error):
X=int(input())
l=[2,3,5,7,11,13,17,19,23,29,31,37]
ans=[]
for i in l:
    tmp=i**2
    while tmp<=X:
        ans.append(tmp)
        tmp*=i

print(max(ans))

Fixed submission:
X=int(input())
l=[i for i in range(2,32)]
ans=[1]
for i in l:
    tmp=i**2
    while tmp<=X:
        ans.append(tmp)
        tmp*=i

print(max(ans))
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split());print(len(bin(y//x))-2)

Fixed submission:
import math
def f(s):
    if len(s)%2==0: p=len(s)//2-1
    else: p=len(s)//2
    
    q=p
    while  q<len(s) and s[p]==s[q]:
        q+=1
    return q



s=input()

print(min(f(s),f(s[::-1])))
Buggy python submission (verdict: Runtime Error):
import math
print(math.ceil(a/2+b/2))

Fixed submission:
import math
a,b=map(int,input().split())
print(math.ceil(a/2+b/2))