Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from sys import setrecursionlimit
setrecursionlimit(100000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

nodes = [[] for _ in range(N)]
for a, b in ab:
  nodes[a-1].append(b-1)
  nodes[b-1].append(a-1)

used = [set() for _ in range(N)]
K = max(len(nodes[i]) for i in range(N))
print(K)

colors = [[-1] * N for _ in range(N)]

def f(node, out, p):
  cn = 1
  for n in nodes[node]:
    if n == p:
      continue
    if cn == out:
      cn += 1
    colors[node][n] = cn
    colors[n][node] = cn
    f(n, cn, node)
    cn += 1

f(0, -1, -1)

for a, b in ab:
  print(colors[a-1][b-1])


### FIXED CODE ###

from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])
### BUGGY CODE ###

import sys
readline = sys.stdin.buffer.readline

N = int(readline())

total = 0

while N >= 1:
    total += N % 10
    N //= 10
    total %= 9

ans = 'Yes' if total == 0 else 'No'

print(ans)

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline

N = int(readline())
ans = 'Yes' if N%9 == 0 else 'No'

print(ans)
### BUGGY CODE ###

H = int(input())
q, r = divmod(H, 2)
i = 1
while q != 1:
    q //= 2
    i += 1
ans = 0
for j in range(i + 1):
    ans += 2 ** j
print(ans)


### FIXED CODE ###

H = int(input())
L = len(bin(H)) - 2
ans = 0
for j in range(L):
    ans += 2 ** j
print(ans)
### BUGGY CODE ###

def f(As, M):
    prev = None
    c = 0

    for i, A in enumerate(As):
        A %= M
        if i == 0:
            prev = [A]
            if A == 0:
                c += 1
            continue

        ccc = [A]
        for p in prev:
            ccc.append((p + A) % M)
        c += ccc.count(0)
        prev = ccc
    return c


def main():
    N, M = [int(a) for a in input().split()]
    As = [int(a) for a in input().split()]
    print(f(As, M))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# def f(As, M):
#     prev = None
#     c = 0
#
#     for i, A in enumerate(As):
#         A %= M
#         if i == 0:
#             prev = {A: 1}
#             if A == 0:
#                 c += 1
#             continue
#
#         ccc = {A: 1}
#         for k in prev.keys():
#             v = prev[k]
#             newv = (k + A) % M
#             if newv in ccc:
#                 ccc[newv] += v
#             else:
#                 ccc[newv] = v
#         c += ccc[0] if 0 in ccc else 0
#         prev = ccc
#     return c
def f(As, M):
    totals = [As[0] % M]
    res = 1 if As[0] % M == 0 else 0
    for A in As[1:]:
        l = (totals[-1] + A) % M
        if l == 0:
            res += 1
        totals.append(l)

    # N = len(As)

    ddd = {}
    for t in totals:
        if t not in ddd:
            ddd[t] = 0
        res += ddd[t]
        ddd[t] += 1

    # for i in range(N):
    #     ii = totals[N - 1 - i]
    #     if ii == 0:
    #         res += 1
    #     for j in range(i + 1, N):
    #         jj = totals[N - 1 - j]
    #
    #         if jj == ii:
    #             res += 1
    return res


def main():
    N, M = [int(a) for a in input().split()]
    As = [int(a) for a in input().split()]
    print(f(As, M))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

total = 0
for i in range(k):
    if a > 0:
        total += 1
        a -= 1
    elif b > 0:
        total += 0
        b -= 1
    elif c > 0:
        total -= 1
        c -= 1
print(total)

### FIXED CODE ###

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


ka = k - a

if ka > 0:
    kb = ka - b
elif ka <= 0:
    a = k
    ka = 0
    kb = 0
else:
    kb = 0
print(a*1+ka*0+kb*-1)
### BUGGY CODE ###

n=int(input())
*a,=map(int,input().split())
for i in range(n):
    a[i]=a[i]%(10**9+7)
