Harryxun/stf_run huggingface dataset:
import bisect

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

Edge = [[] for _ in range(N)]
for _ in range(N-1):
    u,v = map(int,input().split())
    Edge[u-1].append(v-1)
    Edge[v-1].append(u-1)

visited = [False]*N
visited[0] = True
answer = [1]*N

def dfs(v, dp):
    for nv in Edge[v]:
        if visited[nv]:
            continue
        
        visited[nv] = True
        if A[nv]>dp[-1]:
            dp.append(A[nv])
            answer[nv] = len(dp)
            dfs(nv, dp)
            dp.pop()
        else:
            idx = bisect.bisect_left(dp, A[nv])
            temp = dp[idx]
            dp[idx] = A[nv]
            answer[nv] = len(dp)
            dfs(nv, dp)
            dp[idx] = temp
        
    return 

dfs(0, [A[0]])
answer[0] = 1
for a in answer:
    print(a)




### FIXED CODE ###

import bisect
import sys
sys.setrecursionlimit(10**9)

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

Edge = [[] for _ in range(N)]
for _ in range(N-1):
    u,v = map(int,input().split())
    Edge[u-1].append(v-1)
    Edge[v-1].append(u-1)

visited = [False]*N
visited[0] = True
answer = [1]*N

def dfs(v, dp):
    for nv in Edge[v]:
        if visited[nv]:
            continue
        
        visited[nv] = True
        if len(dp)==0 or A[nv]>dp[-1]:
            dp.append(A[nv])
            answer[nv] = len(dp)
            dfs(nv, dp)
            dp.pop()
        else:
            idx = bisect.bisect_left(dp, A[nv])
            temp = dp[idx]
            dp[idx] = A[nv]
            answer[nv] = len(dp)
            dfs(nv, dp)
            dp[idx] = temp
        
    return 

dfs(0, [A[0]])
answer[0] = 1
for a in answer:
    print(a)
import numpy as np

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

values = []
scores = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    values.append(tmp[0])
    scores.append(tmp[1:])
scores = np.array(scores)
values = np.array(values)

def df(arg, score, tmp,args):
    tmps = []
    if arg==N:
        if len(np.where(score>=X)[0]) == M:
            return tmp
        else:
            return 0
    check = df(arg+1, score, tmp, args)
    if check:
        if type(check)==list:
            tmps.extend(check)
        else:
            tmps.append(check)
    check = df(arg+1, score+scores[arg], tmp+values[arg], args+[arg])
    if check:
        if type(check)==list:
            tmps.extend(check)
        else:
            tmps.append(check)
    if tmps == []:
        return 0
    else:
        return tmps

tmp = df(0, np.zeros(M), 0, [])
if tmp != []:
    print(min(tmp))
else:
    print(-1)



### FIXED CODE ###

import numpy as np

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

values = []
scores = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    values.append(tmp[0])
    scores.append(tmp[1:])
scores = np.array(scores)
values = np.array(values)

def df(arg, score, tmp,args):
    tmps = []
    if arg==N:
        if len(np.where(score>=X)[0]) == M:
            return tmp
        else:
            return 0
    check = df(arg+1, score, tmp, args)
    if check:
        if type(check)==list:
            tmps.extend(check)
        else:
            tmps.append(check)
    check = df(arg+1, score+scores[arg], tmp+values[arg], args+[arg])
    if check:
        if type(check)==list:
            tmps.extend(check)
        else:
            tmps.append(check)
    if tmps == []:
        return 0
    else:
        return tmps

tmp = df(0, np.zeros(M), 0, [])
if tmp != 0:
    print(min(tmp))
else:
    print(-1)
n,m = map(int, input().split())
 
arS = [False] * (n+1)
arP = [False] * (n+1)
 
score = 0
penalty = 0

for i in range(m):
	id, res = input().split()
	id = int(id)
	if (res == "AC") and (arS[id]==False):
		arS[id] = True
		score = score+1
        penalty = penalty * arP[id]
	if (res == "WA"): 
		arP[id] = arP[id] + 1
        
