Harryxun/stf_run huggingface dataset:
import numpy as np
import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
num = h * w
mass = np.array([[0] for _ in range(num + 1)])
mp = np.zeros(num+1, dtype=int)
for i in range(h):
    for j, a in enumerate(map(int, input().split())):
        mass[a] = [i, j]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + np.sum(abs(mass[i]-mass[i-d]))
q = int(input())

for _ in range(q):
    l, r = map(int, input().split())
    print(mp[r]-mp[l])


### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
num = h * w
x = [0] * (num + 1)
y = [0] * (num + 1)
mp = [0] * (num + 1)
for i in range(h):
    for j, a in enumerate(map(int, input().split())):
        x[a], y[a] = [i+1, j+1]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d])
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(mp[r]-mp[l])
N, L = map(int, input().split())
S = [input() for _ in range(L)]

ans = sorted(S)
print(''.join(ans))

### FIXED CODE ###

N, L = map(int, input().split())
S = [input() for _ in range(N)]

print(''.join(sorted(S)))
n=input()
ans=0
for i in range(1,n+1):
  if len(str(i)) % 2 == 1:
      ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0

for i in range(1, n + 1):
  if len(str(i)) % 2 == 1:
    ans += 1

print(ans)
W, H, x, y = map(float, input().split())
if x == W/2 & y == H/2:
  chohuku = 1
else:
  chohuku = 0
print(str((H*W)/2) + " " + str(chohuku))


### FIXED CODE ###

W, H, x, y = map(float, input().split())
if x == W/2 and y == H/2:
  chohuku = 1
else:
  chohuku = 0
print(str((H*W)/2) + " " + str(chohuku))
li = input().split(" ")
print(f"{li[2]} {li[0]} {li[1]}")

### FIXED CODE ###

import numpy as np  

li = np.array(input().split(" "), dtype=np.int)
li[0], li[1] = li[1], li[0]
li[0], li[2] = li[2], li[0]

print(li[0], li[1], li[2])
import statistics
n = int(input())
a = list(map(int,input().split()))
ans = []

for i in range(n):
    ans.append(a[i])
    ans.append(a[i]-1)
    ans.append(a[i]+1)

print(ans.count(statistics.mode(ans)))

### FIXED CODE ###

import statistics,collections

n = int(input())
a = list(map(int,input().split()))
ans = []

for i in range(n):
    ans.append(a[i])
    ans.append(a[i]-1)
    ans.append(a[i]+1)

c = collections.Counter(ans)
print(c.most_common()[0][1])
print(1-input())

### FIXED CODE ###

x = int(input())
print(1-x)
import math

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

dp = [math.inf] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n-1])

### FIXED CODE ###

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

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                dp[i-2] + abs(h[i] - h[i-2]))

print(dp[n-1])
# -*- coding: utf-8 -*-

import sys
import os
import math
import numpy as np

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def length(v):
    return math.sqrt(v[0] ** 2 + v[1] ** 2 + v[2] ** 2)

def dist(p0, p1):
    return math.sqrt( (p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2 + (p0[2] - p1[2]) ** 2)

# me
p0 = np.array(list(map(int, input().split())))

# enemy
p1 = np.array(list(map(int, input().split())))

# barrier
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))

a = p1 - p0
b = A - B
c = A - C
d = A - p0

M = np.array([a, b, c]).T
tuv = np.linalg.solve(M, d)

t = tuv[0]
u = tuv[1]
v = tuv[2]

if 0 <= u <= 1 and 0 <= v <= 1 and 0 <= u + v <= 1:
    print('MISS')
else:
    print('HIT')

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math
import random

# refs
# https://shikousakugo.wordpress.com/2012/06/27/ray-intersection-2/

def det(a, b, c):
    return + a[0] * b[1] * c[2] \
           + a[2] * b[0] * c[1] \
           + a[1] * b[2] * c[0] \
           - a[2] * b[1] * c[0] \
           - a[1] * b[0] * c[2] \
           - a[0] * b[2] * c[1]

