Harryxun/stf_run huggingface dataset:
A,B,C,K = map(int,input().split())

a = K - A #Aのカードを引いた後のB,Cの数
b = K - A - B #Bのカードで水増しした後のCの数

if A = 0:
    print((-1)*b)
elif A > 0:
    if b >= 0:
        print(A - b)
    elif b < 0:
        print(A)

### FIXED CODE ###

A,B,C,K = list(map(int,input().split()))
ans = 0

if A > K:
    ans += K * 1
else:
    ans += A * 1

if K - A - B >= 0:
    ans += (K - A - B) * (-1)
else:
    ans += 0
    
print(ans)
N = int(input())
S = input()
ans=0
for i in range(N-1):
  if(S[i] == S[i+1]):
    ans++
ans=N-ans
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans=0
for i in range(N-1):
  if(S[i] == S[i+1]):
    ans+=1
ans=N-ans
print(ans)
import sys
sys.setrecursionlimit(100000)

N, M, K = map(int, input().split())
mod = 998244353

m = [1, M]
k = M
for _ in range(1, N+1):
  k = k*(M-1)%mod
  m.append(k)
ans = []


def solve(now, pairs, colors):
  if now == N:
    ans.append(m[colors])
    return 0
  elif pairs == K:
    colors += N - now
    ans.append(m[colors])
    return 0
  else:
    solve(now+1, pairs+1, colors)
    solve(now+1, pairs, colors+1)


solve(1, 0, 1)


#print(ans)
a = 0
for _ in range(len(ans)):
  a += ans[_]
  a %= mod
print(a)

### FIXED CODE ###

N, M, K = map(int, input().split())
mod = 998244353

