Harryxun/stf_run huggingface dataset:
from collections import defaultdict

n = int(input())
v = list(map(int, input().split(' ')))

odd = defaultdict(int)
even = defaultdict(int)
al = defaultdict(int)

for i in range(len(v)):
  al[v[i]] += 1
  if(i % 2 == 0): # even
    even[v[i]] += 1
  else: # odd
    odd[v[i]] += 1

if(len(al) == 1):
  print(int(n / 2))
  exit()

even_sorted = sorted(even.items(), key=lambda x: x[1], reverse=True)
odd_sorted = sorted(odd.items(), key=lambda x: x[1], reverse=True)

#print(even_sorted)
#print(odd_sorted)

if(len(even_sorted) == 1): # what if either of them had only one uniq num..
  if(odd_sorted[0][0] == even_sorted[0][0]):
    print(n - odd_sorted[1][1]  - even_sorted[0][1])
  else:
    print(n - odd_sorted[0][1] - even_sorted[0][1])
elif(len(odd_sorted) == 1):
  if(odd_sorted[0][0] == even_sorted[0][0]):
    print(n - even_sorted[1][1] - odd_sorted[0][1])
  else:
    print(n - odd_sorted[1][1] - even_sorted[0][1])


else: # both of them have more than 1 uniq num..
  if(odd_sorted[0][0] == even_sorted[0][0]):
    if(odd_sorted[0][1] < even_sorted[0][1]): # odd to be changed (even stays)
      print(n - odd_sorted[1][1] - even_sorted[0][1])
    else:
      print(n - odd_sorted[0][1] - even_sorted[1][1])
  else: # both has more than 1 uniq num, and most freq values aren't the same
    print(n - odd_sorted[0][1] - even_sorted[0][1])



### FIXED CODE ###

from collections import defaultdict

n = int(input())
v = list(map(int, input().split(' ')))

odd = defaultdict(int)
even = defaultdict(int)
al = defaultdict(int)

for i in range(len(v)):
  al[v[i]] += 1
  if(i % 2 == 0): # even
    even[v[i]] += 1
  else: # odd
    odd[v[i]] += 1

if(len(al) == 1):
  print(n // 2)
  exit()

even_sorted = sorted(even.items(), key=lambda x: x[1], reverse=True)
odd_sorted = sorted(odd.items(), key=lambda x: x[1], reverse=True)

#print(even_sorted[0:4])
#print(odd_sorted[0:4])


if(len(even_sorted) == 1): # what if either of them had only one uniq num..
  if(odd_sorted[0][0] == even_sorted[0][0]):
    print(n - odd_sorted[1][1]  - even_sorted[0][1])
  else:
    print(n - odd_sorted[0][1] - even_sorted[0][1])
elif(len(odd_sorted) == 1):
  if(odd_sorted[0][0] == even_sorted[0][0]):
    print(n - even_sorted[1][1] - odd_sorted[0][1])
  else:
    print(n - odd_sorted[0][1] - even_sorted[0][1])


else: # both of them have more than 1 uniq num..
  if(odd_sorted[0][0] == even_sorted[0][0]):
    if(odd_sorted[0][1] == even_sorted[0][1]):
      if(odd_sorted[1][1] < even_sorted[1][1]):
        print(n - odd_sorted[0][1] - even_sorted[1][1])
      else:
        print(n - odd_sorted[1][1] - even_sorted[0][1])
    elif(odd_sorted[0][1] < even_sorted[0][1]): # odd to be changed (even stays)
      print(n - odd_sorted[1][1] - even_sorted[0][1])
    else:
      print(n - odd_sorted[0][1] - even_sorted[1][1])
  else: # both has more than 1 uniq num, and most freq values aren't the same
    print(n - odd_sorted[0][1] - even_sorted[0][1])
def test():
	mod = 10**9 + 7
	n, m = map(int, input().split())
	if abs(n-m) > 1:
		print(0)
		exit()
	i_n = n
	i_m = m
	np = 1
	mp = 1
	while True:
		np = (np%mod) * (i_n%mod)
		mp = (mp%mod) * (i_m%mod)
		i_n -= 1
		i_m -= 1
		if i_n < 1:
			i_n = 1
		if i_m < 1:
			i_m = 1
		if i_n == 1 and i_m == 1:
			break
	s = 2 if n == m else 1
	r = (mp*np*s) % (10**9 + 7)
	print(r)
test()

### FIXED CODE ###

x, a, b = map(int, input().split())
e = b - a
r = 'safe'
if e > x:
	r = 'dangerous'
elif e < 1:
	r = 'delicious'
print(r)
a,b,m=map(int,input().split())
price_A=list(map(int,input().split()))
price_B=list(map(int,input().split()))
coupon=[]
for _ in range(m):
  coupon.append(list(map(int,input().split())))
ans=min(price_A)+min(price_B[0])
for i in range(m):
  deprice=price_A[coupon[i][0]-1]+price_B[coupon[i][1]-1]-coupon[i][2]
  if deprice < ans:
    ans = deprice
print(ans)


### FIXED CODE ###

a,b,m=map(int,input().split())
price_A=list(map(int,input().split()))
price_B=list(map(int,input().split()))
coupon=[]
for _ in range(m):
  coupon.append(list(map(int,input().split())))
ans=min(price_A)+min(price_B)
for i in range(m):
  deprice=price_A[coupon[i][0]-1]+price_B[coupon[i][1]-1]-coupon[i][2]
  if deprice < ans:
    ans = deprice
print(ans)
a,b,c= map(int,input().split())
if a+b>=c && a<=c :
    print("Yes")
else :
    print("No")

### FIXED CODE ###

a,b,c= map(int,input().split())
if a+b>=c and a<=c :
    print("YES")
else :
    print("NO")
import sys
lines = sys.stdin.readlines()

S = str(lines[0])
X = []
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)