def sub(v0, v1):
    # v0 - v1
    return (v0[0] - v1[0], v0[1] - v1[1], v0[2] - v1[2])

# me
p0 = list(map(int, input().split()))

# enemy
p1 = list(map(int, input().split()))

# barrier
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a = sub(p1, p0)
b = sub(A, B)
c = sub(A, C)
d = sub(A, p0)

EPS = 0.0000001
lower = -EPS
upper = 1 + EPS

denom = det(a, b, c)

if denom != 0:
    t = det(d, b, c) / denom
    u = det(a, d, c) / denom
    v = det(a, b, d) / denom

    if t < lower:
        print('HIT')

    # hit barrier
    elif lower < t < upper and lower <= u <= upper and lower <= v <= upper and lower <= u + v <= upper:
        print('MISS')

    else:
        print('HIT')
else:
    print('HIT')
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
 
def main():
    N, L, T = map(int, readline().split())
    position = []
    cnt = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
        	cnt += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                cnt += (x-T)//L
            position.append((x-T)%L)
    position.sort()
    cnt %= N
    ans = position[count:] + position[:count]
    for i in range(N):
        print(ans[i])

### FIXED CODE ###

def main():
    N, L, T = map(int, input().split())
    collision = 0
    ants = []
    for i in range(N):
        x, w = map(int, input().split())
        if w == 1:
            collision += (x + T) // L
            a = (x + T) % L
        else:
            collision += (x - T) // L
            a = (x - T) % L
        ants.append(a)
 
    collision %= N
    ants.sort()
    ants = ants[collision:] + ants[:collision]
    for ant in ants:
        print(ant)
 
 
if __name__ == '__main__':
    main()
# -*- coding:utf8 -*-

w,h,x,y = map(int, input().split())
rec = w * h
o = '0'
all = sorted([rec * (y / h), rec * (h - y)/ h, rec * (x / w), rec * (w - x)/ w], reverse = True)
for i, n in enumerate(all):
    if n <= rec / 2:
        tr = n
        if tr == rec / 2:
            if all[i + 2] == tr:
                o = '1'
                break
        else:
            if all[i + 1] == tr:
                o = '1'
                break
ans = str(tr) + ' ' + o
print(ans)

### FIXED CODE ###

# -*- coding:utf8 -*-

w,h,x,y = map(int, input().split())
ans = (w * h)/2
if x == w/2 and y == h/2:
    ans = str(ans) + ' 1'
else:
    ans = str(ans) + ' 0'
print(ans)
N = int((input()))

A = [int(i) for i in input().split()]

B = [int(i) for i in input().split()]

C = [int(i) for i in input().split()]

can_make = 0
for upp in range(N):
    for midd in range(N):
        for loww in range(N):
            if A[upp] < B[midd] < C[loww]:
                can_make += 1

print　can_make

### FIXED CODE ###

a = input()
b = input()

a_list = list(a)
b_list = list(b)

if a_list[0] == b_list[2] and a_list[1] == b_list[1] and a_list[2] == b_list[0]:
    print('YES')
else:
    print('NO')
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m = [int(i) for i in input().split()]
E = [[] for i in range(n+1)]
used = [False] * (n + 1)
IN = [0] * (n + 1)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    E[a].append(b)
    E[b].append(a)
    IN[a] += 1
    IN[b] += 1

cnt_4 = 0
cnt_6 = 0
v_4 = []
for j, i in enumerate(IN[1:]):
    if i % 2 == 1 or i == 0:
        print('No')
        exit()
    if i >= 4:
        cnt_4 += 1
        v_4.append(j + 1)
    if i >= 6:
        cnt_6 += 1

def dfs(p, v):
    if v == v_4[0]:
        return v_4[0]
    if v == v_4[1]:
        return v_4[1]

    for e in E[v]:
        if e == p:
            continue
        return dfs(v, e)

if cnt_4 > 2 or cnt_6 >= 1:
    print('Yes')
