Harryxun/stf_run huggingface dataset:
from math import *
n = int(input())
engine = [list(map(int, input().split())) for i in range(n)]

args = []
for i in range(n):
    x, y = engine[i]
    if x == 0:
        if y < 0:
            args.append((-pi/2, x, y))
        elif y > 0:
            args.append((pi/2, x, y))

    elif y == 0:
        if x > 0:
            args.append((0, x, y))
        elif x < 0:
            args.append((pi, x, y))

    else:
        args.append((atan(y, x), x, y))

args.sort()
l = len(args)
args = args[:] + args[:]
ans = 0
for i in range(1, l+1):
    for j in range(l):
        x, y = 0, 0
        for k in range(j, j+i):
            x += args[k][1]
            y += args[k][2]
        ans = max(ans, hypot(x, y))

print(ans)


### FIXED CODE ###

from math import *
n = int(input())
engine = [list(map(int, input().split())) for i in range(n)]

args = []
for i in range(n):
    x, y = engine[i]
    if x == 0:
        if y < 0:
            args.append((-pi/2, x, y))
        elif y > 0:
            args.append((pi/2, x, y))

    elif y == 0:
        if x > 0:
            args.append((0, x, y))
        elif x < 0:
            args.append((pi, x, y))

    else:
        args.append((atan2(y, x), x, y))

args.sort()
l = len(args)
args = args[:] + args[:]
ans = 0
for i in range(1, l+1):
    for j in range(l):
        x, y = 0, 0
        for k in range(j, j+i):
            x += args[k][1]
            y += args[k][2]
        ans = max(ans, hypot(x, y))

print(ans)
def rootedTree(node,parent,root,add):
    A.append([node,parent,root,add])
    for root_num,num in root:
        if len(tree[root_num])!=0:
            rootedTree(root_num,node,tree[root_num],num)
        else:
            A.append([root_num,node,tree[root_num],num])


n=int(input())
AB=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
A=[]
tree=[[] for i in range(n+1)]
for a,b,c in AB:
    tree[a] +=[[b,c]]

rootedTree(1,0,tree[1],0)
ans=[0]*n
for node,parent,root,num in A:
    flag=0
    for i,j in enumerate(root):
        if ans[num]==i+1:flag=1
        if flag:
            ans[j[1]]=i+2
            continue
        ans[j[1]]=i+1

print(max(ans))
for i in range(1,n):print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)


def rootedTree(node,parent,root,add):
    A.append([node,parent,root,add])
    for root_num,num in root:
        if len(tree[root_num])!=0:
            rootedTree(root_num,node,tree[root_num],num)
        else:
            A.append([root_num,node,tree[root_num],num])


n=int(input())
AB=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
A=[]
tree=[[] for i in range(n+1)]
for a,b,c in AB:
    tree[a] +=[[b,c]]

rootedTree(1,0,tree[1],0)
ans=[0]*n
for node,parent,root,num in A:
    flag=0
    for i,j in enumerate(root):
        if ans[num]==i+1:flag=1
        if flag:
            ans[j[1]]=i+2
            continue
        ans[j[1]]=i+1

print(max(ans))
for i in range(1,n):print(ans[i])
A, op, B = input(),split()
if op = '+':
  print(int(A)+int(B))
if op = '-':
  print(int(A)-int(B))

### FIXED CODE ###

A, op, B = input().split()
if op is '+':
  print(int(A)+int(B))
if op is '-':
  print(int(A)-int(B))
import math
from functools import reduce

N, X = list(map(int, input().split()))

x = list(map(int, input().split()))
x.sort()

res = [x[i+1]-x[i] for i in range(len(x)-1)]

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

print(gcd(*res))

### FIXED CODE ###

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

N, X = list(map(int, input().split()))
 
x = list(map(int, input().split()))
x.append(X)
x.sort()
 
res = [abs(x[i+1]-x[i]) for i in range(len(x)-1)]
print(gcd(*res))
S = int(input())
h = m * 60
m = s * 60
s = 1
print(h, m, s, sep=':')

### FIXED CODE ###

S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h, m, s, sep=':')
n,k = map(int,input().split())
d = [0]*k
A = [[0]*k]*n
l = set()
for i in range(k):
	d[i] = int(input())
	A[i] = list(map(int,input().split()))
for i in range(k):
	l = l.union(A[i])
if set(range(1,n+1)) == l:
	print(0)
else:
	print(len(set(range(1,n+1))-l))


### FIXED CODE ###

