Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

l=int(input())
r=20
while 2**r>l:
    r-=1
# print(r)
for i in range(2*r):
    lst=[i//2+1, i//2+2, 0]
    if i%2==1:
        lst[2]=2**((i)//2)
    print(*lst)

for i in range(r):
    if l-2**(r-i-1)>=2**r:
        print(*[r-i,r+1,l-2**(r-i-1)])
    l-=2**(r-i-1)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

l=int(input())
r=20
while 2**r>l:
    r-=1
anslst=[]
for i in range(2*r):
    lst=[i//2+1, i//2+2, 0]
    if i%2==1:
        lst[2]=2**((i)//2)
    anslst.append(lst)

for i in range(r):
    if l-2**(r-i-1)>=2**r:
        anslst.append([r-i,r+1,l-2**(r-i-1)])
        l-=2**(r-i-1)

print(*[r+1,len(anslst)])
for i in range(len(anslst)):
    print(*anslst[i])
Buggy python submission (verdict: Runtime Error):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%k
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)

Fixed submission:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
amari=[0]*k
for i in range(n):
    i+=1
    amari[i%k]+=1
# print(amari)

ans=0
for i in range(n):
    i+=1
    am=i%k
    nokori=(k-am)%k
    # print(am,nokori)
    if nokori*2%k==0:
        ans+=amari[nokori]**2
print(ans)
Buggy python submission (verdict: Runtime Error):
vimport sys
def input():
    return sys.stdin.readline()[:-1]
a,b=map(int,input().split())
print((a-1)*(b-1))

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
a,b=map(int,input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
if int(input()) >= 1000:
  print(“ABD”)
else:
  print(“ABC”)

Fixed submission:
if int(input()) >= 1000:
  print("ABD")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
mask=2^21-1
cnt=n
for i in range(n):
    j=i+1
    tmp=a[i]
    while(j<n):
        if tmp&a[j]==0:
            tmp+=a[j]
            cnt+=1
        else:
            break
        j+=1
print(cnt)

Fixed submission:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
cnt=0
i=0
j=0
tmp=0
while(i<n):
    while(j<n):
        if tmp&a[j]==0:
            tmp+=a[j]
            cnt+=j-i+1
            # print(str(i)+" "+str(j))
        else:
            break
        j+=1
    tmp^=a[i]
    i+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
ruix=[0]*(n+1)
ruia=[0]*(n+1)
for i in range(n):
    ruix[i+1]=ruix[i]^a[i]
    ruia[i+1]=ruia[i]+a[i]
cnt=0
for i in range(n):
    for j in range(i,n):
        if ruix[j+1]^ruix[i]==ruia[j+1]-ruia[i]:
            cnt+=1
            # print(str(i)+" "+str(j))
print(cnt)

Fixed submission:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
cnt=0
i=0
j=0
tmp=0
while(i<n):
    while(j<n):
        if tmp&a[j]==0:
            tmp+=a[j]
            cnt+=j-i+1
            # print(str(i)+" "+str(j))
        else:
            break
        j+=1
    tmp^=a[i]
    i+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
a.sort()
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans=[a[-1],a[0]]
tmp=0
for i in range(n-1):
    cnt=combinations_count(a[-1],a[i])
    if tmp<cnt:
        ans[1]=a[i]
        tmp=cnt
print(ans[0])
print(ans[1])

Fixed submission:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
a.sort()
half=float(a[-1])/2
len=float("inf")
ans=a[0]
for i in range(n-1):
    if len>abs(half-a[i]):
        ans=a[i]
        len=abs(half-a[i])
print(a[-1])
print(ans)
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))

if (max(a)-a[0])%2==0 and (max(a)-a[1])%2==0 and (max(a)-a[2])%2==0
    print(int((max(a)*3-sum(a))/2))
else:
    print(int((max(a)*3-sum(a))/2)+2)

Fixed submission:
a=list(map(int,input().split()))
a.sort()

if (max(a)-a[0])%2==0 and (max(a)-a[1])%2==0:
    print(int((max(a)*3-sum(a))/2))
elif (a[2]-a[0])%2==1 and (a[2]-a[1])%2==1:
    print(int((max(a)*3-sum(a))/2))
else:
    print(int((max(a)*3-sum(a))/2)+2)
Buggy python submission (verdict: Runtime Error):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)

Fixed submission:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)
Buggy python submission (verdict: Runtime Error):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
# print(s,t)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
# print(s,t)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
# print(s,t)
if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort()
lst=[0]*c
for i in range(n):
    for j in range(c):
        if lst[j]==0:
            lst[j]=stc[i]
            break
        else:
            if lst[j][2]==stc[i][2]:
                lst[j]=stc[i]
                break
            elif lst[j][1]+1<stc[i][1]:
                lst[j]=stc[i]
                break

