Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
a=sorted(list(map(int, input().split())))
bc = sorted([list(map(int, input().split())) for _ in range(m)], key = lambda x:x[1], reverse = True)
tmp=0
cnt=0
ans=0
for i in range(n):
    if cnt>=bc[tmp][0]:
        ans+=bc[tmp][1]*bc[tmp][0]
        cnt-=bc[tmp][0]
        tmp+=1
    if tmp==m:
        k=n
        break
    if a[i]>bc[tmp][1]:
        k=i
        ans+=bc[tmp][1]*(cnt)
        break
    cnt+=1
print(sum(a[k:])+ans)

### FIXED CODE ###

n, m = map(int, input().split())
a=sorted(list(map(int, input().split())), reverse = True)
bc = sorted([list(map(int, input().split())) for _ in range(m)], key = lambda x:x[1], reverse = True)
i=0
j=0
cnt=0
ans=0
while True:
    if j<m and a[i]<bc[j][1]:
        ans+=min(n-cnt, bc[j][0])*bc[j][1]
        cnt+=min(n-cnt, bc[j][0])
        j+=1
    else:
        ans+=a[i]
        i+=1
        cnt+=1
    if cnt==n:
        break
print(ans)
N,D=map(int,input().split())
c=0
X=[[0]*D]*N
for l in range(N):
    X[l]=list(map(int,input().split()))
for i in range(N-1):
    l=0
    for j in range(i+1,N):
        for k in range(D):
            l+=(X[i][k]-X[j][k])**2
        if pow(l,0.5).is_integer() == True:
            c+=1
print(c)


### FIXED CODE ###

#133 T or T
N,A,B = map(int,input().split())
print(min(N*A,B))
N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 0
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs > abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste

min_taste_index = tastes.index(min_taste)
print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))

### FIXED CODE ###

N, L = (int(nl) for nl in input().split())
tastes = [L+i-1 for i in range(1, N+1)]
min_taste = 100
min_taste_abs = 100
for taste in tastes:
    if min_taste_abs >= abs(taste):
        min_taste_abs = abs(taste)
        min_taste = taste

min_taste_index = tastes.index(min_taste)
if len(tastes) == min_taste_index+1:
    print(sum(tastes[:min_taste_index]))
else:
    print(sum(tastes[:min_taste_index]+tastes[min_taste_index+1:]))
import itertools
import math
import sys

n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n // 2)
else:
    odd_cnt = [0] * (10 ** 5)
    even_cnt = [0] * (10 ** 5)
    for i in range(len(v)):
        if i % 2 == 0:
            even_cnt[v[i]] += 1
        else:
            odd_cnt[v[i]] += 1
    odd = odd_cnt.index(max(odd_cnt))
    even = even_cnt.index(max(even_cnt))
    ans = 0
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != even:
                ans += 1
        else:
            if v[i] != odd:
                ans += 1
    print(ans)


### FIXED CODE ###

import itertools
import math
import sys
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = Counter(v[0::2]).most_common()
o = Counter(v[1::2]).most_common()
if len(e) == 1 and len(o) == 1:
    if e[0][0] == o[0][0]:
        print(n // 2)
    else:
        print(0)
elif len(e) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], o[1][1]))
elif len(o) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], e[1][1]))
else:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))
n, m = map(int, input().split())

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

isVisited = [False] * n

CC = [None] * n


def dfs(u, group):
    isVisited[u] = True
    CC[u] = group
    for v in adj[u]:
        if not isVisited[v]:
            dfs(v, group)

def makeCC(group):
    for i in range(n):
        if not isVisited[i]:
            dfs(i, group)
            group += 1

def isConnected(v1, v2):
    if CC[v1] == CC[v2]:
        print('yes')
    else:
        print('no')


makeCC(0)


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)

### FIXED CODE ###

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

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

groups = [None] * n


def dfs(u, group_num):
    path = []
    path.append(u)
    groups[u] = group_num
    while path:
        u = path[-1]
        if adj[u]:
            v = adj[u].pop(0)
            if not groups[v]:
                groups[v] = group_num
                path.append(v)
        else:
            path.pop()


g_n = 1
for i in range(n):
    if not groups[i]:
        dfs(i, g_n)
        g_n += 1

def isConnected(v1, v2):
    if groups[v1] == groups[v2]:
        print('yes')
    else:
        print('no')


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)
#h:体力 n:必殺技の数
#a:必殺技の威力

