Harryxun/stf_run huggingface dataset:
def per(a, b):
    if a == 0 or b == 0:
        return 0
    return 100 * b / (a + b)


a, b, c, d, e, f = [int(i) for i in input().split()]
max_sugar = e * f / 100
max_water = f - max_sugar
s = 0
water = set()
numa = f // a
numb = f // b
for i in range(numa):
    check = 100 * a * i
    if f < check:
        break
    water.add(check)
    for m in range(numb):
        h = check + 100 * b * m
        if f < h:
            break
        water.add(h)
check = 0
n = 0
sugar_ans = 0
g = 0
for i in water:
    max_sugar = e * i /100
    while check <= max_sugar and check + i <= f:
        while check <= max_sugar and check + i <= f:
            if g < per(i, check) and i + check <= f:
                sugar_ans = check
                g = per(i, check)
                water_ans = i
            check += d
        check = c * n
        n += 1

print(water_ans + sugar_ans, sugar_ans)




### FIXED CODE ###

def node(hen, sin):
    if hen == 0 or sin == 0:
        return 0
    return 100 * sin / (hen + sin)


a, b, c, d, e, f = [int(i) for i in input().split()]
node_ans = 0
water_ans = 0
sugar_ans = 0
for A in range(0, f, a * 100):
    for B in range(0, f, b * 100):
        water = A + B
        max_sugar = water * e
        for C in range(0, f, c):
            for D in range(0, f, d):
                sugar = C + D
                if max_sugar < sugar*100 or f < water + sugar or water == 0:
                    break
                elif node_ans <= node(water, sugar):
                    node_ans = node(water, sugar)
                    sugar_ans = sugar
                    water_ans = water

print(water_ans + sugar_ans, sugar_ans)
import numpy as np
import math
from decimal import Decimal

