Harryxun/stf_run huggingface dataset:
class Tree:
    def __init__(self,parent,left,right):
        self.parent = parent
        self.left = left
        self.right = right


def setdepth(u, p):
    depths[u] = p
    if trees[u].right != -1:
        # ???????????????????????±???????¨????
        setdepth(trees[u].right, p)
    if trees[u].left != -1:
        # ??????????????????????????±???+1????¨????
        setdepth(trees[u].left, p+1)


N = int(input())
# ?????????
trees = [Tree(-1,-1,-1) for i in range(N)]
for i in range(N):
    l = list(map(int, input().split()))
    no = l[0]
    jisu = l[1]
    # 2???????????????????????§???????´??????????
    childs = l[2:]
    for j in range(jisu):
        child = childs[j]
        if j == 0:
            trees[no].left = child

        if j != len(childs)-1:
            trees[child].right = childs[j+1]

        trees[child].parent = no

r = 0
for i in range(N):
    if trees[i].parent == -1:
        r = i

depths = [-1] * N
setdepth(r, 0)

for i in range(N):
    type = ""
    if trees[i].parent == -1: type = "root"
    elif trees[i].left == -1: type = "leaf"
    else: type = "internal node"
    childs = "["
    child = trees[i].left
    while child != -1:
        childs += str(child)
        child = trees[child].right
        if child != -1: childs += ", "
    childs += "]"

    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, trees[i].parent, depths[i], type, childs))

### FIXED CODE ###

class Tree:
    def __init__(self,parent,left,right):
        self.parent = parent
        self.left = left
        self.right = right

def getdepth(u):
    for i in range(N):
        depth = 0
        j = i
        while trees[j].parent != -1:
            j = trees[j].parent
            depth += 1
        depths[i] = depth


N = int(input())
# ?????????
trees = [Tree(-1,-1,-1) for i in range(N)]
for i in range(N):
    l = list(map(int, input().split()))
    no = l[0]
    jisu = l[1]
    # 2???????????????????????§???????´??????????
    childs = l[2:]
    for j in range(jisu):
        child = childs[j]
        if j == 0:
            trees[no].left = child

        if j != len(childs)-1:
            trees[child].right = childs[j+1]

        trees[child].parent = no

r = 0
for i in range(N):
    if trees[i].parent == -1:
        r = i

depths = [-1] * N
getdepth(r)

for i in range(N):
    type = ""
    if trees[i].parent == -1: type = "root"
    elif trees[i].left == -1: type = "leaf"
    else: type = "internal node"
    childs = "["
    child = trees[i].left
    while child != -1:
        childs += str(child)
        child = trees[child].right
        if child != -1: childs += ", "
    childs += "]"

    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, trees[i].parent, depths[i], type, childs))
from sys import exit, stdin
S = stdin.readline().rstrip().split()
if S[3] == S[4] and S[5] == S[6]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

from sys import exit, stdin
S = stdin.readline().rstrip()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
from operator import itemgetter

N = int(input())

A = []
for i in range(N - 1):
    A.append(sorted([int(i) for i in input().split()]))    
A.sort(key = itemgetter(0))

link_list = [[] for i in range(N)]
for row in A:
    link_list[row[0] - 1].append(row[1] - 1)
edge_color = dict()

def DFS_color(node, pre_color):
    target_list = link_list[node]
    color = 1
    if target_list == []:
        pass
    else:
        for ko_node in target_list:
            if pre_color == color:
                color += 1
            edge_color[node, ko_node] = color 
            DFS_color(ko_node, color)
            color += 1

DFS_color(0, 0)

print(max(edge_color.values()))
for node1, node2 in A:
    print(edge_color[node1 - 1, node2 - 1])

### FIXED CODE ###

from operator import itemgetter
import sys
sys.setrecursionlimit(10**7)

N = int(input())


A = []
for i in range(N - 1):
    A.append([int(i)-1 for i in input().split()])

B = []
for row in A:
    B.append(sorted(row))
