peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import collections

n = int(input())

ss = []
for _ in range(n):
	ss.append(input())

c = collections.Counter(ss)

mc = c.most_common()
max_cnt = max([x[1] for x in mc])
ans = [x[0] for x in mc if x[1] == max_cnt]

ans.sort()
for x in ans:
	print(x)
# Judge status: Wrong Answer
w, a, b = map(int, input().split())

print(max(0, b-(w+a)))
# Judge status: Wrong Answer
X = int(input())

a = 1
while a * (a + 1) // 2 <= X:
  a += 1

if abs(a * (a + 1) // 2 - X) < abs((a - 1) * a // 2 - X):
  ans = a + X - a * (a + 1) // 2
else:
  a -= 1
  ans = a + X - a * (a + 1) // 2
print(ans)
# Judge status: Accepted
# 753
X =int(input())
if X in [7,5,3]:
    ans ="YES"
else:
    ans ="NO"
print(ans)
# Judge status: Accepted
s = str(input())
s_fix = s.replace('2017', '2018')
print(s_fix)
# Judge status: Accepted
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    s=sum(A)
    if N>=s:
        print(N-s)
    else:
        print(-1)

resolve()
# Judge status: Accepted
SA=input()
SB=input()
SC=input()
s=["a","b","c"]
S=[SA,SB,SC]
num=[len(SA)-1,len(SB),len(SC)]
X=["A","B","C"]
k=0
for t in range(500):
    if num[k]==-1:
        print(X[k])
        exit()
    for j in range(3):
        if S[k][-num[k]-1]==s[j]:
            k=j
            num[k]-=1
            break
# Judge status: Accepted
n,m = [int(ch) for ch in input().split()]
heights = [int(ch) for ch in input().split()]
graphs = []
for i in range(n):
    graphs.append([])
for i in range(m):
    roadInfo = [int(ch) for ch in input().split()]
    start = roadInfo[0]-1
    end = roadInfo[1]-1
    graphs[start].append(end)
    graphs[end].append(start)
res = []
for i in range(len(graphs)):
    isGood = True
    for v in graphs[i]:
        if heights[i] <= heights[v]:
            isGood = False
            break
    if isGood:
        res.append(i+1)
print(len(res))
# Judge status: Accepted
X, N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

for i in range(102):
    if p.count(X-i) == 0:
        print(X-i)
        break
    if p.count(X+i) == 0:
        print(X+i)
        break
# Judge status: Accepted
import sys
input = sys.stdin.readline
n=int(input())
s=[list(map(int, input().split())) for _ in range(n)]
a=0
for i in range(n-1):
    for j in range(i+1,n):
        a+=((s[i][0]-s[j][0])**2+((s[i][1]-s[j][1])**2))**(1/2)
print(2*a/n)
# Judge status: Wrong Answer
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
ans = 0

for i in range(1, N+1):
    if i < N-1:
        ans += X
    else:
        ans += Y
print(ans)
# Judge status: Wrong Answer
import sys
input()
ans,d=0,{}
for ln in sys.stdin:
    s=''.join(sorted(ln))
    ans+=d.setdefault(s,0)
    d[s]+=1
print(ans)
# Judge status: Wrong Answer
S = input()
s = len(S)

for i in range(1,s//2):
  a = s - i*2
  test = S[0:a]
  n = 0
  while True:
    if n == a/2:
      print(len(test))
      break
    elif test[n] != test[n + a//2]:
      break
    else:
      n += 1
# Judge status: Accepted
n,m=map(int,input().split())
A=list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
bc = sorted(bc,key=lambda x:-x[1])

sub = []
for i in range(m):
   sub += [bc[i][1]] * bc[i][0]
   if len(sub) > n:
       break

A += sub

print(sum(sorted(A,reverse=True)[:n]))
# Judge status: Wrong Answer
x = input()
x = '000'+x
z = x[:-2]
y = x[-2:]
s = 0
z = int(z)
y = int(y)
L = []
y =y//5
if z>=20 or z>=y:
    print(1)
    exit()
print(0)
# Judge status: Accepted
a,b,c = list(map(int, input().strip().split()))
f=0
if a%2==1 or b%2==1 or c%2==1:
    print(f)
elif a==b and b==c:
    f=-1
    print(f)
else:
    while a%2==0 and b%2==0 and c%2==0:
        A=a
        B=b
        C=c
        a=B//2+C//2
        b=A//2+C//2
        c=A//2+B//2
        f=f+1
    else:
        print(f)
# Judge status: Accepted
import math
n=int(input())
ans_rev=""
if n==0:
    print(0)
else:
    while n!=1:
        ans_rev+=str(abs(n%(-2)))
        n=math.ceil(n/(-2))
    ans_rev+="1"
    ans=ans_rev[::-1]
    print(ans)
# Judge status: Wrong Answer
s = [int(s) for s in input().split()]

if all([n % 2 == 0 for n in s]):
    print(0)
else:
    s[s.index(max(s))] = 1
    print(s[0] * s[1] * s[2])
# Judge status: Accepted
a = int(input())
s = input()
if(len(s) > a):
    print(s[:a] +"...")
else:
    print(s)
# Judge status: Wrong Answer
N=int(input())
A=[int(input())]
for i in range(N-1):
  a=int(input())
  if a<=min(A):
    A.append(a)
  elif a>=max(A):
    A[0]=a
  else:
    for j,ls in enumerate(A[::-1]):
      if ls>=a:
        A[-j]=a
        break
print(len(A))
# Judge status: Wrong Answer
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
nums = [i for i in range(1,n+1)]
a = [0,0]
now = 0
for k,i in enumerate(itertools.permutations(nums)):
  if i == p or i == q:
    a[now] = k
    now += 1
print(abs(a[1]-a[0]))
# Judge status: Accepted
n = int(input())
amari = n % 1000
if amari == 0:
    print(0)
else:
    print(1000 - n % 1000)
# Judge status: Accepted
S = input()
print("TBD" if S[6]>="5" or S[5]>="1" else "Heisei")
# Judge status: Accepted
a,b,c=map(int,input().split())
rem=min(a-b,c)
print(c-rem)
# Judge status: Accepted
x = int(input())
kosuu, amari = x // 100, x % 100
ans = 0

for i in range(kosuu):
    amari -= 5
    if amari <= 0:
        ans = 1
        break

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys

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


def main():
    C = readline().rstrip().decode()
    print(chr(ord(C) + 1))


if __name__ == '__main__':
    main()
# Judge status: Accepted
s=str(input())
t=str(input())

l="abcdefghijklmnopqrstuvwxyz"

ss=''.join(sorted(s))
st=''.join(sorted(t))
str=''.join(sorted(t,reverse=True))

if l.index(str[0])>l.index(ss[0]):
  ans="Yes"
elif len(t)>len(s) and ss in st:
  ans="Yes"
else:
  ans="No"
  
print(ans)
# Judge status: Wrong Answer
n=int(input())
l=[]
for _ in range(n):
    a=int(input())
    l.append(a)
count=1
result=l[0]
f=-1
while n>0:
    result=l[result-1]
    if result==l[1]:
        f=count
        break
    count+=1
    n-=1
print(f)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
state = 1
count = 1
tmp = a[0]
for i in a:
  if i == tmp:
    tmp = i
  elif i > tmp:
    state = 1
    break
  else:
    state = 0
    break
tmp = a[0]
for i in a:
  if i == tmp:
    pass
  elif i > tmp:
    if state == 1:
      pass
    else:
      state = 0
      count += 1
  else:
    if state == 0:
      pass
    else:
      state = 1
      count += 1
  tmp = i
print(count)
# Judge status: Accepted
import math
import collections
import sys

#input = sys.stdin.readline
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)]

a,b,c=MI()
print(max(10*a+b+c,a+10*b+c,10*c+a+b))
# Judge status: Accepted
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    A.append(K+A[0])
    ans = K

    for i in range(0, N):
        tmp = K - (A[i+1] - A[i])
        if tmp < ans:
            ans = tmp
    print(ans)







    return 0


if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
m=0
for i in range(1,N-1):
  for j in range(2,N-2):
    if (i**j)<=N:
      if (i**j)>m:
        m=i**j
    else:
      break
print(max(m,1))
# Judge status: Accepted
s = input()

cnt = 0
for i in range(len(s) - 1):
    for j in range(i + 1, len(s)):
        if s[i] == s[j]:
            cnt += 1

if cnt == 2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            count+=1
print(count)
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind + 1)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

