Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python

def makesign(room, rw_lst, sign_lst, check_lst):
    check_lst[room] = True
    newways = []
    for way in rw_lst[room]:
        if sign_lst[way] == -1:
            newways.append(way)
            sign_lst[way] = room
    rw_lst[room] = newways

    for way in rw_lst[room]:
        makesign(way, rw_lst, sign_lst, check_lst)

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1] * (n+1)
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[0] = True

    makesign(1, rw_lst, sign_lst, check_lst)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
from collections import deque

def main():
    n, m = map(int, input().split())
    rw_lst = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        rw_lst[a].append(b)
        rw_lst[b].append(a)

    sign_lst = [-1 for _ in range(n+1)]
    sign_lst[1] = 0
    check_lst = [False for _ in range(n+1)]
    check_lst[1] = True

    queue = deque([1])
    while queue:
        room = queue.popleft()
        for way in rw_lst[room]:
            if not check_lst[way]:
                check_lst[way] = True
                sign_lst[way] = room
                queue.append(way)

    check = True
    for i in range(1, n+1):
        check = check and check_lst[i]

    if check:
        print("Yes")
        for i in range(2, n+1):
            print(sign_lst[i])
    else:
        print("No")


if __name__ == '__main__':
    main()
from collections import deque

N,M=map(int,input().split())
r=[[]for i in range(M)]
d,p=[10**6]*N,[10**6]*N

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

q=deque([0])
p[0],d[0],c=-1,0,0

while len(q)!=0:
  i=q.pop()
  for j in r[i]:
    if d[j]>d[i]+1:
      d[j],p[j]=d[i]+1,i
      q.append(j)

print('Yes')
for i in range(1,N):
  print(p[i]+1)


### FIXED CODE ###

def main():
  N,M=map(int,input().split())

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

  p=[-1]*N
  q=[0]
  while q:
    i=q.pop(0)
    for j in r[i]:
      if p[j]==-1:
        p[j]=i
        q.append(j)

  print('Yes')
  for i in range(1,N):
    print(p[i]+1)

main()
スコード 

Copy
Copy
import math
def prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0: return False
    return True
 
X = int(input())
 
for i in range(X, 10**8):
    if prime(i):
        print(i)
        exit(0)
 
print('No prime number in this range')

### FIXED CODE ###


import math
def prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0: return False
    return True
 
X = int(input())
 
for i in range(X, 10**8):
    if prime(i):
        print(i)
        exit(0)
 
print('No prime number in this range')
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

from collections import deque
import bisect
color = deque([a.pop(0)])
color_count =0 
for i, ai in enumerate(a): 
    index = bisect.bisect_left(color, ai)
    print(index-1, ai, color)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))
def ms():return map(str, input().split())#,a,b,c,d
a ,b =ms()
if a < b:
  pritn("<")
elif a>b:
  print(">")
else:print("=")

### FIXED CODE ###

def ms():return map(str, input().split())#,a,b,c,d
a ,b =ms()
if a < b:
  print("<")
elif a > b:
  print(">")
else:print("=")
n = int(input().split())
h = list(map(int, input().split()))
height = h[0]
counter = 0
for i in h:
    if h[i] >= height:
        counter += 1
        height = h[i]

print(counter)


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
highest = 0
counter = 0

for i in range(n):
    if h[i] >= highest:
        counter += 1
        highest = h[i]

print(counter)
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())

sl = []
cnt = -1
for i in range(M):
    a = int(input())
    b = (a - 1) - (cnt + 1)
    if b == -1:
        print(0)
        break
    sl.append(max(b, 1))
    cnt = a
