Harryxun/stf_run huggingface dataset:
N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = P[:K]
ans = sum(memo)

for i in range(K, N):
    memo.pop(0)
    memo.append(P[i])
    if sum(memo) > ans:
        ans = memo

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = sum(P[:K])
ans = memo

for i in range(K, N):
    memo = memo - P[i-K] + P[i]
    ans = max(ans, memo)

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))
N, Q = [int(n) for n in input().split()]

tree_list = [[] for _ in range(N)]
count_list = [0] * N

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

#print(tree_list)
#print(count_list)

for j in range(Q):
    p, x = [int(n) for n in input().split()]

    def func(pn, xn):
        count_list[pn] += xn
        if not tree_list[pn]:
            return
        for k in tree_list[pn]:
            func(k, xn)

    func(p-1, x)
    
#print(count_list)

print(*count_list)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N, Q = [int(n) for n in input().split()]
tree_list = [[] for _ in range(N)]

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

score_list = [0] * N
for j in range(Q):
    p, x = [int(n) for n in input().split()]
    score_list[p-1] += x

reached = [False] * N
def dfs(v):
    reached[v] = True
    for next_v in tree_list[v]:
        if reached[next_v] == True:
            continue
        score_list[next_v] += score_list[v]
        dfs(next_v)
dfs(0)
print(*score_list)
r = input()
g = input()
print(2* g - r)

### FIXED CODE ###

r = int(input())
g = int(input())

print(2* g - r)
while 1:
    N = int(input())
    a = 0
    lst = []
    for i in range(N):
        lst.append(str(raw_input()))
    M = int(input())
    for j in range(M):
        T = str(raw_input())
        if (T in lst) == True:
            if a == 0:
                a = 1
                print "Opened by " + T
            else:
                a = 0
                print "Closed by " + T
        else:
            print "Unknown " + T
        

### FIXED CODE ###

N = int(input())
a = 0
lst = []
for i in range(N):
    lst.append(str(raw_input()))
M = int(input())
for j in range(M):
    T = str(raw_input())
    if (T in lst) == True:
        if a == 0:
            a = 1
            print "Opened by " + T
        else:
            a = 0
            print "Closed by " + T
    else:
        print "Unknown " + T
S = list(input())
result = 0
for s in S:
    if s == ‘+’:
        result += 1
    else:
        result -= 1
print(result)


### FIXED CODE ###

S = list(str(input()))
result = 0
for s in S:
    if s == '+':
        result += 1
    else:
        result -= 1
print(result)
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    n = int(read())
    al = [[] for _ in range(n)]
    e = [(-1, -1) for _ in range(n - 1)]
    for i in range(n - 1):
        a, b = [int(j) - 1 for j in read().split()]
        al[a].append(b)
        al[b].append(a)
        e[i] = (a, b)
    k = max(map(len, al))
    print(k)
    c = [{i + 1 for i in range(k)} for _ in range(n)]
    for i in range(n - 1):
        a, b = e[i]
        ci = min(c[a] & c[b])
        print(ci)
        c[a].remove(ci)
        c[b].remove(ci)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque
from operator import itemgetter

def read():
    return sys.stdin.readline().rstrip()

def main():
    n = int(read())
    al = [[] for _ in range(n)]
    e = dict()
    for i in range(n - 1):
        a, b = [int(j) - 1 for j in read().split()]
        al[a].append(b)
        al[b].append(a)
        e[(a, b)] = i
    v, k = 0, 0
    for i in range(n):
        if len(al[i]) > k:
            v = i
            k = len(al[i])
    print(k)
    sn = deque([(v, 0)])
    sd = set()
    ce = dict()
    while sn:
        v, cv = sn.popleft()
        sd.add(v)
        ci = 1
        for vn in al[v]:
            if vn in sd:
                continue
            if ci == cv:
                ci += 1
            if (v, vn) in e:
                ce[(v, vn)] = ci
            else:
                ce[(vn, v)] = ci
            sn.append((vn, ci))
            ci += 1
    for k, _ in sorted(e.items(), key=itemgetter(1)):
        print(ce[k])

if __name__ == '__main__':
    main()
A = list(map(int, input().split())) 

ans=0
if A[0]<A[3]:
  ans = A[0]
else:
  ans = A[3]
  print(ans)
  
