Harryxun/stf_run huggingface dataset:
n = int(input())
a = map(int, input().split(" "))
b = map(int, input().split(" "))
c = map(int, input().split(" "))

b_sum = sum(b)

c_sum = 0
for i in range(n-1):
    ai = a[i]
    if ai != n:
        c_sum += c[ai-1]

print(b_sum + c_sum)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

b_sum = sum(b)

c_sum = 0
for i in range(n-1):
    if a[i] != n:
        if a[i] + 1 == a[i+1]:
            c_sum += c[a[i]-1]

print(b_sum + c_sum)
n,d = list(map(int, input().split()))

count = 0
for i in range(n):
    x,y = list(map(int, input.split()))
    if (x**2 + y**2)**0.5 <= d:
        count += 1

print(count)


### FIXED CODE ###

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

count = 0
for i in range(n):
    x,y = list(map(int, input().split()))
    if (x**2 + y**2)**0.5 <= d:
        count += 1

print(count)
# coding:utf-8
# C - Grand Garden

N = int(input())
h = list(map(int,input().split()))
h += [0]
ans = 0

for _ in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                mini_ans += 1
            add = False

print(ans)

### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
h += [0]
add = False
ans = 0
for n in range(100):
    for i in range(N+1):
        if h[i] != 0:
            h[i] -= 1
            add = True
        else:
            if add:
                ans += 1
            add = False
print(ans)
s, _ = list(input().split())
a, b = list(map(int, input().split()))
u = input()
if s == u:
    a -= 1
else:
    b -= u
print(a, end=' ')
print(b)

### FIXED CODE ###

s, _ = list(input().split())
a, b = list(map(int, input().split()))
u = input()
if s == u:
    a -= 1
else:
    b -= 1
print(a, end=' ')
print(b)
import sys
sys.setrecursionlimit(10**6)
t=input()
tl=list(t)
tln=len(t)
x=t.find("?")
if x == 0:
    tl[x]="P"
    t="".join(tl)
while x != -1:
    x=t.find("?")
    if x == tln-1:
        tl[x]="D"
        t="".join(tl)
        break
    if tl[x-1]=="P":
        tl[x]="D"
    elif tl[x+1]=="?":
        tl[x]="P"
    elif tl[x+1]=="D":
        tl[x]="P"
    else:
        tl[x]="D"
    t="".join(tl)
print(t)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
t=input()
tl=list(t)
tln=len(t)
x=0
for x in range(tln):
    if tl[x] == "?":
        if x == tln-1:
            tl[x]="D"
            break
        elif x==0:
            if tl[x+1]=="?":
                tl[x]="P"
                tl[x+1]="D"
            else:
                tl[x]="D"
        elif tl[x-1]=="P":
            tl[x]="D"
        elif tl[x+1]=="?":
            tl[x]="P"
            tl[x+1]="D"
        elif tl[x+1]=="D":
            tl[x]="P"
        else:
            tl[x]="D"
t="".join(tl)
print(t)
n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
score = 1
for i in range(k-1, n-1):
    if int(score) < int(score*a[i+1]/a[i-k+1]):
        print('Yes')
    else:
        print('No')
    score = score*a[i+1]/a[i-k+1]

### FIXED CODE ###

n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
for i in range(k, n):
    score = 1
    if score < score*a[i]/a[i-k]:
        print('Yes')
    else:
        print('No')
s = input().split
s = s[0]+s[1]+s[2]

if s.count('5')==2 and s.count('7')==1:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

a, b, c = input().split()

if (a+b+c).count('5')==2 and (a+b+c).count('7')==1:
  print("YES")
else:
  print("NO")
N = input()
 
if N[-1]==2or N[-1]==4 or N[-1]==5or N[-1]==7or N[-1]==9:
    print('hon')
     
elif N[-1]==0or N[-1]==1or N[-1]==6or N[-1]==8:
    print('pon')
     
else:
    print('bon')

### FIXED CODE ###

N = input()
 
if N[-1]=='2' or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
    print('hon')
     
elif N[-1]=='0' or N[-1]=='1' or N[-1]=='6' or N[-1]=='8':
    print('pon')
     
else:
    print('bon')
import numpy as np

N, K = map(int, input().split())
rawdata = np.array([int(i) for i in input().split()])
setRange = np.reshape(np.arange(K+1), (K+1,1))

def df_calc(X, A):
    return X^A
vfunc = np.vectorize(df_calc)

