Harryxun/stf_run huggingface dataset:
N = input()
number = input()

a = number.split()
n_list=[]
count=0



for num in a:
    num = int(num)
    if num % 2 == 0:
        n_list.append(num)


if n_list != []:
    maxnum = max(n_list)
    maxnum = maxnum/2
    for num2 in n_list:
        for i in range(maxnum):
            if num2 % 2**(i+1) == 0:
                count+=1


print(count)

### FIXED CODE ###

from math import log2

N = input()
number = input()

a = number.split()
n_list=[]
count=0



for num in a:
    num = int(num)
    if num % 2 == 0:
        n_list.append(num)


if n_list != []:
    maxnum = max(n_list)
    maxnum = log2(maxnum)
    maxnum = int(maxnum)
    for num2 in n_list:
        for i in range(maxnum):
            if num2 % 2**(i+1) == 0:
                count+=1


print(count)
from collections import defaultdict
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
d=defaultdict(lambda:0)
for i in range(n-1):
  for j in range(i+1,n):
    dx=xy[i][0]-xy[j][0]
    dy=xy[i][1]-xy[j][1]
    d[(dx,dy)]+=1
    d[(-dx,-dy)]+=1
print(n-max(d.values()))

### FIXED CODE ###

from collections import defaultdict
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
if n==1:
  print(1)
  exit()
d=defaultdict(lambda:0)
for i in range(n-1):
  for j in range(i+1,n):
    dx=xy[i][0]-xy[j][0]
    dy=xy[i][1]-xy[j][1]
    d[(dx,dy)]+=1
    d[(-dx,-dy)]+=1
print(n-max(d.values()))
#for k,v in d.items():
#  print(k,v)
n = int(input())
data_input = []

for i in range(n):
    data_input.append(input().split())

dlList = []

for x in data_input:
    if x[0] == 'insert':
        dlList.insert(0,x[1])
    elif x[0] == 'delete':
        dlList.remove(x[1])
    elif x[0] == 'deleteFirst':
        dlList.pop(0)
    elif x[0] == 'deleteLast':
        dlList.pop()
    else:
        pass

print(' '.join(dlList))

### FIXED CODE ###

import sys
from collections import deque
input_lines = sys.stdin.readlines()

doublyLinkedList = deque()


for x in input_lines[1:]:
    oneLine = x.split()
    if 'insert' in oneLine[0]:
        doublyLinkedList.appendleft((int)(oneLine[1]))
    elif 'delete' == oneLine[0]:
        remove_value = (int)(oneLine[1])
        if remove_value in doublyLinkedList:
            doublyLinkedList.remove(remove_value)
    elif 'deleteFirst'in oneLine[0]:
        doublyLinkedList.popleft()
    elif 'deleteLast' in oneLine[0]:
        doublyLinkedList.pop()

print(*doublyLinkedList)
N=int(input())
a=list(input())
import sys

sys.setrecursionlimit(10**6)

r=a.count('R')
g=a.count('G')
b=a.count('B')
s=0
for i in range(N-1):
    for j in range(i+1, N):
        if 2*j-i < N:
            if a[i] !=a[j] and a[j]!=a[2*j-i] and a[2*j-i]!=a[i]:
                s+=1

n=r*g*b-s
print(n)


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline().rstrip())


a=N%10
b=((N-a)/10)%10
c=(N-10*b-a)/100
n=[a,b,c]
if 7 in n:
    print('Yes')

else:
    print('No')
N-int(input())
s=list(map(int, input().split()))
s.sort()
ans=0
for i in range(N-1):
    if i==0:
        ans=+s[0]
    else:
        ans=((ans+s[i])/2)
print(ans)

### FIXED CODE ###

N=int(input())
s=list(map(int, input().split()))
s.sort()
ans=s[0]
for i in range(N-1):
    ans=((ans+s[i+1])/2)
print(ans)
N, K = (int(x) for x in input().split())
trip = input().split()
 
now = 1
way = []
 
for k in range(K): 
  now = int(trip[now-1])
  way.append(now)
  if way.count(now) == 2:
    a = K % len(way)
    break

print(way[a])

### FIXED CODE ###

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

route = []
town = set()
now = 1

while True:
    now = a[now-1]
    if now in town:
        break
    town.add(now)
    route.append(now)

count = route.index(now)
if count >= k:
    print(route[k-1])
else:
    route = route[count:]
    num = (k-count)%len(route)
    print(route[num-1])