if n > k:
    cnt = k - 1
for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)
# Judge status: Accepted
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()


def solve():
    c = Counter()
    for a in A:
        c[a - 1] += 1
        c[a] += 1
        c[a + 1] += 1

    x, k = c.most_common()[0]

    return k


print(solve())
# Judge status: Accepted
import itertools

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

if N==1:
    if A==B:
        print(1)
        exit()
    else:
        print(0)
        exit()

if A > B:
    print(0)
    exit()

min = A*(N-1)+B
max = A+B*(N-1)

print(max-min+1)
# Judge status: Wrong Answer
N,L = map(int,input().split())
taste = []
tmp = []
for i in range(1,N+1):
	tmp.append(abs(L + i -1))
	taste.append((L + i -1))
num = tmp.index(min(tmp)) 
taste[num] = 0
print(taste)
print(sum(taste))
# Judge status: Accepted
if __name__ == '__main__':
    n = int(input())
    if n % 2 != 0:
        print(0)
        exit(0)

    ans = 0
    div = 10
    while n // div:
        ans += n // div
        div *= 5
    print(ans)
# Judge status: Wrong Answer
N = int(input())

print((10 ** N - 2 * 9 ** N + 8 ** N % (10 ** 9 + 7)))
# Judge status: Accepted
import math
n,p=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(n):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=0
t=1
while t<=odd:
  res=math.factorial(odd)//(math.factorial(t)*math.factorial(odd-t))
  t+=2
  if even!=0:
    w=0
    while w<=even:
      res1=math.factorial(even)//(math.factorial(w)*math.factorial(even-w))
      w+=1
      ans+=res*res1
  else:
    ans+=res
