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

Fixed submission:
words = input()
if words[-1] != "s":
  words += "s"
else:
  words += "es"
print(words)

Buggy submission (verdict: Runtime Error):
words = input()
if words[-1] != s:
  words += "s"
else:
  words += "es"
print(words)

Buggy submission (verdict: Runtime Error):
words = input()
if words[-1] != s:
  words += 's'
else:
  words += 'es'
print(words)
Problem p02570 (python)

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

Buggy submission (verdict: Runtime Error):
D,T,S = list(int,input().split())
if D <= T * S:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
D, T, S = list(map((int, input().split()))
               if D <= T * S:
                 print("YES")
               else:
                 print("NO")
Problem p02847 (python)

Fixed submission:
S = input()
week = ["SUN","MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i in range(7):
  if week[i] == S:
    print(7 - i)

Buggy submission (verdict: Runtime Error):
S = input()
week = ["SUN","MON", "TUE", "WED", "THU", "FRI", "SAT"]
for i in week:
  if week[i] == S:
    print(7 - i)
Problem p02572 (python)

Fixed submission:
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7

sum_ = 0
ans = 0

for i in range(N):
    ans += sum_ * A[i]
    ans %= mod
    sum_ += A[i]
    sum_ %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7
ans = 0
summ = 0

for i in range(N):
    summ += A[i]
    summ %= mod

for i in range(N):
    summ -= A[i]
    if summ < 0:
        sum += mod
    ans += A[i] * summ
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7
ans = 0
summ = 0

for i in range(N):
    summ += A[i]
    summ %= mod

for i in range(N):
    summ -= A[i]
    if summ < 0:
        sum += mod
    ans += A[i] * summ
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7
ans = 0
summ = 0

for i in range(N):
    summ += A[i]
    summ %= mod

for i in range(N):
    summ -= A[i]
    print(summ)
    if summ < 0:
        sum += mod
    ans += A[i] * summ
    print(ans)
    ans %= mod
    print(ans)
print(ans)
Problem p02859 (python)

Fixed submission:
r = int(input())
     
print(r*r)

Buggy submission (verdict: Runtime Error):
r = int(inputs())

print(r*r)
Problem p02570 (python)

Fixed submission:
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = None

d, t, s = m_in(int)
ans = 'Yes' if d <= t*s else 'No'

print(ans)

Buggy submission (verdict: Runtime Error):
def l_in(type_): return list(map(type_, input().split()))
def i_in(): return int(input())
def m_in(type_): return map(type_, input().split())
def r_in(n, type_): return [type_(input()) for _ in range(n)]
ans = None

d, t, s = m_in()
ans = 'Yes' if d <= t*s else 'No'

print(ans)
Problem p02578 (python)

Fixed submission:
from sys import exit
n = int(input())
a = list(map(int, input().split()))
if n==1: print(0); exit()
al = [0 for _ in range(n)]
for index in range(n-1):
	person = a[index]
	person_behind = a[index+1]
	if person_behind < person:
		k = person - person_behind
		a[index+1] += k
		al[index+1] = k
print(sum(al))

Buggy submission (verdict: Runtime Error):
from sys import exit
n = int(input())
a = list(map(int, input().split()))
if n==1: print(0); exit()
al = [0 for _ in range(n)]
for index in range(n-1):
	person = a[index]
	person_behind = a[index+1]
	if person_behind < person:
		k = person - person_behind
		a[index+1] += k
		al[person_behind] = k
print(sum(al))

Buggy submission (verdict: Runtime Error):
from sys import exit
n = int(input())
if n==1: print(0); exit()
a = list(map(int, input().split()))
al = [0 for _ in range(n)]
for index in range(n-1):
	person = a[index]
	person_behind = a[index+1]
	if person_behind < person:
		k = person - person_behind
		a[index+1] += k
		al[person_behind] = k
print(sum(al))
Problem p02571 (python)

Fixed submission:
s =input()
t =input()

S = len(s)
T = len(t)

cnt=0
max=0

for i in range(S-T+1):
    for j in range(T):
        if s[i+j] == t[j]:
            cnt += 1
    else:
        if max<cnt:
            max=cnt
            cnt=0
        else:
            cnt=0

print(T-max)

Buggy submission (verdict: Runtime Error):
s =input()
t =input()

S = len(s)
T = len(t)
cnt=0
max=0

for i in range(T):
    for j in range(S-T):
        if s[i+j] == t[j]:
            cnt += 1
    else:
        if max<cnt:
            max=cnt
            cnt=0

print(T-max)
Problem p02580 (python)

Fixed submission:
h,w,m=map(int,input().split())
table=[]
H=[0]*h
W=[0]*w
li_h=[]
li_w=[]

for i in range(m):
    h1,w1=list(map(int,input().split()))
    table.append((h1-1,w1-1))
    H[h1-1]+=1
    W[w1-1]+=1

h_flag=0
w_flag=0

Hm=max(H)
Wm=max(W)

Hh=[i for i, x in enumerate(H) if x == Hm]
Ww=[i for i, x in enumerate(W) if x == Wm]

cnt=0

for (h, w) in table:
    if H[h] == Hm and W[w] ==  Wm:
        cnt += 1

if cnt<len(Hh)*len(Ww):
    print(Hm+Wm)
else:
    print(Hm+Wm-1)

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
table=[]
H=[0]*h
W=[0]*w
li_h=[]
li_w=[]

for i in range(m):
    h1,w1=list(map(int,input().split()))
    table.append((h1-1,w1-1))
    H[h1-1]+=1
    W[w1-1]+=1

h_flag=0
w_flag=0

Hm=max(H)
Wm=max(W)

Hh=[i for i, x in enumerate(H) if x == HM]
Ww=[i for i, x in enumerate(W) if x == Wm]

cnt=0

for (h, w) in table:
    if H[h] == HM and W[w] ==  Wm:
        cnt += 1

if cnt<len(Hh)*len(Ww):
    print(HM+Wm)
else:
    print(HM+Wm-1)

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())

H=[0]*h
W=[0]*w
li_h=[]
li_w=[]

for i in range(m):
    h1,w1=list(map(int,input().split()))
    li_h.append(h1)
    li_w.append(w1)
    H[h1-1]+=1
    W[w1-1]+=1


h_flag=0
w_flag=0

if H.count(max(H))==1:
    ans_h=max(H)
    h_flag+=1

if W.count(max(W))==1:
    ans_w=max(W)
    w_flag+=1

if h_flag==1 and w_flag==1:
    print(max(H)+max(W))



else:
    if h_flag==1:
        for i in range(m):
            if li_w[i]==max(H):
                if li_h[i]==0:
                    print(max(H)+max(W))
                    h_flag+=1:
        else:
             h_flag==1:
             print(max(H)+max(W)-1)                   
                
            


    elif w_flag==1:
        for i in range(m):
            if li_h[i]==max(W):
                if li_w[i]==0:
                    print(max(H)+max(W))
                    w_flag+=1:
        else:
             w_flag==1:
             print(max(H)+max(W)-1)
Problem p02627 (python)

Fixed submission:
a=input()
   
if str.isupper(a):
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=''
while n>=26:
    s=n%26
    n=n//26
    ans+=(chr(s+96))
ans+=(chr(n+96))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list()
ans=''
while n>=26:
    s=n%26
    n=n//26
    ans+=(chr(s+96))
ans+=(chr(n+96))
print(ans)

Buggy submission (verdict: Runtime Error):
while True:
   D=input()
   
   if str.isupper(D):
       print("A")
   else:
        print("a")
Problem p03042 (python)

Fixed submission:
s=input()

if 12<int(s[:2]) or 0==int(s[:2]):
    if 12>=int(s[2:])>=1:
        print("YYMM")
    else:
        print("NA")
elif 1<=int(s[:2])<=12:
    if 12>=int(s[2:])>=1:
        print("AMBIGUOUS")
    else:
        print("MMYY")

Buggy submission (verdict: Runtime Error):
s=input()

if 12<int(s[:2]):
    if 12>=int(s[2:])>=1:
        print("YYMM")
    else:
        print("NA")
else:
    if 12>=int(s[2:])>=1:
        print("AMBIGUOUS")
    elif 12<s[2:]:
        print("MMYY")
Problem p03804 (python)

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

cnt=0
k=0
flag=0
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for j in range(n-m+1):
    k=0
    for i in range(n-m+1):
        if b[k]==a[i][j:j+m]:
            k+=1
            if k==m:
                print("Yes")
                flag+=1
                break
    else:
        continue
    break


if flag==0:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]