s = list(input())
print("".join(s[:4] + [" "] + s[4:])

### FIXED CODE ###

s = list(input())
print("".join((s[:4] + [" "] + s[4:])))
K = int( input() )
S = input()

if len(S) <= K:
  print( S )
else:
  print( S[:K] + '...' )

### FIXED CODE ###

N = input()
first = int(N) % 10
if first in ( 2, 4, 5, 7, 9 ):
  ret = 'hon'
elif first in ( 0, 1,6,8 ):
  ret = 'pon'
else:
  ret = 'bon'

print( ret )
d = int(input())
t,s = map(int,input().split())

if d − s*t <= 0:
  print('Yes')
else print('No')


### FIXED CODE ###

d,t,s = map(int,input().split())
if (d - s*t <= 0):
  print('Yes')
else:
  print('No')
N = input()
K = input()
if N * 500 >= K:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N, K = map(int,input().split())
if N * 500 >= K:
  print("Yes")
else:
  print("No")
X=int(input())
n=26

a=[]
X_dumy = X
out = ''
while X_dumy>0:
  out = str(X_dumy%n)
  X_dumy = int(X_dumy/n)
  a.append(out)

l = list('abcdefghijklmnopqrstuvwxyz')
N=0
for x in a:
  a[N]=l[int(a[N])-1]
  N=N+1
pg = ''.join(a)
print(pg)

### FIXED CODE ###

if input().isupper():
  print("A")
else:
  print("a")
n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    if min(a, b) == 0:
        return max(a, b)
    while b:
        a, b = b, a%b
    return a

def l(i):
    if i == 0:
        return 0
    else:
        return gcd(l(i-1), a[i-1])

def r(i):
    if i == n:
        return 0
    else:
        return gcd(r(i+1), a[i])

gcd_max = 1
for i in range(n):
    i_gcd = gcd(l(i), r(i+1))
    if i_gcd > gcd_max:
        gcd_max = i_gcd

print(gcd_max)


### FIXED CODE ###

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

def gcd(a, b):
    if min(a, b) == 0:
        return max(a, b)
    while b:
        a, b = b, a % b
    return a

l = [0]
r = [0]
for i in range(n):
    l.append(gcd(l[i], a[i]))
    r.append(gcd(r[i], a[n-i-1]))

r = r[::-1]

ans = 0
for i in range(n):
    g = gcd(l[i], r[i+1])
    ans = max(ans, g)

print(ans)
h=int(input())
a=0
while True:
 h=h//2
 a+=1
 if =h//2==0:
  break

print(2**a-1)


### FIXED CODE ###

h=int(input())
a=1

if h ==1:
 print(1)
else:
 while True:
  h=h//2
  a+=1
  if h//2==0:
   break

 print(2**a-1)
from scipy.special import comb
n, a, b = map(int, input().split())
all = (2**n - 1)
nca = comb(n, a, exact=True)
ncb = comb(n, b, exact=True)
all -= nca + ncb
print(all%1000000007)


### FIXED CODE ###

n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
all = pow(2, n, mod) - 1

def comb(n, r):
  c = 1
  m = 1
  r = min(n-r, r)
  for i in range(r):
    c = c * (n - i) % mod
    m = m * (i + 1) % mod
  return c * pow(m, mod-2, mod) % mod

nca = comb(n, a)
ncb = comb(n, b)
all -= nca + ncb
print(all%mod)
import math
from itertools import accumulate


class Job:

    def __init__(self, job_id, reward, days):
        self.id = job_id
        self.reward = reward
        self.days = days


def dfs(jobs, remaing_days):
    reward = 0

    if remaing_days == 0:
        return 0

    for job in jobs:
        if job.days <= remaing_days:
            # print(
            #     f'trying {job} sum: {reward} remaing_days:{remaing_days} selected:{selected_jobs}')

            remaining_jobs = jobs - set([job])
            new_reward = job.reward + \
                dfs(remaining_jobs, remaing_days - 1)

            # if reward < new_reward:
            #     print(
            #          f'pickup {job} sum: {new_reward} remaing_days:{remaing_days} selected:{selected_jobs}')
            reward = max(reward, new_reward)
        # else:
        #     print(
        #         f'fail to pickup {job} sum: {reward} remaing_days:{remaing_days} selected:{selected_jobs}')

    return reward


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

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.add(Job(job_id=i, reward=B, days=A))

print(dfs(jobs, M))

### FIXED CODE ###

import heapq


class Job:

    def __repr__(self):
        return "%d,%d".format(self.days, self.reward)

    def __lt__(self, other):
        return self.reward < other.reward

    def __init__(self, job_id, reward, days):
        self.id = job_id
        self.reward = reward
        self.days = days

N, M = list(map(int, input().split()))
h = []
jobs = []

for i in range(N):
    A, B = list(map(int, input().split()))
    jobs.append(Job(job_id=i, reward=B, days=A))


jobs = sorted(jobs, key=lambda j: j.days)
idx = 0
c = 0

for i in range(1, M+1):
    while idx < N and jobs[idx].days <= i:
        heapq.heappush(h, -jobs[idx].reward)
        idx += 1

    if len(h) != 0:
        c += -heapq.heappop(h)

print(c)
def main():
    N, M = map(int, input().split())

    A = list(map(int, input().split()))  # 使っていい数字

    match_dic = {9: 6, 8: 7, 7: 3, 6: 6, 5: 5, 4: 4, 3: 5, 2: 5, 1: 2}
    available_dic = {k: v for k, v in match_dic.items() if k in A }
    availables = sorted(available_dic.items(), key=lambda x: x[1])

    def dfs(cost, nums):
        if cost == 0:
            nums.sort(key=lambda x: -x)
            return int(''.join(map(str, nums)))

        cand = [dfs(cost - avs[1], nums + [avs[0]]) for avs in availables if cost >= avs[1]]
        if len(cand) == 0:
            return 0
        else:
            return max(dfs(cost - avs[1], nums + [avs[0]]) for avs in availables if cost >= avs[1])

    print(dfs(N, []))


main()

### FIXED CODE ###

# https://atcoder.jp/contests/abc118/tasks/abc118_d


def main():
    N, M = map(int, input().split())

    A = list(map(int, input().split()))  # 使っていい数字

    costs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]  # 各数字のマッチの数

    dp = [-1 for _ in range(N + 1)]
    dp[0] = 0
    for i in range(1, N + 1):
        for a in A:
            if i < costs[a]:
                continue
            dp[i] = max(dp[i], dp[i - costs[a]] * 10 + a)
    print(dp[N])


