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

Fixed submission:
N=int(input())
S=list(input())
K=int(input())
w=S[K-1]
ans=""
for i in range(N):
    if S[i]==w:
        ans+=w
    else:
        ans+="*"
print(ans)

Buggy submission (verdict: Runtime Error):
9
education
7
Problem p03163 (python)

Fixed submission:
#DP D
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    w,v=wv[i]
    for j in range(W+1):
        if j<w:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
#DP D
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    w,v=wv[i]
    for j in range(W+1):
        if j<w:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-w]+v)
for i in range(n+1):
print(dp[-1][-1])
Problem p03173 (python)

Fixed submission:
import itertools
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
a.append(0)
dp=[[0]*n for i in range(n)]
for l in range(1,n):
    for right in range(l,n):
        left=right-l
        num=inf
        for mid in range(left,right):
            num=min(num,dp[left][mid]+dp[mid+1][right])
        dp[left][right]=num+a[right]-a[left-1]
print(dp[0][n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
dp=[0]*(k+1)
for i in range(a[0]+1):
    dp[i]=1
for i in range(1,n):
    u=a[i]
    h=dp[:]
    for j in range(u+1,k+1):
        h[j]=(dp[j]-dp[j-u-1])%mod
    for j in range(1,k+1):
        h[j]=(h[j]+h[j-1])%mod
    dp=h
print(dp[k])
Problem p03213 (python)

Fixed submission:
import sys
n=int(input())
data=[0]*(n+1)
for i in range(2,n+1):
    for j in range(2,int(i**(1/2))+1):
        if i%j==0:
            break
    else:
        count=0
        for j in range(i,n+1):
            k=j
            while k%i==0:
                k//=i
                data[i]+=1
if n==1:
    print(0)
    sys.exit()
if data[2]>=74:
    ans=1
else:
    ans=0
count3=0
count5=0
count15=0
count25=0
for i in range(n+1):
    if data[i]>=2:
        count3+=1
for i in range(n+1):
    if data[i]>=4:
        count5+=1
for i in range(n+1):
    if data[i]>=14:
        count15+=1
for i in range(n+1):
    if data[i]>=24:
        count25+=1
ans+=count25*(count3-1)
ans+=count15*(count5-1)
ans+=(count3-2)*count5*(count5-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
data=[0]*(n+1)
for i in range(2,n+1):
    for j in range(2,int(i**(1/2))+1):
        if i%j==0:
            break
    else:
        count=0
        for j in range(i,n+1):
            k=j
            while k%i==0:
                k//=i
                data[i]+=1
if data[2]>=74:
    ans=1
else:
    ans=0
count3=0
count5=0
count15=0
count25=0
for i in range(n+1):
    if data[i]>=2:
        count3+=1
for i in range(n+1):
    if data[i]>=4:
        count5+=1
for i in range(n+1):
    if data[i]>=14:
        count15+=1
for i in range(n+1):
    if data[i]>=24:
        count25+=1
ans+=count25*(count3-1)
ans+=count15*(count5-1)
ans+=(count3-2)*count5*(count5-1)//2
print(ans)
Problem p03231 (python)

Fixed submission:
import sys
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)

N,M=map(int,input().split())
S=input()
T=input()
L=N*M//gcd(N,M)
n=L//N
m=L//M
l=n*m//gcd(n,m)
i=l//n
j=l//m
for k in range(N//i):
    if S[i*k]==T[j*k]:
        continue
    else:
        print(-1)
        sys.exit()
print(L)

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)

N,M=map(int,input().split())
S=input()
T=input()
L=N*M//gcd(N,M)
n=L//N
m=L//M
l=n*m//gcd(n,m)
i=l//n
j=l//m
for k in range(N//i):
    if S[i*k]==T[j*k]:
        continue
    else:
        print(-1)
        sys.exit()
print(L)
Problem p03274 (python)

Fixed submission:
import sys
n,k=map(int,input().split())
x=list(map(int,input().split()))
left=[]
right=[]
origin=0
for u in x:
    if u<0:
        left.append(abs(u))
    elif u==0:
        origin+=1
    else:
        right.append(u)
left.sort()
k-=origin
if k==0:
    print(0)
    sys.exit()
r=len(right)
l=len(left)
ans=float("inf")
if k<=r:
    ans=right[k-1]
if k<=l:
    ans=min(ans,left[k-1])
for i in range(k-1):
    if i<r and k-i-2<l:
        y=right[i]+left[k-i-2]+min(right[i],left[k-i-2])
        ans=min(ans,y)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
n,k=map(int,input().split())
x=list(map(int,input().split()))
left=[]
right=[]
origin=0
for u in x:
    if u<0:
        left.append(abs(u))
    elif u==0:
        origin+=1
    else:
        right.append(u)
left.sort()
ans=float("inf")
k-=origin
if k==0:
    print(0)
    sys.exit()
r=len(right)
l=len(left)
for i in range(k):
    if i<r and k-i-2<l:
        y=right[i]+left[k-i-2]+min(right[i],left[k-i-2])
        ans=min(ans,y)
print(ans)
Problem p03388 (python)

Fixed submission:
import math
Q = int(input())
ans = []

for i in range(Q):
    a,b = map(int,input().split())
    if a>b:
        a,b = b,a
    if a == b:
        ans.append((a-1)*2)
        continue
    c = math.ceil((a*b)**0.5-1)
    
    ans.append(c*2-1)
    if a <= c:
        ans[-1] -= 1
    if c*(c+1) < a*b and a != c+1 != b:
        ans[-1] +=1
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
Q=int(input())
ab=[list(map(int,input().split())) for _ in range(Q)]

for a,b in ab:
    
    if a>b:
        a,b=b,a
    if a==b:
        print(2*(a-1))
        continue
        
    c = math.ceil((a*b)**0.5-1)
    
    if c*(c+1)>=a*b:
        print(2*(c-1))
    else:
        print(2*c-1)
Problem p03599 (python)

Fixed submission:
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
if not data:
    data=[0]
data.sort()
ans=-1
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    if m==0:
        continue
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
    else:
        m=bisect(data,f-k)
        o=data[m-1]
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
data.sort()
ans=0
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)
Problem p03633 (python)

Fixed submission:
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    if y==1:
        return 1
    else:
        return gcd(y,x%y)
n=int(input())
t=int(input())
lcm=t
a=t
for i in range(n-1):
    t=int(input())
    a=gcd(lcm,t)
    lcm=lcm*t//a
print(lcm)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
t=int(input())
lcm=t
a=t
for i in range(n-1):
    t=int(input())
    a=math.gcd(lcm,t)
    lcm=lcm*t//a
print(lcm)
Problem p03673 (python)

Fixed submission:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==1:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)
else:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==0:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)

