Harryxun/stf_run huggingface dataset:
from collections import deque
S=deque(list(input()))
Q=int(input())
l=list(input().split() for i in range(Q))
a=0
for j in l:
  if j[0]=="1":
      a+=1
  else:
    if j[1]=="1":
        if a %2==0:
            S.appendleft(j[2])
        else:
            S.append(j[2])
    else:
        if a %2==1:
            S.appendleft(j[2])
        else:
            S.append(j[2])
        
if a%2==0:
    print("".join(S))
else:
    S=S[::-1]
    print("".join(S))
      

### FIXED CODE ###

from collections import deque
S=deque(list(input()))
Q=int(input())
l=list(input().split() for i in range(Q))
a=0
for j in l:
  if j[0]=="1":
      a+=1
  else:
    if j[1]=="1":
        if a %2==0:
            S.appendleft(j[2])
        else:
            S.append(j[2])
    else:
        if a %2==1:
            S.appendleft(j[2])
        else:
            S.append(j[2])
        
if a%2==0:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))
l,r,d = map(int,input(.split()))
c=0
for i in range(l,r+1):
  if i%d==0:
    c+=1
print(c)

### FIXED CODE ###

l,r,d = map(int,input().split())
c=0
for i in range(l,r+1):
  if i%d==0:
    c+=1
print(c)
import heapq

N, M = map(int, input().split())
income = [[] for _ in range(M+1)]  # income[i]はi日後に報酬が得られる全ての仕事についての報酬のリスト
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        income[a].append(-b)

# 後ろから考える。残りi日のときに終了までに報酬が得られる仕事のうち報酬最大のものを選ぶ
ans = 0
tmp = []
for rest_days in range(1, M+1):
    tmp += income[rest_days]
    heapq.heapify(tmp)
    if tmp:
        ans += heapq.heappop(tmp)

print(-ans)v

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
income = [[] for _ in range(M+1)]  # income[i]はi日後に報酬が得られる全ての仕事についての報酬のリスト
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        income[a].append(-b)

# 後ろから考える。残りi日のときに終了までに報酬が得られる仕事のうち報酬最大のものを選ぶ
ans = 0
tmp = []
heapq.heapify(tmp)

for rest_days in range(1, M+1):
    for x in income[rest_days]:
        heapq.heappush(tmp, x)
    if tmp:
        ans += heapq.heappop(tmp)

print(-ans)
def main():
    n = int(input())
    n.sort()
    if n[0]**2+n[1]**2 != n[2]**2:
        print("NO")
    else:
        print("YES")

main()


### FIXED CODE ###

def main():
    n = int(input())
    for i in range(n):
        a=[int(x) for x in input().split()]
        a.sort()
        if a[0] ** 2 + a[1] ** 2 != a[2] ** 2:
            print("NO")
        else:
            print("YES")

main()
N, X = (int(_) for _ in input().split())
L = list(map(int, input().split()))
D = 0
ans = 1
while (D < X or ans < N):
    D += L[ans - 1]
    ans += 1
if D == X:
    print(ans)
else:
    print(ans - 1)

### FIXED CODE ###

N, X = (int(_) for _ in input().split())
L = list(map(int, input().split()))
D = [0 for i in range(N + 1)]
ans = 0
for i in range(N):
    D[i + 1]= D[i] + L[i]
for i in range(N + 1):
    if D[i] <= X:
        ans += 1
print(ans)
n = int(input())
dict1 = {}

for _ in range(n):
    s = input()
    if s in dict1:
        dict1[s] += 1
    else:
        dict1[s] = 1

dict_sorted = sorted(dict1, key = lambda x: x[0])
dict_sorted.sort(key = lambda x: x[1], reverse = True)

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break


### FIXED CODE ###

n = int(input())
dict1 = {}

for _ in range(n):
    s = input()
    if s in dict1:
        dict1[s] += 1
    else:
        dict1[s] = 1

dict_sorted = sorted(list(dict1.items()), key = lambda x: x[0])
dict_sorted.sort(key = lambda x: x[1], reverse = True)

