Harryxun/stf_run huggingface dataset:
import sys

def check(S):
    even = set()
    odd = set()
    for i in range(len(S)):
        if i % 2 == 0:
            odd.add(S[i])
        else:
            even.add(S[i])

    return len(even) == len(odd) == 1


def can_checkmate(S):
    chrs = set(S)
    if len(chrs) != 3:
        return False

    for c in chrs:
        S_ = S.remove(c)
        if check(S_):
            return True

    return False


def main():
    input = sys.stdin.readline
    S = [c for c in input().strip()]

    if check(S):
        return 'Second'

    if S[0] == S[-1]:
        if len(S) % 2 == 0 or can_checkmate(S):
            return 'First'
        else:
            return 'Second'
    else:
        if len(S) % 2 == 1 or can_checkmate(S):
            return 'First'
        else:
            return 'Second'


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys

def check(S):
    even = set()
    odd = set()
    for i in range(len(S)):
        if i % 2 == 0:
            odd.add(S[i])
        else:
            even.add(S[i])

    return len(even) == len(odd) == 1


def can_checkmate(S):
    chrs = set(S)
    if len(chrs) != 3:
        return False

    for c in chrs:
        S_ = S
        S_.remove(c)
        if check(S_):
            return True

    return False


def main():
    input = sys.stdin.readline
    S = [c for c in input().strip()]

    if check(S):
        return 'Second'

    if S[0] == S[-1]:
        if len(S) % 2 == 0 or can_checkmate(S):
            return 'First'

        else:
            return 'Second'
    else:
        if len(S) % 2 == 1:
            return 'First'

        else:
            return 'Second'


if __name__ == '__main__':
    print(main())
N=int(input())
l={}
ans =[]
 
"""for i in range(N):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1
print(l)"""
for i in range(N):
    s=input()
    if s in l:
        l[s]+=1
    else:
        l[s]=1
#print(l)
max = max(l.values())
print(max)
for i in l:
    #print(l[i])
    if l[i]==num:
      ans.append(i)
b = sorted(ans)
for i in b:
    print(i)


### FIXED CODE ###

N=int(input())
l={}
ans =[]
 
"""for i in range(N):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1
print(l)"""
for i in range(N):
    s=input()
    if s in l:
        l[s]+=1
    else:
        l[s]=1
#print(l)
num = max(l.values())
#print(max)
for i in l:
    #print(l[i])
    if l[i]==num:
      ans.append(i)
b = sorted(ans)
for i in b:
    print(i)
import sys
import re


file = open(sys.argv[1], "r")

for line in file:
    ab = map((lambda x: int(x)), re.split(" +", line))
    answer = reduce((lambda x, y: x + y), ab, 0)
    digits = len(str(answer))
    print digits

### FIXED CODE ###

#
# AIZU ONLINE JUDGE: Digit Number
# cf. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0002&lang=jp
#


import sys
import re


#file = open(sys.argv[1], "r")

for line in sys.stdin:
    ab = map(int, re.split(" +", line))
    answer = reduce((lambda x, y: x + y), ab, 0)
    digits = len(str(answer))
    print digits
import sys
import numpy as np 

n = int(sys.stdin.readline().rstrip())
graph = [None] * n
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    if not a: continue
    graph[i] = np.array([sys.stdin.readline().split() for _ in range(a)], dtype=np.int16).T

def main():
    comb = (np.arange(1 << n)[:, None] >> np.arange(n) & 1).astype(np.bool)
    ok = np.full(1 << n, True)
    for i in range(n):
        if graph[i] is None: continue
        x, y = graph[i]
        ok &= ~comb[:, i] | np.all(comb[:, x-1] == y.astype(np.bool), axis=1)

    print(np.amax(comb[ok].sum(axis=1)))

if __name__ ==  '__main__':
    main()

### FIXED CODE ###

import sys
# import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]

for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x-1, y))

# xy = np.array(xy)
# x, y = xy[:, :].T
# x = x.T 
# y = y.T

def main():
    ans = 0
    for comb in range(2 ** n):
        cnt = 0
        ok = True
        for i in range(n):
            if not comb >> i & 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    ok = False
                    break
            if ok:
                cnt += 1
            else:
                break
        else:
            ans = max(ans, cnt)
    return ans
                
if __name__ == '__main__':
    ans = main()
    print(ans)
import math
N,D= map(int,input().split())
listA = [list(map(int,input().split())) for i in range(N)]
ans =0
for i in range(N):
    for j in range(i +1,N):
        D = deffer(listA[i],listA[B])
        if isinstance(D):
            ans +=1
            
