Harryxun/stf_run huggingface dataset:
a, b, c = map(int, input().split())
for i in range(min(a,b), 0, -1):
  if a%i==0 and b%i==0:
    count+=1
  if count==c:
    print(i)
    break
  

### FIXED CODE ###

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

count = 0
for i in range(min(a,b), 0, -1):
  if a%i==0 and b%i==0:
    count+=1
  if count==c:
    print(i)
    break
from collections import deque
n = int(input())
li = list(range(1,n+1))
q = deque(li)
q.rotate(-1)
count = 1
ans = 0
for q_i in q:
    ans += count % q_i
    count += 1
print(ans)

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()
 
n=ii()
a=lmi()
suma=sum(a)
counter=[0]*(10**5)
for i in a:
  counter[i]+=1
#print(counter)
q=ii()
 
for i in range(q):
  b,c=mi()
  suma+=(c-b)*counter[b]
  
  counter[c]+=counter[b]
  counter[b]=0
  #print(counter)
  print(suma)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
suma=sum(a)
q=int(input())
b=[]
c=[]
for i in range(q):
  b_,c_=map(int,input().split())
  b.append(b_)
  c.append(c_)

counter=[0]*(10**5+1)
for i in a:
  counter[i]+=1
new_sum=suma
for i in range(q):
  new_sum=new_sum-b[i]*counter[b[i]]+c[i]*counter[b[i]]
  
  counter[c[i]]+=counter[b[i]]
  counter[b[i]]=0
  print(new_sum)
import numpy as np
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ?????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ????????????§?????????????????????-> ??°?????????????????????¶???????????????????
    3. 2?????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee
    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)
 
    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])
 
    # 3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
 
if __name__ == "__main__":
    first = True
    while (True):
        total_fee = int(input(''))
        if total_fee == 0:
            break
        if first:
            first = False
        else:
            print('')
        coins = input('')
        coins = coins.split(' ')  # 10, 50, 100, 500?????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)

### FIXED CODE ###

import math
def back_oturigation(fee, coin_values, coin_nums):
    """
    1. ?????????????????????????????????£??????????????????
    2. 1????????????????????????????????????????????????????????????
       ????????????§?????????????????????-> ??°?????????????????????¶???????????????????
    3. 2?????????????????????°?????????????????????????????????????????????
    """
    # 1.
    oturi = coin_values[0] * coin_nums[0] \
            + coin_values[1] * coin_nums[1] \
            + coin_values[2] * coin_nums[2] \
            + coin_values[3] * coin_nums[3] \
            - fee

    use_coins = [0] * len(coin_values)
    no_use_coins = [0] * len(coin_values)
 
    # 2.
    for i in range(len(coin_values) - 1, -1, -1):
        no_use_coins[i] = int(oturi / coin_values[i])
        oturi = oturi - (coin_values[i] * no_use_coins[i])
 
    # 3.
    for i in range(0, len(use_coins), 1):
        use_coins[i] = coin_nums[i] - no_use_coins[i]
        if use_coins[i] > 0:
            print(str(coin_values[i]) + ' ' + str(use_coins[i]))
 
if __name__ == "__main__":
    first = True
    while (True):
        total_fee = int(input(''))
        if total_fee == 0:
            break
        if first:
            first = False
        else:
            print('')
        coins = input('')
        coins = coins.split(' ')  # 10, 50, 100, 500?????????§????????????
        coins = [int(coin) for coin in coins]
        coin_values = [10, 50, 100, 500]
        back_oturigation(total_fee, coin_values, coins)
s=input()
temp=0
if(s=="RRR"):print(3)
elif(s=="RRS" or s="SRR"):print(2)
elif(s=="SSS"):print(0)
else:print(1)  

### FIXED CODE ###

s=input()
temp=0
if(s=="RRR"):print(3)
elif(s=="RRS" or s=="SRR"):print(2)
elif(s=="SSS"):print(0)
else:print(1)
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(list[K])