max1 = dict_sorted[0][1]

for i in range(len(dict_sorted)):
    if dict_sorted[i][1] == max1:
        print(dict_sorted[i][0])
    else:
        break
a = int(input())
b = int(input())
if a + b <= 14:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
n = input()
print('Yes') if n % sum(map(int, n)) == 0 else print('No')

### FIXED CODE ###

n = input()
print('Yes') if int(n) % sum(map(int, n)) == 0 else print('No')
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, n-k+2):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))

### FIXED CODE ###

s = input()

for i in range(4):
    cnt = s.count(s[i])
    if(cnt != 2):
        print('No')
        break
else:
    print('Yes')
n = input()
a = list(map(int,input().split()))
ans = 'APPROVED'
 
for i in a:
  if i % 2 == 0:
    if i % 3 != 0:
      ans = 'DENIED'
      break
    elif i % 5 != 0:
      ans = 'DENIED'
      break
 
 
print(ans)

### FIXED CODE ###

n = list(map(int,input().split()))
ans = 'No'
 
if len(set(n)) == 2:
  ans = 'Yes'
 
print(ans)
d = int(input())
if d=25:
    print('Christmas')
elif d= 24:
    print('Christmas Eve')
elif d = 23:
    print('Christmas Eve Eve')
elif d = 22:
    print('Christmas Eve Eve Eve')

### FIXED CODE ###

d = int(input())
if d==25:
    print('Christmas')
elif d== 24:
    print('Christmas Eve')
elif d == 23:
    print('Christmas Eve Eve')
elif d == 22:
    print('Christmas Eve Eve Eve')
H,W = (int(i) for i in input().split())

original = [input() for i in range(H)]
sujimaru = [[0 for i in range(W+2)for j in range(H+2)]]

for j in range(H):
    for i in range(W):
        if(original[i][j] == "#"):
            sujimaru[i][j] += 1
            sujimaru[i+1][j] += 1
            sujimaru[i+2][j] += 1
            sujimaru[i][j+1] += 1
            sujimaru[i+2][j+1] += 1
            sujimaru[i][j+2] += 1
            sujimaru[i+1][j+2] += 1
            sujimaru[i+2][j+2] += 1

d = [""]*H
for j in range(H):
    for i in range(W):
        if(original[j][i] == "."):
            d[j] += str(sujimaru[j+1][i+1])
        else:
            d[j] += "#"

for s in d:
    print(d)

### FIXED CODE ###

H,W = (int(i) for i in input().split())

#囲い付きで入力　上下左右斜めを確認するとき用
firstline = "*"*(W+2)
bomb = [firstline]
for i in range(H):
    line = "*" + input() + "*"
    bomb.append(line)
lastline = "*"*(W+2)
bomb.append(lastline)

#答えの配列
answer = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        if bomb[i+1][j+1] == "#":
            answer[i][j] = "#"
        else:
            if bomb[i+1+1][j+1+1] == "#":
                answer[i][j] += 1
            if bomb[i+1+1][j+1+0] == "#":
                answer[i][j] += 1
            if bomb[i+1+1][j+1-1] == "#":
                answer[i][j] += 1
            if bomb[i+1+0][j+1+1] == "#":
                answer[i][j] += 1
            if bomb[i+1+0][j+1-1] == "#":
                answer[i][j] += 1
            if bomb[i+1-1][j+1+1] == "#":
                answer[i][j] += 1
            if bomb[i+1-1][j+1+0] == "#":
                answer[i][j] += 1
            if bomb[i+1-1][j+1-1] == "#":
                answer[i][j] += 1

#print(answer)
for i in range(H):
    tmp = ""
    for j in range(W):
        tmp += str(answer[i][j])
    print(tmp)
import math
A, B, H, M = map(float, input().split())

PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
#print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
#                 A * math.sin(radA) - B * math.sin(radB)))
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(radA-radB)*math.sin(radA-radB)))

### FIXED CODE ###

