Harryxun/stf_run huggingface dataset:
import numpy as np
a=np.array([[0]*10]*12)
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[ 3*b-4+f, r-1 ] += v
for i in range(12):
    if i > 0 and i%3==0:
        print('#'*20)
    print(' '+' '.join(a[i,]))

### FIXED CODE ###

towers = [
    [[0 for i in range(10)] for j in range(3)] for k in range(4)
]
floor = 3
 
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    towers[b-1][f-1][r-1] += v
 
for b in towers:
    for f in b:
        for r in f:
            print(' ' + str(r), end='')
        print('')
    if floor:
        print('#'*20)
        floor -= 1
a, b=map(int,imput().split())
if a<b:
  print("a<b")
elif a>b:
  print("a>b")
elif a==b:
  print("a=b")
else:
  pass

### FIXED CODE ###

a, b=map(int,input().split())
if a<b:
 print("a < b")
elif a>b:
 print("a > b")
elif a==b:
 print("a == b")
else:
 pass
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

count = 0

max = A[-1]
import math
V = [0]*(math.floor(math.log(max, 2))+1)

for i in range (0, N):
	B = A[i]
	vount = 0
	while B > 0:
		if B%2 == 0:
			B = B//2
			vount+=1			
		else:
			B = (B-1)//2
			V[vount]+=1
			vount+=1

for i in range (0, len(V)):
	count+=((V[i]*(N-V[i]))*(2**i))

print(count%(10**9+7))

### FIXED CODE ###

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

count = 0

max = A[-1]
if max == 0:
	print(0)
	exit()

import math
V = [0]*(math.floor(math.log(max, 2))+1)

for i in range (0, N):
	B = A[i]
	vount = 0
	while B > 0:
		if B%2 == 0:
			B = B//2
			vount+=1			
		else:
			B = (B-1)//2
			V[vount]+=1
			vount+=1

for i in range (0, len(V)):
	count+=((V[i]*(N-V[i]))*(2**i))

print(count%(10**9+7))
#include <bits/stdc++.h>

using namespace std;

// ios::sync_with_stdio(0);
// cin.tie(0);

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int main() {
	int a;
	cin>>a;
	string res;

	while (a != 0) {
		int rem=a%26;
		a/=26;
		char asciiChar=rem+97-1;
		res+=asciiChar;
	}

	reverse(res.begin(),res.end());
	cout<<res;
}

### FIXED CODE ###

N = int(input())
ans = ""

while N > 0:
	N -= 1
	ans += chr(ord('a') + N % 26)
	N //= 26

print(ans[::-1])
a = int(input())
b = int(input())
if a % 2 == 0 or b % 2 == 0:
    print("even")
else
    print("odd")

### FIXED CODE ###

a, b = map(int,input().split())
if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a, b = int()
for i, x in enumerate(permutations(range(1, n + 1), n)):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))

### FIXED CODE ###

from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a, b = 0, 0
for i, x in enumerate(permutations(range(1, n + 1), n)):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))
from fractions import gcd
mod = 10**9+7
def lcm(x, y):
  return x//gcd(x, y)*y