### FIXED CODE ###

K=int(input())
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K-1])
from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
t = 0
 
t = 0
for i in range(n):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()
 
print('Yes')



### FIXED CODE ###

from operator import itemgetter
import sys
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
 
#print(listA)
 
listB = sorted(listA)
la = sorted(listB, key=itemgetter(1))
 
t = 0
for i in range(N):
	s = la[i][1]
	t += la[i][0]
	if t > s:
		print("No")
		sys.exit()
 
print('Yes')
#ABC138D
#node:節 edge:枝
def main():
    import sys
    N, Q = map(int, sys.stdin.readline().split())
    edge = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N-1)]
    #1:ノードのリストを作る
    nodeL = [[] for _ in range(N)]
    for a, b in edge:
        nodeL[a-1].append(b-1)
        nodeL[b-1].append(a-1)
    #print(nodeL)
    px = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]
    #print(px)
    score = [0 for i in range(N)]
    for p, x in px:
        score[p-1] +=x
    #print(score)
    result = score.copy()
    
    def dfs(p, g=-1):
        for c in nodeL[p]:
            if c !=g:
                score[c] +=score[p]
                dfs(c, p)
    
    
    dfs(0)
    print(*score)
    


if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(1000000)

n,q = map(int, input().split())
a_b = [list(map(int, sys.stdin.readline().split())) for _ in range(n-1)]
p_x = [list(map(int, sys.stdin.readline().split())) for _ in range(q)]

v = [deque([]) for i in range(n)]
for e in a_b:
    v[e[0]-1]+=[e[1]-1]
    v[e[1]-1]+=[e[0]-1]
score = [0 for i in range(n)]
for e in p_x:
    score[e[0]-1]+=e[1]
def dfs(p, bp=-1):
    while v[p]:
        c =v[p].popleft()
        if c ==bp:
            continue
        #print(p, c, bp)
        score[c]+=score[p]
        dfs(c, bp=p)
visited = [0]                
dfs(0)
print(*score)
count = 0
for s in input():
    if s = '1':
        count += 1

print(count)

### FIXED CODE ###

count = 0
for s in input():
    if s == '1':
        count += 1

print(count)
def get_answer(ki):
    n = int(ki[0].split(" ")[0])
    q = int(ki[0].split(" ")[1])
    n_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[1:-q]]]
    q_data = [[int(k[0]), int(k[1])] for k in [k.split(" ") for k in ki[-q:]]]
    tree = make_tree(n, n_data)

    score = [0] * n

    for qq in q_data:
        index = qq[0]
        add_score(tree, score, qq, n_data, index)

    score = [str(s) for s in score]
    s = " ".join(score)

    return s


def add_score(tree, score, qq, n_data, index):
    score[index - 1] += qq[1]
    next_index = tree[index -1]
    for n_i in next_index:
        add_score(tree, score, qq, n_data, n_i)


def make_tree(n, n_data):
    r = {}
    for i in range(n):
        r[i] = []
    for n in n_data:
        k = n[0] - 1
        if k in r.keys():
            r[k].append(n[1])
        else:
            r[k] = [n[1]]
    return r


def make_index(n, tree):
    index = {}
    for i in range(n):
        r = []
        add_index(tree, i, r)
        index[i] = r

    return index


def add_index(tree, index, r):
    r.append(index)
    next_index = tree[index]
    for n_i in next_index:
        add_index(tree, n_i - 1, r)


if __name__ == "__main__":
    input_ki = []
    while True:
        try:
            input1 = input()
            if not input1:
                break;
            input_ki.append(input1)
        except EOFError:
            break
    print(get_answer(input_ki))


### FIXED CODE ###

import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1): #木グラフの隣接リストを作成
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
for _ in range(q): #各頂点についてcount[v]を計算
 v,val=map(int,input().split())
 cnt[v]+=val