N = input()

last = list(N)[-1]
if int(last) in (2,4,5,7,9):
    print('hon')
elif int(last) in (0,1,6,8):
    print('pon')
else:
    print('bon')
import math

(x1, y1, x2, y2) = int(input().split())
#distance = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
distance - math.hypot((x2 - x1), (y2 - y1))
print('{0:.5f}'.format(distance))

### FIXED CODE ###

import math

(x1, y1, x2, y2) = [float(i) for i in input().split()]
#distance = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
distance = math.hypot((x2 - x1), (y2 - y1))
print('{0:.5f}'.format(distance))
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]]=p[1]
  print(sum(tmp))
  

### FIXED CODE ###

n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]-1]=p[1]
  print(sum(tmp))
n,k=map(int,input().split())
l = []
for i in range(n):
  a,b=map(int,input().split())
  l.append((a,b))
l = sorted(l)
c = 0
i = 0
while c < k:
  c += l[i][1]
  i += 1

print(l[i][1])

### FIXED CODE ###

n,k=map(int,input().split())
l = []
for i in range(n):
  a,b=map(int,input().split())
  l.append((a,b))
l = sorted(l)
c = 0
i = 0
while c < k:
  c += l[i][1]
  i += 1

print(l[i-1][0])
n,l=(int(x) for x in input().split())
sente1=input()
sente2=input()
sente3=input()
mylist=[sente1,sente2,sente3]
mylist.sort()
print(''.join(mylist))

### FIXED CODE ###

# 入力
N,L=map(int,input().split())

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

# ソート
l.sort()

# 出力
print(''.join(l))
N = int(input())
char = input().split()
out = []
cnt = 0
while cnt <= N:
    out.append(char[x])
    out.reverse()
    cnt += 1
print(" ".join(out))

### FIXED CODE ###

n = int(input())
s = input().split()
s1 = s[::2]
s2 = s[1::2]

if s2:
    if len(s) % 2:
        print(" ".join(s1[::-1]) +" "+ " ".join(s2))
    else:
        print(" ".join(s2[::-1]) +" "+ " ".join(s1))
else:
    print(" ".join(s1))
n, m = map(int, input().split())
L=[set() for i in range(n)]
for i in range(m):
    a, b =  map(int, input().split())
    L[a-1] |= {b}
    L[b-1] |= {a}
Y = {range(1, n+1)}
Z = [0]*(n-1) 
S = {1}
def f(X):
    global S, Z
    X_next = set()
    for j in X:
        R = L[j-1]-S
        S |= L[j-1]
        X_next |= R
        for k in R:
            Z[k-2] += j
    if X_next == set():
        print("Yes")
        print(Z[i] for i in range(n-1))
    else:
        return  f(X_next)
f({1})

### FIXED CODE ###

n, m = map(int, input().split())
import sys
sys.setrecursionlimit(10**6)
L=[set() for i in range(n)]
for i in range(m):
    a, b =  map(int, input().split())
    L[a-1] |= {b}
    L[b-1] |= {a}
Y = {range(1, n+1)}
Z = [0]*(n-1) 
S = {1}
def f(X):
    global S, Z
    X_next = set()
    for j in X:
        R = L[j-1]-S
        S |= L[j-1]
        X_next |= R
        for k in R:
            Z[k-2] += j
    if X_next == set():
        print("Yes")
        print('\n'.join(map(str, Z)))
    else:
        return  f(X_next)
f({1})
import itertools
n = int(input())
alist = list(map(int, input().split()))
result = 0
amari = 0
nmod = 10 ** 9 + 7
    
for i in itertools.combinations(alist, 2):
  amari = ((i[0] % nmod) * (i[1] % nmod)) % nmod
  result = (result + amari) % nmod
  
print(result)


### FIXED CODE ###

d, t, s = map(int,input().split())
if t * s >= d:
  print('Yes')
else:
  print('No')
a = int(input())
b = a // 10
c= a % 10

if b == 9 or c == 9
 print("Yes")
 else
  print("No")


