peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().split()))
a.sort()
ans = a[0]
for i in range(n-1):
    if a[i] == a[i+1]:
        continue
    
    if a[i]%2 == 0:
        if a[i] == 2:
            ans = 2
            break
        continue
    
    if a[i]%2 == 1:
        ans = 1
        break
print(ans)
# Judge status: Accepted
s, k = input(), int(input())

ans = []
a = ord('z') + 1
for i in s:
    if a - ord(i) <= k and i != 'a':
        k -= a - ord(i)
        ans.append(ord('a'))
    else:
        ans.append(ord(i))
ans[-1] += k % 26
if ans[-1] >= a:
    ans[-1] -= 26
print(*map(chr, ans), sep='')
# Judge status: Wrong Answer
n,l = map(int, input().split())
Li = []
i = 0
while i<n:
  li = list(input())
  li.sort()
  Li.append("".join(li))
  i += 1
else:
  Li.sort()
  print("".join(Li))
# Judge status: Wrong Answer
x = input().split()
y = input().split()
z = input().split()
s = 0

for nn in range(2000000):
    if int(x[2]) < 0:
        break
    if int(y[0]) <= int(z[0]) :
        x[2] = int(x[2]) - int(y[0])
        del y[0]  
        y.append(1000000001) 
        s += 1
    else:
        x[2] = int(x[2]) - int(z[0])
        del z[0]
        z.append(1000000001)
        s += 1
print(s-1)
# Judge status: Wrong Answer
def combi(n, r):
    p = 1
    for i in range(1, r+1):
        p = p * (n-i+1) // i
    return p