print(ans)

    
def deffer(A,B):
    sum = 0
    for i in range(len(A)):
        sum += (A[i]-B[i])**2
    sum = math.sqrt(sum)
    return sum

### FIXED CODE ###

import math


    
def deffer(A,B):
    sum = 0
    for i in range(len(A)):
        sum += (A[i]-B[i])**2
    sum = math.sqrt(sum)
    return sum


N,D= map(int,input().split())
listA = [list(map(int,input().split())) for i in range(N)]
ans =0
for i in range(N):
    for j in range(i +1,N):
        D = deffer(listA[i],listA[j])
        
        if D.is_integer():
            ans +=1
            
print(ans)

    
def deffer(A,B):
    sum = 0
    for i in range(len(A)):
        sum += (A[i]-B[i])**2
    sum = math.sqrt(sum)
    print("sum is {}".format(sum))
    return sum
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None
S = None

def main():
    global S

    N = int(input())
    S = input()

    if N == 2:
        if S == "WE":
            print(1)
        else:
            print(0)
        sys.exit()

    E, W = [], []
    e, w = 0, 0

    for s in S:
        if s == "E":
            e += 1
        else:
            w += 1
        E.append(e)
        W.append(w)

    ans = min(ans, E[-1] - E[0 + 1])
    for leader in range(1, N):
        if leader == N - 1:
            ans = min(ans, W[leader - 1])
        else:
            ans = min(ans, W[leader - 1] + E[-1] - E[leader + 1])

    print(ans)


main()


### FIXED CODE ###

import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N = int(input())
    S = input()

    ans = S[1:].count("E")
    A = []
    A.append(ans)

    for i in range(1, N):
        if S[i - 1] == "W":
            ans += 1
        if S[i] == "E":
            ans -= 1
        A.append(ans)

    print(min(A))



main()
import math
while t == 0:	
	try:
		n = int(input().rstrip().split(??? ???))
	except:
		break
	else:
		print(math.log10(int(n[0]) + int(n[1])) + 1)

### FIXED CODE ###

import math
t = 0
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = int (math.log10(x + y) + 1)
		print(a)
n,m= map(int, input().split())
a = list(map(int, input().split()))
d = []
for i in range(m):
    b,c = map(int, input().split())
    d.extend([c]*b)
d = sorted(d,reverse=True)
k = max(len(d),n)
d = d[0:k]

a = sorted(a)

for i in range(n):
    if i >=k-1:
        break 
    if a[i] > d[i]:
        break
    else:
        a[i] = d[i]

print(sum(a))



### FIXED CODE ###

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

bc = []

for i in range(m):
    b,c=map(int,input().split())
    bc.append([b,c])

bc = sorted(bc, key=lambda x: x[1],reverse=True)
a = sorted(a)

itr = 0 
for i in bc:
    b, c = i[0], i[1]
    for j in range(b):
        if a[itr]>=c:
            print(sum(a))
            exit()
        else:
            a[itr]=c
            itr +=1
            if itr == n:
                print(sum(a))
                exit()
print(sum(a))
#解説方針#解法1
from collections import deque
from heapq import heappop, heappush
#標準入力
N = int(input())
mod = 10 ** 9 + 7
L = [[] for i in range(N + 1)] #dfs用
AB = [0] * (N - 1)
for i in range(N - 1):
  a, b = map(int, input().split())
  L[a].append(b)
  L[b].append(a)
  AB[i] = [a, b]
#print(L)
#逆元計算
#P = 10 ** 9 + 7
#N2 = 2 * 100000 + 1
#inv_t = [0]+[1]
#for i in range(2,N2):
#  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

#各辺がSに含まれる確率を求める
def dfs(c, d):#辺をつなぐ2頂点を変数にとる
  q = [c]
  visited = [0] * (N + 1)
  visited[c] = 1
  visited[d] = 1
  ans = 1
  while q:
    e = heappop(q)
    for i in L[e]:
      if visited[i] == 0:
        visited[i] = 1
        ans += 1
        heappush(q, i)
  #print(ans , N - ans)
  pro = (1-((1/2) ** ans)) * (1-((1/2) ** (N - ans)))
  return pro      

#頂点の個数の期待値にする。
#基本的に辺の数+1だが、黒の頂点が一つもない1パターン(確率 1 / 2**N)だけ別に考慮
x = 0
for i in range(N - 1):
  x += dfs(AB[i][0], AB[i][1])
x = x + 1 - (N / 2) - (1/2) ** N
#print(x)#期待値があっていることを確認
  
y = int(2 ** N * x)
z = 2 ** N
T = True
while T:
  if (y % 2 == 0) and (z % 2 == 0):
    y /= 2
    z /= 2
  else:
    T = False
    