ans=0
for i in range(c):
    if lst[i]!=0:
        ans+=1
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort(key=lambda x: x[2])
# print(stc)
lst=[[0]*(10**5+5) for i in range(c)]
for i in range(len(stc)):
    s,t,c=stc[i]
    for j in range(s-1,t):
        lst[c-1][j]+=1
anslst=[0]*(10**5+5)
for i in range(c):
    for j in range(10**5+5):
        if lst[i][j]!=0:
            anslst[j]+=1
print(max(anslst))

Buggy python submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort()
lst=[0]*c
for i in range(n):
    for j in range(c):
        if lst[j]==0:
            lst[j]=stc[i]
            break
        else:
            if lst[j][2]==stc[i][2]:
                lst[j]=stc[i]
                break
            elif lst[j][1]+1<stc[i][1]:
                lst[j]=stc[i]
                break

ans=0
for i in range(c):
    if lst[i]!=0:
        ans+=1
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,c=map(int,input().split())
stc=[list(map(int,input().split())) for i in range(n)]
stc.sort(key=lambda x: x[2])
# print(stc)
lst=[[0]*(10**5+5) for i in range(c)]
for i in range(len(stc)):
    s,t,c=stc[i]
    for j in range(s-1,t):
        lst[c-1][j]+=1
anslst=[0]*(10**5+5)
for i in range(c):
    for j in range(10**5+5):
        if lst[i][j]!=0:
            anslst[j]+=1
print(max(anslst))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))

t.append(0)
v.append(0)
t.insert(0,0)
v.insert(0,0)

tt=sum(t)
lst=[0]*(tt*2+1)

for i in range(tt*2-1):
    tmp=[]
    now=0.5+i/2
    cnt=0
    for j in range(n+2):
        l=cnt
        cnt+=t[j]
        r=cnt
        if j==n+1:
            l=r
        if now<=l:
            tmp.append(l-now+v[j])
        elif r<=now:
            tmp.append(now-r+v[j])
        else:
            tmp.append(v[j])
        # print(l,r)
    lst[i+1]=min(tmp)

# print(lst)
ans=0
for i in range(tt*2):
    ans+=0.25*(lst[i+1]+lst[i])
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
# from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))

t.append(0)
v.append(0)
t.insert(0,0)
v.insert(0,0)

tt=sum(t)
lst=[0]*(tt*2+1)

for i in range(tt*2-1):
    tmp=[]
    now=0.5+i/2
    cnt=0
    for j in range(n+2):
        l=cnt
        cnt+=t[j]
        r=cnt
        if j==n+1:
            l=r
        if now<=l:
            tmp.append(l-now+v[j])
        elif r<=now:
            tmp.append(now-r+v[j])
        else:
            tmp.append(v[j])
        # print(l,r)
    lst[i+1]=min(tmp)