q=collections.deque()
q.append(1) #DFSのスタックによる実装、まずスタックに始点1を積む
checked=[0]*(n+1) #各頂点を見たかどうかのフラグを持っておく
while q:
 v=q.pop()
 checked[v]=1 #頂点を見たかどうかのフラグを更新する
 for u in g[v]:
   if checked[u]==1: #vの子ノードuについて、まだ見ていない頂点であればcount[u]をcount[u]+=count[v]として更新する
     continue
   cnt[u]+=cnt[v]
   q.append(u) #スタックに子ノードuを積む
print(*cnt[1:]) #各頂点のcountが答えとなる
print(input().count(2))

### FIXED CODE ###

print(input().count("2"))
import sys
input = sys.stdin.readline
#-------------------------------------

n,x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
d = 0

for _ in range(n+1):
    if d+l[cnt-1] <= x:
        d = d+l[cnt-1]
        cnt += 1
        # print(d)
    else:
        break

print(cnt)

### FIXED CODE ###


n,x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
d = 0

for _ in range(n):

    if d+l[cnt-1] <= x:
        d = d+l[cnt-1]
        cnt += 1
        # print(d)
    else:
        break

print(cnt)
n, m, q = map(int, input().split())
cnt = 0
for _ in range(q):
    a, b, c, d = list(map(int, input().split()))
for i in range(m-n+1):
    if b[i] - a[i] + (m-n) == c[i]:
        cnt += d[i]
print(cnt)

### FIXED CODE ###

n, m, q = map(int, input().split())
a = [0]*q
b = [0]*q
c = [0]*q
d = [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1

def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):   
        if A[bi] - A[ai] == ci:               
            tmp += di                        
    return tmp                               
    # for i in range(q):
    #     if A[b[i]]-A[a[i]] == c[i]:
    #         tmp += d[i]
    # return tmp

def dfs(A):
    if len(A) == n:
        return score(A)   
    res = 0
    if len(A) > 0:                # prev_last = A[-1] if len(A) > 0 else 0
        prev_last = A[-1] 
    else:
        prev_last = 0
    for i in range(prev_last, m):
        A.append(i)
        res = max(res, dfs(A))    # 再起を呼び出しながら、最大値の更新
        A.pop()
    return res

print(dfs([]))
from collections import Counter
from math import factorial
n = int(input())
s = [''.join(sorted(list(input()))) for _ in range(n)]

def combination(i):
    return factorial(i) // (factorial(i-2) * factorial(2))

cnt = Counter(s)
print(cnt)
ans = 0
for i in cnt.values():
    print(i)
    ans += combination(i)

print(ans)

### FIXED CODE ###

from collections import Counter
from math import factorial
n = int(input())
s = [''.join(sorted(list(input()))) for _ in range(n)]

def combination(i):
    return factorial(i) // (factorial(i-2) * factorial(2))

cnt = Counter(s)
ans = 0
for i in cnt.values():
    if i == 1:
        pass
    else:
        ans += combination(i)
print(ans)
N = int(input())
N2=math.factorial(N)

print(N2%1000000007)

### FIXED CODE ###

import math
N = int(input())
N2=math.factorial(N)

print((N2)%(10 ** 9 + 7))
# -*- coding: utf-8 -*-

import sys
import itertools
import math

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

    if N < M:
        t = M
        M = N
        N = t
        q = S
        S = T
        T = q

    d = math.gcd(N, M)

    n = N / d

    ret = -1
    for step in range(1, M+1):
        slen = step * N
        if slen % M != 0:
            continue
        mstep = slen // M
        good = True
        for i in range(N):
            u = (step * i) % mstep
            if u != 0:
                continue
            j = (step * i) // mstep
            if S[i] != T[j]:
                good = False
                break
        if good:
            ret = step * N
            break

    # 出力
    print("{}".format(ret))


if __name__ == '__main__':
    main()



