Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02862 (python)

Fixed submission:
mod = 10**9+7

def fact(n):
    ans = 1
    for i in range(2,n+1):
        ans *= i
        ans %= mod
    return ans
    
X,Y = list(map(int,input().split()))

# a+2b = X
# 2a+b = Y を解く
# -> a = (2Y-X)/3, b = (2X-Y)/3
# (i+1,j+2) の移動が a 回
# (i+2,j+1) の移動が b 回

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

if (X+Y)%3 != 0 or a<0 or b<0:
    print(0)
    exit(0)

# a回とb回の移動の組み合わせは (a+b)!/a!b!
print(fact(int(a+b)) * pow(fact(int(a)),mod-2,mod) * pow(fact(int(b)),mod-2,mod) % mod)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
X,Y = list(map(int,input().split()))

# a+2b = X
# 2a+b = Y を解く
# -> a = (2Y-X)/3, b = (2X-Y)/3
# (i+1,j+2) の移動が a 回
# (i+2,j+1) の移動が b 回

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

if not a.is_integer() or not b.is_integer():
    print(0)
    exit(0)

# a回とb回の移動の組み合わせは (a+b)!/a!b!
print(cmb(int(a+b),int(a),mod))
Problem p02820 (python)

Fixed submission:
N,K=map(int, input().split()) 
R,S,P=map(int, input().split()) 
T=input()
SC=0

def point(w):
    if w=='r':
        return P
    elif w=='s':
        return R
    else:
        return S
    
Flag=[True for i in range(N)]

for i in range(N):
    if Flag[i]:
        SC+=point(T[i])
        if i+K<N and T[i]==T[i+K]:
            Flag[i+K]=False
print(SC)

Buggy submission (verdict: Runtime Error):
N,K=map(int, input().split()) 
R,S,P=map(int, input().split()) 
T=input()
SC=0

def point(w):
    if w=='r':
        return P
    elif w=='s':
        return R
    else:
        return S
    
Flag=[True for i in range(N)]

for i in range(N):
    SC+=point(T[i])
    if i+K<N and T[i]==T[i+K]:
        Flag[i+K]=False
return(SC)
Problem p02829 (python)

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

print("{}".format(6-a-b))

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

n,u,v=map(int, input().split())
S = []
for _ in range(n-1):
    S.append(list(map(int, input().split())))

pt= [[0]*0 for i in range(n)] 
for i in range(n-1):
    pt[S[i][0]-1].append(S[i][1])
    pt[S[i][1]-1].append(S[i][0])

def bfs(v):
    d=[-1]*n
    d[v-1]=0
    q=[v]
    c=1
    while q:
        q1=[]
        for i in q:
            for j in pt[i-1]:
                if d[j-1]==-1:
                    d[j-1]=c
                    q1.append(j)
        q=q1
        c+=1
        #print(d,q)
    return d
bfs_v=np.array(bfs(v))
bfs_u=np.array(bfs(u))
bfs_v_replace=bfs_v[bfs_v>bfs_u]
answer=np.max(bfs_v_replace)-1
print("{}".format(answer))
Problem p02835 (python)

Fixed submission:
a1,a2,a3=map(int, input().split()) 

if a1+a2+a3>=22:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
def main():
    """"ここに今までのコード"""

n = int(input())
A = [int(a) for a in input().split()]
mod=10**9+7

ans=0
for i in range(60):
    l=sum([a>>i & 1 for a in A])
    ans+= l*(n-l) <<i
    ans%= mod
    
print(ans) 

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    """"ここに今までのコード"""
 
n = int(input())
A = [int(a) for a in input().split()]
mod=10**9+7
 