### FIXED CODE ###

a = int(input())
b = a // 10
c = a % 10

if b == 9 or c == 9 :
	print("Yes")
else :
	print("No")
# coding:utf-8

n,m=map(int,raw_input().split())

def kaijo(n):
    if n==1:
        return 1
    return n*kaijo(n-1)

# 引数として、nかmのうちの小さい方の数字を受け取る
def count(n,m):
    return kaijo(n)*kaijo(m)

if n-m==-1 or n-m==1:
    result=count(n,m)
    print result
elif n-m==0:
    result=count(n,m)
    result*=2
    print result
else:
    print "0"

### FIXED CODE ###

n,m=map(int,raw_input().split())

mod=10**9+7

def kaijo(n):
    result=1
    for i in range(2,n+1):
        result*=i
        if result>mod:
            result=result%mod
    return result
    
def count(n,m):
    return kaijo(n)*kaijo(m)

if n-m==-1 or n-m==1:
    result=count(n,m)
    amari=result%mod
    print amari
elif n-m==0:
    result=count(n,m)
    result*=2
    amari=result%mod
    print amari
else:
    print 0
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


M = 10**9+7
n = int(input())
p = list(map(int, input().split()))
g1 = [None]*(n+10)
v = 1
g1[0] = 1
for i in range(1,len(g1)):
    v *= i
    v %= M
    g1[i] = v
    
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return


index = [i for i,num in enumerate(p) if num==0]
used = [False]*n
for i in range(n):
    if p[i]>0:
        used[p[i]-1] = True
nl = []
for i in range(n):
    if not used[i]:
        nl.append(i+1)
nl.sort()
scores = [0]*(n+1) # scores[i]: nlのうちiより大きいものの個数
v = len(nl)
cur = 0
for i in range(1,n+1):
    if nl and nl[cur]<i:
        cur += 1
        v -= 1
    scores[i] = v
ans = 0
bit = [0]*(n+1)
s = set(index)
val = 0
pp = len(index) # 欠損の個数
ss = sum(nl)
num = 0
inv2 = pow(2, M-2, M)
for i in range(n):
    if i in s:
        ans += (g1[pp-1] * (ss - pp - val - pp*(num)*inv2)) * g1[n-i-1]
        num += 1
    else:
        ans += (g1[pp] * (p[i]-query(bit, p[i])-1) - g1[pp-1]*num*(len(nl)-scores[p[i]])) * g1[n-i-1]
        add(bit, p[i], 1)
        val += scores[p[i]]
    ans %= M
#     print(ans, val)
print((ans + g1[pp])%M)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


M = 10**9+7
n = int(input())
p = list(map(int, input().split()))
g1 = [None]*(n+10)
v = 1
g1[0] = 1
for i in range(1,len(g1)):
    v *= i
    v %= M
    g1[i] = v
    
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return


index = [i for i,num in enumerate(p) if num==0]
used = [False]*n
for i in range(n):
    if p[i]>0:
        used[p[i]-1] = True
nl = []
for i in range(n):
    if not used[i]:
        nl.append(i+1)
nl.sort()
scores = [0]*(n+1) # scores[i]: nlのうちiより大きいものの個数
v = len(nl)
cur = 0
for i in range(1,n+1):
    if nl and cur<len(nl) and nl[cur]<i:
#     if nl and nl[cur]<i:
        cur += 1
        v -= 1
    scores[i] = v
ans = 0
bit = [0]*(n+1)
s = set(index)
val = 0
pp = len(index) # 欠損の個数
ss = sum(nl)
num = 0
inv2 = pow(2, M-2, M)
for i in range(n):
    if p[i]==0:
        ans += (g1[pp-1] * (ss - pp - val - pp*(num)*inv2)) * g1[n-i-1]
        num += 1
    else:
        ans += (g1[pp] * (p[i]-query(bit, p[i])-1) - g1[pp-1]*num*(len(nl)-scores[p[i]])) * g1[n-i-1]
        add(bit, p[i], 1)
        val += scores[p[i]]
    ans %= M