print(score, penalty)

### FIXED CODE ###

n,m = map(int, input().split())
 
arS = [False] * (n+1)
arP = [False] * (n+1)
 
score = 0
penalty = 0

for i in range(m):
	id, res = input().split()
	id = int(id)
	if (res == "AC") and (arS[id]==False):
		arS[id] = True
		score = score+1
		penalty = penalty + arP[id]
	if (res == "WA"): 
		arP[id] = arP[id] + 1
        
print(score, penalty)
n,a,b=int(input().split())
print(min(a*n,b))

### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(b,a*n))
import collections
start = time.time()
n=int(input())
a=[input() for i in range(n)]
a_coll=dict(collections.Counter(a))
ans=0
for b in a_coll:
    if a_coll[b]%2==1:
        ans+=1
print(ans)


### FIXED CODE ###

import collections
n=int(input())
a=[input() for i in range(n)]
a_coll=dict(collections.Counter(a))
ans=0
for b in a_coll:
    if a_coll[b]%2==1:
        ans+=1
print(ans)
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    print(A)
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(A)
print(cnt)

### FIXED CODE ###

import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(cnt)
a = int(input())
b = int(input())

ans = max(a - 2*b, 0)

print(ans)


### FIXED CODE ###

a, b = map(int, input().split())

ans = max([a - 2*b, 0])

print(ans)
import sys


n = int(input())

for i in range(100):
    for j in range(100):
        if i * 4 + j * 7 == n:
            print("Yes")
            sys.exit(1)
print("No")




### FIXED CODE ###

import sys


n = int(input())

for i in range(100):
    for j in range(100):
        if i * 4 + j * 7 == n:
            print("Yes")
            sys.exit()
print("No")
import sys
import string

alphabets=list(string.ascii_lowercase)

s=input()

l=len(s)

hm = lambda a,string: sum([x==a for x in string])

for x in range(l-1):
  if s[x]==s[x+1]:
    print('{} {}'.format(x+1, x+2))
    sys.exit()

def func(r,s,n,m):
  if r==26:
    return print('-1 -1')
  else:
    if hm(alphabets[r],s[n:n+m])>m//2:
      print('{} {}'.format(n+1,n+m))
      sys.exit()
    return func(n+1,s,n,m)

for m in range(3,l,2):
  for n in range(l-m):
    func(0,s,n,m)

### FIXED CODE ###

import sys
import string
 
alphabets=list(string.ascii_lowercase)
 
s=input()
 
l=len(s)
 
hm = lambda a,string: sum([x==a for x in string])
 
for x in range(l-1):
  if s[x]==s[x+1]:
    print('{} {}'.format(x+1, x+2))
    sys.exit()
 
 
for n in range(l-3):
  for a in alphabets:
    if hm(a,s[n:n+3])> 1:
      print('{} {}'.format(n+1,n+3))
      sys.exit()
print('-1 -1')
n=int(input())
    for i in range(1,10):
        if n/i ==n//i and n//i<=9:
            print("Yes")
            exit()
    print("No")

### FIXED CODE ###

n=int(input())
for i in range(1,10):
    if n/i ==n//i and n//i<=9:
        print("Yes")
        exit()
print("No")
n, m = map(int, input().split())
d = {0: 1}
asum = 0
ans = 0
for a in map(int, input().split()):
    asum = (asum + a) % m
    if asum in d:
        ans += d[asum]
        d[asum] += 1
    else:
        d[asum] = 1
