Harryxun/stf_run huggingface dataset:
n, q = map(int, input().split())
ab = [[] for _ in range(n)]
px = [0 for _ in range(n)]
ans = [0 for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ab[a - 1].append(b - 1)
for i in range(q):
    p, x = map(int, input().split())
    px[p - 1] += x


def dfs(current, v):
    vv = v + px[current]
    ans[current] = vv
    for c in ab[current]:
        dfs(c, vv)


dfs(0, 0)
print(' '.join(map(str, ans)))


### FIXED CODE ###

from collections import deque

n, q = map(int, input().split())
ab = [[] for _ in range(n)]
px = [0 for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ab[a - 1].append(b - 1)
    ab[b - 1].append(a - 1)
for i in range(q):
    p, x = map(int, input().split())
    px[p - 1] += x

ans = px
queue = deque([(0, 0)])
while len(queue) > 0:
    prev, a = queue.pop()
    for c in ab[a]:
        if c != prev:
            ans[c] += ans[a]
            queue.append((a, c))

print(*ans)
A, B = map(int, input().split())

import math

print(str((A * B) // math.gcd(A, B)))

### FIXED CODE ###

from fractions import gcd

A, B = map(int, input().split())

print(str((A * B) // gcd(A, B)))
import sys
import math
import itertools

def main():
  n,k = map(int, input().split())
  a = list(map(int,sys.stdin.readline().split()))

  print(a)

  now = 0
  times = 0
  visit =[[0],[0]]

  for _ in range(k):
    times += 1
    now = a[now] - 1
    if now in visit[0]:
      roop = times - visit[1][visit[0].index(now)] #何個の町でループしてるかをroopに代入
      roop_start = visit[1][visit[0].index(now)] #ループが始めった待ちの最初に訪れた時に何回ループしていたかをroop_startに代入
      break
    else:
      visit[0].append(now)
      visit[1].append(times)

  k = (k - roop_start) % roop

  now = 0
  for _ in range(roop_start):
    now = a[now] - 1

  for _ in range(k):
    now = a[now] -1

  print(now+1)


if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
import math
import itertools

def main():
  n,k = map(int, input().split())
  a = list(map(int,sys.stdin.readline().split()))

  now = 0
  times = 0
  visit =[[0],[-1 for _ in range(n)]]
  visit[1][0] = 0
  roop = 0
  roop_start = 0

  for _ in range(k):
    times += 1
    now = a[now] - 1

    if visit[1][now] != -1:
      roop_start = visit[1][now] #ループが始めった待ちの最初に訪れた時に何回ループしていたかをroop_startに代入
      roop = times - roop_start #何個の町でループしてるかをroopに代入
      break
    else:
      visit[0].append(now)
      visit[1][now] = len(visit[0]) - 1

  if roop > 0:
    k = (k - roop_start) % roop

  # print(roop_start)
  # print(roop)
  # print(k)
  # print(visit[0])
  print(visit[0][roop_start + k] + 1)

  # now = 0
  # for _ in range(roop_start):
  #   now = a[now] - 1

  # for _ in range(k):
  #   now = a[now] -1

  # print(now+1)


if __name__ == '__main__':
  main()
x = int( input() )
print(x//3600+":"+(x%3600)//60+":"+x%60)


### FIXED CODE ###

x = int(input())
print(x//3600,end="")
print(':',end="")
print((x//60)%60,end="")
print(':',end="")
print(x%60)
n = input()
k = int(input())
ar = list(map(int, input().split()))
ans = 0
for i,v in enumerate(ar):
  if v <= k:
    ans+= 1
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
ar = list(map(int, input().split()))
ans = 0
for i,v in enumerate(ar):
  if v >= k:
    ans+= 1
print(ans)
import numpy as np

N = int(input())
A = np.array([int(val) for val in A])

A_even = set(A[A%2==0])
A_three = set(A[A%3==0])
A_five = set(A[A%5==0])

A_approve = A_even & (A_three | A_five)

if A_even == A_approve:
    print('APPROVED')
else:
    print('DENIED')

### FIXED CODE ###

import numpy as np
 
N = int(input())
A = input().split()
A = np.array([int(val) for val in A])
 
A_even = set(A[A%2==0])
A_three = set(A[A%3==0])
A_five = set(A[A%5==0])
 
A_approve = A_even & (A_three | A_five)
 
if A_even == A_approve:
    print('APPROVED')
else:
    print('DENIED')
from collections import deque
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
d = [(0,1),(1,0),(0,-1),(-1,0)]
q = deque()
cnt = h*w
t = 0
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      q.append((i,j))
      a[i][j] = 0
      cnt -= 1
for _ in range(cnt):
  y,x = q.popleft()
  for dx,dy in d:
    if 0 <= x+dx < w and 0 <= y+dy < h and a[y+dy][x+dx] == ".":
      a[y+dy][x+dx] = a[y][x] + 1
      q.append((y+dy,x+dx)) 
for i in range(h):
  m = max(a[i])
  t = max(t,m)
print(t)


### FIXED CODE ###

from collections import deque
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
d = [(0,1),(1,0),(0,-1),(-1,0)]
q = deque()
cnt = h*w
t = 0
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      q.append((i,j))
      a[i][j] = 0
      cnt -= 1
while cnt:
  y,x = q.popleft()
  for dx,dy in d:
    if 0 <= x+dx < w and 0 <= y+dy < h and a[y+dy][x+dx] == ".":
      a[y+dy][x+dx] = a[y][x] + 1
      cnt -= 1
      q.append((y+dy,x+dx)) 
for i in range(h):
  m = max(a[i])
  t = max(t,m)
print(t)
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

R, G = iInM()
ans = 2 * G - R
print(ans)

### FIXED CODE ###

###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

R = iIn()
G = iIn()

ans = 2 * G - R
print(ans)
import math

def lcm(x,y):
	return (x * y) // math.gcd(x,y)

N = int(input())
a = list(map(int,input().split()))
a.sort()
tlcm = lcm(a[0],a[1])

for i in range(2,len(a)):
	tlcm = lcm(a[i],tlcm)

tlcm = tlcm - 1
result = 0
for i in range(len(a)):
	result += tlcm % a[i]
print(result)

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(x,y):
	return (x * y) // gcd(x,y)

N = int(input())
a = list(map(int,input().split()))
a.sort()
tlcm = lcm(a[0],a[1])

for i in range(2,len(a)):
	tlcm = lcm(a[i],tlcm)

tlcm = tlcm - 1
result = 0
for i in range(len(a)):
	result += tlcm % a[i]
print(result)
import sys


def solve(h, n, ab):
    ab.sort(key=lambda x: x[1] / x[0])
    INF = 10 ** 18
    cache = {}
    # とりあえず一番コスパいいやつだけを使った結果を暫定最良値としておく
    best = ((h - 1) // ab[0][0] + 1) * ab[0][1]

    def dp(k, i=0, cost=0):
        nonlocal best
        if k <= 0:
            return cost
        if (k, i) in cache:
            return cache[k, i] + cost
        a, b = ab[i]
        if k / a * b + cost >= best:
            # どう足掻いても残りでbestより良い結果は得られない
            return INF
        c = (k - 1) // a + 1
        if i == n - 1:
            ret = cost + b * c
        else:
            ret = min(dp(k - a * j, i + 1, cost + b * j) for j in range(c + 1))
        cache[k, i] = ret - cost
        best = min(best, ret)
        return ret

    dp(h)
    return best


sys.setrecursionlimit(1001)

h, n = map(int, input().split())
ab = [tuple(map(int, line.split())) for line in sys.stdin]
print(solve(h, n, ab))


### FIXED CODE ###

import sys

h, n = list(map(int, input().split()))
INF = 10 ** 18
dp = [INF] * (20201)
dp[0] = 0
for line in sys.stdin:
    a, b = map(int, line.split())
    for i in range(10000):
        if dp[i] == INF:
            continue
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[h:]))
r = int(input())
pi = 3.141592653589
a = r * r * pi
l = r * 2 * pi
print('{:0.8} {:0.8}'.format(a, l))


### FIXED CODE ###

r = float(input())
pi = 3.14159265359
a = r * r * pi
l = r * 2 * pi
print('{:f} {:f}'.format(a, l))
if len(set(input())) ==2: print("Yes)
else: print("No")                                

### FIXED CODE ###

a = input()
if len(set(a)) == 2:
  print("Yes")
else:
  print("No")
n, l = map(int, input().split(' '))
hoges = []
for _ in range(n):
    hoges.append(input())
a = hoges.sort()
print(''.join(a))

### FIXED CODE ###

n, l = map(int, input().split(' '))
a = list(input() for _ in range(n))
print(''.join(sorted(a)))
a=input()
a.replace(1,8)
a.replace(9,1)
a.replace(8,9)
print(a)

### FIXED CODE ###

a=input()
print(a.replace("1","8").replace("9","1").replace("8","9"))
I="abcdefghijklmnopqrstuvwxyz"
for i in range(25):
    if I[i]==input():
        print(I[i+1])


### FIXED CODE ###

S=input()
I="abcdefghijklmnopqrstuvwxyz"
for i in range(26):
    if S==I[i]:
        print(I[i+1])
        exit()
s = input()
ans = s.count(1)
print(ans)

### FIXED CODE ###

s = input()
ans = s.count('1')
print(ans)
n = int(input())
li = []

for _ in range(n):
    s = input()
    count = 0
    while True:
        if count + 1 >= len(s):
            break
        if s[count] == '(' and s[count+1] == ')':
            s = s[:count] + s[count+2:]
            count = max(0, count-1)
        else:
            count += 1
    li.append(s)

li2 = []
for i in li:
    count = 0
    for j in range(len(i)):
        if i[j] == ')':
            count += 1
        else:
            break
    li2.append((count, len(i) - count))

li3 = []
li4 = []

for i in li2:
    if i[0] <= i[1]:
        li3.append(i)
    else:
        li4.append(i)

li3.sort()
li4.sort(key = lambda x: x[1], reverse = True)

s2 = ''
for l,r in li3:
    s2 += ')' * l + '(' * r
for l,r in li4:
    s2 += ')' * l + '(' * r

count = 0
while True:
    if count + 1 >= len(s2):
        break
    if s2[count] == '(' and s2[count+1] == ')':
        s2 = s2[:count] + s2[count+2:]
        count = max(0, count-1)
    else:
        count += 1

if s2 == '':
    print('Yes')
else:


### FIXED CODE ###

n = int(input())
li = []

for _ in range(n):
    s = input()
    count = 0
    while True:
        if count + 1 >= len(s):
            break
        if s[count] == '(' and s[count+1] == ')':
            s = s[:count] + s[count+2:]
            count = max(0, count-1)
        else:
            count += 1
    li.append(s)

li2 = []
for i in li:
    count = 0
    for j in range(len(i)):
        if i[j] == ')':
            count += 1
        else:
            break
    li2.append((count, len(i) - count))

li3 = []
li4 = []

for i in li2:
    if i[0] <= i[1]:
        li3.append(i)
    else:
        li4.append(i)

li3.sort()
li4.sort(key = lambda x: x[1], reverse = True)

now = [0,0]

for l,r in li3:
    if l == 0 and r == 0:
        pass
    elif l == 0:
        now[1] += r
    else:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
        now[1] += r

for l,r in li4:
    if l == 0 and r == 0:
        pass
    elif r == 0:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
    else:
        now[1] -= l
        if now[1] < 0:
            print('No')
            exit()
        now[1] += r

if now[0] == 0 and now[1] == 0:
    print('Yes')
else:
    print('No')
n = int(input())

if n[0] ==7 or n[1] ==7 or n[2] ==7:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n = str(input())

if n[0] =='7' or n[1] =='7' or n[2] =='7':
  print('Yes')
else:
  print('No')
print(2**(len(bin(int(input()))-3))

### FIXED CODE ###

print(2**(len(bin(int(input())))-3))
month, day = map(int, input())
if month > day:
    print(month-1)
else:
    print(month)

### FIXED CODE ###

month, day = map(int, input().split())
if month > day:
    print(month-1)
else:
    print(month)
n,a,b=map(int,input().split())
if n>1 and b>=a or n==1 and a==b: 
    print ((n-2)*(b-a)+1);
else:
    print ("0");

### FIXED CODE ###

n, a, b = map(int, raw_input().split())
print max(a - b + (b - a) * max(n - 1, 0) + 1, 0)
N = int(input())
tmp = [tuple(map(int,input().split())) for i in range(N)]

ct = 0
cx = 0
cy = 0
for t,x,y in tmp:
    dst = abs(cx - x) + abs(cy - y)
    if dst > t-ct or dst%2 != (t-ct)%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y

print('Yes')

### FIXED CODE ###

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

if (a*b)%2 == 0:
    print("Even")
else:
    print("Odd")
n = int(input())
w = [str(input()) for _ in range(n)]

def solve(n,ls):
    if n == -1:
        return print("Yes")
    else:
        if ls[n][-1] == ls[n+1][0]:
            return solve(n-1,ls)
        else:
            return print("No")

solve(n,w)

### FIXED CODE ###

n = int(input())
w = [input()  for _ in range(n)]



def solve(n,ls):
    if n == 0:
        return "Yes"
    else:
        if ls[n-1][-1] == ls[n][0]:
            return solve(n-1,ls)
        else:
            return "No"


flg = solve(n-1,w)
if flg == "No":
    pass
else:
    if not len(w) == len(list(set(w))):
        flg ="No"

print(flg)
N = int(input())
P= [int(x) for x in input().split]

answer=0
for i in range(1,N-1):
  a,b,c=P[i-1:i+2]
  if b != max(a,b,c) and b!= min(a,b,c):
    answer+=1

print(answer)


### FIXED CODE ###

N = int(input())
P = [int(x) for x in input().split()]
#とりまリストに入れる。
answer = 0
for i in range(1,N-1):
  #iがN-2まででいい理由は次行で最終項目までカバーするから
  a,b,c = P[i-1:i+2]
  if b != min(a,b,c) and b != max(a,b,c):
    #三つのうち真ん中というのは最大でも最小でもないということ。
    answer += 1

print(answer)
N=int(input())
 sen = N//1000:
 sen2 = sen*1000
 atai = N-sen2
 
for N in 10000:
  if N % 1000 == 0：
  print(0)
else:
  print(atai)

### FIXED CODE ###

#! /usr/bin/python3

N = int(input())
1 <= N <= 10000

if N % 1000 == 0:
 print(0)
else:
  sen = N//1000
  sen2 = sen*1000
  atai = N-sen2
  atai2 = 1000-atai
  print(atai2)
import random
import copy
n = input()
ori = map(int, raw_input().split())
num = copy.deepcopy(ori)
while not sorted(num) == num:
    l = list()
    for i in xrange(n*2):
        if sorted(num) == num:
            break
        a = random.randint(0, n-1)
        b = random.randint(0, n-1)
        num[a] += num[b]
        l.append("%d %d" % ((a+1), (b+1)))
    else:
        num = copy.deepcopy(ori)

print len(l)
for i in l:
    print i
print num


### FIXED CODE ###

n = input()
num = map(int, raw_input().split())
ma = max(num)
mi = min(num)
l = list()
if ma*mi < 0:
    if ma > abs(mi):
        index = num.index(ma)
    else:
        index = num.index(mi)
    for i in xrange(n):
        l.append("%d %d" % (index+1, i+1))
    b = num[index]
else:
    b = 0
    for i in num:
        if i:
            b = i
            break

if b == 0:
    pass
elif b < 0:
    for i in xrange(n-1, 0, -1):
        l.append("%d %d" % (i+1, i))
else:
    for i in xrange(0, n-1):
        l.append("%d %d" % (i+1, i+2))

print len(l)
for i in l:
    print i
import sys

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

if N == 1:
    print(1)

else:
    a = 1
    ans = 1

    if M == 0:
        ans = (a+b)%1000000007
        a, b = b, ans

    elif M == 1:
        if a_list[0] == 1:
            b = 0
            m = 1
        else:
            b = 1
            m = 0
        for i in range(2, N+1):
            if a_list[0] == i:
                a, b = b, 0
            else:
                ans = (a+b)%1000000007
                a, b = b, ans

    else:
        if a_list[0] == 1:
            b = 0
            m = 1
        else:
            b = 1
            m = 0
        for i in range(2, N+1):
            if m < M-1:
                if a_list[m+1] - a_list[m] == 1:
                    print(0)
                    sys.exit()

                if a_list[m] == i:
                    a, b = b, 0
                    m += 1
                else:
                    ans = (a+b)%1000000007
                    a, b = b, ans

            else:
                if a_list[m] == i:
                    a, b = b, 0
                else:
                    ans = (a+b)%1000000007
                    a, b = b, ans

    print(ans)

### FIXED CODE ###

import sys

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

if N == 1:
    print(1)

else:
    a = 1
    ans = 1

    if M == 0:
        b = 1
        for i in range(2, N+1):
            ans = (a+b)%1000000007
            a, b = b, ans

    elif M == 1:
        if a_list[0] == 1:
            b = 0
            m = 1
        else:
            b = 1
            m = 0
        for i in range(2, N+1):
            if a_list[0] == i:
                a, b = b, 0
            else:
                ans = (a+b)%1000000007
                a, b = b, ans

    else:
        if a_list[0] == 1:
            b = 0
            m = 1
        else:
            b = 1
            m = 0
        for i in range(2, N+1):
            if m < M-1:
                if a_list[m+1] - a_list[m] == 1:
                    print(0)
                    sys.exit()

                if a_list[m] == i:
                    a, b = b, 0
                    m += 1
                else:
                    ans = (a+b)%1000000007
                    a, b = b, ans

            else:
                if a_list[m] == i:
                    a, b = b, 0
                else:
                    ans = (a+b)%1000000007
                    a, b = b, ans

    print(ans)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        A: usize,
        B: usize,
        C: usize,
        X: usize
    }

    let mut ans = 0;

    for a in 0..A+1 {
        for b in 0..B+1 {
            let cnt = (0..C+1).filter(|&c| 500*a + 100*b + 50*c == X).count();
            ans += cnt;
        }
    }

    println!("{}", ans);
}

### FIXED CODE ###

coinA = int(input())
coinB = int(input())
coinC = int(input())
want = int(input())
ways = 0
i = 0
while i <= coinA:
    j = 0
    while j <= coinB:
        k = 0
        while k <= coinC:
            if i*500 + j*100 + k*50 == want:
                ways = ways + 1
            k = k + 1
        j = j + 1
    i = i + 1
print(ways)
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)


H, N = list(map(int, input().split()))
a = []
for i in range(N):
    a.append(list(map(int, input().split())))


dp = [0 for i in range(H+1)]

for h in range(1, H+1):
    dp[h] = min([dp[h-a[i][0]] + a[i][1] for i in range(N)])

print(dp[H])





### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)


H, N = list(map(int, input().split()))
a = []
for i in range(N):
    a.append(list(map(int, input().split())))


dp = [0 for i in range(H+1)]

for h in range(1, H+1):
    dp[h] = min([dp[max(0, h-a[i][0])] + a[i][1] for i in range(N)])

print(dp[H])
input1 = input()
 
row = input1.split('\n')

N = int(row[0])
numbers = row[1].split()

counter = 0

for i in range(N):
    if int(numbers[i]) != i+1:
        counter+=1
        
if counter <= 2:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

N = int(input())
numbers = input().split()

counter = 0

for i in range(N):
    if int(numbers[i]) != i+1:
        counter+=1
        
if counter <= 2:
    print('YES')
else:
    print('NO')
a=int(input())
b=list(input())
count=0
if(a%2==1):
  print('No')
else:
  for i in range(a/2):
    if(b[i]==b[i+a/2]):
      count+=1
  if(count==a/2):
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

a=int(input())
b=list(input())
count=0
if(a%2==0):
    a=int(a/2)
    for i in range(a):
        if(b[i]==b[i+a]):
          count+=1
    if(count==a):
        print('Yes')
    else:
        print('No')
else:
    print('No')
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]=(t[a][0]*(t[i][0]+t[i][1]))%m
            t[a][1]=(t[a][1]*t[i][0])%m
f(1,0)
print(sum(t[1]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n=int(input())
s=[[]for i in range(n+1)]
m=10**9+7
for i in range(n-1):
    x,y=map(int,input().split())
    s[x].append(y)
    s[y].append(x)
t=[[0,0]for i in range(n+1)]
def f(a,b):
    t[a][0]=t[a][1]=1
    for i in s[a]:
        if i!=b:
            f(i,a)
            t[a][0]*=t[i][0]+t[i][1]
            t[a][1]*=t[i][0]
f(1,0)
print(sum(t[1])%m)
S,T=map(string, input().split())
print(S+T)

### FIXED CODE ###

S,T=input().split()
print(T+S)
x,y = map(int,input().split())
if y%2!=0:
    print("No")
kame=(y//2)-x
tsuru = (-y//2)+2x
if kame + tsuru == x:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

x,y = map(int,input().split())
kame=(y//2)-x
if y%2!=0:
    print("No")
elif (kame>=0)&(kame<=x):
    print("Yes")
else:
    print("No")