peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

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


def combination(n, r, mod):
    r = min(r, n-r)

    numer = 1
    denom = 1

    for i in range(r):
        numer = numer * (n-i) % mod
        denom = denom * (r-i) % mod

    return numer * pow(denom, mod-2, mod) % mod

m_n = (X+Y) // 3
m = X - m_n
n = Y - m_n

if X+Y % 3 == 0 or m < 0 or n < 0:
    print(0)
    exit()

print(combination(m_n, m, mod))
# Judge status: Wrong Answer
s=list(input())
n=len(s)
a=s.count('1')
b=n-a
print(abs(a-b))
# Judge status: Accepted
n = int(input())
a = []
cnt = 0
k = 1
while cnt < n:
    cnt += k
    a.append(cnt)
    k += 1
diff = a[-1] - n
for i in range(1, len(a)+1):
    if i == diff:
        pass
    else:
        print(i)
# Judge status: Wrong Answer
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0


def judge(i, j, k, xxx):
    sum = 500 * i + 100 * j + 50 * k
    return sum == xxx and sum <= 2000


count = 0
for i in range(x500):
    if judge(i, j, k, xxx):
        count += 1
    for j in range(x100):
        if judge(i, j, k, xxx):
            count += 1
        for k in range(x50):
            if judge(i, j, k, xxx):
                count += 1
print(count)
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S=input()
count=0
for j in range(Q):
    l, r = map(int, input().split())
    s=S[l-1:r]
    count+=s.count("AC")
print(count)
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
D = abs(A - B)
S = V - W
if V - W <= 0:
  print("NO")
else:
  if D / S > T:
    print("NO")
  else:
    print("YES")
# Judge status: Accepted
a,b=map(int,input().split())
c=0
for i in range(1,(b-a)+1):
    c+=i
print(c-b)
# Judge status: Accepted
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

zx = max(x, max(X)); zy = min(y, min(Y))
print('No War') if zx < zy else print('War')
# Judge status: Accepted
p=10**9+7
X, Y=map(int, input().split())

if (X+Y)%3>0:
  print(0)
  exit()
  
a=(2*X-Y)//3
b=(2*Y-X)//3

if a*b<0:
  print(0)
  exit()

ab=a+b
ue=[1]*(ab+1)
for i in range(1, ab+1):
  ue[i]=ue[i-1]*i%p
  
out=ue[-1]*pow(ue[a], p-2, p)%p
out=out*pow(ue[b], p-2, p)%p

print(out)
# Judge status: Accepted
import math
n = int(input())
div = math.ceil(n/1.08)

if math.floor(div*1.08)==n:
    print(div)
else:
    print(':(')
# Judge status: Accepted
S = input()
months = [i for i in range(1, 13)]
left = int(S[:2])
right = int(S[2:])
if left in months and right in months:
    print('AMBIGUOUS')
elif left in months:
    print('MMYY')
elif right in months:
    print('YYMM')
else:
    print('NA')
# Judge status: Accepted
from collections import Counter

s = Counter(input())

print("Yes" if all(n % 2 == 0 for n in s.values()) else "No")
# Judge status: Accepted
from statistics import mean 
import math
n=int(input())
arr=[int(x) for x in input().split()]
a=math.ceil(mean(arr))
b=math.floor(mean(arr))
s1=0
s2=0
for x in arr:
    s1=s1+((x-a)**2)
    s2=s2+((x-b)**2)
print(min(s1,s2))
# Judge status: Accepted
n=int(input())
a=[int(input()) for _ in range(n)]
b=sorted(a,reverse=True)
for i in range(n):
    if a[i]==b[0]:
        print(b[1])
    else:
        print(b[0])
# Judge status: Wrong Answer
n = int(input())

mod = 10**9+7


x = pow(10,n,mod) - 2*pow(9,n,mod)+ pow(8,n,mod);

print(int(x)%mod)
# Judge status: Wrong Answer
#E
N=int(input())
ans=0
if N%2==0:
    N/=2
else:
    N=0
while N>=1:
    N-=N%5
    N=int(N/5)
    ans+=N
print(ans)
# Judge status: Wrong Answer
import bisect

N, H = map(int, input().split())
ab = [map(int, input().split()) for _ in range(N)]
a, b = [list(i) for i in zip(*ab)]

a.sort()
b.sort()

