Harryxun/stf_run huggingface dataset:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt_a = 0
cnt_b = 0
time = 0
ans = 0

while time <= k:
    if cnt_a == n and cnt_b == m:
        break
    elif cnt_a == n:
        if time + B[cnt_a] > k:
            break
        time += B[cnt_b]
        cnt_b += 1
        ans += 1
    elif cnt_b == m:
        if time + A[cnt_a] > k:
            break
        time += A[cnt_a]
        cnt_a += 1
        ans += 1
    else:
        if A[cnt_a] < B[cnt_b]:
            if time + A[cnt_a] > k:
                break
            time += A[cnt_a]
            cnt_a += 1
            ans += 1
        else:
            if time + B[cnt_a] > k:
                break
            time += B[cnt_b]
            cnt_b += 1
            ans += 1

print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_ruiseki = [0]
for i in range(n):
    if A_ruiseki[-1]+A[i] <= k :
        A_ruiseki.append(A_ruiseki[-1]+A[i])
    else:
        break

B_ruiseki = [0]
for i in range(m):
    if B_ruiseki[-1]+B[i] <= k :
        B_ruiseki.append(B_ruiseki[-1]+B[i])
    else:
        break

ans = len(A_ruiseki)-1

for i in range(len(A_ruiseki)):
    time = A_ruiseki[i]
    expected = max(ans-i, 0)

    if len(B_ruiseki) <= expected:
        continue

    if time + B_ruiseki[expected] > k:
        continue

    time += B_ruiseki[expected]

    for j in range(expected, len(B)):
        if time + B[j] > k:
            break

        time += B[j]
        ans =i+j+1

print(ans)
S = input('天気が雨である日が連続していた最大の日数を出力せよ。')
N = True
while N == False:
if S == 'SSS':
	print(0)
elif S == 'SSR':
	print(1)
elif S == 'SRR':
	print(2)
elif S == 'SRS':
	print(1)
elif S == 'RSS':
	print(1)
elif S == 'RRS':
	print(2)
elif S == 'RRR':
	print(3)
elif S == 'RSR':
	print(1)
else:
	N = False
 

### FIXED CODE ###

S = input()
if S == 'SSS':
  print(0)
elif S == 'SRR':
  print(2)
elif S == 'RRS':
  print(2)
elif S == 'RRR':
  print(3)
else:
  print(1)
N, K = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
K = K-1
ans = -10**9-1
for _ in range(N):%Here, the initial number is fixed and 
   i += 1
   start = i
   circle = [c[i-1]]
   i = p[i-1]
   while i != start:
      l = len(circle)
      score = circle[l-1] + c[i-1]
      circle.append(score)
      i = p[i-1]
   l=len(circle)
   for j in range(min(l, K+1)):
      if circle[l-1] > 0:
         score = circle[j] + ((K - j)//l)*circle[l-1]
      else:
         score = circle[j]
      ans = max(score, ans)      
print(ans)

### FIXED CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
K = K-1
ans = -10**9-1
for h in range(N):
   i = h+1
   start = i
   circle = [c[i-1]]
   i = p[i-1]
   while i != start:
      score = circle[-1] + c[i-1]
      circle.append(score)
      i = p[i-1]
   l=len(circle)
   for j in range(min(l, K+1)):
      if circle[l-1] > 0:
         score = circle[j] + ((K - j)//l)*circle[l-1]
      else:
         score = circle[j]
      ans = max(score, ans)      
print(ans)
while(1):
	n, x = map(int, input().split())
	t = 0
	if n == x == 0:
		break
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(k+1, n+1):
				if i+j+k == x:
					if i != j and j != k and k != i:
						t += 1
						print(i, j, k)
	print(t)

### FIXED CODE ###

while(1):
	n, x = map(int, input().split())
	t = 0
	if n == x == 0:
		break
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(j+1, n+1):
				if i+j+k == x:
					if i != j and j != k and k != i:
						t += 1
						#print(i, j, k)
	print(t)
from math import sqrt
N = int(input())
ans = [0] * N

for x in range(1, int(sqrt(n)) + 1):
    for y in range(1,int(sqrt(n)) + 1):
        for z in range(1, int(sqrt(n)) + 1):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ans < n:
                ans[n] += 1

for a in ans:
    print(a)

### FIXED CODE ###

from math import sqrt
N = int(input())
ans = [0] * (N+1)

for x in range(1, int(sqrt(N)) + 2):
    for y in range(1,int(sqrt(N)) + 2):
        for z in range(1, int(sqrt(N)) + 2):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= N:
                ans[n] += 1

for i in range(1, len(ans)):
    print(ans[i])
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split()))