ans=0
for i in range(60):
    l=sum([a%2 for a in A])
    ans=(ans+l*(n-l)*(2**i))%mod
    A=[a//2 for a in A]

print(int(ans)) 
 
if __name__ == '__main__':
    main()
Problem p02847 (python)

Fixed submission:
S=input()

A=['SAT','FRI','THU','WED','TUE','MON','SUN']

print(A.index(S)+1)

Buggy submission (verdict: Runtime Error):
S=input()

A=['SAT','FRI','THU','WED','THU','MON','SUN']

print(A.index(S)+1)
Problem p02829 (python)

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

c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
a,b=(int(x), for x in input().splite())
c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
a,b=(int(x), for x in input().splite())
c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
a,b=(int(x), for x in input().splite())
c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
a,b=int(input())
c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)
Problem p02835 (python)

Fixed submission:
a,b,c=(int(x) for x in input().split())

sum =a+b+c
if sum>=22:
  print("bust")
else:
  print("win")

Buggy submission (verdict: Runtime Error):
a,b,c=(int(x) for x in input().split())

sum =a+b+c
if sum>=22:
  print(bust)
else:
  print(win)

Buggy submission (verdict: Runtime Error):
a,b,c=(int(x) for x in input().split())

sum =a+b+c
if sum>=22:
  print(bust)
else
  print(win)
Problem p02847 (python)

Fixed submission:
char=input()

week=("SUN","MON","TUE","WED","THU","FRI","SAT")

print(7-week.index(char))

Buggy submission (verdict: Runtime Error):
char=input()

week=("SUN","MON","TUE","WED","THU","FRI","SAT")

print(7-week.index())
Problem p02879 (python)

Fixed submission:
a,b=(int(x) for x in input().split())
 
if a<=9 and b<=9:
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
a,b=int(input())

if a<=10 && b<=10:
  print(a*b)
else:
  print(-1)
Problem p02970 (python)

Fixed submission:
N = map(int,raw_input().split())
for i in range(10):
        A =N[0]-(N[1]*2+1)*i
        if A <= 0:
                print(i)
                exit()
        else:
                pass

Buggy submission (verdict: Runtime Error):
N = map(int,raw_input()).split()
for i in range(100):
  A = N[0]-(N[1]*2+1)*i
  if A >= 0:
    pass
  else:
    print(i)
    exit()
Problem p02831 (python)

Fixed submission:
a,b = (int(i) for i in input().split())

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
a,b = (int(i) for i in input().split())

import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02915 (python)

Fixed submission:
n = int(input())

m = n**3

print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)
Problem p02916 (python)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val-1]]
	else:
		pass

print(score)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[val]
	else:
		pass

print(score)
Problem p02819 (python)

Fixed submission:
# coding: utf-8
 
def is_prime2(q,k=100):
  q = abs(q)
  if q == 2: return True
  if q < 2 or q&1 == 0: return False
  for i in range(3,k):
    x,y = q,i
    while y:
      x, y =  y, x % y
    if x != 1: continue
    if pow(i, q-1, q) != 1:
      return False
  return True
 
X = int(input())
 
for i in range(X,10**5+4):
  if is_prime2(i):
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
# coding: utf-8

def is_prime2(q,k=100):
  q = abs(q)
  if q == 2: return True
  if q < 2 or q&1 == 0: return False
  for i in xrange(3,k):
    x,y = q,i
    while y:
      x, y =  y, x % y
    if x != 1: continue
    if pow(i, q-1, q) != 1:
      return False
  return True

X = int(input())

for i in range(X,10**5+4):
  if is_prime(i):
    print(i)
    exit()
Problem p02835 (python)

Fixed submission:
import sys

def main():
    input_list = input().split(" ")
    a1, a2, a3 = int(input_list[0]), int(input_list[1]), int(input_list[2])
    if a1 + a2 + a3 >= 22:
        print('bust')
    else:
        print('win')

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    num = input()
    num_list = list(map(int, input().split(" ")))
    # result = sum([sum([num_list[i]^num_list[j] for j in range(i)]) for i in range(int(num))])
    result = 0
    for i in range(int(num)):
        for j in range(i):
            result += num_list[i]^num_list[j]
    print(result%(10**9+7))    

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    num = input()
    num_list = list(map(int, input().split(" ")))
    result = sum([sum([num_list[i]^num_list[j] for j in range(i)]) for i in range(int(num))])
    print(result%(10**9+7))    

