Harryxun/stf_run huggingface dataset:
import math as m

N=int(input())
As=list(map(int,input().split()))


D=[0]*(10**6+1)
D[1]=1
for i in range(2,int(m.sqrt(10**6))+2):
    if D[i]!=0:
        continue
    j=i
    while j < 10**6+1:
        D[j]=i
        j+=i

P=[0]*10**6
pc=True
g=As[0]
for n in range(N):
    A=As[n]
    ppre=1
    while True:
        p=D[A]
        if ppre != p:
            if P[p] > 0:
                pc=False
            P[p]+=1
            ppre=p
        A=A//p
        if A==1:
            break
    g=m.gcd(g,A)

if pc:
    print('pairwise coprime')
elif g==1:
    print('setwise coprime')
else:
    print('not coprime')


### FIXED CODE ###

import math as m

N=int(input())
As=list(map(int,input().split()))


D=[0]*(10**6+1)
for i in range(2,int(m.sqrt(10**6))+2):
    if D[i]!=0:
        continue
    j=2*i
    while j < 10**6+1:
        D[j]=i
        j+=i

P=[0]*10**6
pc=True
g=As[0]
for n in range(N):
    A=As[n]
    g=m.gcd(g,A)
    if A==1:
        continue
    ppre=1
    while True:
        p=D[A] if D[A]!=0 else A
        if ppre != p:
            if P[p] > 0:
                pc=False
            P[p]+=1
            ppre=p
        A=A//p
        if A==1:
            break

if pc:
    print('pairwise coprime')
elif g==1:
    print('setwise coprime')
else:
    print('not coprime')
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline

def main():
    INF = float("Inf")
    n,m,l = map(int, input().split())
    G = [[INF]*n for i in range(n)]
    for i in range(n):
        G[i][i] = 0
    for i in range(m):
        a,b,c = map(int, input().split())
        a,b = a-1,b-1
        if c <= l:
            G[a][b] = G[b][a] = c
    G = floyd_warshall(G, directed=False)
    G = np.where(G <=l, 1, INF)
    for i in range(n):
        G[i][i] = 0
    GG = floyd_warshall(G, directed=False)

    q = int(input())
    ans = []
    for i in range(q):
        s,t = map(int, input().split())
        a = int(GG[s-1][t-1])
        if a == INF:
            a = 0
        ans.append(a-1)
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()


### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline

def main():
    INF = float("Inf")
    n,m,l = map(int, input().split())
    G = [[INF]*n for i in range(n)]
    for i in range(n):
        G[i][i] = 0
    for i in range(m):
        a,b,c = map(int, input().split())
        a,b = a-1,b-1
        if c <= l:
            G[a][b] = G[b][a] = c
    G = floyd_warshall(G, directed=False)
    G = np.where(G <=l, 1, INF)
    for i in range(n):
        G[i][i] = 0
    GG = floyd_warshall(G, directed=False)

    q = int(input())
    ans = []
    for i in range(q):
        s,t = map(int, input().split())
        a = GG[s-1][t-1]
        if a == INF:
            a = 0
        else:
            a = int(a)
        ans.append(a-1)
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()
n,k = map(int, input().split())

print min(n%k, abs(n%k-k))

### FIXED CODE ###

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

print(min(n%k, abs(n%k-k)))
A=input()
B=input()
x=A*B
print(x)


### FIXED CODE ###

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

x=a*b
print(x)
#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import statistics
import collections

def solve(n: int, v: "List[int]"):
    half_length = len(v) // 2
    O = [v[i] for i in range(1, n, 2)]
    E = [v[i] for i in range(0, n, 2)]

    co = list(collections.Counter(O).most_common())
    ce = list(collections.Counter(E).most_common())
    o1 = co[0][0]
    e1 = ce[0][0]

    O_ = list(filter(lambda o: o != o1, O))
    E_ = list(filter(lambda e: e != e1, E))
    num_o_1 = len(O_) 
    num_e_1 = len(E_)

    num = 0
    if e1 != o1:
        num = num_o_1 + num_e_1
    else:
        if len(co) == 1 and len(ce) == 1:
            num = half_length
        elif len(co) == 1:
            e2 = ce[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num = num_o_1 + num_e_2
        elif len(ce) == 1:
            o2 = co[1][0]
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = num_o_2 + num_e_1
        else:
            e2 = ce[1][0]
            o2 = co[1][0]
            num_e_2 = len(list(filter(lambda e: e != e2, E)))
            num_o_2 = len(list(filter(lambda o: o != o2, O)))
            num = min(num_o_1 + num_e_2, num_o_2 + num_e_1)
    print(num)
    return

def len2(l):
    n = 0
    for i in l:
        n += 1
    return n

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, v)