else:
    sl.append(max(N - (a + 1), 1))
    ans = 1
    for s in sl:
        p = 0
        for i in range(s):
            j = s - i
            if (i <= j):
                p += combinations_count(j, i)
            else:
                break
        ans *= p
    print(ans % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
a = [0]*N
for _ in range(M):
    idx = int(input()) - 1
    a[idx] = 1
    
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
for i in range(N-1):
    if a[i] == 0:
        dp[i+1] += dp[i]
        dp[i+2] += dp[i]
print(dp[N-1] % 1000000007)
S=input()
s=[]
for i in S:
    s+=[i]
ans=0
que=[]
que+=[s[0]]
def cube(i):
    global ans
    if i==len(s):
        print(ans)
    else:
        que.append(s[i])
        flag=True
        while flag:
            if len(que)==0 or len(que)==1:
                flag=False
            elif que[-1]==que[-2]:
                flag=False
            elif que[-1]!=que[-2]:
                del que[-1]
                del que[-1]
                ans+=2
        cube(i+1)
cube(1)

### FIXED CODE ###


import sys
sys.setrecursionlimit(1000000)

S=input()
s=[]
for i in S:
    s+=[i]
ans=0
que=[]
que+=[s[0]]
def cube(i):
    global ans
    if i==len(s):
        print(ans)
    else:
        que.append(s[i])
        flag=True
        while flag:
            if len(que)==0 or len(que)==1:
                flag=False
            elif que[-1]==que[-2]:
                flag=False
            elif que[-1]!=que[-2]:
                del que[-1]
                del que[-1]
                ans+=2
        cube(i+1)
cube(1)
#ABC142_C
N=int(input())
A=list(map(int,input().split()))
ans=[i+1 for i,_ in sorted(enumerate(A),key=itemgetter(1))]
print(*ans)

### FIXED CODE ###

#ABC142_C
from operator import itemgetter
N=int(input())
A=list(map(int,input().split()))
ans=[i+1 for i,_ in sorted(enumerate(A),key=itemgetter(1))]

print(*ans)
n = int(input())
a = input().split()
 
for i in range(n):
  b = a[:]
  del b[i]
  k = 0
  c = set(b)
  for t in c:
    num = b.count(t)
    for i in range(num):
      k += i
  print(k)

### FIXED CODE ###

n, m = input().split()

n = int(n)
m = int(m)
j = 0
for i in range(1, n):
  j += i
  
for i in range(1, m):
  j += i
  
print(j)
s=input()
s[3]='8'
print(s)

### FIXED CODE ###

s=input()
print(s.replace('2017','2018'))
s = input().strip()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print("Bad")
        exit(1)
print("Good")


### FIXED CODE ###

s = input().strip()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print("Bad")
        exit()
print("Good")
N = int(input())
answer = 1000
for a in range(round(abs(N))):
  if N&a == 0:
    b = N/a
    if answer < min(len(str(a)), len(str(b))):
      answer = min(len(str(a)), len(str(b)))
print(answer)

### FIXED CODE ###

import math

N = int(input())
answer = []
b = 0
for a in range(1,round(math.sqrt(N))+1):
  if N%a == 0:
    b = N//a
    answer.append(max(len(str(a)), len(str(b))))
print(min(answer))
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    G[y-1].append(x-1)


dp = [0]*N
def rec(p, v):
    C = set(G[v]) - set([p])
    if len(C) == 0:
        dp[v] = 1
        return 1
    res = 1
    for u in C:
        res *= (1+rec(v, u)) % M
    dp[v] = res % M
    return dp[v]

root = 0       
rec(None, root)

q = queue.Queue()
q.put(root)
ans = [0]*N
ans[root] = dp[root] % M

while not q.empty():
    p = q.get()
    for v in G[p]:
        if ans[v] > 0: continue
        ans[v] = int(dp[v]*(ans[p]/(1+dp[v])+1)) % M
        q.put(v)

for a in ans:
    print(a)

### FIXED CODE ###

import sys
 
sys.setrecursionlimit(100000)
 
 
def dfs1(v, p):
    val = 1
    pre_mul = [1]
    rev_mul = []
    for c in links[v]:
        if c == p:
            pre_mul.append(val)
            rev_mul.append(1)
            continue
        res = 1 + dfs1(c, v)
        val *= res
        val %= m
        pre_mul.append(val)
        rev_mul.append(res)
    dp[v] = val
    for i in range(len(rev_mul) - 2, -1, -1):
        rev_mul[i] *= rev_mul[i + 1]
        rev_mul[i] %= m
    rev_mul.append(1)
    pre_muls[v] = [pre_mul, rev_mul]
    return val
 
 
def dfs2(v, p, a):
    dp[v] = dp[v] * a % m
    pmv = pre_muls[v]
    for i, c in enumerate(links[v]):
        if c == p:
            continue
        pmc = pmv[0][i] * pmv[1][i + 1] % m
        pmc = pmc * a % m
        dfs2(c, v, pmc + 1)
 
 
n, m = map(int, input().split())
links = [[] for _ in range(n)]
dp = [0 for _ in range(n)]
pre_muls = [None for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    links[x].append(y)
    links[y].append(x)
dfs1(0, None)
dfs2(0, None, 1)
print('\n'.join(map(str, dp)))
import math
a,b,h,m=map(int,input().split())
q=h*30+m*0.5
w=m*6
cosa=math.cos(math.radians(q-w))
print((a**2+b**2-2*a*b*cos)**0.5)

### FIXED CODE ###

import math
a,b,h,m=map(int,input().split())
q=h*30+m*0.5
w=m*6
cosa=math.cos(math.radians(q-w))
print((a**2+b**2-2*a*b*cosa)**0.5)
for _ in [None] * 50:
    m, f, r = map(int, input().split())
    result = " "
    if m == f == r == -1:
        break
    if m == -1 or f == -1 or m + f < 30:
        result = "F"
    elif m + f > 80:
        result = "A"
    elif 80 > m + f >= 65:
        result = "B"
    elif 65 > m + f >= 50:
        result = "C"
    else:
        result = "C" if r >= 50 else result = "D"
    print(result)



### FIXED CODE ###

for _ in [None] * 50:
    m, f, r = map(int, input().split())
    result = ""
    if m == f == r == -1:
        break
    if m == -1 or f == -1 or m + f < 30:
        result = "F"
    elif m + f >= 80:
        result = "A"
    elif 80 > m + f >= 65:
        result = "B"
    elif 65 > m + f >= 50:
        result = "C"
    else:
        result = "C" if r >= 50 else "D"
    print(result)
l=[int(input())for _ inrange(5)]
print([':(','Yay!'][int(input())>=l[4]-l[0]])


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
m = max([a, b, c, d, e])
n = min([a, b, c, d, e])
print('Yay!' if k >= (m - n) else ':(')
import math

n, m = map(int, input().split())
A = 0
arr = [int(x) for x in input().split()]
A = sum(arr)
x = A/(4 * m)
count = 0
for i in range(n):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")



### FIXED CODE ###

n, m = map(int, input().split())
A = 0
arr = [int(i) for i in input().split() ]
arr.sort(reverse = True)
A = sum(arr)
x = A/(4 * m)
count = 0
for i in arr:
	if i >= x:
		count +=1
	else:
		break

if count >= m:
	print("Yes")
else: print("No")
A,,B,C = map(int,input().split())

List_one = [0]*B
List_one = list(map(int,input().split()))

List_one.append(C)
#LIst_one = List_one + [C]
#print (List_one)

List_one.sort()# List_two=List_one.sort()としたらNoneを返してしまう。
#print(List_one)

x = List_one.index(C)

if x+1>=B-x:
    print(B-x)
else:
    print(x+1)


### FIXED CODE ###

A,B,C = map(int,input().split())

List_one = [0]*B
List_one = list(map(int,input().split()))

List_one.append(C)
#LIst_one = List_one + [C]
#print (List_one)

List_one.sort()# List_two=List_one.sort()としたらNoneを返してしまう。
#print(List_one)

x = List_one.index(C)

if x>=B-x:
    print(B-x)
else:
    print(x)
n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

def qwe(y):
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in y:
        if i == 'M':
            m += 1
        elif i == 'A':
            a += 1
        elif i == 'R':
            r += 1
        elif i == 'C':
            c += 1
        elif i == 'H':
            h += 1
        else:
            pass
    q = [m,a,r,c,h]
    return q

def qwer(arr):
    count = 0
    for j in range(len(arr)):
        if arr[j] == 0:
            count += 1
            arr[j] = "D"
    arr.remove("D")
    if count == 5:
        return 0
    if count == 4:
        return 0
    if count == 3:
        return 0
    if count == 2:
        wer = arr[0] * arr[1] * arr[2]
        return wer
    if count == 1:
        asd_1 = arr[0]*arr[1]*arr[2]
        asd_2 = arr[0]*arr[1]*arr[3]
        asd_3 = arr[0]*arr[2]*arr[3]
        asd_4 = arr[1]*arr[2]*arr[3]
        asde = asd_1 + asd_2 + asd_3 + asd_4
        return asde
    if count == 0:
        asf_1 = arr[0]*arr[1]*arr[2]
        asf_2 = arr[0]*arr[1]*arr[3]
        asf_3 = arr[0]*arr[1]*arr[4]
        asf_4 = arr[0]*arr[2]*arr[3]
        asf_5 = arr[0]*arr[2]*arr[4]
        asf_6 = arr[0]*arr[3]*arr[4]
        asf_7 = arr[1]*arr[2]*arr[3]
        asf_8 = arr[1]*arr[2]*arr[4]
        asf_9 = arr[1]*arr[3]*arr[4]
        asf_10 = arr[2]*arr[3]*arr[4]
        asdf =  asf_1 + asf_2 + asf_3 + asf_4 + asf_5 + asf_6 + asf_7 + asf_8 + asf_9 + asf_10
        return asdf
v = qwe(s)
print(qwer(v))


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

def qwe(y):
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in y:
        if i == 'M':
            m += 1
        elif i == 'A':
            a += 1
        elif i == 'R':
            r += 1
        elif i == 'C':
            c += 1
        elif i == 'H':
            h += 1
        else:
            pass
    q = [m,a,r,c,h]
    return q

def qwer(arr):
    count = 0
    for j in range(len(arr)):
        if arr[j] == 0:
            count += 1
            arr[j] = "D"
    while "D" in arr:
        arr.remove("D")
    if count == 5:
        return 0
    if count == 4:
        return 0
    if count == 3:
        return 0
    if count == 2:
        wer = arr[0] * arr[1] * arr[2]
        return wer
    if count == 1:
        asd_1 = arr[0]*arr[1]*arr[2]
        asd_2 = arr[0]*arr[1]*arr[3]
        asd_3 = arr[0]*arr[2]*arr[3]
        asd_4 = arr[1]*arr[2]*arr[3]
        asde = asd_1 + asd_2 + asd_3 + asd_4
        return asde
    if count == 0:
        asf_1 = arr[0]*arr[1]*arr[2]
        asf_2 = arr[0]*arr[1]*arr[3]
        asf_3 = arr[0]*arr[1]*arr[4]
        asf_4 = arr[0]*arr[2]*arr[3]
        asf_5 = arr[0]*arr[2]*arr[4]
        asf_6 = arr[0]*arr[3]*arr[4]
        asf_7 = arr[1]*arr[2]*arr[3]
        asf_8 = arr[1]*arr[2]*arr[4]
        asf_9 = arr[1]*arr[3]*arr[4]
        asf_10 = arr[2]*arr[3]*arr[4]
        asdf =  asf_1 + asf_2 + asf_3 + asf_4 + asf_5 + asf_6 + asf_7 + asf_8 + asf_9 + asf_10
        return asdf
v = qwe(s)
print(qwer(v))
a=input().split()
N=int(a[0])
M=int(a[1])
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])