if __name__ == "__main__":
    main()
Problem p02832 (python)

Fixed submission:
N=int(input())
number=input().split(' ')
number_list=[]
for i in number:
    number_list.append(int(i))
index=1
flag=0
count=0
for i in number_list:
    if(i==1 and flag==0):
        flag=1
        index+=1
    elif (i==index):
        index+=1
    else:
        count+=1

if(flag==0):
    print(-1)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())
gcc=1
i=2
while True:
    if(a<i or b<i):
        break
    elif (a%i==0 and b%i==0):
        gcc*=i
        a/=i
        b/=i
        i=2
    else:
        i+=1

print(int(a*b*gcc))
Problem p02897 (python)

Fixed submission:
N=int(input())
count=0.0
for i in range(1,N+1):
    if(i%2!=0):
        count+=1

print(count/N)

Buggy submission (verdict: Runtime Error):
N=float(input())
count=0
for i in range(N):
    if(i%2==0):
        count+=1

print(count/N)
Problem p03073 (python)

Fixed submission:
def case_1 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==0):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

def case_2 (S,size):
    count=0
    for i in range(0,size):
        if (i%2==1):
            if(int(S[i])==0):
                count+=1
        else:
            if(int(S[i])==1):
                count+=1
    return count

S=str(input())
size=len(S)
can_1=case_1(S,size)
can_2=case_2(S,size)
print(min(can_1,can_2))

Buggy submission (verdict: Runtime Error):
import math
number = int(input())
if (number != 0):
    digit = int(math.log10(number))
else :
    digit=0

a=[]
while(True):
    if (number%10==0):
        a.append("0")
    elif (number%10!=0):
        a.append("1")
    
    number= int(number/10)
    if (number == 0):
        break
b= []
i = digit

while(i !=-1):
    b.append(a[i])
    i -= 1
print(b)

count1=0
count2=0
for j in range(0,digit+1):
    if (j % 2 ==0):
        if b[j]=="1":
            count1 +=1 
    elif (j %2 ==1):
        if b[j]=="0":
            count1 +=1
for j in range(0,digit):
    if (j % 2 ==0):
        if b[j]=="0":
            count2 +=1 
    elif (j %2 ==1):
        if b[j]=="1":
            count2 +=1
print(min(count1,count2))
Problem p03075 (python)

Fixed submission:
def main():
    antenna = []
    for i in range(5):
        antenna.append(int(raw_input()))
    k = int(raw_input())
    if (antenna[-1] - antenna[0]) <= k:
        print("Yay!")
    else:
        print(":(")



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    antenna = []
    for i in range(5):
        antenna.append(int(raw_input()))
    k = int(raw_input())
    if (antenna[-1] - antenna[0]) < k:
        print("yes")
    else:
        print("no")



if __name__ == "__main__":
    main()
Problem p03077 (python)

Fixed submission:
def main():

    capa = []
    n = int(raw_input())
    ans = 0

    for i in range(5):
        capa.append(int(raw_input()))
    sorted_capa = sorted(capa)
    if n % sorted_capa[0] == 0:
        ans = 4 + n//sorted_capa[0]
    else:
        ans = 4 + n//sorted_capa[0] + 1
    print(ans)
    """
    people = [n]
    for i in range(5):
        people.append(0)
    print(capa,people)
    while people[-1] < n:
        for i in reversed(range(0,6)):
            if i != 0:
                people[i] += min(people[i-1],capa[i-1])
                people[i-1] -= min(people[i-1],capa[i-1])
        time += 1
        print(people,time)
    print(time)

    """
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():

    capa = []
    n = int(raw_input())
    ans = 0

    for i in range(5):
        capa.append(int(raw_input()))
    if n % sorted_capa[0] == 0:
        ans = 4 + n//sorted_capa[0]
    else:
        ans = 4 + n//sorted_capa[0] + 1
        print(ans)
    """
    people = [n]
    for i in range(5):
        people.append(0)
    print(capa,people)
    while people[-1] < n:
        for i in reversed(range(0,6)):
            if i != 0:
                people[i] += min(people[i-1],capa[i-1])
                people[i-1] -= min(people[i-1],capa[i-1])
        time += 1
        print(people,time)
    print(time)

    """
