Harryxun/stf_run huggingface dataset:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(M):
    count = c
    count += X[i]
    count -= T[P[i]]
    print(count)

### FIXED CODE ###

N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(M):
    count = c
    count += X[i]
    count -= T[P[i] - 1]
    print(count)
N = input()
for i in range(N):
  i = input()
print(len(set(i)))

### FIXED CODE ###

N = int(input())
list = [input() for i in range(N)]
print(len(set(list)))
all_cards = [[],[],[],[]]
for i in range(4):
	for j in range(13):
		all_cards[i].append(j+1)

n = int(raw_input())
for i in range(n):
	card = raw_input().split()
	if card[0] == "S":
		all_cards[0].remove(card[1])
	elif card[0] == "H":
		all_cards[1].remove(card[1])
	elif card[0] == "C":
		all_cards[2].remove(card[1])
	else:
		all_cards[3].remove(card[1])

for i in range(len(all_cards[0])):
	print("S {:}".format(all_cards[0][i]))
for i in range(len(all_cards[1])):
	print("H {:}".format(all_cards[1][i]))
for i in range(len(all_cards[2])):
	print("C {:}".format(all_cards[2][i]))
for i in range(len(all_cards[3])):
	print("D {:}".format(all_cards[3][i]))

### FIXED CODE ###

all_cards = [[],[],[],[]]
for i in range(4):
	for j in range(13):
		all_cards[i].append(j+1)

n = int(raw_input())
for i in range(n):
	card = raw_input().split(" ")
	#print card
	if card[0] == "S":
		all_cards[0].remove(int(card[1]))
	elif card[0] == "H":
		all_cards[1].remove(int(card[1]))
	elif card[0] == "C":
		all_cards[2].remove(int(card[1]))
	else:
		all_cards[3].remove(int(card[1]))

for i in range(len(all_cards[0])):
	print("S {:}".format(all_cards[0][i]))
for i in range(len(all_cards[1])):
	print("H {:}".format(all_cards[1][i]))
for i in range(len(all_cards[2])):
	print("C {:}".format(all_cards[2][i]))
for i in range(len(all_cards[3])):
	print("D {:}".format(all_cards[3][i]))
def dfs(a,adjl,visited,dp):
  for i in adjl[a]:
    if visited[i]==0:
      visited[i]=1
      dfs(i,adjl,visited,dp)
 
    dp[a]=max(dp[a],1+dp[i])
n,m=map(int,input().split())
li=[]
for i in range(m):
  li.append([int(k) for k in input().split()])
adjl=[[] for j in range(n+1)]
for k in range(len(li)):
  adjl[li[k][0]].append(li[k][1])
visited=[0]*(n+1)
dp=[0]*(n+1)
for a in range(1,n+1):
  if visited[a]==0:
    visited[a]=1
    dfs(a,adjl,visited,dp)
print(max(dp))

  
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
def dfs(a,adjl,visited,dp):
  for i in adjl[a]:
    if visited[i]==0:
      visited[i]=1
      dfs(i,adjl,visited,dp)
 
    dp[a]=max(dp[a],1+dp[i])
n,m=map(int,input().split())
li=[]
for i in range(m):
  li.append([int(k) for k in input().split()])
adjl=[[] for j in range(n+1)]
for k in range(len(li)):
  adjl[li[k][0]].append(li[k][1])
visited=[0]*(n+1)
dp=[0]*(n+1)
for a in range(1,n+1):
  if visited[a]==0:
    visited[a]=1
    dfs(a,adjl,visited,dp)
print(max(dp))
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
            if tmp != h:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)

### FIXED CODE ###

N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0)
            if tmp != l[k][2]:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

low=0
high=max(A)
X=max(A)
while low<=high:
  mid=(low+high)//2
  cnt = 0
  for i in range(N):
      cnt += A[i]//mid
  if K<cnt:
    low=mid+1
  else:
    X=mid
    high=mid-1
print(X)


### FIXED CODE ###

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

low=1
high=2*max(A)
X=max(A)
while low<=high:
  mid=(low+high)//2
  cnt = 0
  for i in range(N):
      if A[i]%mid==0:
          cnt += A[i]//mid-1
      else:
          cnt += A[i]//mid
  if K<cnt:
    low=mid+1
  else:
    X=min(X,mid)
    high=mid-1
