Harryxun/stf_run huggingface dataset:
n = int(input())
l = [int(input()) for _ in range(n)]
m = l.copy()
m = m[::-1]

for i in range(len(l)):
    num = m.pop()
    print(max(m))
    m.insert(0, num)

### FIXED CODE ###

n = int(input())
l = [int(input()) for _ in range(n)]
max_num = max(l)
second_num = sorted(l)[-2]

for i in range(n):
   if l[i] == max_num:
       print(second_num)
   else:
       print(max_num)
N = int(input())
a = list(int,map(input().split())
i = 0       
	for x,a in enumerate a:
         b=x+1
		if b%2!=0 and a%2!=0:
    		i+=1
print(i)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
i=0
for x,y in enumerate (a):
    b=x+1
    if b%2!=0 and y%2!=0:
        i+=1
print(i)
s = input()
n = int(s)

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9":
    n = n - (int(s[-1]) + 1)
    s = str(n)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))

### FIXED CODE ###

s = input()
n = int(s)

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9" and n >= 10:
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))
import collections

n, t = map(int, input().split())
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [collections.defaultdict(int) for _ in range(n + 1)]
dp[0][0] = 0
for i in sorted(range(n), key=lambda x: a[x]):
    for cur in dp[i]:
        dp[i + 1][cur] = max(dp[i + 1][cur], dp[i][cur])
        if cur < t:
            dp[i + 1][cur + a[i]] = max(dp[i + 1][cur + a[i]], dp[i][cur] + b[i])
print(max(dp[n].values()))

### FIXED CODE ###

import collections

n, t = map(int, input().split())
tpls = list(sorted(tuple(map(int, input().split())) for _ in range(n)))
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = tpls[i]

dp = [[0] * (t + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(t):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        k = min(t, j + a[i])
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + b[i])
print(max(map(max, dp)))
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*n

def dfs(node, cml):
    visited[node] = True
    
    if adjList[node]:
        for ngh in adjList[node]:
            if not visited[ngh]:
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i]:
        ca = dfs(i, 1)
        mca = max(mca, ca)

print(mca)
    
    

### FIXED CODE ###

from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

dp = [-1]*n

def root(x):
    if dp[x] < 0:
        return x
    return root(dp[x])

def unite(x, y):
    rx = root(x)
    ry = root(y)
    
    if rx == ry:
        return False
        
    if dp[rx] > dp[ry]:
        rx,ry = ry,rx
        
    dp[rx] += dp[ry]
    dp[ry] = rx
    return True

def size(x):
    return -dp[root(x)]

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    unite(a,b)
    
ans = 0
for i in range(n):
    ans = max(ans, size(i))
    
print(ans)
import numpy as np
import math
import itertools

D, G = tuple(map(int, input().split()))

p_c_list = np.array([tuple(map(int, [100 * (i + 1)] + input().split())) for i in range(D)])
summary = []

masks = itertools.product([False, True], repeat=len(p_c_list))

ret = np.inf
for mask in masks:
  maskedarr = p_c_list[np.array(mask), :]
  comp_sum = (maskedarr[:, 0] * maskedarr[:, 1] + maskedarr[:, 2]).sum()
  suc_num = maskedarr[:, 1].sum()
  if comp_sum < G:
    amari = (G - comp_sum) / p_c_list[~np.array(mask), 0][-1]
    if amari < p_c_list[~np.array(mask), 1][-1]:
      if ret > suc_num + amari:
        ret = suc_num + amari
    else:
      continue
      
print(int(ret))
  



### FIXED CODE ###

import numpy as np
import itertools
import math

D, G = tuple(map(int, input().split()))

p_c_list = np.array([tuple(map(int, [100 * (i + 1)] + input().split())) for i in range(D)])

masks = itertools.product([False, True], repeat=len(p_c_list))

ret = np.inf
for mask in masks:
  maskedarr = p_c_list[np.array(mask), :]
  comp_sum = (maskedarr[:, 0] * maskedarr[:, 1] + maskedarr[:, 2]).sum()
  suc_num = maskedarr[:, 1].sum()
  if comp_sum < G:
    amari = (G - comp_sum) / p_c_list[~np.array(mask), 0][-1]
    if amari < p_c_list[~np.array(mask), 1][-1]:
      if ret > suc_num + amari:
        ret = suc_num + amari
    else:
      continue
  elif suc_num < ret:
    ret = suc_num
  else:
    continue
    