# print(lst)
ans=0
for i in range(tt*2):
    ans+=0.25*(lst[i+1]+lst[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import *
import heapq
import math
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
lst=[0]*n
lst2=[0]*n
for i in range(n):
    x,y=xy[i]
    lst[i],lst2[i]=x,y
lst,lst2=list(permutations(lst,2)),list(permutations(lst2,2))
ans=float('inf')
for i in range(len(lst)):
    xl,xr=min(lst[i]),max(lst[i])
    for j in range(len(lst2)):
        yl,yr=min(lst2[j]),max(lst2[j])
        cnt=0
        for l in range(n):
            x,y=xy[l]
            if xl<=x<=xr and yl<=y<=yr:
                cnt+=1
        if cnt>=k:
            ans=min(ans,(xr-xl)*(yr-yl))
print(ans)

Fixed submission:
import sys
from collections import *
import heapq
import math
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
ru=[[0]*(n+1) for i in range(n+1)]
lst=sorted(xy)
lst2=sorted(xy,key=lambda x: x[1])

for i in range(n):
    for j in range(n):
        flag=0
        for l in range(n):
            if xy[l]==[lst[i][0],lst2[j][1]]:
                flag=1
        if flag:
            ru[i+1][j+1]=1
        ru[i+1][j+1]+=ru[i+1][j]+ru[i][j+1]-ru[i][j]
# print(ru)
xdic=defaultdict(int)
ydic=defaultdict(int)
for i in range(n):
    xdic[lst[i][0]]=i+1
    ydic[lst2[i][1]]=i+1
# print(xdic)
# print(ydic)
lst=[0]*n
lst2=[0]*n
for i in range(n):
    x,y=xy[i]
    lst[i],lst2[i]=x,y
lst,lst2=list(permutations(lst,2)),list(permutations(lst2,2))
ans=float('inf')
for i in range(len(lst)):
    xl,xr=min(lst[i]),max(lst[i])
    for j in range(len(lst2)):
        yl,yr=min(lst2[j]),max(lst2[j])
        # print(ru[xdic[xr]][ydic[yr]]-ru[xdic[xr]][ydic[yl]-1]-ru[xdic[xl]-1][ydic[yr]]+ru[xdic[xl]-1][ydic[yl]-1])
        if ru[xdic[xr]][ydic[yr]]-ru[xdic[xr]][ydic[yl]-1]-ru[xdic[xl]-1][ydic[yr]]+ru[xdic[xl]-1][ydic[yl]-1] >=k:
            ans=min(ans,(xr-xl)*(yr-yl))
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())

for i in range(1,3501):
    for j in range(j,3501):
        if 4*i*j-n*i-n*j>0 and n*i*j%(4*i*j-n*i-n*j)==0:
            w=n*i*j//(4*i*j-n*i-n*j)
            print(i,j,w)
            quit()
        else:
            continue

Fixed submission:
n=int(input())

for i in range(1,3501):
    for j in range(i,3501):
        if (4*i*j-n*i-n*j)>0 and n*i*j%(4*i*j-n*i-n*j)==0:
            w=n*i*j//(4*i*j-n*i-n*j)
            print(i,j,w)
            quit()
        else:
            continue

Buggy python submission (verdict: Runtime Error):
n=int(input())

for i in range(1,3501):
    for j in range(1,3501):
        if n*i*j%(4*i*j-n*i-n*j)==0:
            w=int(n*i*j/(4*i*j-n*i-n*j))
            print(i,j,w)
            break
        else:
            continue

Fixed submission:
n=int(input())

for i in range(1,3501):
    for j in range(i,3501):
        if (4*i*j-n*i-n*j)>0 and n*i*j%(4*i*j-n*i-n*j)==0:
            w=n*i*j//(4*i*j-n*i-n*j)
            print(i,j,w)
            quit()
        else:
            continue
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ans=0
ab.sort()
m=bin(k)
# print(m)
klst=[m]
for i in range(2,len(m)):
    if m[i]=="1":
        klst.append(m[:i]+"0"+"1"*(len(m)-i-1))

# print(klst)
for i in klst:
    tmp=0
    for j in range(n):
        a,b=ab[j]
        m=bin(a)
        if int(i,0)>=a:
            for l in range(min(len(m),len(i))):
                if i[-1-l]=="0" and m[-1-l]=="1":
                    break
            else:
                tmp+=b
    ans=max(ans,tmp)
print(ans)

Fixed submission:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ans=0
ab.sort()
m=bin(k)
# print(m)
klst=[m]
for i in range(2,len(m)):
    if m[i]=="1":
        klst.append(m[:i]+"0"+"1"*(len(m)-i-1))

# print(klst)
for i in klst:
    tmp=0
    for j in range(n):
        a,b=ab[j]
        if a|int(i,0)==int(i,0):
            tmp+=b
    ans=max(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

list=[0]*(10**9+1)

for i in range(n):
    list[a[i]]+=1

one=0
two=0

for i in range(10**9+1):
    if one==0 and list[i]>1:
        one=i
    elif list[i]>1:
        two=one
        one=i

print(one*two)

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

dict={}

for i in range(n):
    if not a[i] in dict:
        dict[a[i]]=0
    dict[a[i]]+=1


a=sorted(dict.items(), key=lambda x:x[0])
one=0
two=0
for i in range(len(a)):
    if a[i][1]>3:
            one=a[i][0]
            two=one

    elif a[i][1]>1:
        two=one
        one=a[i][0]
    
print(one*two)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

list=[0]*(10**5+1)

for i in range(n):
    list[a[i]]+=1

one=0
two=0

for i in range(10**5+1):
    if one==0 and list[i]>1:
        one=i
    elif list[i]>1:
        two=one
        one=i

print(one*two)

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

dict={}

for i in range(n):
    if not a[i] in dict:
        dict[a[i]]=0
    dict[a[i]]+=1


a=sorted(dict.items(), key=lambda x:x[0])
one=0
two=0
for i in range(len(a)):
    if a[i][1]>3:
            one=a[i][0]
            two=one

    elif a[i][1]>1:
        two=one
        one=a[i][0]
    
print(one*two)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]

ninoshima=[]
for i in range(m):
    if ab[i][0]==1:
        ninoshima.append(ab[i][1])

for i in range(m):
    if ab[i][0] in ninoshima and ab[i][1]==n:
        print("POSSIBLE")
        quit()
    elif ab[i][1] in ninoshima and ab[i][0]==n:
        print("POSSIBLE")
        quit()

print("IMPOSSIBLE")

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

ninoshima=[[0]*(n+1) for i in range(2)]

for i in range(m):
    if ab[i][0]==1:
        ninoshima[0][ab[i][1]]=1
    if ab[i][1]==n:
        ninoshima[1][ab[i][0]]=1
    

for i in range(n+1):
    if ninoshima[0][i]==ninoshima[1][i]==1:
        print("POSSIBLE")
        quit()

print("IMPOSSIBLE")