ans=0
for i in range(N):
    con_i=[]
    for j in range(M):
        if way[j][0]==i+1:
            con_i.append(H[way[j][1]-1])
        if way[j][1]==i+1:
            con_i.append(H[way[j][0]-1])
    

    if max(con_i)<H[i]:
        ans+=1
    
print(ans)


            


### FIXED CODE ###

a=input().split()
N=int(a[0])
M=int(a[1])
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])

dic={}
for i in range(N):
    dic[i]=set()

for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    

print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))
n=int(input())
s=input()

i=0
for ss in s:
  if ss=="#":
    break
  i+=1

s=s[i:]  
  
cnt=0
for i in range(1,n+1):  
  if s[-1*i]=="#":
    cnt+=1
  else:
    break
if cnt>0:
	s=s[:-1*cnt]
#print(s)
  
print(min(s.count("."),s.count("#")))

  

### FIXED CODE ###

n=int(input())
s=input()
s=s

ll=0 #左側の黒い数を保持
rr=s.count(".") #右側の白い数を保持

result=ll+rr
for item in s:
    if item=="#":
        ll+=1
    else:
        rr-=1
    
    result=min(result,ll+rr)

print(result)
NN = input()
total = 0
for i in NN:
  a = NN.count(i)
  if a%2 ==0:
    pass
  else:
    totaL +=1