B.sort(key = itemgetter(0))

link_list = [[] for i in range(N)]
for row in B:
    link_list[row[0]].append(row[1])
    link_list[row[1]].append(row[0])
edge_color = dict()
marker = [0] * N


def DFS_color(node, pre_color):
    target_list = link_list[node]
    color = 1
    for ko_node in target_list:
        if marker[ko_node] == 0:
            if pre_color == color:
                color += 1
            edge_color[node, ko_node] = color
            edge_color[ko_node, node] = color 
            marker[ko_node] = 1
            DFS_color(ko_node, color)
            color += 1
        else:
            pass

marker[0] = 1
DFS_color(0, 0)

print(max(edge_color.values()))
for node1, node2 in A:
    print(edge_color[node1, node2])
from numba import njit


@njit
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [10**6] * (N+1)
    dp[0] = 0

    for i in range(1, N):
        for j in range(min(i, K)):
            dp[i] = min(dp[i], dp[i-j-1]+abs(h[i]-h[i-j-1]))

    print(dp[N-1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

from numba import njit


@njit
def main(N, K, h):
    dp = [10**10] * (N+1)
    dp[0] = 0

    for i in range(1, N):
        for j in range(min(i, K)):
            dp[i] = min(dp[i], dp[i-j-1]+abs(h[i]-h[i-j-1]))

    return dp[N-1]


if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    print(main(N, K, h))
S = input().split()
S = list(S)
T = input.split()
T = list(T)
for i in S:
  if(S[i]!=T[i]):
    count++;

print(count)

### FIXED CODE ###

S = input()
s = list(S)
T = input()
t = list(T)
s1=s[0]
t1=t[0]
count = 0
j=0
for i in S:
  if(s[j]!=t[j]):
    count=count+1
  j=j+1
print(count)
i = lambda:map(int,input().split())
_,_,x,y = i()
x_sigma = list(i())
y_sigma = list(i())
print('No War' if max(*x_sigma,x) < min(*y_sigma,y) else 'War')


### FIXED CODE ###


i = lambda:map(int,input().split())
_,_,x,y = i()
print('No War' if len(set(range(max(i())+1,min(i())+1)).intersection(set(range(x+1,y+1)))) > 0 else 'War')
def main():
 i = 0

 while True:
   i += 1
   n = input()
   if n = 0: break
   print('Case ' +str(i) +': ' + n)
main()



### FIXED CODE ###

case = 0
while 1:
    case += 1
    n = int(input())
    if n == 0: break
     
    print("Case {}: {}".format(case, n))
n = int(input())
a = list(map(int, input().split()))
l = []
for i in a:
    count = 0
    for j in range(1, 30):
        if i%(2**j) == 0:
            count += 1
        else:
            l.append(count)
            break
print(min(l))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
l = []
for i in a:
    count = 0
    for j in range(1, 31):
        if i%(2**j) == 0:
            count += 1
        else:
            l.append(count)
            break
print(min(l))
import sys
 
def main():
	x = sys.stdin.read()
    if x == 7 or x == 5 or x == 3:
        print("YES")
    else:
        print("NO")
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
 
def main():
    x = int(sys.stdin.readline().strip())
    
    if x == 7 or x == 5 or x == 3:
        print("YES")
    else:
        print("NO")
 
if __name__ == "__main__":
    main()
N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg = 'Yes'
for i, l in enumerate(list):
  if l <= list[i + 1] or l <= list[i + 1] - 1:
    flg = 'No'
    break
 
print(flg)

### FIXED CODE ###

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l - 1 > list[i + 1] and l < list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)
import numpy as np

N,K = list(map(int, input().split(",")))
h = []
for _ in range(N):
    h.append(int(input()))
h = sorted(h)
res = h[N-1] - h[0]
for i in np.arange(0,N-K+1,1):
    tmp = h[i+K-1] - h[i]
    if res > tmp:
        res = tmp
    
print(res)
    


### FIXED CODE ###

import numpy as np

N,K = list(map(int, input().split()))
h = []
for _ in range(N):
    h.append(int(input()))
h = sorted(h)
res = h[N-1] - h[0]
for i in np.arange(0,N-K+1,1):
    tmp = h[i+K-1] - h[i]
    if res > tmp:
        res = tmp
    
print(res)
import sys
from collections import Counter

#[(105, 3), (120, 1), (106, 1), (119, 1)]
def selection(l1, l2, x ,y):
    
    #print(x)
    #print(y)
    
    #それぞれの出現値が同じ場合
    if x >= len(l1) or y >= len(l2):
        return x - 1, y - 1
        
    if l1[x][0] == l2[y][0]:
            
        #出現回数が同じとき
        if l1[x][1] == l2[y][1]:
            x += 1
            y += 1
            return selection(l1, l2, x ,y)
            
    #出現回数を比較し、少ない方を2番目の出現値で返す
    if l1[x][1] > l2[y][1]:
        y -= 1
    else:
        x -= 1
    
    return x, y
    

def main():
    input = sys.stdin.readline
    
    n = int(input())
    m = [int(i) for i in input().split()]
    
    even = [m[i] for i, _ in enumerate(m) if i % 2 == 0]
    odd = [m[i] for i, _ in enumerate(m) if i % 2 == 1]
    
    even_c = Counter(even).most_common()
    odd_c = Counter(odd).most_common()
    
    
    x, y = selection(even_c, odd_c, 0 ,0)
    
    #全部ばらばら
    if(even_c[x][1] + odd_c[y][1] == 2):
        print(len(m) - 1)
        return
    
    #全部一緒
    if even_c[x][1] == odd_c[y][1]:
        print(len(m) - even_c[x][1])
        return
    
    print( len(m) - (even_c[x][1] + odd_c[y][1]) )
    
    
if __name__ == '__main__':
    main()
    

### FIXED CODE ###

import sys
from collections import Counter
 
def main():
    input = sys.stdin.readline
    
    n = int(input())
    m = [int(i) for i in input().split()]
    
    #偶数列 奇数列
    even = [m[i] for i, _ in enumerate(m) if i % 2 == 0]
    odd = [m[i] for i, _ in enumerate(m) if i % 2 == 1]
    
    #頻値を取り出す
    even_c = Counter(even).most_common()
    odd_c = Counter(odd).most_common()
    
    ans = -1
    
    #print(even_c)
    #print(odd_c)
    #print(len(even_c))
    
    #最頻値の比較
    if even_c[0][0] != odd_c[0][0]:
        ans = len(m) - (even_c[0][1] + odd_c[0][1])
    
    #偶数列と奇数列の最頻値の数字が同じかつ、全て同じ数字じゃない
    elif even_c[0][0] == odd_c[0][0] and len(even_c) > 1:
        ans1 = len(m) - (even_c[0][1] + odd_c[1][1])
        ans2 = len(m) - (even_c[1][1] + odd_c[0][1])
        ans = ans1 if ans1 <= ans2 else ans2
    
    #全て同じ
    else:
        ans = even_c[0][1]
        
    #出力
    print(ans)
    
if __name__ == '__main__':
    main()
X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(10000000))
    ab = 101
    an = []
    for i in range(-1.N):
        a.remove(P[i])
        a = a
    for j in range(101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)
        
 

    

