Harryxun/stf_run huggingface dataset:
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
def dfs(a, b, k):
	global ans

	if a == N and b == M:
		return True

	if k < 0:
		return False

	if a < N and k >= A[a] and dfs(a + 1, b, k - A[a]):
		ans += 1
		return True

	if b < M and k >= B[b] and dfs(a, b + 1, k - B[b]):
		ans += 1
		return True

	return True

dfs(0, 0, K)
print(ans)

### FIXED CODE ###

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

a = [0]
for i in range(N):
    a.append(a[i] +  A[i])
b = [0]
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
a,b = (int(i) for i in input().split())

import math

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

print(lcm(a, b))


### FIXED CODE ###

a,b = (int(i) for i in input().split())

import fractions

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

print(lcm(a, b))
a,b=map(int,intput().split())
if a + b == 15:
  print('+')
elif a * b == 15:
  print('*')
else:
  print('x')
  

### FIXED CODE ###

a,b=map(int,input().split())
if a + b == 15:
  print('+')
elif a * b == 15:
  print('*')
else:
  print('x')
from collections import defaultdict
N, M = map(int, input().split())
AB = []
D = defaultdict(lambda: [])
for i in range(N + M - 1):
    a, b = map(int, input().split())
    AB.append((a - 1, b - 1))
    D[a - 1].append(b - 1)

z = [0]*N
for a, b in AB:
    z[b] += 1

ans = [-1]*N
root = z.index(0)
ok = [False]*N
def rec(u, p):
    ans[u] = p
    ok[u] = True
    for v in D[u]:
        z[v] -= 1
    for v in D[u]:
        if z[v] == 0 and not ok[v]:
            rec(v, u)


rec(root, -1)

for i in range(N):
    print(ans[i] + 1)


### FIXED CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
AB = []
D = defaultdict(lambda: [])
for i in range(N + M - 1):
    a, b = map(int, input().split())
    AB.append((a - 1, b - 1))
    D[a - 1].append(b - 1)

z = [0]*N
for a, b in AB:
    z[b] += 1

ans = [-1]*N
root = z.index(0)
ok = [False]*N
def rec(u, p):
    ans[u] = p
    ok[u] = True
    for v in D[u]:
        z[v] -= 1
    for v in D[u]:
        if z[v] == 0 and not ok[v]:
            rec(v, u)


rec(root, -1)

for i in range(N):
    print(ans[i] + 1)
import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()

m = [[0]*H*W for i in range(H*W)] 
def calc(l,r):
    if m[l][r] != 0:
        return m[l][r]
    else:
        maho = 0
        for k in range(l,r,D):
            maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
        m[l][r] = maho
        return maho
    
for q in range(Q):
    l,r = Is()
    maho = calc(l,r)
    print(maho)


### FIXED CODE ###

import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
m = [0]*(H*W+1)
for i in range(D+1,H*W+1):
    m[i] = m[i-D] + abs(d[i-D][0] - d[i][0]) + abs(d[i-D][1] - d[i][1])

Q = I()
for q in range(Q):
    l,r = Is()
    print(m[r]-m[l])
import numpy as np
N = int(input())
A = tuple(map(int, input().split()))
l = np.lcm.reduce(A) - 1

f = 0 
for a in A:
    f += l % a
print(f)

### FIXED CODE ###

from fractions import gcd
N = int(input())
A = tuple(map(int, input().split()))

l = A[0]
for i in range(1, N):
    l = l * A[i] // gcd(l, A[i])
l = l - 1

f = 0 
for a in A:
    f += l % a
print(f)
s=input()
b=input()
c=0
for i in len(s):
  if s[i]!=b[i]:
    c=c+1
  else:
    pass
print(c)

### FIXED CODE ###

s=input()
b=input()
c=0
for i in range(len(s)):
    if s[i]!=b[i]:
        c=c+1
    else:
        pass
print(c)
# coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
    order,data =input().split() 
    if order == "insert":
        output.append(int(data))
    elif order == "deleteFirst":
        output.pop()
    elif order == "deleteLast":
        output.popleft()
    elif order == "delete":
        try:
            output.remove(int(data))
        except:
            pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output)))

### FIXED CODE ###

import sys
from collections import deque
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
 
