Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split(' '))

if a + b == c:
    print('Yes')
    return
elif a + c == b:
    print('Yes')
    return
elif b + c == a:
    print('Yes')
    return
else:
    print('No')
    return

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

if a + b == c:
    print('Yes')

elif a + c == b:
    print('Yes')

elif b + c == a:
    print('Yes')

else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import re

s = input()

if re.match(r'C.*F', s):
    print(YES)
else:
    print(NO)

Fixed submission:
import re

s = input()

if re.match(r'.*C.*F', s):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import re


if re.match(r'C.*F', s):
    print(YES)
else:
    print(NO)

Fixed submission:
import re

s = input()

if re.match(r'.*C.*F', s):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
if re.match(r'C.*F', s):
    print(YES)
else:
    print(NO)

Fixed submission:
import re

s = input()

if re.match(r'.*C.*F', s):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=1
for i in range(k):
    ans=l[i]*ans

for i in range(k,n):
    prevans=ans
    ans=(ans*l[i])//l[i-k]
    if ans>prevans:
        print("Yes")
    else:
        print("No")




Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=1
for i in range(k):
    ans=l[i]

for i in range(k,n):
    prevans=l[i-k]
    ans=l[i]
    if ans>prevans:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
dummy=len(arr)
ans=0
if dummy>2:
  for i in range(dummy-2):
      for j in range(i+1,dummy-1):
          for k in range(j+1,dummy):
              if arr[i]!=arr[j] and arr[j]!=arr[k] and arr[k]!=arr[i]:
                  if arr[i]<arr[j]+arr[k] and arr[j]<arr[k]+arr[i] and arr[k]<arr[j]+arr[i]:
                      ans+=1
	print(ans)
else:
  print(0)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
dummy=len(arr)
ans=0
if dummy>2:
    for i in range(dummy-2):
        for j in range(i+1,dummy-1):
            for k in range(j+1,dummy):
                if arr[i]!=arr[j] and arr[j]!=arr[k] and arr[k]!=arr[i]:
                    if arr[i]<arr[j]+arr[k] and arr[j]<arr[k]+arr[i] and arr[k]<arr[j]+arr[i]:
                        ans+=1
    print(ans)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
Ls= list(map(int, input().split()))
count=0
for i in range(len(N)):
  for j in range(i,len(N)):
    for k in range(j,len(N)):
      tmp=[Ls[i],Ls[j],Ls[k]]
      if sum(tmp) < 2 * max(tmp):
        count+=1

print(count)
      

Fixed submission:
N = int(input())
L= list(map(int, input().split()))
Ls = list(set(L))
res=[]
for i in range(len(Ls)):
  for j in range(i+1,len(Ls)):
    for k in range(j+1,len(Ls)):
      tmp=[Ls[i],Ls[j],Ls[k]]
      if sum(tmp) > 2*max(tmp):
        res.append(tmp)
        
c=0
for i in range(len(res)):
  ctmp=L.count(res[i][0])*L.count(res[i][1])*L.count(res[i][2])
  c+=ctmp
print(c)
Buggy python submission (verdict: Runtime Error):
L=input().split()
A,B,C=int(L[0]),int(L[1]),int(L[2])
X=set([5,7])
ans = []
for i in range(len(X)):
    ans.append([A,B,C].count(X[i]))
if ans == [2,1]:
  print("YES")
else:
  print("NO")


Fixed submission:
L=input().split()
A,B,C=int(L[0]),int(L[1]),int(L[2])
X=[5,7]
ans = []
for i in range(len(X)):
    ans.append([A,B,C].count(X[i]))
if ans == [2,1]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
if int(input())>29:
  print(Yes)
else:
  print(No)

Fixed submission:
if int(input())>29:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[0]*(N+1)
for i in range(N):
    if i*i>N:
        to=i+1
        break
for x in range(1,to):
    for y in range(1,to):
        for z in range(1,to):
            temp=x*x+y*y+z*z+x*y+y*z+z*x
            if temp<N:
                ans[temp]+=1
for i in range(1,N+1):
    print(ans[i])

Fixed submission:
N=int(input())
ans=[0]*(N+1)
to=int((N)**(1/2))+2
for x in range(1,to):
    for y in range(1,to):
        for z in range(1,to):
            temp=x*x+y*y+z*z+x*y+y*z+z*x
            if temp<=N:
                ans[temp]+=1