elif cnt_4 == 2:
    if all(dfs(v_4[0], e) == v_4[1] for e in E[v_4]):
        print('No')
    else:
        print('Yes')

else:
    print('No')


### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m = [int(i) for i in input().split()]
E = [[] for i in range(n+1)]
used = [False] * (n + 1)
IN = [0] * (n + 1)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    E[a].append(b)
    E[b].append(a)
    IN[a] += 1
    IN[b] += 1

cnt_4 = 0
cnt_6 = 0
v_4 = []
for j, i in enumerate(IN[1:]):
    if i % 2 == 1 or i == 0:
        print('No')
        exit()
    if i >= 4:
        cnt_4 += 1
        v_4.append(j + 1)
    if i >= 6:
        cnt_6 += 1

def dfs(p, v):
    if v == v_4[0]:
        return v_4[0]
    if v == v_4[1]:
        return v_4[1]

    for e in E[v]:
        if e == p:
            continue
        return dfs(v, e)

if cnt_4 > 2 or cnt_6 >= 1:
    print('Yes')
elif cnt_4 == 2:
    if all(dfs(v_4[0], e) == v_4[1] for e in E[v_4[0]]):
        print('No')
    else:
        print('Yes')

else:
    print('No')
from math import factorial
def nCr(n,r):
    return factorial(n) // factorial(r) // factorial(n - r)
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
R = N-K
B = K
for i in range(1,K+1):
    ans = (nCr((R+1),i) * nCr((B-1),i-1))%mod
    print(ans)

### FIXED CODE ###

import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K = [int(i) for i in input().split()]
mod = 1000000000+7
for i in range(1,K+1):
    if N-K+1< i:
        print(0)
    else:
        ans = (nCr((N-K+1),i) * nCr(K-1,i-1)) % mod
        print(ans)
i = 1
while 1:
	x = raw_input()
	if x == 0: break;
	print "Case %s: %s"%(i, x)
	i += 1

### FIXED CODE ###

i = 1
while 1:
	x = raw_input()
	if x == str(0):
	 break;
	print "Case %s: %s"%(i, x)
	i += 1
import collections
mat = [map(int, raw_input().split(' ')) for _ in range(int(raw_input()))]
q = collections.deque([(0,0)])
moves = []
while(q):
	i,j = q.popleft()
	if mat[i][j] % 2:
		if j + 1 < len(mat[0]):
			mat[i][j+1] += 1
			moves.append([(i,j), (i, j + 1)])
			q.append((i,j + 1))
		elif i + 1 < len(mat):
			mat[i+1][j] += 1
			moves.append([(i,j), (i+1, j)])
			q.append((i + 1,j ))
print len(moves)
for u,v in moves: print u[0],u[1], v[0], v[1]

### FIXED CODE ###

import collections
h,w = map(int, raw_input().split())
mat = [map(int, raw_input().split(' ')) for _ in range(h)]
elems = [(i,j) for i in range(len(mat)) for j in range(len(mat[0]))]
elems.sort(key = lambda x: x[0] + x[1])
q = collections.deque(elems)
moves = []
while(q):
	i,j = q.popleft()
	if mat[i][j] % 2:
		if j + 1 < len(mat[0]):
			mat[i][j] -= 1
			mat[i][j+1] += 1
			moves.append([(i+1,j+1), (i+1, j + 2)])
			#q.append((i,j + 1))
		elif i + 1 < len(mat):
			mat[i][j] -=1
			mat[i+1][j] += 1
			moves.append([(i+1,j+1), (i+2, j+1)])
			#q.append((i + 1,j ))
print len(moves)
for u,v in moves: print u[0],u[1],v[0],v[1]
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n+1):
  if((i+1) % 2 == 1 and a[i] % 2 == 1):
    ans += 1
print(ans)

### FIXED CODE ###

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

def make_hist(s):
  hist = collections.Counter()
  for c in s:
    hist[c] += 1
  return hist