### FIXED CODE ###

X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(10000000))
    ab = 101
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(0,102):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)
N = input()
if N == 1:
    print('Hello World')
else:
    AB = [int(input()) for i in range(2)]
    print(sum(AB))

### FIXED CODE ###

N = int(input())

if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)
stack = []
for s in input():
    if s == '0' or s == '1':
        stack.append(s)
    if s == 'B':
        stack.pop()
print(''.join(stack))

### FIXED CODE ###

stack = []
for s in input():
    if s == '0' or s == '1':
        stack.append(s)
    elif s == 'B' and len(stack) != 0:
        stack.pop()
print(''.join(stack))
n=int(input())
a=list(map(int,input().split()))
s=[i for i in a if i<0]
t=sorted([i for i in a if i>0])
if len(s)==0:
    print(t[-1]-t[0]+sum(t[1:-1]))
    k=t[0]
    for i in range(1,n-1):
        print(k,t[i])
        k-=t[i]
    print(t[-1],k)
elif len(t)==0:
    d=s[0]
    print(s[0]-sum(s[1:]))
    for i in range(1,n):
        print(d,s[i])
        d-=s[i]
else:
    print(t[-1]-sum(s)+sum(t[:-1]))
    p=t[-1]
    for i in range(1,len(s)):
        print(p,s[i])
        p-=s[i]
    g=s[0]
    for i in range(len(t)-1):
        print(g,t[i])
        g-=t[i]
    print(p,g)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
