Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
ans=[]
for _ in range(q):
    l,r=map(int,input().split())
    k=s[l-1:r]
    ans.append(k.count("AC"))
for i in ans:
    print(i)

Fixed submission:
n,q=map(int,input().split())
s=input()
ans,c=[0]*q,[0]*n
k=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        k+=1
    c[i]=k

for i in range(q):
    l,r=map(int,input().split())
    ans[i]=c[r-1]-c[l-1]
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
l,r=[],[]
for _ in range(q):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
for i in range(q):
    k=s[l[i]-1:r[i]]
    print(k.count("AC"))

Fixed submission:
n,q=map(int,input().split())
s=input()
ans,c=[0]*q,[0]*n
k=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        k+=1
    c[i]=k

for i in range(q):
    l,r=map(int,input().split())
    ans[i]=c[r-1]-c[l-1]
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
import fractions
def gcdlist(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    return ans

n,y=map(int,input().split())
x=list(map(int,input().split()))
l=[]
if y==1:
    print(abs(x[0]-1))
    exit()

for i in range(n-1):
    l.append(abs(x[i+1]-x[i]))
print(gcdlist(l)) 

Fixed submission:
import fractions
def gcdlist(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    return ans

n,y=map(int,input().split())
x=list(map(int,input().split()))
x.append(y)
if y==1:
    print(abs(x[0]-1))
    exit()

l=[]
for i in range(n):
    l.append(abs(x[i+1]-x[i]))
print(gcdlist(l))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
l,r=[],[]
ans=float("inf")
for i in range(n):
    k=0
    l=s[:i]
    r=s[i:]
    k+=l.count("W")
    k+=r.count("E")
    ans=min(ans,k)
print(ans)

Fixed submission:
n=int(input())
s=input()
l,r=[],[]
ans=min(s.count("W"),s.count("E"))
k=s.count("E")
for i in range(n):
    if s[i]=="W":
        k+=1
    else:
        k-=1
    ans=min(ans,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n=int(input())
x=list(map(int,input().split()))
y=copy.copy(x)
s=0
y.sort()
for i in range(n):
    s=x[i]
    if y.index(s)>=n/2:
        print(y[n//2-1])
    else:
        print(y[n//2])
        


Fixed submission:
import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print(xs[n//2])
    else:
        print(xs[n//2-1])

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n=int(input())
x=list(map(int,input().split()))
y=copy.copy(x)
s=0
for i in range(n):
    s=x[i]
    y.remove(s)
    y.sort()
    print(y[n//2-1])
    y.append(s)


Fixed submission:
import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print(xs[n//2])
    else:
        print(xs[n//2-1])

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import statistics

n=int(input())
x=list(map(int,input().split()))
y=copy.copy(x)
s=0
for i in range(n):
    s=x[i]
    y.remove(s)
    print(statistics.median(y))
    y.append(s)


Fixed submission:
import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print(xs[n//2])
    else:
        print(xs[n//2-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
l=list(set(a))
ans=0
for i in range(len(l)):
    if a.count(l[i])<l[i]:
        ans+=a.count(l[i])
    else:
        ans+=a.count(l[i])-l[i]
print(ans)

Fixed submission:
import collections
n=int(input())
a=list(map(int,input().split()))
l=list(set(a))
m=collections.Counter(a)
ans=0
for i in range(len(l)):
    if m[l[i]]<l[i]:
        ans+=m[l[i]]
    else:
        ans+=m[l[i]]-l[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
c=collections.Counter(a)
if len(c)<k:
    print(ans)
    exit()

for i in range(1,-k+len(c)+1):
    ans+=c.most_common()[-i][1]
print(ans)


Fixed submission:
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
c=collections.Counter(a)
if len(c)<k:
    print(ans)
    exit()
l=c.most_common()
for i in range(1,-k+len(c)+1):
    ans+=l[-i][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in range(n-1):
    k=1
    while a[i]+2>=a[i+k]:
        k+=1
        if i+k>=n:
            break
    ans=max(ans,k)
print(ans)

Fixed submission:
from collections import Counter as C
n=int(input())
a=list(map(int,input().split()))
a.sort()
aset=list(set(a))
ca = C(a)
ans=0
for i in aset:
    if ans<ca[i-1]+ca[i]+ca[i+1]:
        ans=ca[i-1]+ca[i]+ca[i+1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n,m=map(int,input().split())
a,b,c=[],[],[]
for i in range(m):
    A=list(map(int,input().split()))
    a.append(A)
for i in range(m):
    if a[i][1]==n:
        b.append(a[i][0])
    elif a[i][0]==1:
        c.append(a[i][1])
if len(b)>0:
    b=list(set(b))
    c=list(set(c))
    for i in b:
        for j in c:
            if i==j:
                print("POSSIBLE")
                exit()
print("IMPOSSIBLE")


Fixed submission:
import collections

n,m=map(int,input().split())
a,b,c=[],[],[]
for i in range(m):
    A=list(map(int,input().split()))
    a.append(A)
for i in range(m):
    if a[i][1]==n:
        b.append(a[i][0])
    elif a[i][0]==1:
        c.append(a[i][1])
if len(set(b)&set(c))>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(str,input().split()))
b=[]
for i in range(n):
    b.append(a[i])
    b.reverse()
print(" ".join(b))


Fixed submission:
n=int(input())
a=list(map(str,input().split()))
b,c=[],[]
if n%2==0:
    for i in range(n):
        if i%2==0:
            b.append(a[i])
        else:
            c.append(a[i])
    c.reverse()
else:
    for i in range(n):
        if i%2==1:
            b.append(a[i])
        else:
            c.append(a[i])
    c.reverse()
print(" ".join(c+b))
Buggy python submission (verdict: Time Limit Exceeded):
def factorial(n):
    f=1
    for i in range(1,n+1):
        f*=i%(10**9+7)
    return f
n,m=map(int,input().split())
N=factorial(n)
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(2*N*N%(10**9+7))
elif n>m:
    print((N*N//n)%(10**9+7))
else:
    print(N*N*m%(10**9+7))

Fixed submission:
import math
n,m=map(int,input().split())
N=math.factorial(n)
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(2*N*N%(10**9+7))
elif n>m:
    print((N*N//n)%(10**9+7))
else:
    print(N*N*m%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a,b=[],[]
for i in range(n):
    A,B=map(int,input().split())
    b=[A]*B
    a=a+b
a.sort()
print(a[k-1])

Fixed submission:
n,k=map(int,input().split())
a=[]
for i in range(n):
    A=list(map(int,input().split()))
    a.append(A)
a = sorted(a, key=lambda x: x[0])
b=0
for i in range(n):
    b+=a[i][1]
    if b>=k:
        print(a[i][0])
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
a=0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i+j+l==s:
                a+=1
print(a)

Fixed submission:
k,s=map(int,input().split())
a=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=s-i-j<k+1:
            a+=1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x=map(int,input().split())
c=0
for i in range(a,b+1):
    if i%x==0:
        c+=1
print(c)

Fixed submission:
a,b,x=map(int,input().split())
print(b//x-(a-1)//x)
Buggy python submission (verdict: Runtime Error):
import random
D=int(input())
C=np.array(list(map(int,input().split())))
S=[]
for _ in range(D):
    S.append(list(map(int,input().split())))



for i in range(D):
    print(random.randint(1,26))

Fixed submission:
import random
import numpy as np


D=int(input())
C=np.array(list(map(int,input().split())))
S=[]
for _ in range(D):
    S.append(list(map(int,input().split())))


T=[]
for i in range(D):
    print(np.argmax(S[i])+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())-1
if n!=0:
    res=[]
    for b in reversed(basis):
        res.append(n//b)
        n=n%b

    ans=[]
    flag=False
    for x in res:
        if x!=0:
            flag=True
        if flag:
            ans.append(chr(ord("a")+x))

    print("".join(ans))
else:
    print("a")

Fixed submission:
n=int(input())

basis=[26**i for i in range(12)]
l=[]
s=0
for b in basis:
    s+=b
    l.append(s)    

i=0
f=12
while(f-i>1):
#     print(f-i)
    x=(i+f)//2
    if l[x]>n:
        f=x
    else:
        i=x

k=n-l[i]
length=i+1

res=[]
for i in range(length):
    q=k//26
    r=k%26
    k=q
    res.append(r)

ans=list(map(lambda x: chr(ord("a")+x),list(reversed(res))))
print("".join(ans))

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

ans=[]
while(n!=0):
    m=n%p
    n=n//p
    ans.append(m)

res=list(map(lambda x: chr(ord("a")-1+x),ans))

print("".join(res))

Fixed submission:
n=int(input())

basis=[26**i for i in range(12)]
l=[]
s=0
for b in basis:
    s+=b
    l.append(s)    

i=0
f=12
while(f-i>1):
#     print(f-i)
    x=(i+f)//2
    if l[x]>n:
        f=x
    else:
        i=x

k=n-l[i]
length=i+1

res=[]
for i in range(length):
    q=k//26
    r=k%26
    k=q
    res.append(r)

ans=list(map(lambda x: chr(ord("a")+x),list(reversed(res))))
print("".join(ans))
Buggy python submission (verdict: Runtime Error):
a,b=map(float,input().split())
b=int(float(b)*100)
a=int(a)
print(int(a*tempb)//100)


Fixed submission:
a,b=map(str,input().split())
tempb=int(float(b)*1000)
tempa=int(a)
print(int(tempa*tempb)//1000)

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


Fixed submission:
a,b=map(str,input().split())
tempb=int(float(b)*1000)
tempa=int(a)
print(int(tempa*tempb)//1000)

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


Fixed submission:
a,b=map(str,input().split())
tempb=int(float(b)*1000)
tempa=int(a)
print(int(tempa*tempb)//1000)
Buggy python submission (verdict: Runtime Error):
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[]
for i in range(N):
    B.append(int(input()))

import numpy as np
A=np.array(A)
mask=np.isin(A,B)

bingo=np.zeros((3,3),int)
bingo[mask]=1

flag=False
for x in bingo.sum(axis=1):
    if x ==3:
        flag=True
for x in bingo.sum(axis=0):
    if x ==3:
        flag=True
y=0
for i in range(3):
    y+=bingo[i,i]
if y==3:
    flag=True
y=0
for i in range(3):
    y+=bingo[2-i,i]
if y==3:
    flag=True

if flag:
    print("Yes")
else:
    print("No")

Fixed submission:
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[]
for i in range(N):
    B.append(int(input()))

import numpy as np
A=np.array(A)

bingo=np.zeros((3,3),int)
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            bingo[i][j]=1

flag=False
for x in bingo.sum(axis=1):
    if x ==3:
        flag=True
for x in bingo.sum(axis=0):
    if x ==3:
        flag=True
y=0
for i in range(3):
    y+=bingo[i,i]
if y==3:
    flag=True
y=0
for i in range(3):
    y+=bingo[2-i,i]
if y==3:
    flag=True

if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):

N,M=map(int,input().split())
SC=[]
for i in range(M):
    SC.append(list(map(int,input().split())))

import numpy as np
SC=np.array(SC)


keta=np.unique(SC[:,0])
flag=0
for i in keta:
    if len(np.unique(SC[SC[:,0]==i],axis=0))>=2:
        flag=1
for x in SC[SC[:,0]==1]:
    if x[1]==0:
        flag=1

ans=[0]*N
ans[0]=1
if flag!=1:
    for i in keta:
        ans[i-1]=np.unique(SC[SC[:,0]==i],axis=0)[0][1]
    ans2=""
    for a in ans:
        ans2+=str(a)
    print(ans2)
else:
    print(-1)

Fixed submission:
N,M=map(int,input().split())
ans=[0]*N
SC=[0]*N
flag=0
flag2=0
for i in range(M):
    s,c=map(int,input().split())
    if s-1==0:
        flag2=1
    if SC[s-1]==1:
        if ans[s-1]!=c:
            flag=1
    else:
        SC[s-1]=1
        ans[s-1]=c

if flag2==0 and N!=1:
    ans[0]=1

if ans[0]==0 and N!=1:
    flag=1

if flag==0:
    ans2=""
    for a in ans:
        ans2+=str(a)
    print(ans2)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):

N,M=map(int,input().split())
SC=[]
for i in range(M):
    SC.append(list(map(int,input().split())))

import numpy as np
SC=np.array(SC)


keta=np.unique(SC[:,0])
flag=0
for i in keta:
    if len(np.unique(SC[SC[:,0]==i]))>=3:
        flag=1
for x in SC[SC[:,0]==1]:
    if x[1]==0:
        flag=1

ans=[0]*N
ans[0]=1
if flag!=1:
    for i in keta:
        ans[i-1]=np.unique(SC[SC[:,0]==i])[1]
    ans2=""
    for a in ans:
        ans2+=str(a)
    print(ans2)
else:
    print(-1)

Fixed submission:
N,M=map(int,input().split())
ans=[0]*N
SC=[0]*N
flag=0
flag2=0
for i in range(M):
    s,c=map(int,input().split())
    if s-1==0:
        flag2=1
    if SC[s-1]==1:
        if ans[s-1]!=c:
            flag=1
    else:
        SC[s-1]=1
        ans[s-1]=c

if flag2==0 and N!=1:
    ans[0]=1

if ans[0]==0 and N!=1:
    flag=1

if flag==0:
    ans2=""
    for a in ans:
        ans2+=str(a)
    print(ans2)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
mod=10 ** 9 + 7

n, a, b = map(int, input().split())

def power(x,n):
    if n==0:
        return 1
    elif n%2==0:
        half=power2(x,n//2)
        return half**2 %mod
    else:
        half=power2(x,(n-1)//2)
        return  half**2 * x %mod

def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

ans=(power(2,n) - binomial(n,a) -binomial(n,b))%mod

print(ans)

Fixed submission:
mod=10 ** 9 + 7

n, a, b = map(int, input().split())

def power(x,n):
    if n==0:
        return 1
    elif n%2==0:
        half=power(x,n//2)
        return half**2 %mod
    else:
        half=power(x,(n-1)//2)
        return  half**2 * x %mod

def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*power(y,mod-2)%mod

ans=(power(2,n)-1 - binomial(n,a) -binomial(n,b))%mod

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))

def s(x):
    return (1+x)/2


wa=sum(P[0:K])
for i in range(N-K):
    wa+=P[i+K]
    wa-=P[i]
    if temp <= wa:
        temp=wa

ans=s(temp+K-1)
print(ans)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))

def s(x):
    return (1+x)/2


wa=sum(P[0:K])
temp=sum(P[0:K])
for i in range(N-K):
    wa+=P[i+K]
    wa-=P[i]
    if temp <= wa:
        temp=wa

ans=s(temp+K-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))

def s(x):
    return (1+x)/2

wa=0
for i in range(N-K+1):
    temp=sum(P[i:i+K])
    if wa <= temp:
        wa=temp

ans=s(wa+K-1)
print(ans)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))

def s(x):
    return (1+x)/2


wa=sum(P[0:K])
temp=sum(P[0:K])
for i in range(N-K):
    wa+=P[i+K]
    wa-=P[i]
    if temp <= wa:
        temp=wa

ans=s(temp+K-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
P=list(map(int,input().split()))

def s(x):
    return (1+x)/2

start=0
wa=0
for i in range(N-K+1):
    temp=sum(P[i:i+K])
    if wa <= temp:
        start=i
        wa=temp

ans=0
for i in P[start:start+K]:
    ans+=s(i)
print(ans)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))

def s(x):
    return (1+x)/2


wa=sum(P[0:K])
temp=sum(P[0:K])
for i in range(N-K):
    wa+=P[i+K]
    wa-=P[i]
    if temp <= wa:
        temp=wa

ans=s(temp+K-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
XL=[]
for i in range(N):
    a,b=map(int,input().split())
    XL.append([a-b,a+b])
    #XL.append(list(map(int,input().split())))
XL=np.array(XL)

ans=0
end=-10**(19)
for i in range(N):
    x=XL[XL[:,0]>=end][:,1]
    if x.size!=0:
        end=min(x)
        ans+=1
    else:
        break
print(ans)

Fixed submission:
N=int(input())
XL=[]
for i in range(N):
    a,b=map(int,input().split())
    XL.append([a-b,a+b])
    #XL.append(list(map(int,input().split())))
XL=sorted(XL,key = lambda x: (x[1], x[0]))




ans=0
end=-10**(19)
for i in range(N):
    if XL[i][0]>=end:
        ans+=1
        end=XL[i][1]
        
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
ans=0
for s in S:
    
    if s=="A":
        c=1
    elif s=="B" and c==1:
        c=2
    elif s=="C" and c==2:
        ans+=1
        c=0
    else:
        c=0

print(ans)

Fixed submission:
N=int(input())
S=input()
ans=0
c=0
for s in S:
    
    if s=="A":
        c=1
    elif s=="B" and c==1:
        c=2
    elif s=="C" and c==2:
        ans+=1
        c=0
    else:
        c=0

print(ans)
Buggy python submission (verdict: Runtime Error):
 S, T =input().split()
print(T+S)

Fixed submission:
S, T =input().split()
print(T+S)
Buggy python submission (verdict: Runtime Error):
n=len(S)
ans=0
for i in range(n//2):
    if S[i]!=S[n-i-1]:
        ans+=1
print(ans)

Fixed submission:
S=input()
n=len(S)
ans=0
for i in range(n//2):
    if S[i]!=S[n-i-1]:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)

Fixed submission:
def counter(x):
    if x==0:
        return 0
    return counter(x >> 1) + (x & 1)
N=int(input())
A=[[]]
X=[[]]
Y=[[]]
for i in range(1,N+1):
    a=int(input())
    A.append(a)
    x=[[]]
    y=[[]]
    for j in range(a):
        b=list(map(int,input().split()))
        x.append(b[0])
        y.append(b[1])
    X.append(x)
    Y.append(y)
ans=0
for bits in range(1 << N):
    #print(bin(bits))
    ok=True
    for i in range(1,N+1):
        if not (bits & (1<<i-1)):
            continue
        for j in range(1,A[i]+1):
            if(((bits >> (X[i][j]-1)) & 1) ^ Y[i][j]):
                ok = False
        
    if ok:
#        print(ok,bin(bits))
        ans = max(ans, counter(bits))
print(ans)
Buggy python submission (verdict: Runtime Error):
X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*power(y,mod-2)%mod

a=(2*X-Y)//3
b=(2*Y-X)//3

print(binomial(a+b,a)%mod)



Fixed submission:
X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

if (2*X-Y)%3==0 and  (2*Y-X)%3==0:
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    if a<0 or b<0:
        print(0)        
    else:
        print(binomial(a+b,a)%mod)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import math
# from scipy.special import factorial, poch
ppp=10**9+7
x,y =map(int, input().split())
a=[-(x-2*y)//3,-(-2*x+y)//3]
b=[-(x-2*y)%3,-(-2*x+y)%3]
if b[0]==0 and b[1]==0:
    print(math.factorial(a[0]+a[1])//math.factorial(a[0])//math.factorial(a[1])%ppp)
    
else:
    print(0)

Fixed submission:
X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

if (2*X-Y)%3==0 and  (2*Y-X)%3==0:
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    if a<0 or b<0:
        print(0)        
    else:
        print(binomial(a+b,a)%mod)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import math
from scipy.special import factorial, poch
ppp=10**9+7
x,y =map(int, input().split())
a=[-(x-2*y)//3,-(-2*x+y)//3]
b=[-(x-2*y)%3,-(-2*x+y)%3]
if b[0]==0 and b[1]==0:
    print(math.factorial(a[0]+a[1])//math.factorial(a[0])//math.factorial(a[1])%ppp)
    
else:
    print(0)

Fixed submission:
X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

if (2*X-Y)%3==0 and  (2*Y-X)%3==0:
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    if a<0 or b<0:
        print(0)        
    else:
        print(binomial(a+b,a)%mod)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A,B,X=map(int, input().split())
C=2*X/(A*B)
if C<=A:
    math.atan(B/C)*(180)/math.pi
    C=2*X/(A*B)
    print(math.atan(B/C)*(180)/math.pi)
else:
    C=2*Y/(A*A)
    Y=A*A*B-X
    C=2*Y/(A*A)
    print(math.atan(C/A)*(180)/math.pi)
    

Fixed submission:
N=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=10**12
for i in make_divisors(N):
    j=N//i
    if ans>i+j:
        ans=i+j

print(ans-2)
Buggy python submission (verdict: Runtime Error):
A,B,X=map(int, input().split())
C=2*X/(A*B)
if C<=A:
    math.atan(B/C)*(180)/math.pi
    C=2*X/(A*B)
    print(math.atan(B/C)*(180)/math.pi)
else:
    C=2*Y/(A*A)
    Y=A*A*B-X
    C=2*Y/(A*A)
    print(math.atan(C/A)*(180)/math.pi)
    

Fixed submission:
import math
A,B,X=map(int, input().split())
C=2*X/(A*B)
if C<=A:
    math.atan(B/C)*(180)/math.pi
    C=2*X/(A*B)
    print(math.atan(B/C)*(180)/math.pi)
else:
    Y=A*A*B-X
    C=2*Y/(A*A)
    
    C=2*Y/(A*A)
    print(math.atan(C/A)*(180)/math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np
N=int(input())
L=list(map(int, input().split()))
L.sort()
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        l=L[i]+L[j]
        for k in range(j+1,N):
            if L[k]<l:
                ans+=1
            else:
                break
print(ans)    

Fixed submission:
# import numpy as np
N=int(input())
L=list(map(int, input().split()))
L.sort()
ans=0
for i in range(N-2):
    k=i+2
    for j in range(i+1,N-1):
        l=L[i]+L[j]
        while(L[k]<l):
#           print(i,j,k)
            k+=1
            if k==N:
                break
        k-=1
        ans+=k-j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,A,B = map(int, input().split())
ans=np.zeros([H,W], int)
ans[:B,A:]=1
ans[B:,:A]=1
for x in ans:
    maped_num = map(str, x)
    mojiretsu = ''.join(maped_num)
    print(mojiretsu)




Fixed submission:
H, W, A, B = map(int, input().split())

for _ in range(B):
  print(''.join(['0'] * A + ['1'] * (W-A)))
for _ in range(H-B):
  print(''.join(['1'] * A + ['0'] * (W-A)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,A,B = map(int, input().split())
ans=np.zeros([H,W], int)
ans[:B,A:]=1
ans[B:,:A]=1
for x in ans:
    maped_num = map(str, x) #格納される数値を文字列にする
    mojiretsu = ''.join(maped_num)
    print(''.join(mojiretsu))




Fixed submission:
H, W, A, B = map(int, input().split())

for _ in range(B):
  print(''.join(['0'] * A + ['1'] * (W-A)))
for _ in range(H-B):
  print(''.join(['1'] * A + ['0'] * (W-A)))