h,n = map(int,input().split())
a = input().split()
a.sort()

sum = int(a[-1]) + int(a[-2])

result = h - sum
if result <= 0:
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

h,n = map(int,input().split())
a = list(map(int,input().split()))
goukei = sum(a)
result = h - goukei

if result <= 0:
    print("Yes")
else:
    print("No")
N = int(input())
hotel = list(map(int, input().split()))
count = 0
for i in range(1, N):
  for j in range(0, i):
    if all(hotel[i] >= hotel[j]):
      count += 1
print(count+1)


### FIXED CODE ###

N = int(input())
hotel = list(map(int, input().split()))
count = 0
c = 0
for i in range(1, N):
    c=0
    for j in range(0, i):
        
        if hotel[i] >= hotel[j]:
            c += 1
        if c == i:
            count += 1
print(count+1)
s=input()
t=input()
# minimize
mnmz={ch for ch in s} & {ch for ch in t}
if len(mnmz)==0:
    print("")
    exit()
s="".join([ z for z in s if z in mnmz])
t="".join([ z for z in t if z in mnmz])
# init
dp=[0]*len(s)
res={}
#dp
for i in range(len(t)):
    prev=dp[0]
    if dp[0]==0 and t[i]==s[0]:
        dp[0]=1
        res[1]=[s[0]]
    for j in range(1, len(s)):
        temp = max(dp[j-1], dp[j])
        if s[j]==t[i]:
            if temp<prev+1:
                temp=prev+1
                res[temp]=res[prev]+[s[j]]
        prev, dp[j] = dp[j], temp

print("".join(res[dp[len(s)-1]]))



### FIXED CODE ###

s=[ord(ch)-97 for ch in input()]
t=[ord(ch)-97 for ch in input()]

# minimize
mnmz={ch for ch in s} & {ch for ch in t}
if len(mnmz)==0:
    print("")
    exit()
s=[ z for z in s if z in mnmz ]
t=[ z for z in t if z in mnmz ]
if len(s)>len(t): s, t = t, s

# init
dp=[[0]*len(s) for _ in range(len(t))]

#dp frame init
for i in range(len(s)): 
    if s[i]==t[0]:
        for j in range(i, len(s)):
            dp[0][j]=1
        break
for i in range(len(t)): 
    if s[0]==t[i]:
        for j in range(i, len(t)):
            dp[j][0]=1
        break
#dp
for i in range(1,len(t)):
    for j in range(1, len(s)):
        if s[j]==t[i]:
            dp[i][j]=dp[i-1][j-1]+1
        else: dp[i][j]=(dp[i][j-1] if dp[i][j-1]>dp[i-1][j] else dp[i-1][j])

#recover string
res=[]
j=len(s)-1
i=len(t)-1
while i>=0 and j>=0:
    if s[j]==t[i]: #and dp[i][j]==dp[i-1][j-1]+1:
        res.append(s[j])
        i=i-1
        j=j-1
        continue
    if i==0 and j==0: break
    if j>0 and dp[i][j]==dp[i][j-1]:
        j=j-1
    else: i=i-1
# last letter (first acually)


print("".join(chr(i+97) for i in reversed(res)))
from heapq import heapify, _heapify_max, heappushpop, _heappushpop_max

N = int(input())

numbers = [int(x) for x in input().split()]

left = numbers[:N]
heapify(left)

right = numbers[2 * N:]
_heapify_max(right)

for x in numbers[N:2 * N]:
  if left[0] < x < right[0]:
    if abs(left[0] - x) > abs(left[0] - x):
      heappushpop(left, x)
    else:
      _heappushpop_max(right, x)
  elif x > left[0]:
    heappushpop(left, x)
  elif -x > right[0]:
    heappushpop(right, -x)
    
print(sum(left) - sum(right))


### FIXED CODE ###

from heapq import heapify, _heapify_max, heappushpop, _heappushpop_max

N = int(input())

numbers = [int(x) for x in input().split()]

left = numbers[:N]
left_sum = sum(left)
left_memo = [0] * N
heapify(left)

right = numbers[2 * N:]
right_sum = sum(right)
right_memo = [0] * N
_heapify_max(right)

middle = numbers[N:2 * N]