ans = 0
s_hist = []
N = int(input())
for n in range(N):
  new_hist = make_hit(input().strip())
  for s in s_hist:
    if(s == new_hist):
      ans += 1
  s_hist.append(new_hist)
print(ans)

### FIXED CODE ###

import collections

N = int(input())
s_hist = collections.Counter()

for n in range(N):
    s = input().strip()
    s_hist[" ".join(sorted(s))] += 1

ans = 0
for pair in s_hist.most_common():
    ans += s_hist[pair[0]]*(s_hist[pair[0]]-1)/2
    if(pair[1] == 1):
        break
print(int(ans))
h, w, m = map(int, input().split())
boms = [[0,0] for i in range(m)]
Hs = [0] * m
Ws = [0] * m
for i in range(m):
  _h, _w = map(int, input().split())
  boms[i][0] = _h - 1
  boms[i][1] = _w-1
  Hs[_h - 1] += 1
  Ws[_w - 1] += 1
Hmax = max(Hs)
Hcount = Hs.count(Hmax)
Wmax = max(Ws)
Wcount = Ws.count(Wmax)
Hindexs = [0] * Hcount
Windexs = [0] * Wcount
hcount = 0
wcount = 0
for i in range(m):
  if Hs[i] == Hmax:
    Hindexs[hcount] = i
    hcount += 1
  if Ws[i] == Wmax:
    Windexs[wcount] = i
    wcount += 1
count = 0
for bom in boms:
  if (bom[0] in Hindexs) and (bom[1] in Windexs):
    count += 1
if count == len(Hindexs) * len(Windexs):
  print(Hmax + Wmax - 1)
else:
  print(Hmax + Wmax)

### FIXED CODE ###

h, w, m = map(int, input().split())
boms = set()
Hs = [0] * h
Ws = [0] * w
for i in range(m):
  _h, _w = map(int, input().split())
  boms.add((_h - 1, _w - 1))
  Hs[_h - 1] += 1
  Ws[_w - 1] += 1
Hmax = max(Hs)
Hcount = Hs.count(Hmax)
Wmax = max(Ws)
Wcount = Ws.count(Wmax)
Hindexs = [0] * Hcount
Windexs = [0] * Wcount
hcount = 0
wcount = 0
for i in range(h):
  if Hs[i] == Hmax:
    Hindexs[hcount] = i
    hcount += 1
for i in range(w):
  if Ws[i] == Wmax:
    Windexs[wcount] = i
    wcount += 1
if m < len(Hindexs) * len(Windexs):
  print(Hmax + Wmax)
  exit()
for hindex in Hindexs:
  for windex in Windexs:
    if (hindex,windex) not in boms: 
      print(Hmax + Wmax)
      exit()
print(Hmax + Wmax -1)
import numpy

"""

+ その範囲の6の倍数の数
+ その範囲の8の倍数の数
- その範囲の48の倍数の数
で答えが求まる

"""

def v_count(n, start, end):
  start_pop = start % n
  start = start + (n - start_pop)
  return int((end - start) / n) + 1

A, B, C, D = list(map(lambda x: int(x), input().split()))

all_count = B - A + 1

c_count = v_count(C, A, B)
d_count = v_count(D, A, B)
min_cd = numpy.lcm(C, D)
cd_count = v_count(min_cd, A, B)

print(all_count - c_count - d_count + cd_count)


### FIXED CODE ###

from fractions import gcd

"""

+ その範囲の6の倍数の数
  これはBまでの倍数の数からAまでの倍数の数を引く
+ その範囲の8の倍数の数
- その範囲の48の倍数の数
で答えが求まる

"""

def v_count(n, start, end):
  a = (start - 1) // n
  b = end // n
  return b - a

A, B, C, D = list(map(lambda x: int(x), input().split()))

all_count = B - A + 1

c_count = v_count(C, A, B)
d_count = v_count(D, A, B)
min_cd = (C * D) // gcd(C, D)
cd_count = v_count(min_cd, A, B)

print(all_count - c_count - d_count + cd_count)
inp = input()
inp = input()
 
