peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
x = int(input())
ans = 0
t = 0
d = 0

while x > d:
    t += 1
    d += t
    ans += 1

print(ans)
# Judge status: Wrong Answer
a = int(input())
s = input()
print(s if a > 3200 else 'red')
# Judge status: Wrong Answer
A,B,T=map(int,input().split())
print(((T+0.5)//A)*B)
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()

    if "9" in s:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
h,a = map(int,input().split())
print(h//a if h%a == 0 else h//a+1)
# Judge status: Wrong Answer
a=list(input())
if a[0]==a[1] or a[0]==a[2] or a[0]==a[3] or a[1]==a[2] or a[1]==a[3] or a[2]==a[3]:
  print('Good')
else:
  print('Bad')
# Judge status: Wrong Answer
#intの場合
L,R = map(int,input().split())
print(type(L),L,R)
# <class 'int'> 12 34

ans = L*R
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())

if N == 1:
    if M == 1:
        print(1)
    else:
        print(M-2)
else:
    if N <= M:
        print((N-2)*(M-2))
    else:
        print(0)
# Judge status: Accepted
S = input()
T = input()
print('Yes' if S == T[:-1] else 'No')
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
check = B - A + 1
loop = N - 2
if B < A or (N == 1 and A != B):
  print(0)
  exit(0)
elif N == 1:
  print(1)
  exit(0)

if loop % 2 == 0:
  ans = (check + check - loop +1)*(loop/2)
else:
  ans = (check + check - loop+1)*((loop-1)/2)+check -(loop -1)/2
  
print(ans)
# Judge status: Accepted
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
print("Yes" if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d else "No")
# Judge status: Wrong Answer
X = int(input())

flag = False
for i in range(-10 ** 2, 10 ** 2):
  for j in range(-10 ** 2, 10 ** 2):
    if pow(i, 5) - pow(j, 5) == X:
      print(i, j)
      flag = True
      break
  if flag:
    break
# Judge status: Accepted
s=input()
if int(s[5:7])<=4 and int(s[8:9])<=30:
    print("Heisei")
else:
    print("TBD")
# Judge status: Accepted
a,b,k=map(int,input().split())

print(max(a-k,0),min(b,(max(b-(k-a),0))))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

L = int(input())

maxV = 0

for x in range(1,L+1):
    for y in range(1,L+1):
        z = L-(x+y)

        V = x*y*z
    
        if maxV < V:
            maxV = V


print(maxV)
# Judge status: Accepted
a=str(input())
print(chr(ord(a) + 1))
# Judge status: Accepted
# abc082_b.py
S = input()
T = input()

S = sorted(S, reverse=False)
T = sorted(T, reverse=True)
if S >= T:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
S = list(input())

C = Counter(S)
count = 1
mod = 10*9 + 7
for i in C.values():
    count *= i+1
    count %= mod
print(count-1)
# Judge status: Accepted
n = int(input())
w = list(map(int, input().split()))
ans = []
for i in range(n):
    x = abs(sum(w[:i])-sum(w[i:]))
    ans.append(x)
print(min(ans))
# Judge status: Accepted
X,A,B = map(int,input().split())

if B <= A:
    print("delicious")
elif (B-A) <= X:
    print("safe")
else:
    print("dangerous")
# Judge status: Wrong Answer
n = int(input())
s =[[0]*26 for i in range(n)]
a =[0]*26
sa=''
for i in range(n):
    s1=list(input())
    for j in s1:
        s[i][ord(j)-ord('a')]+=1
for j in range(26):
    for i in range(n):
        if a[j]==0:
            a[j]=s[i][j]
        elif a[j]>s[i][j]:
            a[j]=s[i][j]
for i in range(26):
    sa+=chr(ord('a')+i)*a[i]
print(sa)
# Judge status: Wrong Answer
n,m,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))
cnt=0
for i in range(x,y+1):
    if max(xl)<i and i<=min(yl):
        cnt+=1
