Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03014 (python)

Fixed submission:
h,w=map(int,input().split())
ans=[[-3]*w for _ in range(h)]
s=[input() for _ in range(h)]
for i in range(h):
    tmp=0
    for j in range(w):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp
    tmp=0
    for j in range(w-1,-1,-1):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp

for j in range(w):
    tmp=0
    for i in range(h):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp
    tmp=0
    for i in range(h-1,-1,-1):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp

print(max( max(ans[i]) for i in range(h) ))

Buggy submission (verdict: Runtime Error):
def chkp(i,j):
	tmp=j+1
	count=1
	while tmp<W and s[i][tmp]==".":
		count+=1
		tmp+=1
	return count

def chkv(i,j):
	tmp=i+1
	count=1
	while tmp<H and s[tmp][j]==".":
		count+=1
		tmp+=1
	return count

H,W=map(int,input().split())
s=[input() for i in range(H)]

p=[[0 for j in range(W)] for i in range(H)]
v=[[0 for j in range(W)] for i in range(H)]

for i in range(H):
	if W==1:
		if s[i][j]==".": p[i][0]=1
	else:
		if s[i][0]==".": p[i][0]=chkp(i,0)
		for j in range(1,W):
			if s[i][j]==".":
				if s[i][j-1]==".": p[i][j]=p[i][j-1]
				else: p[i][j]=chkp(i,j)

for j in range(W):
	if H==1:
		if s[i][j]==".": v[0][j]=1
	else:
		if s[0][j]==".": v[0][j]=chkv(0,j)
		for i in range(1,H):
			if s[i][j]==".":
				if s[i-1][j]==".": v[i][j]=v[i-1][j]
				else: v[i][j]=chkv(i,j)

print(max( max(v[i][j]+p[i][j] for j in range(W)) for i in range(H)  ))

Buggy submission (verdict: Runtime Error):
def chkp(i,j):
	tmp=j+1
	count=1
	while tmp<W and s[i][tmp]==".":
		count+=1
		tmp+=1
	return count

def chkv(i,j):
	tmp=i+1
	count=1
	while tmp<H and s[tmp][j]==".":
		count+=1
		tmp+=1
	return count

H,W=map(int,input().split())
s=[input() for i in range(H)]

p=[[0 for j in range(W)] for i in range(H)]
v=[[0 for j in range(W)] for i in range(H)]

for i in range(H):
	if W==1:
		if s[i][j]==".": p[i][0]=1
	else:
		if s[i][0]==".": p[i][0]=chkp(i,0)
		for j in range(1,W):
			if s[i][j]==".":
				if s[i][j-1]==".": p[i][j]=p[i][j-1]
				else: p[i][j]=chkp(i,j)

for j in range(W):
	if H==1:
		if s[i][j]==".": v[0][j]=1
	else:
		if s[0][j]==".": v[0][j]=chkv(0,j)
		for i in range(1,H):
			if s[i][j]==".":
				if s[i-1][j]==".": v[i][j]=v[i-1][j]
				else: v[i][j]=chkv(i,j)
					
print(max( max(v[i][j]+p[i][j] for j in range(W)) for i in range(H)  )-1)
Problem p03029 (python)

Fixed submission:
import sys

A,P=map(int,input().split())
print((A*3+P)//2)

Buggy 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)
Problem p03035 (python)

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

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

Buggy 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)

Buggy 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)
Problem p03050 (python)

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 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)
Problem p03059 (python)

Fixed submission:
A,B,T=map(int,input().split())
ans=(T+0.5)//A
ans*=B
print(int(ans))

Buggy 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)
Problem p03070 (python)

Fixed submission:
n=int(input())
a=[int(input()) for _ in range(n)]
mod=998244353
s=sum(a)

dp=[[0]*(s+1) for _ in range(n)]
dp[0][0],dp[0][a[0]]=2,1
for i in range(n-1):
    for j in range(s+1):
        dp[i+1][j]=(dp[i+1][j]+dp[i][j]*2)%mod
        if j+a[i+1]<=s: dp[i+1][j+a[i+1]]=(dp[i+1][j+a[i+1]]+dp[i][j])%mod

dp2=[[0]*(s+1) for _ in range(n)]
dp2[0][0]=1;dp2[0][a[0]]=1
for i in range(n-1):
    for j in range(s+1):
        dp2[i+1][j]=(dp2[i+1][j]+dp2[i][j])%mod
        if j+a[i+1]<=s: dp2[i+1][j+a[i+1]]=(dp2[i+1][j+a[i+1]]+dp2[i][j])%mod