n,k = map(int,input().split())
d = [0]*k
A = [[0]*n]*k
l = set()
for i in range(k):
	d[i] = int(input())
	A[i] = list(map(int,input().split()))
for i in range(k):
	l = l.union(A[i])
if set(range(1,n+1)) == l:
	print(0)
else:
	print(len(set(range(1,n+1))-l))
N = int(input())
if N[-1] == 2:
    print("hon")
if N[-1] == 4:
    print("hon")
if N[-1] == 5:
    print("hon")
if N[-1] == 7:
    print("hon")
if N[-1] == 9:
    print("hon")
if N[-1] == 0:
    print("pon")
if N[-1] == 1:
    print("pon")
if N[-1] == 6:
    print("pon")
if N[-1] == 8:
    print("pon")
if N[-1] == 3:
    print("bon")

### FIXED CODE ###

N = input()
a = int(N[-1])

if a == 2 or a ==4or a ==7 or a == 9 or a ==5:
    print("hon")
if a == 0 or a ==1 or a==6 or a==8:
    print("pon")
if a == 3:
    print("bon")
from sys import stdin
from itertools import repeat
from collections import deque
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    deg = [0] * n
    la = [None] * n
    xt = [0] * (2 * n)
    for i in xrange(m):
        ui = i * 2
        vi = i * 2 + 1
        dat[ui] -= 1
        dat[vi] -= 1
        u = dat[ui]
        v = dat[vi]
        deg[u] += 1
        deg[v] += 1
        xt[vi] = la[u]
        la[u] = vi
        xt[ui] = la[v]
        la[v] = ui
    so = tr = lo = 0
    q = deque()
    done = [0] * n
    pu = q.append
    po = q.popleft
    for i in xrange(n):
        if done[i]:
            continue
        pu(i)
        done[i] = 1
        nu = [i]
        while q:
            x = po()
            y = la[x]
            while y is not None:
                z = dat[y]
                if not done[z]:
                    done[z] = 1
                    pu(z)
                    nu.append(z)
                y = xt[y]
        sd = 0
        for x in nu:
            sd += deg[x]
        if sd == 0:
            so += 1
        elif sd == len(nu) * 2 - 2:
            tr += 1
        else:
            lo += 1
    print lo * lo + lo * tr * 2 + tr * tr * 2 + so * n * 2 - so * so
main()


### FIXED CODE ###

from sys import stdin
from itertools import repeat
from collections import deque
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    deg = [0] * n
    la = [None] * n
    xt = [0] * (2 * m)
    for i in xrange(m):
        ui = i * 2
        vi = i * 2 + 1
        dat[ui] -= 1
        dat[vi] -= 1
        u = dat[ui]
        v = dat[vi]
        deg[u] += 1
        deg[v] += 1
        xt[vi] = la[u]
        la[u] = vi
        xt[ui] = la[v]
        la[v] = ui
    so = tr = lo = 0
    q = deque()
    done = [0] * n
    pu = q.append
    po = q.popleft
    for i in xrange(n):
        if done[i]:
            continue
        pu(i)
        done[i] = 1
        nu = [i]
        while q:
            x = po()
            y = la[x]
            while y is not None:
                z = dat[y]
                if not done[z]:
                    done[z] = 3 - done[x]
                    pu(z)
                    nu.append(z)
                y = xt[y]
        sd = 0
        pa = 0
        for x in nu:
            sd += deg[x]
            y = la[x]
            while y is not None:
                z = dat[y]
                if done[x] == done[z]:
                    pa = 1
                y = xt[y]
        if sd == 0:
            so += 1
        elif pa:
            lo += 1
        else:
            tr += 1
    print lo * lo + lo * tr * 2 + tr * tr * 2 + so * n * 2 - so * so
main()
a,b = map(int,input().split())
b = list(input())
ans = True
for i in range(a+b+1):
  if not((i==a and b[i]=="-") or (i!=a and b[i]!="-")):
    ans = False
    break
print("Yes" if ans else "No")

### FIXED CODE ###

a,b = map(int,input().split())
c = list(input())
ans = True
for i in range(a+b+1):
  if not((i==a and c[i]=="-") or (i!=a and c[i]!="-")):
    ans = False
    break
print("Yes" if ans else "No")
S, T = input().split()
A , B = input().split()

if S == 'blue' or S=='red':
	print(A-1)
else:
  print(B-1)

### FIXED CODE ###