for i in range(0, N):
  left_sum += (middle[i] - heappushpop(left, middle[i]))
  left_memo[i] = left_sum

for i in range(N - 1, -1, -1):
  right_sum += (middle[i] - _heappushpop_max(right, middle[i]))
  right_memo[i] = right_sum

left_memo.insert(0, sum(numbers[:N]))
right_memo.insert(0, None)
right_memo.append(sum(numbers[2 * N:]))
    
print(
  max([left_memo[i] - right_memo[i + 1] for i in range(N + 1)])
)
n = int(input())
primeN = []
tmp = 2
for i in range(2, n):
    if primeN:
        for j in range(len(primeN)):
            if i % primeN[j] == 0:
                break
            else:
                if j == len(primeN) - 1:
                    primeN.append(i)
    else:
        if n > tmp:
            primeN.append(i)
#print(primeN)

s = 0
for j in primeN:
  k = j
  while n%k==0:
    s+=1
    n = int(n/j)
    k = k*j
print(s)

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
S = input()
T = input()
if set(T)-set(S):
    print(-1)
    exit()
ans = 0
for t in T:
    while True:
        if S[ans]==t:break
        ans+=1
    S+=S
print(ans+1)

### FIXED CODE ###

from bisect import bisect
S = input()
T = input()

NS = len(S)
NT = len(T)
alp = {}
for i in range(26):
    alp[chr(97+i)] = i
D = [[] for i in range(26)]
for i in range(NS):
    D[alp[S[i]]].append(i)
inf = float("inf")
for i in range(26):D[i].append(inf)
k = 0
l = -1
ans = -1
for i in range(NT):
    index = alp[T[i]]
    if D[index] == [inf]:break
    b = bisect(D[index],l)
    if D[index][b]==inf:
        k += 1
        l = D[index][0]
    else:
        l = D[index][b]
    if i==NT-1:ans = k*NS+l+1
print(ans)
R = int(input())
G = int(input())
P = 2G-R
print(P)


### FIXED CODE ###

R = int(input())
G = int(input())
P = 2*G-R
print(P)
X,Y = map(int,input().split())
if Y % 2 == 0 and X * 4 >= Y and if X * 2 <= Y:
    print("Yes")
else 
    print("No")

### FIXED CODE ###

X,Y = map(int,input().split())
if Y % 2 == 0 and X * 4 >= Y and X * 2 <= Y:
    print("Yes")
else:
    print("No")
h,a = map(int,input().split()) 
    print(h,a)

    if(h<a):
        print("1")
    elif(h%a != 0):
        print(h/a+1)
    else:
        print(h/a)

### FIXED CODE ###

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

if(h<a):
  print("1")
elif(h%a != 0):
    print(h//a+1)
else:
    print(h//a)
n,k=map(int,input().split())
s=input()
print(s[k].lower())

### FIXED CODE ###

n,k=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])
k = int(input())
x = 7%k
i = 1
for i in range(0,k+1):
    if x==0:
        print(i)
        break    
        
    l.append(x)
    x = (x*10+7)%k
    i += 1

### FIXED CODE ###

k = int(input())
x = 7%k
i = 1
for i in range(1,k+1):
    if x==0:
        break    
    x = (x*10+7)%k
    i += 1
    
if x == 0:
    print(i)
else:
    print('-1')
import numpy as np
from bisect import *
n, m = map(int, input().split())
A, B, C = zip(*(map(int, input().split()) for _ in range(n)))
D, E, F = zip(*(map(int, input().split()) for _ in range(m)))
X = sorted(set(C + E + F))
Y = sorted(set(A + B + D))
H = len(X)-1
W = len(Y)-1
def TX(i):
    return bisect(X, i)-1
def TY(i):
    return bisect(Y, i)-1
U = np.ones((H+1, W))
for d, e, f in zip(D, E, F):
    d, e, f = TY(d), TX(e), TX(f)
    U[d, e:f] = False
L = np.ones((H, W+1))
for a ,b, c in zip(A, B, C):
    a, b, c = TY(a), TY(b), TX(c)
    L[a:b, c] = False
