Harryxun/stf_run huggingface dataset:
H, N = map(int, input().split())
x = [list(map(int, input().split())) for n in range(N)]
x = [[tmp[i] for tmp in x] for i in range(len(x[0]))]
A = x[0]
B = x[1]

import sys
sys.setrecursionlimit(max(1000, H*N))

memo = [-1] * (H + 1)
def ibis(H):
    if memo[H] >= 0:
        return memo[H]
    if H <= 0:
        return 0
    mp = [0] * N
    for n in range(N):
        mp[n] = B[n] + ibis(H - A[n])
    memo[H] = min(mp)
    return memo[H]

print(ibis(H))

### FIXED CODE ###

H, N = map(int, input().split())
x = [list(map(int, input().split())) for n in range(N)]
x = [[tmp[i] for tmp in x] for i in range(len(x[0]))]
A = x[0]
B = x[1]

def ibis(H, A, B):
    dp = [max(B) * H] * (H + 1)
    dp[0] = 0
    for h in range(H):
        for n in range(N):
            hp = min(h + A[n], H)
            dp[hp] = min(dp[hp], dp[h] + B[n])
    return dp[H]

print(ibis(H, A, B))
N = int(input())
A = [map(int, input()) for i in range(N)]

count = 0
temp = []
tempin = []
for i in range(N):
  if i in tempin:
    continue
  temp.append(A[i])
  for j in range(i+1, N):
    if j in tempin:
      continue
    elif temp[-1] < A[j]:
      temp.append(A[j])
      tempin.append(j)
  else:
    print(tempin)
    count += 1

print(count)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]

import bisect
from collections import deque

temp = deque()
temp.appendleft(A[0])
for i in range(1,N):
  if temp[0] >= A[i]:
    temp.appendleft(A[i])
  else:
    temp[bisect.bisect_left(temp,A[i])-1] = A[i]
print(len(temp))
r = input()
print(3 * a**2)

### FIXED CODE ###

r =int(input())
print(3* r**2)
N = int(input())

import math

A = int(math.sqrt(N))