if p==1:
  print(ans)
else:
  print(2**n-ans)
# Judge status: Accepted
N = input().split()
K = int(N[0])
X = int(N[1])
for i in range(X-K+1,X+K):
  print(i,end=' ')
# Judge status: Wrong Answer
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = [-1] * n

for s, c in sc:
    t = s - 1
    if ans[t] == -1:
        ans[t] = c
    elif ans[t] != c:
        print(-1)
        exit()

if ans[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
    exit()
ans[0] = str(max(1, ans[0]))
for i in range(1, n):
    ans[i] = str(max(0, ans[i]))

print(''.join(ans))
# Judge status: Accepted

def main():
    a,b,x = map(int,input().split())
    answer = "YES" if a <= x <= (a+b) else "NO"
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, Y = map(int, input().split())
ans = [-1, -1, -1]

for i in range(N + 1):
    for j in range(N - i, -1, -1):
        if 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            ans[0] = i
            ans[1] = j
            ans[2] = (N - i - j)

print(*ans)
# Judge status: Accepted
a,b,c=map(int,input().split());print(c//a*b)
# Judge status: Wrong Answer
S = input()
sun = "Sunny"
clo = "Cloudy"
rai = "Rainy"
if S == sun:
    print(clo)
    print("In Takahashi's town, a sunny day is followed by a cloudy day.")
elif S == rai:
    print(sun)
# Judge status: Wrong Answer
N,H=map(int,input().split())
B=[]
index=-1
tmp=-1
for i in range(N):
  a,b=map(int,input().split())
  B.append(b)
  if a>tmp:
    index=i
    tmp=a
a_,b_=tmp,B[index]
cnt=0
B=sorted(B,reverse=True)
while H>0 and len(B)!=0:
  b=B.pop(0)
  if b<a_:
    break
  H-=b
  cnt+=1
v=H//a_
if H%a_==0:
  cnt+=v
else:
  cnt+=(v+1)
print(cnt)
# Judge status: Wrong Answer
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
for k in range(k):
    d = []
    for i in range(n):
         d.extend(list(range(int(i - a[i]), int(i + a[i] + 1))))
    print(d)
    c = []
    c = Counter(d)
    print(c)
    for j in c.keys():
        if j >= 0 and j < len(a):
            a[j] = c[j]

L=[str(t) for t in a]
L=" ".join(L)
print(L)
# Judge status: Accepted
def gcd(x, y):
  if y != 0:
    return gcd(y, x % y)
  else:
    return x

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



def resolve():
  n = int(input())
  t = []
  for i in range(n):
    t.append(int(input()))
  ans = 1
  for x in t:
    ans = lcm(x, ans)

  print(ans)
  return

if __name__ == "__main__":
  resolve()
# Judge status: Wrong Answer
n,x,t = map(int,input().split())

print((n//t+1)*t)
# Judge status: Wrong Answer
h,m,h2,m2,k=map(int,input().split())
print(h2*60+m2-h*60+m-k)
# Judge status: Accepted
#(0)入力環境
import bisect#listをsortしたまま要素を挿入できる
n = int(input())
l = sorted(list(map(int,input().split())))

#(1)考察
#aとbの二重ループのなかで最後の一つは二分探索で高速に
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += bisect.bisect_left(l,l[i] + l[j]) - (j + 1)
        

print(ans)
# Judge status: Accepted
H,N=map(int,input().split(' '))
Magics = [list(map(int,input().split(' '))) for i in range(N)]
dp=[float('inf')]*(H+1)
dp[H]=0
for i in range(H,-1,-1):
    for a,b in Magics:
        if 0<=i-a<=H:
            dp[i-a]=min(dp[i-a],dp[i]+b)
        else:
            dp[0]=min(dp[0],dp[i]+b)
print(dp[0])
# Judge status: Accepted
import sys
in1 = sys.stdin.readlines()

#in1 = ['10 15']

K, S = map(int, in1[0].split())

RC = 0
for idx1 in range(K + 1):
    for idx2 in range(K + 1):
        if 0 <= S - idx1 - idx2 <= K:
            RC += 1

print(RC)
# Judge status: Accepted
import fractions
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)
# Judge status: Accepted
def f(): w=input(); return sorted(w.count(c) for c in set(w))
s,t=f(),f()
print('YNeos'[s!=t::2])
# Judge status: Accepted
N, M = map(int, input().split())

if N == 1 and M == 1:
  print(1)
elif min(N,M) == 1:
  print(max(N,M)-2)
else:
  print((N-2)*(M-2))
# Judge status: Accepted
i3=lambda : map(int,input().split())

N,K=i3()
*D,=i3()

D=set(D)

for i in range(N,10**5):
    ans=1
    for s in str(i):
        if int(s) in D:
            ans=0
            break
    if ans : break
print(i)
# Judge status: Accepted
#ABC066-C
from collections import deque
n = int(input())
a = list(map(int,input().split()))

d = deque()

for i in range(n):
    if i % 2 == 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

result = list(d)
if n % 2 == 1:
    result = reversed(list(d))
print(*result)
# Judge status: Wrong Answer
from collections import Counter

a = list(input())
print(a.count('R'))
# Judge status: Accepted
import math

A, B, H, M = map(int, input().split(" "))

degree_h = ((H + M / 60) * 30) % 360
degree_m = ((H * 60 + M) * 6) % 360

deg = (
    min(abs(degree_h - degree_m), 360 - abs(degree_h - degree_m)) * 2 * (math.pi / 360)
)

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(deg)))
# Judge status: Accepted
N = int(input())
fizz = N // 3
buzz = N // 5
fzbz = N // 15
ans = (N+1)*N // 2
ans -= buzz * (5 * buzz + 5) // 2
ans -= fizz * (3 * fizz + 3) // 2
ans += fzbz * (15 * fzbz + 15) // 2
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
S = []
for i in s:
    S.append(i
    )

ans = 0
for i in range(1, n):
    x = S[0:i]
    y = S[i:n]
    a = 0
    for j in range(len(x)):
        if x[j] in y:
            a += 1
            while x[j] in y:
                y[y.index(x[j])] = 0
    ans = max(ans, a)
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
d = list(map(int, input().split()))
usable = []
non_zero_usable = []
for i in range(10):
  if i not in d:
    usable.append(i)
    if i != 0:
      non_zero_usable.append(i)

su = sorted(usable)
zu = sorted(non_zero_usable)
ans = ''
for i, v in enumerate(list(str(n))):
  v = int(v)
  if i == 0:
    for z in zu:
      if v <= z:
        ans += str(z)
        break
    continue
  
  for s in su:
    if v <= s:
      ans += str(s)
      break
      
print(ans)
# Judge status: Accepted
N=int(input())
XY=[tuple(map(int, input().split())) for _ in range(N)]

from math import sqrt
def dist(a,b):
    return sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)