n = int(input())
A = list(map(int, input().split()))
cnt = 0
m = lcm(A[0], A[1])
cnt += m//A[0] + m//A[1]
cnt %= mod
for i in range(2, n):
  t = lcm(m, A[i])
  cnt = cnt*(t//m) + t//A[i]
  m = t
  cnt %= mod
print(cnt)

### FIXED CODE ###

from fractions import gcd
mod = pow(10, 9)+7
n = int(input())
A = list(map(int, input().split()))
m = A[0]
for i in range(1, n):
  m = m // gcd(m, A[i]) * A[i]
ans = 0
for i in A:
  ans += m//i
print(ans%mod)
import sys
import functools
import math
if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    if len(X) == 1:
        print(abs(X[0]-NX[1]))
        sys.exit(0)
    X.append(NX[1])
    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = functools.reduce(math.gcd, diff)
    print(D)
    # D = min(diff)
    # while any(np.array(diff)%D):
    #     D -= 1
    # print(D)

### FIXED CODE ###

import sys
import functools
import fractions

if __name__ == '__main__':
    NX = [int(n) for n in input().split()]
    X = [int(n) for n in input().split()]
    if len(X) == 1:
        print(abs(X[0]-NX[1]))
        sys.exit(0)

    X.append(NX[1])
    X.sort()
    diff = [X[i] - X[i-1] for i in range(1, len(X))]
    D = functools.reduce(fractions.gcd, diff)
    print(D)
    # D = min(diff)
    # while any(np.array(diff)%D):
    #     D -= 1
    # print(D)
a = int.input()
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  if l[i]>M:
    M=l[i]
print(M-m)

### FIXED CODE ###

a = int(input())
l = list(map(int,input().split()))
m = l[0]
M = l[0]
for i in range(1,a):
  if l[i]<m:
    m = l[i]
  else:
    if l[i]>M:
      M = l[i]
    else:
      pass
print(M-m)
N = int(input())
A = list(map(int, input().split()))

# A内の整数値を用いて作られる最小の整数を求めよ、という問題


def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = gcd(A[0], A[1])
for i in range(1, N):
    ans = min(ans, gcd(A[i], A[j]))


print(ans)

### FIXED CODE ###

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

# A内の整数値を用いて作られる最小の整数を求めよ、という問題


def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = gcd(A[0], A[1])
for i in range(1, N):
    ans = min(ans, gcd(ans, A[i]))


print(ans)
def lam(x,mod):
  ans=1
  for i in range(1,x+1):
    ans*=i
    ans%=mod
  return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
  print(0)
  exit()
if n+1==m:
  print(lam(n,mod)*lam(m,mod)%mod)
else:
  print(2*(lam(n,mod)**2)


### FIXED CODE ###

def lam(x,mo):
	ans=1
	for i in range(1,x+1):
		ans*=i
		ans%=mo
	return ans
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
mod=10**9+7
if n<m-1:
	print(0)
	exit()
if n+1==m:
	print(lam(n,mod)*lam(m,mod)%mod)
else:
	print(2*(lam(n,mod)**2)%mod)
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if abs(max(a))>=abs(min(a)):
     b=a.index(max(a))
    for i in range(n):
        print(b+1,i)
    for j in range(n-1):
        print(j+1,j+2)
    
else:
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1,0,-1):
        print(j+1,j)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if abs(max(a))>=abs(min(a)):
    b=a.index(max(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1):
        print(j+1,j+2)
    
else:
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1,0,-1):
        print(j+1,j)
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n
for i in range(m):
    print(ans)
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        ans[b-1] = 0
    else if h[b-1]>h[a-1]:
        ans[a-1] = 0
    else:
        print("a")
        ans[a-1] = 0
        ans[b-1] = 0
print(ans.count(1))    

### FIXED CODE ###

n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1]>h[b-1]:
        ans[b-1] = 0
    elif h[b-1]>h[a-1]:
        ans[a-1] = 0
    else:
        #print("a")
        ans[a-1] = 0
        ans[b-1] = 0
print(ans.count(1))
n,m = map(int,input().split())
digit = [0]*(m+1)
value = [0]*(m+1)
for i in range(1,m+1):
    digit[i],value[i] = map(int,input().split())

if m==0:
    print('-1')
    exit()
res = 0
for i in range(1,n+1):
    if i in digit:
        idx = digit.index(i)
        res += value[idx] * 10**(n-i)

for i in range(1,m+1):
    if int(str(res)[digit[i]-1]) != value[i]:
        print('-1')
        exit()
print(res if len(str(res))==n else '-1')

### FIXED CODE ###

n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')
N,T = map(int,input().split())
c = []
t = []
hoge = []
hogehoge = []

for i in range(N):
  a,b = map(int,input().split())
  c.append(a)
  t.append(b)

for i in range(N):
  if t[i] < T:
    hoge.append(c[i])
print(min(hoge))


### FIXED CODE ###

N,T = map(int,input().split())
c = []
t = []
hoge = []

for i in range(N):
  a,b = map(int,input().split())
  c.append(a)
  t.append(b)

for i in range(N):
  if t[i] <= T:
    hoge.append(c[i])
if hoge != []:
  print(min(hoge))
else:
  print("TLE")
s = input()
if s.replace('hi','') == '':
    print('Yes')
else
    print('No')

### FIXED CODE ###

s = input()
if s.replace('hi','') == '':
    print('Yes')
else:
    print('No')
def main():
  size = int(input())
  for i in range(size):
    array[i] = list(map(int, input().split())
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0]- pre_time
    distance = array[i][1]-pos[0] + array[i][2]-pos[1]
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = time
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

### FIXED CODE ###

def main():
  size = int(input())
  array = []
  for i in range(size):
    array.append(list(map(int, input().split())))
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = array[i][0]
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()
#整数Nを得る
N, K = map(int,input().split())
mod = 10**9 +7

