Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in a:
  b[min(i//400,9)]+=1
print(8-b[:8].count(0),min(8-b[:8].count(0)+b[8],8))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in a:
  b[min(i//400,8)]+=1
print(max(8-b[:8].count(0),1),8-b[:8].count(0)+b[8])

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*9 
for i in a:
  b[i//400]+=1
print(8-b[:8].count(0),min(8-b[:8].count(0)+b[8],8))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in a:
  b[min(i//400,8)]+=1
print(max(8-b[:8].count(0),1),8-b[:8].count(0)+b[8])
Buggy python submission (verdict: Runtime Error):
s=input()
frag="yes"
for i in range(s):
  n=s.count(s[i])
  if n >1:
    frag="no"
    break
    
print(frag)

Fixed submission:
s=input()
frag="yes"
for i in range(len(s)):
  n=s.count(s[i])
  if n >1:
    frag="no"
    break
    
print(frag)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
  b=list(map(int,input()))
  a+=b

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)


Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(m):
  a+=list(map(int,input().split()))

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
  a+=list(map(int,input()))

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)


Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(m):
  a+=list(map(int,input().split()))

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

d=a%b
if c%d==0:
  frag="YES"
else:
  frag="NO"
print(frag)

Fixed submission:
a,b,c=map(int,input().split())

frag='NO'
for i in range(b-1):
  if (i+1)*a%b==c:
    frag='YES'
    break

print(frag)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
frag="EQUAL"
if a>b:
  frag="GREATER"
elif a[i]<b[i]:
  frag="LESS"
      
print(frag)

Fixed submission:
a=list(input())
b=list(input())
frag="EQUAL"
if len(a)!=len(b):
  if len(a)>len(b):
    frag="GREATER"
  else:
    frag="LESS"
else:
  for i in range(len(a)):
    if a[i]>b[i]:
      frag="GREATER"
      break
    elif a[i]<b[i]:
      frag="LESS"
      break
      
print(frag)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
if a[0]<a[1]:flag=1
elif a[0]>a[1]:flag=-1
else:flag=0
for i in range(1,n-1):
  if flag==1 and a[i]>a[i+1]:
    ans+=1
    flag=0
  elif flag==-1 and a[i]<a[i+1]:
    ans+=1
    flag=0
  else:
    if a[i]>a[i+1]:flag=-1
    elif a[i]<a[i+1]:flag=1
print(ans)

Fixed submission:
n=int(input())
if n==1:
  print(1)
  exit()
a=list(map(int,input().split()))
ans=1
if a[0]<a[1]:flag=1
elif a[0]>a[1]:flag=-1
else:flag=0
for i in range(1,n-1):
  if flag==1 and a[i]>a[i+1]:
    ans+=1
    flag=0
  elif flag==-1 and a[i]<a[i+1]:
    ans+=1
    flag=0
  else:
    if a[i]>a[i+1]:flag=-1
    elif a[i]<a[i+1]:flag=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
st=[]
for i in range(n):
  s_d=list(input())
  st.append(s_d)
cp=[]
for i in range(m):
  c_d=list(input())
  cp.append(c_d)
sc=[]
for i in range(n):
  scd=[]
  for j in range(m):
    scd_d=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
    scd.append(scd_d)
  sc.append(min(scd))
  
for i in range(n):
  print(sc[i])

Fixed submission:
n,m=map(int,input().split())
st=[]
for i in range(n):
  s_d=list(map(int,input().split()))
  st.append(s_d)
cp=[]
for i in range(m):
  c_d=list(map(int,input().split()))
  cp.append(c_d)
sc=[]
for i in range(n):
  scd=[]
  for j in range(m):
    scd_d=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
    scd.append(scd_d)
  sc.append(scd.index(min(scd))+1)
  
for i in range(n):
  print(sc[i])

Buggy python submission (verdict: Runtime Error):
n,m map(int,input().split())
st=[]
for i in range(n):
  s_d=list(input())
  st.append(s_d)
cp=[]
for i in range(m):
  c_d=list(input())
  cp.append(c_d)
sc=[]
for i in range(n):
  scd=[]
  for j in range(m):
    scd_d=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
    scd.append(scd_d)
  sc.append(min(scd))
  
for i in range(n):
  print(sc[i])

Fixed submission:
n,m=map(int,input().split())
st=[]
for i in range(n):
  s_d=list(map(int,input().split()))
  st.append(s_d)
cp=[]
for i in range(m):
  c_d=list(map(int,input().split()))
  cp.append(c_d)
sc=[]
for i in range(n):
  scd=[]
  for j in range(m):
    scd_d=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
    scd.append(scd_d)
  sc.append(scd.index(min(scd))+1)
  
for i in range(n):
  print(sc[i])
Buggy python submission (verdict: Runtime Error):
def ser(visited,now):
  visited.append(now)
  if len(visited)==n:
    return 1
  cnt=0
  for i in bri[now]:
    if i not in visited:
      cnt+= ser(visited[:],i)
  return cnt

n,m=map(int,input().split())
bri=[[] for _ in range(m)]
for i in range(m):
  a,b=map(int,input().split())
  bri[a-1].append(b-1)
  bri[b-1].append(a-1)
print(ser([],0))

Fixed submission:
def ser(visited,now):
  visited.append(now)
  if len(visited)==n:
    return 1
  cnt=0
  for i in bri[now]:
    if i not in visited:
      cnt+= ser(visited[:],i)
  return cnt

n,m=map(int,input().split())
bri=[[] for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  bri[a-1].append(b-1)
  bri[b-1].append(a-1)
print(ser([],0))
Buggy python submission (verdict: Runtime Error):
s=list(input())

a=s.index("A")
for i in range(len(s),0):
  if s[i-1]=="Z":
    z=i-1
z-=len(s)-1
sum=z-a+1
print(sum)

Fixed submission:
s=list(input())
n=len(s)
a=s.index("A")
for i in range(n,0,-1):
  if s[i-1]=='Z':
    z=i
    break
sum=z-a
print(sum)
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input())
count=0
for x in range(k+1):
  for y in range(k+1):
    if x+y>s-k:
      count +=1
print(count)

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    if x+y>=s-k and x+y<=s:
      count +=1
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p]+x
  print(sumi)
  

Fixed submission:
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]

m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p-1]+x
  print(sumi)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[]
for i range(h):
  a.append=list(map(list,input().split()))
  a.append=list(map(list,input().split()))
print(a)


Fixed submission:
h,w=map(int,input().split())

a=[]
for i in range(h):
  b=input()
  a.append(b)
  a.append(b)
for i in range(2*h):
  print(a[i])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  if t>a:
    for i in range(x-x%t,x*1000+1,t):
      if i>=x and i//t*a>=y:break
    x,y=i,i//t*a
  else:
    for i in range(y-y%a,y*1000+1,a):
      if i>=y and i//a*t>=x:break
    x,y=i//a*t,i
print(x+y)

Fixed submission:
n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  m=max((x+t-1)//t,(y+a-1)//a)
  x,y=m*t,m*a
print(x+y)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  for i in range(x-x%t,x*1000+1,t):
    if i>=x and i//t*a>=y:break
  x,y=i,i//t*a
print(x+y)
    

Fixed submission:
n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  m=max((x+t-1)//t,(y+a-1)//a)
  x,y=m*t,m*a
print(x+y)

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
n=int(input())
INF=10**18
x,y=map(int,input().split())
for _ in range(n-1):
  t,a=map(int,input().split())
  if x*a>y*t:
    i=1
    while t*i<x:
      i+=1
    x=t*i
    y=x*a//t
  else:
    i=1
    while a*i<y:
      i+=1
    y=a*i
    x=y*t//a
print(x+y)

Fixed submission:
n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  m=max((x+t-1)//t,(y+a-1)//a)
  x,y=m*t,m*a
print(x+y)
Buggy python submission (verdict: Runtime Error):
s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)):
    if a[j]==1:
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)-1,-1,-1):
    if a[j]=='1':
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)