#ここで x = y / (2 ** N)の形にする
y, z = y % mod, int(z % mod)
y = y % z
print(y, z)
#ans = inv_t[z] * 1
#print(int(ans))



### FIXED CODE ###

#解説方針#解法1
#https://qiita.com/ZhangChaoran/items/71fab0e4b8647a93d3a0
from collections import deque
from heapq import heappop, heappush
#標準入力
N = int(input())
MOD = 10 ** 9 + 7
L = [[] for i in range(N + 1)] #dfs用
for i in range(N - 1):
  a, b = map(int, input().split())
  L[a].append(b)
  L[b].append(a)

#木の探索
parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  # 行きがけ順探索リスト
    for y in L[x]:
        if y == parent[x]:
            continue
        parent[y] = x  # 親ノードを記録
        stack.append(y)
#print(order, parent)

half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)#2 ** N の逆元の集合
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):#iが1から
    p = parent[v]
    x = size[v]  # vの子孫ノード数（自分も含む）をとる
    size[p] += x  # 親にノード数を加算
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]
#print(size)
# 辺iがSに含まれるための必要十分条件による辺の個数の期待値 
# (1 - (1/2) ** i)(1 - (1/2) ** (N - i))を展開して計算
# 根である1の頂点以外は、ある頂点とその親を結ぶ辺を考えた際
# i と N - i個の頂点に別れるので,size[2:]でOK
ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) %
          MOD for i in size[2:])  
#ans = sum((1 - (1/2) ** i- (1/2) ** (N - i) + (1/2) ** N) for i in size[2:])  
#print(ans)
ans += 1  # 木の頂点の個数は辺の個数+1
# -「すべての辺が含まれない、つまり空グラフの場合の誤加算」-N/2
ans -= power_inv[N] + N * power_inv[1]  
#ans -= N * power_inv[1]  
ans %= MOD

print(ans)
N=list(map(int,input().split()))
S=list(input())
k=N[1]
S[k]=S[k].lower()
j = ','.join(S)
print(j)

### FIXED CODE ###

N=list(map(int,input().split()))
S=list(input())
k=N[1]
S[k-1]=S[k-1].lower()
j = ' '
 
for x in S:
    j += x
print(j)
n,a,b=map(int,input().split())
    answer=n//(a+b)*a+min(n%(a+b),a)
    print(answer)

### FIXED CODE ###

a = input().split()
a = list(map(int,a))
(n,m,k)=a
answer = n // (m + k) * m + min(n % (m + k), m)
print(answer)
import numpy as np
from numba import njit

rr,cc,k=map(int,input().split())
goods=np.array([list(map(int,input().split())) for _ in range(kk)],dtype=np.int)
gg=np.zeros((rr,cc),dtype=np.int)
for cr,ccc,ck in goods:
    gg[cr-1][ccc-1]=ck

@njit
def calc(r,c,g):
    dp=-1*np.ones((r+1,c+1,4),dtype=np.int)
    maxlst=np.zeros((r+1,c+1),dtype=np.int)

    dp[:,0,0]=0
    dp[0,:,0]=0
    
    for i in range(r):
        for j in range(c):
            tmp=0
            for k in range(3):
                if g[i][j]>0 and dp[i+1][j][k]>=0:
                    dp[i+1][j+1][k+1]=max(dp[i+1][j][k+1],dp[i+1][j][k]+g[i][j])
                else:
                    dp[i+1][j+1][k+1]=dp[i+1][j][k+1]
                tmp=max(tmp,dp[i+1][j+1][k+1])
            
            dp[i+1][j+1][0]=max(maxlst[i][j+1],dp[i+1][j][0])
            tmp=max(tmp,dp[i+1][j+1][0])
            
            if g[i][j]>0 and dp[i+1][j+1][0]>=0:
                dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i+1][j+1][0]+g[i][j])
                tmp=max(tmp,dp[i+1][j+1][1])
            
            maxlst[i+1][j+1]=tmp
    
    return maxlst[r][c]
            
print(calc(rr,cc,gg))

### FIXED CODE ###

import numpy as np
from numba import njit

rr,cc,kk=map(int,input().split())
goods=np.array([list(map(int,input().split())) for _ in range(kk)])
gg=np.zeros((rr,cc))
for cr,ccc,ck in goods:
    gg[cr-1][ccc-1]=ck