print(ans-(A[3]-A[0]-A[1])

### FIXED CODE ###

A = list(map(int, input().split()))
 
if A[0]>=A[3]:
  print(A[3])
else:
  if A[0]+A[1]>=A[3]:
    print(A[0])
  else:
    print(A[0]-A[3]+A[0]+A[1])
N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

"""
・あるボールから（p,q）の移動で別のボールに移れるならコストが０、そうでなければ１
　→あるボールの位置(x,y) + (p,q) の位置にボールがあるかどうか、全てのボールについて確認する。なければコスト＋１
・p,qの選び方は、全ボールの間隔を試すと行けそう(N <= 50 なので間に合いそう)

"""


pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            # 同じ間隔（同じp,qのパターン）が起こりうるのでdictで管理するほうがいいかも
            pq.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))

set_xy = set(xy)
ans = N
for p,q in pq:
    cost = 0
    for x,y in xy:
        if  (x+p, y+q) not in set_xy:
            cost += 1

    ans = min(ans, cost)

print(cost)

### FIXED CODE ###



N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]

pq = []
for i in range(N):
    for j in range(N):
        if i != j:
            pq.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))


ans = N
for p,q in pq:
    cost = 0
    for x,y in xy:
        if  (x+p, y+q) not in xy:
            cost += 1

    ans = min(ans, cost)

print(ans)
a = [(int(i) for i in input().split()) if i > 0 else break]
for i in range(0,len(a)):
    print('Case ', i+1, ': ', a[i], sep='')

### FIXED CODE ###

a =[]
x = 1
while x > 0:
    x = int(input())
    a.append(x)
for i in range(0,len(a)-1):
    print('Case ',i+1,': ',a[i],sep='')
y = x^3
print(y)


### FIXED CODE ###

x = int(input())
print(x*x*x)
N = [int(i) for i in input().split()]
K = [int(i) for i in input().split()]
s = 0
c = 1
for i in K:
	if (i + s) <= N[1]
  		c += 1
      	s += i + s
	else
    	break
print(c)


### FIXED CODE ###

N = [int(i) for i in input().split()]
K = [int(i) for i in input().split()]
s = 0
c = 1
for i in K:
    s += i
    if s > N[1]:
        break
    else:
        c += 1
print(c)
def popcount(x):
  r, q = 0, x
  while x:
    r += 1
    x &= x - 1
  return r, q
 
n = int(input())
r = range(n)
a = [[0, 0] for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y] |= 1 << (x - 1)
l = (1 << n) - 1 
b = sorted(map(popcount, range(1, l + 1)))
ans = next(i for i, x in reversed(b)
           if all(a[j][0] & x == a[j][1] & l - x == 0 for j in r if x >> j & 1)) 
print(ans)


### FIXED CODE ###

from itertools import combinations

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)

fail = lambda x: (not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x))

while n and all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)
n,m,k = map(int, input().split())
ln = list(map(int, input().split()))
lm = list(map(int, input().split()))

def csum(l,ll):
    s = 0
    res = [0] * ll
    for i in range(ll):
        s += l[i]
        res[i] = s
    return res

csln = csum(ln,n)
cslm = csum(lm,m)

import numpy as np

lk = [k-x for x in csln if k-x >=0]
res = np.searchsorted(np.array(cslm), np.array(lk), side='right').
rmax = 0
for i,j in zip(range(1,len(lk)+1), res):
    rmax = max(rmax, i+j)
print(int(rmax))

### FIXED CODE ###

n,m,k = map(int, input().split())
ln = list(map(int, input().split()))
lm = list(map(int, input().split()))

def csum(l,ll):
    s = 0
    res = [0] * ll
    for i in range(ll):
        s += l[i]
        res[i] = s
    return res

csln = csum(ln,n)
cslm = csum(lm,m)

import numpy as np

lk = [k] + [k-x for x in csln if k-x >=0]
res = np.searchsorted(np.array(cslm), np.array(lk), side='right')
rmax = 0
for i,j in zip(range(len(lk)+1), res):
    rmax = max(rmax, i+j)
print(rmax)
from sys import stdin
from heapq import heappush, heappop

class Dijkstra:
    def __init__(self, N):
        self.N = N # #vertices
        self.E = [[] for _ in range(N)]

    def add_edge(self, init, end, weight, undirected=False):
        self.E[init].append((end, weight))
        if undirected: self.E[end].append((init, weight))
    
    def distance(self, s):
        INF = float('inf')
        E, N = self.E, self.N
        self.dist = dist = [INF] * N # the distance of each vertex from s
        self.prev = prev = [-1] * N # the previous vertex of each vertex on a shortest path from s
        dist[s] = 0
        n_visited = 1 # #(visited vertices)
        heap = []
        heappush(heap, (0, s))
        while heap:
            d, v = heappop(heap)
            if dist[v] < d: continue
            for u, c in E[v]:
                temp = d + c
                if dist[u] > temp:
                    dist[u] = temp; prev[u] = v
                    heappush(heap, (temp, u))
            n_visited += 1
            if n_visited == N: break
        return dist
    
    def shortest_path(self, t):
        P = []
        prev = self.prev
        while True:
            P.append(t)
            t = prev[t]
            if t == -1: break
        return P[::-1]


