Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
readline=sys.stdin.readline
read=sys.stdin.read

n,c,*stc=map(int,read())
m=2*10**5
cht=np.zeros((c,m+1),dtype='int64')
for s,t,c in zip(*[iter(stc)]*3):
  cht[c-1,2*t-1:2*s]=np.ones(2*t-2*s+1)
print(max(np.sum(cht,axis=0)))


Fixed submission:
import sys
readline=sys.stdin.readline
read=sys.stdin.read

n,c=map(int,readline().split())
m=2*10**5
stc=[list(map(int,l.split())) for l in read().splitlines()]
cht=[[0]*(m+1) for _ in range(c)]
for e in stc:
  cht[e[2]-1][2*e[0]-1:2*e[1]]=[1 for _ in range(2*e[1]-2*e[0]+1)]
mnr=0
for i in range(1,m+1):
  mnr=max(mnr,sum(cht[ch][i] for ch in range(c)))
print(mnr)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
readline=sys.stdin.readline
read=sys.stdin.read

n,c=map(int,readline().split())
m=2*10**5
stc=[list(map(int,l.split())) for l in read().splitlines()]
cht=np.array([])
for e in stc:
  w=e[1]-e[0]
  cht.vstack((cht,np.pad(np.ones(2*(e[1]-e[0])+1),(2*e[0]-1,m-2*e[1]),\
                mode='constant',constant_values=(1,1))))
mnr=0
for i in range(1,m+1):
  mnr=max(mnr,sum(cht[ch][i] for ch in range(c)))
print(mnr)


Fixed submission:
import sys
readline=sys.stdin.readline
read=sys.stdin.read

n,c=map(int,readline().split())
m=2*10**5
stc=[list(map(int,l.split())) for l in read().splitlines()]
cht=[[0]*(m+1) for _ in range(c)]
for e in stc:
  cht[e[2]-1][2*e[0]-1:2*e[1]]=[1 for _ in range(2*e[1]-2*e[0]+1)]
mnr=0
for i in range(1,m+1):
  mnr=max(mnr,sum(cht[ch][i] for ch in range(c)))