@njit
def calc(r,c,g):
    dp=-1*np.ones((r+1,c+1,4))
    maxlst=np.zeros((r+1,c+1))

    dp[:,0,0]=0
    dp[0,:,0]=0
    
    for i in range(r):
        for j in range(c):
            tmp=0
            for k in range(3):
                if g[i][j]>0 and dp[i+1][j][k]>=0:
                    dp[i+1][j+1][k+1]=max(dp[i+1][j][k+1],dp[i+1][j][k]+g[i][j])
                else:
                    dp[i+1][j+1][k+1]=dp[i+1][j][k+1]
                tmp=max(tmp,dp[i+1][j+1][k+1])
            
            dp[i+1][j+1][0]=max(maxlst[i][j+1],dp[i+1][j][0])
            tmp=max(tmp,dp[i+1][j+1][0])
            
            if g[i][j]>0 and dp[i+1][j+1][0]>=0:
                dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i+1][j+1][0]+g[i][j])
                tmp=max(tmp,dp[i+1][j+1][1])
            
            maxlst[i+1][j+1]=tmp
    
    return maxlst[r][c]
            
print(int(calc(rr,cc,gg)))
k, n = map(int, input().split())
a = list(map(int, input().split()))

# 時計回り
r_ans = 10**9
if a[0] + a[n-1] >= k:
    r_ans = a[n-1] - a[0]
    # print(a[n-1] - a[0])

# 反時計回り
else:
    max_n = 0
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        max_n = max(diff, max_n)
    # print(k - max_n)
    l_ans = k - max_n

print(min(r_ans, l_ans))

### FIXED CODE ###

k, n = map(int, input().split())
a = list(map(int, input().split()))

diff = 0
total = 0
for i in range(n-1):
    diff = max(abs(a[i] - a[i+1]), diff)
    total += abs(a[i] - a[i+1])
    
diff_tmp = abs(a[n-1] - k) + a[0]
diff = max(diff_tmp, diff)
total += abs(a[n-1] - k) + a[0] - diff

print(total)
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    else:
        print(max(possible_sides[0] * possible_sides[1],
                  tmp_square ** 2))


solve()

### FIXED CODE ###

def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
            possible_sides.append(k)
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    elif tmp_square != 0 and len(possible_sides) == 0:
        print(tmp_square ** 2)
    elif tmp_square != 0 and len(possible_sides) == 1:
        print(max(tmp_square ** 2, tmp_square * possible_sides[0]))
    else:
        print(max(tmp_square ** 2, possible_sides[0] * possible_sides[1]))

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

ans = 0

if ab_min > K:
    ans = 0
else:
    while True:
        K = K - min(A[0],B[0])
        if K < 0:
            break
        ans += 1
        if min(A[0],B[0])==A[0]:
            A.pop(0)
            if A == []:
                A.append(10**9+1)
        else:
            B.pop(0)
            if B == []:
                B.append(10**9+1)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans = 0 
for i in range(n + 1):
    if a[i] > k:
        break
    while  a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i + m)
print(ans)
l=list(sorted(map(int,raw_input().split())))
print(l[0],l[[1],l[2])

### FIXED CODE ###

l=list(map(int,input().split()))
L=sorted(l)
print(L[0],L[1],L[2])
n=int(input())
a=list(map(int, input().split()))
for i in a:
  if i%2==0 and i%3!=0 and i%5!=0:
    print('DENIED')
  	break
  else:
    print('APPROVED')

### FIXED CODE ###

_ = input()
a = list(map(int, input().split()))
 
for i in a:
	if i % 2 == 0 and i % 3 != 0 and i % 5 != 0:
		print('DENIED')
		break
else:
	print('APPROVED')
n = int(input())
x = input()
ans = [0]*(n+1)

for i in range(1,n+1):
    s = format(i, 'b')
    c = s.count('1')
    a = i%c
    ans[i] += 1
    ans[i] += ans[a] 

one_cnt = x.count('1')
numx = int(x,2)
for i in range(n):
    temp = one_cnt
    if x[i]=='0':
        temp += 1
        num = numx + 2**(n-1-i)
    else:
        temp -= 1
        num = numx - 2**(n-1-i)
    print(ans[num%temp]+1)


### FIXED CODE ###

n = int(input())
x = input()
ans = [0]*(n+1)

for i in range(1,n+1):
    s = format(i, 'b')
    c = s.count('1')
    a = i%c
    ans[i] += 1
    ans[i] += ans[a] 

one_cnt = x.count('1')
numx = int(x,2)

for i in range(n):
    temp = one_cnt
    if x[i]=='0':
        temp += 1
        num = numx%temp + pow(2,n-1-i,temp)
    else:
        if temp>1:
            temp -= 1
            num = numx%temp - pow(2,n-1-i,temp)
        else:
            print(0)
            continue
    print(ans[num%temp]+1)
import numpy as np
N = int(input())
xy = list()
for i in range(N):
    x,y = map(int,input().split())
    xy.append([x,y])
XY = np.array(xy)

dif = np.expand_dims(XY,axis=1) - np.expand_dims(XY,axis=0)
dis = np.sum(np.abs(dif), axis=-1)


idx = np.unravel_index(np.argmax(dis),dis.shape)
#print(dif)
#print(dis)
#print(idx)
print(dis[idx])

### FIXED CODE ###

# ABC178D Manhattan
n = int(input())
z = []
w = []
for i in range(n):
    x,y = map(int, input().split())
    z.append(x-y)
    w.append(x+y)
    
z_ans = max(z)-min(z)
w_ans = max(w)-min(w)
print(max(z_ans,w_ans))
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    P = [int(p) for p in input().split()]
    swap = 0
    i = 0
    while i < N:
        if P[i] == i + 1:
            P[i], P[i+1] = P[i+1], P[i]
            swap += 1
        i += 1
    print(swap)
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

N = int(input())
P = [int(i) for i in input().split()]
i = 0
ans = 0
while i < N:
    if P[i] == i+1:
        ans += 1
        i += 2
    else:
        i += 1
print(ans)
n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n-1)]