Q = deque()
for i in range(n):
    command = lines[i].split()
    if command[0] == "insert":
        Q.appendleft(command[1])
    elif command[0] == "deleteFirst":
        Q.popleft()
    elif command[0] == "deleteLast":
        Q.pop()
    elif command[0] == "delete":
        try:
            Q.remove(command[1])
        except:
            pass
print(" ".join(Q))
N = int(input())
arr = [None]*N
visited = [False]*N
for i in range(N-1):
    u, v, w = map(int, input().split())
    if i==0:
        arr[u-1] = 0
        arr[v-1] = w
    else:
        if visited[u-1]:
            arr[v-1] = arr[u-1] + w
        else:
            arr[u-1] = arr[v-1] + w
    visited[u-1] = True
    visited[v-1] = True

for a in arr:
    if a%2==0:
        print(0)
    else:
        print(1)

### FIXED CODE ###

N = int(input())

q = []
visited = [0] * N
ans = [0] * N
A = [[] for _ in range(N)]  # tree
W = [[] for _ in range(N)]  # weight

for i in range(N-1):
    u,v,w = map(int, input().split())
    u -= 1
    v -= 1
    A[u].append(v)
    A[v].append(u)
    W[u].append(w)
    W[v].append(w)

q.append(0)  # start
for _ in range(N):
    u = q.pop(0)
    visited[u] = 1
    k = 0
    for v in A[u]:
        if visited[v]==0:
            q.append(v)
            ans[v] = ans[u] + W[u][k]
        k += 1

for a in ans:
    print(a%2)
def main():
	N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
      return 0
    ans = 1
    for i in A:
      if ans > 10**18:
        return -1
      ans*=i
    return ans
print(main())

### FIXED CODE ###

def main():
  N = int(input())
  A = list(map(int,input().split()))
  if 0 in A:
    return 0
  ans = 1
  for i in A:
    ans*=i
    if ans > 10**18:
      return -1
  return ans
print(main())
a,b,c=input().split()
print(a,b,c)

### FIXED CODE ###

print(input().replace(","," "))
import sys

def stdin_parse_int():
    list = []
    for i in sys.stdin.split():
        list.append(int(i))
    return list

list = stdin_parse_int()
A = list[0]
B = list[1]
K = list[2]

if A > K:
    print(str(A-K) + " " + str(B))
elif A+B > K:
    print(str(0) + " " + str(A+B-K))
else:
    print("0 0")



### FIXED CODE ###

import sys

def stdin_parse_int():
    a = list(map(int,input().split()))
    return a

list = stdin_parse_int()
A = list[0]
B = list[1]
K = list[2]

if A > K:
    print(str(A-K) + " " + str(B))
elif A+B > K:
    print(str(0) + " " + str(A+B-K))
else:
    print("0 0")
n = int(input())
x, y = [], []
for i in range(n)
x_, y_ = map(int, input().split())
x.append(x_)
y.append(y_)
for i in range(n-2)
if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
  print("Yes")
  break
else:
  print("No")

### FIXED CODE ###

n = int(input())
x, y = [], []
for i in range(n):
  x_, y_ = map(int, input().split())
  x.append(x_)
  y.append(y_)
for i in range(n-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    print("Yes")
    break
else:
  print("No")
N,A,B,C,D=map(int,input().split())


#print("target:", abs(A-B))
#print("range: ", D-C)
#print("target is larger than D: " ,
#     abs(A-B)>D)
#target=abs(A-B)
#print("next target is: ", target-D)
#print("how many? : ", (target-D)//(D-C))

ans=False
def g(a,b,c,d,n):
  if (n-1)%2==0:
    target=abs(a-b) #スタートは0
    gain=d-c
    if ((n-1)//2)*gain>=target:
      return True
    else:
      return False
  else:
    target=abs(a-b)
    gain=d-c
    if target>d:
      if (n-2)//2 * gain >=target-d:
        return True
      else:
        return False
    elif target<c:
      if (n-2)//2 *gain >= c- target:
        return True
      else:
        return False
    elif c<=target<=d:
      return True
      
A,B=min(A,B),max(A,B)
target=B-A
pos=0
for i in range(N+1):
  target=abs(target)
  if  g(pos, target, C,D, N-i):
      print("YES")
      exit(0)
 　target-=D
    
print("NO")
exit(0)      
  
if g(A,B,C,D,N):
  print("YES")
else:
  print("NO")
    

### FIXED CODE ###

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

n = N-1

found = False

B = abs(A-B)
for i in range(0, n+1):
    if C*(n-i)-D*(i) <= B <= D*(n-i)-C*(i):
        found = True
        break

if found:
    print("YES")
else:
    print("NO")
n,x = map(int, input().split())
if 1 < x < (2*n - 1):
    print("Yes")
    if x != 2:
        ans = [-1 for i in range(2*n-1)]
        k = (n*2-1) //2
        ans[k-1] = x-1
        ans[k] = x
        ans[k+1] = x+1
        ans[k+2] = x-2
        used = set([x-1,x,x+1,x-2])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) not in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert.__next__()
        for i in range(n*2-1):
            print(ans[i])
    else:
        ans = [-1 for i in range(2*n-1)]
        k = (n*2-1) //2
        ans[k-1] = x+2
        ans[k] = x
        ans[k+1] = x-1
        ans[k+2] = x+1
        used = set([x+1,x,x+1,x-1])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) not in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert.__next__()
        for i in range(n*2-1):
            print(ans[i])