if __name__ == '__main__':
    main()
d={}
for s in sys.stdin:
  w,p=s.split()
  if w in d: d[w].append(int(p))
  else: d[w]=int(p)
  
for w in sorted(d.keys()):
  print w,"\n"
  print " ".join(map(str,sorted(d[w])))

### FIXED CODE ###

import sys

d={}
for s in sys.stdin:
  w,p=s.split()
  if w in d: d[w].append(int(p))
  else: d[w]=[int(p)]
  
for w,x in sorted(d.items()):
  print w
  print " ".join(map(str,sorted(x)))
N = int(input()) 
s = [int(input()) for i in range(N)] 

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
#縦横斜めチェック
for r in range(3):
	if a[i][0]==a[i][1]==a[i][2]==0:
		print('Yes')
		exit()
	if a[0][i]==a[1][i]==a[2][i]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')
	


### FIXED CODE ###

a = [list(map(int, input().split())) for l in range(3)]

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

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
for r in range(3):
	if a[r][0]==a[r][1]==a[r][2]==0:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')
N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2b
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
c4=0
c2=0
for i in range(N):
  if A[i]%4==0:
    c4+=1
  elif A[i]%2==0:
    c2+=1
if c4:
  a = c4*2+1
else:
  a = 0
if c2>1:
  b = c2
  if a:
    a -= 1
else:
  b = 0
if a+b>=N:
  print("Yes")
else:
  print("No")
n = int(input())
w = list(map(int, input().split()))
s = float("inf")
for i in range(1,n):
    x = abs(sum(w[0:i])-sum(w[i:n]))
    if x < s:
        s = x
print(s)

### FIXED CODE ###

n = int(input())
s = list()
for i in range(n):
    a,b = input().split()
    b = int(b) * -1
    s.append([a,b])
h = sorted(s)
for i in range(n):
    print(s.index(h[i])+1)
w = str(input())
s = dic()

for wrd in w:
  if s.get(wrd) is None:
    s[wrd] = 1
  else:
    s[wrd] += 1

ans = 1
for wrd in s:
  if s[wrd] %2 !=0:
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")




### FIXED CODE ###

w = str(input())
s = {}
 
for wrd in w:
  if s.get(wrd) is None:
    s[wrd] = 1
  else:
    s[wrd] += 1
 
ans = 1
for wrd in s:
  if s[wrd] %2 !=0:
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
a, b, c = map(int,raw_input().split())
if a < b and b < c:
  print ('Yes')
else
  print ('No')

### FIXED CODE ###

a,b,c=map(int, raw_input().split())
if a < b and b < c:
  print ('Yes')
else:
  print ('No')
from fractions import gcd
def lcm(x,y):
  return (x*y) // gcd(x,y)
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
l = a[0]
for i in range(1,n):
  l = lcm(l,a[i])