sum_a=[]
for i in range(n):
    sum_a.append(sum(a)-sum(a[:i+1]))
b=0
for i in range(n):
    b+=sum_a[i]*a[i]
print(b%(10**9+7))

### FIXED CODE ###

n=int(input())
*a,=map(int,input().split())
s=sum(a)%(10**9+7)
c=0
b=0
for i in range(n):
    b+=a[i]
    amod=a[i]%(10**9+7)
    c+=(s-b)*amod
print(c%(10**9+7))
### BUGGY CODE ###

[N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count > N + 200 : break

for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

import sys
N = int(input())
H = input().split()

count = 0
max = 0
flag = []
for i in (range(int(N)-1)):
  if(int(H[i]) >= int(H[i+1])):
    flag.append(i)
  else:
    continue

H.append(10000000000)

for i in flag:
  for j in range(i,int(N)):
    if(int(H[j]) >= int(H[j+1])):
      continue
    else:
      count = j - i
      break

  if (max < count):
    max = count
    count = 0

print(max)


### FIXED CODE ###

n = int(input())
L = list(map(int,input().split()))
 
count = 0
mcount = 0
for i in range(1,n):
      if L[i - 1] >= L[i]:
            count += 1
            if count >= mcount:
                  mcount = count
      else:
            count = 0
print(mcount)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
arridx = [(i, a) for i, a in enumerate(As)]
arridx.sort(key=lambda x: x[1])

dp = {}
dp[(0, N-1)] = 0
for i in range(N-1, -1, -1):
    ndp = {}
    for l in range(N-i+1):
        r = l + i - 1
        idx, a = arridx[i]
        lsc = rsc = 0
        if l > 0:
            # l-1, r から
            lsc = dp[(l-1, r)] + a * abs(l-1-idx)
        if r < N-1:
            # l, r+1 から
            rsc = dp[(l, r+1)] + a * abs(r+1-idx)
        ndp[(l, r)] = max(lsc, rsc)
    dp = ndp
print(max(dp.values()))

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
arridx = [(i, a) for i, a in enumerate(As)]
arridx.sort(key=lambda x: x[1])

dp = {}
dp[(0, N-1)] = 0
for i in range(N-1, -1, -1):
    ndp = {}
    for l in range(N-i+1):
        r = l + i - 1
        idx, a = arridx[i]
        lsc = rsc = 0
        if l > 0:
            # l-1, r から
            lsc = dp[(l-1, r)] + a * abs(l-1-idx)
        if r < N-1:
            # l, r+1 から
            rsc = dp[(l, r+1)] + a * abs(r+1-idx)
        ndp[(l, r)] = max(lsc, rsc)
    dp = ndp
print(max(dp.values()))
### BUGGY CODE ###

x = int(input())
for a in range(-10000, 10000):
    for b in range(-10000, 10000):
        if a**5 - b**5 == x:
            print(a, b)
            quit()

### FIXED CODE ###

x = int(input())
for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if a**5 - b**5 == x:
            print(a, b)
            quit()
### BUGGY CODE ###

#12:40
n = int(input())
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
dp = [0]
for i in range(1,n+1):
  tmp = dp[-1]+1
  if i-a1 >= 0:
    if dp[i-a1]+b1 > tmp:
      tmp = dp[i-a1]+b1
  if i-a2 >= 0:
    if dp[i-a2]+b2 > tmp:
      tmp = dp[i-a2]+b2
  if i-a3 >= 0:
    if dp[i-a3]+b3 > tmp:
      tmp = dp[i-a3]+b3
  dp.append(tmp)
m = dp[-1]
#print(dp)
#print(m)
dp = [0]
for j in range(1,m+1):
  tmp = dp[-1]+1
  if j-b1 >= 0:
    if dp[j-b1]+a1 > tmp:
      tmp = dp[j-b1]+a1
  if j-b2 >= 0:
    if dp[j-b2]+a2 > tmp:
      tmp = dp[j-b2]+a2
  if j-b3 >= 0:
    if dp[j-b3]+a3 > tmp:
      tmp = dp[j-b3]+a3
  dp.append(tmp)
print(dp[-1])

### FIXED CODE ###

#12:40
n = int(input())
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
dp = [0] * (n+1)
for i in range(1,n+1):
  tmp = dp[i-1]+1
  if i-a1 >= 0:
    if dp[i-a1]+b1 > tmp:
      tmp = dp[i-a1]+b1
  if i-a2 >= 0:
    if dp[i-a2]+b2 > tmp:
      tmp = dp[i-a2]+b2
  if i-a3 >= 0:
    if dp[i-a3]+b3 > tmp:
      tmp = dp[i-a3]+b3
  dp[i] = tmp
m = dp[-1]
#print(dp)
#print(m)
dp = [0] * (m+1)
for j in range(1,m+1):
  tmp = dp[j-1]+1
  if j-b1 >= 0:
    if dp[j-b1]+a1 > tmp:
      tmp = dp[j-b1]+a1
  if j-b2 >= 0:
    if dp[j-b2]+a2 > tmp:
      tmp = dp[j-b2]+a2
  if j-b3 >= 0:
    if dp[j-b3]+a3 > tmp:
      tmp = dp[j-b3]+a3
  dp[j] = tmp
print(dp[-1])
### BUGGY CODE ###

from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from fractions import gcd

NN = 202020
# MOD = 10**9+7
MOD = 998244353
INF = float("inf")

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [[[0]*3 for _ in range(k+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
    for j in range(k+1):
        dp[i+1][j][0] = (dp[i+1][j][0] + dp[i][j][0])%MOD
        dp[i+1][j][1] = (dp[i+1][j][1] + dp[i][j][0] + dp[i][j][1])%MOD
        dp[i+1][j][2] = (dp[i+1][j][2] + dp[i][j][0] + dp[i][j][1] + dp[i][j][2])%MOD
        if j + A[i] <= k:
            dp[i+1][j+A[i]][1] = (dp[i+1][j+A[i]][1] + dp[i][j][0] + dp[i][j][1])%MOD
            dp[i+1][j+A[i]][2] = (dp[i+1][j+A[i]][2] + dp[i][j][0] + dp[i][j][1])%MOD

print(dp[n][k][2])


### FIXED CODE ###

import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

# MOD = 10 ** 9 + 7
MOD = 998244353
# sys.setrecursionlimit(10**8)

n, s = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]

for i in range(n+1):
    dp[i][0] = i + 1

ans = 0
for i in range(n):
    for j in range(s + 1):
        if s > j > 0:
            dp[i + 1][j] += dp[i][j]
        if j + A[i] <= s:
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= MOD

    ans += dp[i + 1][s] * (n - i)
    ans %= MOD

print(ans)
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
ans = []
for i in range(q):
    l,r = map(int,input().split())
    buf = s[max(0,l-1):r]
    ans.append(buf.count('AC'))

for aa in ans:
    print(aa)


### FIXED CODE ###

n,q = map(int,input().split())
s = input()
ans = []
li = [0] * (len(s))
count = 0

for i in range(1,len(s)):
    if s[i] == 'C' and s[i-1] == 'A':
        count += 1
    li[i] = count

for i in range(q):
    l,r = map(int,input().split())
    tmp = li[r-1] - li[l-1]
    ans.append(tmp)

for aa in ans:
    print(aa)
### BUGGY CODE ###

N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-2:
      break
      j+=1    
  count+=1
  j+=2
print(count)

### FIXED CODE ###

N=int(input())
count=1
size=1
p=list(map(int,input().split()))
q=[p[0]]
for i in range (1,N):
  if p[i]!=p[i-1]:
    q.append(p[i])
    size+=1
j=0
while True:
  if j>=size-2:
    break
  while (q[j]-q[j+1])*(q[j+1]-q[j+2])>=0:
    if j>=size-3:
      count-=1
      break
    j+=1    
  count+=1
  j+=2
print(count)
### BUGGY CODE ###

import sys
from itertools import product

def main():
    input = sys.stdin.readline
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    AB = []
    for x in product(A, B):
        AB.append(sum(x))

    AB = sorted(AB, key=lambda x: -x)
    AB = AB[:K]

    ABC = []
    for x in product(AB, C):
        ABC.append(sum(x))

    ABC = sorted(ABC, key=lambda x: -x)
    for i in range(K):
        print(ABC[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from heapq import heappush, heappop

def main():
    input = sys.stdin.readline
    X, Y, Z, K = map(int, input().split())
    A = sorted(list(map(int, input().split())), key=lambda x: -x)
    B = sorted(list(map(int, input().split())), key=lambda x: -x)
    C = sorted(list(map(int, input().split())), key=lambda x: -x)

    deli = []
    heappush(deli, (-A[0]-B[0]-C[0], 0, 0, 0))
    pushed = set((0,0,0))
    for _ in range(K):
        d = heappop(deli)
        i, j, k = d[1], d[2], d[3]

        if i+1 < X and (i+1, j, k) not in pushed:
            heappush(deli, (-A[i+1]-B[j]-C[k], i+1, j, k))
            pushed.add((i+1, j, k))

        if j+1 < Y and (i, j+1, k) not in pushed:
            heappush(deli, (-A[i]-B[j+1]-C[k], i, j+1, k))
            pushed.add((i, j+1, k))

        if k+1 < Z and (i, j, k+1) not in pushed:
            heappush(deli, (-A[i]-B[j]-C[k+1], i, j, k+1))
            pushed.add((i, j, k+1))

        print(-d[0])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

N=int(input())
l=[]
for i in range(N):
    a=int(input())
    l.append(a)
len_l=len(l)
now=[]
for i in range(len_l):
    now=l[0:i]+l[i+1:len_l]
    print(max(now))
    

### FIXED CODE ###

import copy
N=int(input())
A=[int(input()) for i in range(N)]
A_f=copy.deepcopy(A)
A_f.sort()
A_max=A_f[N-1]
A_sec=A_f[N-2]

for i in A:
    if i==A_max:
        print(A_sec)
    else:
        print(A_max)
### BUGGY CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))

ans=[0]*N
ans[1]=abs(h[1]-h[0])


for i in range(2,N):
    ans[i] = min(abs(h[i] - h[j]) + ans[j] for j in range(max(0,i-K),i))
print(ans[N-1])

### FIXED CODE ###

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

    ans=[0]*N
    ans[1]=abs(h[1]-h[0])


    for i in range(2,N):
        ans[i] = min(abs(h[i] - h[j]) + ans[j] for j in range(max(0,i-K),i))
    print(ans[N-1])
    
main()
### BUGGY CODE ###

n, k = map(int,input().split())
p = [int(a) for a in input().split()]

max_index = 0
max_sum = 0
for i in range(n-k+1):
  t = sum(p[i:i+k])
  if max_sum < t:
    max_sum = t
    max_index = i

ans = 0
for j in range(max_index, max_index+k):
  su = 0
  for l in range(1, p[j]+1):
    su += l
  ans += su / p[j]
print(ans)

### FIXED CODE ###

n, k = map(int,input().split())
i = 0
kitaichi = [0] * n
kitaichi_sum = [0] * n
ans = 0
for p in input().split():
  kitaichi[i] = int(p) * (int(p)+1) / 2 / int(p)
  if i == 0:
    kitaichi_sum[i] = kitaichi[i]
  elif i >= k:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i] - kitaichi[i-k]
    if kitaichi_sum[i] > ans:
      ans = kitaichi_sum[i]
  else:
    kitaichi_sum[i] = kitaichi_sum[i-1] + kitaichi[i]
  if kitaichi_sum[i] > ans:
    ans = kitaichi_sum[i]
  i += 1
print(ans)
### BUGGY CODE ###

n = int(input())
h = list(map(int, input().split()))


w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0

for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        for k in range(j,n-2):
            if h[k+1] - h[k+2] == 1:
                w = 0


        
if w == 0:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))


w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0

for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        for k in range(j,n-2):
            if h[k+1] - h[k+2] == 0:
                continue
            if h[k+1] - h[k+2] == 1:
                w = 0
                break
            break


        
if w == 0:
    print("No")
else:
    print("Yes")
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

for i in range(Q):
  l, r = map(int, input().split())
  tmp = S[l-1:r]
  cnt = 0
  for j in range(len(tmp)-1):
    if tmp[j] == 'A' and tmp[j+1] == 'C':
      cnt += 1
  print(cnt)


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
f = [0] * N
for i in range(N-1):
  add = 0
  if S[i:i+2] == 'AC':
    add = 1
  if i == 0:
    f[i+1] = add
  else:
    f[i+1] = f[i] + add

#print(f)
for i in range(Q):
  l, r = map(int, input().split())
  print(f[r-1]-f[l-1])
### BUGGY CODE ###

N = int(input())
ans = 0
s = N//2+1
for i in range(1, s):
  if N%i == 0:
    a = N/i - 1
    if a > i:
      ans += a
    else:
      break;
print(int(ans))

### FIXED CODE ###

import math
N = int(input())
ans = 0
s = math.sqrt(N)
for i in range(1, math.ceil(s)):
  if N%i == 0:
    a = N/i - 1
    if a > i:
      ans += a
    else:
      break;
print(int(ans))
### BUGGY CODE ###

import sys
import math
import collections
#n = int(input())
#a, b = map(int, input().split())
s = input()
#x = list(map(int, input().split()))
q = int(input())
l = []
for i in range(len(s)):
    l.append(s[i])

rev = 1
for i in range(q):
    que = list(map(str, input().split()))
    if que[0] == "1":
        rev *= -1

    else:
        if rev == 1:
            if que[1] == "1":
                l.insert(0, que[2])
            else:
                l.append(que[2])

        else:
            if que[1] == "1":
                l.append(que[2])
            else:
                l.insert(0, que[2])

if rev == 1:
    for i in range(len(l)):
        print(l[i], end="")
else:
    for i in range(len(l)):
        print(l[len(l) - i - 1], end="")



### FIXED CODE ###

import sys
import math
import collections
from collections import deque
def main():
    #n = int(input())
    #a, b = map(int, input().split())
    s = input()
    #x = list(map(int, input().split()))
    q = int(input())
    d = deque([])
    for i in range(len(s)):
        d.append(s[i])

    rev = 1
    for i in range(q):
        que = sys.stdin.readline().split()
        if que[0] == "1":
            rev *= -1

        else:
            if rev == 1:
                if que[1] == "1":
                    d.appendleft(que[2])
                else:
                    d.append(que[2])

            else:
                if que[1] == "1":
                    d.append(que[2])
                else:
                    d.appendleft(que[2])


    if rev == 1:
        for i in range(len(d)):
            print(d.popleft(), end="")
    else:
        for i in range(len(d)):
            print(d.pop(), end="")

main()
### BUGGY CODE ###

import bisect

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

ans = [A[0]]
for i in range(1, N):
    index = bisect.bisect_left(ans, A[i])
    if index > 0:
        ans[index - 1] = A[i]
    else:
        ans.insert(0, A[i])

print(len(ans))


### FIXED CODE ###

import bisect
from collections import deque

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

ans = deque([A[0]])
for i in range(1, N):
    index = bisect.bisect_left(ans, A[i])
    if index > 0:
        ans[index - 1] = A[i]
    else:
        ans.appendleft(A[i])

print(len(ans))
### BUGGY CODE ###

n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

b.sort()
m = 0
l = n+1

for i in range(n):
    m = 0
    l = n+1
    while a[i] != b[(m+l)//2]:
        if a[i] < b[(m+l)//2]:
            l //= 2
        else:
            m = i
    tmp = b[(m+l)//2]
    b[(m+l)//2] = 0
    print(max(b))
    b[(m+l)//2] = tmp

### FIXED CODE ###

n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

b.sort()

for i in range(n):
    if a[i] != b[-1]:
        print(b[-1])
        continue
    else:
        print(b[-2])
### BUGGY CODE ###

import itertools

K, S = map(int, input().strip().split(' '))

X = range(K + 1)
Y = range(K + 1)
Z = range(K + 1)

count = 0
for i, j, k in itertools.product(X, Y, Z):
  if i + j + k == S:
    count += 1
print(count)

### FIXED CODE ###

import itertools

K, S = map(int, input().strip().split(' '))
X = list(range(K + 1))
count = 0
for i, j in itertools.product(X, repeat=2):
  if 0 <= S - i - j <= K:
    count += 1
print(count)
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
add=[0]*n
for _ in range(q):
    a,b=map(int,input().split())
    add[a-1]+=b
st=set() ; v=0 ; s=add[0]
ans=[0]*n
def dfs(g,v,s):
    global ans,st
    if v not in st:
        st.add(v)
        ans[v]+=s
    else: return
    for p in g[v]:
        dfs(g,p,s+add[p])
dfs(g,v,s)
print(*ans)
        
        
    
    

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
n,q=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
add=[0]*n
for _ in range(q):
    a,b=map(int,input().split())
    add[a-1]+=b
st=set() ; v=0 ; s=add[0]
ans=[0]*n
def dfs(g,v,s):
    global ans,st
    if v not in st:
        st.add(v)
        ans[v]+=s
    else: return
    for p in g[v]:
        dfs(g,p,s+add[p])
dfs(g,v,s)
print(*ans)
### BUGGY CODE ###

K = int(input())
S = '7'
ans = 0
while ans == 0:
    if int(S)%K == 0:
        ans = 1
    elif K%2 == 0 or K%5 == 0:
        break
    else:
        S += '7'

if ans == 1:
    print(len(S))
else:
    print('-1')


### FIXED CODE ###

k = int(input())
ans = 7%k

for i in range(1, 10**6 + 1):
  if ans%k == 0:
    print(i)
    exit()
  else:
    ans = (ans*10 + 7)%k
print(-1)
### BUGGY CODE ###

colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
b_max = n // b
c_max = n // c
cnt = 0

for i in range(a_max + 1)[::-1]:
    b_max = (n - a * i) // b
    for j in range(b_max + 1)[::-1]:
        c_max = (n - a * i - b * j) // c
        for k in range(c_max + 1)[::-1]:
            if a * i + b * j + c * k == n:
                cnt += 1
            elif a * i + b * j + c * k < n:
                break     
print(cnt)

### FIXED CODE ###

colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
cnt = 0
ip, jp, kp = -1, -1, -1

for i in range(a_max + 1):
    b_max = (n - a * i) // b
    d = n - a * i
    flag = 0
    for j in range(b_max + 1):
        c_max = (n - a * i - b * j) // c
        for k in range(c_max, c_max + 2):
            if a * i + b * j + c * k == n:
                cnt += 1
                if ip == i:
                    dj = j - jp
                    cnt += ((d // b - j) // dj)
                    flag = 1
                    break
                else:
                    ip, jp, kp = i, j, k
            elif a * i + b * j + c * k > n:
                break
        if flag == 1:
            break
print(cnt)
### BUGGY CODE ###

n=list(map(int,input().split()))
a=[int(input()) for i in range(n[2])]
men=list([n[1]]*n[0])
for i in a:
    men=[j-1 for j in men]
    men[i-1]+=1
for i in men:
    if i > 0:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

n=list(map(int,input().split()))
men=list([n[1]-n[2]]*n[0])
a=[int(input())-1 for i in range(n[2])]
for i in a:
    men[i]+=1
y = ["Yes" if i > 0 else "No" for i in men]
print('\n'.join(map(str, y)))