if total ==0:
  print('Yes')
else:
  print('No')
    


### FIXED CODE ###

NN = input()
total = 0
for i in NN:
  a = NN.count(i)
  if a%2 ==0:
    pass
  else:
    total +=1
if total ==0:
  print('Yes')
else:
  print('No')
a, b, c = [input(i) for i in input().split()]

total = 0
for d in range(a, b + 1):
    if c % d == 0:
        total += 1

print(total)

### FIXED CODE ###

import sys

(a, b, c) = [int(i) for i in sys.stdin.readline().split(' ')]

divisorCount = 0
for d in range(a, b+1):
    if c % d == 0:
        divisorCount += 1

print(divisorCount)
import io
import sys
import math
import itertools
N = int(input())
A = list(map(int, input().split()))

Springboard = []
for i in range(1,len(A)):
  # 自分より前に自分より身長が高い人がいないとき
  if max(A[:i+1]) == A[i]:
    Springboard.append(0)
    # 自分より前に自分より身長が高い人がいるとき
    else:
      Springboard.append(max(A[:i]) - A[i])

print(sum(Springboard))



### FIXED CODE ###

# input here
_INPUT = """\
5
3 3 3 3 3
"""

def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    Springboard = []
    max = A[0]
    for i in range(1,len(A)):
    # 自分より前に自分より身長が高い人がいないとき
        if max < A[i]:
            max = A[i]
            Springboard.append(0)
     # 自分より前に自分より身長が高い人がいるとき
        else:
            Springboard.append(max - A[i])

    print(sum(Springboard))

