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

Fixed submission:
r,d,x=map(int,input().split())
y=[x]
for i in range(10):
  y.append(r*y[i]-d)
  print(y[i+1])

Buggy submission (verdict: Runtime Error):
r = int(input())
d = int(input())
x = int(input())

for i in range(10):
  x = r*x - d
  print(x)

Buggy submission (verdict: Runtime Error):
r = int(input())
d = int(input())
x = int(input())

for i in range(10):
  x = r*x - d
  print(x)
Problem p03077 (python)

Fixed submission:
n = int(input())
transp = [int(input()) for _ in range(5)]
import math
print(math.ceil(n/min(transp))+4)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for _ in range(n)]
pmin = min(i for i in p)

import math
print(math.ceil(n/pmin)+4)
Problem p02623 (python)

Fixed submission:
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a2 = [0] * (n + 1)
b2 = [0] * (m + 1)
for i in range(0, n):
    a2[i+1] = a[i] + a2[i]
for i in range(0, m):
    b2[i+1] = b[i] + b2[i]

ans = 0
for i in range(n+1):
    tmp = bisect.bisect_right(b2, k-a2[i]) - 1
    if a2[i] + b2[tmp] <= k and tmp >= 0:
        ans = max(ans, i+tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(1, n):
    a[i] += a[i-1]
for i in range(1, m):
    b[i] += b[i-1]

I = bisect.bisect_right(a, k)
ans = bisect.bisect_right(b, k)
li = list(range(I))
li = li[::-1]
for i in li:
    tmp = bisect.bisect_right(b, k-a[i])
    if a[i] + b[tmp-1] <= k && tmp != 0:
        ans = max(ans, i+tmp+1)

print(ans)
Problem p02580 (python)

Fixed submission:
import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        if (r, c) not in bomb:
            # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
            # 即座に探索を終了する. これによりループの回数は最大でもM+1回となる.
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Buggy submission (verdict: Runtime Error):
########### E
H, W, M = map(int, input().split())
bombs = []
for _ in range(M):
    bomb = list(map(int, input().split()))
    bombs.append(bomb)

H_list = [0]*H
W_list = [0]*W
sign = True
for i in range(M):
    H_list[bombs[i][0]-1] += 1
    W_list[bombs[i][1]-1] += 1

max_H = [i for i,k in enumerate(H_list) if k == max(H_list)]
max_W = [i for i,k in enumerate(W_list) if k == max(W_list)]

cross = []

for i in max_H:
    for k in max_W:
        if [i+1,k+1] not in bombs:
            sign = False
            print(max(H_list) + max(W_list))
            break
    break

if sign:

Buggy submission (verdict: Runtime Error):
########### E
H, W, M = map(int, input().split())
bombs = []
for _ in range(M):
    bomb = list(map(int, input().split()))
    bombs.append(bomb)

H_list = [0]*H
W_list = [0]*W
sign = True
for i in range(M):
    H_list[bombs[i][0]-1] += 1
    W_list[bombs[i][1]-1] += 1

max_H = [i for i,k in enumerate(H_list) if k == max(H_list)]
max_W = [i for i,k in enumerate(W_list) if k == max(W_list)]

cross = []

for i in max_H:
    for k in max_W:
        if [i+1,k+1] not in bombs:
            sign = False
            print(max(H_list) + max(W_list))
            break
    break

if sign:
Problem p02659 (python)

Fixed submission:
import math
a,b=input().split()
a=int(a)
c=int(b[0]+b[2]+b[3])
print(int(a*c)//100)
#print(a*b)

Buggy submission (verdict: Runtime Error):
import math
a,b=input().split()
a=int(a)
c=b[0]+b[2]+b[3]
print(int(a*c/100))
#print(a*b)

Buggy submission (verdict: Runtime Error):
import math
a,b=input().split()
a=int(a)
b=b*100
ans=math.floor(a*b/100)
print(ans)
Problem p03242 (python)

Fixed submission:
n=int(input())
n2=list(str(n))
for i in range(3):
    if n2[i]=="1":
        n2[i]="9"
    else:
        n2[i]="1"
new_n="".join(n2)
print(new_n)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
odd=[[0,0] for i in range(10**5+1)]
even=[[0,0] for i in range(10**5+1)]
for i in range(1,10**5+1):
    odd[i][1]=i
    even[i][1]=i
for i in range(n):
    if (i+1)%2==1:
        odd[v[i]][0]+=1
    else:
        even[v[i]][0]+=1
odd=sorted(odd,reverse=True)
even=sorted(even,reverse=True)
ans=0
if(odd[0][0]+even[0][0]==n): #odd[0][0]=n//2
    if(odd[0][1]==even[0][1]):
        ans=n//2
    else:
        ans=0

else:
    # odd 19,1 even 20,19のときに、(1+20)=21よりも(19+19)=38のほうがいいい。
    if(odd[0][1]==even[0][1]):
        if(odd[0][0]+even[1][0]<=odd[1][0]+even[0][0]):
            ans=(n//2-odd[1][0])+(n//2-even[0][0])
        else:
            ans=(n//2-odd[0][0])+(n//2-even[1][0])

    else:
        ans=(n//2-odd[0][0])+(n//2-even[0][0])
print(ans)
Problem p03834 (python)

Fixed submission:
s=input()
l=len(s)
s_list=list(s)
for i in range(l):
    if s_list[i]==",":
        s_list[i]=" "
new="".join(s_list)
print(new)

Buggy submission (verdict: Runtime Error):
K,S=map(int,input().split())
sum=0
count=0
for i in range(K+1):
    sum+=i
    a=sum
    L=S-sum
    #print(L)
    LL=min(L,K)
    for j in range(LL+1):
        sum+=j
        if S-sum>=0 and S-sum<=K :
            count+=1
            #print(str(i)+" "+str(j))
        sum=a #jを足す前に戻す
    sum=0
print(count)
Problem p02785 (python)

Fixed submission:
N,A=map(int,input().split())
B=sorted(list(map(int,input().split())))
for j in range(A):
    if B!=[]: B.pop()
print(sum(B))

Buggy submission (verdict: Runtime Error):
N,A=map(int,input().split())
B=sorted(list(map(int,input().split())))
for j in range(A):
    B.pop()
print(sum(B))

Buggy submission (verdict: Runtime Error):
N,A=map(int,input().split())
B=sorted(list(int(input()) for i n range(N)))
for j in range(A):
    B.pop()
print(sum(B))
Problem p02880 (python)

Fixed submission:
N=int(input())
for i in range(1,10):
    if N%i==0 and N//i<=9:
        print('Yes')
        break
else:print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
for i range(1,10):
    if N%i==0 and N//i<=9:
        print('Yes')
else:print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
for i range(1,int(int(N**0.5)+1):
    if N%i==0 and N//i<=9:
        print('Yes')
else:print('No')

Buggy submission (verdict: Runtime Error):
for i range(1,int(int(input())**0.5)+1):
    if N%i==0 and N//i<=9:
        print('Yes')
else:print('No')
Problem p02881 (python)

Fixed submission:
N=int(input())
cnt=N-1
for i in range(1,int(N**0.5)+1):
    if N%i== 0:
        cnt=min(cnt,N//i+i-2)
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
cnt=N-1
for i in range(1,N):
    if N%i==o:
        cnt=min(cnt,N//i+i-2)
print(cnt)
Problem p02970 (python)

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

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(math.ceil(a/(2b+1)))
Problem p03077 (python)

Fixed submission:
import math
n=int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[int(input()) for i in range(5)]
print(mat.ceil(n/min(l))+4)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[int(input()) for in range(5)]
print(mat.ceil(n/min(l))+4)
Problem p03207 (python)

Fixed submission:
P=[int(input()) for i in range(int(input()))]
print(sum(P)-max(P)//2)

Buggy submission (verdict: Runtime Error):
P=[int(input()) for i in range(int(input()))]
print(sum(p)-max(p)//2)
Problem p03242 (python)

Fixed submission:
S=input().replace('1','x').replace('9','1').replace('x','9')
print(S)

Buggy submission (verdict: Runtime Error):
S=input().replace('1','x').replace('9','1').replace('x',9)
print(S)
Problem p03805 (python)

Fixed submission:
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N,M=map(int,input().split())
edges={tuplec(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N,M=map(int,input().split())
edges={tuplec(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1)):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)
Problem p03834 (python)

Fixed submission:
print(*input().split(","))

Buggy submission (verdict: Runtime Error):
print(*input().split(,))
Problem p02596 (python)

Fixed submission:
K = int(input())

A = [0]*1000001
A[0] = 7%K
ans = -1

for i in range(1,1000001):
    A[i] = (A[i-1]*10+7)%K

for i in range(1000001):
    if A[i]==0:
        ans = i+1
        break
        
print(ans)

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

A = [0]*1000000
A[0] = 7%K
ans = 1
while 1==1:
    if A[ans-1]==0:
        break
        
    A[ans] = (A[ans-1]*10+A[0])%K
    ans += 1
    
    if A[ans-1] == A[0] and A[0] != 0:
        ans = -1
        break
        
print(ans)
Problem p02623 (python)

Fixed submission:
import itertools

n,m,k = map(int,input().split())
a = list(map(int,('0 '+input()).split()))
b = list(map(int,('0 '+input()).split()))

asum = list(itertools.accumulate(a))
bsum = list(itertools.accumulate(b))

ans = 0
j=m
for i in range(n+1):
    if asum[i]>k:
        break
    
    while asum[i]+bsum[j]>k:
        j-=1
        
    ans = max(ans,i+j)

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

n,m,k = map(int,input().split())
a = list(map(int,('0 '+input()).split()))
b = list(map(int,('0 '+input()).split()))

asum = list(itertools.accumulate(a))
bsum = list(itertools.accumulate(b))

ans = 0
for i in range(n+1):
    for j in range(m,(ans-i)-1,-1):
        if asum[i]+bsum[j]<=k:
            ans = max(ans,i+j)
            break

print(ans)
Problem p02623 (python)

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

A, B = [0], [0]

for i in range(n):
  A.append(a[i] + A[i])
for i in range(m):
  B.append(b[i] + B[i])

ans, j = 0, m
for i in range(n+1):
  if A[i] > k:
    break
  while B[j] > k - A[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aot = []
i, j = 0, 0
while sum(aot) <= k:


  if len(a) > 0 and len(b) > 0:
    if a[i] >= b[j]:
      aot.append(b[j])
      del b[j]
      #print('aは{}, bは{}'.format(a, b))
    elif a[i] <= b[j]:
      aot.append(a[i])
      del a[i]
      #print('aは{}, bは{}'.format(a, b))
      
  elif len(a) == 0:
    aot.append(b[j])
    del b[j]
  elif len(b) == 0:
    aot.sppend(a[i])
    del a[i]
  
if sum(aot) > k:
  del aot[-1]
print(len(aot))

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aot = []
i, j = 0, 0
while sum(aot) < k:


  if len(a) > 0 and len(b) > 0:
    if a[i] >= b[j]:
      aot.append(b[j])
      del b[j]
      #print('aは{}, bは{}'.format(a, b))
    elif a[i] <= b[j]:
      aot.append(a[i])
      del a[i]
      #print('aは{}, bは{}'.format(a, b))
      
  elif len(a) == 0:
    aot.append(b[j])
    del b[j]
  elif len(b) == 0:
    aot.sppend(a[i])
    del a[i]
  
if sum(aot) > k:
  del aot[-1]
print(len(aot))
Problem p02629 (python)

Fixed submission:
N=int(input())
a=N//27
b=N%27
s=''
if N<27:
  print(chr(N+96))
else:
  n=N
  j=0
  for i in range(1,11):
    if n-1-pow(26,i)>=0:
      n-=pow(26,i)
      j=i
    else:
      break
  for k in range(j,-1,-1):
    if k==0:
      s=s+chr(n-1+97)
    else:
      s=s+chr((n-1)//pow(26,k)+97)
      n-=((n-1)//pow(26,k))*pow(26,k)
  print(s)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=N//27
b=N%27
j=0
p=N
for i in range(1,11):
  if N<pow(26,i):
    j=i-1
    break
  p-=pow(26,i)
s=''
if j==0:
  print(chr(N+96))
else:
  q=N
  for i in range(j):
    q-=pow(26,i+1)
  q-=1
  for k in range(j,-1,-1):
    s=s+chr(q//pow(26,k)+97)
    q-=(q//pow(26,k))*pow(26,k)
  print(s)
Problem p02793 (python)

Fixed submission:
from fractions import gcd
s=int(input())
t=list(map(int, input().split()))
ans=t[0]
for i in t:
  ans=(ans*i)//gcd(ans,i)
mod=10**9+7
a=0
for j in t:
  a+=ans//j
print(int(a)%mod)

Buggy submission (verdict: Runtime Error):
import fractions import gcd
s=int(input())
t=list(map(int, input().split()))
ans=t[0]
for i in t:
  ans=(ans*i)//gcd(ans,i)
mod=10**9+7
ans%=mod
a=0
for j in t:
  a+=ans//j
print(int(a)%mod)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
t=list(map(int,input().split()))
numbers=list(set(t))
for i in range(len(numbers)):
    if i == 0:
        gcd = numbers[i]
        lcm = numbers[i]
    else:
        gcd = fractions.gcd(gcd, numbers[i])
        lcm = (lcm * numbers[i]) // fractions.gcd(lcm, numbers[i])
a=0
mod=10**9+7
for i in range(n):
  a+=lcm/t[i]
  a=a%mod
print(int(a))

Buggy submission (verdict: Runtime Error):
import fractions
s=int(input())
t=list(map(int, input().split()))
ans=t[0]
for i in range(1,s):
  ans=ans*t[i]//fractions.gcd(ans,t[i])
mod=10**9+7
a=0
for j in range(s):
  a+=ans/t[j]
  a=a%mod
print(int(a))
Problem p02829 (python)

Fixed submission:
s=int(input())
t=int(input())
list=[]
list.append(1)
list.append(2)
list.append(3)
list.remove(s)
list.remove(t)
print(*list)

Buggy submission (verdict: Runtime Error):
s=int(input())
t=int(input())
list=[]
list.append(1)
list.append(2)
list.append(3)
del list[s-1]
del list[t-1]
print(*list)
Problem p02862 (python)

Fixed submission:
X,Y=map(int,input().split())
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**6
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 )
if (X+Y)%3!=0:
  print(0)
else:
  n=2*Y-X
  m=2*X-Y
  if n<0 or m<0:
    print(0)
  else:
    n=int(n/3)
    m=int(m/3)
    print(cmb(n+m,m,mod))

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
    return result
if s[0]%3==0 and s[1]%3==0:
  a=max(s)-min(s)
  b=(min(s)-a)//3
  c=ncr(b*2+a,b)%1000000009
  print(int(c))
elif s[0]%3==1 and s[1]%3==2:
  a=s[0]-1
  b=s[1]-2
  c=max(a,b)-min(a,b)
  d=(min(a,b)-c)//3
  e=ncr(d*2+c+1,d)%1000000009
  print(int(e))
elif s[0]%3==2 and s[1]%3==1:
  a=s[0]-2
  b=s[1]-1
  c=max(a,b)-min(a,b)
  d=(min(a,b)-c)//3
  e=ncr(d*2+c+1,d)%1000000009
  print(int(e))
Problem p02912 (python)

Fixed submission:
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=0
c=0
d=s[1]
t.sort(reverse=True)
if s[0]==1:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
else:
  c=t[0]/2
  for j in range(s[1]):
    for l in range(s[0]):
      if d>0:
        if c<t[l]:
          t[l]=math.floor(t[l]/2)
          d=d-1
        else:
            t.sort(reverse=True)
            c=t[0]/2
            break
      else:
        break
e=sum(t)
print(e)

Buggy submission (verdict: Runtime Error):
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=0
c=0
d=s[1]
t.sort(reverse=True)
if s[0]==1:
  for i in range(s[1]):
    t[0]=math.floor(t[0]/2)
else:
  c=t[0]/2
  for j in range(s[1]):
    print(t)
    for l in range(s[0]):
      if d>0:
        if c<t[l]:
          t[l]=math.floor(t[l]/2)
          d=d-1
        else:
            t.sort(reverse=True)
            c=t[0]/2
            break
      else:
        break
e=sum(t)
print(e)

Buggy submission (verdict: Runtime Error):
import math
 
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
t.sort(reverse=True)
for i in range(s[1]):
  t[0]=math.floor(t[0]/2)
  if s[1]>=2:
    if t[0]<t[1]:
      t.sort(reverse=True)
  else:
    continue
a=sum(t)
print(a)

Buggy submission (verdict: Runtime Error):
import math

s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
b=int(s[1])
for i in range(s[1]):
  for j in range(s[0]):
    if max(t)==t[j] and 0<b:
      t[j]=math.floor(t[j]/2)
      b=b-1
    elif: b<=0:
        break
for l in range(s[0]):
  a=a+t[l]
print(a)
Problem p02933 (python)

Fixed submission:
s=int(input())
str=input()
if s<3200:
  print("red")
else:
  print(str)

Buggy submission (verdict: Runtime Error):
s=int(input())
str=input()
if s<3200:
  print(red)
else:
  print(str)
Problem p02951 (python)

Fixed submission:
s=list(map(int,input().split()))
s[0]=int(s[0])
s[1]=int(s[1])
s[2]=int(s[2])
a=0
if s[0]-s[1]>s[2]:
  print(0)
else:
  print(s[2]-s[0]+s[1])

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
a=s[0]-[1]
if a>s[2]:
  print(0)
else:
  print(s[2]-a)
Problem p02954 (python)

Fixed submission:
S=input()
dp=[0]*len(S)
a=0
for i in range(len(S)):
  if S[i]=='R':
    a+=1
  else:
    dp[i]+=a//2
    dp[i-1]+=a-a//2
    a=0
for i in range(len(S)-1,-1,-1):
  if S[i]=='L':
    a+=1
  else:
    dp[i]+=a//2
    dp[i+1]+=a-a//2
    a=0
print(*dp)

Buggy submission (verdict: Runtime Error):
s=input()
def roopR(l,n):
  if list[k]==1:
    for p in range(a):
      if list[l]==-1:
        if n%2==0:
          return l
        else:
          return l-1
      else:
        l += 1
        n += 1
  else:
    for q in range(a):
      if list[m]==1:
        if o%2==0:
          return m
        else:
          return m+1
      else:
        m -= 1
        o += 1

a=len(s)
endlist=[]
list=[]
for i in range(a):
  if s[i]=='R':
    list.append(1)
  else:
    list.append(-1)
for j in range(a):
  endlist.append(0)
for k in range(a):
  b=roopR(k,0)
  endlist[b] += 1
print(*endlist)

Buggy submission (verdict: Runtime Error):
s=input()
def roopR(l,n):
  if s[l]=='L':
    if n%2==0:
      return l
    else:
      return l-1
  else:
    return roopR(l+1,n+1)

def roopL(l,n):
  if s[l]=='R':
    if n%2==0:
      return l
    else:
      return l+1
  else:
    return roopL(l-1,n+1)

a=len(s)
endlist=[]
for j in range(a):
  endlist.append(0)
for k in range(a):
  if s[k]=='R':
    b=roopR(k,0)
    endlist[b] += 1
  else:
    b=roopL(k,0)
    endlist[b] += 1
print(*endlist)

Buggy submission (verdict: Runtime Error):
s=input()
list=[]
def roopR(l,n):
  if list[l]==-1:
    if n%2==0:
      return l
    else:
      return l-1
  else:
    return roopR(l+1,n+1)
  
def roopL(l,n):
  if list[l]==1:
    if n%2==0:
      return l
    else:
      return l+1
  else:
    return roopL(l-1,n+1)

a=len(s)
for i in range(a):
  if s[i]=='R':
    list.append(1)
  else:
    list.append(-1)
s.clear()
endlist=[]
for j in range(a):
  endlist.append(0)
for k in range(a):
  if list[k]==1:
    b=roopR(k,0)
    endlist[b] += 1
  else:
    b=roopL(k,0)
    endlist[b] += 1
print(*endlist)

Buggy submission (verdict: Runtime Error):
s=input()
list=[]
def roopR(l,n):
  if list[l]==-1:
    if n%2==0:
      return l
    else:
      return l-1
  else:
    return roopR(l+1,n+1)
  
def roopL(l,n):
  if list[l]==1:
    if n%2==0:
      return l
    else:
      return l+1
  else:
    return roopL(l-1,n+1)

a=len(s)
for i in range(a):
  if s[i]=='R':
    list.append(1)
  else:
    list.append(-1)
endlist=[]
for j in range(a):
  endlist.append(0)
for k in range(a):
  if list[k]==1:
    b=roopR(k,0)
    endlist[b] += 1
  else:
    b=roopL(k,0)
    endlist[b] += 1
print(*endlist)

Buggy submission (verdict: Runtime Error):
s=input()
list=[]
def roopR(l,n):
  if list[l]==-1:
    if n%2==0:
      return l
    else:
      return l-1
  else:
    return roopR(l+1,n+1)
  
def roopL(l,n):
  if list[l]==1:
    if n%2==0:
      return l
    else:
      return l+1
  else:
    return roopL(l-1,n+1)

a=len(s)
for i in range(a):
  if s[i]=='R':
    list.append(1)
  else:
    list.append(-1)
endlist=[]
for j in range(a):
  endlist.append(0)
for k in range(a):
  if list[k]==1:
    b=roopR(k,0)
    endlist[b] += 1
  else:
    b=roopL(k,0)
    endlist[b] += 1
print(endlist)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]
m=10**9+7
a.append(N+1)
def mul(a,b):
    c=[[0]*len(b[0])for i in range(len(a))]
    for i in range(len(a)):
        for k in range(len(b)):
            for j in range(len(b[0])):
                c[i][j]=(c[i][j]+a[i][k]*b[k][j])%m
    return c
def pow(a,n):
    b=[[0]*len(a) for i in range(len(a))]
    for i in range(len(a)):
        b[i][i]=1
    while 0<n:
        if n&1==1:
            b=mul(a,b)
        a=mul(a,a)
        n=n>>1
    return b                
if M==0:
  A=[[1,1],[1,0]]
  print(pow(A,N+1)[1][0])
elif M==1:
  A=[[1,1],[1,0]]
  print((pow(A,a[0])[1][0]*pow(A,N-a[0])[1][0])%m)
else:
  ans=1
  for i in range(M+1):
    A=[[1,1],[1,0]]
    if a[i]+1==a[i-1]:
      ans=0
      break
    if i==0:
      if a[i]!=1:
        ans=ans*pow(A,a[0])[1][0]
        ans=ans%m
    elif i==M:
      ans=ans*pow(A,a[i]-a[i-1]-1)[1][0]
      ans=ans%m
    else:
      ans=ans*pow(A,a[i]-a[i-1]-1)[1][0]
      ans=ans%m
  print(ans)

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
t=[int(input()) for i in range(s[1])]
list=[]
mod=1000000007
d=1
for k in range(s[0]+4):
  list.append(0)
def fib(x):
  list[0]=list[1]=0
  list[2]=list[3]=1
  for l in range(4,x+3):
    list[l]=list[l-1]+list[l-2]
fib(s[0])
for j in range(s[1]+1):
  if j==0:
    d*=list[t[j]+1]
    d=d%mod
    e=t[j]
  elif j==s[1]:
    d*=list[s[0]-t[j-1]+1]
    d=d%mod
  else:
    d*=list[t[j]-t[j-1]]
    d=d%mod
print(d)

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
t=[int(input()) for i in range(s[1])]
list=[]
mod=1000000007
d=1
for k in range(1010):
  list.append(0)
def fib(x):
  list[0]=list[1]=0
  list[2]=list[3]=1
  for l in range(4,x+3):
    list[l]=list[l-1]+list[l-2]
fib(1000)
for j in range(s[1]+1):
  if j==0:
    d*=list[t[j]+1]
    d=d%mod
    e=t[j]
  elif j==s[1]:
    d*=list[s[0]-t[j-1]+1]
    d=d%mod
  else:
    d*=list[t[j]-t[j-1]]
    d=d%mod
print(d)
Problem p03038 (python)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[list(map(int,input().split())) for _ in range(M)]
B.sort(key=lambda x:-x[1])
i,j=0,0
while i<=N-1:
  for l in range(B[j][0]):
    if A[i]>=B[j][1]:
      print(sum(A))
      exit()
    A[i]=B[j][1]
    i+=1
    if i==N:
      print(sum(A))
      exit()
  j+=1
  if j==M:
    print(sum(A))
    exit()
print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[list(map(int,input().split())) for _ in range(M)]
B.sort(key=lambda x:-x[1])
i,j=0,0
while i<=N-1:
  for l in range(B[j][0]):
    if A[i]>=B[j][1]:
      print(sum(A))
      exit()
    A[i]=B[j][1]
    i+=1
  j+=1
  if j==M:
    print(sum(A))
    exit()
print(sum(A))
Problem p02570 (python)

Fixed submission:
D,T,S = map(int,input().split())
if D/S<=T:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
ans = 0 
for i in range(n-1):
	s-=a[i]
	ans+=s*a[i]
print(ans%(10**9+7))