n, a, b = [int(n) for n in input().split()]
c = 0
m = 0
d = 10**9+7
if n%2==0:
    for i in range(0, n//2):
        print(i)
        c = c + combi(n,i) * 2 
    c += combi(n, n//2)
else:
    for i in range(0, n//2+1):
        c = c + combi(n,i) * 2
m += combi(n, a)
m += combi(n, b)
m += 1
print((c-m)%d)
# Judge status: Accepted
a, b, k = map(int,input().split())
if a + b < k:
    a = 0
    b = 0
elif a < k:
    b = b + a - k
    a = 0
else:
    a = a - k

print(a,b)
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
#from numpy import sign
#import numpy as np
out = float('Inf')
for i in range(0, n - k + 1):
    ans = abs(a[i] - a[i + k - 1]) + abs(min(a[i], a[i + k - 1]))
    out = min(out, ans)
print(out)
# Judge status: Accepted
n = int(input())
alphabet = list("abcdefghijklmnopqrstuvwxyz")
if n <= 26:
    print(alphabet[n-1])
else:
    ans = ""
    while(True):
        q, mod = divmod(n, 26)
        if mod == 0:
            q -= 1
            ans = "z" + ans
        else:
            ans = alphabet[mod-1] + ans
        if q < 1:
            break
        n = q
    print(ans)
# Judge status: Wrong Answer
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
ans = 100
def colsum(s):
    ret = 0
    for i in s:
        ret += int(i)
    return ret

for i in range(n):
    cand = colsum(str(i))+colsum(str(n-i))
    ans = min(cand,ans)
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  elif b == 3:
    print(2)
elif a == 2:
  if b==1:
    print(3)
  elif b==3:
    print(1)
elif a==3:
  if b==1:
    print(2)
  elif b== 2:
    print(1)
# Judge status: Accepted
a,b,c,k=map(int,input().split())
res=0
if k%2==1:res=b-a
else:res=a-b
if(res<10**18):
        print(res)
        exit()
else:
        print("unfair")
        exit()
# Judge status: Accepted

c1=input()
c2=input()

if c1[0]+c1[1]+c1[2] == c2[2]+c2[1]+c2[0]:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from collections import deque

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

A = deque(A)
left = 0
right = 0
while len(A) > 1:
    if (left <= right):
        left += A.popleft()
    else:
        right += A.pop()
if left < right:
    left += A.pop()
else:
    right += A.pop()

print(max(left, right) - min(left, right))
# Judge status: Accepted
A,B,C,X,Y=map(int,input().split())
price=0
if A+B>C+C:
    minXY=min(X,Y)
    price+=minXY*C*2
    X-=minXY
    Y-=minXY
if A>C+C:
    price+=X*2*C
    X=0
else:
    price+=A*X
    X=0
if B>C+C:
    price+=Y*2*C
    Y=0
else:
    price+=B*Y
    Y=0
print(price)
# Judge status: Wrong Answer
a = input()
if a:
    print("X"*len(a))
# Judge status: Accepted
def main():
    ABC = list(map(int, input().split()))
    K = int(input())
    ABC.sort()
    m = ABC.pop()
    mK = m*(2**K)
    ans = sum(ABC) + mK
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n, m = map(int, input().split())
A = list(map(int, input().split()))

B = [[] for _ in range(m)]
for i in range(m):
    B[i] = list(map(int, input().split()))
B.sort(key=lambda x: -x[1])

_A = []
cnt = 0
for i in range(m):
    _A.extend([B[i][1]]*B[i][0])
    cnt += B[i][0]
    if cnt > n:
        break
A += _A
A.sort(reverse=True)
print(sum(A[:n]))
# Judge status: Wrong Answer
H = int(input())

cnt = 1

while H > 2:
  cnt += 1
  H = H/2
  print(H)

H = 2 ** (cnt-1)

print('new:', H)


cnt = H
two = H

while two/2 > 1:
  cnt += two//2
  two = two//2

print(int(cnt+1))
# Judge status: Wrong Answer
n=int(input())
a=[list(map(int,input().split())) for _ in range(n-1)]

def arrive(time,now):
  time=(time+a[now][2]-1)//a[now][2]*a[now][2]+a[now][0]
  if now==n-2:
    return time
  else:
    return arrive(time,now+1)

for i in range(n-1):
  print(arrive(a[i][1],i))
print(0)
# Judge status: Accepted
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        if not a-1 in ans:
            ans.append(a-1)
    elif h[a-1] > h[b-1]:
        if not b-1 in ans:
            ans.append(b-1)
    else:
        if not a-1 in ans:
            ans.append(a-1)
        if not b-1 in ans:
            ans.append(b-1)
print(n-len(ans))
# Judge status: Wrong Answer
I=input()
count = 0
if I[0] == "R":
  if I [1] == "R":
    if I[2] == "R":
      print(3)
    else:
      print(2)
  else:
    print(1)
else:
  if I[1] == "S":
    if I[2] == "S": print(2)
    else:
      print(1)
  else:
    print(0)
# Judge status: Wrong Answer
n=int(input())
a=0
for i in range(1,n+1):
  for j in range(i,n+1):
    if str(i)[0]==str(j)[-1] and str(j)[0]==str(i)[-1]:
      a+=1
print(a)
# Judge status: Accepted
from math import floor, ceil
n = int(input())
f = floor(n/1.08)
c = ceil(n/1.08)
n2 = floor(f*1.08)
n3 = floor(c*1.08)
if n == n2:
    print(f)
elif n == n3:
    print(c)
else:
    print(':(')
# Judge status: Wrong Answer
N, M = map(int, input().split())

store_list = {}
for _ in range(N):
  A, B = map(int, input().split())
  store_list[A] = B
  
store_list = sorted(store_list.items(), key=lambda x:x[0])

ans = 0
for A,B in store_list:
  num = min(M, B)
  ans += A * num
  M -= num
  if M == 0:
    break

print(ans)
# Judge status: Wrong Answer
n = int(input())
ans=0
for i in range(n):
    if i%2==0:
        ans+=1

print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
h=list(map(int,input().split()))
hh=sorted(h)
if(n<=k):
    print(0)
else:
    print(sum(hh[:(n-k)]))
# Judge status: Accepted
from fractions import gcd
N, = map(int, input().split())
X = list(map(int, input().split()))
rs = [0] * N
for i in range(N-1, 0, -1):
    rs[i-1] = gcd(rs[i], X[i])
ls = [0] * N
for i in range(N-1):
    ls[i+1] = gcd(ls[i], X[i])

s = 0
for i in range(N):
    s = max(s, gcd(ls[i], rs[i]))
print(s)
# Judge status: Accepted
k=int(input())

from math import gcd

gcd_sum=[0]*201
ans=0

for i in range(1,k+1):
    for j in range(1,k+1):
        gcd_sum[i]+=gcd(i,j)

for a in range(1,k+1):
    for b in range(1,k+1):
        g=gcd(a,b)
        ans += gcd_sum[g]

print(ans)
# Judge status: Wrong Answer
S = input()
K = int(input())

rest = K
oz = ord('z')
oa = ord('a')
ans = list(S)

for ci in range(len(S)):
    check = oz - ord(S[ci]) + 1
    if rest >= check:
        ans[ci] = 'a'
        rest -= check

if rest >= 0:
    for i in range(rest%26):
        if oz == ord(ans[-1]):
            ans[-1] = 'a'
        else:
            ans[-1] = chr(ord(ans[-1])+1)
    
print("".join(ans))
# Judge status: Wrong Answer
i = list(map(int, input().split()))

A=i[0]
B=i[1]
C=i[2]
D=i[3]

if(C-B>=0 or A-D>=0):
  print(0)
elif(A<D):
  print(B-C)
else:
  print(D-A)
# Judge status: Accepted
import sys

a, b = map(int, sys.stdin.readline().split())

def main():
    if a >= 13: c = b
    elif a >= 6: c = b // 2
    else: c = 0
    print(c)

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
#ABC090

a,b = list(map(int,input().split()))
count = 0
for i in range(a,b+1):
    n = str(i)
    if n[0] == n[4] and n[1] == n[3]:
        count += 1
    
print(count)
# Judge status: Accepted
# ABC167 B

def main():
    a, b, c, k = map(int, input().split())
    total = 0

    if a >= k:
        print(k)
    elif a+b >= k:
        print(a)
    else:
        print(a - (k - a - b))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
a, b, c, d = map(int, input().split())
ans = max(a*c, b*d)
ans = max(ans, a*d)
ans = max(ans, b*d)
print(ans)
# Judge status: Accepted
s=input()
for x in s:
    if s.count(x)>1:
        print("no")
        break
else:
    print("yes")
# Judge status: Wrong Answer
s = input()
if ('S' in s and 'N' in s) or ('S' not in s and 'N' not in s):
    print('Yes')
elif ('E' in s and 'W' in s) or ('E' not in s and 'W' not in s):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
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()))
p=sorted(p)
q=sorted(q)
r=sorted(r)
print(sum(sorted(p[-x:]+q[-y:]+r[-x-y:])[-x-y:]))
# Judge status: Accepted
A, B, T = map(int,input().split())
print( (T//A) * B )
# Judge status: Accepted
from string import ascii_lowercase as alph

def gen_pattern(N, pre="", m=-1):
  for i in range(m+2):
    pat = pre+alph[i]
    if len(pat) == N:
      yield pat
    else:
      yield from gen_pattern(N, pat, max(i,m))

for pattern in gen_pattern(int(input())):
  print(pattern)
# Judge status: Wrong Answer
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    ab[i].append(ab[i][1] - ab[i][0])

from operator import itemgetter
ab.sort(key=itemgetter(2))

cnt = 0
max_ = 0
for i in range(N):
    cnt += ab[i][0]
    max_ = max(max_, ab[i][1])
if cnt > ab[N - 1][1]:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())

if abs(a-c)<=d or abs(a-b)+abs(b-c)<=2*d:
    ans="Yes"
else:
    ans="No"
print(ans)
# Judge status: Wrong Answer
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0]
a_i = getInput()
a_i.sort(reverse=True)
lst = [a_i[i] for i in range(len(a_i)) if i >= N and i < 2*N]
print(sum(lst))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
if A == B:
  print("Yes")
  exit()
if B == C:
  print("Yes")
  exit()
if A == C:
  print("Yes")
  exit()

print("No")
# Judge status: Accepted
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
LCM = A[0]
for i in range(1, N):
    LCM = LCM * A[i] // math.gcd(LCM, A[i])
 
for i in range(N):
  temp = LCM//A[i]
  if temp%2 == 0: #存在しない
    print(0)
    exit()
MIN = LCM//2
nokori = M - MIN
#print(MIN,nokori,LCM)
ans = nokori//LCM + 1
print(ans)
# Judge status: Accepted
a, b, c = input().split()
count = 0
if(a == b): count += 1
if(b == c): count += 1
if(c == a): count += 1

print("Yes" if(count == 1) else "No")
# Judge status: Accepted
n ,k, s = map(int, input().split())
for i in range(k):
    print(s, end=' ')
for i in range(n-k):
    if s == 10**9:
        print(s-1, end=' ')
    else:
        print(s+1, end=' ')
print()
# Judge status: Accepted
import numpy

n,q = [int(x) for x in input().split()]
s = input()

li = [0]*(n+1)
for i in range(n-1):
    if (s[i]=="A" and s[i+1] == "C"):
        li[i+1] = 1
cum = numpy.cumsum(li)
for i in range(q):
    l,r = [int(x) for x in input().split()]
    print(cum[r-1]-cum[l-1])
# Judge status: Accepted
k, x = map(int, input().split())
for i in range(x-k+1, x+k):
    print(i, end = " ")
# Judge status: Accepted
import math

N=int(input())
S=list(map(int,input().split()))
F=S[0]
for i in range(N-1):
    F=math.gcd(F,S[i+1])

print(F)
# Judge status: Accepted
import sys
input = sys.stdin.readline  #文字列入力では注意！

N = int(input())
a,b,c = map(int,input().split())
dp = [[a,b,c]]
for i in range(N-1):
    a,b,c = map(int,input().split())
    A = max(dp[i][1]+a,dp[i][2]+a)
    B = max(dp[i][2]+b,dp[i][0]+b)
    C = max(dp[i][0]+c,dp[i][1]+c)
    dp.append([A,B,C])
print(max(dp[-1]))
# Judge status: Accepted
n,k = map(int,input().split())
li = [int(input()) for _ in range(n)]
li.sort()
ans = 10**10
for i in range(n-k+1):
    ans = min(ans,li[i+k-1]-li[i])
print(ans)
# Judge status: Wrong Answer
import sys

n = int(sys.stdin.readline())
inp = list(map(lambda x: int(x), sys.stdin.readline().split(" ")))


dp = [0]*(n)
dp[1] = abs(inp[1]-inp[0])

for i in range(1,n-1):
    if (abs(inp[i+1]-inp[i-1]) < abs(inp[i+1]-inp[i])):
        dp[i+1] = abs(inp[i+1]-inp[i-1]) + dp[i-1]
    else:
        dp[i+1] = abs(inp[i+1]-inp[i]) + dp[i]

print(dp[-1])
# Judge status: Accepted
N = int(input())
A = {i for i in input().split()}
print("YES" if N==len(A) else "NO")
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x,a,b=MI()
l1=abs(x-a)
l2=abs(x-b)
if l1<l2:
    print("A")
else:
    print("B")
# Judge status: Wrong Answer
X = int(input())

n = 100
cnt = 0
while n < X:
    n += int(n*0.01)
    cnt += 1

print(cnt)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sm = sum(B)
for i in range(N):
    if A[i] > B[i]:
        A[i] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i]
        A[i] = 0

    if A[i+1] > B[i]:
        A[i+1] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i+1]
        A[i+1] = 0

