Harryxun/stf_run huggingface dataset:
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

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

edges = [[]]*n
for i in range(n-1):
    u,v,w = get_nums_l()
    edges[u-1].append([v-1,w%2==0])
    edges[v-1].append([u-1,w%2==0])

def aaa(x):
    # xを含むエッジ

    for edge in edges[x]:
        to = edge[0] # edgeのうちxじゃないほう
        if ans[to] != -1:
            continue
        same = edge[1]
        ans[to] = ans[x] ^ (not same)

        aaa(x)
aaa(0)
for annn in ans:
    print(annn)

### FIXED CODE ###

from collections import deque
import math
from functools import reduce

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

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

edges = [ [] for _ in range(n)]
for i in range(n-1):
    u,v,w = get_nums_l()
    edges[u-1].append([v-1,w%2==0])
    edges[v-1].append([u-1,w%2==0])

def aaa(x):
    # xを含むエッジ

    # breakpoint()

    for edge in edges[x]:
        to = edge[0] # edgeのうちxじゃないほう
        if ans[to] != -1:
            continue
        same = edge[1]
        ans[to] = ans[x] ^ (not same)

        queue.append(to)

queue = deque()
queue.append(0)
while queue:
    aaa(queue.popleft())
for annn in ans:
    print(annn)
A,B,C=map(int,intpu().split())
if A==B:
    print(C)
if B==C:
    print(B)
if A==C:
    print(A)

### FIXED CODE ###

A,B,C=map(int,input().split())
if A==B:
    print(C)
if B==C:
    print(A)
if A==C:
    print(B)
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
nissuu = [0] * 26
k2 = 0
for k in range(26):
    ans = 0
    print(k)
    for i in range(D):
        t = (i+k) % 26 + 1
        for j in range(26):
            if j == t-1:
                nissuu[j] = 0
            else:
                nissuu[j] += 1
            ans -= c[j]*nissuu[j]
        ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)

### FIXED CODE ###

for i in range(365):
  print(1)
n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
if n == 1:
  print(0)
  exit()
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))
#一個だけRE、わからねえ
#解答見る
h,w=map(int,input().split())

def go_next(I,J):
    global dp,w,h
    if 0<=I<h-1:
        if x[I+1][J]==".":
            if dp[I+1][J]>dp[I][J]+1:
                dp[I+1][J]=dp[I][J]+1
                go_next(I+1,J)

    if 0<I<=h-1:
        if x[I-1][J]==".":
            if dp[I-1][J]>dp[I][J]+1:
                dp[I-1][J]=dp[I][J]+1
                go_next(I-1,J)
    if 0<=J<w-1:
        if x[I][J+1]==".":
            if dp[I][J+1]>dp[I][J]+1:
                dp[I][J+1]=dp[I][J]+1
                go_next(I,J+1)
    if 0<J<=w-1:
        if x[I][J-1]==".":
            if dp[I][J-1]>dp[I][J]+1:
                dp[I][J-1]=dp[I][J]+1
                go_next(I,J-1)

if h==1 and w==1:
    s=input()
    print(0)
else:
    x=[]
    for i in range(h):
        x.append(list(input()))
    #print(x)
    c=0
    for i in range(h):
        for j in range(w):
            if x[i][j]==".":
                c+=1
    dp=[[10000000000 for i in range(w)]for j in range(h)]
    dp[0][0]=1
    go_next(0,0)
    if dp[h-1][w-1]==10000000000:
        print(-1)
    else:
        print(c-dp[h-1][w-1])


### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
import itertools
N,M=map(int,input().split())
edge=[]
for i in range(N+1):
  edge.append([0]*(N+1))
for j in range(N):
  a,b=map(int,input().split())
  edge[a][b]=1
  edge[b][a]=1
roots=list(itertools.permutations(range(2,N+1)))
ans=0
for root in roots:
  pos=1
  for i in range(N-1):
    nxt=root[i]
    if edge[pos][nxt]==1:
      pos=nxt
    else:
      break
  else:
    ans+=1
print(ans)
  

### FIXED CODE ###

import itertools
N,M=map(int,input().split())
edge=[]
for i in range(N+1):
  edge.append([0]*(N+1))
for j in range(M):
  a,b=map(int,input().split())
  edge[a][b]=1
  edge[b][a]=1
roots=list(itertools.permutations(range(2,N+1)))
ans=0
for root in roots:
  pos=1
  for i in range(N-1):
    nxt=root[i]
    if edge[pos][nxt]==1:
      pos=nxt
    else:
      break
  else:
    ans+=1
print(ans)
alphabet = 'abcdefghijklmnopqrstuvwxyz'
from collections import defaultdict