s=sorted([i for i in a if i<0])
t=sorted([i for i in a if i>=0])
if len(s)==0:
    print(t[-1]-t[0]+sum(t[1:-1]))
    k=t[0]
    if n!=2:
        for i in range(1,n-1):
            print(k,t[i])
            k-=t[i]
    print(t[-1],k)
elif len(t)==0:
    d=s[-1]
    print(s[-1]-sum(s[:-1]))
    for i in range(n-1):
        print(d,s[i])
        d-=s[i]
else:
    print(t[-1]-sum(s)+sum(t[:-1]))
    p=t[-1]
    for i in range(1,len(s)):
        print(p,s[i])
        p-=s[i]
    g=s[0]
    for i in range(len(t)-1):
        print(g,t[i])
        g-=t[i]
    print(p,g)
n, a, b = map(int, input().split())
     
    ans = 0
    for num in range(n):
      num += 1
      num_0 = num
      place_of_10000 = num//10000
      num -= 10000*place_of_10000
      place_of_1000 = num//1000
      num -= 1000*place_of_1000
      place_of_100 = num//100
      num -= 100*place_of_100
      place_of_10 = num//10
      num -= 10*place_of_10
      
      tmp = place_of_10000 + place_of_1000 + place_of_100 + place_of_10 + num
      if a<=tmp and tmp<=b:
        ans += num_0
        
    print(ans)

### FIXED CODE ###

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

total = 0

for n in range(1,N+1):
    sum = 0
    q = n
    while q != 0:
        sum += (q%10)
        q = q//10
    if (A<=sum) and (sum<=B):
        total += n

print(total)
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2];
}

### FIXED CODE ###

arr = [input() for i in range(3)]
print(arr[0][0]+arr[1][1]+arr[2][2])
S = list(input())
ACGT_filter = ['A', 'C', 'G', 'T']

str_length = 0
str_lengths = []
for s in S:
    if s in ACGT_filter:
        str_length += 1
    else:
        str_lengths.append(str_length)
        str_length = 0

print(max(str_lengths))

### FIXED CODE ###

ACGT_filter = ['A', 'C', 'G', 'T']

ans = 0
now = 0
for s in input():
    if s in ACGT_filter:
        now += 1
    else:
        now = 0
    ans = max(now, ans)

print(ans)
n = input()
dic = [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]
for i in range(26):
  if n.count(dic[i])%2!=0:
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

n = input()
dic = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
  if n.count(str(dic[i]))%2!=0:
    print("No")
    exit()
print("Yes")
N = int(input())
n = "Three"

for i in (N):
  S = input().split()
  If S == "Y":
    n = "Four"
    break
print(n)
    

  

### FIXED CODE ###

N = int(input())
number = "Three"
S = input().split()

for i in range(N):
  if S[i] == "Y":
    number = "Four"
    break

print(number)
#!/usr/bin/env python3

N = int(input())


Ret = [0 for _ in range(10**4+1)]

for i in range(1, N+1):
    for j in range(1, N+1):
        for k in range(1, N+1):
            r = i**2 + j**2 + k**2 + i*j + j*k + i*k
            Ret[r] += 1

for r in Ret[1:N+1]:
    print(r)