#     print(ans, val)
print((ans + g1[pp])%M)
import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    # cs[0]とcs[-1]はindex error除け。
    cs = [0] * 10002

    for _ in range(n):
        s, t, c = map(int, input().split())
        cs[s - 1] += 1
        cs[t + 1] -= 1
    cur = 0
    r = 0
    for cse in cs:
        cur += cse
        r = max(r, cur)
    print(r)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
def main():
    n, c = map(int, input().split())
    d = {e: [0] * (c + 1) for e in range(100001)}
    d1 = [0] * 100001
    m = map(int, read().split())
    stc = zip(m, m, m)
    for s, t, c in stc:
        if d[s][c]:
            d1[s - 1] -= 1
            d1[s] += 1
        else:
            d[s][c] = 1
        if d[t][c]:
            d1[t - 1] -= 1
            d1[t] += 1
        else:
            d[t][c] = 1
        d1[s - 1] += 1
        d1[t] -= 1

    cur = 0
    r = 0
    for i1 in range(100001):
        cur += d1[i1]
        r = max(r, cur)
    print(r)

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

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

#最大公約数: greatest common divisor(gcd)
g = math.gcd(a,b)

def prime_decomposition(n):
  i=2
  table = []
  while i*i <= n:
    while n%i==0:
      n//=i
      table.append(i)
    i+=1
  if n>1:
    table.append(n)
  return table
print(len(set(prime_decomposition(g)))+1)

### FIXED CODE ###

# import math
from fractions import gcd

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

#最大公約数: greatest common divisor(gcd)
# g = math.gcd(a,b)
g=gcd(a,b)

def prime_decomposition(n):
  i=2
  table = []
  while i*i <= n:
    while n%i==0:
      n//=i
      table.append(i)
    i+=1
  if n>1:
    table.append(n)
  return table
print(len(set(prime_decomposition(g)))+1)
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
for i in range(hm,-1,-1):
    for j in range(n)
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


### FIXED CODE ###

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

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)
food = [int(input()) for i in range(5)]
a = 10

for i in range(5):
    x = food[i] % 10
    if 0 < x < a:
        a = x
        remove = food[i]
        
food.remove(remove)

ans = remove

for i in range(4):
    ans += -(-food[i]//10)*10
    
print(ans)

### FIXED CODE ###

food = [int(input()) for i in range(5)]
a = 10
OK = 0

for i in range(5):
    OK += food[i] % 10
    
if OK == 0:
    print(sum(food))
else:
    for i in range(5):
        x = food[i] % 10
        if 0 < x < a:
            a = x
            remove = food[i]

    food.remove(remove)

    ans = remove

    for i in range(4):
        ans += -(-food[i]//10)*10

    print(ans)
import sys
N, M = map(int, input().split())
A = [0 for i in range(N+1)]
for i in range(M):
	A1, A2 = map(int, input().split())
	A[A1] = A2
	
ans = 0
min_dir = sys.maxint
for i in range(1, N+1):
	if A[i] != 0:
		min_dir = min(A[i], min_dir)
	if i >= min_dir:
		ans += 1
		if A[i] != 0:
			min_dir = A[i]
		else:
			min_dir = sys.maxint
print(ans)
	
	

### FIXED CODE ###

import sys

N, M = map(int, input().split())
A = [0 for i in range(N+1)]
for i in range(M):
	A1, A2 = map(int, input().split())
	if A[A1] > A2 or A[A1] == 0:
		A[A1] = A2
	
ans = 0
min_dir = sys.maxsize
for i in range(1, N+1):
	if A[i] != 0:
		min_dir = min(A[i], min_dir)
	if i >= min_dir:
		ans += 1
		if A[i] != 0:
			min_dir = A[i]
		else:
			min_dir = sys.maxsize
print(ans)
r=int(input())
g=int(input())
print(int(g*2−r))

### FIXED CODE ###

r=int(input())
g=int(input())
print(2*g-r)
import math

N,M=map(int,input().split())
if N==1 and M==1:
  print(0)
elif N==1 and M!=1:
  print(int(math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
elif M==1 and N!=1:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)))
else:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))