### FIXED CODE ###

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

import sys
import itertools
import math

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

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

    if N < M:
        t = M
        M = N
        N = t
        q = S
        S = T
        T = q

    d = gcd(N,M)
    c = N * M // d

    ret = -1
    slen = c
    nstep = slen // N
    mstep = slen // M

    dd = gcd(nstep, mstep)
    cc = nstep * mstep // dd

    good = True
    for k in range(0, slen, cc):
        u = (k // nstep) % N
        j = (k // mstep) % M
        if S[u] != T[j]:
            good = False
            break
    if good:
        ret = slen

    # 出力
    print("{}".format(ret))


if __name__ == '__main__':
    main()
A, B = int(input().split())
print(A*B-(A+B-1))


### FIXED CODE ###

A, B = list(map(int, input().split()))
print(A*B-(A+B-1))
import random
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top,   self.bottom = top, bottom
        self.right, self.left   = right, left
        self.front, self.back   = front, back

    def rot(self, d):
        if   d == "N":
            ((self.top, self.back, self.bottom, self.front) =
             (self.front, self.top, self.back, self.bottom))
        elif d == "S":
            ((self.top, self.back, self.bottom, self.front) =
             (self.back, self.bottom, self.front, self.top))
        elif d == "E":
            ((self.top, self.right, self.bottom, self.left) =
             (self.left, self.top, self.right, self.bottom))
        elif d == "W":
            ((self.top, self.right, self.bottom, self.left) =
             (self.right, self.bottom, self.left, self.top))

def same(a, b):
    if ((a.top, a.bottom, a.right, a.left, a.front, a.back) ==
        (b.top, b.bottom, b.right, b.left, b.front, b.back)):
        return True
    else:
        return False

ref = {}
ls1 = map(int, raw_input().split())
ls2 = map(int, raw_input().split())
dice1 = Dice(ls1[0], ls1[1], ls1[2], ls1[3], ls1[4], ls1[5])
dice2 = Dice(ls2[0], ls2[1], ls2[2], ls2[3], ls2[4], ls2[5])
for i in xrange(1000):
    d = "NSEW"[random.randint(0,3)]
    dice1.rot(d)
    if same(dice1, dice2):
        print "Yes"
        break
else:
    print "No"

### FIXED CODE ###

import random
class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top,   self.bottom = top, bottom
        self.right, self.left   = right, left
        self.front, self.back   = front, back

    def rot(self, d):
        if   d == "N":
            (self.top, self.back, self.bottom, self.front) = (
             self.front, self.top, self.back, self.bottom)
        elif d == "S":
            (self.top, self.back, self.bottom, self.front) = (
             self.back, self.bottom, self.front, self.top)
        elif d == "E":
            (self.top, self.right, self.bottom, self.left) = (
             self.left, self.top, self.right, self.bottom)
        elif d == "W":
            (self.top, self.right, self.bottom, self.left) = (
             self.right, self.bottom, self.left, self.top)

def same(a, b):
    if ((a.top, a.bottom, a.right, a.left, a.front, a.back) ==
        (b.top, b.bottom, b.right, b.left, b.front, b.back)):
        return True
    else:
        return False

ref = {}
ls1 = map(int, raw_input().split())
ls2 = map(int, raw_input().split())
dice1 = Dice(ls1[0], ls1[1], ls1[2], ls1[3], ls1[4], ls1[5])
dice2 = Dice(ls2[0], ls2[1], ls2[2], ls2[3], ls2[4], ls2[5])
for i in xrange(1000):
    d = "NSEW"[random.randint(0,3)]
    dice1.rot(d)
    if same(dice1, dice2):
        print "Yes"
        break
else:
    print "No"
def main():
    x, y, a, b, c = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))
    t = [1]
    t.sort()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    s = P[:x] + Q[:y]
    s.sort()
    for i in range(x + y):
        if s[i] < R[i] and i < c:
            s[i] = R[i]
        else:
            break
    print(sum(s))

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    x, y, a, b, c = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))
    t = [1]
    t.sort()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    s = P[:x] + Q[:y]
    s.sort()
    for i in range(x + y):
        if i < c:
            if s[i] < R[i]:
                s[i] = R[i]
            else:
                break
        else:
            break
    print(sum(s))


