peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = []
for j in range(N):
    b = int(input())
    B.append(b)
A = np.array(A)
B = np.array(B)
boolean_matrix = np.isin(A, B)
if boolean_matrix.sum(axis=1).max() >= 3 or \
   boolean_matrix.sum(axis=0).max() >= 3 or \
   np.diag(boolean_matrix).sum() >= 3 or \
   np.diag(np.fliplr(boolean_matrix)).sum() >= 3:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s = input()
s_len = len(s)
if s_len % 2:
  print("No")
else:
  prev = 0
  count = 0
  for i in range(1, (s_len//2)+1):
    if s[prev:i*2] != "hi":
      print("No")
      break
    else:
      count += 1
      prev = i * 2
  if count == s_len // 2:
    print("Yes")
# Judge status: Accepted
import fractions
N = int(input())
T = []


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


for i in range(N):
    t = int(input())
    T.append(t)


M = T[0]
for i in range(1, N):
    M = lcm(M, T[i])

print(M)
# Judge status: Wrong Answer
n = int(input())
a = input().split()
a.sort()
c = int(a[-1])
if n%2 == 0:
  n1 = n//2 - 1
  for i in range(n1):
    a1 = int(a[n-2-i])
    c += a1*2
else:
  n2 = n//2
  a3 = int(a[n-n2])
  c += a3
  for i in range(n2-1):
    a2 = int(a[n-2-i])
    c += a2*2
print(c)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = sum(list(map(int, input().split())))
c = list(map(int, input().split()))
for i in range(n-1):
  if a[i+1] == a[i] + 1:
    b += c[i]
print(b)
# Judge status: Wrong Answer
S = input()
L = list(S)
Q = int(input())

for i in range(Q):
    a = list(map(str, input().split()))
    if a[0] == '1':
        if not len(L) == 1:
            L.reverse()
    else:	
        if a[1] == '1':
            L.append(a[2])
        else:
            L.insert(0, a[2])
L.reverse()
A = "".join(L)
print(A)
# Judge status: Accepted
h, n = map(int, input().split())
a = list(map(int, input().split()))

if (h - sum(a)) <= 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    S, W = map(int, input().split())
    if W >= S:
        print('unsafe')
    else:
        print('safe')


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, t = map(int, input().split())
r = [list(map(int, input().split())) for _ in range(n)]

sorted_by_cost = sorted(r, key=lambda x: x[0])

for i in range(n):
    if sorted_by_cost[i][1] <= t:
        print(sorted_by_cost[i][0])
        exit()
print('TLE')
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()
s_a = s[0:a]
s_b = s[(a+2):(a+2)+b]
minus = s[a]
if minus == "-" and s_a.isdecimal() and s_b.isdecimal():
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
p=[int(_) for _ in input().split()]
p_sort=sorted(p)
count=0
for i in range(n):
    if p[i]!=p_sort[i]:
        count+=1
if count==0 or count==2:print("YES")
else:print("NO")
# Judge status: Wrong Answer
S = input()
s = list(S)
j= 0
count = 0
if not s[0] == 'A':
    print('WA')
    exit()

for i in s[2:-1]:
    if i == 'C':
        count += 1
        tmp = j
    j += 1
if not count == 1:
    print('WA')
    exit()

del s[0]
del s[tmp-1]

if S.isupper():
    print('WA')
    exit()

print('AC')
# Judge status: Accepted
a, b = list(map(int, input().split()))

cnt = 0
for i in range(a, b+1):
  if str(i) == str(i)[::-1]:
    cnt+=1
print(cnt)
# Judge status: Accepted
# vim: fileencoding=utf-8


def main():
    N = int(input())
    A = int(input())
    x = N % 500
    if A >= x:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
print(min(a+b,b+c,c+a))
# Judge status: Wrong Answer
import re
Sp = input().replace('?','.')
T = input()
flag = 0
for i in range(len(Sp)-len(T)+1):
    if re.match(Sp[i:i+len(T)],T):
        if i != len(Sp)-len(T):
            Sp = Sp[:i]+T+Sp[i+len(T)+1:]
        else:
            Sp = Sp[:i]+T+Sp[i+len(T)+1:]
        flag = 1
        break
if flag == 1:
    print(Sp.replace('.','a'))
else:
    print('UNRESTORABLE')
# Judge status: Accepted
import math
import collections
K = int(input())
S = input()
L = list(S)
if len(L) <= K:
  print(S)
else:
  M = L[:K]
  print(''.join(M)+'...')
# Judge status: Wrong Answer
def comTime(x):
  return (x//10)*10 + 10

def solve(_l):
  s = 0
  l =sorted(_l, key=lambda x: x % 10)
  s += sum(map(comTime,l[1:])) + l[0]
  return s
  
_l = [int(input()) for _ in range(5)]
print(solve(_l))
# Judge status: Wrong Answer
N, K = [int(x) for x in input().split(" ")]

i=1
x=K

while x < N:
  x *= K
  i += 1

print(i)
# Judge status: Accepted
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())

n=N//2*2
ans=min(Q*4*n,H*2*n,S*n,D*n//2)

if N%2==1:
    ans+=min(Q*4,H*2,S)
    
print(ans)
# Judge status: Wrong Answer
s=input()

ans=10**10

for i in range(len(s)):
  try:
    ans=min(ans,abs(int(s[i:i+2])-753))
  except:pass

  try:
    ans=min(ans,abs(int(s[i:i+3])-753))
  except:pass
  
  try:
    ans=min(ans,abs(int(s[i:i+4])-753))
  except:pass
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
if 0<A<10 and 0<B<10:
    print(A*B)
else:
    print(-1)
# Judge status: Accepted
N = int(input())
li = [list(map(int, input().split())) for i in range(N - 1)]

for n in range(N):
  if n == N - 1:
    print(0)
    break
  
  ans = 0
  for index, i in enumerate(li):
    if index < n:
      continue

    if ans < i[1]:
      ans = i[1]
    else:
      if (ans - i[1]) % i[2] != 0:
        ans += i[2] - (ans % i[2])

    ans += i[0]
  print(ans)
# Judge status: Accepted
import fractions
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=lcm_list(map(lambda x: x//2, a))
swt=0

for i in range(n):
  if 0==(b//(a[i]//2))%2:
    swt=1
    break

if 0==swt:
  print(math.ceil((m//b)/2))
else:
  print(0)
# Judge status: Wrong Answer
n = int(input())
print((n // 2) * (n % 2))
# Judge status: Accepted
S=input()
weather=['Sunny','Cloudy','Rainy','Sunny']
print(weather[weather.index(S)+1])
# Judge status: Accepted
n=int(input())
L=list(map(int,input().split()))
sumL=[0 for _ in range(n)]
S=sum(L)
for i in range(n):
    if i==0:
        sumL[i]=L[i]
    else:
        sumL[i]=sumL[i-1]+L[i]
ans=2020202020
tmp1=0
tmp2=0
for i in range(n):
    tmp1=sumL[i]
    tmp2=S-sumL[i]
    ans=min(ans,abs(tmp1-tmp2))
print(ans)
# Judge status: Accepted
S = input()
T = input()

def canMake(left):
    for s, t in zip(S[left:], T):
        if s == '?':
            continue
        if s != t:
            return False
    return True

ans = []
for left in range(len(S) - len(T) + 1):
    if canMake(left):
        Z = S[: left] + T + S[left + len(T):]
        ans.append(Z.replace('?', 'a'))

if len(ans) == 0:
    ans.append('UNRESTORABLE')
ans.sort()
print(ans[0])
# Judge status: Accepted
A, B, C = map(int, input().split())

print(min(B // A, C))
# Judge status: Accepted
a,b=map(int,input().split())
if abs(a-b)<=1:
    print(a+b)
else:
    print(max(a,b)*2-1)
# Judge status: Accepted
N,M=map(int,input().split())
A=[]
for i in range(M):
    P,Y=map(int,input().split())
    A.append([P,Y,i])

ans=[""]*M
A=sorted(A, key=lambda x: x[1])
A=sorted(A,key=lambda x:x[0])

now=A[0][0]
cnt=1
for i in range(M):
    pref=str(A[i][0])
    
    if A[i][0]!=now:
        cnt=1
    year=str(cnt)
    now=A[i][0]
    cnt+=1

    ans[A[i][2]]=pref.zfill(6)+year.zfill(6)

for i in range(M):
    print(ans[i])
# Judge status: Accepted
if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    a[0]-=a[2]*2
    print((a[0]+a[2])//(a[1]+a[2]))
# Judge status: Wrong Answer
b, c = map(int, input().split())
a = b*c
if a%2 == 0: print(int(a/2))
else: print(int((a + 1)/2))
# Judge status: Accepted
N, D = map(int, input().split())
A = []
for i in range(N):
    x = list(map(int, input().split()))
    A.append(x)

def check(x, y):
    s = 0
    for a, b in zip(x, y): s += (a - b) ** 2

    for i in range(0, s+1):
        if i * i == s: return 1
    return 0


ans = 0
for i in range(N):
    for j in range(i+1, N): ans += check(A[i], A[j])
print(ans)
# Judge status: Accepted
n=int(input())
l=[2,1]
if n>1:
    for i in range(2,n+1):
        li=l[i-1]+l[i-2]
        l.append(li)
    print(l[n])
else:
    print(l[n])
# Judge status: Accepted
a, b, k = map(int, input().split())
if k < a:
    print(str(a - k) + " " + str(b))
elif a <= k and k < a + b:
    print(str(0) + " " + str(b - k + a))
elif k >= a + b:
    print(str(0) + " " + str(0))
# Judge status: Accepted
N = input()
A = input().split()

_A = set(A)

if len(A) == len(_A):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
s = input()
mod = 10**9 + 7

S = Counter(s)
a = 1
for v in S.values():
    a *= (1+v) % mod

print(a-1)
# Judge status: Accepted
x=int(input())
if x==0:
  print(1)
else:
  print(0)
# Judge status: Accepted
# -*- coding: utf-8 -*-
x = int(input())

l = [0]*(x+1)
l[0] = 1
for i in range(1,x+1):
    for j in range(100,106):
        if i-j>=0:
            l[i] += l[i-j]

if l[x]>0:
    print(1)
else:
    print(0)
# Judge status: Accepted
a,b,c=map(int,input().split())
print('Yes' if a+b==c or b+c==a or c+a==b else 'No')
# Judge status: Accepted
k, x = map(int,input().split())
lst = [x]
if k>1:
    for i in range(k-1):
        lst.append(x-i-1)
    for i in range(k-1):
        lst.append(x+i+1)

lst.sort()
ans = ''
for i in range(len(lst)):
    num = lst[i]
    ans += str(num)
    ans += ' '

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
a = [int(i) for i in input().split()]

ans = ((n - 1) + (k - 1) - 1) // (k - 1)
print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
D=list(input().split())

while True:
    A=str(N)
    count = 0
    for i in range(len(A)):
        if A[i] in D:
            N+=1
            break
        else:
            count +=1
            if count == len(A):
                print(N)
                exit()
# Judge status: Accepted
N = int(input())
Ans = []
s = 0
for i in range(1, N+1):
    Ans.append(i)
    s += i
    if s >= N:
        break

if s != N:
    Ans.remove(s-N)
for a in Ans:
    print(a)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

assign_plus = 0
minus = 0

for i in range(N):
    assign_plus += max(0, (b[i]-a[i])//2)
    minus += max(0, a[i]-b[i])

if assign_plus >= minus:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m=map(int,input().split())
ans=[0]*n
for _ in range(m):
  a,b=map(int,input().split())
  ans[a-1]+=1
  ans[b-1]+=1
for i in ans:
  print(i)
# Judge status: Accepted
a=input()

b=input()

print("YES" if a==b[::-1] and b==a[::-1] else "NO")
# Judge status: Accepted
N,A,B = map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min(A,N-B+1)+(B-A-1)//2)
# Judge status: Accepted
N = int(input())

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

ans = float("inf")
for i in range(min(A), max(A)+1):
    x = 0
    for j in range(N):
        x += (i-A[j])**2
    ans = min(ans, x)

print(ans)
# Judge status: Accepted
O = list(input())
E = list(input()) + ['']
print(*[O+E for O,E in zip(O,E)], sep='')
# Judge status: Wrong Answer

s = str(input())
S = s.split('/')
if int(S[0]) > 2019:
  print('TBD')
elif int(S[0]) == 2019:
  if int(S[1]) > 4:
    print('TBD')
  elif int(S[1]) == 4:
    if int(S[2]) <= 30:
      print('Heisei')
else:
  print('Heisei')
# Judge status: Accepted
a,b,x=map(int, input().split())

import math
if 0.5*a**2*b<=x:
    print(math.degrees(math.atan((2*a**2*b-2*x)/a**3)))
else:
    print(math.degrees(math.atan((a*b**2)/(x*2))))
# Judge status: Accepted
N,K,S=map(int,input().split())
ans=[S]*K
if len(ans)<N:
    nk=N-K
    if S==1000000000:
        aps=S-1
    else:
        aps=S+1
    for i in range(nk):
        ans.append(aps)
print(' '.join(map(str,ans)))
# Judge status: Accepted
ans = 0

l = [int(input()) for _ in range(5)]
m = [10 - (p % 10) for p in l if p % 10 != 0]
print(sum(l) + sum(sorted(m)[:-1]))
# Judge status: Wrong Answer
x = int(input())
pr = [2]
for i in range(3,10**5,2):
    fr = 0
    for j in pr:
        if i % j == 0:
            fr += 1
            break
    if fr == 0:
        if i >= x:
            print(i)
            break
        pr.append(i)
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

if N % max(H,W) == 0:
  print(N//max(H,W))
else:
  print((N//max(H,W)+1))
# Judge status: Wrong Answer
n=int(input())

def go(s):
   global n
   if len(s)==n:
       print(s)
       return
   last=s[-1]
   for i in range(ord('a'),ord(last)+1):
       go(s+chr(i))
   if last < 'z':
       go(s + chr(ord(last) + 1))

go("a")
# Judge status: Wrong Answer
import itertools

n = int(input())
p = map(int, input().split())
q = map(int, input().split())
d = dict()
for i, v in enumerate(itertools.permutations([x for x in range(1, n+1, 1)]), 1):
  d[str(v)] = i

print(d[str(tuple(p))] - d[str(tuple(q))])
# Judge status: Accepted
d,t,s=map(int,input().split())
if t*s>=d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a_list = list(map(int, input().split()))
total = sum(a_list) 
x_list = [0 for i in range(n-1)]
for i in range(1, n):
	x_list[i-1] = sum(a_list[0:i])
print(x_list)
y_list = [0 for i in range(n-1)]
for i, x in enumerate(x_list):
	y_list[i] = abs(total - x*2)
print(min(y_list))
# Judge status: Wrong Answer
from operator import itemgetter

n = int(input())
xl = []

for i in range(n):
    x, l = map(int, input().split())
    xl.append([x - l, x, x + l])

xl = sorted(xl, key=itemgetter(0))

ans = 0
m = -float("inf")
for left, x, right in xl:
    if left < m:
        ans += 1
    else:
        m = max(m, right)

print(n - ans)
# Judge status: Wrong Answer
X, N = map(int, input().split())
p_list = [str(e) for e in input().split()]

for i in range(N + 1):
    x = X - i
    y = X + i
    if str(x) in p_list == 0:
        print(x)
        break
    elif str(y) in p_list == 0:
        print(y)
        break
# Judge status: Wrong Answer
import sys, math
def main():
    s = list(input().split())
    a = int(s[0])
    b = list(s[1])
    for i in range(len(b)):
        if b[i] == '.':
            b[i] = ''
    b = int(''.join(b))
    print(math.floor(a*b/100))
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
s = input()

if s.count("R") in [0,1,3]:
  print( s.count("R") )
else:
  if s == "RSR":
    print(1)
  else:
    print(2)
# Judge status: Accepted
import math
a, b ,c = map(int, input().split())
if 4*a*b < (c-a-b)**2 and (c-a-b) >0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

bc = b//c
bd = b//d

import math
bcd = c*d//math.gcd(c,d)

ac = (a-1)//c
ad = (a-1)//d
acd = c*d//math.gcd(c,d)

ans = (b-(bc+bd-bcd))-((a-1)-(ac+ad-acd))

print(ans)
# Judge status: Accepted
x, y = map(int, input().split())
res = 'No'
for i in range(x+1):
  k = x-i
  if(i*2 + k*4) == y:
    res = 'Yes'
print(res)
# Judge status: Wrong Answer
n=int(input())
line=list(map(int,input().split()))
border=sum(line)/2

flag=True
for i in line:
  if i >= border:
    flag=False
    break

if flag:
  print('yes')
else:
  print('No')
# Judge status: Wrong Answer
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
ans = [i[0] for i in c.items() if i[1] >= 2]
ans.extend([0,0])
ans.sort(reverse=True)
print(ans[0]*ans[1])
# Judge status: Wrong Answer
import numpy as np

n,m = map(int, input().split())
from_start = np.array([])
to_end = np.array([])

for _ in range(m):
  temp = []
  temp = list(map(int, input().split()))
  if temp[0]==1:
    from_start = np.append(from_start, temp[1])
  elif temp[1]==n:
    to_end = np.append(to_end, temp[0])

  if from_start in to_end:
    print('POSSIBLE')
    break
else:
  print('IMPOSSIBLE')

print(from_start)
print(to_end)
print(from_start in to_end)
# Judge status: Accepted
N,K,S = map(int,input().split())
if S != 10**9:
    ans = [S]*K+[S+1]*(N-K)
else:
    ans = [S]*K+[1]*(N-K)
print(*ans)
# Judge status: Accepted
n=int(input())
l1=[]
l2=[]
for i in range(n):
    a,b=map(int,input().split())
    l1.append(a)
    l2.append(b)
l1.sort()
l2.sort()
if n%2==0:
    low=l1[n//2]+l1[n//2-1]
    high=l2[n//2]+l2[n//2-1]
    print(high-low+1)
else:
    low=l1[n//2]
    high=l2[n//2]
    print(high-low+1)
# Judge status: Wrong Answer
n,m = map(int,input().split())
py = sorted([list(map(int,input().split()))+[i] for i in range(m)])
cnt = 1
ans_list = [['0'*(6 - len(str(m)))+str(py[0][0])+'000001',py[0][2]]]
for i in range(1,m):
  ans = '0'*(6 - len(str(py[i][0])))
  ans += str(py[i][0])
  if py[i-1][0] == py[i][0]:
    cnt += 1
  else:
    cnt = 1
  ans += '0'*(6 - len(str(cnt)))
  ans += str(cnt)
  ans_list.append([ans,py[i][2]])
ans_list = sorted(ans_list,key=lambda x:x[1])
for i in ans_list:
  print(i[0])
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 1:
        ans1 += a[i]
    else:
        ans2 += a[i]
print(max(ans1,ans2))
# Judge status: Accepted
a,b=map(int,input().split())
print(int(a+b/2))
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))
sum_w = sum(w)
ans = 100000

t = 0
for i in range(n):
    t += w[i]
    ans = min(ans, abs(sum_w - 2*t))
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(str, input().split()))
if(len(set(a)) != n):
    print("NO")
else:
    print("YES")
# Judge status: Accepted
k, x = map(int, input().split())
a = []
for i in range(x-(k-1), x+(k-1+1)):
    a.append(i)
for i in range(len(a)):
    print(str(a[i]) + ' ', end = "")
# Judge status: Accepted
s = input().split()
#s[0]文字列の個数、s[1]文字列の長さ

wordCNT = int(s[0])

mylist = []

for num in range(wordCNT):
    mylist.append(input())

mylist.sort()

print(''.join(mylist))
# Judge status: Wrong Answer
A, B = map(int, input().split())

if A > 9 and B > 9:
	print(-1)
else:
	print(A*B)
# Judge status: Accepted
# -*- coding: utf-8 -*-

v_l = ['a', 'e', 'i', 'o', 'u']

if str(input()) in v_l:
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
n=int(input())
S=input()
a=S.count("E")
m=a
for s in S:
    if s=="E":
        a-=1
    m=min(m,a)
    if s=="W":
        a+=1
print(m)
# Judge status: Wrong Answer
from itertools import accumulate

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


bound = list(accumulate(A[::-1]))
bound.reverse()

ans = 1
node = 1
for i in range(n):
    node -= A[i]
    if (i < n and node <= 0) or node < 0:
        print(-1)
        exit(0)
    node = min(node * 2, bound[i+1])
    ans += node

print(ans)
# Judge status: Accepted
def LI():
  return [int(s) for s in input().split()]

L,R = LI()

if R - L > 2019:
  R = L + 2019
  
min_mod = 2020

for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j) % 2019 < min_mod:
      min_mod = (i*j) % 2019
      
print(min_mod)
# Judge status: Wrong Answer
K,S=map(int,input().split())
ans=0
for X in range(K+1):
	for Y in range(X,K+1):
		for Z in range(Y,K+1):
			if X+Y+Z==S:
				if X==0 and Y==0:
					ans=ans+3
				elif X==0:
					ans=ans+3
				else:
					ans=ans+1
print(ans)
# Judge status: Accepted
N=int(input())
X=list(map(int,input().split()))


Q=0
A=[]
for i in range(min(X),max(X)+1):
    for j in X:
        Q+=(j-i)**2
    A.append(Q)
    Q=0
print(min(A))
# Judge status: Wrong Answer
a,b = map(int, input().split())

if a*b % 1==0:
    print('Even')
else:
    print('Odd')
# Judge status: Accepted
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
ans = ''
while n != 0:
    r = n % 2
    if r < 0:
        r += 2
    n = (n - r) // (-2)
    ans += str(r)
if ans == '':
    print(0)
else:
    print(ans[::-1])
# Judge status: Accepted
n,m=map(int,input().split())
max_ = 0
min_ = n+1
for i in range(m):
  a,b=map(int, input().split())
  max_ = max(max_, a)
  min_ = min(min_, b)
#print(max_, min_)
if(min_ < max_):print(0)
else:print(min_-max_+1)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse = True)
print(sum(a[::2]) - sum(a[1::2]))
# Judge status: Wrong Answer
row1 = input()
row2 = input()

if row1[0] == row2[2] and row1[1] == row2[1] and row1[2] == row2[0]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    suma = 0
    dab = 0
    dba = 0
    for i in range(n):
        suma += b[i]-a[i]
        if a[i] < b[i]:
            dab += math.ceil((b[i]-a[i])/2)
        else:
            dba += a[i]-b[i]
    if max(dba, dab) > suma:
        print("No")
    else:
        print("Yes")
resolve()
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))
tmp = [0]*N
tmp_2 = [0]*N
Cnt=0
result = 0
for i in range(N):
  tmp[A[i]-1]+= 1
  tmp_2[A[i]-1] = 1

m = sum(tmp_2)-K
if m>0:
	tmp = sorted(tmp)
	for i in range(N):
		if tmp[i]!=0:
			result += tmp[i]
			Cnt +=1
		if Cnt == m:
			break
    
print(result)
# Judge status: Accepted
s = input()
start = -1
end = -1
for i in range(len(s)):
  if start < 0 and s[i] == 'A':
    start = i
  if s[i] == 'Z':
    end = i
print(end - start + 1)
# Judge status: Wrong Answer
n,r = map(int,input().split())
if n >= 10:
    print(r)
else:
    k = 10 - n
    print(100 * k)
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

ans = A[0]
cnt = 1
for a in A[1:]:
    if cnt + 1 < N:
        ans += a
        cnt += 1

    if cnt+ 1 < N:
        ans += a
        cnt += 1
print(ans)
# Judge status: Wrong Answer
A, B, C, K = map(int, input().split())
score = 0

if K - (A + B) > 0:
    # C を取る
    score = A - (K - (A + B))
else:
    # C を取らない
    score = A

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

white =[0]
black=[0]

for i in range(n):
    white.append(white[i]+int(s[i]=='.'))
    black.append(black[i]+int(s[i]=='#'))

ans = 300000
for i in range(n+1):
    if ans>black[i]+white[n]-white[i]:
        ans=black[i]+white[n]-white[i]

print(ans)
# Judge status: Accepted
N = int(input())
V = list(map(int,input().split()))
V.sort(reverse=True)
while len(V)>=2:
    a = V.pop()
    b = V.pop()
    V.append((a+b)/2)
print(V[0])
# Judge status: Wrong Answer
N=int(input())

a=[0]*N
a=list(map(int,input().split()))
ans=0
for i in range(1,N+5,2):
    if(N-1<i):
        break
    if(a[i]%2==1):
        ans=ans+1
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
l = []
for i in a:
    for j in b:
        if l == b:
            print('Yes')
            exit()
        elif j in i:
            l.append(j)
print('No')
# Judge status: Wrong Answer
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])

ans = 0
cnt = 0
for a, b in AB:
  if cnt+b <= M:
    cnt += b
    ans += a*b
    continue
  ans += a * (M - cnt)
print(ans)
# Judge status: Accepted
import bisect
n = int(input())
*L, = map(int, input().split())
# n = 4
# L = [3, 4, 2, 1]
# n = 7
# L = [218, 786, 704, 233, 645, 728, 389]
L.sort()
c = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        c += bisect.bisect_left(L, L[i]+L[j])-(j+1)
print(c)
# Judge status: Accepted
# 1問目類題3
a,b = map(int, input().split())
print((a+b+1)//2)
# Judge status: Accepted
N, M = map(int, input().split())
print(int((N * (N - 1) + M * (M-1)) / 2))