inv = [0,1]
for i in range(2, N):
  inv.append((-inv[mod%i]*(mod//i))%mod)

if N == 1:
  print(M)
  exit()

m = [1]
s = 1
for _ in range(N-1):
  s = s*(M-1)%mod
  m.append(s)

ncombi = [1]
c = 1
for k in range(K):
  c = c*(N-1-k)*inv[k+1]
  c %= mod
  ncombi.append(c)

ans = 0
for k in range(K+1):
  ans = ans + m[-k -1]*ncombi[k]
  ans %= mod

ans = ans*M%mod
print(ans)
from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
n=int(input())
print(n*n)

### FIXED CODE ###

"""from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
"""
n=int(input())
print(n*n)
def c(i, p, f, g, vis):
    if vis[i]:
        return
    vis[i] = True
    w = f[i] + p
    k[i] = w
    ch = g[i]
    for x in ch:
        c(x, w, f, g, vis)


def main():
    import sys
    n, q, *abpx = map(int, sys.stdin.read().split())

    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    c(1, 0, f, g, vis)
    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def c(i, p, f, g, k, vis):
    if vis[i]:
        return
    vis[i] = True
    w = f[i] + p
    k[i] = w
    ch = g[i]
    for x in ch:
        c(x, w, f, g, k, vis)


def main():
    import sys
    sys.setrecursionlimit(300000)
    n, q, *abpx = map(int, sys.stdin.read().split())

    g = [[] for _ in range(n + 1)]
    for u, v in zip(*[iter(abpx[:2 * (n - 1)])] * 2):
        g[u].append(v)
        g[v].append(u)

    f = [0 for _ in range(n + 1)]

    for p, x in zip(*[iter(abpx[2 * (n - 1):])] * 2):
        f[p] += x

    k = [0 for _ in range(n + 1)]
    vis = [False for _ in range(n + 1)]

    c(1, 0, f, g, k, vis)
    ans = ' '.join(map(str, k[1:]))
    print(ans)


if __name__ == '__main__':
    main()
for i in range(n):
    a.append(int(input())-1)

button = 0
cnt = 0
done = [False] * n

while True:
    if done[button] == False:
        done[button] = True
        cnt += 1
        if a[button] == 1:
            break
        button = a[button]
    else:
        cnt = -1
        break

print(cnt)

### FIXED CODE ###

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

for i in range(n):
    a.append(int(input())-1)

button = 0
cnt = 0
done = [False] * n

while True:
    if done[button] == False:
        done[button] = True
        cnt += 1
        if a[button] == 1:
            break
        button = a[button]
    else:
        cnt = -1
        break

print(cnt)
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,h = readInts()
A = [0] * n
B = [0] * n
for i in range(n):
    a,b = readInts()
    A[i] = a
    B[i] = b
A = sorted(A, reverse = True)
B = sorted(B, reverse = True)
MAX = a[0]
ans = 0
for v in b:
    # 投げれるMAXより大きい物はぶん投げろ
    if h <= 0:
        break
    if v > MAX: # 投げろ
        # いつ投げても一緒だねえ
        ans += 1
        h -= v
    else:
        break
if h > 0:
    ans += (h + MAX - 1) // MAX # 振れるやつ限界まで振ってやろう
print(ans)

### FIXED CODE ###

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,h = readInts()
a = [0] * n
b = [0] * n
for i in range(n):
    a_,b_ = readInts()
    a[i] = a_;b[i]=b_;
a = sorted(a,reverse = True)
b = sorted(b,reverse = True)
MAX = a[0]
ans = 0
for v in b:
    if h <= 0:
        break
    if v > MAX:
        ans += 1
        h -= v
    else:
        break
if h > 0:
    ans += (h+MAX-1)//MAX
print(ans)
def gcd(a, b):
    a, b = sorted([a, b])
    while(b != 0):
        a, b = (b, a%b)
    return b

def getMultiCount(start, end, times):
    if end < times: return 0
    s = start-(start%times)
    if s != start: s += times
    e = end-(end%times)
    if s > e: return 0
    return ((e-s)//times)+1
    
def answer(a, b, c, d):
    cCount = getMultiCount(a, b, c)
    dCount = getMultiCount(a, b, d)
    cdCount = getMultiCount(a, b, c*d//gcd(c,d))
    return (b-a+1)-(cCount + dCount - cdCount)

a, b, c, d = map(int, input().split())
print(answer(a, b, c, d))

### FIXED CODE ###

from fractions import gcd
# def gcd(x, y):
#     while(y != 0):
#         temp = y
#         y = x%y
#         x = temp
#     return y

def getMultiCount(start, end, times):
    if end < times: return 0
    s = start-(start%times)
    if s != start: s += times
    e = end-(end%times)
    if s > e: return 0
    return ((e-s)//times)+1
    
def answer(a, b, c, d):
    cCount = getMultiCount(a, b, c)
    dCount = getMultiCount(a, b, d)
    cdCount = getMultiCount(a, b, c*d//gcd(c,d))
    return (b-a+1)-(cCount + dCount - cdCount)

a, b, c, d = map(int, input().split())
print(answer(a, b, c, d))
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ab_total_list = []
total_list = []

A.sort()
A.reverse()
if len(A) > K:
    A = A[0:K+1]

B.sort()
B.reverse()
if len(B) > K:
    B = B[0:K+1]

C.sort()
C.reverse()
if len(C) > K:
    C = C[0:K+1]

for i in A:
    for j in B:
        ab_total_list.append(i+j)
        
ab_total_list.sort()
ab_total_list.reverse()

z = 0
min_total = 0
if K > len(ab_total_list):
    min_total = ab_total_list[-1]
else:
    min_total = ab_total_list[K]

for i in ab_total_list:
    for j in C:
        total = i + j
        total_list.append(i+j)

total_list.sort()
total_list.reverse()
for i in range(0, K):
    print(total_list[i])

### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ab_total_list = []
total_list = []

A.sort()
A.reverse()
if len(A) > K:
    A = A[0:K+1]

B.sort()
B.reverse()
if len(B) > K:
    B = B[0:K+1]

C.sort()
C.reverse()
if len(C) > K:
    C = C[0:K+1]

ab_total_list = []
for i in A:
    for j in B:
        ab_total_list.append(i+j)

ab_total_list.sort()
ab_total_list.reverse()
if len(ab_total_list) > K:
    ab_total_list = ab_total_list[0:K+1]

for i in range(0, K):
    for j in range(0, int(K/(i+1))):
        if j >= len(C) or i >= len(ab_total_list):
            break
        total = ab_total_list[i] + C[j]
        total_list.append(total)
        if (i*j) > K:
            break

total_list.sort()
total_list.reverse()
for i in range(0, K):
    print(total_list[i])
num = int(input())
strng = ""
while num >= 1 :
    kalan = num % 26
    if(kalan==0):
      strng = "z" +strng
    else:
    	strng = chr(96+kalan)+strng
    num = num // 26
print(strng)

### FIXED CODE ###

import re
txt=input()
x = re.search("[A-Z]", txt)
if(x):
  print("A")
else:
  print("a")
while True :
    (x, y) = int(i) for i in input().strip()
    if x = 0 and y = 0 :
        break
    elif x >= y :
        print(x,y)
    else :
        print(y,x)

### FIXED CODE ###

while True:
    (x, y) = [int(i) for i in input().split()]
    
    if x == y == 0 :
        break

    if x <= y :
        print(x, y)
    else :
        print(y, x)
S = input()
W = input()

if S <= W :
    print("unsafe")

elif S > W :
    print("safe")

### FIXED CODE ###

#入力例全てOKだけど黄色#
S,W = map(int,input().split())

if S <= W :
    print("unsafe")

else :
    print("safe")
import sys
sys.setrecursionlimit(10000000000)


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

INF=float("inf")

DP=[INF]*(N+1)
DP[0]=0

def rec(n):
    if DP[n]!=INF:return DP[n]
    res=INF
    for i in range(1,K+1):
        if n-i<0:break
        res=min(res,rec(n-i)+abs(h[n-i]-h[n]))
    DP[n]=res
    return res

ans=rec(N-1)

print(ans)


### FIXED CODE ###

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

DP=[10000000000]*N

DP[0]=0
for i in range(1,N):
    temp=[]
    if i<K:
        for j in range(i):
            temp.append(DP[j]+abs(h[j]-h[i]))
    else:
        for j in range(1,K+1):
            temp.append(DP[i-j]+abs(h[i]-h[i-j]))
    DP[i]=min(temp)

print(DP[N-1])
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int, input().split()))
ans = 0
flag = True
nums = {}
for a in A:
    if a in nums:
        nums[a] += 1
    else:
        nums[a] = 1

if n % 2 == 1:
    if nums[0] != 1:
        flag = False
    for i in range(n//2):
        if nums[2*(i+1)] != 2:
            flag = False
            break
else:
    for i in range(n//2):
        if nums[2*i+1] != 2:
            flag = False
            break

if flag == True:
    ans = 2**(n//2)
    ans = ans % (10**9 + 7)
    
print(ans)

### FIXED CODE ###

n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i in nums:
        nums[i] += 1
        if nums[i] > 2:
            ans = 0
            break
    else:
        nums[i] = 1
        
if n % 2 == 0:
    if 1 in nums.values():
        ans = 0
    else:
        ans = 2**(n//2)
        
else:
    if nums[0] == 1:
        del nums[0]
        if 1 in nums.values():
            ans = 0
        else:
            ans = 2**((n-1)//2)
    else:
        ans = 0
        
print(ans % (10**9+7))
n = input()

if n==1:
  print("Hello World")
else:
  print(int(input())+int(input()))

### FIXED CODE ###

n = int(input())

if n==1:
  print("Hello World")
else:
  print(int(input())+int(input()))
A,B,K = map(int,input().split())
x = []
if A >= B:
    for i in range(1,A):
        if A % i == 0 and B % i == 0:
            x.append(i)
else:
    for i in range(1,B):
        if A % i == 0 and B % i == 0:
            x.append(i)
x.sort(reverse=True)
print(x[K - 1])
  

### FIXED CODE ###

a, b, k = map(int, input().split())
print([i for i in range(1,101) if a%i+b%i<1][-k])
def main():
    n = int(input())
    h = list(map(int, input().split()))

    score = []

    j = 0
    for i in range(n-1):
        if i != 0:
            j = next_j
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                next_j = j+1
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    print(max(score))

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

    score = []

    j = 0
    for i in range(n-1):
        if i != 0:
            j = next_j
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                next_j = j+1
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    if n == 1:
        print(0)
    else:
        print(max(score))

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

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

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

print(lcm(a, b))

### FIXED CODE ###

import fractions

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

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

print(lcm(a, b))
l = sorted([int(input()) for i in range(2)])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])

### FIXED CODE ###

l = sorted([int(i) for i in input().split()])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])
S_d,T = list(input()),list(input())

if len(S_d) < len(T):
  print("UNRESTORABLE");exit()

flag = 1
for i in range(-len(T),-len(S_d)-1,-1):
  key = 0
  for j in range(len(T)):
    if S_d[i+j]=="?" or S_d[i+j]==T[j]:
      key+=1
  if key == len(T):
    st=len(S_d)+i
    break
  else:
    st=-1

if st==-1:
  print(UNRESTORABLE)
else:
  for i in range(len(S_d)):
    if st <= i and i < st+len(T):
      print(T[i-st],end="")
    elif S_d[i]=="?":
      print("a",end="")
    else:
      print(S_d[i],end="")
      

### FIXED CODE ###

S_d,T = list(input()),list(input())

if len(S_d) < len(T):
  print("UNRESTORABLE");exit()

flag = 1
for i in range(-len(T),-len(S_d)-1,-1):
  key = 0
  for j in range(len(T)):
    if S_d[i+j]=="?" or S_d[i+j]==T[j]:
      key+=1
    else:
      break
  if key == len(T):
    st=len(S_d)+i
    break
  else:
    st=-1

if st==-1:
  print("UNRESTORABLE")
else:
  for i in range(len(S_d)):
    if st <= i and i < st+len(T):
      print(T[i-st],end="")
    elif S_d[i]=="?":
      print("a",end="")
    else:
      print(S_d[i],end="")
S = input()
if S[0] == S[1] and S[1] == S[2]:
print('No')
else:
print('Yes')

### FIXED CODE ###

S = input()
if S[0] == S[1] and S[1] == S[2]:
	print('No')
else:
	print('Yes')
a, b = map(int, input().split())
for c in range(1, 4):
  if a*b*c%2 == 1:
    print('Yes')
	break
else:
  print('No')

### FIXED CODE ###

a, b = map(int, input().split())
for c in range(1, 4):
    if a*b*c%2 == 1:
        print('Yes')
        break
else:
    print('No')
S = input()
T = input()

dp = [[[] for _ in range(len(S)+1)] for _ in range(len(T)+1)]
cdp = [[None for _ in range(len(S)+1)] for _ in range(len(T)+1)]
dp[0] = [[''] for _ in range(len(T)+1)]
cdp[0] = [0 for _ in range(len(T)+1)]

for i in range(1,len(T)+1):
    for j in range(len(S)+1):
        if j == 0:
            dp[i][j] = ['']
            cdp[i][j] = 0
            continue
        if S[j-1] == T[i-1]:
            dp[i][j] = [p + S[j-1] for p in dp[i-1][j-1]]
            cdp[i][j] = cdp[i-1][j-1] + 1
        else:
            if cdp[i][j-1] > cdp[i-1][j]:
                dp[i][j] = dp[i][j-1]
                cdp[i][j] = cdp[i][j-1]
            else:
                dp[i][j] = dp[i-1][j]
                cdp[i][j] = cdp[i-1][j]

print(dp[-1][-1][0])


### FIXED CODE ###

S = input()
T = input()

# dp = [[[] for _ in range(len(S)+1)] for _ in range(len(T)+1)]
cdp = [[None for _ in range(len(S)+1)] for _ in range(len(T)+1)]
ddp = [[None for _ in range(len(S)+1)] for _ in range(len(T)+1)]
# dp[0] = [[''] for _ in range(len(S)+1)]
cdp[0] = [0 for _ in range(len(S)+1)]
ddp[0] = [0 for _ in range(len(S)+1)]

for i in range(1,len(T)+1):
    for j in range(len(S)+1):
        if j == 0:
            # dp[i][j] = ['']
            cdp[i][j] = 0
            ddp[i][j] = 0
            continue
        if S[j-1] == T[i-1]:
            # dp[i][j] = [p + S[j-1] for p in dp[i-1][j-1]]
            cdp[i][j] = cdp[i-1][j-1] + 1
            ddp[i][j] = 2
        else:
            if cdp[i][j-1] > cdp[i-1][j]:
                # dp[i][j] = dp[i][j-1]
                cdp[i][j] = cdp[i][j-1]
                ddp[i][j] = 1
            else:
                # dp[i][j] = dp[i-1][j]
                cdp[i][j] = cdp[i-1][j]
                ddp[i][j] = 0

# print(dp[-1][-1][0])

i, j = len(T), len(S)
L = ''
while i > 0 and j > 0:
    if ddp[i][j] == 2:
        i -= 1
        j -= 1
        L += T[i]
    elif ddp[i][j] == 1:
        j -= 1
    elif ddp[i][j] == 0:
        i -= 1

print(L[::-1])
A,B,C = map(int,input().split())
abc = [A,B,C]
Even = []
Odd = []
for i in range(3):
    if min(abc) == abc[i]:
        idx1 = i
    elif max(abc) == abc[i]:
        idx3 = i
    else:
        idx2 = i
    if abc[i]%2 == 0:
       Even += [i]
    else:
       Odd += [i]
       
ans = 0

if len(Even) == 3 or len(Odd) == 3:
    ans = (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Even) == 2:
    ans += 1
    abc[Even[0]] += 1
    abc[Even[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Even) == 1:
    ans += 1
    abc[Odd[0]] += 1
    ans[Odd[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
    
print(ans)
    



### FIXED CODE ###

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

abc = [A,B,C]
ieven = []
iodd = []
for i in range(3):
    if abc[i] % 2 == 0:
        ieven += [i]
    else:
        iodd += [i]
        
if len(ieven) == 3 or len(iodd) == 3:
    abc.sort()
    ans = (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
else:
    if len(ieven) > len(iodd):
        abc[ieven[0]] += 1
        abc[ieven[1]] += 1
        abc.sort()
        ans = 1 + (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
    else:
        abc[iodd[0]] += 1
        abc[iodd[1]] += 1
        abc.sort()
        ans = 1 + (abc[2]-abc[1])//2 + (abc[2]-abc[0])//2
        
print(ans)
import math

def ifprime(num):
  if num == 1:
    return False
  for i in range(2,math.floor(num ** 0.5) + 1):
    if num % i:
      continue
    else:
      return False
  return True

while(True):
  try:
    num = input()
  except:
    break
  count = 0
  for i in range(1,num+1):
    if ifprime(i) and ifprime(num-i):
      count += 1
  print(count)
    
       


### FIXED CODE ###

import math

def ifprime(num):
  if num == 1:
    return False
  for i in range(2,math.floor(num ** 0.5) + 1):
    if num % i:
      continue
    else:
      return False
  return True

while(True):
  try:
    num = int(input())
  except:
    break
  count = 0
  for i in range(1,num+1):
    if ifprime(i) and ifprime(num+1-i):
      count += 1
  print(count)
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
ring = [A[0]]
score = [A[0]]
s = 0

for i in A[1:N]:
    s += max(score)
    j = score.index(max(score))
    ring.insert(j,A[i])
    score.insert(j,A[i])
    score[j-1] = A[i]

print(s)

### FIXED CODE ###

import math
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
s = A[0]

for i in range(1,N-1):
    s += A[math.ceil(i/2)]

print(s)
def sumTree(index, children, prev, pointTree=[]):
    sumPoint = (point[index] if index in point else 0) + prev
    pointTree.append(sumPoint)

    for key in children:
        sumTree(key, tree[key], sumPoint, pointTree)    
    return pointTree

if __name__ == "__main__":
    tree = {}
    point = {}
    N, Q = map(int, input().split(' '))
    for i in [input() for i in range(N-1)]:
        A, B = map(int, i.split(' '))
        if A in tree:
            tree[A].append(B)
        else:
            tree[A] = [B]

        if B not in tree:
            tree[B] = []

    for i in [input() for i in range(Q)]:
        A, B = map(int, i.split(' '))
        if A in point:
            point[A] += B
        else:
            point[A] = B

    firstKey = list(tree.keys())[0]
    pointTree = sumTree(firstKey, tree[firstKey], 0)
    print(' '.join(map(str, pointTree)))

### FIXED CODE ###

from collections import deque
 
if __name__ == "__main__":
    N, q = map(int, input().split())
    links = [[] for _ in range(N)]
    
    for i in range(N - 1):
        a, b = map(int, input().split())
        links[a - 1].append(b - 1)
        links[b - 1].append(a - 1)
    
    ans = [0] * N
    for i in range(q):
        p, x = map(int, input().split())
        ans[p - 1] += x

    deq = deque([0])
    visited = [False] * N
    while deq:
        parent = deq.popleft()
        link = links[parent]
        for v in link:
            if not visited[v]:
                ans[v] += ans[parent]
                deq.append(v)
        visited[parent] = True
    
    print(*ans)
x = input()
y = input()

if(x + y >= 10):
  print("error")
else:
  print(x+y)

### FIXED CODE ###

x, y = input().split()

x = int(x)
y = int(y)

if x + y >= 10 :
  print("error")
else:
  print(x+y)
def solve():
    mod = 10 ** 9 + 7

    x, y = map(int, input().split())

    sum_ = x + y

    q, r = divmod(sum_, 3)
    if r != 0:
        return 0

    a = (x * 2 - y) // 3

    # b = (y * 2 - x) // 3

    def cmb(n, r):
        return (f[n] * invs[r] * invs[n - r]) % mod

    f = [-1] * (q + 1)
    f[0] = 1
    t = 1
    for i in range(1, q + 1):
        t *= i
        t %= mod
        f[i] = t

    inv = pow(t, mod - 2, mod)
    invs = [-1] * (q + 1)
    invs[q] = inv
    for i in range(q - 1, 0, -1):
        inv *= (i + 1)  # <-直した
        inv %= mod
        invs[i] = inv

    return cmb(q, a)


print(solve())


### FIXED CODE ###

def solve():
    mod = 10 ** 9 + 7

    x, y = map(int, input().split())

    sum_ = x + y

    q, r = divmod(sum_, 3)
    if r != 0:
        return 0

    a = (x * 2 - y) // 3

    b = (y * 2 - x) // 3

    if a < 0 or b < 0:
        return 0

    def cmb(n, r):
        return (fact[n] * finv_t[r] * finv_t[n - r]) % mod

    fact = [1, 1]
    inv_t = [0, 1]
    finv_t = [1, 1]
    for i in range(2, q + 1):
        fact.append((fact[-1] * i) % mod)
        inv_t.append((-inv_t[mod % i] * (mod // i)) % mod)
        finv_t.append((finv_t[-1] * inv_t[-1]) % mod)

    return cmb(q, a)


print(solve())
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(key=lambda x:x[1], reverse=True)

a_i = 0
is_fin = False
for b, c in BC:
    if is_fin:
        break

    for _ in range(b):
        if A[a_i] < c:
            A[a_i] = c 
            a_i += 1
        else:
            is_fin = True
            break

print(sum(A))


### FIXED CODE ###

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

A.sort()
BC.sort(key=lambda x:x[1], reverse=True)

a_i = 0
is_fin = False
for b, c in BC:
    if is_fin:
        break

    for _ in range(b):
        if A[a_i] < c:
            A[a_i] = c 
            a_i += 1
            if a_i >= len(A):
                is_fin = True
                break
        else:
            is_fin = True
            break

print(sum(A))