def get_result(data):
    N, M = data[0]
    A = data[1:]
    solver = Dijkstra(N)
    for val in A:
        solver.add_edge(val[0]-1, val[1]-1, undirected=True)
    _, prev = solver.distance(0)
    print('Yes')
    for p in prev[1:]:
        print(p + 1)
    return None

if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    get_result(data)

### FIXED CODE ###

from collections import deque

def bfs(E, s):
    N = len(E)
    order = [-1] * N # a bfs ordering of each vertex
    parent = [-1] * N # parent of each vertex in the bfs search tree
    depth = [-1] * N # the depth of each vertex
    q = deque([(s, -1, 0)]) # (vertex, parent, depth)
    num = 0 # current ordering
    while q:
        v, p, d = q.popleft()
        if order[v] < 0: # visited v for the first time
            order[v] = num; parent[v] = p; depth[v] = d
            num += 1
            for u in E[v]:
                if order[u] >= 0: continue
                q.append((u, v, d+1))
    return order, parent, depth

N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    E[a-1].append(b-1); E[b-1].append(a-1)
_, par, _ = bfs(E, 0)
print('Yes')
for p in par[1:]: print(p + 1)
N = int(input())
cnt = 0
for i in range(0, N):
    if int(input()) != 1:
        cnt = cnt + 1

if N % 2 == 0:
    if cnt % 2 == 0:
        print('second')
    else:
        print('first')
else:
    if cnt % 2 == 0:
        print('first')
    else:
        print('second')

### FIXED CODE ###

N = str(input())

ans = 0
for i in range(0, 4):
    if N[i] == '2':
        ans = ans + 1
        
print(ans)
a=int(input())
b=1.08
d=int(a/b)
d=d-1
hoge=0
for i in range(4):
  if(int(d*c)==a and hoge==0)
    print(a)
    hoge=1
  d=d+1
if(hoge==0):
  print(":(")

### FIXED CODE ###

a=int(input())
b=1.08
d=int(a/b)
d=d-1
hoge=0
for i in range(4):
  if(int(d*b)==a and hoge==0):
    print(d)
    hoge=1
  d=d+1
if(hoge==0):
  print(":(")
A, B = map(int, input().split())

if A >= 13:
  print(B)
elif A >= 6 and A <= 12:
  print(int(B/2))
elif A <= 5
  print(0)

### FIXED CODE ###

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

if A >= 13:
  print(B)
elif A >= 6 and A <= 12:
  print(int(B/2))
elif A <= 5:
  print(0)
s = list(map(int, input().split()))
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

for i in t:
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))


### FIXED CODE ###

S = input()
s = list(map(int, S))
t = s.copy()
n = len(s)
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in range(n-1):
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1
    
for i in range(n-1):
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))
N = int(input())
a = []
a.append(map(int, input().split()))



for i in range(N):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    print(a) 


### FIXED CODE ###

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


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))
import sys

import numpy as np

h, w = list(map(int, input().split()))
field = [[int(c == '.') for c in line.rstrip()] for line in sys.stdin]
field = np.array(field)


def cumsum(f):
    result = np.zeros((h, w), dtype=np.int)
    for i, row in enumerate(f):
        ri = result[i]
        tmp = 0
        for j, c in enumerate(row):
            tmp = (tmp + c) * c
            ri[j] += tmp
        tmp = 0
        for j, c in reversed(list(enumerate(row))):
            tmp = (tmp + c) * c
            ri[j] += tmp
    return result


ans = cumsum(field)
ans += cumsum(field.T).T

print(ans.max() - 3)


### FIXED CODE ###

import sys

h, w = list(map(int, input().split()))
field = [line.rstrip() for line in sys.stdin]

l = [[0] * (w + 2) for _ in [0] * (h + 2)]
r = [[0] * (w + 2) for _ in [0] * (h + 2)]
u = [[0] * (w + 2) for _ in [0] * (h + 2)]
d = [[0] * (w + 2) for _ in [0] * (h + 2)]

for i in range(1, h + 1):
    fi = field[i - 1]
    li = l[i]
    for j in range(1, w + 1):
        c = fi[j - 1]
        u[i][j] = u[i - 1][j] + 1 if c == '.' else 0
        li[j] = li[j - 1] + 1 if c == '.' else 0
