Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
k = input()

for loop in range(k):
    print("ACL", end = "")

Fixed submission:
print('ACL'*int(input()))
Buggy python submission (verdict: Time Limit Exceeded):

from collections import defaultdict

H,W,M=map(int,input().split())
AB=[tuple(map(int,input().split()))for i in range(M)]
AB=[(a-1,b-1)for a,b in AB]
st=set(AB)

Wc=defaultdict(lambda :0)
Hc=defaultdict(lambda :0)
for a,b in AB:
    Hc[a]+=1
    Wc[b]+=1

ans=0
for i in Hc.keys():
    for j in Wc.keys():
        add = -1 if (i,j) in st else 0
        tmp= Hc[i] + Wc[j] + add
        ans=max(ans,tmp)

print(ans)

Fixed submission:

from collections import defaultdict

H,W,M=map(int,input().split())
AB=[tuple(map(int,input().split()))for i in range(M)]
AB=[(a-1,b-1)for a,b in AB]
st=set(AB)

Wc=defaultdict(lambda :0)
Hc=defaultdict(lambda :0)
for a,b in AB:
    Hc[a]+=1
    Wc[b]+=1

Hm=max(Hc.values())
hhh=list(Hc.keys())
www=list(Wc.keys())
for i in hhh:
    if Hc[i]!=Hm:
        Hc.pop(i)
Wm=max(Wc.values())
for j in www:
    if Wc[j]!=Wm:
        Wc.pop(j)

ans=0
count=0
for i in Hc.keys():
    for j in Wc.keys():
        add = -1 if (i,j) in st else 0
        tmp= Hc[i] + Wc[j] + add
        ans=max(ans,tmp)
        if count>300000:
            break
        count+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

H,W,M=map(int,input().split())
AB=[tuple(map(int,input().split()))for i in range(M)]
AB=[(a-1,b-1)for a,b in AB]
st=set(AB)

Wc=[0]*W
Hc=[0]*H
for a,b in AB:
    Hc[a]+=1
    Wc[b]+=1

ans=0
for i in range(H):
    for j in range(W):
        add = -1 if (i,j) in st else 0
        tmp= Hc[i] + Wc[j] + add
        ans=max(ans,tmp)

print(ans)

Fixed submission:

from collections import defaultdict

H,W,M=map(int,input().split())
AB=[tuple(map(int,input().split()))for i in range(M)]
AB=[(a-1,b-1)for a,b in AB]
st=set(AB)

Wc=defaultdict(lambda :0)
Hc=defaultdict(lambda :0)
for a,b in AB:
    Hc[a]+=1
    Wc[b]+=1

Hm=max(Hc.values())
hhh=list(Hc.keys())
www=list(Wc.keys())
for i in hhh:
    if Hc[i]!=Hm:
        Hc.pop(i)
Wm=max(Wc.values())
for j in www:
    if Wc[j]!=Wm:
        Wc.pop(j)

ans=0
count=0
for i in Hc.keys():
    for j in Wc.keys():
        add = -1 if (i,j) in st else 0
        tmp= Hc[i] + Wc[j] + add
        ans=max(ans,tmp)
        if count>300000:
            break
        count+=1

print(ans)
Buggy python submission (verdict: Runtime Error):

N=int(input())
A=list(map(int,input().split()))
Q=int(input())

arg=[0]*(N+5)
for a in A:
    arg[a]+=1
ans=sum(A)
for _ in range(Q):
    a,b=map(int,input().split())
    ans+=arg[a]*(b-a)
    print(ans)
    arg[b]+=arg[a]
    arg[a]=0


Fixed submission:

N=int(input())
A=list(map(int,input().split()))
Q=int(input())

arg=[0]*(100005)
for a in A:
    arg[a]+=1
ans=sum(A)
for _ in range(Q):
    a,b=map(int,input().split())
    ans+=arg[a]*(b-a)
    print(ans)
    arg[b]+=arg[a]
    arg[a]=0
