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


def LI():
    return list(map(int, input().split()))


N = int(input())
A = LI()
B = Counter(A)
A = copy.copy(B)

for k, v in B.items():

    if k-1 in A:
        A[k-1] += v
    else:
        A[k-1] = v
    if k+1 in A:
        A[k+1] += v
    else:
        A[k+1] += v

print(max(A.values()))
# Judge status: Wrong Answer
N,K = map(int, input().split())

A = list()
for _ in range(K):
	d = int(input())
	A.append(list(map(int, input().split())))

sunuke = [i for i in range(1,N+1)]

for a in A:
	for s in sunuke:
		if s in a:
			sunuke.remove(s)

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

M=N//7

flag=0
for i in range(M+1):
  #print(N-i*7)
  if (N-i*7)%4==0:
    flag=1
    break
else:
  if N==4 or N==7:
    flag=1

print('Yes' if flag==1 else 'No')
# Judge status: Wrong Answer
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
for i in range(1,n):
    ls[0] = (ls[0]+ls[i])/2
print(int(ls[0]))
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
cnt=0
for i in range(1,n+1):
  x=(i//1000)+((i%1000)//100)+((i%100)//10)+(i%10)
  if a<=x and b>=x:
    cnt+=1
print(cnt)
# Judge status: Accepted
n,m = map(int,input().split())

llist = []
rlist = []
for i in range(m):
    l,r = map(int,input().split())
    llist += [l]
    rlist += [r]

print(max(0,min(rlist)-max(llist)+1))
# Judge status: Accepted
#!/usr/bin/env python3
from math import degrees, atan

a, b, x = map(int, input().split())
bot = a * a * b
if x * 2 > bot:
    print(degrees(atan((bot - x) * 2 / a**3)))
else:
    print(degrees(atan(b**2 * a / (2 * x))))
# Judge status: Accepted
n, m = map(int, input().split())
left = 1
right = n
for _ in range(m):
  l, r = map(int, input().split())
  if l > left:
    left = l
  if r < right:
    right = r
print(max(0, right - left + 1))
# Judge status: Accepted
n = int(input())
d = list(map(int, input().split()))
sort_d = sorted(d)
ans = sort_d[n//2] - sort_d[n//2 - 1]
print(ans)
# Judge status: Accepted
ss = input()
t = input()

ls = len(ss)
lt = len(t)

before = []
after = []

for i in range(ls-lt+1):
    for j in range(lt):
        if ss[i+j]!="?":
            if ss[i+j]!=t[j]:
                break
    else:
        before += [ss[:i]+t+ss[i+lt:]]
  
for k in before:
    after += [k.replace("?","a")]

if after:
    after = sorted(after)
    print(after[0])
else:
    print("UNRESTORABLE")
# Judge status: Accepted
a, b = list(map(int, input().split()))
x = b - a
t = 0
for i in range(x + 1):
    t += i
print(t - b)
# Judge status: Accepted
N = int(input())
ans = 0
cnt = 0
for _ in range(N):
    a = int(input())
    if a==0:
        ans += cnt//2
        cnt = 0
    else:
        cnt += a
ans += cnt//2
print(ans)
# Judge status: Accepted
x,a,b = map(int,input().split())

disa = abs(x-a)
disb = abs(x-b)

print("A" if disa < disb else "B")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if b-a==c-a:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def main():
    n,m=map(int,input().split())
    ans=0
    for i in range(1,min(int(m**0.5//1)+2,m//n+1)):
        if m%i==0:
            if i>=n:
              ans=max(m//i,ans)
            else:
              ans=max(i,ans)
    print(ans)     
if __name__=='__main__':
    main()
# Judge status: Accepted
N = int(input())
T,A = map(int,input().split())

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

diff=999
I=999
for i in range(N):
  if abs(T-H[i]*0.006-A)<diff:
    diff=abs(T-H[i]*0.006-A)
    I=i
print(I+1)
# Judge status: Accepted
n = int(input())
a1 = list("abcdefghij")

b1 = [[0]]
c1 = 1
ans = []
while c1 < n:
    c1 += 1
    b2 = b1 + []
    b1 = []
    for i in b2:
        imax = max(i)
        for j in range(imax+2):
            b1.append(i+[j])

for i in b1:
    ans = [a1[j] for j in i]
    print("".join(ans))
# Judge status: Wrong Answer
N,M=map(int,input().split())
n1=min(N,M//2)
N-=n1
M-=2*n1

if N==0:
  ans=n1+M//4
else:
  ans=n1+N//2
print(ans)
# Judge status: Wrong Answer
n,a,b = list(map(int,input().split()))
if (b-a)%2==1:
    print(min(n-a,b-1))
else:
    print(min(b-a-1,n-a+1,b))
# Judge status: Accepted
from functools import reduce
import math

#def gcd(*numbers):
#    return reduce(math.gcd, numbers)

a = int(input())
result = 0

for i in range(1, a+1):
  for j in range(1, a+1):
    for k in range(1, a+1):
      result += math.gcd(math.gcd(i, j),k)
      
print(result)
# Judge status: Accepted
a,b,x = [int(i) for i in input().split()]
from math import atan
from math import degrees
def deg(n):
    return degrees(atan(n))
V = a*a*b
if V/2 == x:
    xa = deg(1)
    xa = str(xa) + '0000000000'
    print(xa)
    exit()
if V/2 > x:
    xa = deg(a*b*b/(2*x))
    print(xa)
    exit()
if V/2 < x:
    xa = deg(2*(V-x)/a**3)
    print(xa)
    exit()
# Judge status: Accepted
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split())) + [X]
y = list(map(int, input().split())) + [Y]
if max(x) < min(y):
  print('No War')
else:
  print('War')
# Judge status: Accepted
o = input()
e = input()

pw = [""] * (len(o)+len(e))

for i in range(len(o)):
  pw[2*i] = o[i]
for i in range(len(e)):
  pw[2*i+1] = e[i]
print("".join(pw))
# Judge status: Accepted
cands = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def add_v(v):
  global cands
  global K
  v0 = v % 10
  if v0 == 0:
    cands += [v*10, v*10+1]
    K -=2
  elif v0 == 9:
    cands += [v*10+8, v*10+9]
    K -= 2
  else:
    cands += [v*10+v0-1, v*10+v0, v*10+v0+1]
    K -= 3

K = int(input())
idk = K
K -= 9
idx = 0
while K >= 0:
  add_v(cands[idx])
  idx += 1

print(cands[idk-1])
# Judge status: Wrong Answer
n=int(input())
w=[input() for _ in range(n)]
if len(set(w))!=n:print('No')
else:
  if (w[i][-1]==w[i+1][0] for i in range(n)):print('Yes')
  else:print('No')
# Judge status: Wrong Answer
X,Y = map(int, input().split())
# N = int(input())
print(X + Y / 2)
# Judge status: Accepted
import math

N = int(input())
t = False
for i in range(N * 100, (N + 1) * 100):
    if i % 108 == 0:
        t = True
        break
if t:
    print(math.ceil(N / 1.08))
else:
    print(':(')
# Judge status: Wrong Answer
S=input()
N=len(S)
n1=0
n2=0
for i in range(N):
 if S[i]=="h":
  n1=n1+1
 if S[i]=="i":
  n2=n2+1

if (n1==n2)and(n1==N/2):
 print("Yes")
else:
 print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
if n == 2:
  print(a[0])
  exit()

idx = 1
s = a[0]

for i in range(2,n):
  s += a[idx]
  if i % 2 == 1:
    idx += 1
print(s)
# Judge status: Wrong Answer
def main():
    n = int(input())
    a = list(map(int, input().split()))
    score = [0, 0]
    sort_a = sorted(a, reverse=True)
    print(sort_a)

    for i in range(n):
        if i >= 2:
            sub_i = i % 2
        else:
            sub_i = i
        score[sub_i] += sort_a[i]

    print(score[0] - score[1])


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

S=a,b,c,d,e

if (max(S)-min(S))<k:
	print("Yay!")
else:
	print(":(")
# Judge status: Wrong Answer
n=int(input())
a=[int(i) for i in input().split()]
l=[2*(10**5)]

for i in range(1,n):
  j=n-i
  x=sum(a[:i])
  y=sum(a[i:n])
  if abs(x-y)<l[-1]:
    l.append(abs(x-y))
l.sort()
print(l[0])
# Judge status: Accepted
n, l = map(int, input().split())

aji = (l + l+n-1)*(n/2)

if l >= 0 :
    ans = aji - l
elif l < 0 and l+n <= 0 :
    ans = aji - (l+n-1)
else :
    ans = aji

print(int(ans))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# # 出力
# print("{} {}".format(a+b+c, s))

if n < 500:
    if n > a:
        print('Yes')
    else:
        print('No')
else:    
    amari = n%500
    if amari < a:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
a,b=map(int,input().split())
N=list(str(input()))
if N[a]=="-":
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())

m = 1000000000000
for i in range(max(x, y)*2):
    total = a*(max(0, x-i//2)) + b*(max(0, y-i//2)) + c*i
    if total < m:
        m = total

print(m)
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())
path = ''
for _ in range(tx - sx):
  path += 'R'
for _ in range(ty - sy):
  path += 'U'
for _ in range(tx - sx):
  path += 'L'
for _ in range(ty - sy):
  path += 'D'

  
path += 'D'
for _ in range(tx - sx + 1):
  path += 'R'
for _ in range(ty - sy + 1):
  path += 'U'
path += 'L'
path += 'U'
for _ in range(tx - sx):
  path += 'L'
for _ in range(ty - sy):
  path += 'D'
path += 'R'

print(path)
# Judge status: Wrong Answer
x=int(input())
ans=0
if 400<=x<=599:
    ans=8
elif 600<=x<=799:
    ans=7
elif 800<=x<=999:
    ans=6
elif 1000<=x<=1199: 
    ans=5
elif 1200<=x<=1399:
    an=4
elif 1400<=x<=1599:
    ans=3
elif 1600<=x<=1799:
    ans=2
elif 1800<=x<=1999:
    ans=1
print(ans)
# Judge status: Accepted
N=int(input())

print(((N-1)*N)//2)
# Judge status: Accepted
a, b, c, k = map(int, input().split())

init_ = a - b

if abs(a - b) > 10**18:
    print("Unfair")
else:
    if k % 2 == 1:
        print(-(a - b))
    else:
        print(a - b)
# Judge status: Wrong Answer
H = int(input())

ans = 1

while H > 1:
  ans *= 2
  H /= 2
print(ans - 1)
# Judge status: Wrong Answer
N,K = map(int,input().split())
x = list(map(int,input().split()))

total = 100000000

for i in range(N-K+1):
    x_part = x[i:i+K]
    x_min = min(x_part)
    x_max = max(x_part)
    if (x_min<0)&(x_max>0):
        total = min(total,abs(x_min)*2+abs(x_max))
    elif (x_min<=0) & (x_max<=0):
        total = min(total,abs(x_min))
    else:
        total = min(total,abs(x_max))

print(total)
# Judge status: Accepted
X=int(input())

if X>=30:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
s = input()
ans = 0
center = len(s) // 2

if center % 2 == 1:
  s2 = s[center+1:]
else:
  s2 = s[center:]

s1 = s[:center]
s2 = "".join(reversed(s2))

for str1 , str2 in zip(s1,s2):
  if str1 != str2:
    ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
mod = 1000000007
alphacnt = [0]*26
ans = 0
for c in s:
    idx = ord(c)-ord("a")
    alphacnt[idx] += 1
    cnt = 1
    for i in range(26):
        if i == idx: continue
        cnt = (cnt*(alphacnt[i]+1))%mod
    ans = (ans+cnt)%mod
print(ans)
# Judge status: Wrong Answer
def somaD(numero):
    soma=0
    for i in str(numero):
        soma+=int(i)
    return soma

numero= int(input())
minimo=numero

for i in range(numero):
    # i // numero-i
    soma = somaD(i)+somaD(numero-i)
    if soma < minimo:
        minimo=soma
print(minimo)
# Judge status: Wrong Answer
w,h,n = map(int,input().split())
x1,y1 = 0,0
x1,y2 = 0,h
x2,y1 = w,0
x2,y2 = w,h
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        x1 = x
    elif a == 2:
        x2 = x
    elif a == 3:
        y1 = y
    else:
        y2 = y
if x2-x1 <= 0 or y2-y1 <= 0:
    print(0)
else:
    print((x2-x1)*(y2-y1))
# Judge status: Accepted
c1 = input()
c2 = input()
print("YES" if c1 == c2[::-1] else "NO")
# Judge status: Wrong Answer
s = list(input())
count = [0]
x = ["A","T","G","C"]
c = 0
for i in range(len(s)):
    if (s[i] in x) == True:
        c += 1
    else:
        count.append(c)
        c = 0
count.append(c)
print(count)
# Judge status: Accepted
import numpy as np
A  = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
B = []
for j in range(N):
    B.append(int(input()))

res = np.array([int(i in B) for i in A.ravel()]).reshape(3, 3)
diag_sum = res[0, 0] + res[1, 1] + res[2, 2]
diag_sum2 = res[0, 2] + res[1, 1] + res[2, 0]
if (res.sum(axis=0) == 3).any() or (res.sum(axis=1) == 3).any() or diag_sum == 3 or diag_sum2 == 3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from random import randrange
for i in range(365):
  print(randrange(1, 27))
# Judge status: Accepted
# -*- coding: utf-8 -*-
d, n = map(int,input().split())

if d == 0:
    if n < 100:
        print(n)
    if n == 100:
        print(101)
if d == 1:
    if n < 100:
        print(n * 100)
    if n == 100:
        print(10100)
if d == 2:
    if n < 100:
        print(n * 10000)
    if n == 100:
        print(1010000)
# Judge status: Accepted
a, b = map(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")
# Judge status: Wrong Answer
N, *A = map(int, open(0).read().split())
rising_terms = []
tmp = []
for i in range(N - 1):
    if A[i] <= A[i + 1]:
        tmp.append(A[i])
    elif tmp:
        rising_terms.append(tmp)
        tmp = []
if A[N - 2] <= A[N - 1]:
    rising_terms.append(tmp + [A[N - 1]])
ans = 1000
for rising_term in rising_terms:
    stock, r_money = divmod(ans, rising_term[0])
    ans = r_money + stock * rising_term[-1]
print(ans)
# Judge status: Wrong Answer
a = int(input())
s = input()
if a >= 3200:
  print('red')
else:
  print(s)
# Judge status: Wrong Answer
N, x = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])

ans = 0

if sum(a) == x:
    ans = N
else:
    for i in range(N):
        if x > a[i]:
            x -= a[i]
            ans += 1

print(ans)
# Judge status: Accepted
import sys
s = input()
n = len(s)

ans = 7

for bit in range(2**(n-1)):
    tmp = s[0]
    for i in range(n-1):
        if (1<<i)&bit:
            tmp += '+'
        else:
            tmp += '-'
        tmp += s[i+1]
    total = eval(tmp)
    if total == ans:
        print(tmp + '=7')
        sys.exit()
# Judge status: Wrong Answer
import math
x=int(input())
if x<=360:
  print(int(360/x))
else:
  y=x%360
  print(int(360/y))
# Judge status: Accepted
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()
if x[-1]<y[0] and x[-1]<Y and X<y[0]:
    print("No War")
else:
    print("War")
# Judge status: Accepted
N = int(input())
ans = 0

if N % 2 == 1:
    print(0)
    exit()

tmp = 2 * 5
while N >= tmp:
    ans += N // tmp
    tmp *= 5
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
al = list(map(int, input().split()))

if n >= m:
    print(0)
    exit()

al_s = sorted(al)
res=[]
for i in range(m-1):
    res.append(al_s[i+1]-al_s[i])

res_s = sorted(res)

print(sum(res)-sum(res_s[n+1:]))
# Judge status: Accepted
x,y = map(int,input().split())
if x == y:
    print("Draw")
if x == 1:
    x += 13
if y == 1:
    y += 13
if x < y:
    print("Bob")
if x > y:
    print("Alice")
# Judge status: Accepted
import numpy as np
n = int(input())
t, a = map(int,input().split())
h_ = list(map(int,input().split()))
b = []
for h in h_:
    b.append(abs(a - (t - 0.006 * h))) 

print(np.argmin(b)+1)
# Judge status: Accepted
x,y,z=map(int,input().split())
tmp=x//(y+z)
if tmp*(y+z)+z>x:
    tmp-=1
print(tmp)
# Judge status: Wrong Answer
S=input()
T=input()
n=len(S)
m=len(T)

for i in range(n-m+1) :  
#文字列に安易に ' を入れない方が良い
    s=S[i:i+m]
    for j in range(m+1):
        if j==m :
            print((S[:i]+T+S[i+m:]).replace("?","a"))
            exit()
        if s[j]==T[j] :
            continue
        elif s[j]=="?" :
            continue
        else :
            break
 
print("UNRESTORABLE")
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!

x, y = list(map(int, input().split()))

if(y > x*4):
    print("No")
else:
    if(y%2 == 1):
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
N, A, B = list(map(int,input().split()))
if (B * (N-1) + A) - (B + (N-1) * A) < 0:
  print(0)
elif A == B:
  print(1)
else:
  print((B * (N-1) + A) - (B + (N-1) * A) + 1)
# Judge status: Wrong Answer
import sys
def I(): return int(sys.stdin.readline().rstrip())

N = I()

ANS = [[] for _ in range(N+1)]

for i in range(1,N+1):
    if i == 1:
        ANS[i].append('a')
    else:
        for a in ANS[i-1]:
            for j in range(97,ord(a[-1])+2):
                ANS[i].append(a+chr(j))
print(*ANS[N],sep='\n')
# Judge status: Wrong Answer
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
ans = [K-Q]*N
for a in A:
    ans[a-1] += 1
print(ans)
for n in range(N):
    if ans[n] > 0:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
t=input()

ans=''
for i in range(len(t)):
  if t[i]=='?':
    ans+='D'
  else:
    ans+=t[i]

print(ans)
# Judge status: Wrong Answer
from itertools import groupby, accumulate, product, permutations, combinations
from collections import Counter
def solve():
    N = int(input())
    dics = [0]*N
    S = [input() for _ in range(N)]
    for i in range(N):
        dics[i] = Counter(S[i])
    ans = ''
    for k,v in sorted(dics[0].items()):
        mincnt = v
        for i in range(1,N):
            mincnt = min(v,dics[i][k])
        ans += k*mincnt
    return ans
print(solve())
# Judge status: Accepted
O = list(input())
E = list(input())
ans = []

for i in range(len(E)):
    ans += O[i]
    ans += E[i]

if len(E) != len(O):
    ans += O[-1]
    
print (''.join(ans))
# Judge status: Wrong Answer
N=int(input())
import collections
b=input().split()
c = collections.Counter(b)
c=list(c.values())


for i in range(N) :
	if len(c)>i :
		print(c[i])
	else :
		print('0')
# Judge status: Wrong Answer
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    a=LIST()
    print(n-sum(a))
if __name__ == '__main__':
    do()
# Judge status: Wrong Answer
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            if a + i*b + j*c + k*d == 7:
                op1 = ['-','+'][i==1]
                op2 = ['-','+'][j==1]
                op3 = ['-','+'][k==1]
                print(f'{a}{op1}{b}{op2}{c}{op3}{d}')
                break
# Judge status: Wrong Answer
import heapq
N, M = map(int, input().split())
S = list()
A = [list() for _ in range(M+1)]
for _ in range(N):
    a, b = map(int, input().split())
    if M < a:
        continue
    heapq.heappush(A[M-a], -b)

ans = 0
for i in range(1, M+1):
    for num in A[i]:
        heapq.heappush(S, num)
    if S == []:
        continue
    ans -= heapq.heappop(S)
print(ans)
# Judge status: Accepted
N = int(input())
S = input()

n_R = S.count('R')
n_G = S.count('G')
n_B = N - n_R - n_G
ans = n_R * n_G * n_B

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j-i)
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)
# Judge status: Wrong Answer
a, b = map(int,input().split())
print('Yes' if a < 10 and b < 10 and a > 0 and b > 0 else 'No')
# Judge status: Wrong Answer
n,*h=map(int,open(0).read().split())
h=h+[0]
ans=0
tmp=0
for i in range(n):
  if h[i]-h[i+1]>=0:
    tmp+=1
  else:
    ans=max(ans,tmp)
    tmp=0
ans=max(ans,tmp)
print(ans-1)
# Judge status: Accepted
# coding: utf-8


def main():
    X, Y = map(int, input().split())

    for n_turu in range(X+1):
        n_kame = X - n_turu
        if n_turu * 2 + n_kame * 4 == Y:
            return "Yes"

    return "No"


print(main())
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())

result = int((a + b) * h /2)
print(result)
# Judge status: Accepted
n = int(input())
d = list(map(int,input().split()))

d.sort()

print(d[n // 2] - d[n // 2 - 1])
# Judge status: Accepted
k=list(map(str,input()))

flag=0
for i in range(len(k)):
    if k[i]=='7':
        flag=1
        print("Yes")
        break
    else:
        flag=0
        
if flag==0:
    print("No")
# Judge status: Accepted
N = int(input())
c = list(str(input()))
r = c.count('R')
w = 0
for i in range(r):
    if c[i] == 'W':
        w += 1
print(w)
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())
py = ty-sy
px = tx-sx
ans = "R"*px + "U"*py + "L"*px + "D"*(py+1) + "R"*(px+1) + "U"*(py+1) + "LU" + "L"*(px+1) + "D"*(py+1)+ "R" 
 
print(ans)
# Judge status: Wrong Answer
n = input()
if n[0] >= n[1] and n[1] >= n[2]:
    print(n[0]+n[0]+n[0])
else:
    print(str(int(n[0])+1) + str(int(n[0])+1) + str(int(n[0])+1))
# Judge status: Accepted
H, N = map(int, input().split())

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

dp=[[float("inf")]*(H+1) for _ in range(N+1)]
dp[0][0]=0
for i in range(N):
	a, b = A[i], B[i]
	for j in range(H+1):
		if a>=j:
			dp[i+1][j] = min(dp[i][j], b)
		else:
			dp[i+1][j] = min(dp[i][j], dp[i+1][j-a]+b)
print(dp[-1][-1])
# Judge status: Wrong Answer
S = input(">>")
T = input(">>")
 
a = 0
flag1 = False
flag2 = False

if (len(T) - len(S) == 1):
    flag1 = True

if (S == T[:-1]):
    flag2 = True

if (flag1 and flag2):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from collections import Counter
from math import *
S=input()
c=Counter(S)
l=max(c.values())
print("YES" if ceil(len(S)/3)>=l else "No")
# Judge status: Accepted
l = set(map(int, input().split()))
print(len(l))
# Judge status: Accepted
N = int(input())
S = input()
if N % 2 != 0:
    print('No')
else:
    if S[N // 2:] == S[:N // 2]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import collections
from collections import defaultdict

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

dict = defaultdict(int)
for i in l:
    dict[i]+=1

ans = 0
for v in dict.values():
    ans += int((v*(v-1)) // 2)

for k in l:
    print(ans - (dict[k] - 1))
# Judge status: Accepted
ab, bc, ca = map(int, input().split())
area = ab * bc // 2
print(area)
# Judge status: Accepted
A, B, C = map(int,input().split())
if A==B and A!=C and B!=C:
    print("Yes")
elif A==C and A!=B and C!=B:
    print("Yes")
elif B==C and B!=A and C!=A:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = int(input())
if x < 599:
    print(8)
if x < 799:
    print(7)
if x < 999:
    print(6)
if x < 1199:
    print(5)
if x < 1399:
    print(4)
if x < 1599:
    print(3)
if x < 1799:
    print(2)
if x < 1999:
    print(1)
# Judge status: Wrong Answer
N=int(input())
s=str(input())
t=str(input())

ts=list(s)
tt=list(t)
doubled=0
for i in range(N):
    if ts[N-1-i]==tt[i]:
        doubled+=1

ans=ts+tt[:doubled]
print("".join(ans))
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

if str.isdecimal(S[:A]) and S[A]=="-" and str.isdecimal(S[A+1:]) and len(S[A+1:])==B:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A > 12:
  print(B)
elif A <= 12 and A >= 6:
  print(B/2)
elif A < 6:
  print(0)
# Judge status: Wrong Answer
import itertools
N = int(input())
S = list(input())
num = [i for i in range(0,N)]
C = list(itertools.combinations(num,3))
ans = 0
print(C)
for c in C:
    if c[1]-c[0] == c[2]-c[1]:
        continue
    if S[c[0]] != S[c[1]] and S[c[1]] != S[c[2]]:
        ans += 1
print(ans)
# Judge status: Accepted
s = input()
K = int(input())
k = K

ans = ""
for i in range(len(s)-1):
    if(s[i] == "a"):
        ans += s[i]
        continue
    if(ord(s[i])+k >= ord("z")+1):
        ans += "a"
        k -= ord("z")+1-ord(s[i])
    else:
        ans += s[i]

a = ord(s[-1])+k%26
if(a > ord("z")):
    a -= 26
ans += chr(a)
    
print(ans)
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
if A <= B :
  print(B*10+C+A)
else :
  print(A*10+B+C)
# Judge status: Wrong Answer
n=int(input())
ans=n*(n-1)/2
print(int(ans))
# Judge status: Accepted
import math
X = int(input())


def is_prime(n):
	if n <= 1:
		return False

	if n == 2:
		return True

	if n%2 == 0:
		return False

	for i in range(3,math.ceil(math.sqrt(n)),2):
		if n%i == 0:
			return False

	return True

inf = 10**20
if is_prime(X) == True:
	print(X)

else:
	for i in range(X+1,inf):
		if is_prime(i) == True:
			print(i)
			break
# Judge status: Accepted
c = list(map(int, input().split()))
x, y, z = c[0]-c[1], c[1]-c[2], c[2]-c[0]
flag = True
for i in range(2):
  c = list(map(int, input().split()))
  s, t, u = c[0]-c[1], c[1]-c[2], c[2]-c[0]
  if (x!=s) or (y!=t) or (z!=u):
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a * b % 2 == 0:
  print('Yes')
else:
  print('No')