S = np.outer(np.diff(X), np.diff(Y)) 
i = bisect(Y, 0)-1
j = bisect(X, 0)-1
s = [(i,j)]
v = set()
r = 0
while s:
    i, j = s.pop()
    if (i,j) in v:
        continue
    v.add((i,j))
    if not (0<=i<H and 0<=j<W):
        print('INF')
        break
    r += S[i][j]
    if U[i][j]:
        s.append((i-1,j))
    if U[i+1][j]:
        s.append((i+1,j))
    if L[i][j]:
        s.append((i,j-1))
    if L[i][j+1]:
        s.append((i,j+1))
else:
    print(r)


### FIXED CODE ###

import numpy as np
from numba import njit
from bisect import *
n, m = map(int, input().split())
A, B, C = zip(*(map(int, input().split()) for _ in range(n)))
D, E, F = zip(*(map(int, input().split()) for _ in range(m)))
X = sorted(set(C))
Y = sorted(set(D))
H = len(Y)-1
W = len(X)-1
def TX(i):
    return bisect(X, i)-1
def TY(i):
    return bisect(Y, i)-1
U = np.ones((H+1, W))
for d, e, f in zip(D, E, F):
    #d, e, f = TY(d), TX(e), TX(f)
    d = TY(d)
    e = bisect_left(X, e)
    f = bisect_right(X, f)-1
    U[d, e:f] = False
L = np.ones((H, W+1))
for a ,b, c in zip(A, B, C):
    #a, b, c = TY(a), TY(b), TX(c)
    c = TX(c)
    a = bisect_left(Y, a)
    b = bisect_right(Y, b)-1
    L[a:b, c] = False
S = np.outer(np.diff(Y), np.diff(X))
@njit
def dfs(i, j):
    s = [(i,j)]
    v = np.zeros((H,W))
    r = 0
    while s:
        i, j = s.pop()
        if not (0<=i<H and 0<=j<W):
            return -1
        if v[i,j]:
            continue
        v[i,j] = True
        r += S[i,j]
        if U[i,j]:
            s.append((i-1,j))
        if U[i+1,j]:
            s.append((i+1,j))
        if L[i,j]:
            s.append((i,j-1))
        if L[i,j+1]:
            s.append((i,j+1))
    return r
r = dfs(TY(0), TX(0))
print('INF' if r<0 else r)
s = raw_input()
max0, max1 = -1, -1
cnt = 0
L = []
t = ""
for i in range(len(s)):
    if i == 0:
        t += s[i]
    
    elif s[i] == "0" and s[i-1] == "0":
        t += s[i]
    elif s[i] == "0" and s[i-1] == "1":
        L.append(len(t))
        max1 = max(max1, len(t))
        t = "0" 
        cnt += 1
    elif s[i] == "1" and s[i-1] == "1":
        t += s[i]
    elif s[i] == "1" and s[i-1] == "0":
        max0 = max(max0, len(t))
        t = "1"
        cnt += 1
        L.append(max0)

if t.count("0") == 0:
    max1 = max(len(t))
    L.append(max1)
else:
    max0 = max(len(t))
    L.append(max1)

ans = 0
for i in range(len(L)-1):
    ans = max(ans, (L[i] + L[i+1]))

for i in L:
    print i,

print 
if s.count("0") == len(s) or s.count("1") == len(s):
    print "0"
elif len(s) == 2:
    print "1"
elif cnt == 1:
    print max(ans, 2)
else:
    print ans


### FIXED CODE ###

s = raw_input()

n = ans = len(s)

for i in range(len(s) - 1):
    if s[i] != s[i+1]:
        ans = min(ans, max(i + 1, n - (i + 1)))