x = bisect.bisect_left(b, a[-1])
H -= sum(b[x:])

print(N-x+(H+a[-1]-1)//a[-1])
# Judge status: Wrong Answer
a, b, k = map(int, input().split())
if k < a:
    print(str(k - a) + " " + str(b))
elif a <= k and k < a + b:
    print(str(0) + " " + str(b - k + a))
else:
    print(str(0) + " " + str(0))
# Judge status: Accepted
N = int(input())
As = list(map(int, input().split()))

Bs = [0] * (N+1)
for i in reversed(range(1, N+1)):
    parity = sum(Bs[i::i]) % 2
    if parity != As[i-1]:
        Bs[i] = 1

anss = [i for i in range(1, N+1) if Bs[i]]

print(len(anss))
if anss:
    print(' '.join(map(str, anss)))
# Judge status: Wrong Answer
n = int(input())

ans = 0

bou = list(map(int,input().split()))
bou.sort(reverse=True)
l_bou = len(bou)
for i in range(l_bou):
    for j in range(i+1, l_bou):
        for k in range(j+1, l_bou):
            if ((bou[i] is not bou[j]) and (bou[j] is not bou[k]) and (bou[i] is not bou[k])): 
                if (bou[i] < bou[j] + bou[k]):
                    ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
s = input()
ans = 0

for i in range(n):
    b = set(s[:i]) & set(s[i:])
    ans = max(ans, len(b))

print(ans)
# Judge status: Wrong Answer
a = int(input())
s = input()
if a>=3200:
  print("red")
if a<3200:
  print(s)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    N, P = map(int, input().split())
    A = list(map(int, input().split()))

    pre = [1, 0]

    for i, a in enumerate(A):
        if a&1:# 奇数
            tmp = [sum(pre), sum(pre)]
        else:# 偶数
            tmp = [pre[0] * 2, pre[1] * 2]
        pre = tmp
    
    print(pre[P])

if __name__ == "__main__":
    main()
# Judge status: Accepted
S=input()
S0=S[::2]
S1=S[1::2]
S01=S0.count('1')
S00=S0.count('0')
S11=S1.count('1')
S10=S1.count('0')
change=min(S00+S11,S10+S01)
print(change)
# Judge status: Accepted
s = list(input())
K = int(input())

i = 0
while(s[i]=='1'):
    K -= 1 
    if K == 0:
        break 
    i += 1 
print(s[i])
# Judge status: Accepted
import math
N=int(input())
X=list(map(int,input().split()))
Prange= range(math.floor(min(X))-1,math.ceil(max(X))+1)
summin=100000000000
for P in Prange:
    sum=0
    for x in X:
        sum+=(P-x)**2
    if summin > sum:
        summin=sum
print(summin)
# Judge status: Accepted
def solve():
  N, M = map(int, input().split())
  lis = [False]*N
  cnt = [1]*N
  lis[0] = True
  for i in range(M):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    if lis[x]==True:
      lis[y]=True
      if cnt[x]==1:
        lis[x]=False
    cnt[x] -= 1
    cnt[y] += 1
  ans = lis.count(True)
  return ans
print(solve())
# Judge status: Accepted
s=input()

if s[-1]=="s":
  s+="e"
  
print(s+"s")
# Judge status: Wrong Answer
n,k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print(s)
# Judge status: Accepted
import numpy as np

n = int(input())
X = np.array([input().split() for _ in range(n)], np.int64)
dp = np.zeros((n + 1, 3), np.int64)
dp[0, 0] = dp[0, 1] = dp[0, 2] = 0
for i in range(n):
    for j in range(3):
        dp[i + 1, j] = X[i, j] + max(dp[i, k] for k in range(3) if j != k)
print(max(dp[n]))
# Judge status: Accepted
K = int(input())
if K%2==0:
    print((K//2)**2)
else:
    n = K//2
    print(n*(n+1))
# Judge status: Wrong Answer
a,b=list(input()),list(input())
a.reverse()
print("Yes" if a == b else "No")
# Judge status: Accepted
import math
N=int(input())

min = N/1.08
max = (N+1)/1.08

candidate = math.ceil(min)
if candidate >= max:
    print(':(')
else:
    print(candidate)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a|b > 9:
  print(-1)
else:
 print(a*b)
# Judge status: Accepted
a,b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')
# Judge status: Wrong Answer
from sys import stdin
N,R = [int(x) for x in stdin.readline().rstrip().split()]
print(R + (100*(10-N)))
# Judge status: Accepted
from sys import stdin
input = stdin.readline

a = int(input())
b = int(input())
h = int(input())

print((a+b)*h//2)
# Judge status: Accepted
#11
n,m = map(int,input().split())
ab = []
cd = []
for i in range(n):
    ab.append(list(map(int,input().split())))
for i in range(m):
    cd.append(list(map(int,input().split())))
    
for i in range(n):
    Max = [0,float("inf")]
    for j in range(m):
        l = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if Max[1]>l:
            Max = [j+1,l]
    print(Max[0])
# Judge status: Accepted
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b,c=map(int,input().split())
if b//a<c:
  print(b//a)
else:
  print(c)
# Judge status: Accepted
a, b, c, k = map(int, input().split())

if a >= k:
    print(k)
elif a+b >= k:
    print(a)
elif a+b+c >=k:
    sum = a - (k - (a+b))
    print(sum)
# Judge status: Accepted
x=int(input())

d=100
y=d
i=0
while(y<x):
    y=int(y*1.01)
    i+=1

print(i)
# Judge status: Wrong Answer
n, m = map(int, input().split())
if n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print((n - 2) * (m - 2))
# Judge status: Accepted
N = int(input())
now_t = 0
now_x = 0
now_y = 0
flag = 0
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x-now_x)+abs(y-now_y)<= abs(t-now_t) and (abs(x-now_x)+abs(y-now_y))%2 == abs(t-now_t)%2:
        now_t = t
        now_x = x
        now_y = y
    else:
        flag += 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

flag=True
for i in range(n):
    time=t[i+1]-t[i]
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dist>time:
        flag=False
    if dist%2 != time%2:
        flag=False
if flag == True:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

answer = 0
mod = 10**9 + 7
total_sum = sum(a)
for idx in range(n - 1):
    total_sum -= a[idx]
    answer += a[idx] * total_sum

print(answer % mod)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

F=0
K=1
b=A[0]

for a in A:
    if F==0:
        if b<a:
            F=1
            b=a
        elif b>a:
            F=-1
            b=a
    elif F==1 and b>a:
        K+=1
        F=0
    elif F==-1 and b<a:
        K+=1
        F=0
    b=a
print(K)
# Judge status: Accepted
N = int(input())
plan = [[0,0,0]]
plan.extend(list(map(int, input().split())) for i in range(N))
f = True
for i in range(N):
    time = plan[i+1][0]-plan[i][0]
    dist = abs(plan[i+1][1]-plan[i][1])+abs(plan[i+1][2]-plan[i][2])
    if dist>time or (dist%2 != time%2):
        f = False
print('Yes' if f else 'No')
# Judge status: Accepted
import sys
a = [int(input()) for _ in range(6)]

for i in a[1:-1]:
    if i-a[0] > a[-1]:
        print(':(')
        sys.exit()
print('Yay!')
# Judge status: Accepted
import numpy as np

N = int(input())
A, B = [], []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a if N & 1 else 2 * a)
    B.append(b if N & 1 else 2 * b)

a, b = int(np.median(A)), int(np.median(B))
print(b - a + 1)
# Judge status: Wrong Answer
n,y = map(int,input().split())
for a in range(2001):
  for b in range(2001):
    c = n - a - b
    if 10000*a + 5000*b + 1000*c == y and 0 <= c <= 2000:
      print(str(a) + " " + str(b) + " " + str(c))
    break
# Judge status: Wrong Answer
N=input()
a=[]
a=N

b=a[int(len(N))-1]
if(b==0 or b==1 or b==6 or b==8):
    print('pon')
elif(b==3):
    print('bon')
else:
    print('hon')
# Judge status: Accepted
X, Y = map(int, input().split())
cnt = 0
while X <= Y:
    X *= 2
    cnt += 1
print(cnt)
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort(reverse=True)

i = lst1[0]
lst1 = lst1[1:]

res = i/2
res2 = -1
minimum = 10**18
for j in lst1:
    if abs(j-res) < minimum:
        res2 = j
        minimum = abs(j-res)

print(i,res2)
# Judge status: Wrong Answer
import sys
from collections import Counter

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

if not ("N" in s and "S" in s):
    print("No")
    exit()

if not ("E" in s and "W" in s):
    print("No")
    exit()

print("Yes")
# Judge status: Wrong Answer
s = list(input())
k = int(input())
n = len(s)
c = ord("z") + 1
for i in range(n):
    tmp = c - ord(s[i])
    if k >= tmp:
        s[i] = "a"
        k -= tmp
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))
# Judge status: Accepted
a,b=input().split()
a=str(a)
b=str(b)
n=int(a+b)

#print(n)

for i in range(500):
  if n == i**2:
    print("Yes")
    exit()
print("No")
# Judge status: Accepted
S=input()
import itertools
A=[]
for key,g in itertools.groupby(S):
  A.append([key,len(list(g))])
ans=0
open=True
cur=0
for i in range(len(A)):
  key=A[i][0]
  n=A[i][1]
  if (i==0 and key==">") or (i==len(A)-1 and key=="<"):
    ans+=n*(n+1)//2
  else:
    if open:
      cur=n
      open=False
    else:
      if n>cur:
        cur-=1
      else:
        n-=1
      ans+=cur*(cur+1)//2+n*(n+1)//2
      open=True
print(ans)
# Judge status: Accepted
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    to = [0]*(n+1)
    ans = 0
    for _ in range(m):
        a, b = map(int, input().split())
        to[a] = max(to[a], h[b-1])
        to[b] = max(to[b], h[a-1])
    for i, hi in enumerate(h, 1):
        t = to[i]
        if t == 0 or hi > t:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
a = int(input())
sum = 0
for i in range(1,a+1):
    if(i % 3==0 or i % 5==0 or i% 15 == 0):
        continue
    else:
        sum += i

print(sum)
# Judge status: Wrong Answer
import itertools
N=int(input())
LN=list(input().split(' '))
print(LN)
LN.sort()
LN_sort=list(dict.fromkeys(LN))
print(LN_sort)
cbn=list(itertools.combinations(LN_sort,3))
cnt=int(0)
for i in range(len(cbn)):
    if int(cbn[i][0])+int(cbn[i][1])>int(cbn[i][2]):
        cnt+=LN.count(cbn[i][0])*LN.count(cbn[i][1])*LN.count(cbn[i][2])

print(cnt)
# Judge status: Wrong Answer
s = list(input())

s.reverse()

print(''.join(s))

b = 0
ans = ''
for c in s:
    if c == 'B':
        b += 1
    else:
        if b > 0:
            b -= 1
            continue
        else:
            ans += c

ans = list(ans)
ans.reverse()
print(''.join(ans))
# Judge status: Accepted
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)
# Judge status: Wrong Answer
k = int(input())
s = input()