if s%2==0:
    inable=( sum(dp[n-1][s//2:]) - dp2[n-1][s//2] )*3%mod
else:
    inable=( sum(dp[n-1][s//2+1:]) )*3 %mod

ans=1
for _ in range(n):
    ans=ans*3%mod
ans=(ans-inable)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import numpy as np


MOD=998244353
N=int(input())
a=[int(input()) for i in range(N)]
a.sort(reverse=True)

A=sum(a)
M=math.ceil(A/2)  
x =[ [0 for j in range(M+1)] for i in range(N)]
x[0][0]=2
x[0][min(a[0],M)]=1

p=M-A+a[0]
q=a[0]
for i in range(1,N):
    p+=a[i]
    q+=a[i]
    for j in range(max(p,0),min(q,M)+1):
        if j==M:
            x[i][j]=sum(x[i-1][ max(M-a[i],0): M ])+x[i-1][M]*3

        elif j-a[i]<0: x[i][j]=x[i-1][j]*2
        else: x[i][j]=x[i-1][j]*2+x[i-1][j-a[i]]

        x[i][j]%=MOD

if sum(a)%2==0:
    y =[ [0 for j in range(M+1)] for i in range(N)]
    y[0][0]=1
    p=M-A+a[0]
    q=a[0]
    for i in range(1,N):
        p+=a[i]
        q+=a[i]
        for j in range(max(p,0),min(q,M)+1):
            if j-a[i]<0: y[i][j]=y[i-1][j]
            else: y[i][j]=y[i-1][j]+y[i-1][j-a[i]]

            y[i][j]%=MOD

    ans=3**N-x[N-1][M]*3+y[N-1][M]*6



else: ans=3**N-x[N-1][M]*3
print(ans%MOD)
Problem p03081 (python)

Fixed submission:
N,Q=map(int,input().split())
s="0"+input()+"0"
queri=[list(input().split()) for i in range(Q)]

L,R=0,N+1
for i in range(Q-1,-1,-1):
    t,d=queri[i]
    if t==s[L] and d=="R":
        L-=1
    elif t==s[L+1] and d=="L":
        L+=1
    if t==s[R] and d=="L":
        R+=1
    elif t==s[R-1] and d=="R":
        R-=1

print(R-L-1)

Buggy submission (verdict: Runtime Error):
def simulate(n):
    p=n
    if memo[n]!=-1: return memo[n]
    if n==-1: return 0
    if n==N: return 2
    
    for i in range(Q):
        if TD[i][0]==s[n]:
            if TD[i][1]=="R": n+=1
            if TD[i][1]=="L": n-=1

        if n<0 :
            memo[p]=0
            return 0
        elif n>=N:
            memo[p]=2
            return 2 
    memo[p]=1
    return 1

N, Q = map(int, input().split())
s = input()
TD = [input().split() for i in range(Q)]
memo=[-1]*N


low = 0
high =N-1
# t は中央番目の数
t =int((low+high)/2) 

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかったということ
while (1):
    if simulate(t) in [0,1] and simulate(t+1)==2:
        break
    elif simulate(t) in [0,1]:
        low = t+1
    elif simulate(t)==2:
        high = t-1
    t = int((low + high) / 2)


R=t

low = 0
high =N-1
# t は中央番目の数
t =int((low+high)/2) 

while (1):
    if simulate(t-1)==0 and simulate(t) in [1,2]:
        break
    elif simulate(t)==0:
        low = t+1
    elif simulate(t) in [1,2]:
        high = t-1
    t = int((low + high) / 2)

L=t

print(R-L+1)
print(memo)
Problem p03087 (python)

Fixed submission:

[N,Q] = list(map(int,input().split()))
locate= [-1]*N

str=input()
s = list(str)

num_a=[0]*N
tmp=0

for i in range(1,N):
    if s[i-1]=='A' and s[i]=='C':
        tmp+=1
    num_a[i]=tmp
        

for i in range(Q):
    a = list(map(int, input().split()))
    L=a[0]-1
    R=a[1]-1
    print(num_a[R]-num_a[L])

Buggy submission (verdict: Runtime Error):

[N,Q] = list(map(int,input().split()))
locate= [-1]*N

str=input()
s = list(str)

k=1
locate=[-1]*N

for i in range (N):
    if s[i]=='A' and s[i+1]=='C':
        locate[k]=i
        k+=1

locate[k]=100000000

numL=1
numR=k-1

for i in range(Q):
    a = list(map(int, input().split()))
    L=a[0]-1
    R=a[1]-1

    for j in range(1,k):
        if L>locate[j-1] and L<=locate[j]:
            numL=j
            break
 


    for j in range(1,k):
        if R>locate[j] and R<=locate[j+1]:
            numR=j
            break
    
    
    print(numR-numL+1)

Buggy submission (verdict: Runtime Error):

[N,Q] = list(map(int,input().split()))
locate= [-1]*N

str=input()
s = list(str)

k=1
locate=[-1]*N

for i in range (N):
    if s[i]=='A' and s[i+1]=='C':
        locate[k]=i
        k+=1

locate[k]=100000000

numL=1
numR=k-1

for i in range(Q):
    a = list(map(int, input().split()))
    L=a[0]-1
    R=a[1]-1

    for j in range(1,k):
        if L>locate[j-1] and L<=locate[j]:
            numL=j
            break
 


    for j in range(1,k):
        if R>locate[j] and R<=locate[j+1]:
            numR=j
            break
    
    
    print(numL,numR,numR-numL+1)

Buggy submission (verdict: Runtime Error):

[N,Q] = list(map(int,input().split()))
locate= [-1]*N

str=input()
s = list(str)

k=0
for i in range (N):
    if s[i]=='A' and s[i+1]=='C':
        locate[k]=i
        k+=1

k-=1

for j in range(Q):
    i = list(map(int, input().split()))
    L=i[0]-1
    R=i[1]-1

    low = 0
    high = k
    # t は中央番目の数
    t = int((low + high) / 2) 
    
    while (low<=high):
        if (L>locate[t-1] and L<=locate[t]):
            break
        elif (L > locate[t]):
            low = t+1
        elif (L < locate[t]):
            high = t-1
        t = int((low + high) / 2)
    
 
    numL=t
    
    
    low = 0
    high = k
    # t は中央番目の数
    t = int((low + high) / 2) 
    
    while (low<=high):
        if (R>=locate[t-1]+1 and R<locate[t]+1):
            break
        elif (R > locate[t-1]+1):
            low = t+1
        elif (R < locate[t-1]+1):
            high = t-1
        t = int((low + high) / 2)
    
    numR=t
    
    
    print(numR-numL+1)
Problem p03125 (python)

Fixed submission:
N,K=map(int,input().split())
print(N+K if K%N==0 else K-N)

Buggy 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)
Problem p03128 (python)

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 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="")
Problem p03148 (python)

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 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)
Problem p03192 (python)

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

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

Fixed submission:
n=int(input())

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

print(dic[n])

Buggy 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))
Problem p03284 (python)

Fixed submission:
N,K=map(int,input().split())
print(0 if N%K==0 else 1)

Buggy submission (verdict: Runtime Error):
N=int(input())
print("No" if N in [1,2,3,5,6,9,10,13,17] else "Yes")
Problem p03318 (python)

Fixed submission:
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

sunuke=[]
for i in range(16):
    for j in range(1,500):
        sunuke.append(j*(10**i)-1)

sunuke=list(set(sunuke))
sunuke.sort()
sunuke.pop(0)
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])