if cnt == 0:
    print('War')
else:
    print('No War')
# Judge status: Accepted
#!/usr/bin/env python3

n, m, k = [int(x) for x in input().split()]
for i in range(0, m + 1):
    for j in range(0, n + 1):
        c = i * (n - j) + j * (m - i)
        if c == k:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
s = input()
 
res = 0
 
for i in range(3):
  if s[i] == "1":
    res += 1
    
print(res)
# Judge status: Wrong Answer
SA = input()
SB = input()
SC = input()
turn = "a"
while(len(SA) > 0 and len(SB) > 0 and len(SC) > 0):
    if turn == "a":
        turn = SA[len(SA) - 1]
        SA = SA[:-1]
    elif turn == "b":
        turn = SB[len(SB) - 1]
        SB = SB[:-1]
    elif turn == "c":
        turn = SC[len(SC) - 1]
        SC = SC[:-1]
if len(SA) == 0:
    print("A")
elif len(SB) == 0:
    print("B")
elif len(SC) == 0:
    print("C")
# Judge status: Wrong Answer
w=input()
list_w=list(w)
count1=0
for i in range(0,len(list_w)):
	a=list_w.count(list_w[i])
	if(a%2==0):
		count1+=1
	elif(a%2 != 0):
		count1-=1
		
if(count1>0):
	print("Yes")
elif(count1<0):
	print("No")
# Judge status: Wrong Answer
import sys
input = sys.stdin.buffer.readline
N, W = map(int, input().split())
w = []
v = []
for i in range(N):
    tmp_w,tmp_v = map(int,input().split())
    w.append(tmp_w)
    v.append(tmp_v)

dp = [[0]*(W+1) for j in range(N+1)]
for i in range(N):
  for j in range(W+1):
    if j < w[i]:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = dp[i][j-w[i]] + v[i]
print(dp[N][W])
# Judge status: Accepted
import math

a, b, n = map(int, input().split())
x = b - 1
if x > n:
    x = n
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
l = list(map(int, input().split()))
l = set(l)
print(len(l))
# Judge status: Wrong Answer
import numpy as np

N,L=map(int,input().split())
taste=list(range(L,L+N))
#print(sum(taste))
min_abs=10**5
for i in range(N):
    if abs(taste[i])<min_abs:
        min_abs=taste[i]
        #rec=taste[i]
        #print(rec)
        
        
print(sum(taste)-min_abs)
# Judge status: Wrong Answer
N, M = map(int, input().split())
ans = [0] * N
for i in range(M):
  s, c = map(int, input().split())
  if [s, c] == [1, 0]:
    ans = -1
    break
  if ans[s-1] in [0, c]:
    ans[s-1] = c
  else:
    ans = -1
    break
if ans != -1:

  s = ""
  for i in ans:
    s += str(i)
  ans = int(s)
print(ans)
# Judge status: Accepted
import math

def n_2(n):
  c=0
  while n%2==0:
    c+=1
    n>>=1
  return (n,c)

N,M=map(int,input().split())
A=list(map(int,input().split()))
A[0],a=n_2(A[0])
p=False
for i in range(1,N):
  A[i],b=n_2(A[i])
  if a!=b:
    p=True
    break
if p:
  print(0)
  exit()
n=1
for _ in range(a-1):
  n*=2
l=n
for a in A:
  l=l*a//math.gcd(l,a)
ans=M//l-M//(2*l)
print(ans)
# Judge status: Accepted
x, y = map(int, input().split())

if x == y: print(-1)
elif (x/y).is_integer(): print(-1)
else: print(x)
# Judge status: Accepted
x,y = map(int,input().split())

ans=abs(abs(x)-abs(y))

if x<0 and y<=0 or x>=0 and y>0:
  if x>y:
    ans+=2

else:
  ans+=1
  
print(ans)
# Judge status: Accepted
n = int(input())

