Harryxun/stf_run huggingface dataset:
a,b, c = map(int, input().split())
    now = 0
    for num in range(10):
        if num == 0:
            now = a * c -b
        else:
            now = a * now -b
        print(now)

### FIXED CODE ###

a,b, c = map(int, input().split())
now = 0
for num in range(10):
    if num == 0:
        now = a * c -b
    else:
        now = a * now -b
    print(now)
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A
memo = [1]
def dfs(i, town=1):
    global memo
    arrival = A[town]
    if arrival in memo:
        memo.append(arrival)
        return memo
    memo.append(arrival)
    return dfs(i+1, A[town])

table = dfs(0, 1)
indexes = [i for i, x in enumerate(table) if x == table[-1]]
q = indexes[0]
r = (k - q) % (indexes[1] - q)
print(table[q+r])

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A
memo = []
loop = []
visit = [0]*n
town = 1
while visit[town-1] < 2:
    if visit[town-1] == 0:
        memo.append(town)
    else:
        loop.append(town)
    visit[town-1] += 1
    town = A[town]
outlier = len(memo) - len(loop) 
T = len(loop)
if k <= outlier:
    print(memo[k])
else:
    print(loop[(k-outlier) % T])
a, b = map(int, input(). split())
if (a*b) % 2:
print ("Odd")
else: print("Even")

### FIXED CODE ###

a, b = map(int, input(). split())
if (a*b) % 2:
  print("Odd")
else: 
  print("Even")
# -*- coding: utf-8 -*-
K,S=map(int,input().split())
count=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      if i+j+k=S:
        count=count+1
print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    k=S-i-j
    if 0<=k<=K:
      count=count+1
print(count)
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()

from collections import deque
def resolve():
    drc4 = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + drc4]

    H, W = map(int, input().split())
    sy, sx = map(lambda x: int(x) - 1, inp().split())
    gy, gx = map(lambda x: int(x) - 1, inp().split())
    G = [inpS() for _ in range(H)]

    INF = 10 ** 7
    ans = [[INF] * W for _ in range(H)]

    q = deque()
    q.append((sy, sx, 0))
    ans[sy][sx] = 0

    while q:
        sy, sx, cost = q.popleft()
        for dy, dx in drc4:
            ny, nx = dy + sy, dx + sx
            if 0 <= ny < H and 0 <= nx < W and G[ny][nx] == "." and ans[ny][nx] > cost:
                ans[ny][nx] = cost
                q.append((ny, nx, cost))

        for dy8, dx8 in warp:
            ny8, nx8 = dy8 + sy, dx8 + sx
            if 0 <= ny8 < H and 0 <= nx8 < W and G[ny8][nx8] == "." and ans[ny8][nx8] > cost + 1:
                ans[ny8][nx8] = cost + 1
                q.append((ny8, nx8, cost + 1))

    res = ans[gy][gx] if ans[gy][gx] < INF else -1
    print(res)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###


from collections import deque
def resolve():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]

    INF = 10 ** 12
    path = [[INF] * W for _ in range(H)]

    q = deque()
    path[Ch][Cw] = 0
    q.append((Ch, Cw, 0))

    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    while q:
        x, y, s = q.popleft()
        for dx, dy in walk:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
                path[nx][ny] = s
                q.appendleft((nx, ny, s))
        for dx, dy in warp:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
                path[nx][ny] = s + 1
                q.append((nx, ny, s + 1))

    ans = path[Dh][Dw] if path[Dh][Dw] < INF else -1
    print(ans)


if __name__ == "__main__":
    resolve()
s,t = raw_input.split()
print(t+s)

### FIXED CODE ###

s,t = input().split()
print(t.lower() + s.lower())
import numpy as np
A, B, M = map(int, input().split())
a = np.array([int(i) for i in input().split()], dtype=int)
b = np.array([int(i) for i in input().split()], dtype=int)
x = np.zeros(M, dtype=int)
y = np.zeros(M, dtype=int)
c = np.zeros(M, dtype=int)
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())

non_coupon_val = np.min(a) + np.min(b)
coupon_val_arr = np.zeros(M)
for i in range(M):
  coupon_val_arr[i] = a[x[i]] + b[y[i]] - c[i]
  coupon_val = np.min(coupon_val_arr)
print(np.min([non_coupon_val, coupon_val]))

### FIXED CODE ###