if __name__ == "__main__":
    main()
Problem p02819 (python)

Fixed submission:
def is_prime2(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True

c = int(input())
for i in range(c, 10**6):
    if is_prime2(i):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
def is_prime2(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in xrange(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True

c = int(input())
for i in range(c, 10**6):
    if is_prime(i):
        print(i)
        break
Problem p02948 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
day = [[] for _ in range(10**5+1)]
for _ in range(n):
    a, b = map(int, input().split())
    day[a].append(b)
benefit = []
heapq.heapify(benefit)
ans = 0
for i in range(1, m+1):
    for j in day[i]:
        heapq.heappush(benefit, -j)
    if benefit:
        ans -= heapq.heappop(benefit)  # 最大値を加算
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
n, m = map(int, input().split())
day = [[] for _ in range(m+1)]
for _ in range(n):
    a, b = map(int, input().split())
    day[a].append(b)
benefit = []
heapq.heapify(benefit)
ans = 0
for i in range(1, m+1):
    for j in day[i]:
        heapq.heappush(benefit, -j)
    if benefit:
        ans -= heapq.heappop(benefit)  # 最大値を加算
print(ans)
Problem p02954 (python)

Fixed submission:
s = input()
tmp = [0]
for i in range(len(s)-1):
    if s[i] != s[i+1]:  # RとLが切り替わる時のインデックスを保存
        tmp.append(i+1)
tmp.append(len(s))
ans = [0 for i in range(len(s))]
for i in range(len(tmp)-1):
    if i % 2 == 1:
        ans[tmp[i]] = (tmp[i]-tmp[i-1])//2 + (tmp[i+1]-tmp[i]+1)//2
        ans[tmp[i]-1] = (tmp[i+1]-tmp[i])//2 + (tmp[i]-tmp[i-1]+1)//2
print(*ans)
# RRLLLLRLRRLL

Buggy submission (verdict: Runtime Error):
S = list(input())
position = [1] * len(S)
prev = position.copy()
for i in range(10**100):
    prev_prev = prev.copy()
    prev = position.copy()
    tmp = position.copy()
    for j, s in enumerate(S):
        if position[j] != 0:
            if s == 'R':
                position[j+1] += tmp[j]
                position[j] -= tmp[j]
            elif s == 'L':
                position[j-1] += tmp[j]
                position[j] -= tmp[j]
    if position == prev:
        print(*prev)
        break
    elif position == prev_prev:
        print(*prev_prev)
        break
Problem p03013 (python)

Fixed submission:
import re
import math

def fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int, input().split())
step = ['0']*(n+1)
for i in range(m):
    a = int(input())
    step[a] = '1'
steps = ''.join(step)

a = re.findall('000*', steps)
b = len(re.findall('11', steps))
# print(steps)
count = 1
for i in a:
    count *= fib(len(i)+1) % 1000000007

if b != 0:
    print(0)
else:
    print(count % 1000000007)

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

def fib(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fib(n-1)+fib(n-2)

n,m = map(int, input().split())
step = ['0']*(n+1)
for i in range(m):
    a = int(input())
    step[a] = '1'
steps = ''.join(step)

a = re.findall('000*', steps)
b = len(re.findall('11', steps))
# print(steps)
count = 1
for i in a:
    count *= fib(len(i)+1) % 1000000007

if b != 0:
    print(0)
else:
    print(count % 1000000007)

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

def fib(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fib(n-1)+fib(n-2)

n,m = map(int, input().split())
step = ['0']*(n+1)
for i in range(m):
    a = int(input())
    step[a] = '1'
steps = ''.join(step)

a = re.findall('0+', steps)
b = len(re.findall('11', steps))
# print(steps)
count = 1
for i in a:
    count *= fib(len(i)+1) % 1000000007

if b != 0:
    print(0)
else:
    print(round(count % 1000000007))

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

def fib(n):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fib(n-1)+fib(n-2)

n,m = map(int, input().split())
step = ['0']*(n+1)
for i in range(m):
    a = int(input())
    step[a] = '1'
steps = ''.join(step)

a = re.findall('0+', steps)
b = len(re.findall('11', steps))
# print(steps)
count = 1
for i in a:
    count *= fib(len(i)+1)

if b != 0:
    print(0)
else:
    print(round(count % 1000000007))
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
ans = 0
t = 0
while t < n:
    b, c = a.pop()
    p = min(b, n-t)
    ans += p * c
    t += p
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [(1, int(i) for i in input().split())]
for _ in range(M):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
ans = 0
t = 0
while t < N:
    b, c = a.pop()
    p = min(b, N-t)
    ans += p * c
    t += p
print(ans)
Problem p03011 (python)

Fixed submission:
l = list(map(int, input().split()))
l.sort()
print(sum(l[:2]))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

MOD = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] += dp[i-1] + dp[i-2]
        dp[i] %= MOD

print(dp[n])
Problem p03038 (python)

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0]*m
c = [0]*m
sortsecond = lambda val: val[1]

x = [list(map(int, input().split())) for _ in range(m)]

x.sort(key=sortsecond)

a.sort()


i = 0
for j in range(m):
    times = x[-(j+1)][0]
    number = x[-(j+1)][1]
    while times > 0 :

        try:
            temp = a[i]
        except IndexError:
            print(sum(a))
            exit()
        
        if temp < number:
            a[i] = number
        else:
            print(sum(a))
            exit()
        times -= 1
        i += 1
print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0]*m
c = [0]*m
sortsecond = lambda val: val[1]

x = [list(map(int, input().split())) for _ in range(m)]

x.sort(key=sortsecond)

a.sort()

i = 0
for j in range(m):
    times = x[-(j+1)][0]
    number = x[-(j+1)][1]
    while times > 0 :

        temp = a[i]
        if temp < number:
            a[i] = number
        else:
            print(sum(a))
            exit()
        times -= 1
        i += 1
print(sum(a))
Problem p02859 (python)

Fixed submission:
r=int(input()) 
print(r*r)

Buggy submission (verdict: Runtime Error):
print(int(r*r))
Problem p02862 (python)

Fixed submission:
import numpy as np
v=np.array(list(map(int, input().split())) )
mod = 10**9 +7
import math
def cmb(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = (result*int(numerator[k]))%mod

    return result
  
A = np.array([[2,1],[1,2]])
inv_A = np.linalg.inv(A)

k = np.dot(inv_A,v)

if abs(round(k[0])-k[0])<10**(-10) and abs(round(k[1])-k[1])<10**(-10) and k[0]* k[1] >=0:
  print(int(cmb(int(round(k[0]+k[1])),int(round(k[0])),mod)))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
import numpy as np
v=np.array(list(map(int, input().split())) )
mod = 10**9 +7
import math
def cmb(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = (result*int(numerator[k]))%mod

    return result
  
A = np.array([[2,1],[1,2]])
inv_A = np.linalg.inv(A)

k = np.dot(inv_A,v)

if abs(round(k[0]+ k[1])-(k[0]+k[1]))<10**(-10) and k[0]* k[1] >=0:
  print(cmb(round(k[0]+k[1]),round(k[0]),mod))
else:
  print(0)