cnt=0
k=0
flag=0
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for j in range(n-m+1):
    k=0
    for i in range(n-m+1):
        if b[k]==a[i][j:j+m]:
            k+=1
            if k==m:
                print("Yes")
                flag+=1

if flag==0:
    print("No")
Problem p02594 (python)

Fixed submission:
x=int(input())
if x>=30:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N,D=input().split()
n=int(N)
d=int(D)
count=0
for i in range(n):
  X,Y=input().split()
  x=int(X)
  y=int(Y)
  distance=x*x+y*y
  if distance<=d*d:
    count+=1
print(count)
Problem p02597 (python)

Fixed submission:
n=int(input())
li=[]
red=0
white=0
count=0
li=list(input())
for i in li:
  if i == 'R':
    red+=1
  else:
    white+=1

checkw=0
for i in range(red):
  if li[i]=='W':
    checkw+=1

checkr=0
for i in range(white):
  if li[i+red]=='R':
    checkr+=1
sa=checkw-checkr
if sa==0:
  print(checkr)
elif sa>0:
  print(checkr+sa)
else:
  print(checkw+sa)

Buggy submission (verdict: Runtime Error):
n=int(input())
li=[]
red=0
white=0
count=0
li=list(input())
for i in li:
  if i == 'R':
    red+=1
  else:
    white+=1
