peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from sys import stdin
import sys
import itertools as it

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
K = int(input())
if C > B and B > A:
    print("Yes")
    sys.exit()
for i in range(K+1):
    c1 = C*(2**i)
    b1 = B*(2**(K-i))
    if c1 > b1 and b1 > A:
        print("Yes")
        sys.exit()
print("No")
# Judge status: Accepted
x=int(input())
for i in range(10**5):
  if 2*x<=(i+1)*i:
    print(i)
    break
# Judge status: Accepted
A,B = list(map(int, input().split()))

ans = 0
#各桁の数字を求める
for i in range(A,B+1):
                if str(i)[0] ==  str(i)[4] and str(i)[1] == str(i)[3]:
                        ans += 1

print(ans)
# Judge status: Accepted
N = int(input())
cnt=0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

for i in range(1,N+1,2):
    if(len(make_divisors(i))==8):
        cnt+=1
        
print(cnt)
# Judge status: Accepted
N, M = map(int, input().split())
H = list(map(int, input().split()))
a = [True] * N
for i in range(M):
  ai, bi = map(int, input().split())
  if H[ai-1] <= H[bi-1] :
    a[ai-1] = False
  if H[ai-1] >= H[bi-1]:
    a[bi-1] = False
print(sum(a))
# Judge status: Accepted
A,B = map(int,input().split())

ans = 0
for i in range(2):
    if A >= B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

print(ans)
# Judge status: Accepted
n,q = map(int,input().split())
s = input()
cnt = [0] * (n+1)
for i in range(n):
    if s[i:i+2] == "AC":
        cnt[i+1] = cnt[i] + 1
    else:
        cnt[i+1] = cnt[i]
for i in range(q):
    l,r = map(int,input().split())
    print(cnt[r-1]-cnt[l-1])
# Judge status: Accepted
n,a,b=map(int,input().split())
mod=10**9+7

def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1 
  return ans

N=pow(2,n)
def comb(c,d):
  x=1
  for i in range(d):
    x=x*(c-i)%mod
  y=1
  for i in range(d):
    y=y*(i+1)%mod
  return x*pow(y,mod-2)%mod
A=comb(n,a)
B=comb(n,b)
print((N-A-B-1)%mod)
# Judge status: Wrong Answer
S=input()
L=[0]*(len(S)+1)
#print(L)
for i in range(len(S)-1):
  if S[i]=='<':
    L[i+1]=max(L[i+1],L[i]+1)
for i in range(len(S)-1,-1,-1):
  if S[i]=='>':
    L[i]=max(L[i],L[i+1]+1)
print(sum(L))
# Judge status: Accepted
n,m,x,y = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

x_max = max(X)
y_min = min(Y)

for i in range(x+1,y+1):
  if x_max < i and y_min >= i:
    print("No War")
    exit()

print("War")
# Judge status: Wrong Answer
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
loop = []
now = 1
while not now in loop:
    loop.append(now)
    now = a_list[now - 1]
loop_start_index = loop.index(now)
print(loop[loop_start_index + (k - loop_start_index) % (len(loop) - loop_start_index)])
# Judge status: Accepted
print "Yes" if len(set(raw_input()))!=1 else "No"
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = []
for i in range(K, N):
    ans.append(['No', 'Yes'][A[i] > A[i - K]])

print('\n'.join(ans))
# Judge status: Accepted
a, b,c, k = map(int, input().split())
x = b - a
if k % 2 == 0:
    print(-x)
else:
    print(+x)
# Judge status: Accepted
s = input()

m = int(s[5] + s[6])

if m >= 5:
  print("TBD")

else:
  print("Heisei")
# Judge status: Wrong Answer
N = int(input())

a = N
for i in range(N):
  cc = 0
  t = i
  while t > 0:
    cc += t%6
    t //= 6
  t = N - i
  while t > 0:
    cc += t%9
    t //= 9
  if a > cc:
    a = cc
    
print(a)
# Judge status: Accepted
def main():
    n = int(input())
    cards = []
    for _ in range(n):
        cards.append(int(input()))
    cards.append(0)
    answer = 0
    tmp = 0
    for i in range(n + 1):
        if cards[i]:
            tmp += cards[i]
        else:
            answer += tmp // 2
            tmp = 0
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, border = map(int, input().split())

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