res = vfunc(rawdata, setRange)
res = np.sum(res, axis=1).max()
print(res)

### FIXED CODE ###

a, b = map(int, input().split())
res = a*1.0/b
print(res)
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]
import sys
sys.setrecursionlimit(10**10)
def dfs(i,j):
    if i == N:
        return 0
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j==0:
            dp[i][j] = max(dfs(i+1,1)+abc[i][1], dfs(i+1,2)+abc[i][2])
        elif j==1:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,2)+abc[i][2])
        else:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,1)+abc[i][1])
        return dp[i][j]
print(max(dfs(0,0), dfs(0,1), dfs(0,2)))


### FIXED CODE ###

N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]
import sys
sys.setrecursionlimit(10**9)
def dfs(i,j):
    if i == N:
        return 0
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j==0:
            dp[i][j] = max(dfs(i+1,1)+abc[i][1], dfs(i+1,2)+abc[i][2])
        elif j==1:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,2)+abc[i][2])
        else:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,1)+abc[i][1])
        return dp[i][j]
print(max(dfs(0,0), dfs(0,1), dfs(0,2)))
def inp():
    try:
        while True:
            data=raw_input()
            if not data: break
            yield data
    except KeyboardInterrupt:
        return
sorted(list(inp()),reverse=True)[:3]

### FIXED CODE ###

n=[]
for i in range(0, 10):
    n.append(int(raw_input()))
for i in sorted(n,reverse=True)[:3]:
    print i
n=int(input())
H=list(map(int,input().split()))

ans = 0
i = 0
cnt = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
       cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)


### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
 
ans = 0
i = 0
cnt = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
       cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)
n=int(input())
if 7 in n:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n=input()
if '7' in n:
    print('Yes')
else:
    print('No')
str = input() # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(len(num)):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]
l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1,key=lambda d:d[1],reverse=True)

if l0[0][0]!=l1[0][0]:
    print(len(num)-l0[0][1]-l1[0][1])
elif len(num)==2:
    print(1)
else:
    s=0
    if l0[0][1]>=l1[0][1]:
        s=l0[0][1]+l1[1][1]
    else:
        s=l0[1][1]+l1[0][1]
    print(len(num)-s)


### FIXED CODE ###

n = int(input()) # sを取得し、strに値を入れる
num= input()
num=list(map(int,num.split()))

from collections import defaultdict

d0=defaultdict(int)
d1=defaultdict(int)
for i in range(n):
    if i%2==0:
        d0[num[i]]+=1
    else:
        d1[num[i]]+=1

l0=[(k,d0[k]) for k in d0]
l1=[(k,d1[k]) for k in d1]

l0=sorted(l0, key=lambda d:d[1],reverse=True)
l1=sorted(l1, key=lambda d:d[1],reverse=True)

l0.append(("wild card",0))
l1.append(("wild card",0))

if l0[0][0]!=l1[0][0]: #文字が同じ場合
    print(len(num)-l0[0][1]-l1[0][1])
elif n==2:
    print(1)
else:
    print(n-max(l0[0][1]+l1[1][1],l0[1][1]+l1[0][1]))
tupni = [int(idx) for idx in input.split(" ")]
if tupni.sort() == [5,5,7]:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

data = [int(i) for i in input().split(" ")]
total = 0
for i in data:
    if i==7 or i==5:
        total += i
if total == 17:
  	print("YES")
else:
  	print("NO")
d = input().split()

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

int e = 0

e = a*10+b+c

if e < b*10+a+c:
    e = b*10+a+c
    if e < c*10+a+b:
        e = c*10+a+b

if e < c*10+a+b:
    e= c*10+a+b
    if e < b*10+a+c:
        e = b*10+a+c

print(e)


### FIXED CODE ###

d = input().split()

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

e = 0

e = a*10+b+c

if e < b*10+a+c:
    e = b*10+a+c
    if e < c*10+a+b:
        e = c*10+a+b

if e < c*10+a+b:
    e= c*10+a+b
    if e < b*10+a+c:
        e = b*10+a+c

print(e)
s = input()
t = input()
ans = 10**8
for i in range(len(s)):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]: cnt += 1
    ans = min(ans, cnt)

print(ans)


### FIXED CODE ###

s = input()
t = input()
ans = 10**8
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j] != t[j]: cnt += 1
    ans = min(ans, cnt)