print(int(math.ceil(ret)))
S = int(input.())

h = S // 3600
m = S // 60 % 60
s = S % 60

print('{0}:{1}:{2}'.format(0, 1, 2))

### FIXED CODE ###

S = int(input())

h = S // 3600
m = S // 60 % 60
s = S % 60

print('{0}:{1}:{2}'.format(h, m, s))
a=input().split()
b=input().split()
print("YES" if a[0]==b[2] and a[1]==b[1] and a[2]==b[0] else "NO")

### FIXED CODE ###

a=input()
b=input()
print("YES" if a[0]==b[2] and a[1]==b[1] and a[2]==b[0] else "NO")
x,y = map(int,input())
print(int(x+y/2))

### FIXED CODE ###

x,y = map(int,input().split())
print(int(x+y/2))
x = int(input())
for a in range(-10000, 10000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == x:
            print(a, b)
            quit()

### FIXED CODE ###

s = input()
print('ABC' if s == 'ARC' else 'ARC')
s = input()
n = len(s)
for i in range(n-1):
    a = s[i:i+2]
    if i != n-2:
        b = s[i:i+3]
    if a[0] == a[1]:
        print(i+1,i+2)
        break
    if b[0] == b[2] or b[1] == b[2]:
        print(i+1,i+3)
        break
    if i == n-2:
        print(-1,-1)

### FIXED CODE ###

s = input()
n = len(s)
for i in range(n-1):
    if s[i] == s[i+1]:
        print(i+1,i+2)
        break
    if i != n-2:
        if s[i] == s[i+2] or s[i+1] == s[i+2]:
            print(i+1,i+3)
            break
    if i == n-2:
        print(-1,-1)
N = int(input())
S = input()
if(N % 2 == 1):
    print("No")
    exit()
for i in range(N//2):
    if(S[i] != S[i+3]):
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

N = int(input())
S = input()
if(N % 2 == 1):
    print("No")
    exit()
m = N//2
for i in range(m):
    if(S[i] != S[i+m]):
        print("No")
        exit()
print("Yes")
import sys

sys.setrecursionlimit(100000)

def solve(prev, r, dic):
    d = 0
    t = r
    if r in dic:
        for vtx, cost in dic[r]:
            if vtx == prev:
                continue
            d1, t1 = solve(r, vtx, dic)
            d1 += cost
            if d < d1:
                d = d1
                t = t1
    return d, t

line = input()
n = int(line)
edge = {}
for _ in range(0, n - 1):
    line = input()
    s, t, d = list(map(int, line.split()))
    if s not in edge:
        edge[s] = [[t, d]]
    else:
        edge[s] += [[t, d]]
    if t not in edge:
        edge[t] = [[s, d]]
    else:
        edge[t] += [[s, d]]
r1, t1 = solve(-1, 0, edge)
r2, t2 = solve(-1, t1, edge)
print(r2)


### FIXED CODE ###

def solve(prev, r, dic):
    d = 0
    t = r
    stack = []
    stack += [[prev, r, d]]
    while stack:
        prev, r, d1 = stack.pop(-1)
        if r in dic:
            for vtx, cost in dic[r]:
                if vtx == prev:
                    continue
                stack += [[r, vtx, d1 + cost]]
                if d < d1 + cost:
                    d = d1 + cost
                    t = vtx
    return d, t

line = input()
n = int(line)
edge = {}
for _ in range(0, n - 1):
    line = input()
    s, t, d = list(map(int, line.split()))
    if s not in edge:
        edge[s] = [[t, d]]
    else:
        edge[s] += [[t, d]]
    if t not in edge:
        edge[t] = [[s, d]]
    else:
        edge[t] += [[s, d]]
r1, t1 = solve(-1, 0, edge)
r2, t2 = solve(-1, t1, edge)
print(r2)
# -*- coding: utf-8 -*-

def main():

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

    listNotP = []

    if N == 0:
        ans = 0

    for i in range(1, 101):
        if i not in p:
            listNotP.append(i)

    listNotP.sort()

    for i in range(len(listNotP) - 1):
        if abs(listNotP[i] - X) < abs(listNotP[i + 1] - X):
            ans = listNotP[i]
            break

        elif abs(listNotP[i] - X) == abs(listNotP[i + 1] - X):
            ans = listNotP[i]
            break

    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-

def main():

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

    for i in range(101):
        if (X - i) not in p:
            ans = X - i
            break

        elif (X + i) not in p:
            ans = X + i
            break

    print(ans)


if __name__ == "__main__":
    main()
n,q=map(int,input().split())
s=list(input())

count=0


ans=[0 for i in range(n+2)]
for i in range(n-1):
  if s[i]+s[i+1]=='AC':
    count+=1
    ans[i+1]=count
  else:
    ans[i+1]=count
ans[n]=ans[n-1]
ans[n+1]=ans[n]

print(*ans)

for i in range(q):
  sita,ue=map(int,input().split())
  if s[ue-1]=='A' and s[ue]=='C':
    print(ans[ue]-ans[sita-1]-1)
  
  else:
    print(ans[ue]-ans[sita-1])
    
  

  


### FIXED CODE ###


n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])
S = input()
K = int(input())