main()
def count_divisors(a, b, c):
    if a == b:
        return (1 if c % a == 0 else 0)

    return (1 if c % a == 0 else 0) + count_divisors(a+1, b, c)

a, b, c = map(int, input().split(' '))

print(count_divisors(a, b, c))

### FIXED CODE ###

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

count = 0

for i in range(a, b+1):
    if c % i == 0:
        count += 1

print(count)
x=int(input())
if x==1:
    print(1)
    a=True
for i in range(33):
    if a:
        break
    if i**2<x:
        pass
    else:
        print((i-1)**2)
        break

### FIXED CODE ###

import sys
x=int(input())
a=[]
if x==0:
    print(0)
    sys.exit()
for i in range(1,33):
    for j in range(2,11):
        if i**j<=x:
            a.append(i**j)
print(max(a))
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    v = f()

    a = [ v[i] for i in range(n) if i%2 == 0]
    b = [ v[i] for i in range(n) if i%2 == 1]

    cnt_a = {}
    cnt_b = {}
    for i in a:
        if i in cnt_a:
            cnt_a[i] += 1
        else:
            cnt_a[i] = 1
    
    for i in b:
        if i in cnt_b:
            cnt_b[i] += 1
        else:
            cnt_b[i] = 1

    ncnt_a = sorted(cnt_a.items(), key = lambda x:x[1])
    ncnt_b = sorted(cnt_b.items(), key = lambda x:x[1])

    

    if ncnt_a[0][0]!=ncnt_b[0][0]:
        print(n -ncnt_a[0][1]- ncnt_b[0][1])
    else:
        ans1 = n -ncnt_a[1][1]- ncnt_b[0][1]
        ans2 = n -ncnt_a[0][1]- ncnt_b[1][1]
        print(min(ans1, ans2))



solve()


### FIXED CODE ###

import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    v = f()

    a = [ v[i] for i in range(n) if i%2 == 0]
    b = [ v[i] for i in range(n) if i%2 == 1]

    cnt_a = {}
    cnt_b = {}
    for i in a:
        if i in cnt_a:
            cnt_a[i] += 1
        else:
            cnt_a[i] = 1
    
    for i in b:
        if i in cnt_b:
            cnt_b[i] += 1
        else:
            cnt_b[i] = 1

    ncnt_a = sorted(cnt_a.items(), key = lambda x:-x[1])
    ncnt_b = sorted(cnt_b.items(), key = lambda x:-x[1])

    

    if ncnt_a[0][0]!=ncnt_b[0][0]:
        print(n -ncnt_a[0][1]- ncnt_b[0][1])
    else:
        ans1 = n - ncnt_b[0][1] - (ncnt_a[1][1] if len(ncnt_a)>1 else 0)
        ans2 = n -ncnt_a[0][1]- (ncnt_b[1][1] if len(ncnt_b)>1 else 0)
        print(min(ans1, ans2))



