peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from itertools import combinations
n = int(input())
s = input()
count = 0
list1 = []
list = []
list2= []
for i in range(1, len(s)+1):
    list.append(i)
for c in combinations(list, 3):
    list1.append(c)
for item in list1:
    if (item[1]-item[0]) != (item[2]-item[1]):
        list2.append(item)
        for k in list2:
            if s[k[0] - 1] != s[k[1] - 1] and s[k[0] - 1] != s[k[2] - 1] and s[k[1] - 1] != s[k[2] - 1]:
                count = count + 1
print(count)
# Judge status: Accepted
import math
from decimal import Decimal
A, B = input().split()
A = int(A)
B = Decimal(B)
C = A * B
ans = math.floor(C)
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
if n==1 and m==1:
    print(0)
elif n==1:
    print(m-2)
elif m==1:
    print(n-2)
else:
    print(n*m-(2*n+2*m-4))
# Judge status: Accepted
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    sx,sy,tx,ty=map(int,readline().split())

    ans=""
    u=ty-sy
    v=tx-sx
    a=u*"U"
    b=v*"R"
    c=u*"D"
    d=v*"L"
    ans+=a+b+c+d
    ans+="L"+a+"U"+b+"R"+"D"
    ans+="R"+c+"D"+d+"L"+"U"
    print(ans)

if __name__=="__main__":
    main()
# Judge status: Accepted
N = int(input())
b = 0
c = 0
first = 0
A = []
for i in range(N):
    a = int(input())
    if b < a:
        ind = i
        b = a
    A.append(a)
for j in range(N):
    if j==ind:
        continue
    if c < A[j]:
        sind = j
        c = A[j]
for k in range(N):
    if k==ind:
        print(c)
    else:
        print(b)
# Judge status: Wrong Answer
T=input()

T=list(T)

for i in range(len(T)):
    j=int(i)
    if T[j]=='?':
        T[j]='D'
"".join(T)
print(T)
# Judge status: Accepted
import fractions
n,x = map(int,input().split())
s = set(map(int,input().split()))
s.add(x)
l = list(s)
l.sort()
for i in range(len(l)-1):
  if i == 0:
    y = l[1]-l[0]
  else:
    y = fractions.gcd(l[i+1]-l[i],y)
print(y)
# Judge status: Wrong Answer
a1=input()
a2=[i for i in a1.split()]
x,y=float(a2[0]),float(a2[1])
v,v1=x.is_integer(),y.is_integer()
if 1<=(x and y)<=20 and v==v1==True:
    if 1<=(x and y)<=9:
        print(int(x*y))
    else:
        print('-1')
# Judge status: Accepted
x=input()
if(x=="0"):
  print(1)
else:
  print(0)
# Judge status: Accepted
X=int(input())
for i in range(-500,500):
    for j in range(-500,500):
        if i**5-j**5==X:
            print(i,j)
            exit()
# Judge status: Accepted
k, x = map(int, input().split())
if 500*k >= x:
	print("Yes")
else:
	print ("No")
# Judge status: Wrong Answer
import numpy as np
import math

N = int(input())

X=[]
for i in range(N):
    X.append(list(map(int, input().split())))
X = np.array(X)

gokei = 0
for i in range(N):
    for j in range(i+1, N):
        gokei += np.linalg.norm(X[i]-X[j])
        print(gokei)
if N == 2:
    A = 2
else:
    A = math.factorial(N-2)*4
print(gokei*A/math.factorial(N))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 0
for a in A:
    ans ^= a
#print(ans)
for a in A:
  	print(ans^a)
# Judge status: Accepted
n=int(input())
v=list(map(int,input().split()))
ans=0
while len(v) != 1:
  a=min(v)
  v.remove(a)
  b=min(v)
  v.remove(b)
  ans=(a+b)/2
  v.append(ans)


print(ans)
# Judge status: Accepted
A,B  = map(int, input().split())
print(max(A,B)+ max(max(A,B)-1,min(A,B)))
# Judge status: Accepted
n, k =map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
ans = 10000000000000000
#print(h)
for i in range(n-k+1):
    if h[i+(k-1)] - h[i] <= ans:
        ans = h[i+(k-1)] - h[i]
print(ans)
# Judge status: Accepted
s = input()
a = ['R', 'U', 'D']
b = ['L', 'U', 'D']

def judge():
    for i in range(len(s)):
        if i%2==0 and s[i] not in a:
            return False
        if i%2==1 and s[i] not in b:
            return False
    return True