Fixed submission:
s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)-1,-1,-1):
    if a[j]=='1':
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)
Buggy python submission (verdict: Runtime Error):
s=list(input())
flag="Yes"
while(len(s)>0):
  d=s[0]
  if s.count(d)%2==1:
    flag="No"
    break
  else:
    for i in range(s.count(d)):
      s.remove(d)
print(frag)

Fixed submission:
s=list(input())
flag="Yes"
while(len(s)>0):
  d=s[0]
  if s.count(d)%2==1:
    flag="No"
    break
  else:
    for i in range(s.count(d)):
      s.remove(d)
print(flag)
Buggy python submission (verdict: Runtime Error):
from copy import copy
n=int(input())
a=[int(input()) for _ in range(n)]
b=copy(a)
ans1=0
for i in range(n-1):
  ans1+=min(a[i],a[i+1])
  k=max(a[i]-a[i+1],0)
  a[i+1]=max(a[i+1]-a[i],0)
  a[i]=k
for i in a:
  ans1+=i//2
ans2=0
for i in range(n-1,0,-1):
  ans2+=min(b[i],b[i-1])
  k=max(b[i]-b[i-1],0)
  b[i+1]=max(b[i-1]-b[i],0)
  b[i]=k
for i in b:
  ans2+=i//2