if len(S) <= K:
    print(S)
else:
    s = S[0:K]
    s1 = s + '...'
    print(s1)

### FIXED CODE ###

K = int(input())
S = input()


if len(S) <= K:
    print(S)
else:
    s = S[0:K]
    s1 = s + '...'
    print(s1)
#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

#2Lあたり
Q1,H1,S1 = 8*Q,4*H,2*S
S = min(Q1,H1,S1)

if 2*S>D:
    cnt_A = N//2
    cnt_B = N%2
    pay = a*cnt_A + (cnt_B/B)*(b/(2/B))
else:
    pay = (N//A) * (a/(2/A))
print(int(pay))

### FIXED CODE ###

#A - Ice Tea Store
Q,H,S,D = map(int,input().split())
N = int(input())

Q1,H1 = 4*Q,2*H
S = min(Q1,H1,S)

if 2*S>D:
    cnt_2 = N//2
    cnt_1 = N%2
    pay = D*cnt_2 + S*cnt_1
else:
    pay = N * S
print(pay)
reina@v157-7-237-130:~/magic/kyogi/Atcoder/abc/b101_125/b106$ cat ./c1.py
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
p=5000000000000000
s=input()
n=int(input())

chk=1
ans=f=0
for i in s:
    chk=1
    if i=="1": 
        ans+=1
        continue
    for j in range(p-1):
        chk*=int(i)
        if ans+chk>=p:
            print(i)
            f=1
            break
    ans+=chk
    if f==1: break
if f==0: print(s[-1])

### FIXED CODE ###

s=input()
k=int(input())
x=-1
y=""
for a,i in enumerate(s):
    if i!="1":
        x=a
        y=i
        break

if x!=-1 and x+1<=k: print(y)
else: print(1)
H, W, K = map(int, input().split())
lis = []
ans = 0
for i in range(H):
  lis.append(list(map(int, input().split())))
for i in range(1<<H):
  for j in range(1<<W):
    cnt = 0
    for p in range(H):
      for q in range(W):
        if (i>>p) & 1:
          continue
        if (j>>q) & 1:
          continue
        if lis[p][q] == "#":
          cnt += 1
    if cnt == K:
      ans += 1
print(ans)

### FIXED CODE ###

H, W, K = map(int, input().split())
lis = []
ans = 0
for i in range(H):
  lis.append(list(input()))
for i in range(1<<H):
  for j in range(1<<W):
    cnt = 0
    for p in range(H):
      for q in range(W):
        if (i>>p) & 1:
          continue
        if (j>>q) & 1:
          continue
        if lis[p][q] == "#":
          cnt += 1
    if cnt == K:
      ans += 1
print(ans)
n, a, b = map(int, input().split())
MOD = 10**9 + 7

fact = [0] * (n+1)
inv_fact = [0] * (n+1)

fact[0] = 1
for i in range(1, n+1):
    fact[i] = fact[i-1] * i % MOD

inv_fact[n] = pow(fact[n], MOD-2, MOD)
for i in range(n, 0, -1):
    inv_fact[i-1] = inv_fact[i] * i % MOD


def nCk(n, k):
    return (fact[n] * inv_fact[k] * inv_fact[n-k]) % MOD


ans = 0
for k in range(1, n+1):
    if k == a or k == b:
        continue
    ans += nCk(n, k) % MOD
    
print(ans % MOD)

### FIXED CODE ###

n, a, b = map(int, input().split())
MOD = 10**9 + 7

u = [1]
d = [1]
c = [1]
for i in range(1, b+1):
    u.append(u[-1] * (n-i+1) % MOD)
    d.append(d[-1] * i % MOD)
    # c.append(u[-1] // d[-1] % MOD)
    c.append(u[-1] * pow(d[-1], MOD-2, MOD) % MOD)

print((pow(2, n, MOD) - c[a] - c[b] - 1) % MOD)
n = int(input())
m = int(input())
l1 = []
for i in range (m):
    a1 = int(input())
    l1.append(a1)
s = sum(l1)
result = n - s
print(result)

### FIXED CODE ###

n, m = map(int, input().split())
ai = map(int, input().split())
li = map(int, list(ai))
s = sum(li)
r = (n - s)
if r >= 0:
    print(r)
else:
    print("-1")
import math

h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = h * w

if h == 1:
    print(math.ceil("1".count(s[0])/k))
    exit()

for i in range(2 ** (h-1)):
    ss = str(format(i,"b").zfill(h-1))
    cnt = 0
    zero = 0
    key = 1
    for j in range(len(ss)):
        if ss[j] == "0":
            zero += 1
    now = [0 for i in range(zerocnt+1)]

    for j in range(w):
        next = []
        num = 0
        for n in range(h):
            if s[n][j] == "1":
                num += 1
            if num > k:
                key = 0
            if n < h-1 and ss[n] == "0":
                next.append(num)
                num = 0
        next.append(num)
        
        keykey = 1
        for n in range(zero+1):
            if keykey:
                if now[n] + next[n] > k:
                    now = next
                    cnt += 1
                    keykey = 0
                else:
                    now[n] += next[n]
                    
    if key:ans = min(ans,cnt+zero)
print(ans)

### FIXED CODE ###

import math

h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = h * w

if h == 1:
    print(math.ceil("1".count(s[0])/k))
    exit()

for i in range(2 ** (h-1)):
    ss = str(format(i,"b").zfill(h-1))
    cnt = 0
    zerocnt = 0
    key = 1
    for j in range(len(ss)):
        if ss[j] == "0":
            zerocnt += 1
    now = [0 for i in range(zerocnt+1)]

    for j in range(w):
        next = []
        num = 0
        for n in range(h):
            if s[n][j] == "1":
                num += 1
            if num > k:
                key = 0
            if n < h-1 and ss[n] == "0":
                next.append(num)
                num = 0
        next.append(num)
  #        print(next,now)
        keykey = 1
        for n in range(zerocnt+1):
            if keykey:
                if now[n] + next[n] > k:
                    now = next
                    cnt += 1
                    keykey = 0
                else:
                    now[n] += next[n]
  #    print(now)
  #    print(ans,cnt,zerocnt)
    if key:ans = min(ans,cnt+zerocnt)
print(ans)
n = int(input())
array = [sorted(input()) for x in range(n)]
print(len(set(array)) )


### FIXED CODE ###

from collections import Counter

n = int(input())
array = sorted(["".join(sorted(input())) for x in range(n)])
counter = Counter(array)

res = 0
for key, value in counter.items():
    res += value*(value-1)//2
print(res)
a, b = map(int, input().split())
if (a*b) % 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
n = int(input())
if n=1:
  print('Hello World')
else:
  a = int(input())
  b = int(input())
  print(a+b)

### FIXED CODE ###

n = int(input())
if n==1:
  print('Hello World')
else:
  a = int(input())
  b = int(input())
  print(a+b)
#https://atcoder.jp/contests/abc154/tasks/abc154_c

n=int(input())
a=list(map(int,input().split()))
a.sort()

for i in range(n-1):
    if a[i]==a[i+1]:
        print("NO")
        exit()

print("YES")

### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()

if s==u:
    print(a-1,b)
else:
    print(a,b-1)
import numpy as np
N,M=map(int, input().split())
tabelist = np.zeros(N)
for i in range(N):
  c=list(map(int, input().split()))
  for k in range(1,c[0]+1):
    tabelist[c[k]-1] = tabelist[c[k]-1] + 1
#    print(i,k,tabelist)
print(len([1 for x in tabelist if x==N]))

### FIXED CODE ###

import numpy as np
N,M=map(int, input().split())
tabelist = np.zeros(M)
for i in range(N):
  c=list(map(int, input().split()))
  for k in range(1,c[0]+1):
    tabelist[c[k]-1] = tabelist[c[k]-1] + 1
#    print(i,k,tabelist)
print(len([1 for x in tabelist if x==N]))
x = int(input())
li = list(map(int, input()))
l = []
for i in range(len(li)):
    l.append(i+1-li[i])
print(min(l))

### FIXED CODE ###

x = int(input())
li = list(map(int, input().split()))
k = 1
s = 0
for i in range(len(li)):
    if k == li[i] :
        k += 1
        s += 1
    if i == len(li)-1 and k == 1:
        s = len(li) + 1
print(len(li)-s)
n = int(raw_input())
for i in range(1, n+1)
  if (i % 3 == 0 or i % 10 == 3)
    print (" %d" % i),

### FIXED CODE ###

n = int(raw_input())
print "",
for i in range(1, n+1):
  if i % 3 == 0:
    print "%d" % i,
  else:
    z = i
    while 1:
      if z % 10 == 3:
        print "%d" % i,
        break
      z /= 10
      if z == 0:
        break
M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d2=m: c+=1
print(c)

### FIXED CODE ###

M, D = map(int, input().split())
c=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1 = d%10
    d10 = d//10
    if d1>1 and d10>1 and d1*d10==m:
      c+=1
print(c)
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

S = input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
n = input()
 
INFTY = float('inf')
 
color = [0 for i in range(n)]
m = [[INFTY for i in range(n)] for j in range(n)]
d = [INFTY for i in range(n)]
k = [-1 for i in range(n)]
 
d[0] = 0
 
while 1:
    cost = INFTY
for i in range(n):
    if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i

if cost == INFTY:
    break
    
color[u] = 2
 
for v in range(n):
    if color[v] != 2 and m[u][v] != INFTY and m[u][v] < d[v]:
        d[v] = m[u][v]
        k[v] = u
        color[v] = 1
sum = 0
for i in range(n):
    if p[i] != -1:
        sum += m[i][k[i]]
return sum
 
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(n):
    if G[j] != -1:
        m[i][j] = G[j]

### FIXED CODE ###

n = int(raw_input())
 
INFTY = float('inf')
 
color = [0 for i in range(n)]
M = [[INFTY for i in range(n)] for j in range(n)]
d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]
 