for i in reversed(range(A)):
    if N % i == 0:
        print(i + (N // i) - 2)
        exit()

### FIXED CODE ###

import math

N = int(input())

A = int(math.sqrt(N))

for i in reversed(range(1, A + 1)):
    if N % i == 0:
        print(i + (N // i) - 2)
        exit()
N=int(input())
h=[0]+list(map(int,input().split()))
c=0
for i in range(N):
  c+=max(h[i+1]-l[i],0)
print(c)

### FIXED CODE ###

N=int(input())
h=list(map(int, input().split()))
c=i=0
while sum(h)>0:
  if h[i]>0:
    j=i
    c+=1
    while j<N and h[j]>0:
      h[j]-=1
      j+=1
  else:
    i+=1
print(c)
s = list(map(int,input().split()))
print(s[1::2])


### FIXED CODE ###

s = input()
print(s[::2])
A, B = map(int, input().split())

a = 14 if A == 1 else A
b = 14 if b == 1 else B
print('Alice' if a > b else 'Bob' if a < b else 'Draw')


### FIXED CODE ###

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

a = 14 if A == 1 else A
b = 14 if B == 1 else B
print('Alice' if a > b else 'Bob' if a < b else 'Draw')
def solve(n, y):
    for man in range(0, n + 1):
        for gosen in range(0, n - man + 1):
            sen = n - man - gosen
            if 10000*man + gosen*5000 + sen*1000 == y and man + gosen + sen == n:
                print('{} {} {}'.format(man, gosen, sen))
                return
    print("-1 -1 -1")
    return            

#main
n = int(input())
y = int(input())
solve(n, y)




### FIXED CODE ###

def solve(n, y):
    for man in range(n + 1):
        for gosen in range(n - man + 1):
            sen = n - man - gosen
            if 10000*man + gosen*5000 + sen*1000 == y and man + gosen + sen == n:
                print('{} {} {}'.format(man, gosen, sen))
                return
    print("-1 -1 -1")
    return            

#main
n, y = map(int, raw_input().split())
solve(n, y)
X=int(input())
max=1
else:
  for i in range(1, X):
    for j in range(2, X):
      if i**j<=X:
        if max>1:
          max=i**j
        else:
          break
print(max)

### FIXED CODE ###

X=int(input())
list=[1]
for i in range(1, X):
  for j in range(2, X):
    if (i**j)<=X:
      list.append(i**j)
    else:break
print(max(list))
K=int(input())
if K%2==0
  A=K*K//4
  print(A)
else:
  B=(K-1)*K//4
  print(B)

### FIXED CODE ###

K=int(input())
if K%2==0:
  A=K*K//4
  print(A)
else:
  B=(K-1)*(K+1)//4
  print(B)
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
L, R = zip(*[list(map(int, input().split())) for _ in range(Q)])

# h_pos[a]: a がある位置の h
# w_pos[a]: a がある位置の w
h_pos = np.zeros(H * W + 1)
w_pos = np.zeros(H * W + 1)
for h in range(H):
    for w in range(W):
        h_pos[A[h][w]] = h
        w_pos[A[h][w]] = w

dp = np.zeros(H * W + 1, dtype=int)
for i in range(1, H * W + 1):
    if i - D >= 0:
        dp[i] = dp[i - D] + abs(h_pos[i - D] - h_pos[i]) + abs(w_pos[i - D] - w_pos[i])

for l, r in zip(L, R):
    print(dp[r] - dp[l])


### FIXED CODE ###

import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
L, R = zip(*[list(map(int, input().split())) for _ in range(Q)])

# h_pos[a]: a がある位置の h
# w_pos[a]: a がある位置の w
h_pos = np.zeros(H * W + 1)
w_pos = np.zeros(H * W + 1)
for h in range(H):
    for w in range(W):
        h_pos[A[h][w]] = h
        w_pos[A[h][w]] = w

dp = np.zeros(H * W + 1, dtype=int)
for i in range(1, H * W + 1):
    if i - D >= 0:
        dp[i] = dp[i - D] + abs(h_pos[i - D] - h_pos[i]) + abs(w_pos[i - D] - w_pos[i])

for l, r in zip(L, R):
    print(dp[r] - dp[l])
line = input()
data = line.split()
 
height = int(data[0])
wei = int(data[1])
 
if height %2 ==0:
  if wei %2 ==0:
    print(int(height/2)*wei)
 
else:
  if wei %2 ==0:
    print(int(height/2)* wei + int(wei/2))
  else:
    print(wei* int(height/2) + int(wei/2)+1)
line = input()
data = line.split()

height = int(data[0])
wei = int(data[1])

if height %2 ==0:
  if wei %2 ==0:
    print(int(height/2)*wei)
  else:
    print(int(height/2)*wei)
else:
  if wei %2 ==0:
    print(int(height/2)* wei + int(wei/2))
  else:
    print(wei* int(height/2) + int(wei/2)+1)


### FIXED CODE ###

line = input()
data = line.split()
 
height = int(data[0])
wei = int(data[1])

if height !=1 and wei !=1: 
  if height %2 ==0:
    if wei %2 ==0:
      print(int(wei/2)*height)
    else:
      print(int(wei/2)*height+int(height/2))
  else:
    if wei %2 ==0:
      print(int(height/2)* wei + int(wei/2))
    else:
      print(wei* int(height/2) + int(wei/2)+1)
else:
  print(1)
n=int(input())
a=map(int,input().split())
print(max(a)-min(a))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))
x = int(input())
while True:
  	    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            break
    else:
        print(x)
        exit()
    x += 1

### FIXED CODE ###

# C - Next Prime
x = int(input())
while True:

    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            break
    else:
        print(x)
        exit()
    x += 1
def chmin(a, b):
    if a > b:
        return b
    return a
#配るDP
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [10**10] * n
    dp[0] = 0
    for i in range(n):
        dp[i+1] = chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
        if i < n-2:
        	dp[i+2] = chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
    print(dp[-1])
resolve()


### FIXED CODE ###

def chmin(a, b):
    if a > b:
        return b
    return a
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [10**10] * n
    dp[0] = 0
    for i in range(n):
        dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[-1])
resolve()
N = int(input())

nodes = []
edges = []

for i in range(N):
    nodes.append([])


for i in range(N-1):
    a, b = [int(v) for v in input().split()]
    a -= 1
    b -= 1

    nodes[a].append((b, i))
    nodes[b].append((a, i))

max_l = 0
max_i = 0
for i, links in enumerate(nodes):
    l = len(links)
    if max_l <= l:
        max_l = l
        max_i = i


def fill(nodes, links, e, pc):
    c = 1
    if c == pc:
        c += 1
    for n, i in links:
        if e[i] != 0:
            continue
        e[i] = c
        fill(nodes, nodes[n], e, c)

        c += 1
        if c == pc:
            c += 1
    
e = [0] * (N - 1)
fill(nodes, nodes[max_i], e, 0)

print(max_l)
for i in e:
    print(i)



### FIXED CODE ###

N = int(input())

nodes = []
edge = []
for i in range(N):
    nodes.append([])

for i in range(N-1):
    a, b = [int(v) - 1 for v in input().split(' ')]
    if a >= len(nodes):
        exit()
    if b >= len(nodes):
        exit()
    nodes[a].append((b, i))
    nodes[b].append((a, i))
    edge.append(0)

max_l = 0
max_i = 0
if nodes is None:
    exit()

for i, links in enumerate(nodes):
    if links is None:
        exit()
    l = len(links)
    if max_l < l:
        max_l = l
        max_i = i

def fill(nodes, edge, queue):
    while len(queue) > 0:
        ni, pc = queue.pop(0)
        links = nodes[ni]

        c = 1
        if pc == c:
            c += 1

        if links is None:
            exit()

        next_links = []
        for n, i in links:
            if n < 0 or i < 0:
                exit()
            if n >= len(nodes) or i >= len(edge):
                exit()

            if edge[i] != 0:
                continue
            edge[i] = c
            queue.append((n, c))

            c += 1
            if pc == c:
                c += 1

queue = [(max_i, 0)]    
fill(nodes, edge, queue)

print(max_l)
for e in edge:
    print(e)
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a = np.array(a, dtype=np.float64)
ans = np.prod(a)
print(int(ans))


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
import math
a,b,c,d=map(int,input().split())
cd=int(c*d/(math.gcd(c,d)))
#print(cd)
c1=b//c
c2=(a-1)//c
c3=c1-c2
d1=b//d
d2=(a-1)//d
d3=d1-d2
cd1=b//(cd)
cd2=(a-1)//(cd)
cd3=cd1-cd2
print((b-a+1)-(c3+d3-cd3))
#print(str(c3)+" "+str(d3)+" "+str(cd3))


### FIXED CODE ###

import fractions
a,b,c,d=map(int,input().split())
cd=int(c*d/(fractions.gcd(c,d)))
#print(cd)
c1=b//c
c2=(a-1)//c
c3=c1-c2
d1=b//d
d2=(a-1)//d
d3=d1-d2
cd1=b//(cd)
cd2=(a-1)//(cd)
cd3=cd1-cd2
print((b-a+1)-(c3+d3-cd3))
#print(str(c3)+" "+str(d3)+" "+str(cd3))
#A
X, A =  map(int, input().split())
if X < A:
    print(f"0")
else:
    print(f"10")

### FIXED CODE ###

#A
X, A =  map(int, input().split())
if X < A:
    print("0")
else:
    print("10")
print(int(inpu())**2)

### FIXED CODE ###

print(int(input())**2)
n = int(input())
ba, xa, bx = 0, 0, 0

for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        ba += 1
    if s[0] == "B" and s[-1] != "A":
        bx += 1
    if s[0] != "B" and s[-1] == "A":
        xa += 1

if xa == 0 and bx == 0:
    ans += max(0, ba-1)
else:
    ans += ba
    ans += min(xa, bx)

print(ans)

### FIXED CODE ###

n = int(input())
ans, ba, xa, bx = 0, 0, 0, 0

for i in range(n):
    s = input()
    ans += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        ba += 1
    if s[0] == "B" and s[-1] != "A":
        bx += 1
    if s[0] != "B" and s[-1] == "A":
        xa += 1

if xa == 0 and bx == 0:
    ans += max(0, ba-1)
else:
    ans += ba
    ans += min(xa, bx)

print(ans)
import collections
import bisect
n,m=map(int,input().split())
p = [list(map(int,input().splilt())) for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))