for i in range(n):
  ans += (l//a[i])%mod
print(ans%mod)

### FIXED CODE ###

from fractions import gcd
def lcm(x,y):
  return (x*y) // gcd(x,y)
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
l = a[0]
for i in range(1,n):
  l = lcm(l,a[i])
ans = 0
for i in range(n):
  ans += l//a[i]
print(ans%mod)
N=input()

N=int(N[-1])

if N==3:
  print("bon")
elif N in [1,2,4,5,7,9]:
  print("hon")
else N in [0,1,6,8]:
  print("pon")
  
  


### FIXED CODE ###

N=input()
 
N=int(N[-1])
 
if N==3:
  print("bon")
elif N in [2,4,5,7,9]:
  print("hon")
else :
  print("pon")
= list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
if m > n:
    print('NO')
    exit()
numd = [0]*200005
numt = [0]*200005
for d in D:
    numd[d] += 1
for t in T:
    numt[t] += 1
for t in T:
    if numt[t] > numd[t]:
        print('NO')
        exit()
print('YES')

### FIXED CODE ###

from collections import Counter
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
sd = set(D)
st = set(T)
cntd = Counter(D)
cntt = Counter(T)
ok = True
for t in T:
    if t not in sd:
        ok = False
    elif cntt[t] > cntd[t]:
        ok = False
if ok:
    print('YES')
else:
    print('NO')
n,k = (int(x) for x in input().split())
M = 10**9+7
s = 0

for i in range(n-k):
    ad = 1 + i*(n-i+1)
    s += ad
    if s >= M:
        s -= N
        
print(s)

### FIXED CODE ###

n,k = (int(x) for x in input().split())
M = 10**9+7
s = 0

for i in range(n+2-k):
    ad = 1 + (n+1-k-i)*(k+i)
    s += ad
#if s >= M:
#    s -= M
        
print(s%M)
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v
    return cnt
def shellSort(A, n):
    cnt = 0
    h = 1
    G = []
    while h < n:
        G += [h]
        h = 3 * h + 1
    m = len(G)
    for i in range(m - 1, -1, -1):
        cnt = insertionSort(A, n, G[i], cnt)
    print(m)
    print(*G[::-1])
    print(cnt)
    print(*A, sep="\n")
n = int(input())
A = [int(readline()) for _ in range(n)]
shellSort(A, n)


### FIXED CODE ###

import sys
readline = sys.stdin.readline
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v
    return cnt
def shellSort(A, n):
    cnt = 0
    h = 4
    G = [1]
    while h < n:
        G += [h]
        h = 3 * h + 1
    m = len(G)
    for i in range(m - 1, -1, -1):
        cnt = insertionSort(A, n, G[i], cnt)
    print(m)
    print(*G[::-1])
    print(cnt)
    print(*A, sep="\n")
n = int(input())
# A = [int(readline()) for _ in range(n)]
A = list(map(int, sys.stdin))
shellSort(A, n)
N, L = map(int, input().split())
S = [input() for _ in range(L)]

print(''.join(sorted(S)))

### FIXED CODE ###

N, L = map(int, input().split())
S = [input() for _ in range(N)]

print(''.join(sorted(S)))
N, K = map(int, input().split())
x_list = list(map(int, input().split()))

result = []
for i in range(N-K):
    start = i
    end = i + K -1
    result.append(abs(x_list[start] + abs(x_list[end] - x_list[start])))
    result.append(abs(x_list[end]) +  abs(x_list[end] - x_list[start] ))
print(min(result))

### FIXED CODE ###

N, K = map(int, input().split())
x_list = list(map(int, input().split()))

result = []
for i in range(N-(K-1)):
    start = i
    end = i + (K -1)
    result.append(abs(x_list[start]) + abs(x_list[end] - x_list[start]))
    result.append(abs(x_list[end]) + abs(x_list[end] - x_list[start]))
print(min(result))
num = list(map(int, input().split()))

loop = [0]

for i in loop:
  if num[0] < num[1]:
    difference = abs(num[0] - num[1])
    if difference > num[0]
      break
    else:
      num[0] = difference
  elif num[1] == 1:
    num[0] = 0
    break
  elif num[1] == 0:
    break
  num[0] = abs(num[0] - num[1])
  loop.append(i+1)

print(num[0])

### FIXED CODE ###

num = list(map(int, input().split()))

loop = [0]

for i in loop:
  if num[0] < num[1]:
    difference = abs(num[0] - num[1])
    if difference > num[0]:
      break
    else:
      num[0] = difference
      break
  elif num[1] == 1:
    num[0] = 0
    break
  elif num[1] == 0:
    break
  if i == 0:
    num[0] = num[0] % num[1]
  num[0] = abs(num[0] - num[1])
  loop.append(i+1)

print(num[0])
N,K=map(int, input().split()) 
min = abs(N-K)
if N < K:
    if min < abs(min-K):
        print(min)
    else:
        print(abs(min-K))
else: 
    while min >= abs(min-K):
        min = abs(min-K)
        if min < K:
            if min < abs(min-K):
                print(min)
                break
            else:
                print(abs(min-K))
                break
    else :
        print(min)

### FIXED CODE ###

X,Y,Z=map(int, input().split()) 
X,Y = Y,X
X,Z = Z,X
print(X,Y,Z)
l,r = map(int,(input().split()))
if r-l>=2018:
    print(0)
    sys.exit()

else:
    if l%2019>r%2019:
        l=l%2019
        r=r%2019+2019
    else:
        l=l%2019
        r=r%2019

        m=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            a =i*j%2019
            m =min(m,a)

    print(m)

### FIXED CODE ###

import sys
l,r = map(int,(input().split()))
if r-l>=2018:
    print(0)
    sys.exit()

else:
    if l%2019>r%2019:
        l=l%2019
        r=r%2019+2019
    else:
        l=l%2019
        r=r%2019

    m=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            a =i*j%2019
            m =min(m,a)

    print(m)
N, Q = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(N-1):
    i, k = map(int, input().split())
    A[i-1].append(k-1)
    A[k-1].append(i-1)
n_P = [0] * N
for _ in range(Q):
    k, n = map(int, input().split())
    n_P[k-1] += n
ans = [0] * N
visited = [0] * N
def make(num, p):
    ans[num] += n_P[num] 
    ans[num] += p
    visited[num] = 1
    for i in A[num]:
        if visited[i] == 0:
            make(i,ans[num])
    return
make(0, ans)
print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(2*10**9)
N, Q = map(int, input().split())
A = [[] for _ in range(N)]
for _ in range(N-1):
    i, k = map(int, input().split())
    A[i-1].append(k-1)
    A[k-1].append(i-1)
n_P = [0] * N
for _ in range(Q):
    k, n = map(int, input().split())
    n_P[k-1] += n
ans = [0] * N
visited = [0] * N
def make(num, p):
    ans[num] += n_P[num] 
    ans[num] += p
    visited[num] = 1
    for i in A[num]:
        if visited[i] == 0:
            make(i,ans[num])
    return
make(0, ans[0])
print(*ans)
r=input()
k=r.split()

t1=t2=0
for i in range(k[2]):
    t1 += k[0]
for i in range(k[0]):
    t2 += k[2]
    
jj=[t1,t2]
jj.sort(reverse=True)
print(jj[0])

### FIXED CODE ###

r = input()
k=r.split()



t1=t2=''

t1=k[0]*int(k[1])
t2=k[1]*int(k[0])



rr = [t1,t2]

rr.sort()

print(rr[0])
input()
b=[int(a) for a in input().split()]
print(min(b),max(b),sum(b)')

### FIXED CODE ###

input()
b=list(map(int,input().split()))
print(min(b),max(b),sum(b))
def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(1, N)[::-1]:
            if A[j] < A[j - 1]:
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
                flag = 1
                count += 1

    print(" ".join(map(str, A)))
    print(count)

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

bubbleSort(A, n)

### FIXED CODE ###

def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(1, N)[::-1]:
            if A[i] < A[i - 1]:
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = 1
                count += 1

    print(" ".join(map(str, A)))
    print(count)

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

bubbleSort(A, n)
import math
A, B = map(int, input().split(' '))
print((A * B) // math.gcd(A, B))

### FIXED CODE ###

import fractions
A, B = map(int, input().split(' '))
gcd = fractions.gcd(A, B)
print((A * B) // gcd)
X,A = (int(x) for x in input().split())

if x < A:
  print(0)
else:
  print(10)

### FIXED CODE ###

X,A = (int(x) for x in input().split())
 
if X < A:
  print(0)
else:
  print(10)
import sys
sys.setrecursionlimit(10**7)

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

# 木構造をリストで表現する
graph = [[] for _ in range(N+1)]

for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

# 各操作で与えられる値を、各頂点ごとに集計しておく
value = [0] * (N+1)
for p, x in PX:
    value[p] += x


def dfs(v, parent, point):
    # 現在いる頂点vの親までの値をpointとする
    value[v] += point
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])


dfs(1, 0, 0)

res = ' '.join(map(str, P[1:]))
print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

 
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
 
def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])
 