Buggy submission (verdict: Runtime Error):
sunuke=[]
for i in range(30):
    for j in range(2,11):
        sunuke.append(j*(10**i)-1)

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

Buggy submission (verdict: Runtime Error):
sunuke=[]
for i in range(20):
    for j in range(2,11):
        sunuke.append(j*10**i-1)

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

Buggy submission (verdict: Runtime Error):
sunuke=[]
for i in range(20):
    for j in range(2,11):
        sunuke.append(j*10**i+-1)

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

Buggy submission (verdict: Runtime Error):
sunuke=[]
for i in range(17):
    for j in range(2,11):
        sunuke.append(j*10**i+-1)

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

Buggy submission (verdict: Runtime Error):
sunuke=[]
for i in range(17):
    for j in range(1,10):
        sunuke.append(j*10**i+(10**i-1))

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

Buggy submission (verdict: Runtime Error):

sunuke=[]
for i in range(17):
    for j in range(1,10):
        sunuke.append(j*10**i+(10**i-1))

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

Buggy submission (verdict: Runtime Error):

sunuke=[]
for i in range(16):
    for j in range(1,10):
        sunuke.append(j*10**i+(10**i-1))

for i in range(int(input())):
    print(sunuke[i])
Problem p03328 (python)

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 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)
Problem p03352 (python)

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 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))
Problem p03480 (python)

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 submission (verdict: Runtime Error):
x,y=map(int,input().split());print(len(bin(y//x))-2)
Problem p03485 (python)

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

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil(a/2+b/2))
Problem p03488 (python)

Fixed submission:
def f(s):
    return abs(int(s))

def cul(x,X):
    dic={0:1}
    for i in range(len(x)):
        tmp={}
        for j in dic:
            tmp[j+x[i]]=1
            tmp[j-x[i]]=1
        dic=tmp
    if X in dic: return True
    else: return False

s=input()
X,Y=map(int,input().split())
x,y=[],[]
d,tmp=0,0
for i in range(len(s)):
    if s[i]=="T":
        if tmp!=0:
            if d==0: x.append(tmp)
            else: y.append(tmp)
        d^=1
        tmp=0
        
    else: tmp+=1
if tmp!=0:
    if d==0: x.append(tmp)
    else: y.append(tmp)


if s[0]=="F": X=abs(X-x.pop(0))
Y=abs(Y)


print("Yes" if cul(x,X) and cul(y,Y) else "No")

Buggy submission (verdict: Runtime Error):
def cul(x,X):
    dic={0:1}
    for i in range(len(x)):
        tmp={}
        for j in dic:
            tmp[j+x[i]]=1
            tmp[j-x[i]]=1
        dic=tmp
    if X in dic: return True
    else: return False

s=list(input().split("T"))
X,Y=map(int,input().split())
x,y=[len(i) for i in s[::2]],[len(i) for i in s[1::2]]
if s[0][0]=="F": X=abs(X-x.pop(0))
Y=abs(Y)

x.sort(reverse=True)
y.sort(reverse=True)

print("Yes" if cul(x,X) and cul(y,Y) else "No")
Problem p03493 (python)

Fixed submission:
s=input()
print(sum( int(s[i]) for i in range(3) ))

Buggy submission (verdict: Runtime Error):
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

N=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]) for i in range(N)]
l=b.index(max(b))