for i in range(1,K+1):
    Ans = 1
    a = N - K + 1
    for j in range(1, i +1):
        Ans = Ans * a / j
        a = a-1
    c = 1
    for j in range(1,i):

        c = c * (K - j)/j
    Ans = int(Ans * c % mod)
    print(Ans)


### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N, K = map(int, input().split())
R = N-K

for i in range(1, K+1):
    if i > R+1:
        print(0)
    else:
        ans = cmb(R+1, i, mod) * cmb(K-1, i-1, mod) % mod
        print(ans)
def createPlural(s):
    if s[-1] == "s":
        return s[:-1] + "es"
    else:
        return s + "s"

s = input()
s_plural = cratePlural
print(s_plural)

### FIXED CODE ###

def createPlural(s):
    if s[-1] == "s":
        return s + "es"
    else:
        return s + "s"

s = input()
s_plural = createPlural(s)
print(s_plural)
k = int(input())

count = [pow(k // max(i, 1), 3, mod) for i in range(k + 1)]

for i in range(k, 0, -1):
  for j in range(2 * i, k + 1, i):
    count[i] -= count[j]

sum_ = 0
for i in range(k + 1):
  sum_ += i * count[i]

print(sum_)

### FIXED CODE ###

from math import gcd

k = int(input())
sum_ = 0
for a in range(1, k + 1):
  for b in range(1, k + 1):
    gcd_ab = gcd(a, b)
    for c in range(1, k + 1):
      sum_ += gcd(c, gcd_ab)
print(sum_)
import functools
import math

N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
numbers = [abs(i - X) for i in x]

gcd = functools.reduce(math.gcd, numbers)
print(gcd)


### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
numbers = [abs(i - X) for i in x]

answer = numbers[0]
for i in numbers:
  answer = gcd(answer, i)
print(answer)
n = int(input())
assert n & 1

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = list(map(int,input().split()))

    if n & 1 == 0:
        res = -INF
        score = sum(A[::2])
        res = max(res, score)
        for i in range(n-1,-1,-1):
            if i & 1:
                score += A[i]
            else:
                score -= A[i]
                res = max(res, score)
        print(res)
        return

    front_dp = [None] * n
    choose = -INF
    not_choose = 0
    for i in range(1, n, 2):
        choose, not_choose = max(choose, not_choose) + A[i], not_choose + A[i-1]
        front_dp[i] = max(choose, not_choose)

    back_dp = [None] * n
    choose = -INF
    not_choose = 0
    for i in range(n-2, -1, -2):
        choose, not_choose = max(choose, not_choose) + A[i], not_choose + A[i+1]
        back_dp[i] = max(choose, not_choose)

    res = -INF
    for i in range(1, n, 2):
        if i + 2 < n:
            res = max(res, front_dp[i] + back_dp[i+2])

    res = max(res, front_dp[-2])
    res = max(res, back_dp[1])

    print(res)
resolve()
a,b = raw_input().split("\n")
print int(a)*int(b)

### FIXED CODE ###

a,b = raw_input().strip().split(" ")
print int(a)*int(b),(int(a)+int(b))*2
a､b= map(int,input().split())
apple_pie = (a*3 + b) //2
print(apple_pie)

### FIXED CODE ###

a,b = map(int,input().split())
apple_pie = (a*3 + b) //2
print(apple_pie)
from collections import deque
n,m,k = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))
a,b = A.popleft(), B.popleft()
ans = 0
ok = False
while k > 0:
    if ok: break
    if a < b and k-a >= 0:
        k -= a
        ans += 1
        if A: a = A.popleft()
        else: a = float("INF")
    elif a > b and k-b >= 0:
        k -= b
        ans += 1
        if B: b = B.popleft()
        else: b = float("INF")
    elif a == b:
        for i in range(min(len(A), len(B))):
            if A[i] == B[i]:
                if k-A[i] >=0: 
                    k-= A[i]
                    ans += 1
                else: 
                    ok = True
            elif A[i] < B[i] and k-A[i] >= 0:
                k -= A[i]
                ans += 1
                A = deque(list(A)[i+1:])
            elif A[i] > B[i] and k-B[i]>=0:
                k -= B[i]
                ans += 1
                B = deque(list(B)[i+1:])
            else: ok = True
    else: break
print(ans)

### FIXED CODE ###