from itertools import permutations
a=b=0
for p in permutations(range(N)):
    b+=1
    for i in range(N-1):
        a+=dist(XY[p[i]], XY[p[i+1]])
print(a/b)
# Judge status: Accepted
N=int(input())
H=[int(x) for x in input().split()]

max_h=0
ans='Yes'

for n in range(N):
    if H[n] > max_h:
        max_h = H[n]
        
    if H[n] < max_h-1:
        ans='No'
        
print(ans)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

d = B - A

if (d % 2 == 0):
    ans = d // 2
else:
    left = B - 1
    right = N - A
    mini_1 = min(left, right)
    
    kado = min(A - 1, N - B)
    mini_2 = max(0, (d - kado - 1)) // 2 + kado + 1
    
    ans = min(mini_1, mini_2)

print(ans)
# Judge status: Accepted
n=int(input())
l=[*map(int,input().split())]
a=1000
c=0
for i in range(n-1):
  if l[i]>l[i+1]:
    a+=c*l[i]
    c=0
  if l[i]<l[i+1]:
    while a>=l[i]:
      t=a//l[i]
      a-=t*l[i]
      c+=t
print(a+c*l[n-1])
# Judge status: Wrong Answer
r = input()
n = list(r)
x = int(n[0])*100 + int(n[0])*10 + int(n[0])