print(X)
def judge(s):
    ok = True
    n = len(s)
    m = (n - 1) // 2
    if (m == 0):
        ok = (s[0] == s[1])
    else:
        for i in range(m):
            if s[i] != s[(n-1)-i]:
                ok = False
                break
    return ok

def strong_judge(s):
    ok = judge(s)
    n = len(s)
    m = (n - 1) // 2
    kf = (m - 1) // 2
    kb = m + kf + 1
    sf = s[0:m]
    sb = s[(m + 1):n]
    if ok:
        ok = judge(sf) and judge(sb)
    return ok

s = str(input())

if ((len(s) % 2 == 0) or (len(s) > 99) or (len(s) < 3)):
    print("No")
else:
    if strong_judge(s):
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

def judge(s):
    ok = True
    n = len(s)
    m = (n - 1) // 2
    if (n == 1):
        ok = True
    else:
        if (m == 0):
            ok = (s[0] == s[1])
        else:
            for i in range(m):
                if s[i] != s[(n-1)-i]:
                    ok = False
                    break
    return ok

def strong_judge(s):
    ok = judge(s)
    n = len(s)
    m = (n - 1) // 2
    kf = (m - 1) // 2
    kb = m + kf + 1
    sf = s[0:m]
    sb = s[(m + 1):n]
    if ok:
        ok = judge(sf) and judge(sb)
    return ok

s = str(input())

if ((len(s) % 2 == 0) or (len(s) > 99) or (len(s) < 3)):
    print("No")
else:
    if strong_judge(s):
        print("Yes")
    else:
        print("No")