if judge():
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s = input()

i = 0
lst = []
for j in range(1,len(s)+1):
    if not(s[i:j] in lst):
        lst.append(s[i:j])
        i = j

print(len(lst))
# Judge status: Accepted
import math

def calcEnergy(goal, curr):
  return (curr - goal) * (curr - goal)

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

xs = x.copy()
xl = x.copy()

av = (int(sum(x)/n))

for i in range(n):
  xs[i] = calcEnergy(av, xs[i])
  xl[i] = calcEnergy(av + 1, xl[i])

small = sum(xs)
large = sum(xl)
if(small < large):
  print(small)
else:
  print(large)
# Judge status: Wrong Answer
s1 = list(input())
s2 = s1

n = len(s1)
c = 0
d = 0
for i in range(n-1):
    if s1[i]==s1[i+1]:
        s1[i+1] = abs(1-int(s1[i]))
        c += 1
"""
print("=====================")
for i in range(n-1,0,-1):
    print(s2)
    if s2[i] == s2[i-1]:
        s2[i-1] = abs(1-int(s2[i]))
        d += 1
"""    
print(c)
"""
else:
    print(2,d)
"""
# Judge status: Wrong Answer
A = int(input())
B = int(input())

if (A + B == 3):
    print(3)
elif (A + B == 4):
    print(2)
else:
    print(3)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]%2==1:
        pass
    else:
        if a[i]%3==0 or a[i]%5==0:
            pass
        else:
            print("DENIED")
            exit()
print("APPROVED")
# Judge status: Accepted
s=list(input())
ans=str()

for i in s:
    if i=="0":
        ans+="0"
    elif i=="1":
        ans+="1"
    elif i=="B":
        ans=ans[:-1]
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
x = 0
ans = 0
for s in s:
    if s == 'I':
        x += 1
    else:
        x -= 1
    ans = max(x, ans)