print(ans

### FIXED CODE ###

n, m = map(int, input().split())
d = {0: 1}
asum = 0
ans = 0
for a in map(int, input().split()):
    asum = (asum + a) % m
    if asum in d:
        ans += d[asum]
        d[asum] += 1
    else:
        d[asum] = 1
print(ans)
import sys
x = int(sys.stdin.readline())
a = 0.1
b = -10**5
while not a.is_integer():
  a = x-b**5
  a = a**0.2
  b += 1
print(int(a), b-1)


### FIXED CODE ###

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


x = ri()
for a in range(150):
    for b in range(-150, a):
        if a**5 - b**5 == x:
            print(a, b)
            exit()
import sys

sys.setrecursionlimit(10**8)

def find(x):	#xの根を返す
	global table
	global diff_weight
	
	if table[x] == x:
		return x
	else:
		diff_weight[x] += diff_weight[table[x]] #親の更新に伴う 重みの更新
		table[x] = find(table[x])	#親の更新(根を直接親にして参照距離を短く)
		return table[x]

def union(x,y,w):	#xとyを diff(x,y)=w で繋げる
	w = w - weight(y) + weight(x) 
	x = find(x)	
	y = find(y)
	
	if x == y:
		return
	
	if rank[x] < rank[y]:
		x,y = y,x
		w = -w
	
	table[y] = x
	diff_weight[y] = w
	
	if rank[x] == rank[y]:
			rank[y] += 1

def check(x,y): #xとyか繋がっているか -> return bool
	if find(x) == find(y):
		return True
	else:
		return False

def weight(x):
	find(x)	#経路圧縮
	return diff_weight[x]
		
def diff(x,y): # weight(y)-weight(x)  (繋がってる前提)
	return (weight(y) - weight(x))

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

table = [i for i in range(N)]	#木の親 table[x] == x なら根	
rank  = [1 for i in range(N)]	#木の長さ
diff_weight = [0 for i in range(N)]


for i in range(M):
	a,b,D = (map(int,input().split()))
	a -= 1
	b -= 1
	if check(a,b):
		if diff(a,b) != D:
			print ('table',table)
			print ('weight',diff_weight)
			print('No')
			sys.exit()
	else:
		union(a,b,D)
	print ('table',table)
	print ('weight',diff_weight)
	
	
print ('Yes')

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**8)

def find(x):	#xの根を返す
	global table
	global diff_weight
	
	if table[x] == x:
		return x
	else:
		root = find(table[x])
		diff_weight[x] += diff_weight[table[x]] #親の更新に伴う 重みの更新
		table[x] = root	#親の更新(根を直接親にして参照距離を短く)
		return table[x]

def union(x,y,w):	#xとyを diff(x,y)=w で繋げる
	w = w - weight(y) + weight(x) 
	x = find(x)	
	y = find(y)
	
	if x == y:
		return
	
	if rank[x] < rank[y]:
		x,y = y,x
		w = -w
	
	table[y] = x
	diff_weight[y] = w
	
	if rank[x] == rank[y]:
			rank[y] += 1

def check(x,y): #xとyか繋がっているか -> return bool
	if find(x) == find(y):
		return True
	else:
		return False

def weight(x):
	find(x)	#経路圧縮
	return diff_weight[x]
		
def diff(x,y): # weight(y)-weight(x)  (繋がってる前提)
	return (weight(y) - weight(x))

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

table = [i for i in range(N)]	#木の親 table[x] == x なら根	
rank  = [1 for i in range(N)]	#木の長さ
diff_weight = [0 for i in range(N)]


for i in range(M):
	a,b,D = (map(int,input().split()))
	a -= 1
	b -= 1
	if check(a,b):
		if diff(a,b) != D:
			print('No')
			sys.exit()
	else:
		union(a,b,D)
	
	
print ('Yes')
N,K=map(int,raw_input().split())
P=[]
minus=1000000
save=0

for i in range(N):
  P.append(raw_input())
  
P.sort();
K-=1;

for i in range(N):
  if i+K>N:
    break
  save=int(P[i+K])-int(P[i])
  if minus>save:
    minus=save
  
print minus

### FIXED CODE ###

N,K=map(int,raw_input().split())
P=[]
m=0;

for i in range(N):
  P.append(int(raw_input()))
  
P.sort()


print min(P[i+K-1]-P[i] for i in range(N-K+1))
import numpy as np
def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**6
fact, invfact = make_fact(U,MOD)

MOD = 10**9 + 7
X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
if (k < 0 or Y - r < 0):
    print(0)
else:
    print(fact[r] * invfact[r-k] % MOD * invfact[k] % MOD)