N = int(input())
for i in range(N**0.5):
  if N%i == 0:
    print(i+N//i-2)

### FIXED CODE ###

N = int(input())
minstep = 9999999999999999999999999999999
for i in range(1, int(N**0.5+1)):
  if N%i == 0:
    minstep = min(minstep, i+N//i-2)
print(minstep)
import math
a, b = map(int, input().split())
print(a * b // math.gcd(a, b))

### FIXED CODE ###

a, b = map(int, input().split())
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
print(a * b // gcd(a, b))
n = int(input())
H = list(map(int, input().split()))
f = 0
if n ==1:
    print("Yes")
else:
    for i in range(1, n):
        if H[i+1] - H[i] < 0:
            H[i] -= 1
            if H[i-1] > H[i] or H[i+1] - H[i] < 0:
                f = 1
                break
    if f == 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n = int(input())
H = list(map(int, input().split()))
flag = 0

if n == 1:
    flag = 0
else:
    for i in range(n-1):
        idx = n-1-i
        if (H[idx-1] - H[idx]) == 1:
            H[idx-1] -= 1
        elif (H[idx-1] - H[idx]) > 1:
            flag = 1
            break

if flag == 0:
    print("Yes")
else:
    print("No")
s = 123456789
sum = 0
i = 0

while i < 9:
  sum = sum + s % 10
  s = s // 10
  i = i + 1

if s % sum = 0:
  print("yes")
else:
  print("no")


### FIXED CODE ###

s = raw_input()
print (s.count("+") - s.count("-"))
f = open('C:/Users/naoki/Desktop/Atcoder/input.txt')

def make_list(length, loop):
    result = [[] for _ in range(length)]
    for _ in range(loop):
        a, b = map(lambda x: int(x) - 1, f.readline().split())
        result[a].append(b)
        result[b].append(a)
    return result

def main():
    # 敢えてDFSで解いてみる．
    n, m, k = map(int, f.readline().split())
    friend = make_list(n, m)
    brock = make_list(n, k)
    answer = [0] * n
    group_index = [0] * n
    group_id = 1

    def dfs(index):
        q = [index]
        group_index[index] = group_id
        connection = 1
        while not q == []:
            now = q.pop()
            for f in friend[now]:
                if group_index[f] == 0:
                    connection += 1
                    group_index[f] = group_id
                    q.append(f)
        return connection

    id_and_elements = {}
    for i in range(n):
        if group_index[i] == 0:
            id_and_elements[group_id] = dfs(i)
            group_id += 1

    for i in range(n):
        answer[i] += id_and_elements[group_index[i]] - 1
        answer[i] -= len(friend[i])
        for b in brock[i]:
            if group_index[b] == group_index[i]:
                answer[i] -= 1
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li2=[input() for i in range(m)]
c = []
for i in range(m):
    c.append( [int(x.strip()) for x in li2[i].split()])

ans = min(a) + min (b)

for i in range(m):
    keep = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
    if keep < ans:
        ans = keep

print(ans)

### FIXED CODE ###

A,B,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
li2=[input() for i in range(m)]
c = []
for i in range(m):
    c.append( [int(x.strip()) for x in li2[i].split()])

ans = min(a) + min (b)

for i in range(m):
    keep = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
    if keep < ans:
        ans = keep

print(ans)
l,r=map(int,input().split())
ans=0
if l%2019>r%2019 or r-l>=2018:
    ans=0
else:
    if l%673>r%673 or r-l>=672:
        ans=0
    else:
        ll=l%2019
        rr=r%2019
        ans=min((rr*((r-1)%2019))%2019,(ll*((l+1)%2019)%2019)
print(ans)

### FIXED CODE ###

l,r=map(int,input().split())
ans=l*r%2019
for i in range(l,r):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
        if ans==0:
            break
    if ans==0:
        break
print(ans)
s =input()
t =input()

S = len(s)
T = len(t)
cnt=0
max=0

for i in range(T):
    for j in range(S-T):
        if s[i+j] == t[j]:
            cnt += 1
    else:
        if max<cnt:
            max=cnt
            cnt=0

print(T-max)


### FIXED CODE ###

s =input()
t =input()

S = len(s)
T = len(t)

cnt=0
max=0

for i in range(S-T+1):
    for j in range(T):
        if s[i+j] == t[j]:
            cnt += 1
    else:
        if max<cnt:
            max=cnt
            cnt=0
        else:
            cnt=0

print(T-max)
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
s=[sc[i][0] for i in range(M)]
c=[sc[i][1] for i in range(M)]
sc.sort()
if N==1:
    if 2 in s or 3 in s:
        ans=-1
    else:
        ans=sc[0][1]
if N==2:
    if 3 in s:
        ans=-1
    else:
        if sc[0][0]==1:
            for i in range(1,M):
                if sc[i][0]==2:
                    ans=sc[i][1]+sc[0][0]*10
            else:
                ans=sc[0][1]*10
if N==3:
    if sc[0][0]==1:
        for i in range(1,M):
            if sc[i][0]==2:
                for j in range(i,M):
                    if sc[j][0]==3:
                        ans=sc[0][1]*100+sc[i][1]*10+sc[j][1]
                else:
                    ans=sc[0][1]*100+sc[i][1]*10
        else:
            ans=sc[0][0]*100
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
s=[sc[i][0] for i in range(M)]
c=[sc[i][1] for i in range(M)]

for i in range(1000):
    if len(str(i)) == N:
        for j in range(M):
            if str(i)[s[j]-1] != str(c[j]):
                break
        else:
            print(i)
            break
else:
    print(-1)
import sys
if __name__ == "__main__":
    N,X = map(int, input().split())
    res = 2 * N - 1
    if (X != N - 1 and X != N and X != N + 1):
        print ("No")
        sys.exit()
    result = [0] * res
    left = X - 1
    result[N-1] = X
    right = X + 1
    left_idx = N - 2
    right_idx = N

    cnt = 0
    while (left > 0 and right < 2 * N):
        if (cnt % 2 == 0):
            result[left_idx] = left
            result[right_idx] = right
        else:
            result[left_idx] = right
            result[right_idx] = left

        left_idx -= 1
        left -= 1

        right_idx += 1
        right += 1

        cnt += 1
    if (left > 0):
        for x in range(left_idx, -1, -1):
            res[x] = left
            left -= 1
        for x in range(right_idx, 2 * N):
            res[x] = left
            left -= 1
    if (right < 2 * N):
        for x in range(left_idx, -1, -1):
            res[x] = right
            right += 1
        for x in range(right_idx, 2 * N):
            res[x] = right
            right += 1

    print ("Yes")
    for x in result:
        print (x)


### FIXED CODE ###


import sys
if __name__ == "__main__":

	N,X = map(int, input().split())
	res = 2 * N - 1
	if (X == 1 or X == 2 * N - 1):
		print ("No")
		sys.exit()
	result = [0] * res
	left = X - 1
	result[N-1] = X
	right = X + 1
	left_idx = N - 2
	right_idx = N

	cnt = 0
	while (left > 0 and right < 2 * N):
		if (cnt % 2 == 0):
			result[left_idx] = left
			result[right_idx] = right
		else:
			result[left_idx] = right
			result[right_idx] = left

		left_idx -= 1
		left -= 1

		right_idx += 1
		right += 1

		cnt += 1
	if (left > 0):
		for x in range(left_idx, -1, -1):
			result[x] = left
			left -= 1
		for x in range(right_idx, 2 * N-1):
			result[x] = left
			left -= 1
	if (right < 2 * N):
		for x in range(left_idx, -1, -1):
			result[x] = right
			right += 1
		for x in range(right_idx, 2 * N-1):
			result[x] = right
			right += 1

	print ("Yes")
	for x in result:
		print (x)
s = list(input().split("T"))
x, y = map(int, input().split())
s2 = [len(x) for x in s]
pos = [0, 0]
LR = [s2[i] for i in range(len(s2)) if i % 2 == 0]
UD = [s2[i] for i in range(len(s2)) if i % 2 == 1]

flag = False
tmp = 1
tmp = tmp << sum(LR)
for d in LR:
    tmp = tmp << d | tmp >> d

if x >= 0:
    tmp = tmp >> sum(LR)
    if (tmp >> x) % 2 == 1:
        flag = True
else:
    if (tmp >> (sum(LR) + x)) % 2 == 1:
        flag = True
if flag:
    tmp = 1
    tmp = tmp << sum(UD)
    flag = False
    for d in UD:
        tmp = tmp << d | tmp >> d
    if y >= 0:
        tmp = tmp >> sum(UD)
        if (tmp >> y) % 2 == 1:
            flag = True
    else:
        if tmp >> (sum(UD) + y) % 2 == 1:
            flag = True

if flag:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s = list(input().split("T"))
x, y = map(int, input().split())
s2 = [len(x) for x in s]
LR = [s2[i] for i in range(len(s2)) if i % 2 == 0]
UD = [s2[i] for i in range(len(s2)) if i % 2 == 1]

flag = False
tmp = 1
tmp = tmp << sum(LR)
for i, d in enumerate(LR):
    if i != 0:
        tmp = tmp << d | tmp >> d
    else:
        tmp = tmp << d

if x >= 0:
    tmp = tmp >> sum(LR)
    if (tmp >> x) % 2 == 1:
        flag = True
else:
    if sum(LR) + x >= 0:
        if (tmp >> (sum(LR) + x)) % 2 == 1:
            flag = True
if flag:

    tmp = 1
    tmp = tmp << sum(UD)
    flag = False
    for d in UD:
        tmp = tmp << d | tmp >> d
    if y >= 0:
        tmp = tmp >> sum(UD)
        if (tmp >> y) % 2 == 1:
            flag = True
    else:
        if sum(UD) + y >= 0:
            if (tmp >> (sum(UD) + y)) % 2 == 1:
                flag = True

if flag:
    print("Yes")
else:
    print("No")
from heapq import *
up=2*10**5
maxi=10**9+1
kind=[[] for i in range(up)]
kind_d=[[] for i in range(up)]

class segtree:
    x_unit=maxi # 要素として入れられる最大値
    x_func=min
    def __init__(self,n):
        self.n=n
        self.x=[self.x_unit]*(2*n)
    def build(self, seq):
        for i,j in enumerate(seq, start=self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func(self.x[i*2], self.x[i*2+1])
            # セグ木トーナメント表の左右を比較
            # 例えばn=8の時、seq[4]はx[12]に、seq[5]はx[13]に入っている
            # さらにx[14]とx[15]の間に来るのはx[7]、x[12]とx[13]の間に来るのはx[6]
            # x_funcに従って値を取得
    def set_val(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func(self.x[i*2], self.x[i*2+1])
    def fold(self,l,r): # 区間[l, r)の最小値などを取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func(val_l,self.x[l])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func(val_r,self.x[r])
            l //= 2
            r //= 2
        return self.x_func(val_l,val_r)

n,q=map(int, input().split())
shozoku=[-1]*n
rating=[0]*n
for i in range(n):
    a,b=map(int, input().split())
    heappush(kind[b-1],-a)
    shozoku[i]=b-1
    rating[i]=a
#print(kind)
seg=segtree(up)
root=[maxi for i in range(up)]

for i in range(up):
    if kind[i]:
        rate=-heappop(kind[i])
        root[i]=rate
        heappush(kind[i],-rate)
seg.build(root)

for i in range(q):
    c,d=map(int, input().split())
    c-=1
    d-=1
    rc=rating[c]
    sc=shozoku[c]
    if rc==seg.fold(sc,sc+1):
        while kind_d[sc]:
            q1=heappop(kind_d[sc])
            q2=heappop(kind[sc])
            if q1!=q2:
                heappush(kind_d[sc],q1)
                heappush(kind[sc],q2)
                break
        heappop(kind[sc])
        if kind[sc]:
            while kind[sc] and kind_d[sc]:
                q2=heappop(kind[sc])
                q1=heappop(kind_d[sc])
                if q1==q2:
                    continue
                else:
                    seg.set_val(sc, -q2)
                    heappush(kind[sc],q2)
                    heappush(kind_d[sc],q1)
                    break
        if not kind[sc]:
            seg.set_val(sc, maxi)
        else:
            q2=heappop(kind[sc])
            seg.set_val(sc, -q2)
            heappush(kind[sc],q2)
    else:
        heappush(kind_d[sc], -rc)
    heappush(kind[d],-rc)
    new=seg.fold(d,d+1)
    if rc>new or new==maxi:
        seg.set_val(d, rc)
    shozoku[c]=d
    print(seg.x[1])


### FIXED CODE ###

*x,=map(int, input().split())
for i in range(5):
    if x[i]==0:
        print(i+1)
        break
n=int(input())
x=list(map(int,input().split()))
p=round(sum(x)/n)
m=[]
for i in x:
  m.append((i-m)**2)
print(sum(m))

### FIXED CODE ###

n=int(input())
x=list(map(int,input().split()))
p=round(sum(x)/n)
m=[]
for i in x:
  m.append((i-p)**2)
print(sum(m))
S = input()

S2 = S.replace(7,8,1)

print(S2)

### FIXED CODE ###

s=input()
print("2018"+s[4:])
numA, numB, numCoupon = map(int, input().split(' '))
priceA = map(int, input().split(' '))
priceB = map(int, input().split(' '))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, coupon.split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)

### FIXED CODE ###

numA, numB, numCoupon = map(int, input().split(' '))
priceA = list(map(int, input().split(' ')))
priceB = list(map(int, input().split(' ')))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, input().split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

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

len_A = len(A)
ans = 0
for i in range(1, len_A-1):
  ans += A[len_A-1-int(i/2)]

print(ans)

### FIXED CODE ###

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

len_A = len(A)
ans = 0
for i in range(1, len_A):
  ans += A[len_A-1-int(i/2)]

print(ans)
t,h=0,0
int(input())
for i in range(n):
    a,b=input().split()
    if a > b:
        h+=3
    elif a < b:
        t+=3
    else:
         t+=1
         h+=1
print(t, h)

### FIXED CODE ###

t,h=0,0
n=int(input())
for i in range(n):
    a,b=input().split()
    if a > b:
        t+=3
    elif a < b:
        h+=3
    else:
         t+=1
         h+=1
print(t, h)
n = int(input())
a = int(input())
Max = -9999999
Min = a
for i in range(n):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)

### FIXED CODE ###

n = int(input())
a = int(input())
Max = -10 ** 9
Min = a
for i in range(n-1):
    x = int(input())
    if (Max < x - Min):
        Max = x - Min
    if (x < Min):
        Min = x
print(Max)
N, A = map(int, input().split())
# X = list(map(lambda x: int(x) - A, input().split()))
X = list(map(int, input().split()))

dp = [[[0 for _ in range(max(X) * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
    for j in range(N):
        for k in range(max(X) * N + 1):
            dp[i + 1][j][k] += dp[i][j][k]
            if k >= X[i]:
                dp[i + 1][j + 1][k] += dp[i][j][k - X[i]]

ans = 0
for j in range(1, N + 1):
    ans += dp[N][j][j * A]

print(ans)


### FIXED CODE ###

N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)

dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1

for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]

print(dp[N][N * maxn] - 1)