print ans
#?????????
N = input()
A = map(int, raw_input().split())
for i in range(len(A)):
    v = A[i]
    j = i - 1
    while (j >= 0) & (A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print ' '.join(map(str, A))

### FIXED CODE ###

def insertionSort():
    N = int(input())
    lst = list(map(int, input().split()))
    
    for i in range(1, N):
        print(*lst)
        v = lst[i]
        j = i - 1
        while j >= 0 and lst[j] > v:
            lst[j+1] = lst[j]
            j -= 1
        lst[j+1] = v
    
    print(*lst)
        
insertionSort()
def m():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    dp = [0] * (N + 1)
    for a in A: dp[a] = -1
    if dp[1] != -1 and dp[2] != -1:
        dp[1] = 1
        dp[2] = 2
    elif dp[1] != -1 and dp[2] == -1:
        dp[1] = 1
    elif dp[1] == -1 and dp[2] != -1:
        dp[2] = 1
    else:
        return 0

    for i in range(3, N + 1):
        if dp[i] == -1:
            continue
        l = dp[i - 2] if dp[i - 2] != -1 else 0
        r = dp[i - 1] if dp[i - 1] != -1 else 0
        dp[i] = (l + r) % MOD
    return dp[N] % MOD


print(m())


### FIXED CODE ###

def m():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    dp = [0] * (N + 1)
    for a in A: dp[a] = -1
    if N == 1:
        if dp[1] != -1:
            return 1
        else:
            return 0
    if dp[1] != -1 and dp[2] != -1:
        dp[1] = 1
        dp[2] = 2
    elif dp[1] != -1 and dp[2] == -1:
        dp[1] = 1
    elif dp[1] == -1 and dp[2] != -1:
        dp[2] = 1
    else:
        return 0

    for i in range(3, N + 1):
        if dp[i] == -1:
            continue
        l = dp[i - 2] if dp[i - 2] != -1 else 0
        r = dp[i - 1] if dp[i - 1] != -1 else 0
        dp[i] = (l + r) % MOD
    return dp[N] % MOD


print(m())
s=input()
m=[0 for i in range(26)]
for i in range(len(s)):
  m[ord(s[i])-97]=1
a=0
for i in range(len(s)):
  if m[i]==0:
    print(chr(i+97))
    a=1
    break
if a==0:
  print("None")

### FIXED CODE ###

s=input()
m=[0 for i in range(26)]
for i in range(len(s)):
  m[ord(s[i])-97]=1
a=0
for i in range(26):
  if m[i]==0:
    print(chr(i+97))
    a=1
    break
if a==0:
  print("None")
s = input()
K = int(input())
substring = []
for i in range(len(s)):
	for j in range(len(s)):
		if s[i:j] != '':
			substring.append(s[i:j])
sub_set = set(substring)
ans = list(sub_set)
ans.sort()
if len(s) > 1:
	print(ans[K-1])
else:
	print(s)

### FIXED CODE ###

s = input()
K = int(input())
substr = set()
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        substr.add(s[i:j])
print(sorted(substr)[K-1])
N, M = map(int, input().split())
A = list(map(int, input().split())

print(max(N - sum(A), - 1))         
         

### FIXED CODE ###

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

print(max(N - sum(A), -1))
r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [input() for _ in range(M)]
dp = [0] * (N+1)

if str(1) in a:
    dp[1] = 0
else:
    dp[1] = 1

if str(2) in a:
    dp[2] = 0
else:
    dp[2] = dp[1] + 1

for i in range(1,N-1):
    if str(i+2) in a:
        dp[i+2] = 0
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])

### FIXED CODE ###

r = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
a = sorted(set(a))

if 1 in a:
    dp[1] = 0
    del a[0]
else:
    dp[1] = 1

if N == 1:
    print(dp[1])
    exit()

if 2 in a:
    dp[2] = 0
    del a[0]
else:
    dp[2] = dp[1] + 1

if N == 2:
    print(dp[2])
    exit()

for i in range(1,N-1):
    if a == [] :
        dp[i+2] = (dp[i] + dp[i+1]) % r
    elif i+2 == a[0]:
        dp[i+2] = 0
        del a[0]
    else:
        dp[i+2] = (dp[i] + dp[i+1]) % r

print(dp[N])
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
    print(" ")
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)



### FIXED CODE ###

X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)
from scipy.sparse import*
from itertools import*
n,m,r = map(int,input().split())
R = [int(i)-1 for i in input().split()]
cost = [[0]*n for i in range(n)]
ans = 10**9
for j in range(m):
  a,b,c = map(int,input().split())
  cost[a-1][b-1] = c
  cost[b-1][a-1] = c

Co = csgraph.shortest_path(csr_matrix(cost))

for v in permutations(R):
  temp = 0
  for i in range(1,r):
    temp += Co[v[i-1]][v[i]]
  ans = min(ans,temp)
print(int(ans))

### FIXED CODE ###

from scipy.sparse import*
from itertools import*
n,m,r = map(int,input().split())
R = [int(i)-1 for i in input().split()]
cost = [[0]*n for i in range(n)]
ans = 10**9
for j in range(m):
  a,b,c = map(int,input().split())
  cost[a-1][b-1] = c
  cost[b-1][a-1] = c

Co = csgraph.floyd_warshall(csr_matrix(cost))