Buggy python submission (verdict: Runtime Error):
A=list(map(int,input().split()))
for i in range(1,6):
    if A[i]==0:
        print(i)

Fixed submission:
A=list(map(int,input().split()))
for i in range(1,6):
    if A[i-1]==0:
        print(i)
Buggy python submission (verdict: Runtime Error):

from collections import defaultdict
from math import gcd

P=defaultdict(lambda :0)
n=int(input())
AB=[tuple(map(int,input().split()))for i in range(n)]



for a,b in AB:
    g=gcd(a,b)
    if a<0:
        a//=-g
        b//=-g
    else:
        a//=g
        b//=g
    P[(a,b)]+=1

ans=1
others=n
mod=1000000007
from copy import copy
k=copy(list(P.keys()))
for p in k:
    me=P[p]
    if me==0:
        continue
    a,b=p
    oppidx=(-b,a) if b<0 else (b,-a)
    opp=P[oppidx]
    if P[oppidx]!=0:
        others-=me+opp
        ans*=pow(2,me,mod)+pow(2,opp,mod)-1
        ans%=mod
    P[p]=0
    P[oppidx]=0

ans*=pow(2,others,mod)
ans
ans%=mod

print(ans-1)

Fixed submission:

from collections import defaultdict
from math import gcd

P=defaultdict(lambda :0)
n=int(input())
AB=[tuple(map(int,input().split()))for i in range(n)]

zero=0 #これがいるときは一匹のみ
a0=0 #a0とb0はお互いがペア
b0=0
for a,b in AB:
    g=gcd(a,b)
    if a==0 and b==0:
        zero+=1
    elif a==0:
        a0+=1
    elif b==0:
        b0+=1
    elif a<0:
        a//=-g
        b//=-g
        P[(a,b)]+=1
    else:
        a//=g
        b//=g
        P[(a,b)]+=1

ans=1
others=n-zero-a0-b0
mod=1000000007
from copy import copy
k=copy(list(P.keys()))
for p in k:
    me=P[p]
    if me==0:
        continue
    a,b=p
    oppidx=(-b,a) if b<0 else (b,-a)
    opp=P[oppidx]
    if P[oppidx]!=0:
        others-=me+opp
        ans*=pow(2,me,mod)+pow(2,opp,mod)-1
        ans%=mod
    P[p]=0
    P[oppidx]=0

if a0!=0 and b0!=0:
    ans*=pow(2,a0,mod)+pow(2,b0,mod)-1
    ans%=mod
elif a0!=0 or b0!=0:
    others+=a0+b0

ans*=pow(2,others,mod)
ans%=mod
ans=ans+zero-1
ans%=mod

print(ans)

"""
7
0 1
0 1
1 0
1 0
1 -1
1 1
1 3
"""
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
h=list(map(int,input().split()))

g=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans=0
for i in range(n):
    M=max([h[c] for c in g[i]]+[0])
    if M<h[i]:
        ans+=1
print(ans)

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