X.sort()
flag =1
n = 0
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += flag*(flag-1)//2
    flag = 1
 
print(n)
    



### FIXED CODE ###

S = str(input())

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
n += int(flag*(flag-1)/2)
if X[len(X)-1]==0:
  n +=1
print(n)
A. B, C = input().split()
B = [b for b in B]
print("A{}C".format(B[0]))

### FIXED CODE ###

A, B, C = input().split()
print("A{}C".format(B[0]))
input_str = raw_input()

translate_num = (int("input_str"))**2

print("translate_num\n")

### FIXED CODE ###

input_str = input()

translate_num = (int(input_str))**3

print(translate_num)
# -*- coding: utf-8 -*-
n,y = map(int,input().split())
for i in xrange(n+1):
    for j in xrange(n-i+1):
        k = n-i-j
        if y == 10000*i + 5000*j + 1000*(k):
            print('{0} {1} {2}'.format(i,j,k))
            exit()
print('-1 -1 -1')

### FIXED CODE ###

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

year, mon, day = input().split('/')
if year != 2018:
    year = 2018
print('{0}/{1}/{2}'.format(year,mon,day))
if __name__ == "__main__":
    times = [int(time) for time in input().split()]
    print((A+B)%24)

### FIXED CODE ###

if __name__ == "__main__":
    times = [int(time) for time in input().split()]
    A = times[0]
    B = times[1]
    print((A+B)%24)
import bisect
N = int(input())
L = [int(i) for i in input().split()]

SL = sorted(L)
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        right = bisect.bisect_left(SL, SL[i] + SL[j])
        left = j + 1
        ans += max(right - left)

print(ans)


### FIXED CODE ###

import bisect
N = int(input())
L = [int(i) for i in input().split()]

SL = sorted(L)
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        right = bisect.bisect_left(SL, SL[i] + SL[j])
        left = j + 1
        ans += right - left

print(ans)
N, K = map(int, input().split())
X = list(map(int, input().split()))

if N == 1:
    print(abs(X[0]))
    exit()


flg = False

for x in X:
    if x < 0:
        flg = True

if flg is False:
    print(X[K - 1])
    exit()


def sol(lft, rgt):
    if X[lft] < 0 and X[rgt] < 0:
        return float('inf')
    elif X[lft] <= 0:
        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt])
    else:
        return float('inf')


lft, rgt = 0, 0
ans = float('inf')
while True:

    if rgt == N:
        break

    if rgt - lft + 1 < K:
        rgt += 1
        if rgt - lft + 1 == K:
            ans = min(ans, sol(lft, rgt))
            lft += 1
print(ans)