print(sm - sum(B))
# Judge status: Wrong Answer
n=int(input())
a=[]
for i in range(n):
  ai=int(input())
  a.append(ai)
b=[a[n-1]]
ans=1
for i in reversed(range(n-1)):
  if a[i]>=b[-1]:
    b.append(a[i])
    ans=ans+1
  else:
    for j in range(ans):
      if j>a[i]:
        j=a[i]
        break
print(ans)
# Judge status: Accepted
# coding = SJIS
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = min(n, k) * x + max(n - k, 0) * y
print(ans)
# Judge status: Wrong Answer
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    S = list(sys.stdin.readline())

    for s in S:
        n = ord(s) + N
        print(chr(((n - 65)%26)+65), end="")


if __name__ == '__main__':
    main()
# Judge status: Accepted
import itertools
n = int(input())
p = list(map(int, input().strip().split()))
q = list(map(int, input().strip().split()))

#print(p)
#print(q)
r = list(range(1,n+1))
E = list(itertools.permutations(r))
#print(r)
#print(e)
pi = 0
qi = 0
for i in range(0,len(E)):
    if p == list(E[i]):
        pi = i
        #print(pi)
    if q == list(E[i]):
        qi = i
        #print(qi)

print(abs(pi - qi))
# Judge status: Accepted
n,a,b = map(int, input().split())