for i in range(1,N+1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
def popcount(n):
    ans=0
    for i in range(20):
        if n>>i & 1:
            ans+=1
    return ans

N=int(input())
X=input()
n=0

for i in range(N):
    if X[i]=='1':
        n+=1
np1=0
nm1=0
temp1=1
temp2=1
for i in range(N-1,-1,-1):
    if X[i]=='1':
        np1=(np1+temp1)%(n+1)
        nm1=(nm1+temp2)%(n-1)
    temp1=(temp1*2)%(n+1)
    temp2=(temp2*2)%(n-1)
    
for i in range(N):
    ans=1
    if X[i]=='1':
        temp=(nm1-pow(2,(N-1-i),n-1))%(n-1)
        while temp>0:
            pop_n=popcount(temp)
            temp=temp%pop_n
            ans+=1
    elif X[i]=='0':
        temp=(np1+pow(2,(N-1-i),n+1))%(n+1)
        while temp>0:
            pop_n=popcount(temp)
            temp=temp%pop_n
            ans+=1
    print(ans)

Fixed submission:
def popcount(n):
    ans=0
    for i in range(20):
        if n>>i & 1:
            ans+=1
    return ans

N=int(input())
X=input()
n=0

for i in range(N):
    if X[i]=='1':
        n+=1
np1=0
nm1=0
temp1=1
temp2=1
nm=n-1
if nm==0:
    nm=1
for i in range(N-1,-1,-1):
    if X[i]=='1':
        np1=(np1+temp1)%(n+1)
        nm1=(nm1+temp2)%nm
    temp1=(temp1*2)%(n+1)
    temp2=(temp2*2)%nm
    
for i in range(N):
    ans=1
    if X[i]=='1':
        if n==1:
            print(0)
            continue
        temp=(nm1-pow(2,(N-1-i),n-1))%(n-1)
        while temp>0:
            pop_n=popcount(temp)
            temp=temp%pop_n
            ans+=1
    elif X[i]=='0':
        temp=(np1+pow(2,(N-1-i),n+1))%(n+1)
        while temp>0:
            pop_n=popcount(temp)
            temp=temp%pop_n
            ans+=1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,S=map(int,input().split())
A=list(map(int,input().split()))
MOD=998244353

dp=[0]*(S+1)
dp[0]=pow(2,N,MOD)
div=pow(2,MOD-2,MOD)

m=0
for a in A:
    m+=a
    for i in range(min(m,S),a-1,-1):
        dp[i]=(dp[i]+dp[i-a]*div)%MOD
print(dp[S])

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

def f(N,S,A):
    MOD=998244353
    dp=[0]*(S+1)
    dp[0]=pow(2,N,MOD)
    div=pow(2,MOD-2,MOD)
    m=0
    for a in A:
        m+=a
        for i in range(min(m,S),a-1,-1):
            dp[i]=(dp[i]+dp[i-a]*div)%MOD
    return dp[S]

print(f(N,S,A))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(5000)
MOD=998244353
def dfs(d,tot,num):
    global A,N,S,how
    if tot==S:
        how[num]+=1
        return
    if d==N:
        return
    if d>0 and A[d]==A[d-1]:
    if tot+A[d]<=S:
        dfs(d+1,tot+A[d],num+1)
        dfs(d+1,tot,num)
        
    

N,S=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
how=[0]*(N+1)
dfs(0,0,0)
cur=1
res=0
for i in range(N,0,-1):
    res+=(how[i]*cur)%MOD
    cur=cur*2%MOD
print(res)

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

def f(N,S,A):
    MOD=998244353
    dp=[0]*(S+1)
    dp[0]=pow(2,N,MOD)
    div=pow(2,MOD-2,MOD)
    m=0
    for a in A:
        m+=a
        for i in range(min(m,S),a-1,-1):
            dp[i]=(dp[i]+dp[i-a]*div)%MOD
    return dp[S]

print(f(N,S,A))

Buggy python submission (verdict: Runtime Error):
def dfs(d,tot,num):
    global A,N,S,how
    if tot==S:
        how[num]+=1
        return
    if d==N:
        return
    if tot+A[d]<=S:
        dfs(d+1,tot+A[d],num+1)
    dfs(d+1,tot,num)
        
    

N,S=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
how=[0]*(N+1)
dfs(0,0,0)
cur=1
res=0
for i in range(N,0,-1):
    res+=how[i]*cur
    cur*=2
print(res)

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

def f(N,S,A):
    MOD=998244353
    dp=[0]*(S+1)
    dp[0]=pow(2,N,MOD)
    div=pow(2,MOD-2,MOD)
    m=0
    for a in A:
        m+=a
        for i in range(min(m,S),a-1,-1):
            dp[i]=(dp[i]+dp[i-a]*div)%MOD
    return dp[S]

print(f(N,S,A))
Buggy python submission (verdict: Runtime Error):
def dfs_a(N,v,adjlist,cur):
    global depth_a
    depth_a[v]=cur
    for node in adjlist[v]:
        if depth_a[node]<0:
            dfs_a(N,node,adjlist,cur+1)
def dfs_t(N,v,adjlist,cur):
    global depth_t
    depth_t[v]=cur
    for node in adjlist[v]:
        if depth_t[node]<0:
            dfs_t(N,node,adjlist,cur+1)
    
    
    

from collections import deque

N,u,v=map(int,input().split())
adjlist=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    adjlist[a-1].append(b-1)
    adjlist[b-1].append(a-1)
depth_a=[-1]*N
depth_t=[-1]*N
dfs_a(N,v-1,adjlist,0)
dfs_t(N,u-1,adjlist,0)
M=0
for i in range(N):
    if depth_a[i]>depth_t[i]:
        curm=depth_a[i]-1
        if curm>M:
            M=curm
print(M)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def dfs_a(N,v,adjlist,cur):
    global depth_a
    depth_a[v]=cur
    for node in adjlist[v]:
        if depth_a[node]<0:
            dfs_a(N,node,adjlist,cur+1)
def dfs_t(N,v,adjlist,cur):
    global depth_t
    depth_t[v]=cur
    for node in adjlist[v]:
        if depth_t[node]<0:
            dfs_t(N,node,adjlist,cur+1)
    
    
    

from collections import deque

N,u,v=map(int,input().split())
adjlist=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    adjlist[a-1].append(b-1)
    adjlist[b-1].append(a-1)
depth_a=[-1]*N
depth_t=[-1]*N
dfs_a(N,v-1,adjlist,0)
dfs_t(N,u-1,adjlist,0)
M=0
for i in range(N):
    if depth_a[i]>depth_t[i]:
        curm=depth_a[i]-1
        if curm>M:
            M=curm
print(M)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    print(divide(k,i)*comb(n-k+1,i)%1000000007)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    if i-1 <= n-k:
        print(divide(k,i)*comb(n-k+1,i)%1000000007)
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    print(divide(k,i)*comb(n-k+1,i)%1000000007)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    if i-1 <= n-k:
        print(divide(k,i)*comb(n-k+1,i)%1000000007)
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    print(divide(k,i)*comb(n-k+1,i)%1000000007)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    if i-1 <= n-k:
        print(divide(k,i)*comb(n-k+1,i)%1000000007)
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
visited = [[False,False,False] for _ in range(n)]
ren = [[0]*n for _ in range(n)]
for i in range(m):
    u,v = map(int,input().split())
    ren[u-1][v-1] = 1
s,t = map(int,input().split())

Q = [(s,0)]
visited[s-1][2]=True
ans = -1

while len(Q)>0:
    curs,curcount = Q.pop(0)
    if curs == t:
        ans = curcount
        break
    for i in range(n):
        if ren[curs-1][i] and not visited[i][0]:
            visited[i][0]=True
            for j in range(n):
                if ren[i][j] and not visited[j][1]:
                    visited[j][1]=True
                    for k in range(n):
                        if ren[j][k] and not visited[k][2]:
                            visited[k][2]=True
                            Q.append((k+1,curcount+1))

print(ans)

Fixed submission:
n,m=map(int,input().split())
visited = [[False,False,False] for _ in range(n)]
ren = [[] for _ in range(n)]
for i in range(m):
    u,v = map(int,input().split())
    ren[u-1].append(v)
s,t = map(int,input().split())

Q = [(s,0)]
visited[s-1][2]=True
ans = -1

while len(Q)>0:
    curs,curcount = Q.pop(0)
    if curs == t:
        ans = curcount
        break
    for i in ren[curs-1]:
        if not visited[i-1][0]:
            visited[i-1][0]=True
            for j in ren[i-1]:
                if not visited[j-1][1]:
                    visited[j-1][1]=True
                    for k in ren[j-1]:
                        if not visited[k-1][2]:
                            visited[k-1][2]=True
                            Q.append((k,curcount+1))

print(ans)
Buggy python submission (verdict: Runtime Error):
lis = [1,1,2]
def num(n):
    if len(lis) >= n+1:
        return lis[n]
    else:
        res = num(n-2) + num(n-1)
        lis.append(res)
        return res

N,M = map(int,input().split())
count = 1
pre = 0
for i in range(M+1):
    if i == M:
        cur = N+1
    else:
        cur = int(input())
    number = cur-1-pre
    if number >= 0:
        count = count * num(number) % 1000000007
    else:
        count = 0
        break
    pre = cur + 1
print(count%1000000007)    

Fixed submission:
import sys
sys.setrecursionlimit(200000)

lis = [1,1,2]
def num(n):
    if len(lis) >= n+1:
        return lis[n]
    else:
        res = num(n-2) + num(n-1)
        lis.append(res)
        return res

N,M = map(int,input().split())
count = 1
pre = 0
for i in range(M+1):
    if i == M:
        cur = N+1
    else:
        cur = int(input())
    number = cur-1-pre
    if number >= 0:
        count = count * num(number) % 1000000007
    else:
        count = 0
        break
    pre = cur + 1
print(count%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
x = list(reversed(input()))
cur = 1
for i in range(len(x)):
    if x[i]=="1":
        cur = cur*2 + 3**i
print(cur%1000000007)

Fixed submission:
L = input()
waru = 1000000007
lis1 = 1
lis2 = 2
for i in range(1,len(L)):
    if L[i] == "0":
        lis1 = (lis1*3) % waru
        lis2 = lis2 % waru
    elif L[i] == "1":
        lis1 = (lis1*3+lis2) % waru
        lis2 = (lis2*2) % waru

print((lis1+lis2) % waru)

Buggy python submission (verdict: Time Limit Exceeded):
def ni(n):
    return 3 ** n

def r(x):
    if x=="1":
        return 3
    elif x == "0":
        return 1
    lenx = len(x)
    cur = ni(lenx-1)
    for i in range(1,lenx):
        if x[i] == "1":
            cur += r(x[i:])*2
            break
        elif i == lenx-1:
            cur += 2
    return cur

n = input()
print(r(n)%1000000007)

Fixed submission:
L = input()
waru = 1000000007
lis1 = 1
lis2 = 2
for i in range(1,len(L)):
    if L[i] == "0":
        lis1 = (lis1*3) % waru
        lis2 = lis2 % waru
    elif L[i] == "1":
        lis1 = (lis1*3+lis2) % waru
        lis2 = (lis2*2) % waru

print((lis1+lis2) % waru)
Buggy python submission (verdict: Runtime Error):
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            if dp[j]>=0:
                dp[j+cur_w]=max(dp[j+cur_w],dp[j]+cur_v)
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

Fixed submission:
def solve(N,h):
    dp=[0]*N
    dp[1]=abs(h[1]-h[0])
    for i in range(2,N):
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    return dp[N-1]

N=int(input())
h=list(map(int,input().split()))
print(solve(N,h))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            if dp[j]>=0:
                dp[j+cur_w]=max(dp[j+cur_w],dp[j]+cur_v)
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

Fixed submission:
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            if dp[j]==-1:
                continue
            if dp[j+cur_w]<dp[j]+cur_v:
                dp[j+cur_w]=dp[j]+cur_v
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

Buggy python submission (verdict: Time Limit Exceeded):
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            dp[j+cur_w]=max(dp[j+cur_w],dp[j]+cur_v)
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

Fixed submission:
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            if dp[j]==-1:
                continue
            if dp[j+cur_w]<dp[j]+cur_v:
                dp[j+cur_w]=dp[j]+cur_v
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

Buggy python submission (verdict: Time Limit Exceeded):
def solve(N,W,wv):
    dp=[[-1]*(W+1) for _ in range(N+1)]
    dp[0][0]=0
    for i in range(0,N):
        for j in range(W):
            cur_w=wv[i][0]
            cur_v=wv[i][1]
            if dp[i][j]>=0:
                dp[i+1][j]=max(dp[i+1][j],dp[i][j])
                if j+cur_w<=W:
                    dp[i+1][j+cur_w]=max(dp[i+1][j+cur_w],dp[i][j]+cur_v)
    ans=0
    for j in range(W+1):
        if ans < dp[N][j]:
            ans=dp[N][j]
    return ans
            


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))