print(ans)
#F<=3000で100刻みなので、多分全探索すればよさそう
A,B,C,D,E,F = map(int,input().split())
f = F//100

per = -1
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = w*E
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(sugar,-1,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))


### FIXED CODE ###

A,B,C,D,E,F = map(int,input().split())
f = F//100

ans = [0,0]
per = -1
#水の量を100g単位ずつ全探索
for w in range(1,f+1):
    #そのような水の取り方があるか確認
    wt = 0
    for b in range(0,w+1,B):
        if (w-b)%A == 0:
            wt = 1
            break
    if wt == 0:
        continue

    water = w*100
    sugar = min(w*E,F-water)
    if ans[0] == 0:
        ans[0] = water
    st = 0
    #砂糖として考えられる量を大きい順に0gまでに全探索
    for s in range(sugar,0,-1):
        st = 0
        for d in range(0,s+1,D):
            if (s-d)%C == 0:
                st = 1
                break
        if st == 1:
            break
    if st == 1 and s+water <= F and s/(s+water) > per:
        ans = [s+water,s]
        per = s/(s+water)

print(' '.join(map(str,ans)))
n = input()
num = len(n)-2
for i in range(num,0,-2):
  f = int(i/2)
  if s[:f]==s[f:i]:
    print(i)
    break

### FIXED CODE ###

n = input()
num = len(n)-2
for i in range(num,0,-2):
  f = int(i/2)
  if n[:f]==n[f:i]:
    print(i)
    break
N = int(input())
if N % 2 == 0:
    print(int(N / 2))
else:
    print(int((N - 1) / 2 + 1)))

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    print(int(N / 2))
else:
    print(int((N - 1) / 2 + 1))
lines = list(str.split())
a = int(lines[0])
b = int(lines[1])
c = int(lines[2])
sum_list = [a+b, a+c, b+c]
print(min(sum_list))

### FIXED CODE ###

lines = list(input().split())
a = int(lines[0])
b = int(lines[1])
c = int(lines[2])
sum_list = [a+b, a+c, b+c]
print(min(sum_list))
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(gcd_list(dif))


### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)


n, X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
x = [x[i]-x[0] for i in range(n+1)]
del x[0]
g = x[0]
for i in range(1, n):
    g = gcd(g,x[i])
print(g)
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)

def lcm(a, b):
    return a*b//gcd(a,b)
#import sys
#input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    B = [a for a in A]
    T = 1
    L = 1
    C = [0]*N
    for i in range(N):
        for _ in range(30):
            if B[i]%2 == 0:
                B[i] //= 2
                C[i] += 1
            else:
                break
    p = C[0]
    for i in range(N-1):
        if p != C[i+1]:
            print(0)
            return
    q = pow(2,p)
    t = 1
    for i in range(N):
        t = lcm(t,A[i]//2)
    if t > M:
        print(0)
        return

    print((M-t)//t + 1)

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    N = int( input())
    Q = 10**9+7
    C = list( map( int, input().split()))
    C.sort()
    ans = 1
    if N == 1:
        print(C[0]*2%Q)
        return
    for i in range(N-1):
        ans += pow(2,i,Q)*(((N-1)-i)*pow(2,N-2-i,Q) + pow(2, N-1-i, Q))*C[i]%Q
        ans %= Q
    ans += pow(2, N-1, Q)*C[N-1]%Q
    ans -= 1
    print(ans*pow(2,N,Q)%Q)
if __name__ == '__main__':
    main()
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###


S = ii()

prev = 0
sum = 0
for c in S:
  if c == 'B':
    prev += 1
  else:
    sum += prev
    
print(sum)

### FIXED CODE ###

###template###
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###


S = input()

prev = 0
sum = 0
for c in S:
  if c == 'B':
    prev += 1
  else:
    sum += prev
    
print(sum)
# import sys
import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

# mod = int(1e9+7)
mod = 998244353
INF = 1<<29
lINF = 1<<35

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

def main():
    a,b,h,m = readInt()
    # 時針、分針の進んだ角度とその差を求める
    r1 = h * 30 + (m / 60) * v1
    r2 = m * 6
    r = abs(r1-r2)
    if r>180:
        r = 360 - r
    # 余弦定理から辺の長さを計算する
    ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(r)))
    print(ans)
    return

if __name__=='__main__':
    main()


### FIXED CODE ###

# import sys
import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

# mod = int(1e9+7)
mod = 998244353
INF = 1<<29
lINF = 1<<35

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