for i in range(h, 0, -1):
    fi = field[i - 1]
    ri = r[i]
    for j in range(w, 0, -1):
        c = fi[j - 1]
        d[i][j] = d[i + 1][j] + 1 if c == '.' else 0
        ri[j] = ri[j + 1] + 1 if c == '.' else 0

ans = 0
for i in range(1, h + 1):
    li, ri, ui, di = l[i], r[i], u[i], d[i]
    ans = max(ans, max(li[j] + ri[j] + ui[j] + di[j] for j in range(1, w + 1)))
print(ans - 3)
#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
print(T)
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])

### FIXED CODE ###

#coding: utf-8
N, Q = map(int, input().split())
S = input()
T = [0]
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        T.append(T[i] + 1)
    else:
        T.append(T[i])
for j in range(Q):
    l, r = map(int, input().split())
    print(T[r-1] - T[l-1])
#include <stdio.h>

int main(void){
    int i, a, b, N, M, count[50];

    scanf("%d %d", &N, &M);

    for(i=0; i<M; i++){
        scanf("%d %d", &a, &b);
        count[a-1] += 1;
        count[b-1] += 1;
    }

    for (i = 0; i < N; i++)
    {
        printf("%d\n", count[i]);
    }
    

    return 0;
}

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    
    count = [0] * N

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        count[a] += 1
        count[b] += 1
    
    for i in range(N):
        print(count[i])


if __name__ == "__main__":
    main()
n = int(input())

num = n%10

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

### FIXED CODE ###

import sys

n = int(input())
 
num = n % 10
 
if num == 3:
  print('bon')
elif num==0 or num==1 or num==6 or num==8:
  print('pon')
else:
  print('hon')
import numpy as np
def distance():
    x1,x2,x3,x4 = map(float, input().split())
    n = (x3 - x1)**2 + (x4 - x2)**2
    ans = np.sqrt(n)
    print(ans)
    
if __name__ == '__main__':
    distance()


### FIXED CODE ###

import math

x1,x2,x3,x4 = map(float, input().split())
n = (x3 - x1)**2 + (x4 - x2)**2
ans = math.sqrt(n)
print(ans)
a,b=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])

### FIXED CODE ###

a,b=map(int,input().split())
s=input()
print(s[:b-1]+s[b-1].lower()+s[b:])
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(1,101)]
for p in P:
    all_l.remove(p)

ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    #print(diff,diff_now)
    memo = diff_now
    #print('memo:',memo,'diff:',diff)
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
#print(k_list)
int(max(k_list))

### FIXED CODE ###

x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(0,101)]
for p in P:
    all_l.remove(p)

kouho = x
for i in range(200):
    kouho1 = x-i
    kouho2 = x+i
    if kouho1 not in P:
        print(x-i)
        break
    elif kouho2 not in P:
        print(x+i)
        break
import sys
import numpy as np


def main(stdin):
    N, K, Q = stdin[:3]
    ans = np.full(N + 1, K - Q, dtype=np.int64)
    for i in stdin[3:]:
        ans[i] += 1
    ans = np.where(ans > 0, 'Yes', 'No')
    return ans[1:]


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8[:](i8[:],)')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    stdin = np.array([int(_) for _ in open(0).read().split()])
    print(*main(stdin), sep='\n')


### FIXED CODE ###

N, K, Q = [int(_) for _ in input().split()]
A = [int(input()) for _ in range(Q)]
s = [K - Q] * (N + 1)
for a in A:
    s[a] += 1
for i in range(1, N + 1):
    if s[i] > 0:
        print('Yes')
    else:
        print('No')
N = int(input())
*W, = map(int, input().split())

s1, s2 = 0, sum[W]
ans = sum[W]

for i in range(N):
  s1 += W[i]
  s2 -= W[i]
  ans = min(ans, abs(s1 - s2))
print(ans)

### FIXED CODE ###

N = int(input())
*W, = map(int, input().split())
 
s1, s2 = 0, sum(W)
ans = sum(W)
 
for i in range(N):
  s1 += W[i]
  s2 -= W[i]
  ans = min(ans, abs(s1 - s2))
print(ans)
N,K=list(map(int,input().split()))
X=list(map(int,input().split()))

P_list=[0]
N_list=[0]
zero_num=0

for x in X:
    if x < 0:
        N_list.append(-x)
    elif x == 0:
        zero_num=1
    else:
        P_list.append(x)

P_list.sort()
N_list.sort()
P_list,N_list

move=[]
for i in range(K+1):
    j=K-i