if (b-a)%2 == 0:
  print((b-a)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)
# Judge status: Wrong Answer
from sys import stdin

a = stdin.readline().rstrip()

count = 0
print (a[0],a[1],a[2])
for b in a:
  if b == "1": count = count + 1

print(count)
# Judge status: Accepted
import sys
s=int(input())

cnt=0

if s==1 or s==2:
  print('4')
  sys.exit()

while s!=4:
  if s%2!=0:
    s=3*s+1
    cnt+=1
  elif s%2==0:
    s=s//2
    cnt+=1

if s==4:
  print(cnt+4)
# Judge status: Wrong Answer
d=int(input())
if d==22:
    print('Christmas Eve Eve Eve')
elif d==23:
    print('Chistmas Eve Eve')
elif d==24:
    print('Christams Eve')
else:
    print('Christams')
# Judge status: Wrong Answer
nyuu = list(map(int, input().split()))
sho1 = nyuu[1] // nyuu[2]
sho2 = nyuu[0] // nyuu[2]
print(sho1 - sho2)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 1e9 + 7
digit = 1
for i in range(60):
  one = 0
  for aa in a:
    if (aa >> i) & 1:
      one += 1
  ans += (one * (n - one) * digit) % mod
  ans %= mod
  digit *= 2

print(int(ans))
# Judge status: Accepted
N = int(input())