### FIXED CODE ###

import collections
import bisect
n,m=map(int,input().split())
p=[[int(j) for j in input().split()] for i in range(m)]
a=collections.defaultdict(list)
for x,y in sorted(p):
    a[x]+=[y]
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("%06d%06d"%(x,z))
a=[]
while True:
	a=input()
	if a==0:
		break
	a.append(input())
i=1
for num in a:
	print 'Case {0}: {1}'.format(i,num)

### FIXED CODE ###

a=[]
while True:
	b=input()
	if b==0:
		break
	a.append(b)
i=0
for num in a:
	print 'Case {0}: {1}'.format(i+1,num)
	i+=1
import re
print(max(list(map(len,re.findall('[ATGC]+',input(),re.S)))))

### FIXED CODE ###

import re
result = re.findall('[ATCG]+',input(),re.S)
if len(result)>0:
  print(max(list(map(len,result))))
else:
  print(0)
import numpy as np
from numba import njit
 
n,k = map(int, input().split())
d = np.array(list(map(int, input().split())))
l = np.arange(n)
ans = np.array([0]*n)
cnt = 0


@njit('(i8[:],)', cache=True)
def func(x_left, x_right):
  for x_l,x_r in zip(x_left,x_right):
      ans[x_l:x_r] += 1
 