def get_divisors(n):
    return [i for i in range(1, n//2+1) if n%i == 0] + [n]

ans = 0
for i in range(1, n+1, 2):
    if len(get_divisors(i)) == 8:
        ans += 1
print(ans)
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
S = 0
P = 10**9 + 7
for i in range(N):
  S = (S + A[i])%P
ans = 0
for i in range(N):
  S = (S-A[i]+P)%P
  a = (A[i]*S)%P
  ans = (ans + a)%P
print(ans)
# Judge status: Accepted
n = int(input())

if n % 2 != 0:
  print((int(n/2) + 1)/n)
else:
  print((n/2)/n)
# Judge status: Accepted
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    a, b, c, k = map(int, input().split())
    if k & 1:
        print(b-a)
    else:
        print(a-b)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def f():
    s = int(input())
    i9 = 10**9
    if s == i9 ** 2:
        print(i9, 0, 0, i9, 0, 0)
    else:
        print(i9 - (s%i9), s//i9 + 1, i9, 1, 0, 0)

if __name__ == '__main__':
    f()
# Judge status: Accepted
a=list(map(int, input().split()))
n=a[0]
m=a[1]
l=list(map(int, input().split()))
lm=sum(l)
l=sorted(l, reverse=True)
for i in range(m):
    if l[i]*4*m<lm:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
S = input()
T = input()

import sys

for i in range(len(S)):
    if S[i:len(S)] + S[:i] == T:
        print("Yes")
        sys.exit()
    
print("No")
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(100000)

strings=["a","b","c","d","e","f","g","h","i","j"]

N=int(input())
def f(x):
    for i in x:
        print(strings[i],end="")
    if x[-1]==N-1:
        return ""
    print("")
    if x[-1]-1==x[-2]:
        x[-1]+=1
        return f(g(x,N-1))
    else:
        x[-1]+=1
        return f(x)
# Judge status: Wrong Answer
import collections

n = int(input())
an = []
for i in range(n):
    a = input()
    an.append(a)

c = list(str(collections.Counter(an).values()).replace('dict_values([','').replace('])','').replace(', ',''))
Ans = 0
for i in range(len(c)):
    if int(c[i]) % 2 == 1:
        Ans = Ans + 1

print(Ans)
# Judge status: Accepted
x = int(input())

fh = x // 500 * 1000
f = x % 500 // 5 * 5
print(fh + f)
# Judge status: Accepted
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
B = [(i + 1) + A[i] for i in range(N)]
C = [(i + 1) - A[i] for i in range(N)]
d = defaultdict(int)
for b in B:
    d[b] += 1
ans = 0
for c in C:
    ans += d[c]
print(ans)
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())

start = h1*60 + m1
end = h2*60 + m2

print(end- start - k)
# Judge status: Wrong Answer
n = int(input())
if n % 3 == 2:
    print(n//3 * (n//3+1) * (n//3+1))
else:
    print(n//3 * n//3 * (n//3+n % 3))
# Judge status: Wrong Answer
n = int(input())
time=0
alist=[]
for i in range(n):
  a,b=map(int, input().split())
  alist.append([a,b-a])
  if b>time:
    time=b
alist.sort(key=lambda x: x[1])
ans='Yes'
for i in range(n-1,-1,-1):
  if time<alist[i][1]:
    ans='No'
  time=time-alist[i][0]
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
if abs(a-b)%2:
  print('IMPOSSIBLE')
else:
  print((a+b)//2)
# Judge status: Accepted
N = int(input())

ans = 0
for i in range(1, N):
    for j in range(i, (N // i) + 1):
        if i * j < N:
            if i == j:
                ans += 1
            else:
                ans += 2
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(min(K,100)):
    imos = [0]*(N+1)
    for i, ai in enumerate(A):
        imos[max(0, i-ai)] += 1
        imos[min(N, i+ai+1)] -= 1
    A = [imos[0]]
    for i in range(1, N):
        A += [imos[i]+A[i-1]]
print(' '.join(map(str, A)))
# Judge status: Accepted
n = int(input())
xpy_max = -1001001001
xpy_min =  1001001001
xmy_max = -1001001001
xmy_min =  1001001001

for i in range(n):
    x, y = map(int, input().split())
    xpy_max = max(xpy_max, x+y)
    xpy_min = min(xpy_min, x+y)
    xmy_max = max(xmy_max, x-y)
    xmy_min = min(xmy_min, x-y)
ans = max(xpy_max - xpy_min, xmy_max - xmy_min)
print(ans)
# Judge status: Accepted
n,*a=map(int, open(0).read().split())
print(sum(sorted(a)[n:][::2]))
'''
why do people think there is a purpose in life'''
# Judge status: Wrong Answer
n = int(input())
alist = [input() for i in range(n)]
 
if len(set(alist))==n:
  if all(alist[i][-1]==alist[i+1][0] for i in range(n-1)):
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
N,R = (int(x) for x in input().split())

if N >= 10:
    print(R)
else:
    print(R+(10- N)*100)
# Judge status: Accepted
x, a, b = map(int, input().split())
print("A" if abs(x-a)<abs(x-b) else "B")
# Judge status: Accepted
q,h,s,d = map(int, input().split())
n = int(input())
# print(min(q*8,h*4,s*2,d),min(q*8,h*4,s*2))
print((n//2 * min(q*8,h*4,s*2,d)) + (n%2 * min(q*4,h*2,s)))
# Judge status: Accepted
#!/usr/bin/env python3

n, a, b = map(int, input().split())
print(n//(a+b)*a + min(n-(n//(a+b)*(a+b)), a))
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n,m = map(int,input().split())
scc = min(n,m//2)
n -= scc
m -= scc*2

print(scc + m//4)
# Judge status: Accepted
# coding: utf-8
# Your code here!
x,a,b=map(int,input().split())
if abs(x-a)>abs(x-b):
    print('B')
else:
    print('A')
# Judge status: Accepted
l = [int(input()) for i in range(3)]
p = int(input())
ans = 0
for i in range(l[0]+1):
    for j in range(l[1]+1):
        for k in range(l[2]+1):
            if 500*i+100*j+50*k==p:
                ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
m = 10**10
for i in range(N):
    if m >= A[i]:
        m = A[i]
        ans += 1
print(ans)
# Judge status: Accepted
N=int(input())
S=list(input())

count=0
LR=[0,0]
for i in range(N):
    if S[i]=="(":
        count+=1
    else:
        if count==0:
            LR[0]+=1
            continue
        count-=1

LR[1]=count
for i in range(2):
    for j in range(LR[i]):
        if i==0:
            S.insert(0,"(")
        else:
            S.append(")")

print("".join(S))
# Judge status: Wrong Answer
#C
#入力
N,K,Q=map(int,input().split())
A=[int(input())-1 for i in range(Q)]

#処理
B=[0 for i in range(N)]

for i in A:
    B[i]+=1

print(B)
for i in B:
    if Q-i<K:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import numpy as np
N = int(input())
A = list(map(int ,input().split()))
sum=0
ans=0
for i in range (0,N-1):
  sum=sum+A[i]
  sum=sum%(1000000000+7)
  ans=ans+sum*A[i+1]
  ans=ans%(1000000000+7)
print(ans)
# Judge status: Accepted
x = int(input())
cou = 1
kyo = 0
while True:
    kyo += cou
    if kyo >= x:
        print(cou)
        exit()
    cou += 1
# Judge status: Wrong Answer
S = input()
T = input()
 
c = 0
 
for s in S:
  for t in T:
    if s != t:
      c += 1
print(c)
# Judge status: Accepted
A = list(map(int,input().split()))
K = int(input())
for _ in range(K):
  A[A.index(max(A))]*=2

print(sum(A))
# Judge status: Accepted
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
ans = (n-1)//(k-1)
if ans == (n-1)/(k-1):
    print(ans)
else:
    print(ans+1)
# Judge status: Accepted
x,y=map(int,input().split())
if x%y:
  print(x*(y-1))
else:
  print(-1)
# Judge status: Wrong Answer
n,k=map(int,input().split())
s=input()
p2=0
p1=0
if n==1:
  print(1)
  exit()
if s[0]=="L":
  p1+=1
if s[n-1]=="R":
  p1+=1
  
for i in range(1,n):
  if not (s[i]=="L" and s[i-1]=="R"):
    continue
  p2+=1
if k<=p2-1:
  print(n-2*p2-p1+2*k)
elif p2<k<p2+p1:
  print(n-p1+(k-p2))
else:
  print(n-1)
# Judge status: Accepted
from functools import reduce

def combination2(n, r, MOD=10**9+7):
    if not 0 <= r <= n: return 0
    r = min(r, n - r)
    numerator = reduce(lambda x, y: x * y % MOD, range(n, n - r, -1), 1)
    denominator = reduce(lambda x, y: x * y % MOD, range(1, r + 1), 1)
    return numerator * pow(denominator, MOD - 2, MOD) % MOD

X, Y = map(int, input().split())
if (2*X-Y)%3 or (2*Y-X)%3:
    print(0)
    exit()
x, y = (2*X-Y)//3, (2*Y-X)//3
print(combination2(x+y,x))
# Judge status: Wrong Answer
a = list(map(int, input().split()))
s = 1
for i in a:
  s *= i
print("Positive" if s > 0 else "Negative" if s < 0 else 0)
# Judge status: Accepted
s = int(input())

a = {s}
b = s 
for i in range(2,1000001):
    if b%2==0:
        b //= 2
    else:
        b = 3*b+1

    if b in a:
        print(i)
        exit()
    else:
        a.add(b)
# Judge status: Wrong Answer
S = str,input()

if S == "abc":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()
ans = True if len(s)%2 == 0 else False
for i in range(len(s)//2):
    if i%2 == 1:
        continue
    if s[i:i+2] != "hi":
        ans = False

print("Yes" if ans else "No")
# Judge status: Accepted
s = input()

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

print (count)
# Judge status: Accepted
from fractions import gcd

A, B, C, D = map(int, input().split())

num1 = B // C - (A-1) // C
num2 = B // D - (A-1) // D
gcdCD = C * D // gcd(C, D)
num3 = B // gcdCD - (A-1) // gcdCD

print(B - A - num1 - num2 + num3 + 1)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = A[0]
while A[0] > 0:
    ans = A[0]
    for i in range(1,N):
        A[i] -= A[0]
    A.sort()

print(ans)
# Judge status: Accepted
import math as mt

s = int(input())
def check(x):
    a = [i for i in range(2,int(mt.sqrt(x))+1,1)]
    if all([x%j != 0 for j in a]):
        return False
    else:
        return True

f = True
while f:
    f = check(s)
    s+=1

print(s-1)
# Judge status: Accepted
from itertools import accumulate
n,k,*a=map(int,open(0).read().split())
for _ in range(k):
    b=[0]*n
    for i in range(n):
        b[max(0,i-a[i])]+=1
        if i+a[i]+1<n:b[i+a[i]+1]-=1
    a=list(accumulate(b))
    if a==[n]*n:break
print(" ".join(map(str,a)))
# Judge status: Wrong Answer
a=int(input())
b=list(map(int,input().split()))

for i in range(len(b)):
    print(b.count(b[i]))
print(0)
# Judge status: Accepted
N,M = map(int, input().split())
ans = []
if N%2==1:
  for i in range(2,N//2+2):
    ans.append((i,N+2-i))
else:
  l = 2
  r = N
  while r-l>N//2:
    ans.append((l,r))
    l += 1
    r -= 1
  l += 1
  while r>l:
    ans.append((l,r))
    l += 1
    r -= 1
for i in range(M):
  print(*ans[i])
# Judge status: Accepted
S = set()
for _ in range(int(input())):
    a = int(input())
    if a in S:
        S.remove(a)
    else:
        S.add(a)
print(len(S))
# Judge status: Wrong Answer
N = int(input())
a = 0
b = 0
while N > 0:
    if N <= 10:
        c, N = N, 0
        break
    elif N % 10 != 9:
        b = 1
    N //= 10
    a += 1
if b == 1:
    c -= 1
ans = c + a * 9
print(ans)
# Judge status: Accepted
from fractions import gcd

n = int(input())
a = [int(i) for i in input().split()]

gcd_to = [0] + a[:]
gcd_from = a[:] + [0]
for i in range(1, n+1):
    gcd_to[i] = gcd(gcd_to[i-1], gcd_to[i])
    gcd_from[n-i] = gcd(gcd_from[n-i+1], a[n-i])

gcd_exclude = []
for i in range(n):
    gcd_exclude.append(gcd(gcd_to[i], gcd_from[i+1]))

print(max(gcd_exclude))
# Judge status: Accepted
arr = list(map(int, input().split()))

a, b = arr[0], arr[1]

if (a+b)%2 == 0: print(int((a+b)/2))
else: print("IMPOSSIBLE")
# Judge status: Accepted
k, x = map(int, input().split())
b = [x - k + 1]

if k > 1:
  for i in range(x - k + 2, x + k):
    b.append(i)

print(" ".join(map(str, b)))
# Judge status: Accepted
# C - Bugged
N = int(input())
S = [int(input()) for _ in range(N)]
S = sorted(S)

ans = sum(S)

if ans % 10 != 0:
	pass
else:
	for i in range(N):
		if S[i] % 10 != 0:
			ans = ans - S[i]
			break
	else:
		ans = 0

print(ans)
# Judge status: Wrong Answer
import sys

N,Y = map(int, input().split())

for x in range(N+1):
    for y in range(N+1):
        z = Y - (10000*x+y*5000)
        z = z // 1000
        if z>=0:
            print(x,y,z)
            sys.exit()
print(-1,-1,-1)
# Judge status: Accepted
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
mx=max(a)
for i in range(n):
    if a[i] == mx:
        mx_index = i
        break
a.sort()
for i in range(n):
    print(a[n-2] if i == mx_index else a[n-1])
# Judge status: Wrong Answer
a, b = map(int, input().split())
if 1 <= a <= b <= 9:
    print(a*b)
else:
    print(-1)
# Judge status: Accepted
N=110000
dp=[0]*N

n=int(input()) 
h=list(map(int,input().split()))
now=[0,0,0]
for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        now=[i,i-1,i-2]
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])
# Judge status: Accepted
n,m = map(int,input().split())
array = []

for i in range(m):
  p,y = map(int,input().split())
  array.append((p,y,i))
  
array.sort()


ans = []
last_p = -1
index = 1
for i in range(m):
  p,y,j = array[i]
  
  if p != last_p:
    index = 1
    
  number = str(p).zfill(6) + str(index).zfill(6)
  ans.append((j,number))
  
  last_p = p
  index += 1
  
for t in sorted(ans):
  print(t[1])
# Judge status: Accepted
N, M = map(int,input().split())
S = "0" * N

for i in range(M):
    s,c = map(int,input().split())
    if s == 1 and c == 0 and N != 1:
        print("-1")
        quit()
    elif S[s-1] == "0" or S[s-1] == str(c):
        S = S[0:s-1] + str(c) + S[s:]
    else:
        print("-1")
        quit()

if S[0] == "0" and N != 1:
    S = "1" + S[1:]

print(S)
# Judge status: Wrong Answer
alphabet = 'abcdefghijklmnopqrstuvwxyz'
s = input()
K = int(input())
ans = ''
for i in range(len(s) - 1):
    s_i = alphabet.index(s[i])
    if (26 - s_i < K) & (s_i != 0):
        K -= 26 - s_i
        s_i = 0
    ans += alphabet[s_i]
s_i = (alphabet.index(s[-1]) + K) % 26
ans += alphabet[s_i]
print(ans)
# Judge status: Accepted
*t,=map(int,open(0).read().split())
a=t[:9]
s={10}
for b in t[10:]:
  if b in a:s|={a.index(b)}
print('NYoe s'[any(s>={i*3,i*3+1,i*3+2}or s>={i,i+3,i+6}for i in(0,1,2))or s>={0,4,8}or s>={2,4,6}::2])
# Judge status: Accepted
A=list(input())
b=[]
for i in range(2**3):
  b.clear()
  for j in range(3):
    if (i>>j)&1:
      b.append("+")
    else:
      b.append("-")
  c=eval(A[0]+b[0]+A[1]+b[1]+A[2]+b[2]+A[3])
  if c==7:
    print(A[0]+b[0]+A[1]+b[1]+A[2]+b[2]+A[3]+"=7")
    exit()
# Judge status: Accepted
n = int(input())
*a, = map(int, input().split())

*b, = filter(lambda x: x%4 != 0, a)
mul_4 = n-len(b)

*c, = filter(lambda x: x%2 != 0, b)
mul_2 = (len(b)-len(c))//2

print("Yes" if n//2 <= mul_4+mul_2 else "No")
# Judge status: Accepted
n = int(input())
arr = list(map(int,input().split()))

N = pow(10,9)+7
def gcd(a,b):
    if a==0:return b
    return gcd(b%a,a)

def lcm(a,b):
    tmp =  (a*b)//gcd(a,b)
    return tmp

hcm = arr[0]
for i in range(1,n):
    hcm = lcm(hcm,arr[i])

res = 0
for num in arr:
    res += (hcm//num)
    

print(res%N)
# Judge status: Wrong Answer
[a,b,c,x,y] = [int(i) for i in input().split()]

ans = a * x + b * y
cnt = 1

while x != 0 or y != 0:
  x = max(x - 1, 0)
  y = max(y - 1, 0)
  ans = min(ans,a*x+b*y+c*2*cnt)
  cnt += 1
  print(ans)
# Judge status: Wrong Answer
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for i in range(Q)]
ABCD.sort(key=lambda x: x[3])
A = [1 for _ in range(N)]
for i in range(Q):
    if not(A[ABCD[i][0]-1] + ABCD[i][2] > M):
        A[ABCD[i][1]-1] = A[ABCD[i][0]-1] + ABCD[i][2]

ans = 0
for i in range(Q):
    if A[ABCD[i][1]-1] == A[ABCD[i][0]-1] + ABCD[i][2]:
        ans += ABCD[i][3]
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
t = input()

c = 0
for i in range(n):
    d = t[:i]
    if d in s:
        c = i
if s == t:
    print(n)
else:
    print(2*n-c)
# Judge status: Accepted
A, B, C = map(int, input().split())
if B < C:
  print(0)
elif A * C < B:
  print(C)
else:
  print(B//A)
# Judge status: Wrong Answer
x = int(input())
ans = x//11 * 2
if 0 < x%11 <= 5: ans += 1
elif x % 11 >= 6: ans += 2
print(ans)
# Judge status: Accepted
abc=sorted(list(map(int,input().split())))
if abc[0]==abc[2]:
    print(1)
elif abc[0]==abc[1] or abc[1]==abc[2]:
    print(2)
else:
    print(3)
# Judge status: Accepted
s = input()

res = 0
previous = s[0]
for i in range(1, len(s)):
    if s[i] == previous:
        res += 1
        previous = str((int(previous) + 1) % 2)
    else:
        previous = s[i]

print(res)
# Judge status: Accepted
n, a, b = map(int, input().split())

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(a, rem)  # ansとremを比較することでnの位置よって処理を変えられる

print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1       
print(count)