dfs(1,0,0)
 
answer = ' '.join(map(str,value[1:]))
print(answer)
n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1
cnt = 0

while(flag == 1):
    flag = 0
    for j in range(n-1,0,-1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            flag = 1
            cnt += 1

for k in range(0,len(A)-1):
    print(A[k],end=" ")
print(A[len(A)-1])
print (cnt))

### FIXED CODE ###

n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1
cnt = 0

while(flag == 1):
    flag = 0
    for j in range(n-1,0,-1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            flag = 1
            cnt += 1

for k in range(0,len(A)-1):
    print(A[k],end=" ")
print(A[len(A)-1])
print (cnt)
h,w=map(int,input().split())
b=[list("."*(w+2))]
for i in range(w):
  b.append(list("."+input()+"."))
b.append(list("."*(w+2)))
ans="Yes"
dx=[0,1,0,-1]
dy=[1,0,-1,0]
for i in range(1,h+1):
  for j in range(1,w+1):
    if b[i][j]==".":continue
    flag=True
    for x,y in zip(dx,dy):
      if b[i][j]==b[i+x][j+y]:flag=False
    if flag:ans="No"
print(ans)

### FIXED CODE ###

h,w=map(int,input().split());a=[input()for i in range(h)]
def che(i,j):
  global h,w,a
  if i==0:
    if a[i+1][j]=="#":return
  elif i==h-1:
    if a[i-1][j]=="#":return
  else:
    if a[i-1][j]=="#"or a[i+1][j]=="#":return
  print("No");exit()
for i in range(h):
  s=a[i]
  if s[:2]=="#.":che(i,0)
  if s[-2:]==".#":che(i,w-1)
  for j in range(w-2):
    if s[j]+s[j+1]+s[j+2]==".#.":che(i,j+1)
print("Yes")
length = input()
list(map(int, input().split()))

for i in range(length):
  if i == length:
    print('Yes')
  elif list[i+1] - list[i] >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

### FIXED CODE ###

length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)-1):
  if a_list[i] < a_list[i+1]:
    a_list[i+1] -= 1
  elif a_list[i] > a_list[i+1]:
    print("No")
    exit()
    