### FIXED CODE ###

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

if N == 1:
    print(abs(X[0]))
    exit()


flg = False

for x in X:
    if x < 0:
        flg = True

if flg is False:
    print(X[K - 1])
    exit()

flag2 = False

for x in X:
    if x > 0:
        flag2 = True

if flag2 is False:
    X.reverse()
    print(abs(X[K - 1]))
    exit()


def sol(lft, rgt):
    if X[lft] < 0 and X[rgt] < 0:
        return float('inf')
    elif X[lft] <= 0:
        return min(2 * abs(X[lft]) + X[rgt], abs(X[lft]) + 2 * X[rgt])
    else:
        return float('inf')


lft, rgt = 0, 0
ans = float('inf')
while True:

    if rgt == N - 1:
        break

    if rgt - lft + 1 < K:
        rgt += 1
        if rgt - lft + 1 == K:
            ans = min(ans, sol(lft, rgt))
            lft += 1
print(ans)
a = int(inpur())
s = input()

if a < 3200:
    print('red')
else :
    print(s)

### FIXED CODE ###

a = int(input())
s = input()

if a < 3200:
    print('red')
else :
    print(s)
import math
N=range(int(raw_input()))
for i in N:
    a,w,b,x,c,y,d,z=map(float, raw_input().split())
    print ["NO","YES"][(w-x)*(c-d)=(y-z)*(a-b)]

### FIXED CODE ###

import math
for i in range(int(raw_input())):
    a,w,b,x,c,y,d,z=map(float, raw_input().split())
    print ["NO","YES"][abs((w-x)*(c-d)-(y-z)*(a-b))<1e-10]
# -*- coding: utf-8 -*-

from random import choices