S, T = input().split()
A, B = map(int, input().split())
U = input()
if U == S:    A -= 1
else: B -= 1
print(A, B)
S = input()
T = input()

import re

regxp = '^' + S + '.'

repattern = re.compile(regxp)
result = repattern.search(T)

# print(result.group())

if result.group() == T:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

S = input()
T = input()

import re

regxp = '^' + S + '.'

repattern = re.compile(regxp)
result = repattern.search(T)

# print(result.group())

try:
	if result.group() == T:
		print('Yes')
	else:
		print('No')
except:
	print('No')
N=input()
if '7' in  N
print('Yes')
if not '7' in N
print('No')

### FIXED CODE ###

N=input()
if '7' in N:
  print('Yes')
else:
  print('No')
a=int(input())
b=int(input())
if a>b:print("GREATER")
elif a<b:print("LESS")
else print("EQUAL")

### FIXED CODE ###

a=int(input())
b=int(input())
if a>b:print("GREATER")
elif a<b:print("LESS")
else:print("EQUAL")
input = input()

for i in range(3):
    tmp = int(input % 60)
    hms.append(tmp)
    input = int((input-tmp)/60)

hms.reverse()

print(str(hms[0])+':'str(hms[1])+':'str(hms[2]))

### FIXED CODE ###

sec = int(input())

hms = [0]*3
for i in range(3):
    tmp = int(sec % 60)
    hms[i] = tmp
    sec = int((sec-tmp)/60)

hms.reverse()

print(str(hms[0])+':'+str(hms[1])+':'+str(hms[2]))
n, a = map(int, input().split())
x = list(map(int, input().split()))

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fraction
from functools import reduce

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

print(gcd_list(diff_all))


### FIXED CODE ###

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

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fractions
from functools import reduce

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

print(gcd_list(diff_all))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 

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

T = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

# def dfs(x, p):
#     for j in T[x]:
#         if j == p:
#             continue
#         X[j] += X[x]
#         dfs(j, x)
def dfs(nownode,oya=-1):
    for nextnode in ablist[nownode]:
        if oya == nextnode:
            continue
        anslist[nextnode] += anslist[nownode]
        dfs(nextnode,nownode)

dfs(0, -1)

for i in range(N):
    print(X[i], end =" ")


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 

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

T = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

# def dfs(x, p):
#     for j in T[x]:
#         if j == p:
#             continue
#         X[j] += X[x]
#         dfs(j, x)
def dfs(nownode,oya=-1):
    for nextnode in T[nownode]:
        if oya == nextnode:
            continue
        X[nextnode] += X[nownode]
        dfs(nextnode,nownode)

dfs(0, -1)

print(*X)
abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans -= '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7', ans)
    break

### FIXED CODE ###

abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans += '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7'.format(ans))
    break
#include <stdio.h>