def mp(nums):
  n = 1
  for num in nums:
    n *=num
  	if num > limit:
  		print(-1)
  		return
  print(num)
  return
 
limit= 10 ** 10
num = mp([int(x) for x in inp.split(" ")])
 


### FIXED CODE ###

inp = input()
inp = input()
 
def mp(nums):
  if 0 in nums:
    print(0)
    return
  n = 1
  limit = 10**18
  for num in nums:
    n *=num
    if n > limit:
      print(-1)
      return
  print(n)
 
mp([int(x) for x in inp.split(" ")])
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

    return cnt


def shellSort(A, n):
    cnt = 0

    G = []
    if n <= 3:
        m = 1:
        G[0] = 1
    else:
        m = n // 2
        G = [0] * m
        G[0] = n // m
        for i in range(1, m):
            G[i] = G[i-1] // 2
            if G[i] == 0:
                G[i] = 1

    print(m)
    print(*G)
    for i in range(m):
        cnt = insertionSort(A, n, G[i], cnt)

    print(cnt)


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i])


if __name__ == '__main__':
    main()



### FIXED CODE ###

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

    return cnt


def shellSort(A, n):
    cnt = 0

    G = []
    G.append(1)
    for i in range(n):
        tmp = 3 * G[-1] + 1
        if tmp > n:
            break
        else:
            G.append(tmp)
    G.reverse()
    m = len(G)

    print(m)
    print(*G)

    for i in range(m):
        cnt = insertionSort(A, n, G[i], cnt)

    print(cnt)


def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    shellSort(a, n)

    for i in range(n):
        print(a[i])


if __name__ == '__main__':
    main()
import numpy as np

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(100000))

print(primes[list(np.array(primes) >= X).index(True)])

### FIXED CODE ###

import numpy as np

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(110000))

print(primes[list(np.array(primes) >= X).index(True)])
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        x, y  =tuple(map(int, input().split()))
        a[i] = x
        b[i] = y
    from collections import defaultdict
    d = defaultdict(lambda : 0)
    for i in range(n):
        for j in range(i+1, n):
            d[(abs(a[i] - a[j]), abs(b[i] - b[j]))] += 1

    print(n-max(d.values()))

main()

### FIXED CODE ###

def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        x, y = map(int, input().split())
        a[i] = x
        b[i] = y
    from collections import defaultdict
    if n == 1:
        print(1)
        return 
    d = defaultdict(lambda: 0)
    for i in range(n):
        for j in range(i+1, n):
            t = a[i] - a[j]
            y = b[i] - b[j]
            tmp = 1 if (t > 0 or (t == 0 and y > 0)) else -1
            d[(tmp * t, tmp * y)] += 1

    print(n-max(d.values()))

main()
class UnionFind(): 
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):

        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split()) 
    union_find = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        union_find.union(A, B)

    answer = 0
    for i in range(N):
        answer = max(answer, union_find.size(i))

    print(answer)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):

        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


if __name__ == "__main__":
    N, M = map(int, input().split()) 
    union_find = UnionFind(N)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        union_find.union(A, B)

    answer = 0
    for i in range(N):
        answer = max(answer, union_find.size(i))

    print(answer)
r = int(input)
print("{}".format(r**2))

### FIXED CODE ###

r = int(input())
print("{}".format(int(r**2)))
def dfs(x, c=-1, p=-1):
    k = 1
    for y, ei in G[x]:
        if y == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k; k+=1
        dfs(y, k, x)

n = int(input())
G = [[] for _ in range(n)]
ans = [0] * (n-1)
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1; b-=1
  G[a].append((b, i))
  G[b].append((a, i))

dfs(0)
mx = 0
for g in G:
    mx = max(mx, len(g))
print(mx)
for a in ans:
    print(a)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

def dfs(x, c=-1, p=-1):
    k = 1
    for y, ei in G[x]:
        if y == p:
            continue
        if k == c:
            k += 1
        ans[ei] = k; k+=1
        dfs(y, ans[ei], x)