if x <= int(r):
  print( ((int(n[0])+1)*100 + (int(n[0])+1)*10 + int(n[0])+1))
else:
  print(x)
# Judge status: Wrong Answer
n,m,k=map(int,input().split())
a=sorted(map(int,input().split()))
b=sorted(map(int,input().split()))[::-1]
x=sum(a)
z=n
ans=0
while a and x>k:
  c=a.pop()
  x-=c
  z-=1
  if x>k:continue
  ans=max(ans,z)
while a:
  while b and b[-1]+x<=k:
    c=b.pop()
    x+=c
    z+=1
  ans=max(ans,z)
  c=a.pop()
  x-=c
  z-=1
  if x>k:continue
  ans=max(ans,z)
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
H = list(map(int, input().split()))
if N <= K:
  print(0)
else:
  print(sum(H[:N-K]))
# Judge status: Accepted
n,y=map(int,input().split())
y //= 1000
for i in range(n+1):
    p,q = divmod(y-n-i,4)
    if q == 0 and i <= p-i <= n:
        print(i,p-2*i, n-p+i)
        exit()
print("-1 "*3)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
print(a)
# Judge status: Wrong Answer
N = int(input())

if N < 105:
  ans = 0
elif N == 105:
  ans = 1
else:
  ans = 1
  for n in range(106, N+1):
    count = 0
    for i in range(1, int(n**(1/2))+1):
      if n % i == 0:
      	count += 1
    if count == 8:
      ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
ans = 0
sum = 0
for _ in range(n):
  a = int(input())
  if a == 0:
    ans += sum//2
    sum = 0
    continue
  sum += a
ans += sum // 2
print(ans)
# Judge status: Accepted
n = list(input())
n[3] = "8"
print("".join(n))
# Judge status: Accepted
X = int(input())
val = 1
for b in range(1, int(X**0.5)+1):
    for p in range(2,X):
        if b**p > X:
            break
        else:
            val = max(val, b**p)
print(val)
# Judge status: Accepted
N,K = map(int, input().split())
H = [int(a) for a in input().split()]

ans = 0
H.sort(reverse=True)
for i in range(N):
    if i < K:
        continue
    else:
        ans += H[i]

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
an = list(map(int, input().split()))
mini = min(an)
need = 0
for a in an:
    if a != mini:
        need += 1