solve()
N = int(input())
nums = list(map(int, input().split()))


def check():
    for i in range(1, N):
        if nums[i] == nums[i - 1]:
            continue
        elif nums[i] - 1 >= nums[i - 1]:
            nums[i] -= 1
        else:
            return "No"
    return "Yes"


print(check()

### FIXED CODE ###

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


def check():
    for i in range(1, N):
        if nums[i] == nums[i - 1]:
            continue
        elif nums[i] - 1 >= nums[i - 1]:
            nums[i] -= 1
            continue
        else:
            return "No"
    return "Yes"


print(check())
import math

k = int(input())

gcd_sum_dict = collections.defaultdict(int)
for i in range(1, k+1):
    gcd_sum_dict[i] = 0
    for j in range(1, k+1):
        gcd_sum_dict[i] += gcd(i, j)

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        ans += gcd_sum_dict[gcd(i, j)]

print(ans)

### FIXED CODE ###

import math
import collections

k = int(input())

gcd_sum_dict = collections.defaultdict(int)
for i in range(1, k+1):
    gcd_sum_dict[i] = 0
    for j in range(1, k+1):
        gcd_sum_dict[i] += math.gcd(i, j)

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        ans += gcd_sum_dict[math.gcd(i, j)]

print(ans)
N = [int(i) for i in input().split()][0]

balls=[]
for i in range(N):
  balls.append( [int(i) for i in input().split()])

salist=[]
sa_uniq=[]
for i in range(1,len(balls),1):
  sax = balls[i][0]-balls[i-1][0]
  say = balls[i][1]-balls[i-1][1]
  salist.append([sax,say])
  if [sax,say] not in sa_uniq:
    sa_uniq.append([sax,say])

count = []
for sa in sa_uniq:
  count.append(salist.count(sa))

if N-max(count)==1:
  print('1')
else:
  print(N-max(count))

### FIXED CODE ###

N = [int(i) for i in input().split()][0]

balls=[]
for i in range(N):
  balls.append( [int(i) for i in input().split()])

ans=0
for i in range(0,N-1):
  for j in range(i+1,N):
    sax = balls[j][0]-balls[i][0]
    say = balls[j][1]-balls[i][1]
    merge=0
    for k in range(0,N):
      if([balls[k][0]+sax,balls[k][1]+say] in balls):
          merge+=1
    ans=max(ans,merge)
print(N-ans)
N = int(input())
H = list(map(int, input().split()))
ans = True
for i in range(1,len(H)):
    if (H[i-1] - H[i]) == 1:
        H[i-1] -= 1
    elif (H[i-1] - H[i]) <= 0:
        continue
    else:
        ans = False
        break
H.reverse()
for i in range(1,len(H)):
    if H[i-1]-H[i] >=  0:
        pass
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A,B,C = map(int,input().split())
s = A - B
test = C - s
if test <=  0:
    test = 0
print(test)
print(int(input()) * 6.28

### FIXED CODE ###

print(int(input()) * 6.28)
import sys

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

bin_vals = [bin(val) for val in a]
bit_result = bin(0)

# 論理和
for r in bin_vals:
    bit_result = bit_result | r

int_result = int(str(bit_result), 2)
count = 0
while True:
    if int_result % 2 != 0:
        break
    int_result = int_result / 2
    count = count + 1
print(count)

### FIXED CODE ###

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

temp = 0

for i in a:
    temp |= i

count = 0
while True:
    if temp % 2 != 0:
        break
    temp /= 2
    count +=  1
print(count)
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.cound("R") > s.count("B"):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if s.count("R") > s.count("B"):
    print("Yes")
else:
    print("No")
n, m = [for i in input().split()]
a = [int(i) for i in input().split()]

ok_count = 0
for i in a:
    if i > 1 / (4 * sum(a)): ok_count += 1

print("Yes" if m >= ok_count else "No")

### FIXED CODE ###

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

ok_count = 0
for i in a:
    if i >= sum(a) / (4 * m): ok_count += 1

print("Yes" if m <= ok_count else "No")
def circle_in_rectangle(radius, pos, height, width):
    """ 
    radius: float
    pos: tuple, (x, y)
    height: float, height of rectangle
    width: float, width of rectangle

    returns True if circle is in rectangle, otherwise False
    """
    (x, y) = pos 
    if x < radius or x > width - radius:
        return False

    if y < radius or y > height - radius:
        return False

    return True

(w, h, x, y, r) = input().split(' ')

if circle_in_rectangle(r, (x, y), h, w):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

def circle_in_rectangle(radius, pos, height, width):
    """
    radius: int
    pos: tuple, (x, y)
    height: int, height of rectangle
    width: int, width of rectangle

    returns True if circle is in rectangle, otherwise False

    >>> circle_in_rectangle(1, (1, 1), 4, 5)
    True
    >>> circle_in_rectangle(1, (2, 4), 4, 5)
    False
    """
    (x, y) = pos
    if x < radius or x > width - radius:
        return False

    if y < radius or y > height - radius:
        return False

    return True

if __name__ == '__main__':
    #import doctest
    #doctest.testmod()

    (w, h, x, y, r) = input().split(' ')

    if circle_in_rectangle(int(r), (int(x), int(y)), int(h), int(w)):
        print('Yes')
    else:
        print('No')
n, m, k = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
CD = [list(map(int, input().split())) for _ in range(k)]
group = []  # 連結成分ごとのサイズ
person_group = [-1] * n  # 人ごとの属するグループ
person_unable= [0] * n  # 人ごとの候補に入らない人の人数
graph = [[] for _ in range(n)]  # 連結リスト
for ab in AB:
    ab[0] -= 1
    ab[1] -= 1
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])