A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = [0 for i in range(M)]
y = [0 for i in range(M)]
c = [0 for i in range(M)]
for i in range(M):
  x[i], y[i], c[i] = map(int, input().split())
non_coupon_val = min(a) + min(b)
coupon_val_arr = [0 for i in range(M)]
for i in range(M):
  coupon_val_arr[i] = a[x[i]-1] + b[y[i]-1] - c[i]
coupon_val = min(coupon_val_arr)
print(min([non_coupon_val, coupon_val]))
a

### FIXED CODE ###

for i in range(1,10):
    for j in range(1,10):
        print str(i) + "x" + str(j) + "=" + str(i * j)
a, b = map(int, input().split())

if a>=13:
    print(b)
elif a>=6:
    print(int(b/2)
else:
    print(0)

### FIXED CODE ###

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

if a>=13:
    print(b)
elif a>=6:
    print(int(b/2))
else:
    print(0)
from collections import deque

N = int(input())
data1 = []
data2 = [[] for i in range(N)]
data3 = [set() for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data1.append([a,b])
    data2[a].append(b)
    data2[b].append(a)

for i in range(N-1):
    a,b = data1[i]
    for x in data2[a]:
        for y in data2[b]:
            if y != a and x != b:
                data3[x].add(y)
                data3[y].add(x)

for i in range(N):
    data3[i] = list(data3[i])

#####print(data3)

s = [0,0,0]
while len(data2[s[0]]) <= 1:
    s[0] += 1

s[1] = data2[s[0]][0]
s[2] = data2[s[0]][1]

stack = deque([[s[0],1],[s[1],1],[s[2],2]])
ans = [0] * N
ans[s[0]] = 1
ans[s[1]] = 4
ans[s[2]] = 2
count = [3,7,5]

while stack:
    p = stack.pop()
    for q in data3[p[0]]:
        if ans[q] != 0:
            continue
        if count[2] <= N and p[1]%3 != 2:
            ans[q] = count[2]
            count[2] += 3
            stack.append([q,2])
        elif count[1] <= N and p[1]%3 != 1:
            ans[q] = count[1]
            count[1] += 3
            stack.append([q,1])
        else:
            ans[q] = count[0]
            count[0] += 3
            stack.append([q,0])
        #####print(ans,stack)

print(" ".join(map(str,ans)))


### FIXED CODE ###

N = int(input())
data = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    data[b].append(a)

stack = [0]
d = [-1] * N
d[0] = 0

while stack:
    x = stack.pop()
    for y in data[x]:
        if d[y] != -1:
            continue
        d[y] = d[x] + 1
        stack.append(y)

mod = [[],[]]
for i in range(N):
    mod[d[i]%2].append(i)

ans = [0]*N

p = 1
q = 2
r = 3
if len(mod[0]) > N//3 and len(mod[1]) > N//3:
    for k in mod[0]:
        if p <= N:
            ans[k] = p
            p += 3
        else:
            ans[k] = r
            r += 3
    for l in mod[1]:
        if q <= N:
            ans[l] = q
            q += 3
        else:
            ans[l] = r
            r += 3
    
elif len(mod[0]) > N//3:
    for k in mod[0]:
        if p <= N:
            ans[k] = p
            p += 3
        elif q <= N:
            ans[k] = q
            q += 3
        else:
            ans[k] = r
            r += 3
    for l in mod[1]:
        ans[l] = r
        r += 3

else:
    for k in mod[1]:
        if p <= N:
            ans[k] = p
            p += 3
        elif q <= N:
            ans[k] = q
            q += 3
        else:
            ans[k] = r
            r += 3
    for l in mod[0]:
        ans[l] = r
        r += 3

print(" ".join(map(str,ans)))
a=input().split()
b=int(a[0])
data = [input() for i in range(b)]
sort(data)

for j in data:
    c=c+j
    
print(c)

### FIXED CODE ###

a=input().split()
b=int(a[0])
data = [input() for i in range(b)]
data.sort()
#print(data)

k=""
for i in data:
    k=k+i
print(k)
n=input()
l=list(map(int, input().split()))
res=0
#print(f"le{len(l)}")
for i in range(len(l)):
    for j in range(i+1,len(l)):
        res+=l[i]*l[j]
        #print(res)
print(res%(10**9+7))

### FIXED CODE ###

d,t,s=map(int, input().split())
if d/s<=t:
  print("Yes")
else:
  print("No")
from functools import reduce
import fractions

def gcd(*numbers):
	return reduce(fractions.gcd, numbers)

sum = 0
K = int(input())

for i in range(K):
  for j in range(K):
    for k in rage(K):
      sum += gcd(i,j,k)
      
print(sum)

### FIXED CODE ###

from functools import reduce
import functools
import fractions
 
@functools.lru_cache(maxsize=None)
def gcd(*numbers):
  return reduce(gcd_, numbers)

@functools.lru_cache(maxsize=None)
def gcd_(a, b):
  if (b == 0):
    return a
  return gcd(b, a % b)
 
sum = 0
K = int(input())
 
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if (i == j) & (j == k):
        sum += gcd(i,j,k)
      elif (i == j) & (j != k):
        sum += gcd(i,j,k)*3
      elif (i != j) & (j == k):
        sum += gcd(i,j,k)*3
      elif (i != j) & (j != k):
        sum += gcd(i,j,k)*6

print(sum)
num = list(input())

num = num.sort().reverse()

print(int(num[0] + num[1]) + int(num[2]))


### FIXED CODE ###

s = input()

num = list(s)

num.sort()
num.reverse()

print(int(num[0] + num[1]) + int(num[2]))
from collections import deque
from collections import defaultdict
N, Q = map(int, input().split())
C = defaultdict(int)
D = defaultdict(set)
for i in range(N-1):
  a, b = map(int, input().split())
  D[a-1].add(b-1)
  D[b-1].add(a-1)
for i in range(Q):
  p, x = map(int, input().split())
  C[p-1] = x

def dfs(n, vstd, x):
  C[n] += x
  vstd.append(n)
  for i in D[n]:
    if i in vstd:
      continue
    dfs(i, vstd, C[n])

dfs(0, [0], 0)    
print (" ".join(map(str, C.values())))

### FIXED CODE ###

from collections import deque
from collections import defaultdict
N, Q = map(int, input().split())
C = [0]* N
D = defaultdict(set)
for i in range(N-1):
  a, b = map(int, input().split())
  D[a-1].add(b-1)
  D[b-1].add(a-1)
for i in range(Q):
  p, x = map(int, input().split())
  C[p-1] += x

Q = deque([])
Q.append(0)
vstd = set()

while len(Q)>0:
  a = Q.popleft()
  vstd.add(a)
  for b in D[a]:
    if b in vstd:
      continue
    C[b] += C[a]
    Q.append(b)

print (" ".join(map(str, C)))
# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

if N == 2:
    if H[0]>H[1]:
    H[0] -= 1
else:
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]:
            H[i] -= 1

for i in range(N-1):
    if H[i]>H[i+1]:
        flag = 0

print(H)

if flag == 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

if N == 2:
    if H[0]>H[1]:
        H[0] -= 1
else:
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]:
            H[i] -= 1