while True:
  if np.all(d==n):
    ans = d
    break
 
  if cnt == k or cnt==100:
    break
 
  ans *= 0
  x_left = l-d
  x_left[x_left < 0] = 0
  x_right = l+d+1
  x_right[x_left > n] = n
  func(x_left, x_right)
  cnt += 1
  d = ans.copy()
 
  
print(' '.join(map(str, ans)))

### FIXED CODE ###

import sys
import numpy as np
from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
@njit('(i8[::1],)', cache=True)
def update(A):
    N = len(A)
    B = np.zeros_like(A)
    for i, x in enumerate(A):
        l = max(0, i - x)
        r = min(N - 1, i + x)
        B[l] += 1
        if r + 1 < N:
            B[r + 1] -= 1
    B = np.cumsum(B)
    return B
 
N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)
 
K = min(K, 100)
for _ in range(K):
    A = update(A)
print(' '.join(A.astype(str)))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 12 22:19:09 2020

@author: nanasakiwataru
"""


ans = chr(ord(C) + 1)
st = C + 'の次は' + ans + 'です。'
print(st)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 12 22:19:09 2020

@author: nanasakiwataru
"""

C = input()
ans = chr(ord(C) + 1)
print(ans)
n, m = map(int, input().split())
lst = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    lst[x].append(y)

def rec_dp(x):
    global dp
    if dp[x] != -1:
        return dp[x]
    else:
        ans = 0
        for y in lst[x]:
            ans = max(ans, rec_dp(y) + 1)
        dp[x] = ans
        return dp[x]
      
dp = [-1] * n
ans = 0
for _ in range(n):
    ans = max(ans, rec_dp(_))
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(20000)

n, m = map(int, input().split())
lst = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    lst[x].append(y)

def rec_dp(x):
    global dp
    if dp[x] != -1:
        return dp[x]
    else:
        ans = 0
        for y in lst[x]:
            ans = max(ans, rec_dp(y) + 1)
        dp[x] = ans
        return dp[x]
      
dp = [-1] * n
ans = 0
for _ in range(n):
    ans = max(ans, rec_dp(_))
print(ans)
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,m,c = map(int,input().split())
B = np.array(input().split(),dtype=np.int64)
times = n
table = []
for _ in range(times):
    table.append(list(map(int,input().split()))) # 行列の場合
A = np.array(table)

lis = np.dot(A,B) +c
ans = np.bincount(lis > 0)[1]

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


### FIXED CODE ###

# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
n,m,c = map(int,input().split())
B = np.array(input().split(),dtype=np.int64)
times = n
table = []
for _ in range(times):
    table.append(list(map(int,input().split()))) # 行列の場合
A = np.array(table)

lis = np.dot(A,B) +c
anslis = np.bincount(lis > 0,minlength=2)
ans = anslis[1]

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))
N = int(input())
n_1 = N[-1]

if num == 3:
  print('bon')
elif num == 0 or num == 1 or num == 6 or num == 8:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

N = str(input())
num = N[-1]
num = int(num)
 
if num == 3:
  print('bon')
elif num == 0:
  print('pon')
elif num == 1:
  print('pon')
elif num == 6:
  print('pon')
elif num == 8:
  print('pon')
elif num ==2:
  print('hon')