print(-(-need//(k-1)))
# Judge status: Accepted
# -*- coding: utf-8 -*-
from string import ascii_lowercase

c = input()

i = 0
while i<100:
    if ascii_lowercase[i]==c:
        print(ascii_lowercase[i+1])
        exit()
    i += 1
# Judge status: Accepted
n,m=[int(_)for _ in input().split()]

ab=[[int(_) for _ in input().split()]for i in range(n)]
cd=[[int(_) for _ in input().split()]for i in range(m)]


def dist(p1,p2):
  return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

for i in range(n):
  d=1000000000
  ans=0
  for j in range(m):
    if d>dist(ab[i],cd[j]):
      ans=j+1
      d=dist(ab[i],cd[j])
  print(ans)
# Judge status: Accepted
N,A,B=map(int,input().split())
ans=(A+B*(N-1))-(A*(N-1)+B)+1
print(ans if ans>=0 else 0)
# Judge status: Accepted
N, K = map(int, input().split())
S = input()
print(S[:K-1]+S[K-1].lower()+S[K:])
# Judge status: Accepted
import math

a, b, x = map(int, input().split())
tan = (a*b*b)/(2*x) if a*a*b/2 > x else (2*a*a*b-2*x)/(a*a*a)
print(math.degrees(math.atan(tan)))
# Judge status: Accepted
n = int(input())
A = [int(x) for x in input().split()]
colored = [False] * 8
cnt = 0
super= 0
for a in A:
    if 3200 <= a:
        super += 1
        continue
    rank = a // 400
    if not colored[rank]:
        colored[rank] = True
        cnt += 1
mn = 1 if cnt == 0 and super != 0 else cnt
mx = cnt + super
print(mn, mx)
# Judge status: Wrong Answer
import math
H, W = map(int, input().split())
if H % 2 == 1 and W % 2 == 1:
    print(math.ceil(H*W/2))
else:
    print(int(H*W/2))
# Judge status: Accepted
S = input()
if S == "AAA" or S == "BBB":
	print("No")
else:
	print("Yes")
# Judge status: Accepted
s = input()
a = [int(c) for c in s]

if sum(a)%9==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def readinput():
    n=int(input())
    return n

def main(n):
    if 1<=n and n<=9:
        return n
    elif 10<=n and n<=99:
        return 9
    elif 100<=n and n<=999:
        return 9+(n-99)
    elif 1000<=n and n<=9999:
        return 9+900
    elif 10000<=n and n<=99999:
        return 9+900+(n-9999)
    elif 100000==n:
        return 9+900+90000
    return 0

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)
# Judge status: Accepted
h,w = map(int, input().split())
squares = h * w
if h == 1 or w == 1:
  print(1)
elif squares % 2 == 0:
  print(int(squares / 2))
else:
  print(int((squares - 1) / 2 + 1))
# Judge status: Accepted
import sys
import collections

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    s = [input().rstrip('\n') for _ in range(n)]
    m = int(input())
    t = [input().rstrip('\n') for _ in range(m)]
    cs = collections.Counter(s)
    ct = collections.Counter(t)
    for k,v in cs.items():
        ans = max(v-ct[k], ans)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
if b>a*c:
    print(c)
else:
    print(b//a)
# Judge status: Accepted
s=list(input())
A=s.index("A")
S=s[::-1]
S=len(S)-1-S.index("Z")
print(S-A+1)
# Judge status: Wrong Answer
n = int(input())
fn = [0] * (10**5)

def f(x, y, z):
    return x**2 + y**2 + z**2 + x*y + y*z+ z*x 
for x in range(1, 32):
    for y in range(1, 32):
        for z in range(1, 32):
            idx = f(x, y, z)
            fn[idx] += 1

for i in range(1, n+1):
    print(fn[i])
# Judge status: Wrong Answer
n=int(input())
a=int(input())
b=int(input())
c=int(input())

print(n*b+min(0,n-a)*c)
# Judge status: Accepted
s = input()
x = ''.join(list(reversed(s)))
n = len(s)
ans = 'No'
if s==x:
    a = s[:(n-1)//2]
    x = ''.join(list(reversed(a)))
    if a==x:
        b = s[(n+3)//2-1:]
        x = ''.join(list(reversed(b)))
        if b==x:
            ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
s = int (input ())
l = []
a = 0
while True:
  a += 1
  if s%2 == 0:
    s = round(s/2)
  else:
    s = s*3+1
  if l.count (s) != 0:
    print (a+1)
    break
  l.append (s)
# Judge status: Accepted
n,m=map(int,input().split())
H=list(map(int,input().split()))


visited=[1]*n
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if H[a]>H[b]:
        visited[b]=0
    elif H[b]>H[a]:
        visited[a]=0
    else:
        visited[a]=visited[b]=0   

print(sum(visited))
# Judge status: Wrong Answer
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

A.sort()
ans = []
for i in A:
	x -= i
	#print(ans, x)
	if x <= 0:
		break
	ans.append(i)

if x > 0:
	print(len(ans)-1)
else:
	print(len(ans))
# Judge status: Accepted
s, w = list(map(int, input().rstrip().split()))

print('unsafe' if w >= s else 'safe')