### FIXED CODE ###

import numpy as np
def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**6
MOD = 10**9 + 7
fact, invfact = make_fact(U,MOD)

X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
if (k < 0 or Y - r < 0):
    print(0)
else:
    print(fact[r] * invfact[r-k] % MOD * invfact[k] % MOD)
lis =[]
abc =[]
count = 0

N = int(input())
lis =[lis.append(input()) for _ in range(N)]

for i in lis:
    if any(i == j for j in abc):
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

### FIXED CODE ###

S,W = map(int,input().split())

if S > W:
    print('safe')
else:
    print('unsafe')
N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def g(l, cx, cy):
    H_max_l = set(H(cx, cy, x, y, h) for x, y, h in xyh if h == 0)
    h_max = min(H_max_l) if any(H_max_l) else 10**9
    
    TH = set(H(cx, cy, x, y, h) for x, y, h in l if h > 0)
    if len(TH) == 1:
        high = TH.pop()
        if high <= h_max:
            return high
    return -1



def f(l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            h = g(l, cx, cy)
            if h >= 0:
                return cx, cy, h

cx, cy, h = f(xyh)
print(cx, cy, h)


### FIXED CODE ###

N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def g(l, cx, cy):
    H_max_l = set(H(cx, cy, x, y, h) for x, y, h in l if h == 0)
    h_max = min(H_max_l) if any(H_max_l) else -1
    
    TH = set(H(cx, cy, x, y, h) for x, y, h in l if h > 0)
    if len(TH) == 1:
        high = TH.pop()
        if h_max == -1 or high <= h_max:
            return high
    return -1


def f(l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            h = g(l, cx, cy)
            if h > 0:
                return cx, cy, h

cx, cy, h = f(xyh)
print(cx, cy, h)
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()

s = S()
gx,gy = Is()
xlis,ylis = [],[]
x,y = 0,0
h = 0
for e in s:
    if e == "F":
        if h == 0:
            x += 1 
        else:
            y += 1 
    else:
        if h == 0:
            if x:
                xlis.append(x) 
        else:
            if y:
                ylis.append(y)
        x,y = 0,0
        h = not h
if h == 0:
    if x:
        xlis.append(x) 
else:
    if y:
        ylis.append(y)
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xmat = [[False]*16001 for i in range(len(xlis)+1)]
ymat = [[False]*16001 for i in range(len(ylis)+1)]
xmat[0][sx] = True
ymat[0][sy] = True
def xdp(i,d):
    if xmat[i][d]:
        return True
    if i == 0:
        return False
    xmat[i][d] = xdp(i-1,d + xlis[i-1]) or xdp(i-1,d - xlis[i-1])
    return xmat[i][d]
def ydp(i,d):
    if ymat[i][d]:
        return True
    if i == 0:
        return False
    ymat[i][d] = ydp(i-1,d + ylis[i-1]) or ydp(i-1,d - ylis[i-1])
    return xmat[i][d]
if xdp(len(xlis),gx) and ydp(len(ylis),gy):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()
 
s = S()
gx,gy = Is()
l = s.split("T")
for i in range(len(l)):
    l[i] = len(l[i])
xlis,ylis = l[::2],l[1::2]
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xlis.sort(reverse=True)
ylis.sort(reverse=True)
def calc(start,goal,lis):
    p = start
    for e in lis:
        if p < goal:
            p += e
        else:
            p -= e
    return p == goal
if calc(sx,gx,xlis) and calc(sy,gy,ylis):
    print("Yes")
else:
    print("No")
a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0
 
for i in range(min(k,a)+1):
  for j in range(min(k,a)-i+1):
    S=L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
print(ans)

### FIXED CODE ###

a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0
 
for i in range(min(k,a)+1):
  for j in range(min(k,a)-i+1):
    S=[0]+L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
print(ans)
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[chr(i) for i in range(97, 97+26)]

i=1
res=0
while True:
    if n>pow(26,i)+res:
        res+=pow(26,i)
        i+=1
    else:
        keta=i
        break
ans=""
r=0
sy=0
for k in range(keta):
    r=n//pow(26,keta-k-1)
    n-=pow(26,keta-k-1)*r
    ans+=l[r-1]
print(ans)  

### FIXED CODE ###

#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[chr(i) for i in range(97, 97+26)]
n-=1
i=1
res=0
ans=[]
while True:
    if n>=pow(26,i)+res:
        res+=pow(26,i)
        i+=1
    else:
        keta=i
        n-=res
        break
ans=""
for i in range(keta):
  r=n%pow(26,keta-i-1)
  s=n//pow(26,keta-i-1)
  ans+=l[s]
  n=r
print(ans)
n = int ( input())
ans = 0
test = (3,5,7,11,13)
for i in range ( 105,n+1,2) :
  div = 0
  for d in test :
    if i % d == 0 :
      div += 1
  if div == 3 and i % 9 != 0:
    ans += 1
  elif i %= 27:
    ans += 1
print (ans)

### FIXED CODE ###

n = int ( input())
ans = 0
test = (3,5,7,11,13)
for i in range ( 105,n+1,2) :
  div = 0
  for d in test :
    if i % d == 0 :
      div += 1
  if div == 3 and i % 9 != 0:
    ans += 1
  elif i % 27 == 0:
    ans += 1
print (ans)
n=int(input())-1

nodes = {1: (None, 0, 0)}
for _ in range(n):
    [a, b, c] = map(int, input().split())
    if a > b:
        a,b=b,a
    if a not in nodes:
        import time
        time.sleep(3)
    nodes[b] = nodes[a], c, c + nodes[a][2]

def dist(a, b):
    if a == b:
        return 0
    if a[2] < b[2]:
        return b[1] + dist(a, b[0])
    if a[2] > b[2]:
        return a[1] + dist(a[0], b)

q, k = map(int, input().split())

for _ in range(q):
    [x, y] = map(int, input().split())
    print(dist(nodes[x], nodes[k]) + dist(nodes[k], nodes[y]))


### FIXED CODE ###

n=int(input())-1

edges = {}
lens = {}
for _ in range(n):
    [a, b, c] = map(int, input().split())
    if a > b:
        a,b=b,a
    edges.setdefault(a, []).append(b)
    edges.setdefault(b, []).append(a)
    lens[(a,b)] = c

q, k = map(int, input().split())

dists = {}
def build(x, d=0):
    ss = [(x, 0)]
    while ss:
        x, d = ss.pop()
        if x not in dists:
            dists[x] = d
            for c in edges.get(x, []):
                ss.append((c, d + lens[(min(x,c), max(x,c))]))

build(k)

for _ in range(q):
    [x, y] = map(int, input().split())
    print(dists[x] + dists[y])
from fractions import gcd
def lcm(x,y):
    return x*y//gcd(x,y)
n,m = map(int,input().split())
s=input()
t=input()
ss=''
tt=''

l=lcm(n,m)
x=['*']*l

for i in range(n):
    x[i*(l//n)]=s[i]

for i in range(m):
    x[i*(l//m)]=t[i]

for i in range(n):
    if x[i*(l//n)]!=s[i]:
        print(-1)
        exit()

for i in range(m):
    if x[i*(l//m)]!=t[i]:
        print(-1)
        exit()
print(l)


### FIXED CODE ###

from fractions import gcd
def lcm(x,y):
    return x*y//gcd(x,y)
n,m = map(int,input().split())
s=input()
t=input()

l=lcm(n,m)
x=dict()

for i in range(n):
    x[i*(l//n)]=s[i]

for i in range(m):
    j=i*(l//m)
    if j in x and x[j]!=t[i]:
        print(-1)
        exit()
print(l)
aru = False
antenas = []
for i in range(5):
  k=int(input())
  antenas.append(n)
k=int(input())
for i in range(4):
  if abs(antenas[i]-antenas[i+1])>k:
    aru = True
if aru:
  print(':(')
else:
  print("Yay!")

### FIXED CODE ###

aru = False
antenas = []
for i in range(5):
  k=int(input())
  antenas.append(k)
k=int(input())
for i in range(5):
  for t in range(i,5):
    if abs(antenas[i]-antenas[t])>k:
      aru = True
if aru:
  print(':(')
else:
  print("Yay!")
import numpy as np

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

C = np.arange(A,B+1)

E=C[B-K-2:]


if max(C)<=K:
    for x in range(B):
        print(C[x])


        
else:
    for y in range(K):
        print(C[y])
    for z in range(B-K-2,B):
        print(C[z])


### FIXED CODE ###

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

L = B - A + 1

if L >= 2*K:
    for i in range(A, A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
        
else:
    for i in range(A,B+1):
        print(i)
import sys
w = sys.stdin.readline().strip().lower()
t = sys.stdin.read().lower.split()
print(w, t)

### FIXED CODE ###

import sys
w = sys.stdin.readline().strip().lower()
t = sys.stdin.read().lower().split()
print(t.count(w))
import os

def main():
    n,x = map(int, input().split())
    list_a = list(map(int, input().split()))
    ans = 0
    count = 1
    i = 0

    while(ans < x):
        ans += list_a[i]
        if ans <= x:
            count += 1
            i += 1
        else:
            break

    print(count)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import os

def main():
    n,x = map(int, input().split())
    list_a = list(map(int, input().split()))
    ans = 0
    count = 1

    for i in range(n):
        ans += list_a[i]
        if (ans <= x):
            count += 1
        else:
            break

    print(count)

if __name__ == "__main__":
    main()
N,K=map(int, raw_input().split())
S=raw_input()

if "0" not in S:
	print len(S)
	quit()

L=[]
zero_kukan=0
for i,x in enumerate(S):
	if i==0:
		cnt=1
		if x=="0": zero_kukan+=1
	else:
		if prev==x:
			cnt+=1
		else:
			L.append(cnt)
			cnt=1
			if x=="0": zero_kukan+=1
	prev=x
else:
	L.append(cnt)

K=min(K, zero_kukan)


LSUM=[0]
for x in L:
	LSUM.append(LSUM[-1]+x)


#print "L :::: ",L
#print "LSUM  :::: ",LSUM

lsum_len=len(LSUM)

#print "lsum_len  :::: ",lsum_len

h=2*K+1

ans=0
if S[0]=="1":
	for l in range(0,lsum_len-h,2):
		r=l+h
		ans=max(ans, LSUM[r]-LSUM[l])
else:
	ans=max(ans, LSUM[2*K]-LSUM[0])
	for l in range(1,lsum_len-h,2):
		r=l+h
		ans=max(ans, LSUM[r]-LSUM[l])
	
	ans=max(ans, LSUM[lsum_len-1]-LSUM[lsum_len-1-2*K])
print ans
		

### FIXED CODE ###

N,K=map(int, raw_input().split())
S=raw_input()

if "0" not in S:
	print len(S)
	quit()
L=[]
if S[0]=="0": L.append(0)
for i,x in enumerate(S):
	if i==0:
		cnt=1
	else:
		if prev==x:
			cnt+=1
		else:
			L.append(cnt)
			cnt=1
	prev=x
else:
	L.append(cnt)

if S[-1]=="0": L.append(0)

LSUM=[0]
for x in L:
	LSUM.append(LSUM[-1]+x)

K=min(K,len(L)/2)

ans=0
len_lsum=len(LSUM)
for l in range(0,len_lsum,2):
	r=l+2*K+1
	if r < len_lsum:
		ans=max(ans , LSUM[r]-LSUM[l])

print ans
a, b, c = map(int,input().split())
if a+b+c=17:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

a, b, c = map(int,input().split())
if a == b == 5 and c==7:
    print('YES')
elif a== c == 5 and b==7:
    print('YES')
elif b == c == 5 and a==7:
    print('YES')
else:
    print('NO')
s1, s2, s3 = input().split()
print(s1,s2,s3.pop = 1)


### FIXED CODE ###

s = input()
print(s.count('1'))