g=[[]for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans=0
for i in range(n):
    M=max([h[c] for c in g[i]]+[0])
    if M<h[i]:
        ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(enumerate(map(int,input().split())))
a.sort(key=lambda x: -x[1])
dp=[[0]*(n+1) for i in range(n+1)]
for idx,ix in enumerate(a):
    i,x=ix
    for j in range(idx+1):
        dp[j+1][idx-j]=max(dp[j+1][idx-j],dp[j][idx-j]+(i-j)*x)
        dp[j][idx-j+1]=max(dp[j][idx-j+1],dp[j][idx-j]+((n-1-(idx-j))-i)*x)
print(max([dp[i][n-i] for i in range(n+1)]))

Fixed submission:
n=int(input())
a=list(enumerate(map(int,input().split())))
a.sort(key=lambda x: -x[1])
dp=[[0]*(n+1) for i in range(n+1)]
for idx,ix in enumerate(a):
    i,x=ix
    for j in range(idx+1):
        dp[j+1][idx-j]=max(dp[j+1][idx-j],dp[j][idx-j]+(i-j)*x)
        dp[j][idx-j+1]=max(dp[j][idx-j+1],dp[j][idx-j]+((n-1-(idx-j))-i)*x)
print(max([dp[i][n-i] for i in range(n+1)]))
Buggy python submission (verdict: Runtime Error):
def main():
    n=int(input())
    color=list(map(int,input().split()))
    nodes=[[]for i in range(n)]
    cut=[[0]for i in range(n+1)]
    ans=[0]*(n+1)
    for i in range(n-1):
        a,b=map(int,input().split())
        nodes[a-1].append(b-1)
        nodes[b-1].append(a-1)
    def num(p,parent):
        s=0
        for child in nodes[p]:
            if child==parent:
                continue
            cut[color[p]].append(0)
            nc=num(child,p)
            group=nc-cut[color[p]].pop()
            ans[color[p]]+=group*(group+1)//2
            s+=nc
        s+=1
        cut[color[p]][-1]+=s
        return s
    num(0,-1)
    for a,c in zip(ans[1:],cut[1:]):
        group=n-c[0]
        c=group*(group+1)//2
        print(n*(n+1)//2-c-a)
main()

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
def main():
    n=int(input())
    color=list(map(int,input().split()))
    nodes=[[]for i in range(n)]
    cut=[[0]for i in range(n+1)]
    ans=[0]*(n+1)
    for i in range(n-1):
        a,b=map(int,input().split())
        nodes[a-1].append(b-1)
        nodes[b-1].append(a-1)
    def num(p,parent):
        s=0
        for child in nodes[p]:
            if child==parent:
                continue
            cut[color[p]].append(0)
            nc=num(child,p)
            group=nc-cut[color[p]].pop()
            ans[color[p]]+=group*(group+1)//2
            s+=nc
        s+=1
        cut[color[p]][-1]+=s
        return s
    num(0,-1)
    for a,c in zip(ans[1:],cut[1:]):
        group=n-c[0]
        c=group*(group+1)//2
        print(n*(n+1)//2-c-a)
main()
Buggy python submission (verdict: Runtime Error):
n,k,rest= map(int, input().split())
s=input()
s+="x"*rest
l=[]
i=-1
ban=0
suc=0
new=[]
if rest==0:
    if s.count("o")==k:
        for i in range(len(s)):
            if s[i]=="o":
                print(i+1)
else:
    while i<len(s)+rest-1:
        i+=1
        ban-=1
        c=s[i]
        if c=="o":
            suc=0
            if ban>=0:
                continue
            new.append(i+1)
            ban=rest
        else:
            suc+=1
            if suc>=rest:
                if ban==0:
                    l+=new
                new=[]

    if len(l)>k:
        print()
    else:
        for i in l:
            print(i)

Fixed submission:
n,k,rest=map(int,input().split())
s=input()

last=-3000000
l1=[]
l2=set()
for i,c in enumerate(s):
    if last+rest<i and c=="o":
        last=i
        l1.append(i)
last=6000000
for i,c in enumerate(reversed(s)):
    if n-1-i<last-rest and c=="o":
        last=n-1-i
        l2.add(n-1-i)

if len(l1)!=k:
    print()
else:
    for i in l1:
        if i in l2:
            print(i+1)

Buggy python submission (verdict: Runtime Error):
n,k,c= map(int, input().split())
s=input()
l=[]

for c in s.split("x"*c):
    count=0
    while i<len()
    if i=="o":


Fixed submission:
n,k,rest=map(int,input().split())
s=input()

last=-3000000
l1=[]
l2=set()
for i,c in enumerate(s):
    if last+rest<i and c=="o":
        last=i
        l1.append(i)
last=6000000
for i,c in enumerate(reversed(s)):
    if n-1-i<last-rest and c=="o":
        last=n-1-i
        l2.add(n-1-i)

if len(l1)!=k:
    print()
else:
    for i in l1:
        if i in l2:
            print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
a=list(map(int,input().split()))

dp=[[0]*(s+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0]=1
ans=0

# i indicade low , c indicade column
for i,w in enumerate(a):
    for c in range(s+1):
        dp[i][c]+=dp[i-1][c]
    for c in range(s-w+1):
        dp[i][c+w]+=dp[i-1][c]
    ans+=dp[i][-1]
    ans%=998244353

print(ans)


Fixed submission:
import numpy as np

n,s=map(int,input().split())
a=list(map(int,input().split()))

dp=[np.zeros(s+1,dtype=np.int64) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0]=1
ans=0

for i,w in enumerate(a):
    dp[i]+=dp[i-1]
    dp[i][w:]+=dp[i-1][:-w]
    dp[i]%=998244353
    ans+=dp[i][-1]
    ans%=998244353

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
a=list(map(int,input().split()))

dp=[[0]*(n+1) for _ in range(s+1)]
for i in range(n+1):
    dp[0][i]=1
ans=0

# i indicade low , c indicade column
for i,w in enumerate(a):
    for c in range(s+1):
        dp[c][i]+=dp[c][i-1]
    for c in range(s-w+1):
        dp[c+w][i]+=dp[c][i-1]
    ans+=dp[-1][i]
    ans%=998244353

print(ans)

Fixed submission:
import numpy as np

n,s=map(int,input().split())
a=list(map(int,input().split()))

dp=[np.zeros(s+1,dtype=np.int64) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0]=1
ans=0

for i,w in enumerate(a):
    dp[i]+=dp[i-1]
    dp[i][w:]+=dp[i-1][:-w]
    dp[i]%=998244353
    ans+=dp[i][-1]
    ans%=998244353

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
s=map(int,list(input()))
ans=0
if k==2 or k==5:
    for i,p in enumerate(s):
        if p%k==0:
            ans+=i+1
else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        total+=p*inv
        total%=k
        ans+=S[total]
        S[total]+=1
print(ans)


Fixed submission:
n,k=map(int,input().split())
s=map(int,list(input()))
ans=0
if k==2 or k==5:
    for i,p in enumerate(s):
        if p%k==0:
            ans+=i+1
else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        inv%=k
        total+=p*inv
        total%=k
        ans+=S[total]
        S[total]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
s=input()
ans=0

if k==2 or k==5:
    for i,p in enumerate(s):
        p=int(p)
        if p%k==0:
            ans+=i+1

else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        p=int(p)
        total+=p*inv
        S[total%k]+=1
    for i in S:
        ans+=i*(i-1)//2

print(ans)

Fixed submission:
n,k=map(int,input().split())
s=map(int,list(input()))
ans=0
if k==2 or k==5:
    for i,p in enumerate(s):
        if p%k==0:
            ans+=i+1
else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        inv%=k
        total+=p*inv
        total%=k
        ans+=S[total]
        S[total]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
s=input()
ans=0

if k==2 or k==5:
    for i,p in enumerate(s):
        p=int(p)
        if p%k==0:
            ans+=i+1

else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        p=int(p)
        total+=p*inv
        S[total%k]+=1
    for i in S:
        ans+=i*(i-1)//2

print(ans)

Fixed submission:
n,k=map(int,input().split())
s=map(int,list(input()))
ans=0
if k==2 or k==5:
    for i,p in enumerate(s):
        if p%k==0:
            ans+=i+1
else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        inv%=k
        total+=p*inv
        total%=k
        ans+=S[total]
        S[total]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,k=map(int,input().split())
A=list(map(int,input().split()))

A.sort()

left=-10**18
right=10**18
count=0

a=bisect.bisect_left(A,0)
b=bisect.bisect_right(A,0)

if b*(n-a)-(b-a)-(b-a)*(b-a-1)//2>=k:
    right=0
else:
    left=1

while right!=left:
    pos=(left+right)//2
    count=0
    for a in A:
        if a==0:
            if pos>=0:
                count+=n-1
        elif a<0:
            i=bisect.bisect_right(A,(-1-pos)//(-a))
            count+=n-i + (-1 if a*a<=pos else 0)
        else:
            i=bisect.bisect_right(A,pos//a)
            count+=i + (-1 if a*a<=pos else 0)
    if count>=2*k:
        right=pos
    else:
        left=pos+1

print(left)


Fixed submission:
import numpy as np

n,k=map(int,input().split())
A=np.array(input().split(),np.int64)
A.sort()

zero=A[A==0]
neg=A[A<0]
pos=A[A>0]

def f(x): # count pairs x or less
    cnt=0
    #zero
    if x>=0:
        cnt += len(zero)*n
    #pos
    cnt += A.searchsorted(x//pos,side="right").sum()
    #neg
    cnt += (n-A.searchsorted(-(-x//neg),side="left")).sum()
    #except a*a
    cnt-=np.count_nonzero(A*A<=x)
    return cnt//2

l=-10**18
r=10**18

while l<r:
    pov=(l+r)//2
    if f(pov)>=k:
        r=pov
    else:
        l=pov+1
print(l)

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

n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

left=-10**18
right=10**18
count=0

a=bisect.bisect_left(A,0)
b=bisect.bisect_right(A,0)

if n*(n-1)-b*(n-a)-(b-a)>=2*k:
    right=0
else:
    left=1

while right!=left:
    pos=(left+right)//2
    count=0
    for a in A:
        if a==0 and pos>=0:
            count+=n-1
        elif a<0:
            i=bisect.bisect_right(A,(-1-pos)//(-a))
            count+=n-i + (-1 if a*a<=pos else 0)
        else:
            i=bisect.bisect_right(A,pos//a)
            count+=i + (-1 if a*a<=pos else 0)
    if count>=2*k:
        right=pos
    else:
        left=pos+1

print(left)


Fixed submission:
import numpy as np

n,k=map(int,input().split())
A=np.array(input().split(),np.int64)
A.sort()

zero=A[A==0]
neg=A[A<0]
pos=A[A>0]

def f(x): # count pairs x or less
    cnt=0
    #zero
    if x>=0:
        cnt += len(zero)*n
    #pos
    cnt += A.searchsorted(x//pos,side="right").sum()
    #neg
    cnt += (n-A.searchsorted(-(-x//neg),side="left")).sum()
    #except a*a
    cnt-=np.count_nonzero(A*A<=x)
    return cnt//2

l=-10**18
r=10**18

while l<r:
    pov=(l+r)//2
    if f(pov)>=k:
        r=pov
    else:
        l=pov+1
print(l)
Buggy python submission (verdict: Runtime Error):
from math import log10
n=input()
k=int(input())

#ないときも後で
l=len(n)
ans1=0
if l>k:
    if k==1:
        ans1=l-1
    elif k==2:
        ans1=(l-1)*(l-2)//2
    else:
        ans1=(l-1)*(l-2)*(l-3)//6
ans1*=9**k
ans=0
if l>=k:
    if k==1:
        ans=0
    elif k==2:
        ans=(l-1)
    else:
        ans=(l-1)*(l-2)//2
ans*=(int(n[0])-1)*9**(k-1)

dp=[[0]*3 for _ in range(l-1)]
dp[-1][0]=1
n=list(n)
n.reverse()
for i,c in enumerate(n[:-1]):
    c=int(c)
    dp[i][0]=1
    dp[i][1]=dp[i-1][1]+dp[i-1][0]*c
    dp[i][2]=dp[i-1][2]+dp[i-1][1]*c
ans+=dp[-1][k-1]
print(ans+ans1)

Fixed submission:
n=input()
k=int(input())

n1,n2,n3=int(n[-1]),0,0
a1,a2,a3=9,0,0
for i in n[-2::-1]:
    i=int(i)
    if i!=0:
        n1,n2,n3=i+a1,(i-1)*a1+n1+a2,(i-1)*a2+n2+a3
    a1,a2,a3=9+a1,9*a1+a2,9*a2+a3
print([n1,n2,n3][k-1])

Buggy python submission (verdict: Runtime Error):
from math import log10
n=input()
k=int(input())

#ないときも後で
l=len(n)
ans1=0
if l>k:
    if k==1:
        ans1=l-1
    elif k==2:
        ans1=(l-1)*(l-2)//2
    else:
        ans1=(l-1)*(l-2)*(l-3)//6
ans1*=9**k
if l>=k:
    if k==1:
        ans=0
    elif k==2:
        ans=(l-1)
    else:
        ans=(l-1)*(l-2)//2
ans*=(int(n[0])-1)*9**(k-1)

dp=[[0]*3 for _ in range(l-1)]
dp[-1][0]=1
n=list(n)
n.reverse()
for i,c in enumerate(n[:-1]):
    c=int(c)
    dp[i][0]=1
    dp[i][1]=dp[i-1][1]+dp[i-1][0]*c
    dp[i][2]=dp[i-1][2]+dp[i-1][1]*c
ans+=dp[-1][k-1]
print(ans+ans1)

Fixed submission:
n=input()
k=int(input())

n1,n2,n3=int(n[-1]),0,0
a1,a2,a3=9,0,0
for i in n[-2::-1]:
    i=int(i)
    if i!=0:
        n1,n2,n3=i+a1,(i-1)*a1+n1+a2,(i-1)*a2+n2+a3
    a1,a2,a3=9+a1,9*a1+a2,9*a2+a3
print([n1,n2,n3][k-1])
Buggy python submission (verdict: Runtime Error):
n,k,s = [int(i) for i in input().split()]

for i in range(k):
    print(s,end="")
    if i!=k-1:
        print(" ",end="")

s = s-1 if s==10**0 else s+1

for i in range(k,n):
    print(" "+str(s),end="")

Fixed submission:
n = int(input())
lr = []
for i in range(n):
    x,l=input().split()
    x=int(x)
    l=int(l)
    lr.append([x-l,x+l])

lr.sort(key=lambda x:x[1])

l = -2000000000
ans=0
for i in range(n):
    if l<=lr[i][0]:
        l=lr[i][1]
        ans+=1

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

from math import gcd
def lcm(a,b):
    return a*b//gcd(a,b)

l=1
for i in a:
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

ans=1 if l<=m else 0
m-=l

print(ans+max(0,m//(2*l)))

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

from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
l=1

max2=0
min2=1000

for i in a:
    factor=(i^(i-1)).bit_length()
    max2=max(max2,factor)
    min2=min(min2,factor)
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

if l>m or min2!=max2:
    print(0)
else:
    ans=1 if l<=m else 0
    m-=l
    print(ans+max(0,m//(2*l)))

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

from math import gcd
def lcm(a,b):
    return a*b//gcd(a,b)

l=1
for i in a:
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

ans=1 if l<=m else 0
m-=l

print(ans+max(0,m//(2*l)))

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

from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
l=1

max2=0
min2=1000

for i in a:
    factor=(i^(i-1)).bit_length()
    max2=max(max2,factor)
    min2=min(min2,factor)
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

if l>m or min2!=max2:
    print(0)
else:
    ans=1 if l<=m else 0
    m-=l
    print(ans+max(0,m//(2*l)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = 2**18
 
f = np.array([0]*d)
for i in a:
    f[i]+=1
 
tf = np.fft.fft(f)
f = np.fft.ifft(tf*tf)
f = [int(i+0.5) for i in f]
 
ans=0
for i in range(len(f)-1,0,-1):
    if f[i]<=m:
        ans+=i*f[i]
        m-=f[i]
    elif f[i]>m:
        ans+=i*m
        break
print(ans)

Fixed submission:
s,t = input().split()
print(t+s)
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = 2**18
 
f = np.array([0]*d)
for i in a:
    f[i]+=1
 
tf = np.fft.fft(f)
f = np.fft.ifft(tf*tf)
f = [int(i+0.5) for i in f]
 
ans=0
for i in range(len(f)-1,0,-1):
    if f[i]<=m:
        ans+=i*f[i]
        m-=f[i]
    elif f[i]>m:
        ans+=i*m
        break
print(ans)

Fixed submission:
import numpy as np

n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = 2**18

f = np.array([0]*d)
for i in a:
    f[i]+=1

tf = np.fft.fft(f)
f = np.fft.ifft(tf*tf)
f = [int(i+0.5) for i in f]

ans=0
for i in range(len(f)-1,0,-1):
    if f[i]<=m:
        ans+=i*f[i]
        m-=f[i]
    elif f[i]>m:
        ans+=i*m
        break
print(ans)

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

n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = 2**15

f = np.array([0]*d)
for i in a:
    f[i]+=1

tf = np.fft.fft(f)
f = np.fft.ifft(tf*tf)
f = [int(i+0.5) for i in f]

ans=0
for i in range(len(f)-1,0,-1):
    if f[i]<=m:
        ans+=i*f[i]
        m-=f[i]
    elif f[i]>m:
        ans+=i*m
        break
print(ans)

Fixed submission:
import numpy as np

n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = 2**18

f = np.array([0]*d)
for i in a:
    f[i]+=1

tf = np.fft.fft(f)
f = np.fft.ifft(tf*tf)
f = [int(i+0.5) for i in f]

ans=0
for i in range(len(f)-1,0,-1):
    if f[i]<=m:
        ans+=i*f[i]
        m-=f[i]
    elif f[i]>m:
        ans+=i*m
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,v,p = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
p-=1

a.sort(reverse=True)

ans=0
s = sum(a)

def safe(index):
    if a[p]>a[index]+m:
        return False
    i=0
    wall = -1
    while a[i]>=a[index]+m:
        if a[i]>=a[index]+m+1:
            wall = i
        i+=1
    if i>index:
        return True
    intg = 0
    while i<index:
        intg += a[index] + m - a[i]
        i+=1
    intg += (len(a)-1-index)*m + min(v,p - wall + 1)*m
    #print("intg = ",intg ,m*(v-1) )
    return intg >= m*(v-1)

left = 0
right = len(a)-1
ans = int((right - left)/2)
if safe(right):
    ans = right
else:
    j = safe(ans)
    while not(j and not safe(ans+1)):
        if j:
            left = ans
        else:
            right = ans
        ans = left + int((right - left)/2)
        j = safe(ans)
print(ans+1)
"""
for i in range(len(a)):
    print(a[i],safe(i))
"""

Fixed submission:
n,a,b = [int(i) for i in input().split()]
if (b-a)%2==0:
    print((b-a)//2)
else:
    r = a + (b-a-1)//2
    l = n-b+1 + ( n - (a+n-b+1) )//2 
    print(min(r,l))
Buggy python submission (verdict: Runtime Error):
import math

a,b = [int(i) for i in input().split()]

print(a*b//math.gcd(a, b))

Fixed submission:
a,b = [int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
print(a*b//gcd(a, b))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

for b in a:
    for i in range(60):
        counts[i]+=b%2
        b//=2

ans=0
mod = 10**9+7
for i in range(60):
    c=counts[i]
    comb=c*(n-c)
    ans=(ans+(1<<i)*comb)%mod
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
counts=[0]*60
for b in a:
    for i in range(60):
        counts[i]+=b%2
        b//=2
ans=0
mod = 10**9+7
for i in range(60):
    c=counts[i]
    comb=c*(n-c)
    ans=(ans+(1<<i)*comb)%mod
print(ans)