n = int(input())
G = [[] for _ in range(n)]
ans = [0] * (n-1)
for i in range(n-1):
  a, b = map(int, input().split())
  a-=1; b-=1
  G[a].append((b, i))
  G[b].append((a, i))

dfs(0)
mx = 0
for g in G:
    mx = max(mx, len(g))
print(mx)
for a in ans:
    print(a)
S = str(input())
A = S.split()

for i in range(A):
    if A[i]=A[i+1]:
        print('Bad')
    else:
        print('Good')


### FIXED CODE ###

S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')
from itertools import combinations
from math import gcd

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

m = max(an)
g = max(map(lambda x:gcd(x[0],x[1]), combinations(an, 2)))

if K <=m and k % g == 0:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'

### FIXED CODE ###

from functools import reduce
from fractions import gcd

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

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

if K <=m and K % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')
s = 2
n = int(input())

a = int(input())
if a % 2 == 1:
    print(a*2)
else:
    print(a)

### FIXED CODE ###

a = int(input())
if a % 2 == 1:
    print(a*2)
else:
    print(a)
s = input()
d = len(s)//2
print("Yes" if s[:d] == s[d+1:] "No" else)

### FIXED CODE ###

s = input()
d = len(s)//2
print("Yes" if s[:d] == s[d+1:] else "No")
import math

pai = math.pi

r = int(input())

print('{:.6f} {:.6f}'.format(pai*r**2,2*pai*r))


### FIXED CODE ###

import math

pai = math.pi

r = float(input())

print('{:.6f} {:.6f}'.format(pai*r**2,2*pai*r))
import re
ans=[]
for i in l:
    if 'peach' in i:
        ans.append(i.replace('peach','apple'))
    elif 'apple' in i:
        ans.append(i.replace('apple','peach'))
    else:
        ans.append(i)
print ' '.join(ans)

### FIXED CODE ###

l=map(str,raw_input().split())
ans=[]
for i in l:
    if 'peach' in i:
        ans.append(i.replace('peach','apple'))
    elif 'apple' in i:
        ans.append(i.replace('apple','peach'))
    else:
        ans.append(i)
print ' '.join(ans)
#!/usr/bin/env python3
n, a, b = map(int, input().split())
s = "b" * a
r = "r" * b
ans = ""
for i in range(n):
    ans += s
    ans += r
    if len(ans) >= n:
        break
print(ans[:n].count("b"))


### FIXED CODE ###

#!/usr/bin/env python3
n, a, b = map(int, input().split())
x = n // (a + b)
r = n % (a + b)
print(a * x + r) if r < a else print((a * (x + 1)))
L = []
for i in range(5):
    L.append(int(input()))

ans = 0
tmp = []

for i in range(len(L)):
    if(L[i]%10 == 0):
        ans += L[i]
    else:
        ans += L[i] + (10 - L[i]%10)
        tmp.append(L[i]%10)

ans -= min(tmp)

print(ans)


### FIXED CODE ###

L = []
for i in range(5):
    L.append(int(input()))

ans = 0
tmp = []

for i in range(len(L)):
    if(L[i]%10 == 0):
        ans += L[i]
    else:
        ans += L[i] + (10 - L[i]%10)
        tmp.append(L[i]%10)

if(len(tmp) > 0):
    ans -= 10 - min(tmp)

print(ans)
N, T = map(int, input().split())
x = [map(int, input().split()) for _ in range(N)]
x.sort(key=lambda y:y[0], reverse=True)
ans = 0
for (c, t) in x:
    if t <= T:
        ans = c
print(ans)

### FIXED CODE ###

N, T = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
x.sort(key=lambda y:y[0], reverse=True)
ans = 0
for (c, t) in x:
    if t <= T:
        ans = c
if ans == 0:
    print('TLE')
else:
    print(ans)
x = int(input()
print('ARC' if x >= 1200 else 'ABC')


### FIXED CODE ###

x = int(input())
if x < 1200:
    print('ABC')
else:
    print('ARC')