seen = [False] * n
# その節の連結成分のサイズを返す
def dfs(n, group_id):
    global size
    seen[n] = True
    person_group[n] = group_id
    for v in graph[n]:
        if seen[v]:
            continue
        size = dfs(v, group_id)
    size += 1
    return size
    
    
group_id = 0
for i in range(n):
    if seen[i]:
        continue
    size = 0
    group.append(dfs(i, group_id))
    group_id += 1

# unable計算。まず友達の人
for i in range(n):
    person_unable[i] += len(graph[i])
# 次にブロックの人
for i in range(k):
    CD[i][0] -= 1
    CD[i][1] -= 1
    if person_group[CD[i][0]] == person_group[CD[i][1]]:
        person_unable[CD[i][0]] += 1
        person_unable[CD[i][1]] += 1

for i in range(n):
    print(group[person_group[i]] - person_unable[i] - 1, "", end="")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6 + 10)

n, m, k = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
CD = [list(map(int, input().split())) for _ in range(k)]
group = []  # 連結成分ごとのサイズ
person_group = [-1] * n  # 人ごとの属するグループ
person_unable= [0] * n  # 人ごとの候補に入らない人の人数
graph = [[] for _ in range(n)]  # 連結リスト
for ab in AB:
    ab[0] -= 1
    ab[1] -= 1
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])

seen = [False] * n
# その節の連結成分のサイズを返す
def dfs(n, group_id):
    global size
    seen[n] = True
    person_group[n] = group_id
    for v in graph[n]:
        if seen[v]:
            continue
        size = dfs(v, group_id)
    size += 1
    return size
    
    
group_id = 0
for i in range(n):
    if seen[i]:
        continue
    size = 0
    group.append(dfs(i, group_id))
    group_id += 1

# unable計算。まず友達の人
for i in range(n):
    person_unable[i] += len(graph[i])
# 次にブロックの人
for i in range(k):
    CD[i][0] -= 1
    CD[i][1] -= 1
    if person_group[CD[i][0]] == person_group[CD[i][1]]:
        person_unable[CD[i][0]] += 1
        person_unable[CD[i][1]] += 1

for i in range(n):
    print(group[person_group[i]] - person_unable[i] - 1, "", end="")
b = input().split()
l = np.zeros((int(b[0]), 3))
for i in range(int(b[0])):
	buf = input().split()
	for j in range(3):
		l[i][j] = int(buf[j])
r = 0