def main():
    a,b,h,m = readInt()
    v1 = 30
    v2 = 6
    r1 = h * v1 + (m / 60) * v1
    r2 = m * v2
    r = abs(r1-r2)
    if r>180:
        r = 360 - r
    ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(r)))
    print(ans)
    return

if __name__=='__main__':
    main()
import sys
import math

input = sys.stdin.readline


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for text in set(lines):
        txt_cnt = lines.count(text)
        count += int(math.factorial(txt_cnt) / math.factorial(txt_cnt - 2)) // 2
    print(count)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from functools import reduce
from operator import mul
from collections import Counter

input = sys.stdin.readline


def cmb(n, r):
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()
n, k = map(int,input().split())
s = input()
ha = []
owa = []
ju = 0
for i in range(len(s)) :
    if s[i] == "1" :
        if ju == 0 :
            ha.append(i)
            ju = 1
    else :
        if ju == 1 :
            owa.append(i - 1)
            ju = 0
if ha[0] != 0 :
    ha.insert(0,0)
    owa.insert(0,0)
owa.append(len(s)-1)
if ha[-1] != len(s) - 1 :
    ha.append(len(s) - 1)
#print(ha,owa)
dai = 0
for i in range(len(owa) - k) :
    dai = max(dai,owa[i+k] - ha[i] + 1)
if len(ha) > k :
    print(dai)
else :
    print(len(s))


### FIXED CODE ###

n, k = map(int,input().split())
s = input()
ha = []
owa = []
ju = 0
for i in range(len(s)) :
    if s[i] == "1" :
        if ju == 0 :
            ha.append(i)
            ju = 1
    else :
        if ju == 1 :
            owa.append(i - 1)
            ju = 0
if not ha :
    print(len(s))
else :
    if ha[0] != 0 :
        ha.insert(0,0)
        owa.insert(0,0)
    owa.append(len(s)-1)
    if len(ha) != len(owa) :
        ha.append(len(s) - 1)
    #print(ha,owa)
    dai = 0
    for i in range(len(owa) - k) :
        dai = max(dai,owa[i+k] - ha[i] + 1)
    if len(ha) > k :
        print(dai)
    else :
        print(len(s))
N, M = map(int, input().split())
 
G = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    G[x] += [y]
# print(G)
 
dp = [-1] * (N + 1)
 
 
def func(n):
    if dp[n] != -1:
        return dp[n]
    cnt = 0
	# 先にノードが存在する場合
	# ノードが存在しない場合は、cnt=0のままforをすっ飛ばす
    for m in G[n]:
        cnt = max(cnt, func(m) + 1)
    dp[n] = cnt
    return cnt
 
 
for i in range(1, N + 1):
    func(i)
 
# print(dp)
print(max(dp))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
 
 
N, M = map(int, input().split())
 
G = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    G[x] += [y]
# print(G)
 
dp = [-1] * (N + 1)
 
 
def func(n):
    if dp[n] != -1:
        return dp[n]
    cnt = 0
	# 先にノードが存在する場合
	# ノードが存在しない場合は、cnt=0のままforをすっ飛ばす
    for m in G[n]:
        cnt = max(cnt, func(m) + 1)
    dp[n] = cnt
    return cnt
 
 
for i in range(1, N + 1):
    func(i)
 
# print(dp)
print(max(dp))
mod=10**9+7
n=int(input())
l=list(map(int,input().split()))
ans=1
rgb=[0,0,0]
for i in range(n):
    c=0
    for j in range(3):
        if l[i]==rgb[j]:
            c+=1
    p=rgb.index(l[i])
    rgb[p]+=1
    ans*=c
    ans%=mod
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
ans=1
rgb=[0]*3
for i in range(n):
    f=0
    for j in range(3):
        if l[i]==rgb[j]:
            if f==0:
                rgb[j]+=1
            f+=1
    ans*=f
    ans%=mod
print(ans)
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
x,n=get_ints()
p=get_array()
for i in range(1,102):
    if i==x:
        for j in range(i,0,-1):
            if j in p:
                continue 
            else:
                ans1=j
                break
        for k in range(i,102):
            if k in p:
                continue 
            else:
                ans2=k 
                break
        break 
if ans2-x<x-ans1:
    print(ans2)
elif x-ans1<ans2-x:
    print(ans1)
else:
    print(ans1)
            
            

    

### FIXED CODE ###