while True:
  for i in range(red):
    checkw=-1
    if li[i]=='W':
      checkw=i
      break
  for i in range(white):
    checkr=-1
    if li[i+red]=='R':
      checkr=i
      break
  if checkw!=-1 and checkr!=-1:
    li[checkw]='R'
    li[red+checkr]='W'
    count+=1
  elif checkw!=-1:
    li[checkw]='R'
    count+=1
  elif checkr!=-1:
    li[red+checkr]='W'
    count+=1
  else:
    break
print(count)
Problem p02862 (python)

Fixed submission:
import math
import numpy as np

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 )





x,y = map(int,input().split()) 

if (x+y) % 3 == 0:

    A = np.array([[1, 2],
                  [2, 1]])

    b = np.array([x, y])

    N = np.linalg.solve(A, b)


    if N[0].is_integer() == True and N[1].is_integer() == True and N[0] >=0 and N[1] >=0:
          
        print(cmb(int(N[0]+N[1]),int(N[0]),mod))

    else:
        print(0)

else:
    print(0)

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

x,y = map(int,input().split()) 

A = np.array([[1, 2],
             [2, 1]])

b = np.array([x, y])
 
sol_auto = np.linalg.solve(A, b)


if sol_auto[0].is_integer() == True and sol_auto[1].is_integer() == True:
    k = math.factorial(sol_auto[0]+sol_auto[1])/(math.factorial(sol_auto[0])*math.factorial(sol_auto[1]))

    print(int(k%1000000007))
else:
    print(0)

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

x,y = map(int,input().split()) 

A = np.array([[1, 2],
             [2, 1]])

b = np.array([x, y])
 
sol_auto = np.linalg.solve(A, b)


if sol_auto[0].is_integer() == True and sol_auto[1].is_integer() == True:
    k = math.factorial(sol_auto[0]+sol_auto[1])/(math.factorial(sol_auto[0])*math.factorial(sol_auto[1]))

    print(int(k%1000000007))
else:
    print(0)
Problem p02693 (python)