for i in range(N-1):
    if H[i]>H[i+1]:
        flag = 0

if flag == 1:
    print('Yes')
else:
    print('No')
def resolve():
    def dfs(num, p=-1):
        for i in to[num]:
            if p == i:
                continue
            ns[i] += ns[num]
            dfs(i, num)
            
    n, q = map(int, input().split())

    to = [[] for _ in range(n)]

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

    ns = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        ns[p] += x

    dfs(0)
    print(*ns)
resolve()

### FIXED CODE ###

from heapq import heappush,heappop

def resolve():
    n, q = map(int, input().split())

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

    ns = [0 for _ in range(n+1)]
    for _ in range(q):
        p, x = map(int, input().split())
        ns[p] += x

    # 操作はまとめられる。頂点nに対してpの和
    # 親から累積させながら末端へ下ろしていく

    while len(hen) > 0:
        a, b = heappop(hen)
        ns[b] += ns[a]

    print(*ns[1:n+1])
resolve()
n = int(input())
a = list(map(int,input().split()))
b=1
count=0
for i in range(n):
    if(a[i]%2!=0):
        print(count)
        b=0
count=1
while b==1:
    for i in range(n):
        if(a[i]%2!=0):
            print(count)
            b=0
        a[i]/=2
    count+=1

### FIXED CODE ###

# cook your dish here
s = input()
count=0
for c in s:
    if c=='1':
        count+=1
print(count)
coffee
str=input()
S=print(str)
if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = input()

if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
s = input()
long = len(s)
count = 0
for i in range(long):
  for j in range(i+1,long):
    num = int(s[i:j+1])
    if len(str(num)) < 4:
      continue
    if num % 2019 == 0:
      count += 1