for p in range(8):
	rbuf = 0
	box = ((-1)**p)*l.T[0]+((-1)**(p//2))*l.T[1]+((-1)**(p//4))*l.T[2]
	#print((-1)**p, (-1)**(p//2), (-1)**(p//4))
	for i in range(int(b[1])):
		rbuf += np.max(box)
		box[np.argmax(box)] = 0
	if(rbuf > r):
		r = rbuf
		
print(int(r))# your code goes here

### FIXED CODE ###

import numpy as np

b = input().split()
l = np.zeros((int(b[0]), 3))
for i in range(int(b[0])):
	buf = input().split()
	for j in range(3):
		l[i][j] = int(buf[j])
r = 0

for p in range(8):
	rbuf = 0
	box = ((-1)**p)*l.T[0]+((-1)**(p//2))*l.T[1]+((-1)**(p//4))*l.T[2]
	box = np.sort(box)[::-1]
	for i in range(int(b[1])):
		rbuf += box[i]
	if(rbuf > r):
		r = rbuf
		
print(int(r))
n,x,k=map(int,input().split(' '))

print(((n/x)+1))*k)


### FIXED CODE ###

n,x,k=map(int,input().split(' '))
temp=k
ans=0
while n>0:
    n-=x
    ans +=temp
    k+=k


print(ans)
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a<10:
  if b<10:
    print(a*b)
    else:
      print('-1')
  else:
    print('-1')
     

### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a<10 and b<10:
  print(a*b)
else:
  print(0-1)
n = int(input())
c = []
not_c = []
chosen = set()
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	not_c.append([max(a, b), i])
	c.append([min(a, b), i])
	ans += min(a, b)
	if a < b:
		chosen.add("a")
	elif a > b:
		chosen.add("b")

if len(chosen) < 2:
	print(ans)
else:
	c = sorted(c, reverse=True)
	not_c = sorted(not_c)
	#print(c, not_c)
	#used_c = [False] * n
	#used_n = [False] * n

	if c[0][1] != not_c[0][1]:
		ans = ans - c[0][0] + not_c[0][0]
		c_cur = 1
		not_cur = 1
	else:
		ans = min(ans - c[1][0] + not_c[0][0], ans - c[0][0] + not_c[1][0])
		if ans - c[1][0] + not_c[0][0] <= ans - c[0][0] + not_c[1][0]:
			c_cur = 2
			not_cur = 1
		else:
			c_cur = 1
			not_c = 2
	while c[c_cur][0] > not_c[not_cur][0]:
		if c[c_cur][1] != not_c[not_cur][1]:
			ans = ans - c[c_cur][0] + not_c[not_cur][0]
			c_cur += 1
			not_cur += 1
		else:
			ans = min(ans - c[c_cur+1][0] + not_c[not_cur][0], ans - c[c_cur][0] + not_c[not_cur+1][0])
			if ans - c[c_cur+1][0] + not_c[not_cur][0] <= ans - c[c_cur][0] + not_c[not_cur+1][0]:
				c_cur += 2
				not_cur += 1
			else:
				c_cur += 1
				not_c += 2
		if c_cur >= n or not_cur >= n:
			break
	print(ans)


### FIXED CODE ###

n = int(input())
c = []
not_c = []
chosen = set()
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	not_c.append([max(a, b), i])
	c.append([min(a, b), i])
	ans += min(a, b)
	if a < b:
		chosen.add("a")
	elif a > b:
		chosen.add("b")

if len(chosen) < 2:
	print(ans)
else:
	c = sorted(c, reverse=True)
	not_c = sorted(not_c)
	#print(c, not_c)
	#used_c = [False] * n
	#used_n = [False] * n

	if c[0][1] != not_c[0][1]:
		ans = ans - c[0][0] + not_c[0][0]
		c_cur = 1
		not_cur = 1
	else:
		ans = min(ans - c[1][0] + not_c[0][0], ans - c[0][0] + not_c[1][0])
		if ans - c[1][0] + not_c[0][0] <= ans - c[0][0] + not_c[1][0]:
			c_cur = 2
			not_cur = 1
		else:
			c_cur = 1
			not_cur = 2
	if c_cur < n and not_cur < n:
		while c[c_cur][0] > not_c[not_cur][0]:
			if c[c_cur][1] != not_c[not_cur][1]:
				ans = ans - c[c_cur][0] + not_c[not_cur][0]
				c_cur += 1
				not_cur += 1
			elif c_cur == n - 1 or not_cur == n - 1:
				break
			else:
				ans = min(ans - c[c_cur+1][0] + not_c[not_cur][0], ans - c[c_cur][0] + not_c[not_cur+1][0])
				if ans - c[c_cur+1][0] + not_c[not_cur][0] <= ans - c[c_cur][0] + not_c[not_cur+1][0]:
					c_cur += 2
					not_cur += 1
				else:
					c_cur += 1
					not_cur += 2
			if c_cur >= n or not_cur >= n:
				break
	print(ans)