elif num == 4:
  print('hon')
elif num==5:
  print('hon')
elif num==7:
  print('hon')
elif num==9:
  print('hon')
for i in range(1000):   
print "Hello World" 

### FIXED CODE ###

for i in range(1000):
    print 'Hello World'
import sys

for line in sys.stdin:
    a,b,c,d,e,f= map(int,line.split())
    z=a*e-b*d
    if(z!=0):
        x=(c*e-b*f)/z
        y=(a*f-c*d)/z
    print("{0:.3f} {1:.3f)".format(x+0, y+0))

### FIXED CODE ###

while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break
s = input()
ans = 0
for i in range len(s):
  if(s[i] == '+'):
    ans += 1
  else:
    ans -= 1
print(ans)

### FIXED CODE ###

s = input()
ans = 0
for i in range(len(s)):
  if(s[i] == '+'):
    ans += 1
  else:
    ans -= 1
print(ans)
import sys
N, M = map(int, input().split())
A = list(map(int, input().split()))
card = [ list(map(int, i.rstrip().split())) for i in sys.stdin.readlines()]
card = sorted(card, key=lambda x:x[1], reverse=True)
A = sorted(A)
i = 0
for b, c in card:
  for _ in range(b):
    if A[i] >= c:
      break
    else:
      A[i] = c
      i += 1
print(sum(A))

### FIXED CODE ###

import sys
N, M = map(int, input().split())
A = list(map(int, input().split()))
card = [ list(map(int, i.rstrip().split())) for i in sys.stdin.readlines()]
card = sorted(card, key=lambda x:x[1], reverse=True)
A = sorted(A)
i = 0
for b, c in card:
  for _ in range(b):
    if i >= N:
      break
    elif A[i] >= c:
      break
    else:
      A[i] = c
      i += 1
print(sum(A))
k,n=map(int,input().split())
A-list(map(int,input().split()))
ans=-1
for i in range(n-1):
  ans=max(ans,A[i+1]-A[i])
print(sum(A)- max(ans,k-(A[n-1]-A[0])))

### FIXED CODE ###

k,n=map(int,input().split())
A=list(map(int,input().split()))
ans=-1
for i in range(n-1):
  ans=max(ans,A[i+1]-A[i])
print(k- max(ans,k-(A[n-1]-A[0])))
import collections as col
from collections import defaultdict as dd

d=dd(list)

N,M=map(int, input().split())
p=[-1]*N
cnt=[0]*N

for _ in range(M):
    i,j=map(int, input().split())
    if i>j:
        i,j=j,i
    d[i].append(j)

for i in d:
    for j in d[i]:
        print(i,j)
        if p[j-1]!=-1:
            if p[i-1]==-1:
                p[i-1]=j
                cnt[p[j-1]]+=1
            continue
        if p[i-1]==-1:
            p[j-1]=i
            cnt[i]+=1
        else:
            p[j-1]=p[i-1]
            cnt[p[i-1]]+=1