adict = defaultdict(int)

while True:
    str_in = input().lower()
    for c in str_in:
        adict[c] += 1
    if str_in[-1] == '.':
        break

for k in alphabet:
    print('%s : %i' %(k, adict[k]))

### FIXED CODE ###

alphabet = 'abcdefghijklmnopqrstuvwxyz'
from collections import defaultdict
import sys

adict = defaultdict(int)

for l in sys.stdin:
    for c in l.lower():
        adict[c] += 1
        
for k in alphabet:
    print('%s : %i' %(k, adict[k]))
a = sorted([int(input()) for _ in range(3)])

print(abs(a[0] - a[1]) + abs(a[1] - a[2]))

### FIXED CODE ###

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

print(abs(a[0] - a[1]) + abs(a[1] - a[2]))
A, B = map(int, input().split())
print("%d"% max([A + B, A - B, A* B])


### FIXED CODE ###

A, B = map(int, input().split())
val = A * B
if B > 0:
  val = (A + B) if (A + B) > val else val
else:
  val = (A - B) if (A - B) > val else val

print("%d"%val)
from fractions import gcd

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

# preprocess
if D < 0:
    X = -X
    D = -D
g = gcd(X, D)
X //= g
D //= g

AN = X + D * (N - 1)

ans_set = set()
for k in range(N + 1):
    start = k * (2 * X + (k - 1) * D) // 2
    end = k * (2 * AN - (k - 1) * D) // 2
    if D:
        for r in range(start, end + D, D):
            ans_set.add(r)
    else:
        ans_set.add(start)

print(len(ans_set))


### FIXED CODE ###

from fractions import gcd
from collections import defaultdict

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

if D == 0:
    if X == 0:
        ans = 1
    else:
        ans = N + 1
else:
    if D < 0:
        X = -X
        D = -D
    g = gcd(X, D)
    X //= g
    D //= g

    AN = X + D * (N - 1)

    intervals_dict = defaultdict(list)
    for k in range(N + 1):
        start = k * (2 * X + (k - 1) * D) // 2
        end = k * (2 * AN - (k - 1) * D) // 2

        intervals_dict[start % D].append((start // D, end // D + 1))

    ans = 0
    for k, v in intervals_dict.items():
        v.sort()

        current_stop = -float("inf")
        for start, stop in v:
            ans += max(stop, current_stop) - max(start, current_stop)
            current_stop = max(current_stop, stop)

print(ans)
import sys


sys.setrecursionlimit(1000000)


MAX_N = 100000

memo = [-1] * MAX_N


def f(n):
    # 残り金額が0なら引き出す必要がないので0(再帰の終端条件)
    if n == 0:
        return 0
    # すでに探索済みならメモを参照する
    if memo[n] != -1:
        return memo[n]

    res = sys.maxsize

    pow9 = 1
    while pow9 <= N:
        if n - pow9 < 0:
            break
        res = min(res, f(n-pow9)+1)
        pow9 *= 9


    pow6 = 1
    while pow6 <= N:
        if n - pow6 < 0:
            break
        res = min(res, f(n-pow6)+1)
        pow6 *= 6

    # メモ
    memo[n] = res

    return res


if __name__ == '__main__':
    N = int(input())

    print(f(N))



### FIXED CODE ###

import sys


sys.setrecursionlimit(1000000)


MAX_N = 100001

memo = [-1] * MAX_N


def f(n):
    # 残り金額が0なら引き出す必要がないので0(再帰の終端条件)
    if n == 0:
        return 0
    # すでに探索済みならメモを参照する
    if memo[n] != -1:
        return memo[n]

    res = sys.maxsize

    pow9 = 1
    while pow9 <= N:
        if n - pow9 < 0:
            break
        res = min(res, f(n-pow9)+1)
        pow9 *= 9


    pow6 = 1
    while pow6 <= N:
        if n - pow6 < 0:
            break
        res = min(res, f(n-pow6)+1)
        pow6 *= 6

    # メモ
    memo[n] = res

    return res


if __name__ == '__main__':
    N = int(input())

    print(f(N))
N=input()
for idx in len(N):
  if N[idx] == str(7):
    print('Yes')
    break
else:
  print('No')


### FIXED CODE ###

N=input()
for idx in range(len(N)):
  if N[idx] == str(7):
    print('Yes')
    break
else:
  print('No')
def eratosthenes2(n):
    lim=int(n**0.5)
    d=[i+1 for i in range(2,n,2)]
    D=[2]*(n+1)
    D[0]=D[1]=-1
    while True:
        p=d[0]
        if lim<p:
            for x in d:
                D[x]=x
            break
        D[p]=p
        d2=[]
        for x in d:
            if x%p!=0:
                d2.append(x)
            else:
                D[x]=p
        d=d2
    return D
    
N=int(input())
A=list(map(int,input().split()))
maxA=max(A)
D=eratosthenes2(maxA)
print(D)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
maxA=max(A)
count=[0]*(maxA+1)
for x in A:
    count[x]+=1
maxc=0
for i in range(2,maxA+1):
    maxc = max(maxc,sum(count[i::i]))

if maxc==N:
    print('not coprime')
elif maxc<=1:
    print('pairwise coprime')
else:
    print('setwise coprime')
from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1]
    e_val = [(1 + val) / 2 for val in A]

    # 累積和を算出 (最初は0)
    e_cumsum = [0]
    for i in range(N):
      e_cumsum.append(e_cumsum[i] + e_val[i])

    # 隣接するK個の部分和を取得
    e_sum_k = []
    for i in range(N-K):
      e_sum_k.append(e_cumsum[i+K] - e_cumsum[i])

    return max(e_sum_k)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


### FIXED CODE ###

from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1]
    e_val = [(1 + val) / 2 for val in A]

    # 累積和を算出 (最初は0)
    e_cumsum = [0]
    for i in range(N):
      e_cumsum.append(e_cumsum[i] + e_val[i])

    # 隣接するK個の部分和を取得
    e_sum_k = []
    for i in range(N+1-K):
      e_sum_k.append(e_cumsum[i+K] - e_cumsum[i])

    return max(e_sum_k)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
aa = Counter(LIST())
aa = sorted(aa.items(), key=itemgetter(0))
a = [[aa[i][1], aa[i][0]] for i in range(len(aa))]
b = sorted([LIST() for i in range(m)], key=itemgetter(1), reverse=True)

ans = 0
i = j = 0
while i < m and j < n and b[i][1] > a[j][1]:
    if b[i][0] >= a[j][0]:
        ans += b[i][1]*a[j][0]
        b[i][0] -= a[j][0]
        a[j][0] = 0
        j += 1
    else:
        ans += b[i][1]*b[i][0]
        a[j][0] -= b[i][0]
        b[i][0] = 0
        i += 1
reg = j
for i in range(j, len(a)):
    ans += a[i][0]*a[i][1]
print(ans)

### FIXED CODE ###

from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
aa = Counter(LIST())
aa = sorted(aa.items(), key=itemgetter(0))
a = [[aa[i][1], aa[i][0]] for i in range(len(aa))]
b = sorted([LIST() for i in range(m)], key=itemgetter(1), reverse=True)

ans = 0
i = j = 0
while i < len(b) and j < len(a) and b[i][1] > a[j][1]:
    if b[i][0] >= a[j][0]:
        ans += b[i][1]*a[j][0]
        b[i][0] -= a[j][0]
        a[j][0] = 0
        j += 1
    else:
        ans += b[i][1]*b[i][0]
        a[j][0] -= b[i][0]
        b[i][0] = 0
        i += 1
reg = j
if reg < len(a):
    for i in range(j, len(a)):
        ans += a[i][0]*a[i][1]
print(ans)
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    break
else:
  print("NG")
  break

### FIXED CODE ###

k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    break
else:
  print("NG")
string = input()
k = int(input())
if len(string) >= k:
    substrs = set()
    ls = sorted(list(string))
    for i in range(k):
        for s, c in enumerate(string):
            if c == ls[i]:
                for l in range(1, k+1):
                    substrs.add(string[s:s+l])
    substrs = list(substrs)
    substrs.sort()
    print(substrs[k-1])

else:
    substrs = set()
    for leng in range(1, len(string)):
        for s in range(0, len(string) - leng):
            substrs.add(string[s:s+leng])
    substrs = list(substrs)
    substrs.sort()
    print(substrs[k-1])


### FIXED CODE ###

string = input()
k = int(input())
if len(string) > k:
    substrs = set()
    ls = sorted(list(string))
    for i in range(k):
        for s, c in enumerate(string):
            if c == ls[i]:
                for l in range(1, k+1):
                    substrs.add(string[s:s+l])
    substrs = list(substrs)
    substrs.sort()
    print(substrs[k-1])

else:
    substrs = set()
    for leng in range(1, len(string) + 1):
        for s in range(0, len(string) - leng + 1):
            substrs.add(string[s:s+leng])
    substrs = list(substrs)
    substrs.sort()
    print(substrs[k-1])
A, B = map(int, input().split())
print(max([a + B, a - b, a * b]))

### FIXED CODE ###

# input
A, B = map(int, input().split())
print(max([A + B, A - B, A * B]))
def aaaa():
    n=int(input())
    a=list(map(int, input().split()))
    ans=0
    if a[0]>0:
        return -1
    nezen=1
    hazen=0
    line=[]
    liha=[]
    line.append(nezen)
    liha.append(hazen)
    su=0
    su=sum(a[x] for x in range(len(a)))
    for x in range(1,n+1):
        if nezen<=0:
            return -1
        ha=a[x]
        su-=ha
        ne=min(nezen*2-ha,su)
        nezen=ne
        line.append(ne)
        liha.append(ha)
    line[n]=0
    for x in range(len(line)):
        ans+=line[x]+liha[x]
    return ans
print(aaaa())

### FIXED CODE ###

h1,m1,h2,m2,k=map(int, input().split())
oki=h1*60+m1
ne=h2*60+m2
print(ne-oki-k)
import collections
n = int(raw_input())


def f(ais):
	extra = 0
	cc = collections.Counter()
	for ai in ais:
		if ai/400 < 8:
		cc[ai/400] +=1
	else:
		extra +=1
	print min(cc.values()), max(cc.values()) + extra


### FIXED CODE ###

import collections
def f(n,ais):
	cc,extra = collections.Counter(),0
	for ai in ais:
		if ai/400 < 8: cc[ai/400] +=1
		else: extra +=1
	print len(cc) + (1 if (len(cc) == 0 and extra) else 0), min(10000, len(cc) + extra)
	#print min(cc.values() or [0]), max(cc.values() or [0]) + extra
f(int(raw_input()), map(int, raw_input().split()))
N, Q = map(int, input().split())
a_b = [list(map(int, input().split())) for _ in range(N-1)]
p_x = [list(map(int, input().split())) for _ in range(Q)]

rin = [[] for _ in range(N)]
for v in a_b:
    rin[v[0]-1].append(v[1]-1)
    rin[v[1]-1].append(v[0]-1)
    
score = [0 for _ in range(N)]
for ele in p_x:
    score[ele[0]-1] +=ele[1]
#print(score)

ans = [0 for _ in range(N)]
def dfs(p, bp=-1):
    for c in rin[p]:
        if c != bp:
            #print(c)
            score[c]+= score[p]
            dfs(c, p)




dfs(0)
print(*score)

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(1000000)

n,q = map(int, input().split())
a_b = [list(map(int, sys.stdin.readline().split())) for _ in range(n-1)]
p_x = [list(map(int, sys.stdin.readline().split())) for _ in range(q)]

v = [deque([]) for i in range(n)]
for e in a_b:
    v[e[0]-1]+=[e[1]-1]
    v[e[1]-1]+=[e[0]-1]
score = [0 for i in range(n)]
for e in p_x:
    score[e[0]-1]+=e[1]
def dfs(p, bp=-1):
    while v[p]:
        c =v[p].popleft()
        if c ==bp:
            continue
        #print(p, c, bp)
        score[c]+=score[p]
        dfs(c, bp=p)
visited = [0]                
dfs(0)
print(*score)
import math
a,b = map(int, input().strip().split())
print((a*b)//int(math.gcd(a,b)))


### FIXED CODE ###

from fractions import gcd
a,b = map(int, input().split())
print((a*b)//gcd(a,b))
P = [105, 135, 165, 189, 195, 201]

N = int(input())

for i,p in enumerate(P):
  if N < p:
    print(i)
    break


### FIXED CODE ###

A, B = map(int, input().split())
print((A-1)*(B-1))
# input
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

count = 0

for i in range(N):
    count += A[i][1]
    if count >= K:
        print(A[i][0])
        break

### FIXED CODE ###

# input
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

A = sorted(A)

count = 0

for i in range(N):
    count += A[i][1]
    if count >= K:
        print(A[i][0])
        break
N = int(input())
A = [input() for _ in [0]*N]

for i,a in enumerate(A):
    b = a.split(".")
    if len(b)==1:
        A[i] = int(a)*10**9
        continue
    c = b[1]
    n = len(c)
    c += "0"*(9-n)
    A[i] = int(b[0] + c)

cnt = [[0]*20 for _ in [0]*20]
B = [(0,0)]*N
for k,a in enumerate(A):
    i = 0
    j = 0
    while a%2==0:
        a//=2
        i+=1
    while a%5==0:
        a//=5
        j+=1
    B[k] = (i,j)
    cnt[i][j] += 1
exit()

for i in range(1,20):
    i = 19-i
    for j in range(20):
        j = 19-j
        cnt[i][j] += cnt[i+1][j]

for i in range(20):
    i = 19-i
    for j in range(1,20):
        j = 19-j
        cnt[i][j] += cnt[i][j+1]

ans = 0
for i,j in B:
    me = int(i>=9 and j>=9)
    ans += cnt[18-i][18-j]-me

print(ans//2)

### FIXED CODE ###

N = int(input())
A = [input() for _ in [0]*N]

for i,a in enumerate(A):
    b = a.split(".")
    if len(b)==1:
        A[i] = int(a)*10**9
        continue
    c = b[1]
    n = len(c)
    c += "0"*(9-n)
    A[i] = int(b[0] + c)

cnt = [[0]*40 for _ in [0]*40]
B = [(0,0)]*N
for k,a in enumerate(A):
    i = 0
    j = 0
    while a%2==0:
        a//=2
        i+=1
    while a%5==0:
        a//=5
        j+=1
    B[k] = (i,j)
    cnt[i][j] += 1

for i in range(1,40):
    i = 39-i
    for j in range(40):
        j = 39-j
        cnt[i][j] += cnt[i+1][j]

for i in range(40):
    i = 39-i
    for j in range(1,40):
        j = 39-j
        cnt[i][j] += cnt[i][j+1]

ans = 0
for i,j in B:
    me = int(i>=9 and j>=9)
    ans += cnt[max(0,18-i)][max(0,18-j)]-me

print(ans//2)
N,Q= map(int, input().split())
es=[]
ope=[]
point=[0]*N
for _ in range(N-1):
    a,b=map(int, input().split())
    es.append((a,b))
for _ in range(Q):
    p,x=map(int, input().split())
    ope.append((p,x))
import numpy as np
point=np.array(point)
nodes=np.eye(N, dtype=int)
for e in es:
    nodes[e[0]-1][e[1]-1]=1
    nodes[:,e[1]-1]=np.logical_or(nodes[:,e[1]-1],nodes[:,e[0]-1])
for o in ope:
    point+=nodes[o[0]-1]*o[1]
string=""
for i in range(N):
    string+=str(int(point[i]))+" "
print(string)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * 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):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b

def dfs(now , prev = -1):
    for next in graph[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next , now)

dfs(0)
print(*point)
a = input().split("\n")[1]
print(len(a.split("ABC"))-1)

### FIXED CODE ###

a = input()
a = input()
print(a.count("ABC"))
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def counting_sort(A, k):
    B = [0] * k
    C = [0] * k
    for j in range(array_length):
        C[A[j]] += 1
    # print('1', C[:array_length])

    for i in range(1, k):
        C[i] += C[i - 1]
    # print('2', C[:array_length])

    for m in range(array_length - 1, -1, -1):
        B[C[A[m]]] = A[m]
        C[A[m]] -= 1

    return B[1:array_length + 1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    MAX_ELEM = int(1e4 + 1)
    result = counting_sort(A=array, k=MAX_ELEM)
    print(*result)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def counting_sort(A, max_occurance):
    result = [0] * array_length
    count_list = [0] * max_occurance

    for j in range(array_length):
        count_list[A[j]] += 1
    # print('step-1', C[:array_length])

    for i in range(1, max_occurance):
        count_list[i] += count_list[i - 1]
    # print('step-2', C[:array_length])

    for m in array[::-1]:
        result[count_list[m] - 1] = m
        count_list[m] -= 1

    return result


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    max_elem = int(1e4)
    result = counting_sort(A=array, max_occurance=max_elem)
    print(*result)
n = int(input())
p = list(map(int, input().split( )))
c =0
m = p[0]
for i in range(n):
    if m => p[i]:
        c += 1
        m = p[i]
print(c)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split( )))
c = 1
m = p[0]
for a in p[1:]:
    m = min(m, a)
    if m == a:
        c += 1
print(c)
n,m=map(int,input().split())
g = [[] for _ in range(m)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
p = [0]*n
from collections import deque
q = deque([0])

while q:
  v = q.popleft()
  for i in g[v]:
    if p[i]<1:p[i]=v+1;q.append(i)
if 0 in p: print('No')
else:
  print('Yes')
  for v in p[1:]: print(v)

### FIXED CODE ###

f=lambda:map(int,input().split())
n,m=f()
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1]+=[b-1]
  g[b-1]+=[a-1]
p=[0]*n
from collections import*
q=deque([0])
while q:
  v=q.popleft()
  for c in g[v]:
    if p[c]<1: p[c]=v+1; q.append(c)
if 0 in p: print('No')
else: print('Yes',*p[1:],sep='\n')