print(ans)
# Judge status: Wrong Answer
s = input().split()
print("safe" if s[0] > s[1] else "unsafe")
# Judge status: Accepted
N,A,B,C,D=map(int,input().split())
S=input()
if "##" in S[A-1:max(C,D)] or ("..." not in S[B-2:min(C,D)+1] and C>D):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n, m = map(int, input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
ans = [-1 for _ in range(n)]
ans[0] = 0
tree=[[]for _ in range(n)]
for a,b in ab:
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
visited={0}
q=[0]
for i in q:
    for j in tree[i]:
        if ans[j] < 0:
            q.append(j)
            ans[j]=i+1
print("Yes")
for i in ans[1:]:
    print(i)
# Judge status: Accepted
S = list(input())

if S[0] != "A":
  print("WA")
elif S[2:-1].count("C") != 1:
  print("WA")
elif sum([s.islower() for s in S])+2 != len(S):
  print("WA")
else:
  print("AC")
# Judge status: Wrong Answer
N = int(input())
count = 0
num = set([])

for i in range(N):
    tmp = int(input())
    if tmp not in num:
        num.add(tmp)
    else:
        count += 1

print(len(num) - count)
# Judge status: Accepted
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

import itertools
for i,A in enumerate(itertools.permutations( [i for i in range(1,N+1)] )):
  if A==P:
    a=i+1
  if A==Q:
    b=i+1
print(abs(b-a))
# Judge status: Accepted
N, M = map(int, input().split())
c = [0 for i in range(N+1)]
for x in range(M):
    L, R = map(int, input().split())
    c[L-1] += 1
    c[R] -= 1
r = 0
t = 0
for x in c[:-1]:
    t += x
    if t == M:
        r += 1
print(r)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
k = int(input())

d = max(a,b,c)

print(d*2*k+a+b+c-d)
# Judge status: Accepted
s = input()
res = "Good"
for i in range(1,len(s),1):
    if s[i-1] == s[i]:
        res = "Bad"
print(res)
# Judge status: Accepted
A = [int(i) for i in input().split()]
A.sort()
s,m,l = A
count = 0
ls = l-s
lm = l-m
count += ls//2
count += lm//2
if ls%2 == 0 and lm%2 == 0:
  print(count)
  exit()
elif ls%2 == 1 and lm%2 == 1:
  count += 1
  print(count)
else:
  count += 2
  print(count)
# Judge status: Accepted
s = int(input())

x1 = 10**9
y1 = 1
x2 = (10**9 - s%10**9)%10**9
y2 = (s+x2) // 10**9

print(0, 0, x1, y1, x2, y2)
# Judge status: Wrong Answer
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0
for i in range(min(X//500,A)):
  for j in range(min(X//100,B)):
    for k in range(min(X//50,C)):
      if X-500*i-100*j-50*k==0:
        ans+=1
print(ans)
# Judge status: Accepted
n,x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0

for i in range(n):
    x -= a[i]
    if (x < 0):
        print(i)
        break
else:
    if (x != 0):
        print(n - 1)
    else:
        print(n)
# Judge status: Accepted
S = input()
K = int(input())
alp = '0bcdefghijklmnopqrstuvwxyza'
alp_dict = {s:i for i,s in enumerate(alp)}


cnt = 0
ans = ''
for i,s in enumerate(S):
  if cnt + (26-alp_dict[s]) <= K:
    cnt += (26-alp_dict[s])
    ans += 'a'
  else:
    ans += s

if (K-cnt)%26==0:
  print(ans)
else:
  rest = (K-cnt)%26
  print(ans[:-1]+alp[(alp_dict[ans[-1]]+rest)%26])
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
diff = []
s_1 = 0
s_2 = sum(W)

for i in range(N):
    s_1 += W[i]
    s_2 -= W[i]
    diff.append(abs(s_1 - s_2))

print(min(diff))
# Judge status: Accepted
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = sorted(LIST(), reverse=True)

h = 0
w = 0
reg = n-1
for i in range(n-1):
   if a[i] == a[i+1]:
        h = a[i]
        reg = i
        break
for i in range(reg+2, n-1):
   if a[i] == a[i+1]:
        w = a[i]
        break

print(h*w)
# Judge status: Accepted
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
ans = 0
for i in c:
    if i<=c[i]: ans += c[i]-i
    else: ans += c[i]
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
 
l = [0]*N
for i in range(N):
  l[A[i]-1] = str(i+1)

ans = ''
for i in range(N):
  ans += (l[i] + ' ')
  
print(ans)
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
x = -1
s = ""
for i in h:
    if x>=i:
        s+="1"
    else:
        s+="0"
    x=i
print(max([len(s) for s in s.split("0")]))
# Judge status: Accepted
import sys
input = sys.stdin.readline
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort(reverse = True)
t = []
for _ in range(X): t.append(p.pop())
for _ in range(Y): t.append(q.pop())
t.sort()
for i in range(min(C, X + Y)):
  if t[i] < r[i]: t[i] = r[i]
print(sum(t))
# Judge status: Wrong Answer
n,m = map(int,input().split())
if n==1 or m==1:
  print(max(max(m,n)-2,0))
else:
  n = n-2
  m = m-2
  print(n*m)
# Judge status: Accepted
# 3個のパックにそれぞれ、a,b,c個のキャンディーが入っている
# キャンディーを2人に分ける際、個数が等しくなるか判定

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

# 処理
if a == b + c or b == a + c or c == a + b:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s=input()
ans1,ans2=0,0
for i in range(0,len(s)-1,2):
    if s[i]!="1":
        ans1+=1
    if s[i+1]!="0":
        ans1+=1
for i in range(0,len(s)-1,2):
    if s[i]!="0":
        ans2+=1
    if s[i+1]!="1":
        ans2+=1
print(min(ans1,ans2))
# Judge status: Accepted
n = int(input())
m = 1000000000000000000
num_list = [ int(v) for v in input().split() ]
ans = 1
s = 0
if 0 in num_list:
	ans = 0
for i in num_list:
	ans *= i
	if ans > m:
		s = 1
		break
if s == 0:
	print(ans)
else:
  	print(-1)
# Judge status: Accepted
n=int(input())
i=0
while n > 0:
   i+=n
   n-=1
print(i)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
t = [0] * 9

for i in range(n):
    if a[i] < 3200:
        t[a[i] // 400] += 1
    else:
        t[8] += 1

z = t.pop(8)
p = t.count(0)
amax = min(8,8-p+z)
if p == 8:
    amin = 1
else:
    amin = 8 - p

print(amin,amax)
# Judge status: Accepted
n=int(input())
if n<1000:
    print("ABC")
else:
    print("ABD")
# Judge status: Wrong Answer
N, x = map(int,input().split())

al = list(map(int,input().split()))

al.sort()

cnt = 0

for a in al:

  x -= a

  if x < 0:

    break

  cnt += 1

if x != 0 and cnt >= 1:
  print(cnt-1)
else:
  print(cnt)
# Judge status: Wrong Answer
r = int(input())
s =  r*r*3.14
b = s / 3.14
print(int(b))
# Judge status: Wrong Answer
a, b = map(int,input().split())
print(a+b)
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())

if (b > 0 and d > 0):
    print(b * d)
elif (b < 0 and c > 0):
    print(b * c)
elif (a > 0 and d < 0):
    print(a * d)
else:
    print(a * c)
# Judge status: Wrong Answer
from math import log2
N = int(input())
ans = 0
if(N % 2 == 0 and N != 0):
  for i in range(int(log2(N))):
    ans += (N // 5 ** (i+1)) // 2
  print(ans)
elif(N % 2 == 1):
  print(0)
else:
  print(1)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if sum(a)>sum(b):
  print("No")
else:
  ca = 0
  cb = 0
  for i in range(n):
    if a[i]>b[i]:
      cb += a[i]-b[i]
    else:
      ca += (b[i]-a[i]+1)//2
      cb += (b[i]-a[i])%2
  if (sum(b)-sum(a)-ca)*2 == sum(b)-sum(a)-cb:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
a = input()
for i in range(3):
    if a[i] == a[i+1]:
        print("Bad")
        break
print("Good")
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,c,k=mp()
t=sorted([int(input()) for i in range(n)])
count=1
f=t[0]
ans=1
for i in range(1,n):
    count+=1
    d=t[i]-f
    if d>k or count>c:
        ans+=1
        count=1
        f=t[i]

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3

X, Y = map(int, input().split())

count = 0
num = X

while True:
    if not X <= num <= Y:
        break

    num *= 2
    count += 1

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

ans = n-1
for i in range(2,10**6+1):
    if(n%i == 0):
        ans = min(ans, i + n//i - 2)

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

rs = clist.count("R")
ws = clist.count("W")

sort_rs = rs - clist[0:rs].count("R")
ans = rs
if ws < ans:
    ans = ws

if sort_rs < ans:
    ans = sort_rs
print(ans)
# Judge status: Wrong Answer
S = input()
year = int(S[0:4])
mon = int(S[5:7])
day = int(S[8:])
print(year,mon,day)
if year <= 2019 and 1 <= mon <= 4 and 1 <= day <= 30:
    print("Heisei")
else:
    print("TBD")
# Judge status: Wrong Answer
N,*A = map(int, open(0).read().split())

S = sum(A)
k = 0
m = 10**18

for i,a in enumerate(A):
    if i == N - 1: break
    k += a
    d = abs(S - 2*k)
    if d < m:
        m = d
    else:
        break

print(m)
# Judge status: Accepted
from itertools import*
n,m,q,*L=map(int,open(0).read().split())
print(max(sum(d*(x[b-1]-x[a-1]==c)for a,b,c,d in zip(*[iter(L)]*4))for x in combinations_with_replacement(range(m),n)))
# Judge status: Wrong Answer
N = input()
lst = list(map(int,input().split()))
cnt = 0
for i in range(len(lst)):
  for j in range(len(lst)):
    for k in range(len(lst)):
      if lst[k]+lst[j] > lst[i]:
        if lst[k] != lst[j] != lst[i]:
        
          cnt += 1
print(cnt)
# Judge status: Accepted
X = list(str(input()))
n = len(X)

s = []
for x in X:
    if x == 'S':
        s.append(x)
    if x == 'T':
        if s:
            if s[-1] == 'S':
                s.pop()
            else:
                s.append(x)
        else:
            s.append(x)
print(len(s))
# Judge status: Wrong Answer
n=int(input())
num=round(n/1.08)
check=int(num*1.08)
if check==n:
    print(num)
else:
    print(':(')
# Judge status: Wrong Answer
n=int(input())
min1=11**15
for i in range(5):
    a=int(input())
    min1=min(min1,a)
print((n//min1+1)+4)
# Judge status: Accepted
a, b = map(int, input().split())

if (a*b)%2==0:
    print('Even')
else:
    print('Odd')
# Judge status: Wrong Answer
x=int (input())
 
i=0
c=100
d=100
 
while x >= d:
  c=c+((c*0.01)//1)
  d=d+c
  i=i+1
 
 
 
print(i)
# Judge status: Accepted
N, M = list(map(int,input().split()))
A = sorted(list(map(int,input().split())), reverse=True)
b = []

b.append(A.pop(0)//2)
for i in range(1,M):
    if A == []:
        b.append(b.pop(0)//2)
    else:
        if A[0] > b[0]:
            b.append(A.pop(0)//2)
        else:
            b.append(b.pop(0)//2)

print(sum(A)+sum(b))
# Judge status: Accepted
n = int(input())

odds_cnt = (n+1)//2
print(odds_cnt/n)
# Judge status: Accepted
s = input()

if s[0] == "A":
    if s[2:-1].count("C") == 1:
        if s[1:].replace("C","").islower():
            print("AC")
            exit()
print("WA")
# Judge status: Accepted
A,B,N = map(int, input().split())
x = min(B-1,N)
ans = (A*x)//B
print(ans)
# Judge status: Accepted
n = int(input())

ans = 0
cnt = [[0] * 9 for i in range(9)]

for i in range(1, n + 1):
    if i % 10 == 0:
        continue
    a = str(i)[0]
    b = str(i)[-1]
    cnt[int(a) - 1][int(b) - 1] += 1

for i in range(9):
    for j in range(9):
        ans += cnt[i][j] * cnt[j][i]
print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
b = [-1] *N

for i in range((N+1)//2):
  b[i] = str(a[N-1-i*2])
for i in range(N //2):
  b[i+((N+1)//2)] = str(a[N%2 + 2*i])
print(" ".join(b))
# Judge status: Accepted
from collections import Counter

n = int(input())
s = list(map(str, input().rstrip()))

c = Counter(s)

dp = 1
for x in c.values():
    dp = dp * (x + 1)

dp = (dp - 1) % (10 ** 9 + 7)

print(dp)
# Judge status: Accepted
n = int(input())
A = sorted(list(map(int, input().split())))
M = 10**6 + 1
L = [0]*M
for a in A:
    L[a] += 1
    if L[a] == 1:
        # k>=2として k*aは全て不適
        for i in range(2*a, M, a):
            L[i] += 2
# flagの数が答え
print(L.count(1))
# Judge status: Accepted
l,r,n=map(int,input().split())
c=0
for i in range(l,r+1):
  if i%n==0:
    c+=1
print(c)
# Judge status: Accepted
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
d = Counter(A)
Q = int(input())

def sum_from_counter(d):
  return sum(map(lambda k: k * d[k], d))

s = sum(map(lambda k: k * d[k], d))
for i in range(Q):
  B, C = [int(x) for x in input().split()]
  d[C] = d.get(C, 0) + d[B]
  s += (C - B) * d[B]
  d[B] = 0
  print(s)
# Judge status: Accepted
s=input()
a=s.count('a')
b=s.count('b')
c=s.count('c')
if (a==1 and b==1 and c==1):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
A = input().split()
# print(A)
A_list = list(map(float, A))
sa = 0
for i in range(N-1):
    # print(i)
    if A_list[i] > A_list[i+1]:
        sa += A_list[i] - A_list[i+1]
        A_list[i+1] = A_list[i]
print(sa)
# Judge status: Accepted

N = input()

lim = len(N)
dp = [[0, 0] for _ in range(lim + 1)]
dp[0][1] = 1
for i in range(lim):
    n = int(N[i])
    dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + 10 - n)
    dp[i + 1][1] = min(dp[i][0] + n + 1, dp[i][1] + 10 - n - 1)

print(dp[-1][0])
# Judge status: Wrong Answer
N,M = map(int, input().strip().split(' '))
print('Yes' if M <= N else 'No')
# Judge status: Accepted
x, y= map(int, input().split())
s=[list(map(int,list(input().split()))) for i in range(x)]
k= list(s)
k.sort()
a=0
t=0
for i in range(x):
	if y-a>=k[i][1]:
		t=t+k[i][0]*k[i][1]
		a=a+k[i][1]
	else:
		t=t+((y-a)*k[i][0])
		a=y
print(t)
# Judge status: Wrong Answer
import math
S = int(input())


a = int(math.sqrt(S))+1
b = S//a+1

diff = a* b - S
if diff > 0:
    print(0,0,a,diff,1,b)
    if diff > 10**9:
        exit(1)
elif diff < 0:
    exit(1)
else:
    print(0,0,a,0,0,b)
# Judge status: Accepted
n=int(input())
l = list(map(int,input().split()))
max=0
a=0
for i in range(n-1):
    if l[i+1]<=l[i]:
        a+=1
        if a>=max:
            max=a
    elif l[i+1]>l[i]:
        if a>=max:
            max=a
        a=0
print(max)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,c = map(int,input().split())
k = int(input())
print((2**k-1)*max([a,b,c])+sum([a,b,c]))
# Judge status: Accepted
a,b,c = map(int, input().split())
k = int(input())

while not (a<b and b<c):
    if a>=b :
        b*=2
        k-=1
    if b>=c :
        c*=2
        k-=1

if(k<0):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
N,A,B = map(int,input().split())
mi = A*(N-1)+B
ma = A+B*(N-1)
if (N == 1 and A != B)or ma-mi < 0:
    print(0)
else:
    print(ma-mi+1)
# Judge status: Wrong Answer
W, a, b = map(int, input().split())

ans = min(abs(b - (a+W)), abs(a - (b+W)))
if a == b:
    ans = 0
print(ans)
# Judge status: Accepted
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    x = bisect.bisect_left(A, B[i])
    y = N-bisect.bisect_right(C, B[i])
    ans += x*y
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())

if 2 * N >= M:
    print(N)
else:
    d = M - 2 * N
    d //= 4
    print(N + d)
# Judge status: Wrong Answer
a,b = map(int,input().split())
ans = 0
while b > 0:
    b-=a
    ans+=1
    if b<=0:break
    b+=1
print(ans)
# Judge status: Wrong Answer
import sys

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M):
    if i >= M:
        break

    matched = True
    for j in range(N - M):
        if A[i][j:j+M] == B[i][j:j+M]:
            continue
        else:
            matched = False
            break
    if matched:
        print('Yes')
        sys.exit()

print('No')
# Judge status: Wrong Answer
from collections import deque
n = int(input())
s = input()
A = deque([])
for i in range(n):
  if s[i]=='(':
    A.append(s[i])
  elif s[i]==')':
    if len(A)!=0 and A[-1]=='(':
      A.append(s[i])
    elif len(A)==0 or A[-1]==')':
      A.appendleft("(")
      A.append(")")
cou = -1
for i in range(len(A)):
  if A[i]==')':
    cou = i
amari = len(A)-(cou+1)
#print(amari)
for j in range(amari):
  A.append(")")
print("".join(A))
# Judge status: Accepted
X=int(input())
if X==3 or X==5 or X==7:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
dp = [0] * (N+10)
dp[2] = A[1] - A[0] 
for i in range(2,N):
    Ai = abs(A[i] - A[i-1])
    Ai2 = abs(A[i] - A[i-2])
    dp[i+1] = min(dp[i]+Ai,dp[i-1]+Ai2)

print(dp[N])
# Judge status: Wrong Answer
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(N-2):
  if P[i] > P[i+1] and P[i+1] > P[i+2]:
    ans += 1

print(ans)
# Judge status: Wrong Answer
A, B = input().split()
if int(A) >= 13:
    print(B)
elif int(A) >=5:
    print(int(B)/2)
else:
    print(0)
# Judge status: Accepted
n, k = map(int, input().split())
A =list(map(int, input().split()))

ans = 0
while n > 0:
    if ans == 0:
        n -= k
    else:
        n -= (k-1)
    ans += 1
print(ans)
# Judge status: Accepted
a, b, t = map(int, input().split())

tt = 0
x = 0
while True:
    tt += a
    if tt > t + 0.5:
        break
    x += b
print(x)
# Judge status: Wrong Answer
C=[list(map(int,input().split())) for _ in range(3)]
ans='Yes'
if C[0][0]-C[1][0]!=C[0][1]-C[1][1]!=C[0][2]-C[1][2]:
    ans='No'
elif C[1][0]-C[2][0]!=C[1][1]-C[2][1]!=C[1][2]-C[2][2]:
    ans='No'
elif C[0][0]-C[0][1]!=C[1][0]-C[1][1]!=C[2][0]-C[2][1]:
    ans='No'
elif C[0][1]-C[0][2]!=C[1][1]-C[1][2]!=C[2][1]-C[2][2]:
    ans='No'

print(ans)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()

N = ini()
tasks = []
for i in range(N):
    a, b = inm()
    tasks.append((b, a))
tasks.sort()


def solve():
    t = 0
    for b, a in tasks:
        if t + a > b:
            return False
        t += a
    return True


print("Yes" if solve() else "No")
# Judge status: Accepted
def main():
    n, m = map(int, input().split())
    if n == m == 1:
        r = 1
    elif n == 1:
        r = m - 2
    elif m == 1:
        r = n - 2
    else:
        r = (n - 2) * (m - 2)
    print(r)

if __name__ == '__main__':
    main()