count = 0
for  i in range(n):
    if(boxes[i] > border):
        count += boxes[i] - border
        boxes[i] = border

for i in range(n-1):
    if(boxes[i] + boxes[i+1] > border):
        count += boxes[i] + boxes[i+1] - border
        boxes[i+1] -= boxes[i] + boxes[i+1] - border
        
print(count)
# Judge status: Wrong Answer
n=int(input())

if n==1:
  print(2)
elif n==2:
  print(1)
else:
  ans=0
  num_1=2
  num_2=1
  for i in range(n-1):
    ans = num_1+num_2
    num_1,num_2 = num_2, ans
  print(ans)
# Judge status: Accepted
words = ['maerd', 'remaerd', 'esare', 'resare']
S = input()
T = ''
for a in S[::-1]:
  T += a
  for s in words:
    if T == s:
      T = ''
print('YES' if T == '' else 'NO')
# Judge status: Accepted
# -*- coding: utf-8 -*-

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

cnt = 0

for i in range(1, n-1):
    if sorted(p[i-1:i+2])[1] == p[i]:
        cnt += 1

print(cnt)
# Judge status: Accepted
n = int(input())

for i in range(26):
    for j in range(15):
        if 4*i + 7*j == n:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
def main():
    S = [s for s in input()]
    T = [t for t in input()]
    S.sort()
    T.sort(reverse=True)
    if S < T:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
alpha = input()
a_code = ord('a')
z_code = ord('z')
alpha_code = ord(alpha)
if alpha_code >= a_code and alpha_code < z_code:
	next_alpha_code = alpha_code + 1
	next_alpha = chr(next_alpha_code)
	print(alpha + 'の次は' + next_alpha + 'です。')
else:print('a ~ yを入力してください')
# Judge status: Wrong Answer
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
count = 0
for i in range(N-3):
    if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]:
        count += 1
        print("Yes")
        break

if count == 0:
    print("No")
# Judge status: Accepted
N,M = map(int,input().split())
ans = [0]*M
for i in range(N):
    KA = list(map(int,input().split()))
    for j in range(1,len(KA)):
        ans[KA[j]-1] += 1
print(ans.count(N))
# Judge status: Accepted
import collections

n = int(input())
l = list(map(int,input().split()))
c = collections.Counter(l)

count = 0

for i,j in c.items():
    
    if i < j:
        count += j-i
    elif i > j:
        count += j