Fixed submission:
k = int(input())
a,b = map(int, input().split())
largest = (b//k)*k
print("OK" if largest >= a else "NG")

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int, input().split)
largest = (b//k)*k
print("OK" if largest >= a else "NG")
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
r = int((input))
print(r**2)
Problem p03774 (python)

Fixed submission:
n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
  st.append(list(map(int, input().split())))
for i in range(m):
  pt.append(list(map(int, input().split())))
for j in st:
  for k in pt:
    d = abs(j[0]-k[0]) + abs(j[1]-k[1])
    ch.append(d)
  print(ch.index(min(ch))+1)
  ch = []

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
  st.append(list(map(int, input().split())))
for i in range(n):
  pt.append(list(map(int, input().split())))
for j in st:
  for k in pt:
    d = abs(j[0]-k[0]) + abs(j[1]-k[1])
    ch.append(d)
  print(ch.index(min(ch))+1)
  ch = []
Problem p02627 (python)

Fixed submission:
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

#cnt = 0
#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

S = str(input())
A = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U","V","W","X","Y","Z"]

if S in A:
    print('A')
else:
    print('a')

Buggy submission (verdict: Runtime Error):

Jupyter Notebook
200621 Current Kernel Logo

Python 3

    File
    Edit
    View
    Insert
    Cell
    Kernel
    Help

1

import sys

2

#sys.exit()

3

#sorted( ,reverse=True)

4

#N = int(input())

5

#S,T = map(int, input().split())

6

#A = list(map(int, input().split()))

7

#A = [int(input()) for _ in range(N)]

8

​

9

#cnt = 0

10

#cnt += 1

11

​

12

​

13

​

14

#print(N)

15

#print(S,T)

16

#print(A)

17

#print('Yes')

18

#print('No')

19

#print(cnt)

3
3
4
5
3
[3, 4, 5]

1

import sys

2

#sys.exit()

3

#sorted( ,reverse=True)

4

#N = int(input())

5

#S,T = map(int, input().split())

6

#A = list(map(int, input().split()))

7

#A = [int(input()) for _ in range(N)]

8

​

9

#cnt = 0

10

#cnt += 1

11

​

12

​

13

​

14

#print(N)

15

#print(S,T)

16

#print(A)

17

#print('Yes')

18

#print('No')

19

#print(cnt)

20

​

21

S = str(input())

22

A = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U","V","W","X","Y","Z"]

23

​

24

if S in A:

25

    print('A')

26

else:

27

    print('a')

a
a

1

​
Problem p02682 (python)

Fixed submission:
A,B,C,K= map(int, input().split())
if A >= K:
    print(K)
    #print("a")
else:
    ans = A
    if B >= K-A:
        print(A)
        #print("b")
    else:
        print(A-(K-(A+B)))
        #print("c")

Buggy submission (verdict: Runtime Error):
A,B,C,K= map(int, input().split())
Z = [1,]*A + [0,]*B+[-1,]*C
ans = 0
for i in Z[0:K]:
    ans += i
print(ans)
Problem p02753 (python)

Fixed submission:
S = str(input())
if S[0] != S[1] or S[1] != S[2]:
    print("Yes")
else:
    print("No")

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

ans1 = int(A *100// 8) 
ans2 = int(B *100 // 10)

if ans1 = ans2:
    print(ans1)

elif ans1 > ans2:
    ans2_2 = int((B+1) *100 // 10)
    list = [int(ans2)]

    for i in range(ans2+1,ans2_2):
        list.append(int(i)) 
    
    if int(ans1) in list:
        print(ans1)
    else:
        print(-1)
elif ans1 < ans2:
    ans1_2 = int((A+1) *100 // 8)
    list = [int(ans1)]

    for i in range(ans1+1,ans1_2):
        list.append(int(i)) 
    
    if int(ans2) in list:
        print(ans2)
    else:
        print(-1)
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
print(6-A-B)

Buggy submission (verdict: Runtime Error):
N = int(input())
S,T = list(map(str, input().split()))
for i in range(N):
    print(S[i],end='')
    print(T[i],end='')

Buggy submission (verdict: Runtime Error):
N = int(input())
S,T = list(map(str, input().split()))
for i in range(N):
    print(S[i],end='')
    print(T[i],end='')

Buggy submission (verdict: Runtime Error):
N = int(input())
S,T = list(map(str, input().split()))
for i in range(N):
    print(S[i],end='')
    print(T[i],end='')
Problem p02847 (python)

Fixed submission:
l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
S = input()
print(7-l.index(S))

Buggy submission (verdict: Runtime Error):
l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRY', 'SAT']
S = input()
print(7-l.index(S))

Buggy submission (verdict: Runtime Error):
l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRY', 'SAT']
S = input()
print(7-l.index(S))

Buggy submission (verdict: Runtime Error):
l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRY', 'SAT']
S = input()
print(7-l.index(S))
Problem p02577 (python)

Fixed submission:
N=int(input())
if N%9==0:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=0
while N>=1:
    S+=N%10
    N=int(N/10)

if S%9==0:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=0
while 1:
    S+=N-10*(int(N/10))
    N=int(N/10)
    if N<1:break

N=S
S=0
while 1:
    S+=N-10*(int(N/10))
    N=int(N/10)
    if N<1:break
N=S
S=0
while 1:
    S+=N-10*(int(N/10))
    N=int(N/10)
    if N<1:break
if S%9==0:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=0
while 1:
    S+=N-10*(int(N/10))
    N=int(N/10)
    if N<1:break

N=S
S=0
while 1:
    S+=N-10*(int(N/10))
    N=int(N/10)
    if N<1:break

if S%9==0:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=0
while 1:
    S+=N-10*(int(N/10))
    N=int(N/10)
    if N<1:break
if S%9==0:print("Yes")
else:print("No")
Problem p02623 (python)

Fixed submission:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = sum(b)
ans = 0
j = m

for i in range(n+1):
    while j > 0 and t>k:
        j -= 1
        t -= b[j]
    if t>k: break
    ans = max(ans, i+j)
    if i==n: break
    t += a[i]

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()))
t = sum(b)
ans = 0
j = m

for i in range(n+1):
    while j > 0 and t>k:
        j -= 1
        t -= b[j]
    if t>k: break
    ans = max(ans, i+j)
    #if i==n: break
    t += a[i]

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()))
copyA = A[:]
copyB = B[:]
max = 0
counter = 0
i = 0
while i < N:
  if max + A[i] > K:
    break
  else:
    max += A[i]
    counter += 1
  i += 1
numA = counter
numB = 0

for i in range(M):
  if max + B[i] <= K:
    max = max + B[i]
    counter += 1
    numB += 1
  else:
    break
while numB < M and numA >=0:
  if max - A[numA] + B[numB+1] <= K:
    max = max -A[numA] + B[numB+1]
    numA -= 1
    numB += 1
    flag=1
    while flag and numB < M-1:
      if max + B[numB+1] <= K:
        counter += 1
        numB +=1
      else:
        flag = 0
  else:
    max -= A[numA]
    numA -= 1

print(counter)
Problem p02624 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N+1):
  Limit = N//i
  ans += int(Limit*(Limit+1)*i/2)