import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
x,n=get_ints()
p=get_array()
ans1=x 
ans2=x
for j in range(x,-100,-1):
    if j not in p:
        ans1=j 
        break
for k in range(x,200):
    if k not in p:
        ans2=k 
        break
if ans2-x<x-ans1:
    print(ans2)
elif x-ans1<ans2-x:
    print(ans1)
else:
    print(ans1)
n,m=map(int,input().split())
li=[]
ans=0
if m!=0: 
    for i in range(m):
        a,b=map(int,input().split())
        if len(li)==0:
            li.append([a,b])
        else:
            flag=0
            for j in range(len(li)):
                if a in li[j] and b not in li[j]:
                	li[j].append(b)
                	flag=1
                elif a not in li[j] and b in li[j]:
                    li[j].append(a)
                    flag=1
                elif a in li[j] and b in li[j]:
                    break
                elif flag==0 and j==len(li)-1:
                    li.append([a,b])
        #print(li)
    ans=max([len(li[i]) for i in range(len(li))])
print(ans if m!=0 else 1)


### FIXED CODE ###

d,t,s=map(int,input().split())
print("Yes" if t*s>=d else "No")
"""bfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())

to = [[] for _ in range(n)]
eid = [[] for _ in range(n)]
ans = [0]*(n-1)

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); eid[a].append(i) # to:nodeの繋がり、eid:edgeの色
    to[b].append(a); eid[b].append(i)

import queue

q = queue.Queue()
used = [0]*n
q.put(0)
used[0] = 1
while not q.empty():
    v = q.get()
    p = pre[v]
    c = -1
    for i in range(len(to[v])):
        u = to[v]; ei = eid[v]
        if used[u]: c = ans[ei]
    k = 1
    for i in range(len(to[v])):
        u = to[v]; ei = eid[v]
        if used[u]: continue
        if k == c: k += 1
        ans[ei] = k
        k += 1
        q.put(u)
        used[u] = 1

mx = 0
for i in range(n):
    mx = max(mx, len(to[i]))
print(mx)
for i in range(n-1):
    print(ans[i])

### FIXED CODE ###

"""dfs"""

n = int(input())
import sys
sys.setrecursionlimit(10**6)

to = [[] for _ in range(n)]
eid = [[] for _ in range(n)]
ans = [0]*n

def dfs(v, c=-1, p=-1):
    k = 1
    for i in range(len(to[v])):
        u = to[v][i]
        ei = eid[v][i]
        if u == p: continue
        if k == c: k += 1
        ans[ei] = k
        k += 1
        dfs(u,ans[ei],v)

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); eid[a].append(i)
    to[b].append(a); eid[b].append(i)

dfs(0)
mx = 0
for i in range(n):
    mx = max(mx, len(to[i]))
print(mx)
for i in range(n-1):
    print(ans[i])
a,b,c,d,e,f=input().split()
if c==d and e==f:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c,d,e,f=input()
if c==d and e==f:
  print("Yes")
else:
  print("No")
N=int(input())
a=list(map(int,input().split()))

n=0
flag = 1

while flag:
	for i in range(len(a)):
		if a[i]%2==0:
			a[i]=a[i]//2
		else:
			flag = 0
	n=n+1

print(n-1)

### FIXED CODE ###

i=input()
print(i.count('1'))
from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(b(n, m, g))


def b(n: int, m: int, g: List[Tuple[int, int]]):
    ret = 0
    for i in range(m):
        v = set()
        w = []
        w.append(1)
        while w:
            now = w.pop()
            v.add(now)
            for j, node in enumerate(g):
                if j == i:
                    continue
                if node[0] == now and node[1] not in v:
                    w.append(node[1])
                elif node[1] == now and node[0] not in v:
                    w.append(node[0])
        if len(v) != n:
            ret += 1
    return ret


if __name__ == '__main__':
    main()


### FIXED CODE ###

from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(bb(n, m, g))


def bb(n: int, m: int, g: List[Tuple[int, int]]):
    ret = 0
    for i in range(m):
        v = set()
        w = [1]
        while w:
            now = w.pop()
            v.add(now)
            for j, node in enumerate(g):
                if j == i:
                    continue
                if node[0] == now and node[1] not in v:
                    w.append(node[1])
                elif node[1] == now and node[0] not in v:
                    w.append(node[0])
        if len(v) != n:
            ret += 1
    return ret


if __name__ == '__main__':
    main()