if a[l]==0: print(0),sys.exit()
elif a[l]>0:
	print(N*2)
	for i in range(2):
		print(l+1,1)
	for i in range(1,N):
		for j in range(2):
			print(i,i+1)

else:
	print(N*2)
	for i in range(2):
		print(l+1,N)
	for i in range(N,1,-1):
		for j in range(2):
			print(i,i-1)
Problem p03657 (python)

Fixed submission:
a,b=map(int,input().split())
print("Possible" if a*b*(a+b)%3==0 else "Impossible")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

def cur(p):
    for x in neighbor[p]:
        if x==par[p]: continue
        else:
            par[x]=p
            descend[p]+=cur(x)
    neighbor[p].remove(par[p])
    return descend[p]

n=int(input())
neighbor=[[]  for _ in range(n+1)]
descend=[1]*(n+1)
par=[0]*(n+1)

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


x=[descend[n]-1]
t=n
while t!=1:
    t,pret=par[t],t
    x.append(descend[t]-descend[pret]-1)

l=len(x)
p,q=sum(x[:l//2]),sum(x[l//2:])
if l%2==0: print("Fennec" if p<q else "Snuke")
else: print("Fennec" if p<=q else "Snuke")
Problem p02783 (python)

Fixed submission:
h, a = map(int, input().split())
print((h+a-1)//a)

Buggy submission (verdict: Runtime Error):
h, a = map(int, input().split())
  print((h+a-1)//a)

Buggy submission (verdict: Runtime Error):
h, a = map(int, input().split())
  print(h//a + h%a != 0)
Problem p02797 (python)

Fixed submission:
n, k, s = map(int, input().split())
if s == 10**9:
    ans = [s]*k + [s-1]*(n-k)
else:
    ans = [s]*k + [s+1]*(n-k)
print(*ans)

Buggy submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
if s = 10**9:
    ans = [s]*k + [s-1]*(n-k)
else:
    ans = [s]*k + [s+1]*(n-k)
print(*ans)

Buggy submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
print(*[s]*k, *[s+1]*(n-k))
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
cap = 0
count = 0
if b == 1:
    print(count)
else:
    while cap < b:
        cap += a
        if cap < b:
            cap -= 1
        count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
cap = 0
count = 0
if b = 1:
    print(count)
else:
    while cap < b:
        cap += a
        if cap < b:
            cap -= 1
        count += 1
    print(count)