Fixed submission:
def solve(N,W,wv):
    dp=[-1]*(W+1)
    dp[0]=0
    for i in range(N):
        cur_w=wv[i][0]
        cur_v=wv[i][1]
        for j in range(W-cur_w,-1,-1):
            if dp[j]==-1:
                continue
            if dp[j+cur_w]<dp[j]+cur_v:
                dp[j+cur_w]=dp[j]+cur_v
    return max(dp)


N,W=map(int,input().split())
wv=tuple(tuple(map(int,input().split())) for _ in range(N))
print(solve(N,W,wv))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
canB=[0]*N
canC=[0]*N
p1=0
p2=0
total=0
for j in range(N):
    c=C[j]
    while p2<N and B[p2]<c:
        while p1<N and A[p1]<B[p2]:
            canB[p2]+=1
            p1+=1
        p2+=1
        if p2<N:
            canB[p2]=canB[p2-1]
    canC[j]=sum(canB[:p2])
print(sum(canC))

Fixed submission:
import bisect
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
total=0
for j in range(N):
    b=B[j]
    p_a=bisect.bisect_left(A,b)
    p_b=bisect.bisect_right(C,b)
    total+=p_a*(N-p_b)
print(total)
Buggy python submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
ans = 0
if X<0:
  X = (-1)*X
  