result = 1
flag = 0
for x in range(N):
  result *= i[x]
  if(result>pow(10,18)):
    result = -1
    flag = 1
    break

if(flag==0):
  print(result)
else:
  print('-1')






### FIXED CODE ###

i = list(map(int, input().split()))
print(i[0]*i[1])
from math import floor
T = int(input())
for i in range(T):
    memo = {}
    def buy(A):
        if A < B:
            return False
        else:
            if A % B > C:
                return False
            else:
                A = floor((C-A%B)/B)*B+A%B+D
                if A not in memo:
                    memo[A] = 0
                    return buy(A)
                else:
                    return(True)
    A,B,C,D = map(int,input().split())
    if buy(A):
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

from math import floor
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D or B > A:
        print("No")
    else:
        if A%B>C:
            print("No")
        else:
            d = gcd(B,D%B)
            r = (A%B)%d
            if B - d + r > C:
                print("No")
            else:
                print("Yes")
n=int(input())
a=list(map(int,input().split()))
cnt=0
for _ in range(len(bin(max(a))-2):
  for i in a:
    if a%2==1:
      break
  cnt+=1
print(cnt)

### FIXED CODE ###

length = int(input())
a_list = map(int, input().split())

num_list = []
for a in a_list:
    t = a
    num = 0
    while t % 2 == 0:
        num += 1
        t = t / 2
    num_list.append(num)

print(min(num_list))
#こぴぺです。
S = input()
S = int(S)
  
h = S//3600
S = S - h * 3600
m = S // 60
s = S - m * 60
  
print("%d:%d:%d" %(h, m, s))


### FIXED CODE ###

if __name__ == '__main__':
	S = int(input())
	h = S // 3600
	S %= 3600
	m = S // 60
	S %= 60
	
	print("%d:%d:%d" %(h, m, S))
import bisect
n=int(input())
a=list(map(int,input().split()))
la=[0]
for i in range(n):
    la.append(la[i]+a[i])
sa = la[-1]
ma = sa // 2
def ans(r):
    return max(r) - min(r)
def ans2(r1,r2,r3,r4):
    return max(r1,r2,r3,r4) - min(r1,r2,r3,r4)

ca = bisect.bisect_left(la,ma)

ha1 = la[:ca]
ha2 = la[ca:]

cha1 = bisect.bisect_left(ha1,ha1[-1]//2)
r1=[0,0]
r1[0] = ha1[cha1]
r1[1] = ha1[-1] - r1[0]
r2=[0,0]
r2[0] = ha1[cha1-1]
r2[1] = ha1[-1] - r2[0]

tminus = ha1[-1]
for i in range(len(ha2)):
    ha2[i] -= tminus
cha2 = bisect.bisect_left(ha2,ha2[-1]//2)
r3=[0,0]
r3[0] = ha2[cha2]
r3[1] = ha2[-1] - r3[0]
r4=[0,0]
r4[0] = ha2[cha2-1]
r4[1] = ha2[-1] - r4[0]

res1 = min(ans(r1+r3),ans(r1+r4),ans(r2+r3),ans(r2+r4))

ha1 = la[:ca-1]
ha2 = la[ca-1:]

cha1 = bisect.bisect_left(ha1,ha1[-1]//2)
r1=[0,0]
r1[0] = ha1[cha1]
r1[1] = ha1[-1] - r1[0]
r2=[0,0]
r2[0] = ha1[cha1-1]
r2[1] = ha1[-1] - r2[0]

tminus = ha1[-1]
for i in range(len(ha2)):
    ha2[i] -= tminus
cha2 = bisect.bisect_left(ha2,ha2[-1]//2)
r3=[0,0]
r3[0] = ha2[cha2]
r3[1] = ha2[-1] - r3[0]
r4=[0,0]
r4[0] = ha2[cha2-1]
r4[1] = ha2[-1] - r4[0]

res2 = min(ans(r1+r3),ans(r1+r4),ans(r2+r3),ans(r2+r4))

ha1 = la[:ca+1]
ha2 = la[ca+1:]

cha1 = bisect.bisect_left(ha1,ha1[-1]//2)
r1=[0,0]
r1[0] = ha1[cha1]
r1[1] = ha1[-1] - r1[0]
r2=[0,0]
r2[0] = ha1[cha1-1]
r2[1] = ha1[-1] - r2[0]

tminus = ha1[-1]
for i in range(len(ha2)):
    ha2[i] -= tminus
cha2 = bisect.bisect_left(ha2,ha2[-1]//2)
r3=[0,0]
r3[0] = ha2[cha2]
r3[1] = ha2[-1] - r3[0]
r4=[0,0]
r4[0] = ha2[cha2-1]
r4[1] = ha2[-1] - r4[0]

res3 = min(ans(r1+r3),ans(r1+r4),ans(r2+r3),ans(r2+r4))


print(min(res1,res2,res3))

### FIXED CODE ###

import bisect
INF = 10**16
n=int(input())
a=list(map(int,input().split()))
la=[0]
for i in range(n):
    la.append(la[i]+a[i])
la.pop(0)
sa = la[-1]
l=0
r=2
res = INF
for i in range(1,n-2):
    while abs(la[l+1]-(la[i]-la[l+1])) < abs(la[l]-(la[i]-la[l])):
        l += 1

    if r == i:
        r += 1
    while abs((la[r+1] - la[i])-(sa - la[r+1])) < abs((la[r] - la[i])-(sa - la[r])):
        r += 1
    r1 = la[l]
    r2 = la[i] - la[l]
    r3 = la[r] - la[i]
    r4 = sa    - la[r]
    res=min(res,max(r1,r2,r3,r4)-min(r1,r2,r3,r4))
print(res)
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print(Bad)
else:
  print(Good)
  
  

### FIXED CODE ###

s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
  print("Bad")
else:
  print("Good")
N,X=map(int,input().split())
L=[int(x)for x in input().split()]

count=1
D=1
for i in range(0,N+1):
    if(D>X):
        break
    else:
        D=D+L[i]
        count+=1

print(count)

### FIXED CODE ###

N,X=map(int,input().split())
L=[int(x)for x in input().split()]

count=0
D=0
n=0
for i in range(0,N):
    n+=1
    if(D>X):
        break
    else:
        count+=1
        D=D+L[i]
    
if(n==N and D<=X):
    count+=1
print(count)
import  string

count = {x: 0 for x in string.ascii_lowercase}
lines = ""

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

fpr c in lines:
    if 'a' <= c <= 'z':
    count[c] += 1

for key in string.ascii lowercase:
    print("{0} : {1}".format(key, count[key]))

### FIXED CODE ###

import string
  
count = {x: 0 for x in string.ascii_lowercase}
lines = ""
  
while True:
    try:
        lines += input().lower()
    except EOFError:
        break
          
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
          
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))
s = input()

words = ['dream', 'dreamer', 'erase', 'eraser']
def dfs(t):
    if t == '':
        return True
    ans = False
    for word in words:
        if t[:len(word)] == word:
            ans = ans or dfs(t[len(word):])

    return ans

if dfs(s):
    print("YES")
else:
    print("NO")


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

s = input()

words = ['dream', 'dreamer', 'erase', 'eraser']
def dfs(idx):
    if idx == len(s):
        return True
    ans = False
    for word in words:
        if s[idx:idx+len(word)] == word:
            ans = ans or dfs(idx + len(word))

    return ans

if dfs(0):
    print("YES")
else:
    print("NO")
N, K = map(int, input().split())
A = tuple(map(int, input().split()))

rec = [0] * N
costs = [0] * N

loc = 1
rec[loc-1] = 1

finished = True
for i in range(1, K+1):
    next_loc = A[loc - 1]

    if rec[next_loc - 1] == 1:
        break

    costs[next_loc - 1] = i
    rec[next_loc - 1] = 1
    loc = next_loc

loop_index_cost = costs[next_loc - 1]
loop_cost = i - loop_index_cost

cs = tuple(map(lambda x: x - loop_index_cost, costs))

final_loc = cs.index((K - loop_index_cost) % loop_cost) + 1
print(final_loc)

### FIXED CODE ###

N, K = map(int, input().split())
A = tuple(map(lambda n: int(n) - 1, input().split()))

costs = [-1] * N
loc = 0

if K <= N:
    for i in range(K):
        loc = A[loc]
    print(loc + 1)

else:
    costs[loc] = 0
    for i in range(1, K):
        loc = A[loc]

        if costs[loc] >= 0:
            break

        costs[loc] = i

    offset = costs[loc]
    loop = i - offset

    K -= i
    K %= loop

    for _ in range(K):
        loc = A[loc]
    print(loc + 1)
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N, M = LI()
S = input()
T = input()
#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(N, M)
print(32131)

### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N, M = LI()
S = input()
T = input()

#  N, M = 10**5, 10**5
#  S = 's'*N
#  T = 't'*M

X = lcm(N, M)
L = X
#  XS = ['X' for i in range(L+1)]
#  XT = ['X' for i in range(L+1)]
XS, XT = {}, {}
count = 0
LN = L/N
while True:
    XS[int(count*LN)] = S[count]
    count += 1
    if count > N-1:
        break

count = 0
LM = L/M
while True:
    XT[int(count*LM)] = T[count]
    count += 1
    if count > M-1:
        break

for key, value in XS.items():
    #  print(key, value)
    if key in XT:
        if value != XT[key]:
            print(-1)
            exit()
#  print(XS, XT)
#  for i in range(0, L+1):
#      if XS[i] != 'X' and XT[i] != 'X':
#          if XT[i] != XS[i]:
#              print(-1)
#              exit()
print(L)
h, w, a, b = map(int, input().split())

ans = []
for i in range(b):
    l = [1 for j in range(w)]
    ans.append(l)

for i in range(h-b):
    l = [0 for j in range(w)]
    ans.append(l)
    

for i in range(int(h/2)+1):
    if sum(ans[2*i]) != a or sum(ans[2*i]) != w-a:
        for j in range(min(abs(sum(ans[2*i])-a), abs(sum(ans[2*i])-w+a))):
            ans[2*i][j] = 1 - ans[2*i][j]
            if 2 * i + 1 != h:
                ans[2*i+1][j] = 1 - ans[2*i+1][j]

for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end="")
    print()
        



    










 

 


                                        




    




        


    







        



### FIXED CODE ###

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

ans = []
for i in range(b):
    l = [1 for j in range(w)]
    ans.append(l)

for i in range(h-b):
    l = [0 for j in range(w)]
    ans.append(l)

if h % 2 == 0:
    m = int(h/2)
else:
    m = int(h/2) + 1

for i in range(m):
    if sum(ans[2*i]) != a or sum(ans[2*i]) != w-a:
        for j in range(min(abs(sum(ans[2*i])-a), abs(sum(ans[2*i])-w+a))):
            ans[2*i][j] = 1 - ans[2*i][j]
            if i != int(h/2):
                ans[2*i+1][j] = 1 - ans[2*i+1][j]
                
for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end="")
    print()
def i_map(): return map(int, input().split())
sys.setrecursionlimit(10 ** 7)

def dfs(current, parent, edges, ans_list):
    for child in edges[current]:
        if child == parent:
            continue
        ans_list[child] += ans_list[current]
        dfs(child, current, edges, ans_list)

def main():
    n, q = i_map()

    edges = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = i_map()
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    ans_list = [0] * n
    for i in range(q):
        p, x = i_map()
        ans_list[p-1] += x

    dfs(0, -1, edges, ans_list)

    print(*ans_list)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys, re
from math import ceil, floor, sqrt, pi#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_rpw_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7

def dfs(current, parent, edges, ans_list):
    for child in edges[current]:
        if child == parent:
            continue
        ans_list[child] += ans_list[current]
        dfs(child, current, edges, ans_list)

def main():
    n, q = i_map()

    edges = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = i_map()
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    ans_list = [0] * n
    for i in range(q):
        p, x = i_map()
        ans_list[p-1] += x

    dfs(0, -1, edges, ans_list)

    print(*ans_list)

if __name__ == '__main__':
    main()
# https://atcoder.jp/contests/abc155/tasks/abc155_c

def main():
    N = int(input())
    S_list = []
    for _ in range(N):
        S_list.append(input())

    S_dict = {}
    for s in S_list:
        S_dict[s]=0
    for s in S_list:
        S_dict[s]+=1



    max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max(S_dict.values())]
    max_k_list.sort()
    for k in max_k_list:
        print(k)

if __name__ == '__main__'
     main()

### FIXED CODE ###

def main():
    N = int(input())
    S_list = []
    for _ in range(N):
        S_list.append(input())

    S_dict = {}
    for s in S_list:
        S_dict[s]=0
    for s in S_list:
        S_dict[s]+=1

    max_v = max(S_dict.values())

    max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max_v]
    max_k_list.sort()
    for k in max_k_list:
        print(k)

if __name__ == '__main__':
     main()
def f(n):
    if n<2:
        return 1
    return n*f(n-2)

N = int(input())
if N%2==1:
    print(0)
    exit(1)
ans = 0
tmp = N//50//2
for i in range(1, len(str(N))):
    # if i != len(str(N))-1:
    #     ans+=(10**(i))
    ans += N//5//2
    N //= 10
print(ans+tmp)

### FIXED CODE ###

N = int(input())
if N%2==1:
    print(0)
    exit(0)
ans = 0
tmp = N
for i in range(1, 100):
    ans += tmp//pow(5, i)//2
print(ans)
N = int(input())
if N%2==0:
  print(N/2)
if N==1:
  print("1")
if N==3:
  print("2")
if else:
  print(N/2+1)

### FIXED CODE ###

N = int(input())
if N%2==0:
	print(int(N/2))
else:
	print(int((N+1)/2))
N = int(input())

print('ABC'+ N, end='')

### FIXED CODE ###

N = int(input())

print('ABC'+ str(N))
a,b,h=map(int,input().split())
print((a+b)*h//2)

### FIXED CODE ###

a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
N, M = map(int, input().split())
N2 = 2**N.bit_length()
D = [[0]*(N2+1) for i in range(M)]
def get(i, k):
    data = D[i]
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def add(i, k, x):
    data = D[i]
    while k <= N2:
        data[k] += x
        k += k & -k
cnts = [0]*M
for i in range(N):
    v = int(input())
    cnts[v-1] += 1
    add(v-1, i+1, 1)
memo = {2**M-1: 0}
def dfs(state, idx):
    if state in memo:
        return memo[state]
    res = N
    for i in range(M):
        if state & (1 << i) == 0:
            need = cnts[i] - (get(i, cnts[i] + idx) - get(i, idx))
            res = min(res, need + dfs(state | (1 << i), idx + cnts[i]))
    memo[state] = res
    return res
print(dfs(0, 0))

### FIXED CODE ###

N, M = map(int, input().split())
D = [[0]*(N+1) for i in range(M)]
cnts = [0]*M
for i in range(N):
    v = int(input())
    cnts[v-1] += 1
    D[v-1][i+1] = 1
for i in range(M):
    d = D[i]
    for j in range(1, N+1):
        d[j] += d[j-1]
memo = [None]*(2**M)
memo[2**M-1] = 0
def dfs(state, idx):
    if memo[state] is not None:
        return memo[state]
    res = N
    for i in range(M):
        if state & (1 << i) == 0:
            need = cnts[i] - (D[i][cnts[i] + idx] - D[i][idx])
            res = min(res, need + dfs(state | (1 << i), idx + cnts[i]))
    memo[state] = res
    return res
print(dfs(0, 0))
s=input()
t=input()
if len(s)==len(t):
    c=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            c=c+1
else:
    c=[0 for i in range(len(s)-len(t))]
    for i in range(len(s)-len(t)):
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                c[i]=c[i]+1

print(min(c))


### FIXED CODE ###

s=input()
t=input()
if len(s)==len(t):
    cm=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            cm+=1
else:
    cm=1000
    for i in range(len(s)-len(t)):
        cn=0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                cn+=1
        cm=min(cm,cn)

print(cm)
n = int(input())

ans = ''
for w in str(s):
    if w == '1':
        ans += '9'
    elif w == '9':
        ans += '1'
    else:
        ans += str(w)
        
print(int(ans))

### FIXED CODE ###

s = input()
 
ans = ''
for w in str(s):
    if w == '1':
        ans += '9'
    elif w == '9':
        ans += '1'
        
print(int(ans))
a = int(input())
b = int(input())
print((a-1) * (b-1))

### FIXED CODE ###

a,b = (int(x) for x in input().split())
print((a-1) * (b-1))
a = input()

b = int(a[0:0])
c = int(a[1:0])
d = int(a[2:0])

ball = 0

if(b == 1):
  ball += 1

if(c == 1):
  ball += 1

if(d == 1):
  ball += 1
  
print(ball)

### FIXED CODE ###

a = input()
b = int(a[0:1])
c = int(a[1:2])
d = int(a[2:3])

ball = 0

if(b == 1):
  ball += 1

if(c == 1):
  ball += 1

if(d == 1):
  ball += 1
  
print(ball)
N, W = map(int, input().split())
weight = []
value = []
for _ in range(N):
    w_tmp, v_tmp = map(int, input().split())
    weight.append(w_tmp)
    value.append(v_tmp)

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    for j in range(W+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j - weight[i]] + v[i])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
weight = []
value = []
for _ in range(N):
    w_tmp, v_tmp = map(int, input().split())
    weight.append(w_tmp)
    value.append(v_tmp)

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    for j in range(W+1):
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j - weight[i]] + value[i])
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[N][W])
import collections
n,k = map(int, raw_input().split(' '))
heigths = [int(raw_input()) for _ in range(n)]
heigths.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k+1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0

### FIXED CODE ###

import collections
n,k = map(int, raw_input().split(' '))
heights = [int(raw_input()) for _ in range(n)]
heights.sort()
q = collections.deque([])
r =  float('inf') 
for h in heights:
	q.append(h)
	if len(q) == k + 1: q.popleft()
	if k and len(q) == k:
		r =min(r, q[-1] - q[0])
print r if k else 0
A,B = map(int,input().split())
A,B = map(int,input().split())
if B < A:
    n = A
    A -= 1
else:
    n = B
    B -= 1
if B < A:
    n += A
else:
    n += B

print(n)

### FIXED CODE ###

A,B = map(int,input().split())
if B < A:
    n = A
    A -= 1
else:
    n = B
    B -= 1
if B < A:
    n += A
else:
    n += B

print(n)