print('Yes')
s = input()
a = 0
for i in range(len(s)):
    a += s[i]
s = int(s)
if s % a = 0 :
    print('Yes')
else :
    print('No')

### FIXED CODE ###

n = input()
s = 0
for i in range(len(n)) :
    s += int(n[i])
n = int(n)
if n % s == 0 :
    print('Yes')
else :
    print('No')
N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * M
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = (str(p).zfill(6) + str(num[p-1]).zfill(6))

for i in ans:
    print(i)

### FIXED CODE ###

N, M = map(int, input().split())
cnt = [0 for i in range(N + 1)] 
check = []
ans = []

for i in range(M):
    p, y = map(int, input().split())
    check.append((y, p, i))

check.sort()

for y, p, i in check:
    cnt[p] += 1
    ans.append((i,str(p).zfill(6)+str(cnt[p]).zfill(6)))

ans.sort()

for aa, bb in ans:
    print(bb)
from sympy import Symbol, solve
x = Symbol('x')
y = Symbol('y')

tmp1 = 2*x + 3*y - 6
tmp2 = 3*x + 2*y - 12

ans = solve((tmp1, tmp2))
print(ans[x])
print(x)

### FIXED CODE ###

MOD = 10 ** 9 + 7
MAX = 10 ** 6 + 1
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def CoMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        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

X, Y = map(int, input().split())

if (X + Y) % 3:
    print(0)
    exit()
n = (X + Y) // 3
X -= n
Y -= n
if X < 0 or Y < 0:
    print(0)
    exit()
CoMinit()
ans = COM(X + Y, X)
print(ans)