### FIXED CODE ###

import math

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

if (N==0 or N==1) and (M==0 or M==1):
  print(0)
elif (N==0 or N==1) and (M!=0 and M!=1):
  print(int(math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
elif (M==0 or M==1) and (N!=0 and N!=1):
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)))
else:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
# -*- coding: utf-8 -*-
import copy

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    beki=2**b
    if beki > A[i]:
      pair=beki - A[i]
      if A.count(pair) >0:
        A[i] = -1
        A[A.index(pair)] = -1
        pairCounter+=1
      break
print(pairCounter)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c=collections.Counter(A)

pairCounter=0

beki=29
nibeki=2**beki

for i in range(N):
  target = A[i]
  if c[target] < 1:
    continue
  c[target]-= 1

  while (nibeki > target):
    beki-=1
    nibeki=2**beki

  pair = nibeki * 2 - target
  if pair in c.keys() and c[pair] > 0:
    c[pair]-= 1
    pairCounter+=1

print(pairCounter)
import math

x1, y1, x2, y2 = map(int, input().split())
r = math.sqrt((x1 - x2) **2 + (y1 - y2) **2)
print(r)



### FIXED CODE ###

import math

x1, y1, x2, y2 = map(float, input().split())
r = math.sqrt((x1 - x2) **2 + (y1 - y2) **2)
print(r)
n, m = map(int, input())
print((n - 1) * (m - 1))


### FIXED CODE ###

n, m = map(int, input().split())
print((n - 1) * (m - 1))
def abc146_d():
    n = int(input())
    Q = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(n-1)]

    deg = [0] * n
    adj = [[] for _ in range(n)]
    color = dict()

    for a, b in Q:
        deg[a] += 1
        deg[b] += 1
        adj[a].append(b)
        adj[b].append(a)

    def dfs(s, p):
        nouse = -1
        if p > -1: nouse = color[(min(s, p), max(s, p))]
        c = 1
        for t in adj[s]:
            if t == p: continue
            if c == nouse: c += 1
            color[(min(s, t), max(s, t))] = c
            dfs(t, s)
            c += 1

    dfs(1, -1)

    print(max(deg))
    for a, b in Q:
        print(color[(a, b)])

if __name__ == '__main__':
    abc146_d()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10010010)

def abc146_d():
    n = int(input())
    Q = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(n-1)]

    deg = [0] * n
    adj = [[] for _ in range(n)]
    color = dict()

    for a, b in Q:
        deg[a] += 1
        deg[b] += 1
        adj[a].append(b)
        adj[b].append(a)

    def dfs(s, p):
        nouse = -1
        if p > -1: nouse = color[(min(s, p), max(s, p))]
        c = 1
        for t in adj[s]:
            if t == p: continue
            if c == nouse: c += 1
            color[(min(s, t), max(s, t))] = c
            dfs(t, s)
            c += 1

    dfs(1, -1)

    print(max(deg))
    for a, b in Q:
        print(color[(a, b)])

if __name__ == '__main__':
    abc146_d()
# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

import collections

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

ma = sum(p[:K])
idx = 0

kukan = [sum(p[i:i+K]) for i in range(N-K)]
idx = kukan.index(max(kukan))

ans = 0
for i in range(K):
  ans += (0.5 * (p[idx+i]-1) + 1)

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
p  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

q = sum(p[:k])
max_ = (q, 0, k)
for i in range(k, n):
    q = q + p[i] - p[i-k]
    if max_[0] < q:
        max_ = (q, i-k+1, i+1)

ans = 0
for p_ in p[max_[1]:max_[2]]:
    ans += 1 + (p_ - 1) * 0.5

#print(max_)
print(ans)
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= 

### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.full(N*1000+1, 10 ** 10, dtype=np.int64)
dp[0] = 0
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= W)))