if X-K*D >=0:
  ans = X-K*D
else:
  Y = int(X/D)
  z = X%D
  if (K-Y)%2=0:
    ans = Z
  if (K-Y)%2=1:
    ans = D-Z
if ans<0:
  ans = (-1)*ans
print(ans)
  


Fixed submission:
X,K,D = map(int,input().split())
ans = 0
if X<0:
  X = (-1)*X
  
if X-K*D >=0:
  ans = X-K*D
else:
  Y = int(X/D)
  Z = X%D
  if (K-Y)%2==0:
    ans = Z
  if (K-Y)%2==1:
    ans = D-Z
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
judge = 0
for i in range(len(S)):
  if S[i] !== T[i]:
    judge = 1
    break
if judge == 1:
  print("No")
else:
  print("Yes")


Fixed submission:
S = input()
T = input()
judge = 0
for i in range(len(S)):
  if S[i] != T[i]:
    judge = 1
    break
if judge == 1:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
  print(A.count(i+1))
  

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans =[0]*N
for i in A:
  ans[i-1] += 1
for i in range(N):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
N = input()
judge = "No"
for i in 3:
  if N[i] == 7:
    judge = "Yes"
    break
print(judge)

Fixed submission:
N = input()
judge = "No"
for i in N:
  if i == "7":
    judge = "Yes"
    break
print(judge)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
count = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      count += gcd(i,j,k)
print(count)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
count = 0
for i in range(1,K-1):
  for j in range(i+1,K):
    for k in range(j+1,K+1):
      count += 6*(gcd(i,j,k))
      
for i in range(1,K):
  for j in range(i+1,K+1):
    count += 6*(gcd(i,j))

for i in range(1,K+1):
  count += i
      
print(count)
Buggy python submission (verdict: Runtime Error):
A,B = int(input().split())
count = 0
for i in range(A,B+1):
  if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
    count += 1
print(count)

Fixed submission:
A,B = map(int,input().split())
count = 0
for i in range(A,B+1):
  if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input().split()
A.sort()
B = A[0::1]
b = sum(B)
C = A[1::1]
c = sum(C)
if b >= c:
  print(b-c)
else:
  print(c-b)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
B = A[0::2]
b = sum(B)
C = A[1::2]
c = sum(C)
if b >= c:
  print(b-c)
else:
  print(c-b)