es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append((b, i))
    es[b].append((a, i))


# BFS
colors = {}
root = 0 # 頂点1が存在することが問題文中で保証されてるからここを根ノードとしよう
root_child0, _ = es[root][0]
colors[(root,root_child0)] = 0
color_parent = 0
K = 0
queue = [root]
visited = [0]*n
visited[root] = 1

ans_color = [0]*(n-1)

while queue:
    v = queue.pop(0)
    visited[v] = 1

    color = 1
    parent, _ = es[v][0] # vがrootの時は変なことになるけど後で弾くから大丈夫
    color_parent = colors[(v, parent)]

    for to, j in es[v]:
        if visited[to]: continue
        queue.append(to)

        if color == color_parent and v != root:
            color += 1

        colors[(v,to)] = color
        colors[(to,v)] = color

        ans_color[j] = color

        K = max(K, color)
        color += 1


print(K)
print(*ans_color, sep='\n')


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

n = int(input())
ab = [tuple(map(int,input().split())) for i in range(n-1)]

es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append((b, i))
    es[b].append((a, i))

visited = [0]*n
ans_color = [0]*(n-1)

# DFS
def dfs(v, fromColor):
    color = 1
    visited[v] = 1
    for to, i in es[v]:
        if visited[to]: continue

        if color == fromColor:
            color += 1
        ans_color[i] = color
        dfs(to, color)
        color += 1

root = 0 # 頂点1が存在することが問題文中で保証されてるからここを根ノードとしよう
dfs(root, 0)

print(max(ans_color))
print(*ans_color, sep='\n')
n, m = map(int, input().split())
mod = 10**9 + 7
dp = [[0] * (m+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
    for j in range(1, m+1):
        if i-2 >= 0 and j-1 >= 0:
            dp[i][j] += dp[i-2][j-1] % mod
        if i-1 >= 0 and j-2 >= 0:
            dp[i][j] += dp[i-1][j-2] % mod
        dp[i][j] %= mod
print(dp[n][m])


### FIXED CODE ###

x, y = map(int, input().split())
mod = 10 ** 9 + 7


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

if (x + y) % 3 != 0:
    print(0)
else:
    res = 0
    m, n = 0, 0
    while m * 2 <= x:
        n = x - m * 2
        if 2 * n + m == y:
            res += cmb(m + n, m, mod)
        m += 1
    print(res)
w, h, x, y = list(map(int, input().split(' ')))
hoge = abs(y/x) == 1
print('%.6f %s' % ((w*h) / 2, int(hoge)))


### FIXED CODE ###

w, h, x, y = list(map(int, input().split(' ')))
hoge = w / 2 == x
fuga = h / 2 == y
print('%.6f %s' % ((w*h) / 2, int(hoge and fuga)))
a = int(input())
b = map(int, input().split())

cnt = 0
endflag = false

while(True):
  for i in range(0,len(b)-1):
    if ((b[i] % 2 ) == 0):
      b[i] = b[i] /2
    else:
      endflag = true
  cnt = cnt +1
  
  if (endflag):
    break;
      
print(cnt)


### FIXED CODE ###

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

cnt = 0
endflag = False

while(True):
  for i in range(0,a):
    if ((b[i] %2 ) == 0):
      b[i] = b[i] / 2
    else:
      endflag = True
      break
  if (endflag):
    break
  cnt = cnt + 1

print(cnt)