def resolve():
  S = input().split(" ")
  # print(math.floor(int(S[0])*Decimal(S[1])))
  # print(math.floor((int(S[0]) * int(float(S[1])*100))) // 100)
  print(math.floor((int(A) * int(float(B)*100))) // 100)
# if __name__ == "__main__":
#   resolve()

if __name__ == "__main__":
  resolve()

### FIXED CODE ###

import numpy as np
import math
from decimal import Decimal

def resolve():
  S = input().split(" ")
  print(math.floor(int(S[0])*Decimal(S[1])))


if __name__ == "__main__":
  resolve()
# -*- coding:utf-8 -*-
import sys

first = 0
second = 0
third = 0

for line in open(sys.argv[1],"r"):
    if first < int(line):
        third = second
        second = first
        first = int(line)
    elif second < int(line):
        third = second
        second = int(line)
    elif third < int(line):
        third = int(line)

print(first)
print(second)
print(third)

### FIXED CODE ###

# -*- coding:utf-8 -*-

first = 0
second = 0
third = 0
i = 0

for i in range(0,10):
    line = int(input())
    
    if first < int(line):
        third = second
        second = first
        first = int(line)
    elif second < int(line):
        third = second
        second = int(line)
    elif third < int(line):
        third = int(line)
print(first)
print(second)
print(third)
import math
A, B = map(int, input().split())
arange = set(range(math.ceil(A*100/8), math.ceil((A+1)*100/8)))
brange = set(range(math.ceil(B*100/10), math.ceil((B+1)*100/10)))
print(min(arange & brange))


### FIXED CODE ###

import math
A, B = map(int, input().split())
arange = set(range(math.ceil(A*100/8), math.ceil((A+1)*100/8)))
brange = set(range(math.ceil(B*100/10), math.ceil((B+1)*100/10)))
ans_range = arange & brange
if len(ans_range) == 0:
    print(-1)
else:
    print(min(ans_range))
paper = [0,0,0,0,0,0,0,0,0,0]
N = int(input())
for _ in range(N):
    number = int(input())
    paper[number] += 1
sum = 0
for x in range(10):
    if paper[x] % 2 == 1:
        sum += 1
print(sum)

### FIXED CODE ###

N = int(input())
set = set([])
for _ in range(N):
    p = int(input())
    if p not in set:
        set.add(p)
    else:
        set.remove(p)
print(len(set))
n = int(input())
s = input()

num = 0
lmax = 0
rmax = 0
for i in range(n):
    if s[i] == ")":
        num += 1
    else:
        num -= 1
    if num == -1:
        
    lmax = max(lmax, num)

num = 0
for i in range(n-1, -1, -1):
    if s[i] == "(":
        num += 1
    else:
        num -= 1
    rmax = max(rmax, num)

print("("*lmax + s + ")"*rmax)

### FIXED CODE ###

n = int(input())
s = input()

num = 0
lmax = 0
rmax = 0
for i in range(n):
    if s[i] == ")":
        num += 1
    else:
        num -= 1
    lmax = max(lmax, num)

num = 0
for i in range(n-1, -1, -1):
    if s[i] == "(":
        num += 1
    else:
        num -= 1
    rmax = max(rmax, num)

print("("*lmax + s + ")"*rmax)
import math
A, B = input().split()

print(int(math.floor(float(A) * float(B))))


### FIXED CODE ###

n = int(input())

d = 2
ans = 0
while d * d <= n:
    if (n % d != 0):
        d += 1
        continue
    z = d
    while n % z == 0:
        n //= z
        z *= d
        ans += 1

    while n % d == 0:
        # 残りかすを除去
        n //= d

if (n != 1):
    ans += 1

print(ans)
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
#elif x<0 and x+y>0:
#    print(abs(x//(x+y))*2-1)
elif x>0 and x+y<0:
    print(abs(y//(x+y))*2)
else:
    print(hhh)

### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
for i in range(N):
    if s[i]=='o':
        si=copy.copy(s)
        si[i]='x'
        day=N
        count=0
        flag=False
        while day>K-1 and count<K:
            if si[day-1]=='x':
                day-=1
            else:
                count+=1
                day-=C+1
                if count==K:
                    flag=True
        if flag==False:
            print(i+1)

### FIXED CODE ###


# -*- coding: utf-8 -*-

import numpy as np
N, K, C=map(int, input().split())
s=list(input())

forward=np.zeros(K)
back=np.zeros(K)

day=0
count=0
while day <N and count<K:
    if s[day]=='o':
        forward[count]=day
        count+=1
        day+=C+1
    else:
        day+=1

day=N-1
count=0
while day<N and count<K:
    if s[day]=='o':
        back[count]=day
        count+=1
        day-=C+1
    else:
        day-=1

#print(forward)
#print(back[::-1])

for i in range(K):
    if forward[i]==back[K-1-i]:
        print(int(forward[i])+1)
import sys
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    n = input()
    stns = [int(x) for x in input().split()]



    # reader = (s.rstrip() for s in sys.stdin)
    # input = reader.__next__
    # sys.setrecursionlimit(1000000)
    # do magic here
    # n = int(input())
    # stns = [int(x) for x in input().split()]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()

### FIXED CODE ###

import sys
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    # n = input()
    # stns = [int(x) for x in input().split(' ')]



    reader = (s.rstrip() for s in sys.stdin)
    input = reader.__next__
    sys.setrecursionlimit(1000000)
    # do magic here
    n = int(input())
    stns = [int(x) for x in input().split()]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

N,M = [int(x) for x in input().split()]
xls = [int(x) for x in input().split()]
dls = [xls[i+1]-xls[i] for i in range(M-1)]
if N >= M:
    ans = 0


print(ans)

### FIXED CODE ###

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

N,M = [int(x) for x in input().split()]
xls = [int(x) for x in input().split()]
xls.sort()
dls = [xls[i+1]-xls[i] for i in range(M-1)]
if N >= M:
    ans = 0
else:
    dls.sort()
    ans = sum(dls[0:M-N])

print(ans)
count = 1
count = int(count)
while True:
    num = input()
    if num == 0:
        break
    print('Case {0}: {1}'.format(count,num))
    count = count + 1

### FIXED CODE ###

count = 1
count = int(count)
while True:
    num = input()
    num = int(num)
    if num == 0:
        break
    print('Case {0}: {1}'.format(count,num))
    count = count + 1
n, m = map(int,input().split())

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append((a,b))

ca = []
for i in range(n):
    a, b = map(int, input().split())
    ca.append((a,b))

for i in la:
    mi = 1000000001
    ans = 0
    for k,j in enumerate(ca):
        if abs(i[0]-j[0]) + abs(i[1]-j[1]) < mi:
            mi = abs(i[0]-j[0]) + abs(i[1]-j[1])
            ans = k+1
    print(ans)



### FIXED CODE ###

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

la = []
for i in range(n):
    a, b = map(int, input().split())
    la.append((a,b))

ca = []
for i in range(m):
    a, b = map(int, input().split())
    ca.append((a,b))

for i in range(len(la)):
    mi = 1000000001
    ans = 0
    for j in range(len(ca)):
        p = abs(la[i][0]-ca[j][0]) + abs(la[i][1]-ca[j][1])
        if  p < mi:
            mi = p
            ans = j+1
    print(ans)
import numpy as np
N = int(input())
A = list(map(int,input().split()))

chofuku_dict = {}
chofuku = []

for a in A:
    if a not in chofuku_dict:
        chofuku_dict[a] = 1
    else:
        chofuku.append(a)
        
chofuku = set(chofuku)

A = list(set(A))
A.sort()

bl = np.array([0] + [1]*A[-1])
ans = 0
for a in A:
    if a in chofuku:
        continue
    if bl[a] == 1:
        bl[a] = 0
        ans += 1
        bl[2*a::a] = 0
print(ans)

### FIXED CODE ###

x = list(map(int,input().split()))
print(x.index(0)+1)
import numpy as np
N = int(input())
A = np.array(input().split())
B = np.array(input().split())

ans = 0
mod = 1
for k in range(30):
    T = mod
    mod *= 2
    c = 0
    b = np.sort(B % mod)
    a = A % mod
    L1, R1, L2, R2 = (np.searchsorted(b, x - a).sum() for x in (T, 2*T, 3*T, 4*T))
    c += R1 - L1
    c += R2 - L2

    if c % 2:
        ans += T

print(ans)


### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)

ans = 0
mod = 1
for k in range(30):
    T = mod
    mod *= 2
    c = 0
    b = np.sort(B % mod)
    a = A % mod
    L1, R1, L2, R2 = (np.searchsorted(b, x - a).sum() for x in (T, 2*T, 3*T, 4*T))
    c += R1 - L1
    c += R2 - L2

    if c % 2:
        ans += T

print(ans)
# ABC077C

import bisect

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

bC=[0 for i in range(N)]
for i in range(N):
    bC[i]=N-bisect.bisect(C,B[i])
    
bCS=[0]*N+1
for i in range(N):
    bCS[i+1] = bCS[i]+bC[i]
    
ans=0
for i in range(N):
    x=bisect.bisect(B,A[i])
    ans+=bCS[N]-bCS[x]
        
print(ans)

### FIXED CODE ###

# ABC077C

import bisect

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

bC=[0 for i in range(N)]
for i in range(N):
    bC[i]=N-bisect.bisect(C,B[i])
    
bCS=[0]*(N+1)
for i in range(N):
    bCS[i+1] = bCS[i]+bC[i]
    
ans=0
for i in range(N):
    x=bisect.bisect(B,A[i])
    ans+=bCS[N]-bCS[x]
        
print(ans)
string = input()
numlist = [int(n) for n in string]
fst = numlist[0] * 10 + numlist[1]
scd = numlist[2] * 10 + numlist[3]
 
  
if string == '0000':
    print('NA')
    
elif fst > 12:
    if scd > 12:
        print('NA')
    else:
      	print('YYMM')
else:
    if scd > 12:
        print('MMYY')
    else:
        print('AMBIGUOUS')

### FIXED CODE ###

nk_str = input()
string = input()
nk_list = nk_str.split()
k = int(nk_list[-1])
string_list = [c for c in string]
string_list[k - 1] = string_list[k - 1].lower()
string = ''.join(string_list)
print(string)
m = [i+1 for i in range(int(raw_input()))]
n = int(raw_input())
for i in range(n):
	x,y = map(int, raw_input().split())
	if m.index(x) > m.index(y):
		r = m.pop(m.index(x))
		m.insert(m.index(y),r)
for i in range(n):
	print m[i]

### FIXED CODE ###

def solve(a):
	for i in M-set(a):
		if any(x == i and y not in a for x,y in xy): continue
		r = solve([i]+a)
		if r: return r
	return a
m = input()
M = set(range(1,m+1))
xy = [map(int,raw_input().split()) for i in range(input())]
for i in solve([]): print i
S = input().split()
if(S=ABC):
    print('ARC')
else:
    print('ABC')

### FIXED CODE ###

S = input()
if(S=='ABC'):
    print('ARC')
else:
    print('ABC')
import copy
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.pop(0)
for i in range(n-1):
  t=list(map(int,input().split()))
  k=t.pop(0)
  b=copy.deepcopy(a)
  for j in range(0,len(a)):
    if not b[j] in t:
      a.remove(a[j])
print(len(a))
  

### FIXED CODE ###

import copy
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.pop(0)
for i in range(n-1):
  t=list(map(int,input().split()))
  k=t.pop(0)
  b=copy.deepcopy(a)
  for j in range(0,len(a)):
    if not b[j] in t:
      a.remove(b[j])
print(len(a))
a, b = map(int, input().split())
c = map(int, input().split())
if a <= c.sum():
  print('Yes')
else:
  print('No')


### FIXED CODE ###

a, b = map(int, input().split())
c = list(map(int, input().split()))
if a <= sum(c):
  print('Yes')
else:
  print('No')
from scipy.special import comb
n,a,b=map(int,input().split())
MOD=10**9+7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

na=comb(n,a)
nb=comb(n,b)

ans=(pos(2,n,MOD)-na-nb-1)%MOD

print(ans)

### FIXED CODE ###


n,a,b=map(int,input().split())
MOD=10**9+7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

na=comb(n,a)
nb=comb(n,b)

ans=(pos(2,n,MOD)-na-nb-1)%MOD

print(ans)
n = int(input())
h = list(map(int, input().split()))

ans = 0
for i in range(0, n-2):
  c = 0
  for j in range(i, n-2):
  if h[j] > = h[j+1]:
    c += 1
    if(c > ans):
      ans = c
print(ans)

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
c = 0
ans = 0

for i in range(n-1, 0, -1):
  if h[i-1] >= h[i]:
    c += 1
    if c > ans:
      ans = c
  elif h[i-1] < h[i]:
      c = 0
      
print(ans)
print("Heisei" if input() <= 2019/04/30 else "TBD")

### FIXED CODE ###

print("Heisei" if input() <= "2019/04/30" else "TBD")
T = input()
PD = list(T)

for i in range(len(PD)):
  if PD[i] == '?':
    if i == 0 and P[1] == 'D':
      PD[i] = 'P'
    elif i == len(PD):
      PD[i] = 'D'
    elif PD[i-2] == 'P' and PD[i-1] == 'D':
      PD[i] = 'P'
    else:
      PD[i] = 'D'
      
print(''.join(PD))

### FIXED CODE ###

T = input()
print(T.replace('?','D'))
x = int(inout())
if x>1200:
  print('ARC')
else:
  print('ABC')

### FIXED CODE ###

x = int(input())
if x>=1200:
  print('ARC')
else:
  print('ABC')
import math
a, b, x = map(int, input().split())
y = a*a*b - x

if (a*a*b/2 < x):
  print(90-math.degrees(math.atan((a**3)/(2*y))))
else:
  print(90-math.degrees(math.atan((2*x)/(a* b**2))))


### FIXED CODE ###

import math
a, b, x = map(int, input().split())
y = a*a*b - x
if y == 0:
  print(0)
  exit()

if (a*a*b/2 < x):
  print(90-math.degrees(math.atan((a**3)/(2*y))))
else:
  print(90-math.degrees(math.atan((2*x)/(a* b**2))))
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, C = MAP()
stc = [LIST() for _ in range(N)]

now = [0]*(10**5+1)

for s, t, c in stc:
	now[s] += 1
	now[t+1] -= 1

now_acc = accumulate(now)
print(max(now_acc))


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, C = MAP()
stc = [LIST() for _ in range(N)]
stc.sort(key=lambda x:(x[2], x[0]))

tmp_s = stc[0][0]
tmp_t = stc[0][1]
tmp_c = stc[0][2]

stc = stc[1:]
stc_new = []
for s, t, c in stc:
	if tmp_c != c:
		stc_new.append((tmp_s, tmp_t))
		tmp_s = s
		tmp_t = t
		tmp_c = c
		
	elif tmp_t != s:
		stc_new.append((tmp_s, tmp_t))
		tmp_s = s
	
	tmp_t = t
stc_new.append((tmp_s, tmp_t))

now = [0]*(10**5+2)
for s, t in stc_new:
	now[s] += 1
	now[t+1] -= 1

now_acc = accumulate(now)
print(max(now_acc))
a,b,c=map(int,input().split())
print("YES" b-a==c-a else "NO")

### FIXED CODE ###

a,b,c=map(int,input().split())
print("YES" if b-a==c-b else "NO")
while True:
   print("Case 1: " + input())


### FIXED CODE ###

c = 1
while True:
   i = input()
   if i == "0":
      quit()
   print("Case {}: {}".format(c, i))
   c += 1
N, M = map(int, input().split())
res = True
A = [0]*N
B = ''
S = []
C = []
for m in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
T = max(S)
cnt = -1
man = False
for n in range(1, 1000):
    num = str(n)
    res = True
    for m in range(M):
        if len(num) != N:
            res = False
            continue
        if num[S[m]-1] != str(C[m]):
            res = False
    if res:
        cnt = int(num)
        man = True
        break
if man:
    print(cnt)
else:
    print(cnt)

### FIXED CODE ###

N, M = map(int, input().split())
S = []
C = []
for m in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
cnt = -1
man = False
for n in range(1000):
    num = str(n)
    res = True
    if len(num) != N:
        res = False
        continue
    for m in range(M):
        if num[S[m]-1] != str(C[m]):
            res = False
    if res:
        cnt = int(num)
        man = True
        break
if man:
    print(cnt)
else:
    print(cnt)
A, B = eval("int(input())" * 2)
if A > B:
	print("GREATER")
elif A < B:
	print("LESS")
else:
	print("EQUAL")


### FIXED CODE ###

A, B = eval("int(input())," * 2)
if A > B:
	print("GREATER")
elif A < B:
	print("LESS")
else:
	print("EQUAL")
count = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())

count = 0
for i in range(1, n + 1):
    if len(str(i)) % 2 == 1:
        count += 1
print(count)
n = input()
i = 0
while True:
  if i == n:
    break
  a[i] = input().split
  a[i] = a[n-i]
  print(a[i])


### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.reverse()
print(' '.join(map(str,l)))
n=int(raw_input())
t=map(int,raw_input().split())
total=sum(t)
m=int(raw_input())
for _ in xrange(m):
	p,x=map(int,raw_input())
	print sum-t[p-1]+x

### FIXED CODE ###

n=int(raw_input())
t=map(int,raw_input().split())
total=sum(t)
m=int(raw_input())
for _ in xrange(m):
	p,x=map(int,raw_input().split())
	print total-t[p-1]+x
n=input()
k=int(input())
l=len(n)

dp=[[[0 for _ in range(2)] for _ in range(5)] for _ in range(l+1)]

dp[0][1][1]=int(n[0]-1)
dp[0][1][0]=1
dp[0][0][1]=1

for i in range(1,l):
  for j in range(4):
    b=i-1
    now=n[i]
    if now==0:
      dp[i][j][0]+=dp[b][j][0]
    else:
      dp[i][j][1]+=dp[b][j][0]
      dp[i][j+1][1]+=dp[b][j][0]*(now-1)
      dp[i][j+1][0]+=dp[b][j][0]
print(dp[l-1][k][0]+dp[l-1][k][1])

### FIXED CODE ###

n=input()
k=int(input())
l=len(n)
dp=[[[0 for _ in range(2)] for _ in range(5)] for _ in range(l+1)]
dp[0][1][1]=int(n[0])-1
dp[0][1][0]=1
for i in range(1,l):
  for j in range(4):
    b=i-1
    now=int(n[i])
    if now==0:
      dp[i][j][0]+=dp[b][j][0]
    else:
      dp[i][j][1]+=dp[b][j][0]
      dp[i][j+1][1]+=dp[b][j][0]*(now-1)
      dp[i][j+1][0]+=dp[b][j][0]
    dp[i][j][1]+=dp[b][j][1]
    dp[i][j+1][1]+=dp[b][j][1]*9
  dp[i][1][1]+=9
print(dp[l-1][k][0]+dp[l-1][k][1])
N,M = map(int,input().split())
P=[map(int,input().split()) for _ in range(M)]
d = {}
for p,y in P:
  if p not in d:
    d[p]=[]
  d[p].append(y)
sd = {k:dict(zip(sorted(v),range(1,1+len(v))))
      for k,v in d.items()}
for p,y in P:
  print('%06d%06d' % (p, sd[p][y]))

### FIXED CODE ###

N,M = map(int,input().split())
P=[]
for _ in range(M):
  p,y = map(int,input().split())
  P.append((p,y))
d = {}
for p,y in P:
  if p not in d:
    d[p]=[]
  d[p].append(y)
sd = {k:dict(zip(sorted(v),range(1,1+len(v))))
      for k,v in d.items()}
for p,y in P:
  print('%06d%06d' % (p, sd[p][y]))
A, V = [int(i) for i in input().split()]
B, W = [int(i) for i in input().split()]

print('YES' if V > W and abs(A - B) <= T * (V - W) else 'NO')

### FIXED CODE ###

A, V = [int(i) for i in input().split()]
B, W = [int(i) for i in input().split()]
T = int(input())

print('YES' if V > W and abs(A - B) <= T * (V - W) else 'NO')
import sys
sys.setrecursionlimit(10 ** 7)

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for _ in range(n-1)]
px = [list(map(int,input().split()))for _ in range(q)]

graph = [[] for _ in range(n+3)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0]*(n+1)
for p,x in px:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if v == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)
print(*value[1:],end="\t")


### FIXED CODE ###

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

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)