if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    # sys.stdin = io.StringIO(_INPUT)
    main()
import numpy as np
import math

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

g=math.gcd(a,b)
if(c%g==0):
    print("YES")
else:
    print("NO")

### FIXED CODE ###



import numpy as np
import fractions as fra

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

g=fra.gcd(a,b)
if(c%g==0):
    print("YES")
else:
    print("NO")
[n,m]=map(int,raw_input().split())
l,r=1,n
for i in range(m):
	[li,ri]=map(int,raw_input().split())
	l = max(li, l)
	r = min(ri, r)
ans=l-r+l
print(ans if ans > 0 else 0)

### FIXED CODE ###

[a,b]=map(int,raw_input().split())

if a >= 13:
	print b
elif a >= 6:
	print b/2
else:
	print 0
def power(x, y, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    二分累乗法でx ** yを求める
    
    2 ** n = 4 ** (n//2) = 16 ** (n//4)
    みたいなことをする
    """

    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2, mod)**2 % mod
    else            : return power(x, y//2, mod)**2 * x % mod


def mul(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味したかけ算を行う
    """
    return ((a % mod) * (b % mod)) % mod

def div(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味した割り算を行う    
    """
    if a == b:
        return 1
    return mul(a, power(b, mod-2, mod), mod)


def factorial_part(start, last, mod):
    """
    startからlastまでのかけ算を行う
    
    factorial_part(2, 4, mod) = 2 * 3 * 4 = 24    
    """
    assert(start <= last)
    x = 1
    for k in range(start, last+1):
        x *= k
        x %= mod
    return x

def combination(n, a, mod):
    nCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)
    return nCa

mod = int(1e9) + 7



x, y  = map(int, input().split())
s = x + y
if s % 3 != 0:
    print(0)
else:
    s = s // 3
    x -= s
    y -= s
    if x < 0:
        print(0)
    elif y < 0:
        print(0)
    else:
        print(combination(x + y, x, mod))

### FIXED CODE ###

def power(x, y, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    二分累乗法でx ** yを求める
    
    2 ** n = 4 ** (n//2) = 16 ** (n//4)
    みたいなことをする
    """

    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2, mod)**2 % mod
    else            : return power(x, y//2, mod)**2 * x % mod


def mul(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味したかけ算を行う
    """
    return ((a % mod) * (b % mod)) % mod

def div(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味した割り算を行う    
    """
    if a == b:
        return 1
    return mul(a, power(b, mod-2, mod), mod)


def factorial_part(start, last, mod):
    """
    startからlastまでのかけ算を行う
    
    factorial_part(2, 4, mod) = 2 * 3 * 4 = 24    
    """
    assert(start <= last)
    x = 1
    for k in range(start, last+1):
        x *= k
        x %= mod
    return x

def combination(n, a, mod):
    if a == 0:
        return 1
    nCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)
    return nCa

mod = int(1e9) + 7



x, y  = map(int, input().split())
s = x + y
if s % 3 != 0:
    print(0)
else:
    s = s // 3
    x -= s
    y -= s
    if x < 0:
        print(0)
    elif y < 0:
        print(0)
    else:
        print(combination(x + y, x, mod))
N= int(input())
C0 = C1 = C2 = C3 = 0
for i in range(N):
	if input() == 'AC':
		C0 += 1
	elif input() == 'WA':
		C1 += 1
	elif input() == 'TLE':
		C2 += 1
	else:
		C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))

### FIXED CODE ###

N = int(input())
C_0 = C_1 = C_2 = C_3 = 0
for i in range(N):
  c = input()
  if c == 'AC':
    C_0 += 1
  elif c == 'WA':
    C_1 += 1
  elif c == 'TLE':
    C_2 += 1
  else:
    C_3 += 1

print('AC x ' + str(C_0))
print('WA x ' + str(C_1))
print('TLE x ' + str(C_2))
print('RE x ' + str(C_3))
a,b = map(int,input().split())
if a == b == 1:
  print(1000000)
elif a < 3:
  if b < 3:
    print(100000*(4-a)+100000*(4-b))
  else:
    print(1000000*(4-a))
else:
  if b < 3:
    print(1000000*(4-b)
  else:print(0)

### FIXED CODE ###

X, Y = map(int, input().split())
tmp=0
if X==1 and Y==1:
    tmp+=400000

for i in (X, Y):
    if i==1:
        tmp+=300000
    elif i==2:
        tmp+=200000
    elif i==3:
        tmp+=100000
print(tmp)
a, b = map(int, input.split())

a *= 3

print((a+b)//2)

### FIXED CODE ###

a, b = map(int, input().split())
a *= 3
print((a+b)//2)
A,B=input().split()
import math
print(math.ceil(B-1)/A)

### FIXED CODE ###

A,B=input().split()
import math
print(math.ceil((int(B)-1)/(int(A)-1)))