if len(s) > len(s[:k]):
    s += '...'

print(s)
# Judge status: Accepted
import itertools

N = int(input())
odd = N // 2 + N % 2
even = N // 2

print(odd * even)
# Judge status: Wrong Answer
mod=10**9+7
n,k=map(int,input().split())
ans=(n+1)*( (n+k+1)*(n-k+2)/2 - (n+2)*(2*n+3)/6 )+k*(k-1)*(2*k-1)/6+(n-k+2)
ans=int(ans)%mod
print(ans)
# Judge status: Wrong Answer
a,b =map(int, input().split())

if b < 0:
    if (b - a)%2 == 0:
        print('Positive')
    else:
        print('Negative')
elif b >= 0 and a <= 0:
    print('Zero')
else:
    print('Positive')
# Judge status: Accepted
# https://atcoder.jp/contests/abc144/tasks/abc144_d

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

# 高さ
y = x / (a ** 2)

if y >= ((1 / 2) * b):
    d = math.atan2(2 * (y * a - a * b), a ** 2)

    # dを度数法単位に変換
    d_deg = math.degrees(d)

    print(abs(d_deg))

else:
    d = math.atan2((1 / 2) * (b ** 2), y * a)

    # dを度数法単位に変換
    d_deg = math.degrees(d)

    print(abs(d_deg))