else:
    print("No")

### FIXED CODE ###

n,x = map(int, input().split())
if 1 < x < (2*n - 1):
    print("Yes")
    if n == 2:
        for i in range(3):
            print(i+1)
        exit()
    if x != 2:
        ans = [-1 for i in range(2*n-1)]
        k = (n*2-1) //2
        ans[k-1] = x-1
        ans[k] = x
        ans[k+1] = x+1
        ans[k+2] = x-2
        used = set([x-1,x,x+1,x-2])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) not in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert.__next__()
        for i in range(n*2-1):
            print(ans[i])
    else:
        ans = [-1 for i in range(2*n-1)]
        k = (n*2-1) // 2
        ans[k-1] = x+2
        ans[k] = x
        ans[k+1] = x-1
        ans[k+2] = x+1
        used = set([x+1,x,x+2,x-1])
        insert = iter([i+1 for i in range(n*2-1) if (i+1) not in used])
        for i in range(2*n-1):
            if ans[i] == -1:
                ans[i] = insert.__next__()
        for i in range(n*2-1):
            print(ans[i])
else:
    print("No")
N, K = map(int, input().split())
A = []
for i in range(K):
  d = input()
  A += list(map(int, input()))
print(N - len(set(A)))

### FIXED CODE ###

N, K = map(int, input().split())
A = set()
for _ in range(K):
  d = input()
  A = A.union(set(map(int, input().split())))
print(N - len(A))
import math

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

# 最小公倍数を求める
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def cal(num, a, b):
    x = num // a
    y = num // b
    z = num // (lcm(a, b))
    print('z={}'.format(z))
    return num - (x + y - z)

num_a = cal(b, c, d)
num_b = cal(a-1, c, d)

print(num_a - num_b)


### FIXED CODE ###

import fractions

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

# 最小公倍数を求める
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def cal(num, a, b):
    x = num // a
    y = num // b
    z = num // (lcm(a, b))
    return num - (x + y - z)

num_a = cal(b, c, d)
num_b = cal(a-1, c, d)

print(num_a - num_b)
strN, strT = input().split()
N = int(strN)
max_t = int(strT)

min_cost: int = 0
for i in range(1, N+1):
    str_cost, str_time = input().split()
    cost = int(str_cost)
    t = int(str_time)
    if max_t < t:
        continue
    if min_cost == 0:
        min_cost = cost
    elif min_cost > cost:
        min_cost = cost

if min_cost == 0:
    print('TLE')
else:
    print(min_cost)


### FIXED CODE ###

strN, strT = input().split()
N = int(strN)
max_t = int(strT)

min_cost = 0
for i in range(1, N+1):
    str_cost, str_time = input().split()
    cost = int(str_cost)
    t = int(str_time)
    if max_t < t:
        continue
    if min_cost == 0:
        min_cost = cost
    elif min_cost > cost:
        min_cost = cost

if min_cost == 0:
    print('TLE')
else:
    print(min_cost)
#!/usr/bin/env python3

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

flag = 0
ans = [None for i in range(m)]
# print(ans)
for i in range(m):
    s, c = map(int, input().split())
    if ans[s-1] is None or ans[s-1] == c:
        ans[s-1] = c
    else:
        flag = 1