Buggy submission (verdict: Runtime Error):
from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==1:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=y+x
    print(*z)
else:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==0:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=y+x
    print(*z)
Problem p03674 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n=int(input())
a=list(map(int,input().split()))
data=[0]*(n+1)
for i in range(n+1):
    data[a[i]]+=1
for i in range(1,n+1):
    if data[i]==2:
        b=i
        break
l=[]
for i in range(n+1):
    if a[i]==b:
        l.append(i)
c=l[1]-l[0]+1
for k in range(1,n+3-c):
    ans=cmb(n+1,k,mod)-cmb(n+1-c,k-1,mod)
    print(ans%mod)
for k in range(n+3-c,n+2):
    ans=cmb(n+1,k,mod)
    print(ans)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
MAX=10**5

g1=[1,1]
g2=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(pow(num_1,mod-2,mod))
    
def cmb(n,r,MOD):
    return g1[n]*g2[r]*g2[n-r]%MOD

n=int(input())
a=list(map(int,input().split()))
data=[0]*(n+1)
for i in range(n+1):
    data[a[i]]+=1
for i in range(1,n+1):
    if data[i]==2:
        b=i
        break
l=[]
for i in range(n+1):
    if a[i]==b:
        l.append(i)
c=l[1]-l[0]+1
for k in range(1,n+3-c):
    ans=cmb(n+1,k,mod)-cmb(n+1-c,k-1,mod)
    print(ans%mod)
for k in range(n+3-c,n+2):
    ans=cmb(n+1,k,mod)
    print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
n=int(input())
a=list(map(int,input().split()))
data=[0]*(n+1)
for i in range(n+1):
    data[a[i]]+=1