import numpy
import bisect
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]+list(numpy.cumsum(A))
b = [0]+list(numpy.cumsum(B))
ans = 0
# print(a,b)
for i in range(len(a)):
    x = k - a[i]
    if x >= 0:
        j = bisect.bisect_right(b,x)-1
        ans = max(ans, i+j)
print(ans)
n, d = map(int(input()))
cnt = 0
while(n>0):
    p,q = map(int(input()))
    if d == int((p**2)+(q**2)):
        cnt++
print(cnt)

### FIXED CODE ###

n,d = map(int, input().split())
ans = 0
for i in range(n):
  x, y = map(int, input().split()) 
  if x*x + y*y <= d*d: # since they have given atmost distance d
    ans+= 1
print(ans)
'''
using distance formula check whether the the distance 
from origin is less than x sq and y sq
'''
h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = []
    for i in range(0,2):
        if w == 2 and i == 0:
            break
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            break
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))

### FIXED CODE ###

h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = [h,w]
    for i in range(0,2):
        if w == 2 and i == 0:
            continue
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        #print([a,b,c])
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            continue
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        #print([a,b,c])
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))
a,b,c=[int(i) for i in input().split()]
print(["No" "Yes"][a<=c and c<=b])

### FIXED CODE ###

a,b,c=[int(i) for i in input().split()]
print(["No","Yes"][a<=c and c<=b])
from collections import deque