print(count)

### FIXED CODE ###

s,w = map(int,input().split())
if w < s:
  print("safe")
else:
  print("unsafe")
from collections import deque


N = int(input())
A = list(map(int, input().split()))
A.sort()
queue_plus = deque()
queue_minus = deque()
for A_i in A:
    if A_i < 0:
        queue_minus.append(A_i)
    else:
        queue_plus.append(A_i)

xy = [[] for _ in range(N-1)]
cnt = 0
if len(queue_plus) == 0:
    x = queue_minus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
if len(queue_minus) == 0:
    x = queue_plus.popleft()
    y = queue_plus.popleft()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
while len(queue_plus) > 0 and len(queue_minus) > 1:
    x = queue_plus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
while len(queue_plus) > 1 and len(queue_minus) > 0:
    x = queue_minus.pop()
    y = queue_plus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
x = queue_plus.pop()
y = queue_minus.pop()
xy[cnt] = [x, y]
ans = x - y
print(ans)
for x_y in xy:
    print(" ".join(map(str, x_y)))


### FIXED CODE ###

from collections import deque


N = int(input())
A = list(map(int, input().split()))
A.sort()
queue_plus = deque()
queue_minus = deque()
for A_i in A:
    if A_i < 0:
        queue_minus.append(A_i)
    else:
        queue_plus.append(A_i)

xy = [[] for _ in range(N-1)]
cnt = 0
if len(queue_plus) == 0:
    x = queue_minus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
elif len(queue_minus) == 0:
    x = queue_plus.popleft()
    y = queue_plus.popleft()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
while len(queue_plus) > 0 and len(queue_minus) > 1:
    x = queue_plus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
while len(queue_plus) > 1 and len(queue_minus) > 0:
    x = queue_minus.pop()
    y = queue_plus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
if len(queue_plus) + len(queue_minus) == 1:
    if len(queue_plus) > 0:
        print(queue_plus.pop())
    else:
        print(queue_minus.pop())
else:
    x = queue_plus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    ans = x - y
    print(ans)
for x_y in xy:
    print(" ".join(map(str, x_y)))
N = input()
n = int(N)

c = 0
for i in range(len(N)):
    s = N[i]
    i = int(s)
    if i <= 5:
        c += i
    else:
        c += 1 + (10 - i)
        if i > 0 and N[i-1] > '5':
            c -= 2
print (c)


### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = [0] + list(map(int,SI()))
    ans = 0
    for i in range(len(N)-1,-1,-1):

        if N[i] < 6 and not(N[i] == 5 and (i > 0 and N[i-1] >= 5)):
            ans += N[i]
        else:
            ans += 10 - N[i]
            N[i-1] += 1
    print(ans)
if __name__ == '__main__':
    main()
N = int(input())
S = input()

result = min(S.count("."),S.count("#"))
i = 0

while i < N:
    leftslice = S[:i]
    rughtslice = S[i:]
    leftblack = leftslice.count("#")
    rightwhite = rightslice.count(".")
    nowresult = leftblack + rightwhite
    if result >= nowresult:
        result = nowresult
    else:
        i += (nowresult - result)
    i += 1

print(result)

### FIXED CODE ###

N = int(input())
S = input()
 
result = min(S.count("."),S.count("#"))
leftblack = 0
rightwhite = S.count(".")
 
for i in range(N):
    if(S[i] == "."):
        rightwhite -= 1
    else:
        leftblack += 1
    if result >= leftblack + rightwhite:
        result = leftblack + rightwhite
 
print(result)
# ABC118c
from fractions import gcd
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#from functools import reduce


def gcds(*numbers):
    return reduce(gcd, numbers)


print(gcds(a))
exit(0)


def solve(l):
    m = min(l)
    nl = list()
    for i in l:
        if i % m != 0:
            nl.append(i % m)
    nl.append(m)
    # print(nl)
    if len(nl) == 1:
        return m
    return solve(nl)


print(solve(a))


### FIXED CODE ###

# ABC118c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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


def solve(l):
    m = min(l)
    nl = list()
    for i in l:
        if i % m != 0:
            nl.append(i % m)
    nl.append(m)
    # print(nl)
    if len(nl) == 1:
        return m
    return solve(nl)


print(solve(a))
a=int(input())
b=int(input())
c=int(input())
if a*c<b:
    print(c)