print(mnr)
Buggy python submission (verdict: Runtime Error):
print(['<','=','>'][min(2,max(0,1+int('0x'+input())-int('0x'+input())))a,b=input().split()
print(['<','=','>'][min(2,max(0,1+int(a,16)-int(b,16)))])

Fixed submission:
a,b=input().split()
print(['<','=','>'][min(2,max(0,1+int(a,16)-int(b,16)))])
Buggy python submission (verdict: Runtime Error):
for x,y in zip(input(),reversed(input)):
  if x!=y:
    print('NO')
    break
else:
  print('YES')


Fixed submission:
for x,y in zip(input(),reversed(input())):
  if x!=y:
    print('NO')
    break
else:
  print('YES')
Buggy python submission (verdict: Runtime Error):
for x in range(int(input())):
  if x**2>n:
    print(x-1)
    break

Fixed submission:
n=int(input())
for x in range(10**5):
  if x**2>n:
    print((x-1)**2)
    break
Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect_right
read=sys.stdin.read
readline=sys.stdin.readline

def main():
    n=int(readline())
    a,b,c=(list(map(int,lst.split())) for lst in read().splitlines())
    a.sort()
    b.sort()
    c=[-x for x in c]
    c.sort()
    print(sum(bisect_right(x,a)*bisect_right(-x,c) for x in b))

if __name__=='__main__':
    main()
      
      


Fixed submission:

import sys
from heapq import heapify,heappop,heappush
from collections import defaultdict
read=sys.stdin.read
readline=sys.stdin.readline

def main():
    n=int(readline())
    a,b,c=(list(map(int,lst.split())) for lst in read().splitlines())
    a.sort()
    b.sort()
    c=[-x for x in c]
    c.sort()

    def bise(x,lst):
        left=0
        right=len(lst)
        while right-left>0:
            mid=(right+left)//2
            if lst[mid]>=x:
                right=mid
            else:
                left=mid+1
        return left
    print(sum(bise(x,a)*bise(-x,c) for x in b))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
r,g=map(int,input().split())
print(2*g-r)

Fixed submission:
r=int(input())
g=int(input())
print(2*g-r)
Buggy python submission (verdict: Runtime Error):
import sys
readline=sys.stdin.readline
read=sys.stdin.read

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1
    ans=0
    for i in range(ek):
        if k>>i&1:
            m=(k>>(i+1))<<(i+1)|((1<<i)-1)
            ans=max(ans,sum([e[1] for e in ab if e[0]|m==m]))
    ans=max(ans,sum([e[1] for e in ab if e[0]|k==k]))
    print(max(cand))

if __name__=='__main__':
    main()


Fixed submission:
import sys
readline=sys.stdin.readline
read=sys.stdin.read

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1

    cand=[]
    for i in range(ek):
        if k>>i&1:
            m=(k>>(i+1))<<(i+1)|((1<<i)-1)
            cand.append(sum([e[1] for e in ab if e[0]|m==m]))
    cand.append(sum([e[1] for e in ab if e[0]|k==k]))
    print(max(cand))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
read=sys.stdin.read

n,a=map(int,read().spliitlines())

print(n**2-a)

Fixed submission:
import sys
read=sys.stdin.read

n,a=map(int,read().splitlines())

print(n**2-a)
Buggy python submission (verdict: Runtime Error):
import sys
read=sys.stdin.read
readline=sys.stdin.readline

a,b,c,d,e,f=map(int,readline().split())

def searints(m,n,l):#m<=n
  mask=(1<<l+1)-1
  s=sum([1<<n*i for i in range(1,l//n+1)])&mask
  for i in range(1,l//m+1):
    s=(s+1<<m*i|s) &mask
  return [x for x in range(0,l+1) if ((s+1)>>x)&1==1]

w=searints(100*a,100*b,f)
s=searints(c,d,f)
candidates=[(100*y/(x+y),x+y,y) for x in w for y in s if e*x>=100*y and x*y>0 and x+y<=f]
print(*max(candidates)[1:])

Fixed submission:
import sys
read=sys.stdin.read
readline=sys.stdin.readline

a,b,c,d,e,f=map(int,readline().split())

def searints(m,n,l):#m<=n
  mask=(1<<l+1)-1
  s=sum([1<<n*i for i in range(1,l//n+1)])&mask
  for i in range(1,l//m+1):
    s=(s+1<<m*i|s) &mask
  return [x for x in range(0,l+1) if ((s+1)>>x)&1==1]

w=searints(100*a,100*b,f)
s=searints(c,d,f)
candidates=[(100*y/(x+y),x+y,y) for x in w for y in s if e*x>=100*y and x*y>0 and x+y<=f]
if candidates:
  print(*max(candidates)[1:])
else:
  print(100*a,0)
Buggy python submission (verdict: Runtime Error):
N=int(input())
print(['No','Yes'][9 in [N%10, (N-N%10)//10]]

Fixed submission:
N=int(input())
print(['No','Yes'][9 in [N%10, (N-N%10)//10]])
Buggy python submission (verdict: Runtime Error):
N=int(input())
lr=[list(map(int,input())) for _ in range(N)]
print(sum([e[1]-e[0]+1 for e in lr]))


Fixed submission:
N=int(input())
lr=[list(map(int,input().split())) for _ in range(N)]
print(sum([e[1]-e[0]+1 for e in lr]))

Buggy python submission (verdict: Runtime Error):
N=int(input())
lr=[list(map(int,input())) for _ in range(N)]
print(sum([e[1]-e[0]+1 for e in lr])

Fixed submission:
N=int(input())
lr=[list(map(int,input().split())) for _ in range(N)]
print(sum([e[1]-e[0]+1 for e in lr]))
Buggy python submission (verdict: Runtime Error):
import sys
readline=sys.stdin.readline

n=int(readline().strip())
a=[int(readline().strip()) for _  in range(n)]
l=[0]*(max(a)+1)
for x in a:
  l[x]^=1
print(sum(l))


Fixed submission:
import sys
from collections import Counter
read=sys.stdin.read

n,*a=map(int,read().split())
x=Counter(a)
print(sum(list(map(lambda n:n%2, list(x.values())))))

Buggy python submission (verdict: Runtime Error):
import sys
read=sys.stdin.read

n,*a=map(int,read().split())
l=[0]*(max(a)+1)
for x in a:
  l[x]^=1
print(sum(l))

Fixed submission:
import sys
from collections import Counter
read=sys.stdin.read

n,*a=map(int,read().split())
x=Counter(a)
print(sum(list(map(lambda n:n%2, list(x.values())))))

Buggy python submission (verdict: Runtime Error):
import sys
read=sys.stdin.read

n,*a=map(int,read().split())
l=[0]*max(a)
for i in a:
  l[a]^=1
print(sum(l))


Fixed submission:
import sys
from collections import Counter
read=sys.stdin.read

n,*a=map(int,read().split())
x=Counter(a)
print(sum(list(map(lambda n:n%2, list(x.values())))))
Buggy python submission (verdict: Runtime Error):
import sys
from string import ascii_lowercase as aplhabets
from collections import defaultdict

readline=sys.stdin.readline

s=readline().split()
d=defautdict(int)
for x in s:
  d[x]=1
for a in alphabets:
  if d[a]==0:
    print(a)
    sys.exit()
print('None')


Fixed submission:
import sys
from string import ascii_lowercase as alphabets
from collections import defaultdict

readline=sys.stdin.readline

s=readline().strip()
d=defaultdict(int)
for x in s:
  d[x]=1
for a in alphabets:
  if d[a]==0:
    print(a)
    sys.exit()
print('None')

Buggy python submission (verdict: Runtime Error):
import sys
from string import ascii_lowercase as aplhabets
from collections import defaultdict

readline=sys.stdin.readline

s=readline().split()
d=defautdict(int)
for x in s:
  d[x]=1
for a in alphabets:
  if d[a]=0:
    print(a)
    sys.exit()
print('None')

Fixed submission:
import sys
from string import ascii_lowercase as alphabets
from collections import defaultdict

readline=sys.stdin.readline

s=readline().strip()
d=defaultdict(int)
for x in s:
  d[x]=1
for a in alphabets:
  if d[a]==0:
    print(a)
    sys.exit()
print('None')
Buggy python submission (verdict: Runtime Error):
import sys

n,*a=map(int,sys.stdin.read())

a.sort(reverse=True)
c=0
f=0
ans=[]
for i in range(n-1):
  if a[i]==a[i+1]:
    c+=1
    f+=1
    ans.append(a[i])
  else:
    f=0
  if (c==2 and f==1) or (c==3 and f==2):
    print(ans[0]*ans[1])
    sys.exit()
print(0)
  
  

Fixed submission:
import sys

n,*a=map(int,sys.stdin.read().split())

a.sort(reverse=True)
c=0
f=0
ans=[]
for i in range(n-1):
  if a[i]==a[i+1]:
    c+=1
    f+=1
    ans.append(a[i])
  else:
    f=0
  if (c>1 and f==1) or (c>2 and f==3):
    print(ans[0]*ans[-1])
    sys.exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

n,m=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(m)]
d=defaultdict(int)
for x in s:
  d[x[0]]|=(1<<x[1])
  d[x[1]]|=(1<<x[0])
if d[1]&d[n]>0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')


Fixed submission:
import sys
from collections import defaultdict
from heapq import heapify, heappush
n,m=map(int,input().split())
s=[tuple(map(int,input().split())) for _ in range(m)]
def hl():
  ret=[]
  heapify(ret)
  return ret
d=defaultdict(hl)
for x in s:
  heappush(d[x[0]],-x[1])
  heappush(d[x[1]],-x[0])
for e in d[1]:
  if d[-e][0]==-n:
    print('POSSIBLE')
    sys.exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
from collections import deque, defaultdict

def main():
  n=int(input())
  edges=[tuple(map(int,input().split())) for _ in range(n-1)]
  d=defaultdict(list)
  for e in edges:
    d[e[0]].append(e[1])
    d[e[1]].append(e[0])
  def dist(m):
    dl=[-1]*(n+1)
    cv=deque([m])
    nv=deque([1])
    while nv:
      c+=1
      cv.extend(nv)
      nv.clear()
      for e in cv:
        dl[e]=c
        for x in d[e]:
          if dl[x]<0:
            nv.append(x)
      cv.clear()
    return dl[1:]
  fnc=dist(1)
  snk=dist(n)
  j=sum([(fnc[i]<=snk[i])-(fnc[i]>snk[i]) for i in range(n)])
  if j>0:
    print('Fennec')
  else:
    print('Snuke')

if __name__=='__main__':
    main()


Fixed submission:
import sys
from collections import defaultdict
from collections import deque

n=int(input())
edges=[tuple(map(int,input().split())) for _ in range(n-1)]
d=defaultdict(list)
for e in edges:
  d[e[0]].append(e[1])
  d[e[1]].append(e[0])
fnc=[-1]*(n+1)
snk=[-1]*(n+1)
fnc[1]=0
snk[n]=0
cv=deque([1])
nv=deque([1])
c=-1
while nv:
  c+=1
  cv.extend(nv)
  nv.clear()
  for e in cv:
    fnc[e]=c
    for x in d[e]:
      if fnc[x]<0:
        nv.append(x)
  cv.clear()
cv.append(n)
nv=deque([1])
c=-1
while nv:
  c+=1
  cv.extend(nv)
  nv.clear()
  for e in cv:
    snk[e]=c
    for x in d[e]:
      if snk[x]<0:
        nv.append(x)
  cv.clear()

j=sum([(fnc[i]<=snk[i])-(fnc[i]>snk[i]) for i in range(1,n+1)])
if j>0:
  print('Fennec')
else:
  print('Snuke')
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)//2

for x in range(1,n):
  if s[:n-i]==s[n-i:2*n-2*i]:
    print(2*n-2*i)
    break

Fixed submission:
s=input()
n=len(s)//2
 
for i in range(1,n):
  if s[:n-i]==s[n-i:2*n-2*i]:
    print(2*n-2*i)
    break
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=[]

for i in range(n):
  if (n-i)%2==0:
    b.append(a[i])
  else:
    b=[a[i]]+b
print(' '.join(b))


Fixed submission:
import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=deque()

for i in range(n):
  if (n-i)%2==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
print(' '.join(b))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=[]

for i in range(n):
  if (n-i)%2==0:
    b.append(a[i])
  else:
    b.insert(0,a[i])
print(' '.join(b))


Fixed submission:
import sys
from collections import deque
finput=lambda: sys.stdin.readline().strip()

n=int(finput())
a=finput().split()
b=deque()

for i in range(n):
  if (n-i)%2==0:
    b.append(a[i])
  else:
    b.appendleft(a[i])
print(' '.join(b))
Buggy python submission (verdict: Runtime Error):

def main():
  p=10**9+7
  def modpfac(n):
    ret=1
    for i in range(1,n+1):
      ret*=i % p
    return ret
  n,m=map(int,input().split())
  if abs(m-n)>1:
    return print(0)
  elif abs(m-n)=1:
    return print(modpfac(n)*modpfac(m)%p)
  else:
    return print(2*modpfac(n)*modpfac(m)%p)

main()
  


Fixed submission:
def main():
  p=10**9+7
  def modpfac(n):
    ret=1
    for i in range(1,n+1):
      ret=ret*i % p
    return ret
  n,m=map(int,input().split())
  if abs(m-n)>1:
    return print(0)
  elif abs(m-n)==1:
    return print(modpfac(n)*modpfac(m)%p)
  else:
    return print(2*modpfac(n)*modpfac(m)%p)
 
main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ in range(n)]
print(max(a)-min(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
s0=1<<(x-1)|1<<(y-1)
s1=sum(list(map(lambda x:1<<(x-1),[1,3,5,7,8,10,12])))&s0
s2=sum(list(map(lambda x:1<<(x-1),[4,6,9,11])))&s0
s3==sum(list(map(lambda x:1<<(x-1),[2])))&s0

if s1==s0 or s2==s0 or s3==s0:
  print('Yes')
else:
  print('No')


Fixed submission:
x,y=map(int,input().split())
s0=1<<(x-1)|1<<(y-1)
s1=sum(list(map(lambda x:1<<(x-1),[1,3,5,7,8,10,12])))&s0
s2=sum(list(map(lambda x:1<<(x-1),[4,6,9,11])))&s0
s3=sum(list(map(lambda x:1<<(x-1),[2])))&s0

if s1==s0 or s2==s0 or s3==s0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
s0=1<<(x-1)|1<<(y-1)
s1=sum(map(lambda x:1<<(x-1),[1,3,5,7,8,10,12]))&s0
s2=sum(map(lambda x:1<<(x-1),[4,6,9,11]))&s0
s3==sum(map(lambda x:1<<(x-1),[2]))&s0

if s1==s0 or s2==s0 or s3==s0:
  print('Yes')
else:
  print('No')


Fixed submission:
x,y=map(int,input().split())
s0=1<<(x-1)|1<<(y-1)
s1=sum(list(map(lambda x:1<<(x-1),[1,3,5,7,8,10,12])))&s0
s2=sum(list(map(lambda x:1<<(x-1),[4,6,9,11])))&s0
s3=sum(list(map(lambda x:1<<(x-1),[2])))&s0

if s1==s0 or s2==s0 or s3==s0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n,m=map(int,input().split())
r=[list(map(int,input().split())) for _ in range(n)]
d=defaultdict(int)
for x in r:
  d[x[0]]+=1
  d[x[1]]+=1

for i in range(1,n+1):
  print(d[i])

Fixed submission:
from collections import defaultdict

n,m=map(int,input().split())
r=[list(map(int,input().split())) for _ in range(m)]
d=defaultdict(int)
for x in r:
  d[x[0]]+=1
  d[x[1]]+=1

for i in range(1,n+1):
  print(d[i])
Buggy python submission (verdict: Runtime Error):
from sys
rl=sys.stdin.readline

def main():
    n,k=map(int,rl.strip().split())
    ints=[list(map(int,rl.strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s<=k:
            print(e[0])
            break

if __name__=='__main__':
    main()


Fixed submission:
import sys
rl=sys.stdin.readline

def main():
    n,k=map(int,rl().strip().split())
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print(e[0])
            break

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,k=map(int,input().split())
ints=[list(map(int,input().split())) for _ in range(n)]
d=deque()
for x in ints:
  d.extend([x[0]]*x[1])
ans=sorted(list(d))
print(ans[k-1])

Fixed submission:
import sys
rl=sys.stdin.readline

def main():
    n,k=map(int,rl().strip().split())
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print(e[0])
            break

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import deque
n,k=map(int,input().split())
ints=[list(map(int,input().split())) for _ in range(n)]
d=deque()
for x in ints:
  d.extend([x[0]]*x[1])
ans=list(d).sort()
print(ans[k-1])

Fixed submission:
import sys
rl=sys.stdin.readline

def main():
    n,k=map(int,rl().strip().split())
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print(e[0])
            break

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict
rl=sys.stdin.readline


def main():
    n,m=map(int,rl().strip().split())
    ewdata=[list(map(int,rl().strip().split())) for _ in range(m)]
    ew=dict(((x[0],x[1]),x[2]) for x in ewdata)
    ed=defaultdict(list)
    deg=defaultdict(int)
    memo=defaultdict(int)
    for x in ew:
        ed[x[0]].append(x[1])
        deg[x[0]]+=1
    prev=0
    curr=1
    scores=[0]*(n+2)
    cps=[0]*(n+1)
    maxscore=-10**14
    stack=[]
    c=1
    while memo[1]<deg[1]:
        if cps[curr]==0:
            cps[curr]=c
        else:
            if scores[c]-scores[cps[curr]]>0:
                maxscore='inf'
                break
            else:
                memo[prev]+=1
                curr=prev 
                prev=stack.pop()
                c-=1
                continue
        if curr==n:
            maxscore=max(scores[c],maxscore)
        if memo[curr]<deg[curr]:
            c+=1
            stack.append(prev)
            prev=curr
            curr=ed[curr][memo[curr]]
            scores[c]+=scores[c-1]+ew[(prev,curr)]
        else:
            scores[c]=0
            memo[curr]=0
            memo[prev]+=1
            cps[curr]=0
            cps[prev]=0
            curr=prev
            prev=stack.pop()
            c-=1
        # print(c,cps,stack)
        # print(c,cps,scores)
        # print(list(memo.items()),stack)
    # print(deg)
    print(maxscore)

if __name__=='__main__':
    main()



Fixed submission:
import sys
rl=sys.stdin.readline

def main():
    n,m=map(int,rl().strip().split())
    eaw=[list(map(int,rl().strip().split())) for _ in range(m)]
    d=dict(((x[0]-1,x[1]-1),-x[2]) for x in eaw)
    inf=10**14
    mdl=[inf]*n
    mdl[0]=0
    def blrelax(dl,k):
        for _ in range(k):
            for e in iter(d):
                if dl[e[0]]+d[e]<dl[e[1]]:
                    dl[e[1]]=dl[e[0]]+d[e]
    blrelax(mdl,n-1)
    a1=mdl[n-1]
    blrelax(mdl,n)
    a2=mdl[n-1]
    if a1>a2:
        print('inf')
    else:
        print(-a1)
    
if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    n,w=map(int,stdin.readline().strip().split())
    t=[list(map(int,stdin.readline().strip().split())) for _ in range(n)]
    w1=t[0][0]
    for i in range(4):
        t.append([w1+i,0])
    arr=[sorted([x for x in t if x[0]==w1+i],reverse=True,key=lambda e:e[1]) for i in range(4)]
    # arr=[x.sort(reverse=True,key=lambda e:e[1]) for x in arr]
    arrlen=list(map(len,arr))
    ans=0
    sw=0
    sv=0
    for i0 in range(arrlen[0]):
         for i1 in range(arrlen[1]):
              for i2 in range(arrlen[2]):
                   for i3 in range(arrlen[3]):
                        sw=sum([x[0] for x in arr[0][:i0]])+sum([x[0] for x in arr[1][:i1]])\
                          +sum([x[0] for x in arr[2][:i2]])+sum([x[0] for x in arr[3][:i3]])
                        sv=sum([x[1] for x in arr[0][:i0]])+sum([x[1] for x in arr[1][:i1]])\
                          +sum([x[1] for x in arr[2][:i2]])+sum([x[1] for x in arr[3][:i3]])
                        if sw<=w:
                            ans=max(ans,sv)
    print(ans)
    # wts=list(map(lambda l:l[0]-w1-1, t))
    # val=list(map(lambda l:l[1], t))

if __name__=='__main__':
    main()   


Fixed submission:
from sys import stdin
import numpy as np

def main():
    def itrsum(arr):
        n=len(arr)
        tri=np.array([[i>=j for i in range(n)] for j in range(n+1)])
        return np.dot(tri,arr).astype('int64')
    n,w=map(int,stdin.readline().strip().split())
    t=[list(map(int,stdin.readline().strip().split())) for _ in range(n)]
    w1=t[0][0]
    # arr=[sorted([x for x in t if x[0]==w1+i],reverse=True,key=lambda e:e[1]) for i in range(4)]
    arr=[[x for x in t if x[0]==w1+i] for i in range(4)]
    arr=[l for l in arr]
    lenarr=list(map(len,arr))
    arr0=[itrsum(np.array(sorted([x[0] for x in l]),dtype='int64')) for l in arr]
    arr1=[itrsum(np.array(sorted([x[1] for x in l]),dtype='int64')) for l in arr]
    # arr=[x.sort(reverse=True,key=lambda e:e[1]) for x in arr]
    arr=np.array(arr)
    arrw=0
    arrv=0
    for i in range(4):
        arrw=np.ravel(arr0[i].reshape(lenarr[i]+1,1)+np.array([arrw]))
        arrv=np.ravel(arr1[i].reshape(lenarr[i]+1,1)+np.array([arrv]))
    #print(arr0)
    #print(arr1)
    #print('\n')
    #print(arrw)
    #print(arrv)
    #print(arrv[arrw<=w])
    ansarr=arrv[arrw<=w]
    print(np.max(ansarr))
    # wts=list(map(lambda l:l[0]-w1-1, t))
    # val=list(map(lambda l:l[1], t))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a=int(input().split())
b=int(input().split())

if a>b:
  print('GREATER')
elif a==b:
  print('EQUAL')
else:
  print('LESS')

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

if a>b:
  print('GREATER')
elif a==b:
  print('EQUAL')
else:
  print('LESS')
Buggy python submission (verdict: Runtime Error):
from itertools import zip_longest

o=input()
e=input()

print(''.join([x+y for x,y in zip_longetst(o,e,fillvalue='')]))


Fixed submission:
from collections import deque
 
O=input()
E=input()
 
o=deque(O)
e=deque(E)
 
s=''
while True:
  if not e  and not o:
    break
  if o:
    s+=o.popleft()
  if e:
    s+=e.popleft()
    
  
print(s)

Buggy python submission (verdict: Runtime Error):
from collections import deque

O=input()
E=input()

o=deque(O)
e=deque(E)

s=''
While True:
  if not e a and not o:
    break
  elif o:
    s+=o.pop()
  elif e:
    s+=e.pop()
    
  
print(s)

Fixed submission:
from collections import deque
 
O=input()
E=input()
 
o=deque(O)
e=deque(E)
 
s=''
while True:
  if not e  and not o:
    break
  if o:
    s+=o.popleft()
  if e:
    s+=e.popleft()
    
  
print(s)

Buggy python submission (verdict: Runtime Error):
from collections import deque

O=input()
E=input()

o=deque(O)
e=deque(E)

s=''
While True:
  if not e a and not o:
    break
  elif o:
    s+=o.pop()
  elif e:
    s+=e.pop()
    
  

Fixed submission:
from collections import deque
 
O=input()
E=input()
 
o=deque(O)
e=deque(E)
 
s=''
while True:
  if not e  and not o:
    break
  if o:
    s+=o.popleft()
  if e:
    s+=e.popleft()
    
  
print(s)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())

print((a+b)%24)

Fixed submission:
a,b=map(int,input().split())
 
print((a+b)%24)
Buggy python submission (verdict: Runtime Error):
a,b =input().split()

d={'H':0, 'D':1}
print(['H','D'][d[a]^d[b]]

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

d={'H':0, 'D':1}
print(['H','D'][d[a]^d[b]])