print(count)
# Judge status: Accepted
K,A,B = map(int,input().split())
ans = 1+K
rem = K-(A-1)
ans2 = A + rem%2 + (rem//2)*(B-A)
print(max(ans, ans2))
# Judge status: Accepted
a=list(input())
b=list(input())
c=list(input())

a.append('A')
b.append('B')
c.append('C')

def f(s):
  if len(s)>1:
    va=s[0]
    del s[0]
    if va=='a':
      f(a)
    elif va=='b':
      f(b)
    else:
      f(c)
  else:
    return print(s[0])
f(a)
# Judge status: Wrong Answer
import numpy as np
N,K = map(int,input().split())
an = list(map(int,input().split()))

min_an_index = np.argmin(an)

a = min_an_index
b = N - min_an_index - 1

a1 = a // (K-1)
if a % (K-1) != 0:
    a1 += 1
    
b1 = b // (K-1)
if b % (K-1) != 0:
    b1 += 1

count = a1 + b1
print(count)
# Judge status: Wrong Answer
import bisect
n=int(input())
a=[0]+sorted(list(map(int,input().split())))
x=a[-1]
i=bisect.bisect_left(a,x//2)
if abs(a[i]-x)>abs(a[i-1]-x):y=a[i-1]
elif i==n:y=a[i-1]
else:y=a[i]
print(x,y)
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())
ans = 0

while True:
    if h >= w:
        n = n - h
    else:
        n = n - w

    ans = ans + 1

    if n <= 0:
        break

print(ans)
# Judge status: Accepted
n = list(input())

for i in range(len(n)):
    for j in range(i,len(n)):
        tmp = n[:]
        del tmp[i:j]
        if ''.join(tmp) == 'keyence':
            print('YES')
            exit()
else:
    print('NO')
# Judge status: Wrong Answer
r,k = map(int,input().split())
b = [i for i in map(int,input().split())]
s = set(b)

if len(s) <= k:
    print(0)
else:
    n = [b.count(i) for i in s]
    n.sort()
    ans = 0
    for i in range(len(s)-k):
        ans += n[i]
        print(n[i])
    print(ans)
# Judge status: Wrong Answer
X, N = map(int, input().split())
if (N == 0):
  print(X)
else:
  nums = list(map(int, input().split()))
    
  nums.sort()
  low = nums[0]
  high = nums[-1]
  minDiff = 100000000
  minNum = -1
  for i in range(1, 101):
    if i in nums:
      continue
    else:
      Dif = abs(X-i)
    if (Dif < minDiff):
      minDiff = Dif
      minNum=i

  if (minNum == -1):
    print(X)
  else:
    print(minNum)
# Judge status: Accepted
x,k,d = map(int,input().split())
x = abs(x)
if x//d > k:
  print(x-k*d)
elif (k-x//d)%2 == 0:
  print(x%d)
else:
  print(d-x%d)
# Judge status: Accepted
a,b = input().split()
c = int(a)
d = round(float(b)*100)
print(c*d//100)
# Judge status: Accepted
def main():
    s = input()
    k = int(input())
    r = '1'
    for i,v in enumerate(s):
        if v != '1':
            r = v
            break
    if i >= k:
        print(1)
    else:
        print(r)
    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a,b,c =map(int,input().split())

print((a-1)//(b+c))
# Judge status: Wrong Answer
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
S = []
S = list(input())
JS = 0
AS = 0
OT = 0

for i in range(N):
  print(S[i])
  if S[i] == 'a':
    JS += 1
  elif S[i] == 'b':
    AS += 1
  elif S[i] == 'c':
    OT += 1
  
  if S[i] == 'a' and A + B >= (JS + AS):
    print('Yes')
  elif S[i] == 'b' and A + B >= (JS + AS) and AS <= B:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
#ARC069-C
n,m = map(int,input().split())
if n*2 <= m:#cのほうが多いとき
    print((n*2 + m)//4)
else:
    print(m//2)
# Judge status: Wrong Answer
def resolve():
    s = input()

    def dfs(i, f):
        if i == 3:
            return f.split(",")
        return dfs(i+1, f + "+" + s[i+1]) + dfs(i+1, f + "-" + s[i-1])
    for i in dfs(0, s[0]):
        if eval(i) == 7:
            print(i + "=7")
            exit()
resolve()
# Judge status: Accepted
S=list(map(int,input().split()))
while True:
  S[2]=S[2]-S[1]
  S[0]=S[0]-S[3]
  if S[2]<=0:
    print("Yes")
    break
  elif S[0]<=0:
    print("No")
    break
# Judge status: Accepted
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
s = 0
cnt = 0

for i in range(n-m+1):
    for j in range(n-m+1):
        for x in range(m):
            for y in range(m):
                if a[i+x][j+y] == b[x][y]:
                    s += 1
        if s == m ** 2:
            cnt += 1
        else:
            s = 0
if cnt > 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def solve(n, m):

    ans = len([i for i in range(n, m+1) if str(i)[:2] == str(i)[:-2]])
    return ans

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(solve(n, m))
# Judge status: Accepted
N = int(input())
A=input().split()

s=int(A[0])//N
if int(A[0])%N==0:
    print('OK')
else:
    if (s+1)*N>int(A[1]):
        print('NG')
    else:
        print('OK')
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
tmp = 0

for i in range(n):
    ans += 1
    if a[tmp] == 2:
        break;
    tmp = a[tmp] - 1
if ans == 0:
    ans = -1

print(ans)
# Judge status: Accepted
N = int(input())

for x in range(1, 10):
    if N%x == 0:
        y = N//x
        if 1 <= y <= 9:
            print('Yes')
            break
else:
    print('No')
# Judge status: Accepted
from collections import Counter
n, k = map(int, input().split())
d = Counter([])
for i in range(n):
    a, b = map(int, input().split())
    d[a] += b
ans = 1
cnt = 0
while cnt < k:
    cnt += d[ans]
    ans += 1

print(ans - 1)
# Judge status: Wrong Answer
N = int(input())

print(20*800 - 20//15*200)
# Judge status: Wrong Answer
S = input()
T = input()

ans = len(T)

for i in range(len(T)):
    for j in range(i + 1, len(T) + 1):
        if T[i:j] in S[i:]:
            if len(T) - len(T[i:j]) < ans:
                ans = len(T) - len(T[i:j])

print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
print(int((b-a)*(b-a+1)/2-b))
# Judge status: Accepted
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list("x" * K + input())

win = {"r":P,"s":R,"p":S}

ans = 0
for i in range(K, len(T)):
  if T[i] == T[i - K]:
    T[i] = "x"
  else:
    ans += win[T[i]]

print(ans)
# Judge status: Wrong Answer
n, k = list(map(int,input().split()))
arr = list(map(int,input().split()))
arr = list(set(arr))
print(max(0,k - len(arr) ) )
# Judge status: Accepted
n=int(input())
for i in range(1,10):
    for j in range(1, 10):
        if i*j==n:
            print("Yes")
            exit(0)
print("No")
# Judge status: Accepted
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])

if s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 1:
    print('MMYY')
elif s2 <= 12 and s2 >= 1:
    print('YYMM')
else:
    print('NA')
# Judge status: Wrong Answer
x = int(input())

if x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)
elif 600 <= x < 800:
    print(5)
elif 1200 <= x < 1400:
    print(4)
elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
else:
    print(1)
# Judge status: Accepted
a, b, c = map(int, input().split())
flag = False
for i in range(b):
    if a*i % b == c:
        flag = True
        break
print('YES' if flag else 'NO')
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
# 標準入力複数
# print(a, b, c, d)
if a - b <= 3 and b - c <= 3:
    print("Yes")
elif b - a <= 3 and c - b <= 3:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
h1,m1,h2,m2,k = map(int, input().split())

bt = h1*60 + m1
at = h2*60 + m2

time = at - bt

print(time-k)
# Judge status: Wrong Answer
n = int(input())
s = input()
c = 0
for k in range(n):
  for j in range(n-1):
    for i in range(n-2):
      if s[k] != s[j] and s[j] != s[i] and s[i] != s[k]:
        if j - k != k - j:
          c += 1
print(c)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(n):
  if i%2 == 0:
    ans.append(a[i])
  else:
    ans.insert(0,a[i])
for an in ans:
  print(an,end=' ')
# Judge status: Accepted
n = int(input())
li = list(input())

R = li.count("R")
G = li.count("G")
B = li.count("B")

cnt = 0

for i in range(n-1):
    for j in range(i+1, n):
        if 2*j - i > n-1:
            continue
        if li[i] != li[j]:
            if li[2*j-i] != li[i] and li[2*j-i] != li[j]:
                cnt += 1
print(R*G*B - cnt)
# Judge status: Wrong Answer
a = str(input())
b = str(input())
if a[1] == b[1] and a[0] == b[2] and a[2] == b[0]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from itertools import accumulate

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

sa = list(accumulate(a))
mod = 10 ** 9 + 7
ans = 0
for i in range(n - 1):
    ans += a[i] * (sa[-1] - sa[i])
    ans %= mod
print(ans)
# Judge status: Accepted
X=int(input())

def is_prime(n):
    for i in range(2,n+1):
        if i*i >n:
            break
        if n%i==0:
            return False
    return True

for i in range(1000):
    A=is_prime(X+i)
    if A==True:
        print(X+i)
        break
# Judge status: Wrong Answer
N = int(input())
S = input()
C = [0] * (N + 1)

for i in range(N):
    if S[i] == '#':
        C[i + 1] = C[i]  + 1
    else:
        C[i + 1] = C[i]


# print(C)

j = N
count = 0
while j > 0:
    jj = j - 1
    while jj >= 0 and C[jj] == C[j]:
        jj -= 1
    
    if jj >= 0 and jj < j - 1:
        count += j - jj - 1

    # print(j, jj)
    j = jj

print(count)
# Judge status: Wrong Answer
a=int(input())
print(a+a**+a*a*a)
# Judge status: Accepted
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)
# Judge status: Accepted
import numpy as np
from numba import njit

N, K = map(int, input().split())
A = np.array((list(map(int, input().split()))), dtype=np.int64)

@njit
def imos(A):
    B = np.zeros(N, dtype=np.int64)
    for i,x in enumerate(A):
        a = max(0, i-x)
        b = min(i+x, N-1)
        B[a] += 1
        if b+1 <= N-1:
            B[b+1] -= 1
    B = np.cumsum(B)
    return B

for i in range(K):
    if i >= 50:
        break
    A = imos(A)
print(*A)
# Judge status: Wrong Answer
import collections

N=int(input())
A=list(map(int, input().split()))
c = collections.Counter(A)
sum=0
for i, j in c.items():
    sum+=j*(j-1)//2

for i in A:
        b = c[i]
        if b >= 2:
            print(sum-b*(b-1)//2+(b-1)*(b-2)//2)
        else:
            print(0)
# Judge status: Wrong Answer
n,k=map(int,input().split())
l=[]
for i in range(n):
  v=int(input())
  l.append(v)
tmp=l[n-1]
for j in range(n-k+1):
  tmp=min(tmp,l[j+k-1]-l[j])
print(tmp)
# Judge status: Wrong Answer
x = int(input())
t = int(x ** 0.5)
min_d = int(t * 0.5 * (t + 1))
if min_d == x:
  print(t)
elif (min_d + 2) <= x:
  print(t + 2)
else:
  print(t + 1)
# Judge status: Accepted
from collections import defaultdict


def create_id(p, o):
    return str(p).zfill(6) + str(o).zfill(6)


n, m = [int(i) for i in input().split()]
db = defaultdict(list)
for i in range(m):
    p, y = [int(i) for i in input().split()]
    db[p].append((y, i))

ans = [None] * m
for p in db:
    db[p].sort()
    for i in range(len(db[p])):
        ans[db[p][i][1]] = create_id(p, i + 1)
print(*ans, sep="\n")
# Judge status: Accepted
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j]=0

ans='No'
#tate
for i in range(3):
  if a[0][i]+a[1][i]+a[2][i]==0:
    ans='Yes'
#yoko
for i in range(3):
  if sum(a[i])==0:
    ans='Yes'
#naname
if a[0][0]+a[1][1]+a[2][2]==0 or a[0][2]+a[1][1]+a[2][0]==0:
  ans='Yes'
print(ans)
# Judge status: Accepted
z=int(input())
#1と6の時は5
#他はすべて6出せる。
#つまり基本的には6,5,6,5,6,,,,と続けられます。
#11で割ってあげた余りが6より大きいか小さいかで5を追加するか考える。

ans=z//11
if z-(ans*11)==0:
  print(ans*2)
elif z-(ans*11)>6:
  print(ans*2+2)
else:
  print(ans*2+1)
# Judge status: Wrong Answer
N=int(input())
list=input().split()
for all in list:
    all=int(all)
flag=False
c=0
x="YES"
leng=len(list)
for i in range(leng-1):
    if list[i]>list[i+1]:
        c=c+1
        t=list[i]
        list[i]=list[i-1]
        list[i-1]=t
        print(list)      
    if c==2:
        x="NO"
        break
print(x)
# Judge status: Wrong Answer
def fact(n,mod):
  ret=1
  for i in range(2,n+1):
    ret=(ret*i)%mod
  return ret

def pCq(p,q,mod):
  pCq=1
  for i in range(q):
    pCq*=p-i
    pCq=pCq%mod
  den=fact(q,mod)
  inv=pow(den,mod-2,mod)
  pCq=(pCq*inv)%mod
  return pCq

X,Y=map(int,input().split())
MOD=10**9+7
ans=0
n,m=2*X-Y,2*Y-X
if n%3==0 and m%3==0:
  n//=3
  m//=3
  ans+=pCq(m+n,min(m,n),MOD)
print(ans)
# Judge status: Accepted
import itertools
N, M, Q = map(int, input().split())
Qs = [list(map(int, input().split())) for _ in range(Q)]

_max = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    score = sum([q[3] for q in Qs if A[q[1] - 1] - A[q[0] - 1] == q[2]])
    _max = score if _max < score else _max
print(_max)
# Judge status: Wrong Answer
N,x=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
for i in range(N-1,-1,-1):
  gap=A[i]+A[i-1]-x
  if gap>0:    
    cnt+=gap
    A[i]-=gap
print(cnt)
# Judge status: Accepted

url = "https://atcoder.jp//contests/abc072/tasks/arc082_b"

def main():
    n = input()
    p = list(map(int, input().split()))
    count = 0
    for i, v in enumerate(p):
        if i == len(p)-1 and i+1 == v:
            count += 1
            break
        if i+1 == v:
            p[i] = p[i+1]
            p[i+1] = v
            count += 1
    print(count)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
s = list(input())
x = 0
ans = 0
for i in range(n):
  if s[i] == "I":
    x += 1
  else:
    x -= 1
  ans = max(ans,x)
print(ans)
# Judge status: Accepted
A,B = map(int,input().split())
if max(A,B) > min(A,B):
    ans = max(A,B)*2-1
else:
    ans = A*2
print(ans)
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())

c = 0
count = 0
while(True):
    c += max(h,w)
    count += 1
    if c>=n:
        break
    if h >= w:
        w -= 1
    else:
        h -= 1
        
print(count)
# Judge status: Accepted
from collections import Counter
lim=10**9+7
N=int(input())
S=input()
d=Counter(S)
ans = 1
for s in d.keys():
    ans = (ans*(d[s]+1))%lim
    #print(ans)
print(ans-1)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
if len(A)==len(set(A)):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
X = int(input())
d, v = divmod(X, 500)
print(d * 1000 + v * 5)
# Judge status: Accepted
n,a,b,c,d = map(int, input().split())
s = input()

long_s = s[a-1:max(c,d)]
short_s = s[b-2:min(c,d)+1]
rocks = long_s.count("##")
change = short_s.count("...")

if rocks >= 1:
  print("No")
elif c > d and change == 0:
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
import bisect
N,M,K= map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

dpA = [0]*(N+1)
dpB = [0]*(M+1)

for i in range(1,N+1):
    dpA[i] = dpA[i-1] + A[i-1]

for i in range(1,M+1):
    dpB[i] = dpB[i-1] + B[i-1]

ans = 0
for i in range(1,N+1):
    if dpA[i] > K:
        continue
    indexB = bisect.bisect_right(dpB, K - dpA[i])
    ans = max(ans, i + indexB - 1)

print(ans)
# Judge status: Accepted
from collections import defaultdict

s = input()
t = input()

in_deg = defaultdict(set)
out_deg = defaultdict(set)

for es, et in zip(s, t):
    out_deg[es].add(et)
    in_deg[et].add(es)

in_deg_mx = max(map(len, in_deg.values()))
out_deg_mx = max(map(len, out_deg.values()))

if in_deg_mx <= 1 and out_deg_mx <= 1:
    ans = "Yes"
else:
    ans = "No"

print(ans)
# Judge status: Wrong Answer
R = list()
L = list()
N = int(input())
R.append(0)
for i in range(N):
    k = int(input())
    L.append(k)
    if k == 0:
        R.append(len(L))
R.append(N)
S = sum(L)
for i in range(len(R) - 1):
    if sum(L[R[i] + 1 : R[i + 1]]) % 2 == 1:
        S = S - 1
print(S // 2)
# Judge status: Wrong Answer
N,M=map(int,input().split())
N,M=min(N,M),max(N,M)

if N==1:
    print(M-2)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
X,Y=map(int,input().split())

print(X+(Y//2))
# Judge status: Wrong Answer
s = input()
for i in s:
  if i == 'L' and s.index(i)%2 == 0:
    print('No')
  elif i == 'R' and s.index(i)%2 == 1:
    print('No')
  else:
    print("Yes")
# Judge status: Accepted
N,M=map(int,input().split())
A=[]
B=[]
C=[]
D=[]
for i in range(N):
	x,y=map(int,input().split())
	A.append(x)
	B.append(y)
for i in range(M):
	x,y=map(int,input().split())
	C.append(x)
	D.append(y)
for i in range(N):
	ans=[]
	for j in range(M):
		tmp=abs(A[i]-C[j])+abs(B[i]-D[j])
		ans.append(tmp)
	T=len(ans)
	for k in range(T):
		if ans[k]==min(ans):
			print(k+1)
			break
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
l = list(map(lambda x:int(x)*-1, input().split()))
heapq.heapify(l)

for _ in range(m):
  a = heapq.heappop(l)
  heapq.heappush(l, a * (-1) // 2 * (-1))
  
print(sum(l)*-1)
# Judge status: Accepted
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

res = []
for i in range(m-1):
  res.append(x[i+1]-x[i])
res.sort()

ans = 0
for i in range(m-n):
  ans += res[i]
print(ans)
# Judge status: Accepted
from fractions import gcd
N=int(input())
A=list(map(int, input().split()))

for i in range(N-1):
    if i==0:
        G=gcd(A[0],A[1])
    else:
        G=gcd(G,A[i+1])

print(G)