#     print(i,j)
    if i >= len(P_list) or j >= len(N_list):
        continue
    move_=min(2*P_list[i]+N_list[j],P_list[i]+2*N_list[j])
#     print(move_)
    move.append(move_)
print(min(move))

### FIXED CODE ###

N,K=list(map(int,input().split()))
X=list(map(int,input().split()))

P_list=[0]
N_list=[0]
zero_num=0

for x in X:
    if x < 0:
        N_list.append(-x)
    elif x == 0:
        zero_num=1
    else:
        P_list.append(x)
        
K=K-zero_num

P_list.sort()
N_list.sort()
P_list,N_list

move=[]
for i in range(K+1):
    j=K-i
#     print(i,j)
    if i >= len(P_list) or j >= len(N_list):
        continue
    move_=min(2*P_list[i]+N_list[j],P_list[i]+2*N_list[j])
#     print(move_)
    move.append(move_)
    
if len(move)==0:
    move.append(0)
    
print(min(move))
if __name__ == '__main__':
    num = int(input())
    # data = [int(input()) for i in range(num)]
    
    ans = 0
    for i in range(num):
        data = input()
        if int(data[-1]) % 2 == 1:
            ans += 1

    if ans+1 % 2 == 0:
        print('second')
    else:
        print('first')

### FIXED CODE ###

print(input().count('2'))
def roof(x):
    if x == int(x):
        return x
    else:
        return int(x)+1

def ans(n,a,b,h):
    
    m = max(h)

    M = roof(m / b)
    
    x = M
    y = 0
    
    if x == 1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())

print(int(ans(n,a,b,h))

### FIXED CODE ###

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

h = []

for i in range(N):
    h.append(int(input()))

def det(num):
    count = 0
    for i in range(N):
        H = h[i]-B*num
        count += max(0,H//(A-B) + min(1,H%(A-B)))
    if count <= num:
        return True
    else:
        return False

x = 1###False
y = max(h)###True

while y - x > 1:
    if det((x+y)//2):
        y = (x+y)//2
    else:
        x = (x+y)//2
    #print(x,y)

print(y)
def main():
    s = input()
    k = input()
    if(len(s)<k):
        print(s)
    else:
        print(s[0:k] + '...')
    
 
main()

### FIXED CODE ###

def main():
    K = int(input())
    S = input()
    if(len(S)<=K):
        print(S)
    else:
        print(S[0:K] + '...')
    
 
main()
n,m=map(int,input().split())
a=[]
for i in range(m):
	a.append(int(input()))
if a[0]!=1:
	a.insert(0,-1)
if a[-1]!=n-1:
	a.append(n+1)
b=[]
for i in range(len(a)-1):
	b.append(a[i+1]-a[i]-1)
	if a[i+1]-a[i]==1:
		print(0)
		exit()
def Fib(n, memo={}):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = Fib(n-1,memo)+Fib(n-2,memo)
        return memo[n]
ans=1
for i in range(len(b)):
	ans*=Fib(b[i])
	ans%=10**9+7
print(ans)
print(b)


### FIXED CODE ###

def Fib(n):
    a=[0,1,1]
    if n<=2:
    	return a[n]
    else:
    	for i in range(n-2):
    		a.append(a[i+1]+a[i+2])
    	return a[n]
n,m=map(int,input().split())
if m==0:
	print(Fib(n+1)%(10**9+7))
	exit()
a=[]
for i in range(m):
	a.append(int(input()))
if a[0]!=1:
	a.insert(0,-1)
if a[-1]!=n-1:
	a.append(n+1)
b=[]
for i in range(len(a)-1):
	b.append(a[i+1]-a[i]-1)
	if a[i+1]-a[i]==1:
		print(0)
		exit()
ans=1
for i in range(len(b)):
	ans*=Fib(b[i])
	ans%=10**9+7
print(ans)
n=int(input())
s=str(input())
slime_cnt=0

for i in range(n-1):
  if s[i]==s[i+1]:
    slime_cnt=slime_cnt
  if s[i]!=s[i+1]:
    slime_cnt+=1
if s[-1]==s[-2]:
  print(slime_cnt)
else:
  print(slime_cnt+1)

### FIXED CODE ###

N=int(input())
S=str(input())
cnt=1

for i in range(len(S)-1):
  if S[i]==S[i+1]:
    continue
  else:
    cnt+=1
print(cnt)
import collections
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    global maxPath
    global dp
    if dp[node]>=0:
        return dp[node] 
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i)+1)
    dp[node] = ans
    # maxPath = max(maxPath, ans) 
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


### FIXED CODE ###

import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)