C = []; S = []; F = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c); S.append(s); F.append(f)

for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t <= S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        elif t % F[j] !=0:
            t += F[j] - (t%F[j])
        t += C[j]
    print(t)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split())) 

B = sorted(A)
X = B[N//2-1]
Y = B[N//2]

for i in range(N):
    if A[i] <= X:
        print(Y)
    else:
        print(X)
# Judge status: Wrong Answer
A,B,C,K = map(int,input().split())

if A >= K:
    print(K)
elif A + B >= K:
    print(K)
else:
    print(A - (K-(A+B)))
# Judge status: Accepted
N, M = map(int, input().split())
K = [0] * N
A = [0] * N
for i in range(N):
    A[i] = list(map(int, input().split()))
    K[i] = A[i][0]
    A[i].pop(0)

S = set(A[0])
for i in range(1, N):
    S &= set(A[i])
print(len(S))
# Judge status: Accepted
s = input()
t = input()
count=0
for (i,j) in zip(s,t):
  if i != j:
    count+=1
print(count)
# Judge status: Wrong Answer
a, b = map(int, input().split())
ans = -(a*a-b*b)/(2*(b-a))
if type(ans) == int:
    print(ans)

else:
    print('IMPOSSIBLE')
# Judge status: Accepted
n=int(input())
abc=[[-1,-1,-1,-1]]

for i in range(n):
  a,b,c=map(int,input().split())
  abc.append([-1,a,b,c])
dp=[[0 for i in range(4)] for j in range(n+1)]

for i in range(1,n+1):
  for j in range(1,4):
    for k in range(1,4):
      if j==k:
        continue
      dp[i][k]=max(dp[i][k],dp[i-1][j]+abc[i][k])
ans=max(dp[n])
print(ans)
# Judge status: Wrong Answer
a= str(input())
b = a[-1]
if b == 3:
    print("bon")
elif b == 0 or b==1 or b==6 or b ==8:
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','S','Y','X','Z']
N = int(input())
S = list(input())
B = []
for i in range(len(S)):
  for j in range(26):
    if S[i] == A[j]:
      if j+N > 25:
        B.append(A[j+N-25])
      else:
        B.append(A[j+N])
print(''.join(B))
# Judge status: Accepted
input()
t=s=input()
p,q=o="()"
while o in s:s=s.replace(o,"")
print(p*s.count(q)+t+q*s.count(p))
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
print('Yes' if A+(B*2)>=C else 'No')
# Judge status: Accepted
a, b, c = map(int, input().split())

if (b-a) == (c-b):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

h, a = map(int, input().split())

print(h // a)
# Judge status: Accepted
import sys
import math
input = sys.stdin.readline

n = int(input())
print((10**n - 2*(9**n)+8**n)%((10**9)+7))
# Judge status: Accepted
s = input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Accepted
c1=input()
c2=input()
print("YES" if c1[::-1]==c2 else "NO")
# Judge status: Accepted
N=int(input())
ans=''
for i in range(33):
    if N%pow(2,i+1):
        ans+='1'
        N-=pow(-2,i)
    else:
        ans+='0'
print(int(ans[::-1]))
# Judge status: Wrong Answer
from numpy import zeros
 
N = int(input())
A = zeros((10,10))
 
for i in range(1,N+1):
  a = int(str(i)[0])
  b = int(str(i)[-1])
  A[a][b] += 1
 
cnt = 0
for _ in range(1,N+1):
  a = int(str(_)[0])
  b = int(str(_)[-1])
  cnt += A[b][a]
  
print(cnt)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
f=1
for i in range(n):
    if a[i]%2:
        continue
    else:
        if a[i]%3==0 or a[i]%5==0:
            continue
        else:
            f=0
if f:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
N=int(input())
List = list(map(int, input().split()))

Max=0
i=0
while i<N:
    
    if List[i]-Max <= -2:
        print("No")
        quit()
    Max=max(Max,List[i])
    
    i+=1

print("Yes")
# Judge status: Accepted
k,n = map(int,input().split())
A = list(map(int,input().split()))
A.append(A[0]+k)
B = [0 for i in range(n)]
for j in range(n):
    B[j] = A[j+1] - A[j]
#print(A)
#print(B)
B.sort()
B.pop()
#print(B)
ans = sum(B)
print(ans)
# Judge status: Accepted
def main():


	l = list(str(input()))

	ans = 0
	for i in range(len(l)-1):
		if l[i] != l[i+1]:
			ans += 1
	if ans > 0:
		print("Yes")
	else:
		print("No")
	

if __name__ == '__main__':
	main()
# Judge status: Accepted
from math import cos, pi, sqrt

a, b, h, m = map(int, input().split())

th = 2 * pi * (h / 12) + (2 * pi / 12) * (m / 60)
tm = 2 * pi * (m / 60)

answer = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(th - tm))
print(answer)
# Judge status: Wrong Answer
a=int(input())
if a%2==0:
  ans=(a/2)**2
else:
  ans=((a-1)/2)*((a+1)/2)
print(ans)
# Judge status: Wrong Answer
X = int(input())

if X>=30:
  print("Yes")
else:
  print("Np")
# Judge status: Accepted
n=int(input())
d=list(map(int,input().split()))

d_sort = sorted(d)
d_med1 = d_sort[len(d)//2-1]
d_med2 = d_sort[len(d)//2]
print(d_med2-d_med1)
# Judge status: Accepted
import sys
def input():
	return sys.stdin.readline()[:-1]

A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for _ in range(m):
	x, y, c = map(int, input().split())
	ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)
# Judge status: Accepted
def main():
    N = int(input())

    ans = [0] * (10**4 + 1)
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if tmp < 10**4 + 1:
                    ans[tmp] += 1

    for i in range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())

d = dict()

for _ in range(n):
    k = input()
    if d.get(k):
        d[k] += 1
    else:
        d[k] = 1

for kk in ['AC', 'WA', 'TLE', 'RE']:
    if d.get(kk):
        print(kk + ' x ' + str(d.get(kk)))
    else:
        print(kk + ' x 0')
# Judge status: Accepted
#!/usr/bin/env python3
n, k = map(int, input().split())
print(0--~-n//~-k)
# Judge status: Accepted
from heapq import heappush,heappop

n,m=[int(x) for x in input().rstrip().split()]
ab=[[] for i in range(10**5)]

for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  ab[a-1].append(-b)

ans=0
time=0
l=[]
for i in range(m):
  for b in ab[i]:
    heappush(l,b)
  if l:
    ans-=heappop(l)

print(ans)
# Judge status: Accepted
def main():
    n, m = map(int, input().split())
    left = 1
    right = n
    is_shift = False
    ans = []
    while left < right:
        if right - left <= n // 2 and not is_shift and n % 2 == 0:
            left += 1
            is_shift = True
        ans.append([left, right])
        left += 1
        right -= 1

    for l in range(m):
        print(*ans[l])


if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline #inputに置き換え可能

n = int(input())
txy = [[0,0,0]] + [list(map(int,input().split())) for i in range(n)]

flg = True
for i in range(1, n+1):
    dt = txy[i][0] - txy[i-1][0] 
    dx = abs(txy[i][1] - txy[i-1][1])
    dy = abs(txy[i][2] - txy[i-1][2])
    dxdy = dx + dy
    if dt % 2 != dxdy % 2 or dt < dxdy:
        flg = False
        break
print('Yes') if flg else print('No')