### FIXED CODE ###

#!/usr/bin/env python3

N = int(input())

Ret = [0 for _ in range(10**5)]

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            r = i**2 + j**2 + k**2 + i*j + j*k + i*k
            if r > len(Ret): print(r)
            Ret[r] += 1

for r in Ret[1:N+1]:
    print(r)
a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a):
  if ar[i] < ar[i-1] and ar[i] > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar[i] > ar[i-1]:
    count += 1
print(count)


### FIXED CODE ###

a = int(input())
ar = list(map(int,input().split(" ")))
count = 0
for i in range(1,a-1):
  if ar[i] < ar[i-1] and ar[i] > ar[i+1]:
    count += 1
  elif ar[i] < ar[i+1] and ar[i] > ar[i-1]:
    count += 1
print(count)
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    if S == N:
        return N + 1

    def f(b, n):
        if n < b:
            return n
        return f(b, n//b) + n % b

    for b in range(2, int(math.sqrt(N)) + 1):
        s = f(b, N)
        if s == S:
            return b

    for p in range(1, int(math.sqrt(N))):
        b = (N - S + p) // p
        s = f(b, N)
        if s == S:
            return b

    return -1


def main():
    N = read_int()
    S = read_int()

    print(slv(N, S))


if __name__ == '__main__':
    main()


### FIXED CODE ###


# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    if S == N:
        return N + 1

    def f(b, n):
        if n < b:
            return n
        return f(b, n//b) + n % b

    for b in range(2, int(math.sqrt(N)) + 1):
        s = f(b, N)
        if s == S:
            return b

    cnd = []
    for p in range(1, int(math.sqrt(N))+1):
        b = (N - S) // p + 1
        if b < 2:
            continue
        s = f(b, N)
        if s == S:
            cnd.append(b)

    if cnd:
        return min(cnd)

    return -1


def main():
    N = read_int()
    S = read_int()

    print(slv(N, S))


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

a = [0,2,5,5,4,5,6,3,7,6]

kazu = [a[List[i]] for i in range(M)]

def dddd(kazu,X):
  dp = [ [ 0 for j in range(X+1)]  for i in range(M)]

  for i in range(M):
    for j in range(X):
      if kazu[i] <= j:
        dp[i][j+1] = max(dp[i][j+1-kazu[i]] + 1,dp[i-1][j+1])
      else:
        dp[i][j+1] = dp[i-1][j+1]
  return dp[-1]
   
keta_arr = dddd(kazu,N)
keta = keta_arr[-1]
List.sort(reverse=True)
ans = []
x = 0

for i in range(keta):
  for aa in List:
    k = a[aa]
    if N-k >= 0:
      if keta_arr[-k-1-x] == keta-i-1:
        ans.append(aa)
        x += k
        N = N-k
    else:
      continue
ans.sort(reverse=True)
print(int(''.join(map(str,ans))))

### FIXED CODE ###

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

a = [0,2,5,5,4,5,6,3,7,6]

kazu = [a[List[i]] for i in range(M)]

def dddd(kazu,X):
  dp = [ [ -float('inf') for j in range(X+1)]  for i in range(M)]
  for i in range(M):
    dp[i][0] = 0

  for i in range(M):
    for j in range(X+1):
      if kazu[i] <= j:
        dp[i][j] = max(dp[i][j-kazu[i]] + 1,dp[i-1][j])
      else:
        dp[i][j] = dp[i-1][j]
  return dp[-1]
   
keta_arr = dddd(kazu,N)
keta = keta_arr[-1]
List.sort(reverse=True)
ans = []

while keta>0:
  for aa in List:
    k = a[aa]
    if N-k < 0:
      continue
    if N-k >= 0:
      if keta_arr[N-k] == keta-1:       
        ans.append(aa)
        N = N-k
        keta -= 1
        break
ans.sort(reverse=True)
print(int(''.join(map(str,ans))))
# coding: utf-8
# Your code here!
# from collections import Counter
# from functools import *

def LI():
    return list(map(int,input().split()))

n,k=LI()
a=LI()
b=[]
visited=[-1]*n

now=1
for i in range(k):
    nxt=a[now-1]
    b.append(nxt)
    if visited[nxt-1]==-1:
        visited[nxt-1]=i+1
    else:
        mod=(visited[nxt-1],i+1)
        break
    now=nxt

ml,mr=mod
k=(k-ml)%(mr-ml)+ml
print(k)

print(b[k-1])

### FIXED CODE ###

n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))

