Harryxun/stf_run huggingface dataset:
N = int(input())
a = list(map(int, input().split()))

cnt_of_4 = 0
cnt_of_2 = 0
cnt_of_1 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt_of_4 += 1
    elif a[i] == 2:
        cnt_of_2 += 1
    else:
        cnt_of_1 += 1

if cnt_of_4 == N//2:
    print('Yes')
else:
    if cnt_of_1 < cnt_of_4:
        cnt_of_2 = cnt_of_2 - (cnt_of_4-cont_of1)
    if cnt_of_4 * 2 + ((cnt_of_2//2)*2) >= N:
        print('Yes')
    else:
        print('No')
    


### FIXED CODE ###

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

cnt_of_4 = 0
cnt_of_2 = 0
for i in range(N):
    if a[i] % 4 == 0:
        cnt_of_4 += 1
    elif a[i] % 2 ==  0:
        cnt_of_2 += 1

if cnt_of_4 >= N//2 or cnt_of_4 *2 + cnt_of_2 >= N:
    print('Yes')
else:
    print('No')
N = int(input())

A_list = list( map(int, input().split() ) )
B_list = list( map(int, input().split() ) )
C_list = list( map(int, input().split() ) )
# print(d,n,m)
# print(A_list)
# print(B_list)
# print(C_list)

A_sort = sorted(A_list)
C_sort = sorted(C_list)
# print(A_sort)
# print(C_sort)

# kよりも小さい値の位置を探す
def search_lower_num(a_list, k):
    low = 0
    high = len(a_list) - 1
    mid = (low + high)//2

    while low <= high:
        mid = (low + high)//2

        if mid-1 >= 0:
            if a_list[mid-1] < k \
                and a_list[mid] >= k:
                return a_list[:mid]

        # 2分探索する。
        if a_list[mid] < k:
            low = mid + 1
        elif a_list[mid] > k:
            high = mid - 1
        else:
            return None

    if a_list[mid] < k:
        return a_list[:mid+1]

    return None

# kよりも大きい値の位置を探す
def search_upper_num(a_list, k):
    low = 0
    high = len(a_list) - 1
    mid = (low + high)//2

    while low <= high:
        mid = (low + high)//2

        if mid+1 < len(a_list):
            if a_list[mid] <= k \
                and a_list[mid+1] > k:
                return a_list[mid+1:]

        # 2分探索する。
        if a_list[mid] < k:
            low = mid + 1
        elif a_list[mid] > k:
            high = mid - 1
        else:
            return a_list[mid:]

    if a_list[mid] > k:
        return a_list[mid:]

    return None




sum_conbi = 0
for B in B_list:
    a_result = search_lower_num(A_sort, B)
    c_result = search_upper_num(C_sort, B)

    # print(a_result)
    # print(c_result)

    sum_conbi += len(a_result) * len(c_result)

print(sum_conbi)



### FIXED CODE ###

N = int(input())

A_list = list( map(int, input().split() ) )
B_list = list( map(int, input().split() ) )
C_list = list( map(int, input().split() ) )
# print(d,n,m)
# print(A_list)
# print(B_list)
# print(C_list)

A_sort = sorted(A_list)
C_sort = sorted(C_list)

# print("A:", A_sort)
# print("C:", C_sort)

def is_ok_lower(list_data, index: int, key: int):
    if (list_data[index] >= key):
        return True
    else:
        return False

def is_ok_upper(list_data, index: int, key: int):
    if (list_data[index] > key):
        return True
    else:
        return False


def binary_search(list_data, key: int, is_ok_func):
    ng = -1  #「index = 0」が条件を満たすこともあるので、初期値は -1
    ok = len(list_data) # 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    # どんな二分探索でもここの書き方を変えずにできる！
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2

        if (is_ok_func(list_data, mid, key)):
            ok = mid
        else:
            ng = mid

    # left は条件を満たさない最大の値、ok は条件を満たす最小の値になっている
    return ok

sum_conbi = 0
for B in B_list:
    a_key = binary_search(A_sort, B, is_ok_lower)
    c_key = binary_search(C_sort, B, is_ok_upper)

    # print(a_key, N-c_key)
    # print(B,">", A_sort[:a_key])
    # print(B,"<", C_sort[c_key:])

    sum_conbi += (a_key) * (N-c_key)

print(sum_conbi)
n = int(input())
k = 0
if int(n/111) == n/111:
  k = n/111
else k = int(n/111) + 1
print(111*k)

### FIXED CODE ###

n = int(input())
k = 0
if int(n/111) == n/111:
  k = int(n/111)
else:
  k = int(n/111) + 1
print(111*k)
l = int(input())
s = input()
s_dict = {}
for i in range(0, len(s)):
    if not s[i] in s_dict:
        s_dict[s[i]] = 1
    else:
        s_dict[s[i]] += 1
ans = 2**l
for v in s_dict.values():
    if not v == 1:
        ans *= (v+1)/2**v

print(int(ans-1)%(10**9+7))


### FIXED CODE ###

l = int(input())
s = input()
s_dict = {}
l = len(s)
for i in range(l):
    if not s[i] in s_dict:
        s_dict[s[i]] = 1
    else:
        s_dict[s[i]] += 1
ans = 1
for v in s_dict.values():
    if v == 1:
    	ans *= 2
    else:
        ans *= v+1

print(int(ans-1)%(10**9+7))
n,m=map(int,input().split())
print(Yes) if n==m else print(No)

### FIXED CODE ###

n,m=map(int,input().split())
print("Yes") if n==m else print("No")
a = 0
b= 0
 
input_numbers = raw_input()
 
fori in input_numbers:
   if input_numbers[0] == i:
      a = int(i)
   elif input_numbers[2] == i:
      b = int(i)
 
print a * b, 2 * (a + b)

### FIXED CODE ###

num = raw_input()
num = num.split()
a = int(num[0])
b = int(num[1])

print a * b, 2 * (a + b)
def f(n):
  m=A[n]
  if m==1:
    print(n)
  elif L[m]==1:
    print(-1)
  else:
    n+=1
    L[m]=1
    return f(m)

N=int(input())
L=[0 for i in range(N)]
A=[int(input())-1  for _ in range(N)]
L[0]=1
n=0
if A[0]==1:
  print(1)
else:
  f(0)

### FIXED CODE ###

N=int(input())
L=[0 for i in range(N)]
A=[int(input())-1  for _ in range(N)]
n=0
m=1
while L[n]!=1 and A[n]!=1:
  L[n]=1
  m+=1
  n=A[n]
if L[n]==1:
  print(-1)
else:
  print(m)
S = input()
cnt = [0] * 26
for i in range(len(S)):
    cnt[ord(S[i]) - ord('a')] += 1

for i in range(len(S)):
    if not cnt[i]:
        print(chr(ord('a')+i))
        break

### FIXED CODE ###

import sys
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"

for s in alphabet:
    if s not in S:
        print(s)
        sys.exit()

print("None")
a, b = input().split()

bigA = a*int(b)
bigB = b*int(a)

if bigA < bigB:
    print(bigA)
elif bigA = bigB:
    print(bigA)
else:
    print(bigB)

### FIXED CODE ###

a, b = input().split()

bigA = a*int(b)
bigB = b*int(a)

if bigA < bigB:
    print(bigA)
elif bigA == bigB:
    print(bigA)
else:
    print(bigB)
w,h,x,y = map(int, input().split())
if w//2==x and h//2==y and w%2==0 and h%2==0:
	print(w*h/2., 1)
else*
	print(w*h/2., 0)
	

### FIXED CODE ###

w,h,x,y = map(int, input().split())
if w//2==x and h//2==y and w%2==0 and h%2==0:
	print(w*h/2., 1)
else:
	print(w*h/2., 0)
n,m = map(int,input().split())
a = [input().split() for i in rabge(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

ac = 0
wa = 0
wa_c = [0]*n
ac_c = [False]*n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)

### FIXED CODE ###

n,m = map(int,input().split())
a = [input().split() for i in range(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

ac = 0
wa = 0
wa_c = [0]*n
ac_c = [False]*n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)
a

### FIXED CODE ###

import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
def main():
    n, m = map(int, input().split())
	all_patterns = 2**n
    DP = [10**9] * all_patterns
    DP[0] = 0
    for _ in range(m):
        cost, types = map(int, input().split())
        to_open = list(map(int, input().split()))

        openable = 0
        for open in to_open:
            openable += 1 << (open-1)

        for opened in range(all_patterns):
            pattern = opened | openable
            new_cost = DP[opened] + cost
            if DP[pattern] > new_cost:
                DP[pattern] = new_cost

    full_open = 2**n - 1
    ans = DP[full_open]

    if ans == 10 ** 9:
        ans = -1

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

keys = []

for i in range(m):
    cost, num = map(int, input().split())
    C = list(map(int, input().split()))
    can_open = 0
    for c in C:
        can_open += 2 ** (c-1)
    keys.append([cost, can_open])

DP = {}
for i in range(2**n):
    DP[i] = float('INF')
DP[0] = 0

for cost, can_open in keys:
    for key in DP.keys():
        pre_cost = DP[key]
        next_key = key | can_open
        DP[next_key] = min(DP[next_key], pre_cost+cost)


full_open = (1 << n) - 1

if DP[full_open] == float('INF'):
    print(-1)
else:
    print(DP[full_open])
# -*- coding: utf-8 -*-
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(readline())
S = [int(x) - ord("A") for x in read().rstrip]
N = int(readline())

S = [(x + N) % 26 for x in S]

anser = "".join([chr(x + ord("A")) for x in S])

print(anser)


### FIXED CODE ###

N = int(input())
S = input()

out = ""
for i in S:
    tmp = (ord(i) + N) % 91
    if tmp < 65:
        tmp = tmp + 65
    out = out + chr(tmp)

print(out)
from collections import deque

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


dist=[float("inf")]*N
dist[0]=0
prev=[None]*N

def dfs1(v,parent,d):
    prev[v]=parent
    dist[v]=d
    for v2 in graph[v]:
        if v2==parent:
            continue
        dfs1(v2,v,d+1)

dfs1(0,-1,0)

x=N-1
for _ in range((dist[-1]-1)//2):
    x=prev[x]
cant_go=prev[x]

sunuke_score=0
def dfs2(v,parent):
    global sunuke_score
    sunuke_score+=1
    for v2 in graph[v]:
        if v2==parent:
            continue
        if v2==cant_go:
            continue
        dfs2(v2,v)

dfs2(x,-1)

fennec_score=N-sunuke_score
if sunuke_score>fennec_score:
    print("Snuke")
else:
    print("Fennec")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

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


dist=[float("inf")]*N
dist[0]=0
prev=[None]*N

def dfs1(v,parent,d):
    prev[v]=parent
    dist[v]=d
    for v2 in graph[v]:
        if v2==parent:
            continue
        dfs1(v2,v,d+1)

dfs1(0,-1,0)

x=N-1
for _ in range((dist[-1]-1)//2):
    x=prev[x]
cant_go=prev[x]

sunuke_score=0
def dfs2(v,parent):
    global sunuke_score
    sunuke_score+=1
    for v2 in graph[v]:
        if v2==parent:
            continue
        if v2==cant_go:
            continue
        dfs2(v2,v)

dfs2(x,-1)

fennec_score=N-sunuke_score
if sunuke_score>=fennec_score:
    print("Snuke")
else:
    print("Fennec")
import math
a, b = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True


ans = 1
divs = make_divisors(math.gcd(a, b))
for num in divs:
    if is_prime(num):
        ans += 1
print(ans)

### FIXED CODE ###

import math
import fractions
a, b = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True


ans = 1
divs = make_divisors(fractions.gcd(a, b))
for num in divs:
    if is_prime(num):
        ans += 1
print(ans)
n = int(input())
a = list(map(int,input().split()))
w = [0 for i in range(9)]
count = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
    w[i//400]+=1
if count == 0:
    print(1,w[8])
elif w[8] == 0:
    print(count,count)
else:
    b= count+w[8]
    print(count,b)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
w = [0 for i in range(8)]
count = 0
sup = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
        w[i//400] += 1
    elif i >= 3200:
        sup += 1
if count == 0:
    print(1,sup)
elif sup == 0:
    print(count,count)
else:
    b= count+sup
    print(count,b)
n = int(input())
p = list(map(int, input().split()))
count = 0

for i in range(1, n):
    new = p[:i]
    m = max(new)
    print(new)
    if p[i] < m:
        count += 1

print(count)


### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
min = 10 ** 100
count = 0


for i in range(n):
    if p[i] < min:
        min = p[i]
        count += 1

print(count)
A,B = map(int,input().split())
S = input()
L = [0,1,2,3,4,5,6,7,8,9]
for i in (range(A) and range(A+1,A+B+1)):
  if (S[i] in L):
    if (S[A] == '-'):
      print('Yes')
  else:
    print('No')

### FIXED CODE ###

N,A,B = map(int,input().split())
L = []
for i in range(1,N+1):
  k = str(i)
  s = 0
  for j in range(len(k)):
    s += int(k[j])
  if (A <= s <= B):
    L.append(i)
print(sum(L))
r,g,b,n = map(int,input().split())
lis=[r,g,b]
lis.sort()
cnt=0
for i in range(n//lis[2] + 1):
  for l in range(n//lis[1]+1):
    for m in range(n//lis[0]+1):
      if i*lis[2]+l*lis[1]+m*lis[0] = n:
        cnt+=1
print(cnt)


### FIXED CODE ###

b,r,g,n=map(int,input().split())
ans=0
for i in range(3000//r+1):
    for j in range(3000//g+1):
        if n-j*g-i*r>=0 and (n-j*g-i*r)%b==0:
            ans+=1
print(ans)
n,m = map(int,input().split())
lm = list(map(int,input().split()))
ln = []
for _ in range(m):
    ln.append(list(map(int,input().split())))
for a in range(m):
    for b in range(ln[a][0]):
        if  ln[a][1] > min(lm) :
            c = min(lm)
            lm[lm.index(c)] =  ln[a][1] 
    print('aa')
print(sum(lm))

### FIXED CODE ###

a,b = map(int,input().split())
if a <= 5:
    print(0)
elif 6 <= a <= 12:
    print(int(b*0.5))
else:
    print(b)
import math

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

if x<=a^2*b/2:
  y=x/a*2/b
  print(math.atan(b/y))
else:
  z=b*2-2*x/(a^2)
  print(math.atan(z/a))


### FIXED CODE ###

import math

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

if x<=(a**2)*b/2:
  y=x/a*2/b
  print(' {:.10f}'.format(math.atan(b/y)/math.pi*180))
else:
  z=b*2-2*x/(a**2)
  print(' {:.10f}'.format(math.atan(z/a)/math.pi*180))
A, B, K = [int(s) for s in input().split()]

if K <= A:
    print(A-K, B)
elif K <= A + B:
    print(0, A+B-K)
else:
    print(0, 0)

### FIXED CODE ###

S,T = input().split()
print(T + S)
N,k= map(int,input().split())
A= list(map(int,input().split()))
tree = [0] * (N+1)
M=10**9+7
def BIT_update(tree,x):
  while x <= N:
    tree[x] += 1
    x += x&(-x)
def BIT_sum(tree,x):
  s = 0
  while x:
    s += tree[x]
    x -= x&(-x)
  return s

answer = N*(N-1)//2
c={}
for x in A:
    answer -= BIT_sum(tree,x)
    BIT_update(tree,x)
    if x not in c:
        c[x]=1
    else:
        c[x]+=1
c=sorted(c.items(),key=lambda x:x[0])
d,e=0,0
for j in c:
    d=(d+(((k*(k-1))//2))*e)%M
    e+=j[1]
print((answer*k+d)%M)

### FIXED CODE ###

n,k=map(int,input().split())
a,b=list(map(int,input().split())),0
for i,j in enumerate(a):
    for h in a[i:]:
        if j<h:b+=k*(k-1)//2
        elif j>h:b+=k*(k+1)//2
print(b%(10**9+7))
n,m=map(int,raw_input().split())

while n!=0 and m!=0:
    ok=0
    list=map(int,raw_input().split())
    if list[0]<m:
        max=list[0]
    for j in range(len(list)-1):
        for k in range(1,len(list)):
            tmp=list[j]+list[k]
            if tmp>max and tmp<=m:
                ok=1
                max=tmp
    if ok==1:
        print(max)
    else:
        print("NONE")
    n,m=map(int,raw_input().split())



### FIXED CODE ###

A=[0 for i in range(2)]
A=input().split()
n=int(A[0])
m=int(A[1])
max=[]
k=0

while n>0 and m>0:
    B=[0 for i in range(n)]
    B=input().split()
    for i in range(n):
        B[i]=int(B[i])
    max1=0
    for i in range(n):
        for j in range(i+1,n):  
            x=0 
            x=B[i]+B[j]
            if max1<x and x<=m:
                max1=x
    max.append(max1)
    A=input().split()
    n=int(A[0])
    m=int(A[1])
    k+=1
for i in range(k):
    if max[i]>0:
        print(max[i])
    else:
        print("NONE")
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
if m > n:
    print('NO')
    exit()
numd = [0]*(10**9+5)
numt = [0]*(10**9+5)
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 = input()
input_list = list(map(int, input().split()))
input_list.sort(reverse=True)
# aliceは奇数番目のものを、bobは偶数番目のものをとる
alice = 0
bob = 0
for i in range(n):
    if (i+1) % 2 == 1:
        alice += input_list[i]
    else:
        bob += input_list[i]
print(alice - bob)

### FIXED CODE ###

n = int(input())
input_list = list(map(int, input().split()))
input_list.sort(reverse=True)
# aliceは奇数番目のものを、bobは偶数番目のものをとる
a = 0
b = 0
for i in range(n):
    if (i+1) % 2 == 1:
        a += input_list[i]
    else:
        b += input_list[i]
print(a - b)
s=input()
a={}
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a=a|{s[i]}
print(ans)

### FIXED CODE ###

s=input()
a=set()
ans="yes"
for i in range(len(s)):
  if s[i] in a:
    ans="no"
    break
  a.add(s[i])
print(ans)
a = input()
print(len(a[a.index('A'):a.rindex('Z')+1]))

### FIXED CODE ###

a = int(input())
print('ARC') if a>=1200 else print('ABC')
s = input()
n = len(s)
MOD = 1e9 + 7
dp = [[0] * 13 for _ in range(n)]
for i in range(10):
	if s[0] == "?":
		dp[0][i] = 1
	else:
		cur = ord(s[0]) - ord("0")
		dp[0][cur] = 1
for i in range(1, n):
	if s[i] != "?":
		cur = ord(s[i]) - ord("0")
		for j in range(13):
			dp[i][(10 * j + cur) % 13] += dp[i - 1][j]
	else:
		for j in range(13):
			for cur in range(10):
				dp[i][(10 * j + cur) % 13] += dp[i - 1][j]
#print(dp)
print(int(dp[n - 1][5] % MOD))

### FIXED CODE ###

s = input()
n = len(s)
MOD = 1e9 + 7
dp = [[0] * 13 for _ in range(n)]
for i in range(10):
	if s[0] == "?":
		dp[0][i] = 1
	else:
		cur = ord(s[0]) - ord("0")
		dp[0][cur] = 1
for i in range(1, n):
	if s[i] != "?":
		cur = ord(s[i]) - ord("0")
		for j in range(13):
			dp[i][(10 * j + cur) % 13] += dp[i - 1][j] % MOD
	else:
		for j in range(13):
			for cur in range(10):
				dp[i][(10 * j + cur) % 13] += dp[i - 1][j] % MOD
#print(dp)
print(int(dp[n - 1][5] % MOD))
a, b = map(int, input.split())↲
  2 ↲
  3 if (a + b)%2 == 0:↲
  4   print('even')↲
  5 else:↲
  6   print('odd')↲                                                                                                                                                                            
~                  

### FIXED CODE ###

a, b = map(int, input().split())
if (a * b)%2 == 0:
  print('Even')
else:
  print('Odd')
a = raw_input()
b = raw_input()
print a*b 2(a+b)

### FIXED CODE ###

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

print a*b, 2*(a+b)
# -*- coding: utf-8 -*-
def check(t, n, idx):
    if t == n + idx or t == n - idx:
        return idx
    if idx >= t and t > 0:
        return t
    elif t < 0 and idx * -1 <= t:
        return idx
    return min(check(t, n + idx, idx + 1), check(t, n - idx, idx + 1), check(t, n, idx + 1))

X = int(input())
print(check(X, 0, 1))

### FIXED CODE ###

N = int(input())
 
for i in range(1, N + 1):
    if N <= (i * (i + 1) / 2):
        print (str(i))
        break
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]
px = [list(map(int,input().split())) for _ in range(Q)]
tree = [[] for i in range(N)]
ans = [0]*N
ad = [0]*N
for a,b in ab:
  tree[a-1].append(b-1)
  

for i in range(N-1,-1,-1):
  x = tree[i].copy()
  for j in x:
    tree[i]+=tree[j]

for p,x in px:
  ad[p-1]+=x
  

for i,a in enumerate(ad):
  ans[i]+=a
  x=tree[i].copy()
  for j in x:
    ans[j]+=a
    
print(' '.join(map(str,ans)))

### FIXED CODE ###

from collections import deque
N, Q = map(int, input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]
px = [list(map(int,input().split())) for _ in range(Q)]
tree = [[] for _ in range(N)]
ans = [0]*N
for a,b in ab:
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
  
for p,x in px:
  ans[p-1]+=x
  
q = deque([0])
judge = [False]*N
while q:
  a=q.pop()
  judge[a]=True
  for i in tree[a]:
    if judge[i]:
      continue
    ans[i]+=ans[a]
    q.append(i)
    
print(' '.join(map(str,ans)))
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))


### FIXED CODE ###

import numpy as np
N,M=map(int,input().split())
S=np.ones(N)
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1]=0

  elif H[a-1]>H[b-1]:
    S[b-1]=0

  else:
    S[a-1]=0
    S[b-1]=0

print(int(np.sum(S)))
from collections import defaultdict

n=int(input())
dct=defaultdict(list)

for i in range(n-1):
  a,b,c=map(int,input().split())
  dct[a]+=[[b,c]]
  dct[b]+=[[a,c]]


q,k=map(int,input().split())
lk=[0]*(n)

def dfs(v,p,d):
  lk[v-1]=d

  for l in dct[v]:
    if l[0]==p or lk[l[0]-1]!=0:
      continue
    else:
      dfs(l[0],v,d+l[1])
  return

dfs(k,-1,0)



for i in range(q):
  x,y=map(int,input().split())
  print(lk[x-1]+lk[y-1])

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)

n=int(input())
dct=defaultdict(list)

for i in range(n-1):
  a,b,c=map(int,input().split())
  dct[a]+=[[b,c]]
  dct[b]+=[[a,c]]


q,k=map(int,input().split())
lk=[0]*(n)

def dfs(v,p,d):
  lk[v-1]=d

  for l in dct[v]:
    if l[0]==p or lk[l[0]-1]!=0:
      continue
    else:
      dfs(l[0],v,d+l[1])
  return

dfs(k,-1,0)



for i in range(q):
  x,y=map(int,input().split())
  print(lk[x-1]+lk[y-1])
import numpy as np
h,w,a,b =map(int,input().split())
for i in range(b):
    print('1'*a+'0'*(w-a))
for i in range(h-b):
    print('0'*a+'1'*(w-a))

### FIXED CODE ###

def main():
    h,w,a,b=map(int,input().split())
    Ans=[[0]*w for _ in range(h)]
    for x in range(h):
        for y in range(w):
            Ans[x][y]=int((x<b)^(y<a))
    for ans in Ans:
        print(*ans,sep='')
    return
    
if __name__=='__main__':
    main()
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A_reverse = list(reversed(A))
    left = [0]
    right = [0]
    answer = []
    for n in range(N):
        left.append(gcd(left[n], A[n]))
        right.append(gcd(right[n], A_reverse[n]))
    del left[N]
    del right[N]
    right.reverse()
    for n in range(N-1):
        answer.append(gcd(left[n], right[n]))
    print(max(answer))


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin


def main():
    A, B, T = [int(x) for x in stdin.readline().split()]

    print((T // A * B))


if __name__ == "__main__":
    main()
c,a,b=map(int(input().split()))
print(a*c)

### FIXED CODE ###

c,a,b=map(int,input().split( ))
print(int(a*c/2))
x,y = map (int raw_input().split())
print x*y, 2*x+2*y

### FIXED CODE ###

a,b = map(int,raw_input().split())
print ("{0} {1}").format(a*b,2*a+2*b)