for i in range(1,n+1):
    if data[i]==2:
        b=i
        break
l=[]
for i in range(n+1):
    if a[i]==b:
        l.append(i)
c=l[1]-l[0]+1
for k in range(1,n+3-c):
    ans=cmb(n+1,k,mod)-cmb(n+1-c,k-1,mod)
    print(ans%mod)
for k in range(n+3-c,n+2):
    ans=cmb(n+1,k,mod)
    print(ans)
Problem p03780 (python)

Fixed submission:
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(max(0,k-a[x]),k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
elif fff(low):
    print(low+1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=h[i]|dp[i-u]
        dp=h
    cnt=0
    for i in range(k-a[x],k):
        cnt+=dp[i]
    if cnt==0:
        return True
    else:
        return False

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
else:
    print(low+1)

Buggy submission (verdict: Runtime Error):
import itertools

def fff(x):
    dp=[0]*k
    dp[0]=1
    for u in itertools.chain(a[:x],a[x+1:]):
        h=dp[:]
        for i in range(u,k):
            h[i]=max(h[i],dp[i-u])
        dp=h
    for i in range(k-a[x],k):
        if dp[i]==1:
            return False
            break
    else:
        return True
        

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if fff(mid):    #不必要
        low=mid
    else:
        high=mid

if fff(high):
    print(high+1)
else:
    print(low+1)

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

#必要ないならTrueを返す
def test(i):
    b=itertools.chain(a[:i],a[i+1:])
    dp=[False]*k
    dp[0]=True
    for u in b:
        dp[u:]=np.logical_or(dp[u:],dp[:-u])
    return not any(dp[-a[i]:])
    

low=0
high=n-1
while high-low>1:
    mid=(high+low)//2
    if test(mid):
        low=mid
    else:
        high=mid
    
if test(high):
    print(high+1)
else:
    print(high)

Buggy submission (verdict: Runtime Error):
def f(x):
    global a
    dp=[0]*k
    dp[0]=1
    for i in range(n):
        if i==x:
            continue
        else:
            h=[0]*k
            b=a[i]
            for i in range(k):
                if dp[i]==1:
                    h[i]=1
                    if i+b<k:
                        h[i+b]=1
        dp=h
    for i in range(k-a[x],k):
        if dp[i]==1:
            return True
    else:
        return False
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
low=0
high=n-1
while high>low+1:
    h=(high+low)//2
    if f(h):
        high=h
    else:
        low=h
if f(low):
    print(max(0,low-1)+1)
else:
    if f(high):
        print(low+1)
    else:
        print(high+1)
Problem p03801 (python)

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

num=A[0]
data=[[A[0],0]]

for i in range(1,N):
    if A[i]>num:
        data.append([A[i],i])
        num=A[i]
        
B=sorted(A,reverse=True)
C=[0]*N
C[0]=B[0]
for i in range(1,N):
    C[i]=C[i-1]+B[i]
    
    
ans=[0]*N
cnt=0
kkk=0
for i in range(len(data)-1,0,-1):
    
    zzz=data[i-1][0]
    while kkk<N and B[kkk]>zzz:
        kkk+=1
    num=C[kkk-1]-kkk*zzz
    num-=cnt
    ans[data[i][1]]=num
    cnt+=num

ans[0]=sum(A)-sum(ans)

for u in ans:
    print(u)

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

num=A[0]
data=[[A[0],0]]

for i in range(1,N):
    if A[i]>num:
        data.append([A[i],i])
        num=A[i]
        
B=sorted(A,reverse=True)

ans=[0]*N

kkk=0
for i in range(len(data)-1,0,-1):
    
    zzz=data[i][0]
    while kkk<N and B[kkk]>=zzz:
        kkk+=1
        
    ans[data[i][1]]=(zzz-data[i-1][0])*kkk
    cnt+=1
ans[0]=sum(A)-sum(ans)

for u in ans:
    print(u)
Problem p03854 (python)

Fixed submission:
s=input()
s=s.replace("dream","D")
s=s.replace("erase","E")
s=s.replace("Der","M")
s=s.replace("Er","M")
s=s.replace("D","M")
s=s.replace("E","M")
s=s.replace("M","")
if s:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
s=input()
s=s.replace("dream","D")
s=s.replace("erase","E")
n=len(s)
i=0
while i<n:
    if s[i]=="D":
        if i+2<n:
            if s[i:i+3]=="Der":
                i+=3
            else:
                i+=1
        else:
            i+=1
    elif s[i]=="E":
        if i+1<n:
            if s[i:i+2]=="Er":
                i+=2
            else:
                i+=1
        else:
            i+=1
    else:
        break
else:
    print("YES")
    sys.exit()
print("NO")
Problem p03230 (python)

Fixed submission:
n = int(input())

def isTriangular(n):
    i = 1
    while( (i*(i+1))//2 <= n) :
        if (i*(i+1))//2 == n:
            return True
        i+=1
    return False


def solve(n):
    if not isTriangular(n):
        print("No")
        return
    i = 1
    jump = 2
    ans = [[1],[1]]
    while ans[-1][-1] != n:
        next_ind = list(range(ans[-1][-1]+1, ans[-1][-1]+jump+1))
        for i in range(len(next_ind)):
            ans[i].append(next_ind[i])
        ans.append(next_ind)
        i+=jump
        jump += 1
    print("Yes")
    print(len(ans))
    for x in ans:
        p_str = ""
        p_str += str(len(x))
        for b in x:
            p_str += " " 
            p_str += str(b)
        print(p_str)
solve(n)

Buggy submission (verdict: Runtime Error):
n = int(input())

def isTriangular(n):
    i = 1
    while( (i*(i+1))//2 <= n) :
        if (i*(i+1))//2 == n:
            return True
        i+=1
    return False


def solve(n):
    if not isTriangular(n):
        print("No")
        return
    i = 1
    jump = 2
    ans = [[1],[1]]
    while ans[-1][-1] != n:
        next_ind = range(ans[-1][-1]+1, ans[-1][-1]+jump+1)
        for i in range(len(next_ind)):
            ans[i].append(next_ind[i])
        ans.append(next_ind)
        i+=jump
        jump += 1
    print("Yes")
    print(len(ans))
    for x in ans:
        p_str = ""
        p_str += str(len(x))
        for b in x:
            p_str += " " 
            p_str += str(b)
        print(p_str)

        

        

solve(n)
Problem p03238 (python)

Fixed submission:
n = int(input())
 
if n == 1:
  print("Hello World")
elif n == 2:
  a = int(input())
  b = int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(raw_input())

if n == 1:
  print("Hello World")
elif n == 2:
  a = int(raw_input())
  b = int(raw_input())
  print(a+b)
Problem p03438 (python)

Fixed submission:
n = input()
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]

negatives = 0
positives = 0

for aa, bb in zip(a,b):
    if aa - bb < 0:
        negatives += (bb-aa)//2*2
    else:
        positives += aa-bb

if negatives >= 2*positives:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
a = [long(x) for x in input().split(" ")]
b = [long(x) for x in input().split(" ")]

if sum(a) <= sum(b):
    print("Yes")
else:
    print("No")
Problem p02923 (python)

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

ans = 0
cnt = 0
for i in range(n-1):
    if height[i] >= height[i+1]:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0

if cnt > ans:
    ans = cnt

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
height = list(map(int, input().split()))

ans = 0
left = height.pop(0)
while height != []:
    cnt = 0
    while 1:
        if height == []:
            break
        right = height.pop(0)
        if left >= right:
            cnt += 1
            left = right
        else:
            left = right
            break
    if ans < cnt:
        ans = cnt

print(cnt)
Problem p02995 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
def Euclid(x,y):
    while x != 0:
        z=x
        x=y%x
        y=z
    return y
l = c*d//(Euclid(c,d))
print((b- b//c - b//d + b//l) - ((a-1)- (a-1)//c - (a-1)//d + (a-1)//l))

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
gcd = math.gcd(c, d)
lcm = c * d / gcd

lower = (a-1) // c + (a-1) // d - (a-1) // lcm
upper = b // c + b // d - b // lcm

print(int(b - (a-1) - (upper - lower)))
Problem p03087 (python)

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

lr = []
for _ in range(q):
    l, r = map(int, input().split())
    lr.append([l, r])

t = [0] * (n+1)
for i in range(n-1):
    if S[i] == "A" and S[i+1] == "C":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for temp in lr:
    l, r = temp
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
S = list(input())

lr = []
for _ in range(q):
    l, r = map(int, input().split())
    lr.append([l, r])

t = [0] * (n+1)
for i in range(n):
    if S[i] == "A" and S[i+1] == "C":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for temp in lr:
    l, r = temp
    print(t[r-1] - t[l-1])
Problem p02732 (python)

Fixed submission:
from sys import stdin

N = int(stdin.readline())
a_dict = {}
A = list(map(int, stdin.readline().split()))
for a in A:
    if a in a_dict:
        a_dict[a] += 1
    else:
        a_dict[a] = 1

sum_comb = 0
B = set(A)
for b in B:
    n = a_dict[b]
    sum_comb += n * (n - 1) // 2

for a in A:
    ans = sum_comb
    n = a_dict[a]
    ans -= n * (n - 1) // 2
    ans += (n - 1) * (n - 2) // 2
    print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
from sys import stdin

N = int(stdin.readline())
count1 = [0] * (N + 1)
count2 = [0] * (N + 1)
A = list(map(int, stdin.readline().split()))

B = list(set(A))

for b in B:
    num_of_b = A.count(b)
    if num_of_b > 2:
        count1[b] = comb(num_of_b, 2, exact=True)
        count2[b] = comb(num_of_b - 1, 2, exact=True)
    elif num_of_b == 2:
        count1[b] = 1


for a in A:
    ans = 0
    ans += sum(count1) - count1[a]
    ans += count2[a]
    print(ans)
Problem p02755 (python)

Fixed submission:
from math import floor, ceil

A, B = map(int, input().split())

min1 = A/0.08
max1 = (A+0.9999999)/0.08
min2 = B/0.1
max2 = (B+0.9999999)/0.1

rangeMin = ceil(max(min1, min2))
rangeMax = floor(min(max1, max2))
if rangeMin > rangeMax:
    print(-1)
else:
    print(rangeMin)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

tmp = N%(A+B)
if 0 <= tmp <= A:
    print(A*(N//(A+B))+tmp)
else:
        print(A*(N//(A+B)))
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
P = [None]*M
S = [None]*M
for i in range(M):
    P[i], S[i] = input().split()
    P[i] = int(P[i])

AC = [0]*(N+1)
wa = [0]*(N+1)
WA = 0

for i in range(M):
    if S[i] == "WA":
        if AC[P[i]] == 0:
            wa[P[i]] += 1
    else:
        AC[P[i]] = 1

for i in range(N+1):
    WA += wa[i]*AC[i] 

print(sum(AC[1:]), WA)

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int, sys.stdin.readline().split())
P = [None]*M
S = [None]*M
for i in range(M):
    P[i], S[i] = sys.stdin.readline().split()

AC = [0]*N
WA = 0
"""
for i in range(M):
    if S[i] == "AC":
        if AC[int(P[i])-1] == 0:
            AC[int(P[i])-1] += 1
            for j in range(i):
                if P[j] == P[i] and S[j] == "WA":
                    WA += 1
"""


for i in range(M):
    if AC[i]==0 and S[i] == "WA":
        WA += 1
    if S[i] == "AC":
        if AC[int(P[i])-1] == 0:
            AC[int(P[i])-1] += 1

print(sum(AC), WA)
Problem p02817 (python)

Fixed submission:
import sys

S, T = map(str,input().split())

print(T+S)

Buggy submission (verdict: Runtime Error):
import sys

S, T = map(int, sys.stdin.readline.split())

print(S+T)
Problem p02888 (python)

Fixed submission:
import sys
import bisect

N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))
L = sorted(L)

count = 0
for a_i in range(N-1):
    for b_i in range(a_i+1, N):
        max_c = bisect.bisect_left(L, L[a_i]+L[b_i])
        if max_c > b_i:
            count += max_c - b_i - 1
        
print(count)

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

count = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] < L[j] + L[k]:
                if L[j] < L[i] + L[k]:
                    if L[k] < L[i] + L[j]:
                        count += 1

print(count)