print(max(ans1,ans2))

Fixed submission:
from copy import copy
n=int(input())
a=[0]+[int(input()) for _ in range(n)]
ans=0
for i in range(n):
  ans+=(a[i+1]+a[i])//2
  if a[i+1]:a[i+1]=(a[i+1]+a[i])%2
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
a=[]
b=""
for i in range(s):
  if s[i]=="B":
    a.pop()
  else:
    a.append(s[i])
for i in range(len(a)):
  b+=a[i]
print(b)
    

Fixed submission:
s=input()
n=len(s)
a=[]
b=""
for i in range(n):
  if s[i]=="B":
    if len(a)!=0:
      a.pop()
  else:
    a.append(s[i])
for i in range(len(a)):
  b+=a[i]
print(b)
Buggy python submission (verdict: Runtime Error):
n,l=map(int,input().split())
s=[[]]
for i in range(n):
  dumy=inout()
  s.append(dumy)
n_s=sorted(s)

b=''
for i in range(n):
  b+=n_s[i]

print(b)

Fixed submission:
n,l=map(int,input().split())
s=[]
for i in range(n):
  dumy=input()
  s.append(dumy)
n_s=sorted(s)

b=''
for i in range(n):
  b+=n_s[i]

print(b)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(a*b//euclidean(a,b))

def euclidean(a,b):
    r=a%b
    if r==0:
        return b
    return euclidean(b,r)

Fixed submission:
def euclidean(a,b):
    while True:
      r=a%b
      if r==0:
         return b
      a,b=b,r

a,b=map(int,input().split())
print(a*b//euclidean(a,b))

Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(a*b//math.gcd(a,b))

Fixed submission:
def euclidean(a,b):
    while True:
      r=a%b
      if r==0:
         return b
      a,b=b,r

a,b=map(int,input().split())
print(a*b//euclidean(a,b))
Buggy python submission (verdict: Runtime Error):
from statistics import mode
import numpy as np
N=input()
p=list(map(int,input().split()))
p=np.array(p)
q=p-np.arange(len(p-1))
q = list(q)
r = len(list(set(q)))
if sum(list(q))==2*mode(q):
    print('YES')
else:
    print('NO')
    



Fixed submission:
N=int(input())
p=list(map(int,input().split()))
q=sorted(p)
count=0
for i in range(N):
    if p[i]!=q[i]:
        count+=1
if count<=2:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
S=int(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')

Fixed submission:
S=input()
for i in range(3):
  if S[i]==S[i+1]:
    print('Bad')
    exit()
print('Good')
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
f=lambda n:n-(n//c+n//d-n//(c*d//math.gcd(c,d)))
print(f(b)-f(a-1))

Fixed submission:
import fractions 
a,b,c,d=map(int,input().split())
f=lambda n:n-(n//c+n//d-n//(c*d//fractions.gcd(c,d)))
print(f(b)-f(a-1))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
e=0
f=a%c
g=a%d
for j in range(b-a+1):
  if (f+j)%c!=0 and (g+j)%d!=0:
    e+=1
print(e)
  

Fixed submission:
import fractions 
a,b,c,d=map(int,input().split())
f=lambda n:n-(n//c+n//d-n//(c*d//fractions.gcd(c,d)))
print(f(b)-f(a-1))
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())

i=0
count=0

def exist(st):
    h = 0
    for i in range(len(st)-2):
        if st[i]=='A' and st[i+1]=='B' and st[i+2]=='C':
            h=1
    return h


while exist(s):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        s[i] ='B'
        s[i+1]='C'
        s[i+2]='A'
        count+=1
    if i==len(s)-3:
        i=0
    i+=1
print(count)

Fixed submission:
a=b=0
for s in input().replace('BC','D'):
    if s=='A':
        a+=1
    elif s=='D':
        b+=a
    else:
        a=0
print(b)
Buggy python submission (verdict: Runtime Error):
INF=1000100
dp=[INF]*(100010)
n=int(input())
h=list(map(int,input().split()))

def rec(i):
    if dp[i]<INF:return dp[i]

    if i==0:return 0

    res=INF
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    dp[i]=res
    return dp[i]

print(rec(n-1))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[1000000000]*(n)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
#ver.2 再帰メモ化
INF=1000100
dp=[INF]*(100010)
h=[0]*(100010)
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
    h.insert(i,x[i])

def rec(i):
    if dp[i]<INF:return dp[i]

    if i==0:return 0

    res=INF
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    dp[i]=res
    return dp[i]

print(rec(n-1))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[1000000000]*(n)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[n-1])

Fixed submission:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#grundy[k]:=山にk(1≤k≤K)個石がある時のgrundy数
grundy=[0]*(K+1)
#DP(動的計画法)の考えかたを用いてGrundy数を求める
for j in range(K+1):
    s=set()
    for i in range(N):
        if a[i]<=j:
            s.add(grundy[j-a[i]])
    #mex()の動作
    g=0
    while g in s:g+=1 
    grundy[j]=g
if grundy[K]:print("First")
else:print("Second")



Fixed submission:
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#DPの配列(少し余裕を持たせる)、Falseで初期化
DP=[False]*(K+10)
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            DP[i] |= ~DP[i-a[j]] # ~は否定の意味(ビット反転)
            #ORなので, 一つでもFalseがあればTrueがはいる
if DP[K]:print("First")
else: print("Second")

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=list(map(int,input().split()))
grundy=[0]*(K+1)
for j in range(K+1):
    s=set()
    for i in range(N):
        if a[i]<=j:
            s.add(grundy[j-a[i]])
        g=0
        while g in s:g+=1
        grundy[j]=g
if grundy[K]:print("First")
else:print("Second")

Fixed submission:
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#DPの配列(少し余裕を持たせる)、Falseで初期化
DP=[False]*(K+10)
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            DP[i] |= ~DP[i-a[j]] # ~は否定の意味(ビット反転)
            #ORなので, 一つでもFalseがあればTrueがはいる
if DP[K]:print("First")
else: print("Second")

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
a=list(map(int,input().split()))
grundy=[0]*(K+1)
for j in range(K+1):
    s=set()
    for i in range(N):
        if a[i]<=j:
            s.add(grundy[j-a[i]])
        g=0
        while g in s:g+=1
        grundy[j]=g
if grundy[K]:print("First")
else:print("Second")

Fixed submission:
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#DPの配列(少し余裕を持たせる)、Falseで初期化
DP=[False]*(K+10)
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            DP[i] |= ~DP[i-a[j]] # ~は否定の意味(ビット反転)
            #ORなので, 一つでもFalseがあればTrueがはいる
if DP[K]:print("First")
else: print("Second")

Buggy python submission (verdict: Time Limit Exceeded):
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#DPの配列(少し余裕を持たせる)、Falseで初期化
DP=[False]*(K+10)
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            DP[i] |= ~DP[i-a[j]] # ~は否定の意味(ビット反転)
            #ORなので, 一つでもFalseがあればTrueがはいる
if DP[K]:print("First")
else: print("Second")

Fixed submission:
#入力を受け取る
N,K=map(int,input().split())
a=list(map(int,input().split()))
#DPの配列(少し余裕を持たせる)、Falseで初期化
DP=[False]*(K+10)
for i in range(1,K+1):
    for j in range(N):
        if i-a[j]>=0:
            DP[i] |= ~DP[i-a[j]] # ~は否定の意味(ビット反転)
            #ORなので, 一つでもFalseがあればTrueがはいる
if DP[K]:print("First")
else: print("Second")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
MOD=10**9+7
def solve(N:int,K:int,A:list)->int:
    #dp[i][j]:=i人目までの子供にj個の飴を配る場合の数
    dp=[[0]*(K+1) for i in range(N+1)]
    for i in range(N):dp[i][0]=1
    sum=[0]*(K+2)
    for i in range(N):
        for j in range(K+1):#累積和
            sum[j+1]=(sum[j]+dp[i][j])%MOD
        for j in range(K+1):
            dp[i+1][j]=(sum[j+1]-sum[max(0,j-A[i])]+MOD)%MOD
            dp[i+1][j]%=MOD
    return dp[N][K]
def main(lines):
    N,K=map(int,lines[0].split())
    A=list(map(int,lines[1].split()))
    print(solve(N,K,A))
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


Fixed submission:
import sys
MOD=10**9+7
def solve(N:int,K:int,A:list)->int:
    #dp[i][j]:=i人目までの子供にj個の飴を配る場合の数
    dp=[[0]*(K+1) for i in range(N+1)]
    for i in range(N):dp[i][0]=1
    sum=[0]*(K+2)
    for i in range(N):
        for j in range(K+1):#累積和
            sum[j+1]=(sum[j]+dp[i][j])%MOD
        for j in range(K+1):
            dp[i+1][j]=(sum[j+1]-sum[max(0,j-A[i])]+MOD)%MOD
            dp[i+1][j]%=MOD
    return dp[N][K]
def main(lines):
    N,K=map(int,lines[0].split())
    A=list(map(int,lines[1].split()))
    print(solve(N,K,A))
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(len(n)):
    if n[i] == '1':
        n[i]='9'
    else:
        n[i]='1'
        print(n)
        


Fixed submission:
n = input()
print(n.translate(str.maketrans('19','91')))
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(ans, score):
  LastDay = [0]*26
  for i in range(D):
    score += s[i][ans[i]-1]
  for i in range(D):
    score += (D - i+1) * (i+1 - LastDay[ans[i]-1])*c[i]
  return score

D = I()
c = IL()
s = [IL() for i in range(D)]
ans = [I() for i in range(D)]

score = 0
for i in range(26):
  score -= D * (2*c[i] + (D - 1)*c[i])//2

print(max(0, 10**6 + tami(ans, score)))

Fixed submission:
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(date, LastDay, type, score):
  res = score
  res += s[date-1][type]
  for i in range(26):
    if i == type:
      continue
    res -= (date - LastDay[i]) *c[i]
  return res

D = I()
c = IL()
s = [IL() for i in range(D)]
ans = [I() for i in range(D)]

LastDay = [0]*26
score = 0
for d in range(D):
  score = tami(d+1, LastDay, ans[d]-1, score)
  LastDay[ans[d]-1] = d+1
  print(score)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M,K = IL()
a = IL()
b = IL()

ans = 0
tmp2 = 0
for j in range(M):
  tmp2 += b[j]
  if tmp2 > K:
    ans = j
    break
else:
  ans = M

tmp = 0
for i in range(N):
  cnt = i+1
  tmp += a[i]
  time = tmp
  if time > K:
    break
  else:
    nokori = K - time
    tmp2 = 0
    for j in range(M):
      tmp2 += b[j]
      if nokori < tmp2:
        cnt += j
        break
    else:
      cnt += M
  ans = max(ans, cnt)
print(ans)

Fixed submission:
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M,K = IL()
a = IL()
b = IL()

ruia = [0]
for i in range(N):
  ruia.append(ruia[-1] + a[i])

ruib = [0]
for i in range(M):
  ruib.append(ruib[-1] + b[i])

r = N
l = 0
ans = 0
for l in range(M+1):
  while ruia[r] + ruib[l] > K:
    r -= 1
    if r == -1:
      break  
  cnt = r+l
  ans = max(ans, cnt)
  if r == -1:
    break
print(ans)