else:
    print(b/a)

### FIXED CODE ###

a,b,c = map(int,input().split())
if a*c<b:
    print(c)
else:
    print(b//a)
s=input()
k="keyence"
c=0
for i in range(len(s)):
    if s[i]==k[c]:
        c+=1
if c==7:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)
s = input()
k = input()

print(s[0] if s[0] != "1" else s[1])

### FIXED CODE ###

S = input()
K = input()

#A = int(l[0])


length_1 = len(S)
K = int(K)

i =int(S)
v_1 = []
#cnt = []
while i > 0:
    v_1.append( i % 10 )
    #cnt.append(1)
    i //= 10 # 必須
v_1.reverse()

length_n = 0
target_v_num = 0

while length_n < K:
    V = v_1[target_v_num]
    length_n = length_n + 1
    if V > 1:
        length_n = length_n + K
    target_v_num = target_v_num + 1


print(V)
n,k = [int(i) for i in input().split()]
h = [int(inoput()) for _ in range(n)]
h.sort()

ans = 10**9
for i,j in zip(h,h[k-1:]):
  ans = min(ans,j-i)
print(ans)

### FIXED CODE ###

n,k = [int(i) for i in input().split()]
h = [int(input()) for _ in range(n)]
h.sort()

ans = 10**9
for i,j in zip(h,h[k-1:]):
  ans = min(ans,j-i)
print(ans)
# -*- coding: utf-8 -*-

N = int(input())
c = 0

print({}.format(N*3))

### FIXED CODE ###

# -*- coding: utf-8 -*-

N = int(input())

print(N*N*N)
a, b = [int(item) for item in input().split()]
if a > b:
  print("Alice")
eiif a == b:
  print("Draw")
else:
  print("Bob")

### FIXED CODE ###

a, b = [int(item) for item in input().split()]
if a == 1:
  a += 100
if b == 1:
  b += 100
  
if a > b:
  print("Alice")
elif a == b:
  print("Draw")
else:
  print("Bob")
from itertools import groupby

def solve():
    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupgy(S)]
    
    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            return a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0]+a[-1]) // 2 * (K-1)
            ans += sum(n // 2 for n in a[1:-1]) * K
            return ans
    else:
        return sum(n // 2 for n in a) * K
    
print(solve())

### FIXED CODE ###

from itertools import groupby

def solve():
    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupby(S)]
    
    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            return a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0]+a[-1]) // 2 * (K-1)
            ans += sum(n // 2 for n in a[1:-1]) * K
            return ans
    else:
        return sum(n // 2 for n in a) * K
    
print(solve())
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

""" 
参考:http://drken1215.hatenablog.com/entry/2018/06/08/210000
maximとmodを適宜設定。
あ入力忘れを考慮してあえて入力例通らないようにしておいたで。

combを使う前にcominit()を使う

"""
maxim = 10**6 + 10
mod = 10**9+7
fac = [None] * maxim
finv = [None] * maxim
inv = [None] * maxim

def cominit():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1

    for i in range(2, maxim):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def com(n, k):
    if (n < k):
        return 0
    if (n < 0 or k < 0):
        return 0

    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    x,y = map(int, input().split())
    if (x+y) % 3 != 0 or x/2 > y or y > 2*x:
        print(0)
        return

    # (x+y) // 3で何段目かわかる
    # パスカルの三角形で言うところのハジから何番目かがわかればいい

    # k段目の点は -x + 3*k上にある
    # 2*xが一番端にある
    
    k = (x+y) // 3
    # k段目の上端は (k, 2k)に存在する
    # 左から何番目かは2*k -yで求まる
    # 解は kC2*k-y

    cominit()
    m = (2*y-x)//3
    n = m+x-y
    
    print(comb(m+n,n))

    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

from math import factorial
import sys

x, y = map(int, input().split())

maxim = 10**6+10
mod = 10**9 + 7

fac = [None] * maxim
finv = [None] * maxim
inv = [None] * maxim

def cominit():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1

    for i in range(2, maxim):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def com(n, k):
    if (n < k):
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    if (x + y) % 3 != 0:
        return 0
    else:

        b = (2*y - x) // 3 
        a = b + x -y
        if a < 0 or b < 0:
            print(0)
            sys.exit()
        
        cominit()
        ans = com(a+b, b)
        return ans 
    # answer = (a+b)! / a!b! mod 10^9+7


    
print(main())

# 999999 999999