for v in permutations(R):
  temp = 0
  for i in range(1,r):
    temp += Co[v[i-1]][v[i]]
  ans = min(ans,temp)
print(int(ans))
# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(a, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()
A,B = map(int,input().split())
i = 0
X = 0
if(A != B):
    while i <= 1: 
        X += max(A,B)
        i += 1
    print(X-1)
else:
print(A + B)

### FIXED CODE ###

A,B = map(int,input().split())
i = 0
X = 0
if(A != B):
    while i <= 1: 
        X += max(A,B)
        i += 1
    print(X-1)
else:
    print(A + B)
N, M = map(int,input().split())
if 2 * N >= M:
    print(M // 2)
else:
    k = M - 2 * S
    print(S + k // 4)

### FIXED CODE ###

N, M = map(int,input().split())
if 2 * N >= M:
    print(M // 2)
else:
    k = M - 2 * N
    print(N + k // 4)
import math
import copy

inputa = input().split()
inputb = input().split()
inputb = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# a = inputa[0]
# inputList = list(a)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)

b = [int(n) for n in inputb[0]]
c = [int(n) for n in inputc[0]]

sum = 0
for i in range(len(b)):
    if b[i] > c[i]:
       sum += b[i] - c[i]

print(sum)




### FIXED CODE ###

import math
import copy

inputa = input().split()
inputb = input().split()
inputc = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# a = inputa[0]
# inputList = list(a)

# x = int(inputb[0])
# y = int(inputb[1])

# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)

b = [int(n) for n in inputb]
c = [int(n) for n in inputc]

sum = 0
for i in range(len(b)):
    if b[i] > c[i]:
       sum += b[i] - c[i]

print(sum)
s = input()
AKB = KIHBR
tmp = 0
count = 0
for i in range(len(s)):
  if s[i] == "A" and count < 4:
    count += 1
  elif s[i] == AKB[tmp]:
    tmp += 1

if count <= 4 and tmp = 5:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

s = input()
rep = s.replace("A","")

if rep == "KIHBR" and "AA" not in s and "KIH" in s :
  print("YES")
else:
  print("NO")
a=int(input())
if a = 1:
  print(a)
elif a%2 = 0:
  print(1/2)
else:
  print((int(a/2)+1)/a)


### FIXED CODE ###

import math
a=int(input())
b=math.floor(float(a/2))
print(float((a-b)/a))
K = int(input())


if K % 2 == 0:
	print((K//2)**2)
else:
	print((K//2)*((K//2)+1)

### FIXED CODE ###

k = int(input())

if k % 2 == 0:
    print((k//2)**2)
else:
    print((k//2)*((k//2)+1))
import sys
n = int(input())
A = list(map(int, sys.stdin))

cnt = 0
def insertion_sort(L, n, g):
    global cnt
    for i in range(g, n):
        v = L[i]
        j = i - g
        while 0 <= j and v < L[j]:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v


def shell_sort(L, n):
    global G
    for i in G:
        insertion_sort(L, n, i)

G = [i for i in [262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1] if i <= n]
shell_sort(A, n)

print(len(G))
print(' '.join(str(x) for x in G))
print(cnt)
for i in B:
    print(i)

### FIXED CODE ###

import sys
n = int(input())
A = list(map(int, sys.stdin))

cnt = 0
def insertion_sort(L, n, g):
    global cnt
    for i in range(g, n):
        v = L[i]
        j = i - g
        while 0 <= j and v < L[j]:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v


def shell_sort(L, n):
    global G
    for i in G:
        insertion_sort(L, n, i)

G = [i for i in [262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1] if i <= n]
shell_sort(A, n)

print(len(G))
print(' '.join(str(x) for x in G))
print(cnt)
for i in A:
    print(i)
a, b = exec(input().replace(' ', ','))
print(f"{a*b} {2(a+b)}")

### FIXED CODE ###

a, b = eval(input().replace(' ', ','))
print("{} {}".format(a*b, 2*(a+b)))
S = input()

result = []

for i in range(len(S) - 3):
    for j in range(i + 3, len(S)):
        if int(S[i:j+1]) % 2019 == 0:
            result.append([i + 1, j + 1])

print(len(result))


### FIXED CODE ###

S, W = map(int, input().split())

if S > W:
    print("safe")
else:
    print("unsafe")