# print(flag)
if ans[0] == 0:
    flag = 1
if ans[0] is None:
    ans[0] = 1
for i in range(1, len(ans)):
    if ans[i] is None:
        ans[i] = 0

print("".join(map(str, ans)) if flag == 0 else -1)


### FIXED CODE ###

# C
N, M = list(map(int, input().split()))

flag = 0
ans = [0]*N
ans_flag = [0]*N

sc = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    s, c = sc[i]
    if ans_flag[s-1] == 1:
        if ans[s-1] != c:
            flag = 1
            break
    ans_flag[s-1] = 1
    ans[s-1] = c

if flag == 1:
    print("-1")
else:
    if N==1:
        for i in ans:
            print(i, end="")

    elif ans[0] == 0 and ans_flag[0]==1:
        print("-1")
    else:
        if ans[0]==0:
            ans[0] = 1
        for i in ans:
            print(i, end="")
N, M = map(int, input().split())

if N >= 2 * M:
print(M // 2)
else:
print(N + ((M - 2 * N) // 4))

### FIXED CODE ###

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

if N >= (M // 2):
    print(M // 2)
else:
    print(N + ((M - 2 * N) // 4))
import sys, math, itertools
input = sys.stdin.readline

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
S = set([input() for _ in range(N)])

m_set = len({cand for cand in S if ((cand[0] == 'M')) })
a_set = len({cand for cand in S if ((cand[0] == 'A')) })
r_set = len({cand for cand in S if ((cand[0] == 'R')) })
c_set = len({cand for cand in S if ((cand[0] == 'C')) })
h_set = len({cand for cand in S if ((cand[0] == 'H')) })
set_elements_num = [m_set,a_set,r_set,c_set,h_set]
set_elements_num.remove(0)

# print(set_elements_num)
comb = 0
for i, elements_num in enumerate(set_elements_num):
    last_elements = set_elements_num[i+1:]
    # print(last_elements)
    last_elements_comb = list(itertools.combinations(last_elements,2))
    for elements in last_elements_comb:
        local_comb = elements_num
        for x in elements:
            local_comb *= x
        comb += local_comb

print(comb)

### FIXED CODE ###

import sys,itertools
input = sys.stdin.readline


N = int(input())
S = set([input() for _ in range(N)])

m = len([cand for cand in S if ((cand[0] == 'M')) ])
a = len([cand for cand in S if ((cand[0] == 'A')) ])
r = len([cand for cand in S if ((cand[0] == 'R')) ])
c = len([cand for cand in S if ((cand[0] == 'C')) ])
h = len([cand for cand in S if ((cand[0] == 'H')) ])

# print(set_elements_num)

comb = m*a*r + m*a*c + m*a*h
comb += m*r*c + m*r*h + m*c*h
comb += a*r*c + a*r*h + a*c*h
comb += r*c*h

print(comb)
a,b=map(str,input().split())
a=int(a)
b = b[0]+b[2:]
b = int(b)
ans = a*b
ans = str(ans)
ans = ans[:-2]
ans = int(ans)
print(ans)

### FIXED CODE ###

a,b=map(str,input().split())
a=int(a)
b = b[0]+b[2:]
b = int(b)
ans = a*b
ans = str(ans)
if len(ans)>=3:
    ans = ans[:-2]
    ans = int(ans)
else:
    ans = 0
print(ans)
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
pcount=0
qcount=0
rcount=0
ans=[]
for i in range(x):
  ans.append(p[-1-i])
for i in range(y):
  ans.append(q[-1-i])
ans.sort()
for i in ragne(r):
  if ans[i]<=r[-1-rcount]:
    ans[i]=r[-1-rcount]
    rcount+=1
print(sum(ans))
  

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
rcount=0
ans=[]
for i in range(x):
  ans.append(p[-1-i])
for i in range(y):
  ans.append(q[-1-i])
ans.sort()
for i in range(min(len(ans),c)):
  if ans[i]<=r[rcount]:
    ans[i]=r[rcount]
    rcount+=1
print(sum(ans))
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = [0] * (2 * 10 ** 5 + 1)
M = max(A)

for a in A:
	B[a] += 1

if sum(B) == N:
	print(0)
else:
	for a in A:
		if B[a] > 0:
			i = 2
			b = a * i
			while b <= M:
				B[b] = 0
				i += 1
				b = a * i
	for b in B:
		if b > 1:
			B[b] = 0
	print(sum(B))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
M = max(A)
B = [0] * (M + 1)

for a in A:
    B[a] += 1

for a in A:
    if B[a] > 0:
        i = 2
        b = a * i
        while b <= M:
            B[b] = 0
            i += 1
            b = a * i
for i in range(M + 1):
    if B[i] > 1:
        B[i] = 0
print(sum(B))
N = int(input())
A = [int(input()) for _ in range(N)]

max_val = max(A)
subset = list(set(A))
subset.remove(max_val)
max_val_2 = max(subset)
count = A.count(max_val)

for i, num in enumerate(A):
  if num < max_val:
    print(max_val)
  else:
    if count > 1:
      print(max_val)
    else:
      print(max_val_2)

### FIXED CODE ###

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

max_val = max(A)
count = A.count(max_val)

subset = list(set(A))
if len(subset) > 1:
  subset.remove(max_val)
  max_val_2 = max(subset)

for i, num in enumerate(A):
  if num < max_val:
    print(max_val)
  else:
    if count > 1:
      print(max_val)
    else:
      print(max_val_2)
# NとKを数値入力させる
N, K = map(int, input().split())

# 棒を入れるリストを用意する
A = []

# N本の棒の長さを入力させる
for i in range(N):
    # 数字を1つ入力させる
    a = int(input())

    # リストAに追加する
    A.append(a)

# リストAをソートする．このとき引数にreverse = Trueを設定すると降順になる（デフォルトは昇順）
A = sorted(A, reverse = True)

# 現在リストAには大きい順に棒の長さが格納されている．
# 大きい方からK本の長さの総和が最大値なので初期値0にしてK本分足していく
ans = 0
for i in range(K):
    ans += A[i]

print(ans)

### FIXED CODE ###

n,k=input().split()
print(sum(sorted(list(map(int,input().split())))[:-int(k)-1:-1]))
a=int(input())
b=int(input())
c=int(input())
if(abs(a-b)==abs(b-c)):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a,b,c= map(int, input().split())
if ((a+c)==b*2):
 print('YES')
else:
 print('NO')
n=int(input())
a=list(map(int,input().split()))
a=a[::-1]
print(" ".join(a))

### FIXED CODE ###

n=int(input())
a=list(map(str,input().split()))
a=a[::-1]
print(" ".join(a))
import collections

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

l = []
for _ in range(n):
  l.append([])

# for x in range(n):
#   l[x]

for a, b in ab:
  a -= 1
  b -= 1
  l[a].append(b)
  l[b].append(a)

# c = [None] * n

# for i in range(n):
#   if c[i] is None:
#     c[i] = i
#   for f in l[i]:
#     if c[f] is None:
#       c[f] = i


c = [None] * n

def dfs(i, d):
  if c[i] is not None:
    return
  c[i] = d

  for f in l[i]:
    dfs(f, d)


for i in range(n):
  if c[i] is None:
    dfs(i, i)

print(max([v for k, v in collections.Counter(c).items()]))


### FIXED CODE ###

import collections
import sys

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

l = []
for _ in range(n):
  l.append([])

# for x in range(n):
#   l[x]

for a, b in ab:
  a -= 1
  b -= 1
  l[a].append(b)
  l[b].append(a)

# c = [None] * n

# for i in range(n):
#   if c[i] is None:
#     c[i] = i
#   for f in l[i]:
#     if c[f] is None:
#       c[f] = i


# https://algo-logic.info/connected-components-num/

color = [None] * n

sys.setrecursionlimit(3*10**5)


def dfs(i, c):
  if color[i] is not None:
    return
  color[i] = c

  for f in l[i]:
    dfs(f, c)


for i in range(n):
  if color[i] is None:
    dfs(i, i)

print(max([v for k, v in collections.Counter(color).items()]))
import numpy as np
from scipy.sparse.csgraph import shortest_path

n, m = map(int, input().split())
e = np.zeros((n, n))
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a][b] = 1
    e[b][a] = 1

dist, predecessor = shortest_path(
    e, directed=False, return_predecessors=True, unweighted=True, indices=0)

print("Yes")
for i in predecessor[1:]:
    print(i+1)


### FIXED CODE ###

from collections import deque

n, m = map(int, input().split())
e = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)

dist = [1000000] * n
ans = [None]*n
not_visited = set(range(n))
not_visited.remove(0)
vs = deque([0])
dist[0] = 0
while vs:
    v = vs.popleft()
    for other_side in e[v]:
        if other_side in not_visited:
            vs.append(other_side)
            not_visited.remove(other_side)
            if dist[other_side] > dist[v] + 1:
                dist[other_side] = dist[v] + 1
                ans[other_side] = v

print("Yes")
for i in ans[1:]:
    print(i+1)
while True:
    [H,W]=[int(x) for x in input().split()]
    if [H,W]==[0,0]:
        break
    unit="#."
    for i in range(0,H):
        print(unit*(W/2)+unit[0]*(W%2))
        unit=unit[1]+unit[0]
    print("")

### FIXED CODE ###

while True:
    [H,W]=[int(x) for x in input().split()]
    if [H,W]==[0,0]:
        break
    unit="#."
    for i in range(0,H):
        print(unit*(W//2)+unit[0]*(W%2))
        unit=unit[1]+unit[0]
    print("")
a, b, c= map(int, input().split())
kawaiso = 0 
if a==b && a!=c:
    kawaiso = 1

if b==c && b!=a :
    kawaiso = 1

if c==a && c!=b :
    kawaiso = 1

if kawaiso == 1 :
    print ('yes')

else :
    print('No')


### FIXED CODE ###

a, b, c= map(int, input().split())
kawaiso = 0 
if a==b and a!=c:
    kawaiso = 1
 
elif  b==c and b!=a:
    kawaiso = 1
 
elif c==a and c!=b:
    kawaiso = 1
    
else:
    kawaiso = 0
  
 
if kawaiso == 1:
    print ("Yes")
    
else:
    print("No")
N,K=map(int,input().split())
S=input()
First=S[0]
Last=S[N-1]

Now=First
cnt=0
A=[0,0]
for s in S:
    if Now=='1' and s=='0':
        A+=[cnt]
        Now='0'
    elif Now=='0' and s=='1':
        A+=[cnt]
        Now='1'
    cnt+=1
A+=[cnt,cnt]

ans=0
dp=2*K+1
if First=="0":
    p=0
else:
    p=1
while p+dp<len(A):
   if A[p+dp]-A[p]>ans:ans=A[p+dp]-A[p]
   p+=2
print(ans)

### FIXED CODE ###

A,B=list(map(int,input().split()))
if A==B:
  print(2*A)
else:
  print(2*max(A,B)-1)
n = int(input())
x = input()
xi = int('0b' + x, 2)
xc = x.count("1")

xip = xi % (xc+1)
xim = xi % (xc-1)

def f(u):
  if u==0: return 0
  m = u % bin(u).count("1")
  return 1 + f(m)

for i in range(n):
  if x[i] == "0":
    y = xip + (pow(2, n-i-1)%(xc+1))
    y = y % (xc+1)
  else:
    y = xim - (pow(2, n-i-1)%(xc-1))
    y = y % (xc-1)

  print(f(y)+1)

### FIXED CODE ###

N = int(input())
X = input()
val = int(X,2)
C = X.count("1")

if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()

# xをpopcountで割ったあまりに置き換える
def f(x):
  if x==0: return 0
  return 1 + f(x % bin(x).count("1"))

# 初回のpopcountでの割り方は、(C+1) or (C-1)
Y = val%(C+1)
if C-1 != 0:
  Z = val%(C-1)
else:
  Z = 0

for i in range(N):
  if X[i] == "1":
    if Z - 1 == 0:
      print(0)
      continue
    k = (Z - pow(2,N-i-1,C-1)) % (C-1)
  else:
    k = (Y + pow(2,N-i-1,C+1)) % (C+1)
  print(f(k)+1)
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1) :
    for j in range(B+1) :
        for k in range(C+1) :
            if x%(500*i + 100*j + 50*k) == 0 :
                count += 1

print(count)


### FIXED CODE ###


A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1) :
    for j in range(B+1) :
        for k in range(C+1) :
            if X == 500*i + 100*j + 50*k :
                count += 1

print(count)