if __name__ == "__main__":
    main()
pi = 3.14159
r = int(input())
area = pi*pi*r
length = pi*r*2

print('{:.5f}'.format(area),'{:5f}'.format(length))


### FIXED CODE ###

pi = 3.14159265359 
r = float(input()) 
area = r*r*pi 
length = 2*r*pi 

print('{:.6f}'.format(area),'{:.6f}'.format(length))
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(1,len(A)):
    if A[i - 1] != A[i]:
        continue
        k = True
    else:
        k = False
        break

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

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(1, len(A)):
    if A[i - 1] != A[i]:
        k = True
    else:
        k = False
        break

if k:
    print("YES")
else:
    print("NO")
n=int(input().split())
ans=0
s,t=input().split()
for i in range(n):
    ans=ans+s[i]+t[i]
print(ans)

### FIXED CODE ###

n=int(input())
s,t=input().split()
ans=s[0]+t[0]
for i in range(1,n):
    ans=ans+s[i]+t[i]
print(ans)
import sys
sys.setrecursionlimit(100000)
H,W=map(int,input().split())
series = [[] for h in range(H)]
for h in range(H):
	series[h] = list(input())

def Go(h,w):
	#print(h,w)
	global c
	check[h][w]=1
	count = 0
	front = ""
	if series[h][w] == "#":
		front = "."
	else:
		front = "#"
	if h >= 1:
		if series[h-1][w] == front and check[h-1][w] == 0:
			if series[h-1][w] == ".":
				count += Go(h-1,w)+1
			else:
				count += Go(h-1,w)
				c += 1
				used[h-1][w] = 1
	if h < H-1:
		if series[h+1][w] == front and check[h+1][w] == 0:
			if series[h+1][w] == ".":
				count += Go(h+1,w)+1
			else:
				count += Go(h+1,w)
				c += 1
				used[h+1][w] = 1
	if w >= 1:
		if series[h][w-1] == front and check[h][w-1] == 0:
			if series[h][w-1] == ".":
				count += Go(h,w-1)+1
			else:
				count += Go(h,w-1)
				c += 1
				used[h][w-1] = 1
	if w < W-1:
		if series[h][w+1] == front and check[h][w+1] == 0:
			if series[h][w+1] == ".":
				count += Go(h,w+1)+1
			else:
				count += Go(h,w+1)
				c += 1
				used[h][w+1] = 1
	return count

ans=0
used =  [[0 for w in range(W)] for h in range(H)]
check = [[0 for w in range(W)] for h in range(H)]
for h in range(H):
	for w in range(W):
		if series[h][w] == "#" and used[h][w] == 0:
			c=1
			ans += Go(h,w) * c
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
H,W=map(int,input().split())
series = [[] for h in range(H)]
for h in range(H):
	series[h] = list(input())

def Go(h,w):
	#print(h,w)
	global c
	check[h][w]=1
	count = 0
	front = ""
	if series[h][w] == "#":
		front = "."
	else:
		front = "#"
	if h >= 1:
		if series[h-1][w] == front and check[h-1][w] == 0:
			if series[h-1][w] == ".":
				count += Go(h-1,w)+1
			else:
				count += Go(h-1,w)
				c += 1
				used[h-1][w] = 1
	if h < H-1:
		if series[h+1][w] == front and check[h+1][w] == 0:
			if series[h+1][w] == ".":
				count += Go(h+1,w)+1
			else:
				count += Go(h+1,w)
				c += 1
				used[h+1][w] = 1
	if w >= 1:
		if series[h][w-1] == front and check[h][w-1] == 0:
			if series[h][w-1] == ".":
				count += Go(h,w-1)+1
			else:
				count += Go(h,w-1)
				c += 1
				used[h][w-1] = 1
	if w < W-1:
		if series[h][w+1] == front and check[h][w+1] == 0:
			if series[h][w+1] == ".":
				count += Go(h,w+1)+1
			else:
				count += Go(h,w+1)
				c += 1
				used[h][w+1] = 1
	return count