int main(void) {
	int i,j;
	for (i=1;i<10;i++){
		for (j=1;j<10;j++){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

### FIXED CODE ###

for i in range(1, 10):
    for j in range(1, 10):
        print ("%dx%d=%d" % (i,j, i*j))
S == int(input())
print(S // 3600 ":", (S % 3600) // 60 ":", S // 60)

### FIXED CODE ###

S = int(input())
s = S % 60
m = S // 60 % 60
h = S // 3600
print("{0}"":""{1}"":""{2}".format(h,m,s))
list = int(input()).sort()

a, b, c = map(split(), list)
print("{a} {b} {c}").format(a=a, b=b, c=c)

### FIXED CODE ###

num = list(map(int, input().split()))
num.sort()
print(num[0], num[1], num[2])
a,b,c=map(int,input().split())
if a < b < c:
    print("Yes")
  print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())
if a < b < c:
    print("Yes")
else:
  print("No")
s=list(input())
t=list(input())
for i in range(len(s)):
  if s==t:
    print("Yes")
    exit()
  s=s[1:].append(s[0])
print("No")


### FIXED CODE ###

s=list(input())
t=list(input())
for i in range(len(s)):
  if s==t:
    print("Yes")
    exit()
  s.append(s[0])
  s=s[1:]
print("No")
import numpy as np

n, a, b, c = map(int, input().split(' '))
ls = []
for _ in range(n):
    ls.append(int(input()))
n = 0
def solve(obj):
  c = len(ls)
  dp = np.zeros((obj+1, c+1), dtype=int)
  dp[1:, 0] = np.inf
  for j in range(1, c+1):
    dp[0, j] = min(ls[:j])
  for i in range(1, obj+1):
    for j in range(1, c+1):
      dp[i, j] = min(dp[i-1, j] + 1, dp[i, j-1], dp[i-ls[j-1], j-1] + 10, abs(ls[j-1]) - i)
  return dp[obj, c]

for obj in [a, b, c]:
  if obj in ls:
    continue
  else:
    n += solve(obj)
print(n)

### FIXED CODE ###


import numpy as np

N, A, B, C = map(int, input().split(' '))
ls = []
for _ in range(N):
    ls.append(int(input()))
n = 0
INF = 10 ** 9

def dfs(n, a, b, c):
    if n == N:
        return INF if min(a, b, c) == 0 else abs(a-A) + abs(b-B) + abs(c-C) - 30
    res0 = dfs(n+1, a, b, c)
    res1 = dfs(n+1, a+ls[n], b, c) + 10
    res2 = dfs(n+1, a, b+ls[n], c) + 10
    res3 = dfs(n+1, a, b, c+ls[n]) + 10
    return min(res0, res1, res2, res3)

print(dfs(0, 0, 0, 0))
from math import gcd
n=int(input())
a=list(map(int,input().split()))
b=[]
if n==2:
  print(max(a))

else:
  for i in range(n):
    x=a[i]
    y=a[i-1]
    b+=[gcd(x,y)]
  b.sort()
  print(b[2])

### FIXED CODE ###

import math

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

def segfunc(x, y):
    return math.gcd(x,y)

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = 0

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

a=init(a)

ans=1
for i in range(n):
    ans=max(ans,math.gcd(query(0,i),query(i+1,n)))


print(ans)
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n, i):
        tmp += a[j]
    if a[i-1] % 2 != tmp % 2:
        count[i] += 1
m = sum(count)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n+1, i):
        tmp += count[j-1]
    #print(tmp)
    if a[i-1] % 2 != tmp % 2:
        count[i-1] += 1
#print(count)
m = sum(count)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i+1))

print(m)
print(' '.join(ans))
n=int(input())
a=list(map(int,input().split()))
def f():
  if 0 in a:
    print(0)
  else:
    b=1
    for i in range(0,n):
      b*=a[i]

      if b>10**8:
        print(-1)
        return
   
  print(b)

f()

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=1
if 0 in a:
  print(0)
else:
  for i in range(n):
    b*=a[i]
    if b>10**18:
      print(-1)
      exit()
  print(b)
s = input()
 
if s == 'Sunny':
  pirnt('Cloudy')
elif s == 'Cloudy':
  pirnt('Rainy')
elif s == 'Rainy':
  print('Sunny')
else:
  break
  

### FIXED CODE ###

s = input()
 
if s == 'Sunny':
  print('Cloudy')
elif s == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
n, q = [int(x) for x in input().split()]

tree = [[] for _ in range(n + 1)]
cnt = [0] * (n + 1)

for _ in range(n - 1):
    a, b = [int(x) for x in input().split()]
    tree[a].append(b)

def walk(p, x):
    cnt[p] += x
    for n in tree[p]:
        walk(n, x)

for _ in range(q):
    p, x = [int(x) for x in input().split()]
    walk(p, x)

print(*cnt[1:])


### FIXED CODE ###

from sys import stdin, setrecursionlimit

setrecursionlimit(1000000)


def main():
    def read_tree(n):
        parents = [0 for _ in range(n + 1)]
        for _ in range(n - 1):
            a, b = [int(x) for x in input().split()]
            parents[b] = a
        return parents

    n, q = [int(x) for x in input().split()]

    parents = read_tree(n)
    cnt = [0] * (n + 1)

    for _ in range(q):
        p, x = [int(x) for x in input().split()]
        cnt[p] += x
    
    for i in range(1, n + 1):
        cnt[i] += cnt[parents[i]]

    for i in range(1, n + 1):
        print(cnt[i], end=" ")


main()
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()

n = [[] for _ in range(C)]
for _ in range(N):
	s, t, c = MAP()
	n[c-1].append((s, t))

m = [[] for _ in range(C)]

for i in range(C):
	if n[i] == []:
		continue
	n[i].sort(key = lambda y:y[0])
	s = n[i][0][0]
	t = n[i][0][1]
	L = len(n[i])
	n[i].append((0, 0))
	for j in range(L):
		if j < L and n[i][j][1] == n[i][j+1][0]:
			t = n[i][j+1][i+1]
		else:
			m[i].append((s, t))
			s = n[i][j+1][0]
			t = n[i][j+1][1]