cnt.sort(reverse=True)
print(cnt[0]+1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:
        return
    
    if rank[a]<rank[b]:
        par[a]=b
        rank[b]+=rank[a]
        rank[a]=rank[b]
    else:
        par[b]=a
        rank[a]+=rank[b]
        rank[b]=rank[a]

    return

def chk(a,b):
    if par[a]==par[b]:
        print('Yes')
    else:
        print('No')

    return

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

par=(list(range(N+1)))
rank=[1]*(N+1)

for _ in range(M):
    A,B=map(int, input().split())
    union(A,B)

print(max(rank))
X=input()
if X>=400 and X<=599:
    print(8)
if X>=600 and X<=799:
    print(7)
if X>=800 and X<=999:
    print(6)
if X>=1000 and X<=1199:
    print(5)
if X>=1200 and X<=1399:
    print(4)
if X>=1400 and X<=1599:
    print(3)
if X>=1600 and X<=1799:
    print(2)
if X>=1800 and X<=1999:
    print(1)

### FIXED CODE ###

X=int(input())
if X>=400 and X<=599:
  print('8')
if X>=600 and X<=799:
  print('7')
if X>=800 and X<=999:
  print('6')
if X>=1000 and X<=1199:
  print('5')
if X>=1200 and X<=1399:
  print('4')
if X>=1400 and X<=1599:
  print('3')
if X>=1600 and X<=1799:
  print('2')
if X>=1800 and X<=1999:
  print('1')
N, K= map(int, input().split())
h = list(map(int, input().split()))
import numpy as np
dp = np.full((N+1, K+1), np.inf, dtype=float)
dp[1] = np.zeros(K+1)
for i in range(1, N):
    k = 1
    while i >= k >= 0:
        dp[i+1][k] = abs(h[i] - h[i - k]) + min(dp[i + 1 - k])
        k += 1
print(int(min(dp[N])))

### FIXED CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*(N+1)
for i in range(1, N):
    dp[i+1] = min(
        [
            abs(h[i]-h[i-k]) + dp[i+1-k]
            for k in range(1, min(K, i)+1)
        ]
    )
print(dp[N])
data = [input() for i in range(2)]

if data[0]>=3200:
  print(data[1])

else:
  print("red")

### FIXED CODE ###

n=int(input())
s=input()
print(s if n>=3200 else 'red')
K = input()

try:
   if 0 > int(K) or int(K) >= 100:
      print("K's value must be over 1 and under 100")
      exit()
except ValueError:
   print("K's value must be integer")
   exit() 

S = input()
  if 1 > len(S) or 100 < len(S):
    print("S's length must be over 1 and under 100")
    exit()
   
  if len(S) <= int(K):
    print(S)
  else:
  S = S[:int(K)]
  S += '...'
  print(S)


### FIXED CODE ###

K = input()
S = input()

   
if len(S) <= int(K):
  print(S)
else:
  S = S[:int(K)]
  S += '...'
  print(S)
from collections import deque

# 上下左右1マスを検索するために必要とする
dis_x = [1, 0, -1, 0]
dis_y = [0, 1, 0, -1]

# 迷路の縦幅,横幅
max_h, max_w = map(int, input().split())

s = []
for _ in range(max_h):
    line = input()
    # 横1マスを壁でPadding. これでindex out of boundを防ぐ
    s.append(list("#{}#".format(line)))

# 縦1マスを壁でPadding. これでindex out of boundを防ぐ
s = [list("#" * (max_w + 2))] + s + [list("#" * (max_w + 2))]
dist = [ [0] * (max_w + 2) for _ in range(max_h+2)]

queue = deque()
for i in range(1, max_h+1):
    for j in range(1, max_w+1):
        if s[i][j] == '#':
            queue.append((i, j))

while queue:
    # 先頭の値を取り出す
    h, w = queue.popleft()

    # 上下左右4マスに対し処理
    for i in range(4):

        # 移動距離
        dx, dy = dis_x[i], dis_y[i]

        # もし次のマスが通路かつ黒塗りが終わっていないなら
        if s[h+dy][w+dx] == '.' and target_count != 0:
            s[h+dy][w+dx] = '#'
            dist[h+dy][w+dx] = dist[h][w] + 1
            target_count -= 1

            queue.append((h+dy, w+dx))


print(max(max(l) for l in dist))

### FIXED CODE ###

from collections import deque

# 上下左右1マスを検索するために必要とする
dis_x = [1, 0, -1, 0]
dis_y = [0, 1, 0, -1]

# 迷路の縦幅,横幅
max_h, max_w = map(int, input().split())

s = []
for _ in range(max_h):
    line = input()
    # 横1マスを壁でPadding. これでindex out of boundを防ぐ
    s.append(list("#{}#".format(line)))

# 縦1マスを壁でPadding. これでindex out of boundを防ぐ
s = [list("#" * (max_w + 2))] + s + [list("#" * (max_w + 2))]
dist = [ [0] * (max_w + 2) for _ in range(max_h+2)]

queue = deque()
for i in range(1, max_h+1):
    for j in range(1, max_w+1):
        if s[i][j] == '#':
            queue.append((i, j))

while queue:
    # 先頭の値を取り出す
    h, w = queue.popleft()

    # 上下左右4マスに対し処理
    for i in range(4):

        # 移動距離
        dx, dy = dis_x[i], dis_y[i]

        # もし次のマスの黒塗りが終わっていないなら
        if s[h+dy][w+dx] == '.':
            s[h+dy][w+dx] = '#'
            dist[h+dy][w+dx] = dist[h][w] + 1

            queue.append((h+dy, w+dx))


print(max(max(l) for l in dist))