ans=0
used =  [[0 for w in range(W)] for h in range(H)]
check = [[0 for w in range(W)] for h in range(H)]
for h in range(H):
	for w in range(W):
		if series[h][w] == "#" and used[h][w] == 0:
			c=1
			ans += Go(h,w) * c
print(ans)
n = int(input())
A = [int(input()) for i in range(n)] 

counter = [0] * 1000000000
cnt = 0
for a in A:
    counter[a-1] += 1
for c in counter:
    if c == 1:
        cnt += 1
print(cnt)


### FIXED CODE ###

N = input()
result = "No"
for i in N:
    if i == '9':
        result = "Yes"
print(result)
n=int(input())
rec=list(map(int,input().split()))
s=[rec[0],rec[1]-rec[0]]
for i in range(2,n):
        total2=abs(rec[i]-rec[i-2])+s[i-2]
        total1=abs(rec[i]-rec[i-1])+s[i-1]
        s.append(min(total2,total))
print(s[-1])

### FIXED CODE ###

n=int(input())
rec=list(map(int,input().split()))
s=[0,abs(rec[1]-rec[0])]
for i in range(2,n):
        total2=abs(rec[i]-rec[i-2])+s[i-2]
        total1=abs(rec[i]-rec[i-1])+s[i-1]
        s.append(min(total2,total1))
print(s[-1])
X,Y=map(int,input().split())

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**6
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 )

Z=X+Y
if Z%3 == 0:
    D=int(Z/3)
    print(cmb(D,abs(D-X),MOD))
else:
    print(0)

### FIXED CODE ###

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

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**6
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 )

Z=X+Y
if Z%3 == 0:
    D=int(Z/3)
    d=min(X,Y)
    print(cmb(D,d-D,MOD))
else:
    print(0)
N = int(input())

PS = [[Q * 4, 0.25], [H * 2, 0.5], [S, 1], [D / 2, 2]]

PS.sort(key=lambda x: x[0])

# print(PS)

R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] * (R // PS[i][1])
        R = R % PS[i][1]
    # print("ans :", ans)

print(int(ans))

### FIXED CODE ###

Q, H, S, D = map(int, input().split())
N = int(input())

PS = [[Q * 8, 0.25], [H * 4, 0.5], [S * 2, 1], [D, 2]]

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += int(PS[i][0] * PS[i][1] // 2 * (R // PS[i][1]))
        R = R % PS[i][1]

print(ans)
N, Q = map(int, input().split())
childs = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = list(map(int, input().split()))
    childs[a - 1].append(b - 1)

nodes = [0] * (N)
for i in range(Q):
    num, pt = list(map(int, input().split()))
    nodes[num - 1] += pt


def dfs(xs, now=0):
    print(xs, now)
    for x in xs:
        nodes[x] += now
        if childs[x] != []:
            dfs(childs[x], nodes[x])
    return


dfs(childs[0], nodes[0])
print(*nodes)

### FIXED CODE ###

N,Q = map(int,input().split())
parents = {1:0}
for _ in range(N-1):
    a,b = map(int,input().split())
    key,val = max(a,b), min(a,b)
    parents[key] = val
counts = [0]*(N+1)
for _ in range(Q):
    p,x = map(int,input().split())
    counts[p] += x
results = [0]*(N+2)
for i in range(1,N+1):
    results[i] = counts[i]+results[parents[i]]
    print(results[i], end=' ')