n, m, d = map(int, input().split())
if n > 10**3*5 or m > 10**3*5:
    _max = max(n, m)
    n = max(1, int(n // (_max/10**3*5)))
    m = max(2, int(m // (_max/10**3*5)))
    d = int(d // (_max/10**3*5))

_sum = 0
for i in range(10**3*5):
    A = choices(list(range(1, n+1)), k=m)
    # print(A)
    for j in range(m-1):
        if abs(A[j] - A[j+1]) == d:
            _sum += 1

print(_sum/(10**3*5))


### FIXED CODE ###

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

n, m, d = map(int, input().split())
if d == 0:
    print(((n-d)/(n**2))*(m-1))
else:
    print((2*(n-d)/(n**2))*(m-1))
n = int(input())
x = input()

def f(n):
    t = int(n,2) % list(n).count('1')
    if t == 0:
        return 1
    else:
        return f(str(bin(t))) + 1

for i in range(n):
    xb = list(x)
    xb[i] = '0' if xb[i] == '1' else '1'
    print(f(''.join(xb)))

### FIXED CODE ###

n = int(input())
X = input()
x = int(X,2)
bitx = bin(x).count('1')
 
ans = [0]*(bitx+2)
for i in range(1,bitx+2):
    ans[i] = 1 + ans[i%bin(i).count('1')]
#print(ans)
l = []
bitp = bitx + 1
bitm = bitx - 1
xmp = 0
xmm = 0


if bitx != 1:
    for i in range(n):
        if X[i] == '1':
            xmp += pow(2, n-(i+1), bitp)
            xmm += pow(2, n-(i+1), bitm)
    for i in range(n):
        if X[i] == '1':
            xm = (xmm - pow(2,n-i-1,bitm)) % bitm
            l.append(str(1+ans[xm]))
        else:
            xm = (xmp + pow(2,n-i-1,bitp))%bitp
            l.append(str(1+ans[xm]))
 
else:
    for i in range(n):
        if X[i] == '1':
            xmp += pow(2, n-(i+1), bitp)
    for i in range(n):
        if X[i] == '1':
            l.append(str(0))
        else:
            xm = (xmp + pow(2,n-i-1,bitp))%bitp
            l.append(str(1+ans[xm]))
 
print('\n'.join(l))
n, m = map(int, input().split())
a = list(map(int, input().split()))

all_sum = sum(a)
standard = all_sum/(4*M)
ans = 0

for i in a:
  if i >= standard:
    ans += 1

if ans >= m:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

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

all_sum = sum(a)
standard = all_sum/(4*m)
ans = 0

for i in a:
  if i >= standard:
    ans += 1

if ans >= m:
  print('Yes')
else:
  print('No')
from collections import Counter
n = int(input())
s, t = [], []
for _ in range(n):
    s.append(input())
m = int(input())
for _ in range(n):
    t.append(input())
u = Counter(s) - Counter(t)
ans = u.most_common(1)[0][1]
print(ans)


### FIXED CODE ###

from collections import Counter, defaultdict
n = int(input())
s= []
t = defaultdict(int)
for _ in range(n):
    s.append(input())
u = Counter(s)
m = int(input())
for _ in range(m):
    word = input()
    t[word] -= 1
    if word in u.keys():
        u[word] -= 1

ans = u.most_common(1)[0][1]
t = sorted(t.items(), key=lambda x:x[1], reverse=True)[0][1]
t = max(t, 0)
print(max(ans,t))
A = input()
B = input()
print(6 - A - B)

### FIXED CODE ###

A = int(input())
B = int(input())
print(6 - A - B)
z = int().split()
a=z[0]
b=z[1]
c=z[2]
count=0
for i in range(a,b+1) :
    if c%i == 0:
        count += 1
print(count)

### FIXED CODE ###

a,b,c=map(int,input().split())
d=[i for i in range(a,b+1)]
count=0
for i in d:
    if c%i==0:
        count+=1
print(count)
nums =input().split()
a = int(nums[0])
b = int(nums[1])
if a < b:
     print('a < b')
elif a > b:
     print('a > b')
eles:
     print('a == b')

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
if a < b:
     print('a < b')
elif a > b:
     print('a > b')
else:
     print('a == b')
def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("$" * (2 + h)))
	for i in range(0, w) : array.append(list("$" + raw_input().replace(" ", "") + "$"))
	array.append(list("$" * (2 + h)))
	
	count = 0
	for i in range(1, h + 1):
		for j in range(1, w + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("0" * (2 + h)))
	for i in range(0, w) : array.append(list("0" + raw_input().replace(" ", "") + "0"))
	array.append(list("0" * (2 + h)))
	
	count = 0
	for i in range(1, w + 1):
		for j in range(1, h + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count
k=int(input())
s=input()
if len(s)>k:
    print(s[:k]+"...")
else:
    print(s[:k])

### FIXED CODE ###

n=input()
if n[-1]=="3":
    print("bon")
elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8":
    print("pon")
else:
    print("hon")
a,b,c = sorted(int, input().split())
print(int(a*b/2))

### FIXED CODE ###

a,b,c = sorted(map(int, input().split()))
print(int(a*b/2))
x = int(input())
y = int(input())
z = int(input())

print(z, x, y)

### FIXED CODE ###

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

print(z, x, y)
import numpy as np

def knapsackGreedy(sizes, vals, volume):
    ids = np.argsort([val / size for val, size in zip(vals, sizes)])

    sumVal = 0
    for i in ids:
        if sizes[i] <= volume:
            volume -= sizes[i]
            sumVal += vals[i]
        if volume <= 0:
            break

    return sumVal


if __name__ == "__main__":
    n, volume = [int(x) for x in input().split()]
    sizes, vals = [], []
    for _ in range(n):
        s, v = [int(x) for x in input().split()]
        sizes.append(s)
        vals.append(v)
    print(knapsackGreedy(sizes, vals, volume))


### FIXED CODE ###

def knapsack(sizes, vals, volume):
    n = len(sizes)

    dp = [[0] * (volume+1) for _ in range(n)] # j is 0...volume

    for i in range(n):
        for j in range(volume+1):
            dp[i][j] = max(dp[i][j], dp[i-1][j])
            if j - sizes[i] >= 0:
                dp[i][j] = max(dp[i][j], dp[i-1][j-sizes[i]] + vals[i])
            dp[i][j] = max(dp[i][j], dp[i-1][j])

    return dp[-1][-1]


if __name__ == "__main__":
    n, volume = [int(x) for x in input().split()]
    sizes, vals = [], []
    for _ in range(n):
        s, v = [int(x) for x in input().split()]
        sizes.append(s)
        vals.append(v)
    print(knapsack(sizes, vals, volume))
n = int(input())
for i in range(2**n):
    a = list(format(i,'b'))[::-1]
    
    summ = 0
    for index,aa in enumerate(a):
        summ += int(aa)*((-2)**index)

    if summ == n:
        print(format(i,'b'))
        break


### FIXED CODE ###

import math
import sys

n = int(input())
if n == 0:
  print(0)
  sys.exit()
  
keta = 0
under = 0
s = ""
nn = 1

if n > 0:
    while True:
      if sum([2**i for i in range(0,nn,2)])+1<= n and n <= sum([2**i for i in range(0,nn+1,2)]):
          keta = nn+1
          under = sum([2**i for i in range(0,nn,2)])
          break
      else:
          nn+=1

    for i in range(1,keta):
        remainder = (n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "0" if i%2==1 else "1"
        else:
            s += "1" if i%2==1 else "0"
    else:
        s+="1"
    print(s[::-1])

else:
    while True:
        if n <= sum([(-2)**i for i in range(1,nn,2)]) and n >= sum([(-2)**i for i in range(1,nn+1,2)]):
            keta = nn+1
            under = sum([(-2)**i for i in range(1,nn,2)])
            break
        else:
            nn+=1

    for i in range(1,keta):
        remainder = abs(n-under)%(2**i)
        if remainder in range(1,2**(i-1)+1):
            s += "1" if i%2==1 else "0"
        else:
            s += "0" if i%2==1 else "1"
    else:
        s+="1"
    print(s[::-1])
# -*- coding: utf-8 -*-
 
if 'o' == 'S'[:1] :
   x = 1
    
if 'o' == 'S'[1:2] :
   x = x + 1
 
if 'o' == 'S'[2:] :
   x = x + 1
 
y = 700 + x * 100
 
print str(y)

### FIXED CODE ###

# -*- coding: utf-8 -*-
s = input()
a = s.count('o')
y = 700 + 100 * a
print(y)
def solve(string):
    n, *a = map(int, string.split())
    l, c, r = 1, 2, 3
    sll, slr, srl, srr = sum(a[r:]), sum(a[c:r]), sum(a[l:c]), sum(a[:l])
    ans = max(sll, slr, srl, srr) - min(sll, slr, srl, srr)
    while c < n - 1:
        d = abs(sll - slr)
        dn = abs(sll + 2 * a[l] - slr)
        while dn < d:
            sll, slr = sll + a[l], slr - a[l]
            l += 1
            d = abs(sll - slr)
            dn = abs(sll + 2 * a[l] - slr)
        d = abs(srl - srr)
        dn = abs(srl + 2 * a[r] - srr)
        while dn < d:
            srl, srr = srl + a[r], srr - a[r]
            r += 1
            d = abs(srl - srr)
            dn = abs(srl + 2 * a[r] - srr)
        ans = min(ans, max(sll, slr, srl, srr) - min(sll, slr, srl, srr))
        slr += a[c]
        srl -= a[c]
        c += 1
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


### FIXED CODE ###

def solve(string):
    n, *a = map(int, string.split())
    l, c, r = 1, 2, 3
    sll, slr, srl, srr = sum(a[:l]), sum(a[l:c]), sum(a[c:r]), sum(a[r:])
    ans = max(sll, slr, srl, srr) - min(sll, slr, srl, srr)
    while c < n - 1:
        d = abs(sll - slr)
        dn = abs(sll + 2 * a[l] - slr)
        while dn < d:
            sll, slr = sll + a[l], slr - a[l]
            l += 1
            d = abs(sll - slr)
            dn = abs(sll + 2 * a[l] - slr)
        d = abs(srl - srr)
        dn = abs(srl + 2 * a[r] - srr)
        while dn < d:
            srl, srr = srl + a[r], srr - a[r]
            r += 1
            d = abs(srl - srr)
            dn = abs(srl + 2 * a[r] - srr)
        ans = min(ans, max(sll, slr, srl, srr) - min(sll, slr, srl, srr))
        slr += a[c]
        srl -= a[c]
        c += 1
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
l = []
for i in range(5):
  a = int(input())
  l.append(a)
k = int(input())
for i in range(4):
  for j in range(i+1,5)
  if l[j] - l[i] > k:
    print(":(")
    exit()
    
print("Yay!")

### FIXED CODE ###

l = []
for i in range(5):
  a = int(input())
  l.append(a)
k = int(input())
for i in range(4):
  for j in range(i+1,5):
    if l[j] - l[i] > k:
      print(":(")
      exit()
    
print("Yay!")
import numpy as np
import bisect
N,M=map(int,input().split())
A=np.array(list(map(int,input().split())))
JinA=[]
for i in range(M):
    b,c=map(int,input().split())
    JinA.append((c,b))

JinA.sort(reverse=True)

A.sort()
len_b=0
new_list=[]
for c,b in JinA:
    add_b=min(b,N-len_b)
    new_list+=[c]*add_b
    
now=np.array(new_list)    
Ans=np.minimum(A,now)
print(Ans.sum())

### FIXED CODE ###

from operator import itemgetter

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

q = sorted(A+BC, key=itemgetter(1), reverse=True)

ans = 0
i = 0

while N:
    n = min(q[i][0], N)
    ans += q[i][1] * n
    N -= n
    i += 1
print(ans)
a, b = list(map(int, input()).split())

if a * b % 2 == 0:
    print("Odd")
else:
    print("Even")


### FIXED CODE ###

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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

if n == 1:
  print(max(a) - min(a))
  exit()


for i in range(1,len(a)):
  if a[i] == x:
    print(min(x-a[i-1] , a[i+1] - x))
    exit()



### FIXED CODE ###

import functools
import fractions

n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.append(x)
a.sort()

for i in range(len(a)):
  a[i] = abs(a[i] - x)

gcd = functools.reduce(fractions.gcd, a)
print(gcd)
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 T:
    count += T[i]

discount = 0
for i in T:
    if i <= M:
        discount += T[i]

special = 0
for i in P, X:
    special += P[i]
    special += X[i]

count *= M
count -= discount
count += special

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 = int(input())
A = [map(int, input().split())]
d = 0
for n in range(0, N-1):
    if A[n+1] < A[n]:
        d += A[n]-A[n+1]
        A[n+1] = A[n]
print(d)

   

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
d = 0
for n in range(0, N-1):
    if A[n+1] < A[n]:
        d += A[n]-A[n+1]
        A[n+1] = A[n]
print(d)
import numpy as np
from sys import stdinans=0
c=0
N = int(input().rstrip())
for i in range(N):
  c=0
  i+=1
  if i%2==1:
    for j in range(i):
      j+=1
      if i%j==0:
        c+=1
  if c==8:
    ans+=1

print(ans)

### FIXED CODE ###

import numpy as np
from sys import stdin
ans=0
c=0
N = int(input().rstrip())
for i in range(N):
  c=0
  i+=1
  if i%2==1:
    for j in range(i):
      j+=1
      if i%j==0:
        c+=1
  if c==8:
    ans+=1

print(ans)
n, k = map(int, input().split())
h = list(map(int, input().split()))
a = [0]*n
for i in range(1, n):
      hi = h[i]
      for j in range(max(0,i-k)i):
            a[i] = min(a[j] + abs(hi - h[j])
print(a[-1])

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * n
a[0] = 0
for i in range(1, n):
      hi = h[i]
      a[i] = min(a[j] + abs(hi - h[j]) for j in range(max(0, i - k), i))
print(a[-1])
2 6 3


### FIXED CODE ###

# encoding: utf-8
ABC = sorted(list(map(int, input().split())))

diff0 = ABC[-1] - ABC[0]
diff1 = ABC[-1] - ABC[1]

# +2 only
if diff0 % 2 == diff1 % 2 == 0: ans = (diff0 + diff1) // 2
# +1 (ABC[0], ABC[1]) once and +2
elif diff0 % 2 == diff1 % 2 == 1: ans = (diff0 + diff1) // 2
# +1 (ABC[{0, 1}], ABC[2]) once and +2)
else: ans = 1 + (diff0 + diff1 + 2) // 2

print(ans)
import math

n,m = map(int,input().split())
m_div = []
for i in range(1,math.ceil(math.sqrt(m)+1)):
  if m%i ==0:
    m_div.extend([i,m//i])
m_div = list(set(m_div))
m_div.sort(reverse = True)
for div in m_div:
  if div >= n:
    ans = m//div
  else:
    break
print(ans)
    

### FIXED CODE ###

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