print(ans)

Buggy submission (verdict: Runtime Error):
1N = int(input())
ans = 0
for i in range(1,N+1):
  Limit = N//i
  ans += int(Limit*(Limit+1)*i/2)
print(ans)
Problem p02970 (python)

Fixed submission:
n, d = map(int, input().split())
Answer = n//(2*d+1)
if n%(2*d+1) != 0:
  Answer +=1
  
print(Answer)

Buggy submission (verdict: Runtime Error):
N,D = map(int,input().split())
Answer = (N-1)//(2D+1)+1
print(Answer)
Problem p02629 (python)

Fixed submission:
n = int(input())
ans=''
while(n>0):
     n -= 1
     ans += chr(ord('a')+n%26)
     n //= 26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans=''
while(n>0):
     ans+=crd(ord('a')+n%26)
     n //=n
print(ans)
Problem p02623 (python)

Fixed submission:
import sys
from functools import reduce

def main(n, m, k, a, b):
    """ main
    """

    bestScore = 0
    _k = 0
    _ai = 0

    while True:
        if _ai >= n or _k + a[_ai] > k:
            bestScore = _ai
            break
        else:
            _k = _k + a[_ai]
            _ai = _ai + 1

    _bi = 0

    while _bi < m:
        _k = _k + b[_bi]

        while _k > k and _ai - 1 >= 0:
            _k = _k - a[_ai - 1] 
            _ai = _ai - 1

        if _k > k:
            break

        _bi = _bi + 1

        if _ai + _bi > bestScore:
            bestScore = _ai + _bi

    return bestScore