MAX_N=2*10**5
b=[1]
visited=[-1]*(n+10)
for i in range(1,2*MAX_N+1):
    nxt=a[b[-1]]
    b.append(nxt)
        
if k<=n:
    print(b[k])
    exit()
# print(b)  
for i,bi in enumerate(b):
    if visited[bi]==-1:
        visited[bi]=i
    else:
        m=i-visited[bi]
        l=visited[bi]
        break
k=k%m

while k<n:
    k+=m
print(b[k])
n,y = map(int,input().split())
fl = 0
for i in range(n+1):
  for j in range(n+1):
    if n-i-j>=0 && 10000*(n-i-j)+5000*j+1000*i == y:
      print("{0}{1}{2}".format(n-i-j,j,i))
      fl = 1
      break
  break
if(fl==0):
  print("-1 -1 -1")

### FIXED CODE ###

n,y = map(int,input().split())
fl = 0
for i in range(n+1):
  for j in range(n+1):
    if n-i-j>=0 and 10000*(n-i-j)+5000*j+1000*i == y:
      print("{0} {1} {2}".format(n-i-j,j,i))
      fl = 1
      break
  if(fl == 1):
    break
if(fl==0):
  print("-1 -1 -1")
a,b,op=map(int,raw_input().split())

while 1:
 if op = '?':
   break
 elif op = '+':
   print a+b
 elif op = '-':
   print a-b
 elif op = '/':
   print a/b
 elif op = '*':
   print a*b
  

### FIXED CODE ###

while True:
    a, op, b = raw_input().split()
    ai = int(a)
    bi = int(b)
    if op == '?':
        break
    elif op == '+':
        print(ai + bi)
    elif op == '-':
        print(ai - bi)
    elif op == '*':
        print(ai * bi)
    elif op == '/':
        print(ai / bi)
n = int(input())
a = list(map(int, input().split()))
ans =0
for i in range(n+1):
    if i%2==0 and a[i]%2!=0:
        ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i%2==0 and a[i]%2!=0:
        ans+=1
print(ans)
inp = input()
inp = inp.split()
N = int(inp[0])
M = int(inp[1])
BigM = N+2

E = []
for m in range(M):
    abinp = input()
    abinp = abinp.split()
    a = int(abinp[0])
    b = int(abinp[1])
    E.append(set([a,b]))

output = [0] + [0] + [BigM]*(N-1)
prev_cnt = 0
now = [1]

while len(now) > 0:
    n = now.pop(0)
    prev_cnt += 1
    for e in E:
        if n in e:
            next = list(e - set([n]))[0]
            if output[next] == BigM:
                output[next] = n
                now.append(int(next))
                E.remove(e)

if prev_cnt == N:
    print("Yes")
    for n in range(2,N+1):
        print(output[n])
else:
    print("No")




### FIXED CODE ###

num = int(input())%10

honlist = [2,4,5,7,9]
ponlist = [0,1,6,8]
bonlist = [3]

if num in honlist:
    print("hon")
elif num in ponlist:
    print("pon")
else:
    print("bon")
A,B,C,K = list(map(int, input().split()))

    
if A > K:
  print(A)
elif A <= K and A + B > K:
  print(A):
elif A <= K and A + B <= K:
  print(A - (K - A - B))

### FIXED CODE ###

A,B,C,K = map(int,input().split())
 
if K <= A:
    print(str(K))
elif K <= A + B:
    print(str(A))
else:
    print(str(A - (C - (A + B + C - K))))