def MST():
  d[0] = 0
 
  while True:
    cost = INFTY
    for i in range(n):
      if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i
 
    if cost == INFTY:
      break
     
    color[u] = 2
 
    for v in range(n):
      if color[v] != 2 and M[u][v] != INFTY and M[u][v] < d[v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1
 
  sum = 0
  for i in range(n):
    if p[i] != -1:
      sum += M[i][p[i]]
  return sum
 
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(n):
   if G[j] != -1:
     M[i][j] = G[j]
 
print MST()
# coding: utf-8
n,m=map(int,input().split())
data=[]
dic={}
muki={}
kita={}
for i in range(1,n+1):
    dic[i]=0
    muki[i]=[(-1,0)]
    kita[i]=0

def heiroCheck(moto,m):
    for i in muki[moto]:
        if i[0]!=m:
            if i[0]!=-1:
                heiroCheck(i[0],m)
        else:
            print('inf')
            exit()

for i in range(m):
    a,b,c=map(int,input().split())
    if muki[a][0]!=(-1,0):
        muki[a].append((b,c))
    else:
        muki[a]=[(b,c)]

for i in range(1,n+1):
    heiroCheck(i,i)

def check(moto):
    for p in muki[moto]:
        if kita[p[0]]==0 or dic[p[0]]<dic[moto]+p[1]:
            dic[p[0]]=dic[moto]+p[1]
            kita[p[0]]+=1
        if muki[p[0]][0][0]!=-1:
            check(p[0])
            
check(1)
print(dic[n])


### FIXED CODE ###

# coding: utf-8
n,m=map(int,input().split())
edge=[]
for i in range(m):
    a,b,c=map(int,input().split())
    edge.append((a-1,b-1,-c))
inf=99999999999999999999
d=[inf for i in range(n)]
d[0]=0
count=0
while count<n+1:
    count+=1
    if count==n:
        tmp=d[n-1]
    update=False
    for i in range(m):
        f,t,cost=edge[i]
        if(d[t]>d[f]+cost):
            d[t]=d[f]+cost
            update=True
    if count==n and tmp!=d[n-1]:
        print('inf')
        break
    if not update:
        print(-d[n-1])
        break
else:
    print(-d[n-1])
s = input()
x,y = map(int,input().split())
k = 0
data = [[],[]]
f = 0
p = 1
for s_ in s:
    if p==1 and s_=='F':
        x -= 1
        continue
    p = 0
    if s_ == 'T':
        if f:
            data[k].append(f)
        k = (k+1)%2
        f = 0
    else:
        f += 1
if f:
    data[k].append(f)

nx = sum(data[0])
ny = sum(data[1])

if nx<x or ny<y:
    print('No')
    exit()

dpx = [[0]*((nx+10)//2) for _ in range(len(data[0])+1)]
dpy = [[0]*((ny+10)//2) for _ in range(len(data[1])+1)]
x_zero = nx+5
y_zero = ny+5
dpx[0][x_zero] = 1
dpy[0][y_zero] = 1

for i in range(len(data[0])):
    for j in range(len(dpx[i])):
        if dpx[i][j]==1:
            dpx[i+1][j+data[0][i]] = 1
            dpx[i+1][j-data[0][i]] = 1

for i in range(len(data[1])):
    for j in range(len(dpy[i])):
        if dpy[i][j]==1:
            dpy[i+1][j+data[1][i]] = 1
            dpy[i+1][j-data[1][i]] = 1
if dpx[-1][x_zero+x]==1 and dpy[-1][y_zero+y]==1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

now=0
idx=-1
data=[[],[]]
cnt=0
for s in input():
    if s=='F':
        cnt+=1
    elif s=='T':
        if idx==-1:
            now+=cnt
            cnt=0
            idx=1
        elif idx==0:
            data[0].append(cnt)
            cnt=0
            idx=1
        elif idx==1:
            data[1].append(cnt)
            cnt=0
            idx=0
if idx==-1:
    now+=cnt
else:
    data[idx].append(cnt)
def solve(target,move):
    dp={0,}
    for m in move:
        dpc=dp.copy()
        dp=set()
        for k in dpc:
            dp|={k-m,k+m}
    if target in dp:
        return True
    return False
x,y=map(int,input().split())
x-=now
if solve(x,data[0]) and solve(y,data[1]):
    print('Yes')
else:
    print('No')
N, K = map(int, input().split())
S = input()
S = S + "8"

a = []
f = S[0]
l = 0
for i in range(1, N+1):
    #print(S[i])
    if f != S[i]:
        #a.append([l, i-1, int(f)])
        #a.append([i-l, int(f)])
        a.append(i-l)
        l = i
        f = S[i]
        
#print(a)

if S[0] == '0':
    a = [0] + a

#print(a[0:0+2*K+1])
SUM = sum(a[0:0+2*K+1])

MAX = max(0, SUM)
for i in range(1, len(a)//2+len(a)%2):
    if i % 2 == 0:
        #print(a[i:i+2*K+1])
        #print(a[i-2], a[i-1])
        #print(a[i+2*K-1], a[i+2*K])
        #print(sum(a[i:i+2*K+1]))
        #MAX = max(MAX, sum(a[i:i+2*K+1]))
        SUM = SUM-(a[i-2]+a[i-1])+(a[i+2*K-1]+a[i+2*K])
        MAX = max(MAX, SUM)

print(MAX)

### FIXED CODE ###


N, K = map(int, input().split())
S = input()
S = S + "8"

a = []
f = S[0]
l = 0
for i in range(1, N+1):
    if f != S[i]:
        a.append(i-l)
        l = i
        f = S[i]
        

if S[0] == '0':
    a = [0] + a

SUM = sum(a[0:0+2*K+1])

MAX = max(0, SUM)
for i in range(2, len(a)):
    if i % 2 == 0:
        try:
            SUM = SUM - (a[i-2]+a[i-1]) + (a[i+2*K-1]+a[i+2*K])
        except:
            try:
                SUM = SUM - (a[i-2]+a[i-1]) + (a[i+2*K-1])
            except:
                break
        
        MAX = max(MAX, SUM)


print(MAX)