#print(m)
cnt = [0]*(10**5+1)

for x in m:
	for s, t in x:
		cnt[s-1] += 1
		cnt[t] -= 1


cnt = list(accumulate(cnt))
#print(cnt)
print(max(cnt))


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
import numpy as np
#decimal.getcontext().prec = 10

N, C = MAP()

n = [[] for _ in range(C)]
for _ in range(N):
	s, t, c = MAP()
	n[c-1].append((s, t))

m = [[] for _ in range(C)]

for i in range(C):
	if n[i] == []:
		continue
	n[i].sort(key = lambda y:y[0])
	s = n[i][0][0]
	t = n[i][0][1]
	L = len(n[i])
	n[i].append((0, 0))
	for j in range(L):
		if j < L and n[i][j][1] == n[i][j+1][0]:
			t = n[i][j+1][1]
		else:
			m[i].append((s, t))
			s = n[i][j+1][0]
			t = n[i][j+1][1]

#print(m)
cnt = [0]*(10**5+1)

for x in m:
	for s, t in x:
		cnt[s-1] += 1
		cnt[t] -= 1


cnt = list(accumulate(cnt))
#print(cnt)
print(max(cnt))
import sys

def add_count(addnum, relations, counters, nodelist):
  new_nodelist = []
  for node in nodelist:
    if node not in relations:
      continue
    else:
      new_nodelist = new_nodelist + relations[node]
      for child in relations[node]:
        counters[child-1] += addnum
  
  if len(new_nodelist) == 0:
    return counters
  else:
    return add_count(addnum, relations, counters, new_nodelist)

N, Q = map(int, sys.stdin.readline().split())
alist = list(list(map(int, sys.stdin.readline().split())) for i in range(N-1))
qlist = list(list(map(int, sys.stdin.readline().split())) for i in range(Q))

counters = [0 for i in range(N)]
relations = {}
for a in alist:
  if a[0] not in relations:
    relations[a[0]] = [a[1]]
  else:
    relations[a[0]].append(a[1])
    
for q in qlist:
  if q[0] <= N-1:
    counters[q[0]-1] += q[1]
    counters = add_count(q[1], relations, counters, [q[0]])

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

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input=lambda :sys.stdin.readline()

def sol():

  N,Q = map(int,input().split())
  graph = [[] for i in range(N)]
  ans = [0 for i in range(N)]
  for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

  for _ in range(Q):
    p, x = map(int,input().split())
    ans[p-1] += x 
 
  def dfs(v,p=-1):
    for u in graph[v]:
      if u == p: continue
      ans[u] += ans[v]
      dfs(u,v)
  dfs(0)
  print(*ans)

sol()
#テストコード
import bisect
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()] #初期配置
t = [i for i in S()] #目標配置

cnt = []
ans = 0
for i in s:
	tmp = t.index(i)+1
	bi = bisect.bisect_left(cnt,tmp)
	cnt.insert(bi,tmp)
	ans += tmp-1-bi
print(ans)

#ご査収ください

### FIXED CODE ###

import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C = IL()

if A+B < C:
    print(B*2+A+1)
else:
    print(B+C)
N,A,B = map(int.input())
M = N+A+B
if (M%2==1):
    print("Borys")
else:
    print("Alice")

### FIXED CODE ###

n, a, b = map(int,input().split())
m = a + b
if (m % 2==1):
    print("Borys")
else:
    print("Alice")
A=input()
B=input()
C=input()
D=input()
if A<=B:
  min1=int(A)
else:
  min1=int(B)
if C<=D:
  min2=int(C)
else:
  min2=int(D)
min_=min1+min2
print(int(min)_)

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
D=int(input())
if A<=B:
  min1=A
else:
  min1=B
if C<=D:
  min2=C
else:
  min2=D
  
print(min1+min2)
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = sorted([[a[i][0] + a[i][1], a[i][0]] for i in range(n)])
taka = 0
aoki = 0

for i in range(n):
  if i % 2 == 0:
    taka += b[n - k - i - 1][1]
  else:
    aoki += b[n - k - i - 1][0] - b[n - k - i - 1][1]

print(taka - aoki)

### FIXED CODE ###

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = sorted([[a[i][0] + a[i][1], a[i][0]] for i in range(n)])
taka = 0
aoki = 0

for i in range(n):
  if i % 2 == 0:
    taka += b[n - i - 1][1]
  else:
    aoki += b[n - i - 1][0] - b[n - i - 1][1]

print(taka - aoki)