# Judge status: Accepted
from math import *
def gcd2(array):
    temp = array[0]
    for a in array[1:]:
        temp = gcd(temp, a)
    return temp
N, X = map(int, input().split())
D = []
for x in map(int, input().split()):
    D.append(abs(x-X))
print(gcd2(D))
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

for i in range(K):
  print(A + i)
  
for j in reversed(range(K)):
  print(B - j)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 17:30:58 2020

@author: shinba
"""

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

if b-a+2 <= 2*k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
# Judge status: Wrong Answer

s=input()
a = len(s)
for i in range(a):
    print('x')
# Judge status: Accepted
s = input(); 
n = len(s);
ss = "";
sss = "";
ssss = "";

for i in range(1,n+1):
  ss = ss + s[n-i];

mid = int((n+1)/2);

for i in range(mid-1):
  sss = sss + s[mid-2-i]
  
for i in range(mid-1):
  ssss = ssss + s[n - i -1];
  
if ss ==s and sss == s[0:mid-1] and ssss == s[mid:n]:
  print("Yes");
else:
  print("No")
# Judge status: Accepted
from distutils.util import strtobool
s = input()
ss = [int(s[0]) if x % 2 == 0 else int(s[0])^1 for x in range(len(s))]

cnt = 0
for i in range(len(s)):
    if int(s[i]) != ss[i]:
        cnt += 1

print(cnt)
# Judge status: Wrong Answer
n = int(input())
h = list(map(int, input().split()))

zenkai_gen = False
no_flag = False

for i in range(n-1):
  sa = h[i+1] - h[i]
  
  if (zenkai_gen == True) and (sa < 0):
    no_flag = True
  elif sa <= -2:
    no_flag = True
  else:
    pass
    
  if sa <= 0:
    zenkai_gen = True
  else:
    zenkai_gen = False

if no_flag == True:
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
import sys
N = int(input())
H = [int(N) for N in input().split()]
arr = []
cnt = 0

if H == sorted(H):
  print(0)
  sys.exit()

for i in range(0,N-1):
  if H[i]>=H[i+1]:
    cnt=cnt+1
print (cnt-1)
# Judge status: Wrong Answer
import numpy as np
import fractions as fr
N = int(input())
As = np.array(list(map(int, input().split())), int)
def mylcm(a, b):
  return a * b // fr.gcd(a, b)

M = As[0]
for Ai in As[1:]:
  M = mylcm(M, Ai)

B = [M//Ai for Ai in As]

print(sum(B) % (10**9 + 7))
# Judge status: Accepted
a,b,c=map(int,input().split())
a=0.5 * a* b
print("%d"%a)
# Judge status: Accepted
S=list(map(int,input()[::-1]))
lenS=len(S)
cnt = [0]*2019
tmp = 0
for n,i in enumerate(S):
    tmp += i*pow(10,n,2019)
    cnt[tmp%2019]+=1
ans = cnt[0]*(cnt[0]+1)//2
for i in cnt[1:]:
    ans += i*(i-1)//2
print(ans)
# Judge status: Accepted
D,N=map(int,input().split())
print(100**D * N if N !=100 else 100**D*101)
# Judge status: Accepted
S = input()
T = input()

res = 0
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            tmp += 1
    res = max(res, tmp)

print(len(T) - res)
# Judge status: Accepted
q, h, s, d = map(int,input().split())
n = int(input())
v1 = min(q*4, h*2, s* 1)
v2 = min(v1 * 2, d)
print(n // 2 * v2 + n%2 * v1)
#print(v1, v2)
# Judge status: Accepted
N = int(input())

table = [[0]*10 for i in range(10)]

for i in range(1, N+1):
  s = str(i)
  id1 = int(s[0])
  id2 = int(s[-1])
  table[id1][id2] += 1

ans = 0
for i in range(10):
  for j in range(10):
    ans += table[i][j]*table[j][i]

print(ans)
# Judge status: Accepted
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd_n(numbers):
    return reduce(gcd, numbers)


def main():
    N, X, *x = map(int, open(0).read().split())
    x = [abs(X - int(i)) for i in x]
    print(gcd_n(x))
    return


main()
# Judge status: Accepted
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
print(N*(N-1)//2)
# Judge status: Accepted
s = input()
t = input()
for i in range(len(s)):
    s = s[-1] + s[:-1]
    if s == t:
        print("Yes")
        exit()
    else:
        pass
print("No")
# Judge status: Accepted
W,H,N = map(int,input().split())
height = set([])
wigth = set([])
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        for i in range(x):
            wigth.add(i)
    elif a == 2:
        for i in range(x,W):
            wigth.add(i)
    elif a == 3:
        for i in range(y):
            height.add(i)
    else:
        for i in range(y,H):
            height.add(i)
print((H-len(height))*(W-len(wigth)))
# Judge status: Wrong Answer
x, y = list(map(int,input().split()))
ans = y / 2 - x 
if y % 2 != 0:
    print("No")
elif ans <= x or ans == x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
m_num = int(input())
w = list(map(int,input().split()))

temp = []
for i in range(m_num -1 ):
    temp.append(abs(sum(w[0:i+1]) - sum(w[i + 1:])))
print(min(temp))
# Judge status: Accepted
if __name__ == '__main__':
    x = list(input())
    sl = []
    ans = 0
    for i in x:
        if i == "S":
            sl.append(1)
        else:
            if len(sl) != 0:
                ans += sl.pop()

    print(len(x) - ans * 2)
# Judge status: Accepted
# NK=list(map(int,input().split()))
N = int(input())
'''
An = list(map(int,input().split()))
Q = int(input())
Bn = [0] * Q
Cn = [0] * Q
for c in range(Q):
    Bn[c], Cn[c] = map(int, input().split())
'''

alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n",
            "o","p","q","r","s","t","u","v","w","x","y", "z"]

columnName = ""
modulo =0

while N>0:
    modulo = (N-1)%26
    columnName = alphabet[modulo]+columnName
    N = int((N-modulo)/26)


print(columnName)
# Judge status: Wrong Answer
s = raw_input()
print 'Yes' if 'hi' in s else 'No'
# Judge status: Accepted
def main():
    s = int(input())
    e = set([s])
    i = 1
    while True:
        i += 1
        s = f(s)
        if s in e:
            print(i)
            return
        e.add(s)
    
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
X = int(input())

if 400 <= X <= 599:
  print(8)
elif 600 <= X <= 799:
  print(7)
elif 800 <= X <= 999:
  print(6)
elif 1000 <= X <= 1199:
  print(5)
elif 1200 <= X <= 1399:
  print(4)
elif 1400 <= X <= 1599:
  print(3)
elif 1600 <= X <= 1799:
  print(2)
elif 1800 <= X <= 1999:
  print(1)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))

if n==2:
    print(max(l),min(l))
    exit()
maxi = max(l)
med = maxi//2
d = 10**9+1
ans = -1

for i in range(n):
    x = l[i]
    if l[i] > med:
        x = maxi-l[i]
    if med-x < d:
        d = med-x
        ans = l[i]

print(maxi,ans)
# Judge status: Accepted
import math
n = int(input())
m = math.sqrt(n)
x = int(math.floor(m))
print(x**2)
# Judge status: Accepted
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB=sorted(AB,key=lambda x:x[0])
ans=0
for i in range(N):
  if M-AB[i][1]>=0:
    M-=AB[i][1]
    ans+=AB[i][1]*AB[i][0]
  else:
    if M>0:
      ans+=AB[i][0]*M
    break
print(ans)
# Judge status: Accepted
from sys import stdin

data = stdin.readline().rstrip().split()

total = 100 * int(data[0]) + 10 * int(data[1]) + int(data[2])
if total % 4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import sys
readline = sys.stdin.readline

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

print((b // x) - (a - 1)// x)
# Judge status: Accepted
a, b, c = map(int, input().split())
if c-a-b < 0:
    print("No")
else:
    print("Yes" if (c-a-b)**2-4*a*b > 0 else "No")
# Judge status: Accepted
a,b,c=map(int,input().split())
if abs(b-a)>abs(c-a):
    print("B")
else:
    print("A")
# Judge status: Wrong Answer
N=int(input())
ans=1
for i in range(1,N+1):
    ans=(ans*i)%1000000007
print(ans%(10**9+7))
# Judge status: Wrong Answer
a,b = map(int,input().split())
if a > b:
  print(a*(a-1))
elif a == b:
  print(a*b)
elif a < b:
  print(b*(b-1))
# Judge status: Wrong Answer
N = int(input())
cnt = 0
for i in range(1,N+1):
  if N%2:
    cnt += 1
print(cnt/N)
# Judge status: Accepted
a,b = map(int,input().split())

if a > 16/2 or b > 16/2:
  print(":(")
else:
  print("Yay!")