def f(x):
    if x == 1:
        return 1
    else:
        return 2 * f(H // 2) + 1   

H = int(input())

    min = f(H)

print(min)

### FIXED CODE ###

def f(x):
    if x == 1:
        return 1
    else:
        return 2 * f(x // 2) + 1   

H = int(input())

min = f(H)

print(min)
if __name__== '__main__':
  s = input('>>')
  for i in range(2):
     if s[i] == 'A':
        print('Yes')
     elif s[i] == 'B':
      	print('Yes')
      else:
        print('No')
      

### FIXED CODE ###

if __name__== '__main__':
  s = input()
  if s[0] == 'A' and s[1] == 'A' and s[2] == 'A':
        	print('No')
  elif s[0] == 'B' and s[1] == 'B' and s[2] == 'B':
      		print('No')
  else:
        	print('Yes')
s = list(input())
for i in range(2**3):
    f = (s[0])
    for j in range(3):
        if (i>>j)&1:
            f = f "+"
        else:
            f = f + "-"
        f = f + s[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()

### FIXED CODE ###

s = list(input())
ans = 0
for i in range(2**(3)):
    f = (s[0])
    for j in range(3):
        if i&(1<<j):
            f = f+"+"
        else:
            f = f+"-"
        f = f+s[j+1]
    if eval(f)==7:
        print(f+"=7")
        exit()
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
import heapq
#https://atcoder.jp/contests/abc148/tasks/abc148_f
#F - Playing Tag on Tree
"""
"""
N = gi()
u = gi()
v = gi()
t = [[] for i in range(N + 1)]
d = [[0 for i in range(2)] for j in range(N + 1)]

for _ in range(1, N):
    a = gi()
    b = gi()
    t[a].append(b)
    t[b].append(a)

ls = []


def dfs(i, p, di):

    if len(t[i]) == 1:
        ls.append(i)
    for nei in t[i]:
        if nei == p:
            continue
        d[nei][di] = d[i][di] + 1
        dfs(nei, i, di)


d[u][0] = 0
dfs(u, -1, 0)
d[v][1] = 0
dfs(v, -1, 1)

ans = 0
for l in ls:
    du = d[l][0]
    dv = d[l][1]
    if dv >= du:
        ans = max(ans, dv - 1)

print(ans)


### FIXED CODE ###

from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
import heapq
#https://atcoder.jp/contests/abc148/tasks/abc148_f
#F - Playing Tag on Tree
"""
"""
N = gi()
U = gi()
V = gi()
t = [[] for i in range(N + 1)]
d = [[-1 for i in range(2)] for j in range(N + 1)]

for _ in range(1, N):
    a = gi()
    b = gi()
    t[a].append(b)
    t[b].append(a)


def bfs(s, di):
    d[s][di] = 0
    q = deque()
    q.append(s)
    while len(q):
        v = q.pop()
        for u in t[v]:
            if d[u][di] >= 0:
                continue
            d[u][di] = d[v][di] + 1
            q.append(u)


bfs(U, 0)
bfs(V, 1)

ans = 0
for l in range(1, N + 1):
    if len(t[l]) > 1:
        continue
    du = d[l][0]
    dv = d[l][1]
    #print(l, du, dv)
    if dv >= du:
        ans = max(ans, dv - 1)

print(ans)
N = int(input())
As = list(map(int,input().split()))
Q = int(input())

count_array = [0]*(10**5)
for i in range(N):
    count_array[As[i]] += 1

sum = 0
for i in range(len(As)):
    sum += As[i]

for i in range(Q):
    x,y = map(int,input().split())
    sum += count_array[x]*(y-x)
    print(sum)
    count_array[y] += count_array[x]
    count_array[x] = 0


### FIXED CODE ###

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

count_array = [0]*(10**5+1)
for i in range(N):
    count_array[As[i]] += 1

sum = 0
for i in range(len(As)):
    sum += As[i]

for i in range(Q):
    x,y = map(int,input().split())
    sum += count_array[x]*(y-x)
    print(sum)
    count_array[y] += count_array[x]
    count_array[x] = 0
n = int(input())
t = list(map(int,input().split()))
m = int(input())
s = sum(t)

for i in range(m):
  p,x = map(int,input().split())
  print(s-t[p+1]+x)

### FIXED CODE ###

n = input()
t = list(map(int,input().split()))
m = int(input())
s = sum(t)

for i in range(m):
  p,x = map(int,input().split())
  print(s-t[p-1]+x)
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

S.sort（）
str1=''
str1.append(S[i] for i in range (H))
print(str1)

### FIXED CODE ###

H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

S.sort()
str1=''
for i in range (H):
    str1=str1+S[i] 
print(str1)
a,b = (int(x) for x in input().split())
c = (a - b)
if c > ('-1'):
    print(c)
elif c < ('-1'):
    print('0')

### FIXED CODE ###

X, t = map(int, input().split())
x = X - t
 
if x > 0:
    print(x)
else:
    print(0)
ar = input()

k = int(input())

l = len(ar)


DP = [[[-1] * 2 for j in range(5)] for i in range(102)]


def dp(i, j, fl):
    if i == l:
        if j == k:
            return 1
        else:
            return 0

    if DP[i][j][fl] != -1:
        return DP[i][j][fl]

    res = 0

   # print(i,j,fl)
    if fl:
        for p in range(10):

            res += dp(i+1, j + (p != 0) , fl == 1)
    else:
        ko = ord(ar[i]) - ord('0')
        for p in range(ko + 1):

            res += dp(i + 1, j + (p != 0), p < ko)
    DP[i][j][fl] = res
    return res

print(dp(0, 0, 0))


### FIXED CODE ###



ar = input()

k = int(input())

l = len(ar)


DP = [[[-1] * 2 for j in range(103)] for i in range(102)]


def dp(i, j, fl):
    if i == l:
        if j == k:
            return 1
        else:
            return 0

    if DP[i][j][fl] != -1:
        return DP[i][j][fl]

    res = 0

   # print(i,j,fl)
    if fl:
        for p in range(10):

            res += dp(i+1, j + (p != 0) , fl == 1)
    else:
        ko = ord(ar[i]) - ord('0')
        for p in range(ko + 1):

            res += dp(i + 1, j + (p != 0), p < ko)
    DP[i][j][fl] = res
    return res

print(dp(0, 0, 0))
A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[]
wari=[]
warik=0
ans=0
for i in range(M):
    c+=list(map(int, input().split()))
for i in range(M):
    wari.append(a[c[i*3]]+b[c[(2*i+1)]]-c[2*i+2])
warik=min(wari)
ans=min(a)+min(b)
if ans>warik:
    print(warik)
else:
    print(ans)

### FIXED CODE ###

A,B,M=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[]
wari=[]
warik=0
ans=0
for i in range(M):
    c+=list(map(int, input().split()))
for i in range(M):
    wari.append(a[c[i*3]-1]+b[c[2*i+(i+1)]-1]-c[2+3*i])    
warik=min(wari)
ans=min(a)+min(b)
if ans<warik:
    print(ans)
else:
    print(warik)
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
G = [[int(i in (j,(j+1)%N)) for i in range(N)] for j in range(N)]
kakudai = np.array(G)
X=np.linalg.solve(G,A)
print(*[int(x*2) for x in X])


### FIXED CODE ###

N=int(input())
A = [int(i) for i in input().split()]
Rzero = sum(A)
#雨[0]を求める
for i in range(1,N,2):
    Rzero -= A[i]*2
Rain = [0]*N
Rain[0] = Rzero
for i in range(1,N):
    Rain[i] = (2*A[i-1] - Rain[i-1])
print(*Rain)