if __name__ == "__main__":
    N, M, K = map(int, sys.stdin.readline().split(" "))
    A = list(map(int, sys.stdin.readline().split(" ")))
    B = list(map(int, sys.stdin.readline().split(" ")))

    print(main(N, M, K, A, B))

Buggy submission (verdict: Runtime Error):
import sys
from functools import reduce

def _main():
    n, m, k = map(int, sys.stdin.readline().split(" "))
    a = list(map(int, sys.stdin.readline().split(" ")))
    b = list(map(int, sys.stdin.readline().split(" ")))

    bestScore = 0
    _k = 0
    _ai = 0

    while _k < k and _ai < n:
        _k = _k + a[_ai]
        if _k > k:
            _k = _k - a[_ai]
            bestScore = _ai
            break
        _ai = _ai + 1

    _bi = 0

    while _bi < m and _ai >= 0:
        _k = _k + b[_bi]

        while _k > k and _ai >= 0:
            _k = _k - a[_ai] 
            _ai = _ai - 1

        _bi = _bi + 1

        if _k <= k and _ai + _bi > bestScore:
            bestScore = _ai + _bi

    print(bestScore)

if __name__ == "__main__":
    _main()
Problem p02859 (python)

Fixed submission:
n=int(input())
print(n*n)

Buggy submission (verdict: Runtime Error):
n=int(input())
print(r*r)
Problem p02729 (python)

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

ans = 0

if N > 1:
    ans += (N * (N - 1)) // 2
if M > 1:
    ans += (M * (M - 1)) // 2

print(ans)

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

# 各数字の個数を格納
dict = {}
for a in A:
    if a in dict:
        dict[a] += 1
    else:
        dict[a] = 1

# k番目の値を除いたlistで同じ数字を引く回数を出力
memo = {}
for k in range(N):
    ans = 0
    m = A[k]
    if m in memo.keys():
        ans = memo[m]
    else:
        dict_work = dict.copy()
        dict_work[m] -= 1
        for d in dict_work.values():
            if d > 1:
                ans += (d * (d - 1)) // 2
        memo[m] = ans
    print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print(red)
Problem p02987 (python)

Fixed submission:
S = list(input())
s = list(set(S))
ans = 'No'
if len(s) == 2:
    if S.count(s[0]) == 2:
        ans = 'Yes'

print(ans)

Buggy submission (verdict: Runtime Error):
import math

def nCr(n,r):
    f = math.factorial
    return int(f(n) / f(r) / f(n-r))

def nHk(n, k):
    f = math.factorial
    return int(f(n + k - 1) // f(k) // f(n - 1))

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

for i in range(1, K + 1):
#   print('i: ' + str(i))
    # 青玉をi個のグループに並べる並べ方
    blue = 1
#    if i == 1:
#        blue = 1
#    else:
#        blue = nCr(K - 1, i - 1)
#    print('blue: ' + str(blue))
    # 青い玉に合わせた赤い玉の並べ方
    if (N - K) < (i - 1):
        red = 0
#        print('red0: ' + str(red))
    elif i == 1:
        red = (N - K) + 1
#        print('red1: ' + str(red))
    else:
        red = nCr(K - 1, i - 1) * nHk(i + 1, N - K - (i - 1))
#        print('nCr: ' + str(nCr(K - 1, i - 1)))
#        print('nHk: ' + str(nHk(i + 1, N - K - (i - 1))))
#        print('red2: ' + str(red))

    # 解は青の並べ方と赤の並べ方の組み合わせ
    ans = blue * red % MOD
#    print(ans)
    print('ans: ' + str(ans))