peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a_i = max(a)
a.sort(key=lambda x: abs(a_i/2-x))

if a[0] == a_i:
    print(a_i, a[1])
else:
    print(a_i, a[0])
# Judge status: Wrong Answer
N,M,K=map(int,input().split())
ret = 'No'
for m in range(M+1):
  a=K-m*N
  b=M-2*m
  if 0<a and 0<b and a%b==0:
    n=a//b
    if 0<=n<=N:
      ret = 'Yes'
      break
print(ret)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
d=0
e=1
while 1:
  if c+0.5<a:
    a*=e
    e+=1
    d+=b
  else:
    break
print(d)
# Judge status: Accepted
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = sum(l[:k])
tmp = ans
for i in range(k,n):
  tmp += l[i]-l[i-k]
  ans = max(ans, tmp)
print((ans+k)/2)
# Judge status: Accepted
n, m = [int(i) for i in input().split()]
i = 0
j = 1
k = 0
while j < n//2 and k < m:
    print(i % n + 1, (i + j) % n + 1)
    i -= 1
    j += 2
    k += 1
i = (i + j - 1 + (m - k)) % n
j = 2
while k < m:
    print(i % n + 1, (i + j) % n + 1)
    i -= 1
    j += 2
    k += 1
# Judge status: Accepted
s = int(input())
fn = [s]
while True:
   if fn[-1] % 2 == 0:
       if fn[-1]//2 in fn[:len(fn)-1]:
           print(len(fn) + 1)
           break
       else:
           fn.append(fn[-1] // 2)
   else:
        if fn[-1]*3 + 1 in fn[:len(fn)-1]:
            print(len(fn) + 1)
            break
        else:
            fn.append(fn[-1]*3 + 1)
# Judge status: Accepted
n=int(input())
l=len(str(n))
dp=[[0]*9 for i in range(9)]
count=0
for i in range(1,n+1):
    x,y=int(str(i)[0]),int(str(i)[-1])
    if x!=0 and y!=0:
        dp[x-1][y-1]+=1
for i in range(9):
    for j in range(9):
        count+=dp[i][j]*dp[j][i]
print(count)
# Judge status: Accepted
x,y=map(int,input().split())
print(-1 if x%y<1 else x)
# Judge status: Accepted
S = input()

mod = [0] * 2019
mod[0] = 1
digit = 1
temp = 0
 
for i in S[::-1]:
    temp = (temp + digit * int(i)) % 2019
    mod[temp] += 1
    digit = (digit * 10) % 2019

ans = 0
for m in mod:
    ans += m * (m - 1) // 2

print(ans)
# Judge status: Accepted
def solve(N):
    if N < 26:
        return chr(ord('a') + (N) % 26)
    else:
        return solve(N // 26 - 1) + chr(ord('a') + N % 26)

print(solve(int(input()) - 1))
# Judge status: Accepted
S = input("")
if S =="ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys


def main():
    S = int( sys.stdin.readline() )

    dp = [0]*(S+1)
    dp[0] = 1
    mod = 10**9 + 7

    for i in range(3, S+1):
        dp[i] = dp[i-3] + dp[i-1]
        dp[i] %= mod
    

    print(dp[-1])


if __name__ == "__main__":
    main()
# Judge status: Accepted
a, b = map(int, input().split())

ans = a if b >= a else a - 1
print(ans)
# Judge status: Accepted
a = int(input())
s = str(input())
if a >= 3200:
    print(s)
else:
    print("red")
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]
A.append(0)
f = [0] * N
for i in range(N):
    if A[i] < A[i+1]:
        f[i] = 1
    elif A[i] > A[i+1]:
        f[i] = 2
cnt = 1000
stock = 0
prev = 0
for i in range(N):
    if stock == 0 and prev != 1 and f[i] == 1:
        stock = cnt // A[i]
        cnt %= A[i]
    elif prev != 2 and f[i] == 2:
        cnt += stock * A[i]
        stock = 0
    prev = f[i]
print(cnt)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
A = input().split()
AK = [[0 for j in range(N)] for i in range(2)]
for l in range(N):
  AK[0][l] = int(AK[0][l]) + int(A[l])
p = int(math.log10(K+1))
for m in range(1,p,1):
  for o in range(N):
    for x in range(N):
      if((o-AK[0][o]+0.5) < (x+1)) and ((x+1) < (o+AK[0][o]+1.5)):
        AK[1][x] = AK[1][x] +1
  AK[0] = AK[1]
  AK[1] = [0] * N
print(*AK[0])
# Judge status: Accepted
import sys
from collections import deque
input = sys.stdin.readline
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
ans=[-1]*n
ans[0]=0
print('Yes')
d=deque([0])
while d:
  now=d.pop()
  for x in l[now]:
    if ans[x]<0:
      ans[x]=now
      d.appendleft(x)
for i in range(1,n):
  print(ans[i]+1)
# Judge status: Accepted
from collections import deque
import copy
N,K = map(int, input().split())
p = list([(i+1)* i/2/i for i in map(int, input().split())])
que = deque([0]* K)
sumM = 0
sumq = 0
E = 0.0

for i in range(N):
    sumq -= que.popleft()
    sumq += p[i]
    que.append(p[i])
    if E < sumq:
        E = sumq
print(E)
# Judge status: Accepted
#!/usr/bin/env python3


def main():
    N, x, *A = map(int, open(0).read().split())
    A.sort()
    for i in range(N):
        x -= A[i]
        if x == 0:
            print(i + 1)
            break
        elif x < 0:
            print(i)
            break
    else:
        # ちょうどN個もらわないと喜べない悲しい子どもたち
        print(N - 1)


main()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
fumi_sum = 0
for i in range(1,n):
    if a[i] < a[i-1]:
        fumi_sum += a[i-1] - a[i]
        a[i] += a[i-1] - a[i]
print(fumi_sum)
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()
if s == t: print(n)
else:
    idx = False
    for i in reversed(range(n)):
        if s[i] == t[0]:
            idx = i
            for j in range(0, n - idx):
                if s[idx + j] == t[j]: continue
                else:
                    idx = False
                    break
    if idx == False: print(len(s + t))
    else: print(len(s[:idx] + t))
# Judge status: Wrong Answer
x="AtCoder "+input().capitalize()+" Contest"
print(x)

print("A"+x[8]+"C")
# Judge status: Accepted
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
c = 1
for i in range(1, n + 1):
    d += l[i - 1]
    if d <= x:
        c += 1
    else:
        break
print(c)
# Judge status: Accepted
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
q = []
for i in range(m):
    b,c = map(int,input().split())
    q.append([c,b])
q.sort(reverse=True)
j = 0
for i in range(m):
    while j < len(a) and q[i][1]>0:
        if a[j]<q[i][0]:
            a[j] = q[i][0]
            q[i][1] -= 1
        j+=1
print(sum(a))
# Judge status: Wrong Answer
import math
import sys
a,v=(int(x) for x in input().split())
b,w=(int(x) for x in input().split())
t = int(input())

e1=pow(10, -9)
e2=pow(10, 9)

if (a<e1)or(e2<a)or(b<e1)or(e2<b)or(v<1)or(e2<v)or(w<1)or(e2<w)or(t<1)or(e2<t)or(a==b):
    sys.exit(0)

aa = a/t + v
bb = b/t + w

if (aa>=bb):
    print("YES")
else :
    print("NO")
# Judge status: Accepted
n, x, t = input().split()
N = int(n)
X = int(x)
T = int(t)
if N % X == 0:
    c = N / X
else:
    c = int(N / X) + 1 
C = int(c)
print(C*T)
# Judge status: Wrong Answer
s = str(input())
j = 0
flag = 0
if "key" in s:
    if "ence" in s:
        print("YES")
        exit()
print("NO")
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(1,n - k):
    score = 1
    p_score = 1
    for j in range(i,i+k):
        score *= a[j]
        p_score *= a[j-1]
    if score > p_score:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
A1, A2, A3 = map(int, input().split())

t = A1 + A2 + A3

if t >= 22:
  print("bust")
else:
  print("win")
# Judge status: Wrong Answer
N,M=map(int,input().split())
print(1 if N==1 and M==1 else M-2 if N==1 and M!=1 else (N-2)*(M-2))
# Judge status: Accepted
N=int(input())
a=list(map(int, input().split()))
a.sort()
a=a[::-1]
A=sum([a[i] for i in range(0, N, 2)])
B=sum([a[i] for i in range(1, N, 2)])
print(A-B)
# Judge status: Accepted
a,b,c=map(int,input().split())
print("No" if a==b==c else "Yes" if a==b or b==c or c==a else "No")
# Judge status: Accepted
import sys
input = sys.stdin.readline

# A - AtCoder Group Contest
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0

for i in range(1, n * 2, 2):
	ans += a[i]
	
print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    q,h,s,d=map(int, input().split())
    n=int(input())
    s=min(4*q,2*h,s)
    if 2*s<=d:
        print(n*s)
    else:
        a,b=divmod(n,2)
        print(a*d+b*s)
resolve()
# Judge status: Accepted
A, B, K = map(int,input().split())
l = [x for x in range(1,A+1) if A%x == 0 and B%x == 0]
print(l[-K])
# Judge status: Accepted
n,m=list(map(int,input().split()))

i=1
ans=0

while i*i<=m:
    if m%i==0:
        if n<=m/i:
            ans=max(ans,i)
        if n<=i:
            ans=max(ans,m//i)
        
    i+=1

print(ans)
# Judge status: Accepted
import sys
N = int(input())
turn = 0
x, y = 0, 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0]%2 == 0 and (a[1]+a[2])%2 == 1:
        print("No")
        sys.exit()
    if a[0]%2 == 1 and (a[1]+a[2])%2 == 0:
        print("No")
        sys.exit()
    if (a[0] - turn) < abs(x - a[1]) + abs(y - a[2]):
        print("No")
        sys.exit()
print('Yes')
# Judge status: Wrong Answer
#!/usr/local/bin/python3
# coding: utf-8

ha = input()
kita = ha.split(" ")
x = int(kita[0])
y = int(kita[1])
ifAshi = False

for i in range(x):
    if((y - 2*i)%4 == 0):
        if((x-i) == ((y - 2*i)/4)):
            ifAshi = True

if(ifAshi):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
X = int(input())

lst = [ [400, 599, 8], [600, 799, 7], [800, 999, 6], [1000, 1199, 5], [1200, 1399, 4], [1400, 1599, 3], [1600, 1799, 2], [1800, 1999, 1] ]

def Kyu(X):
   
   for i in lst:
      if i[0] <= X <= i[1]:
         result = i[2]
         break
   
   print(result)
# Judge status: Wrong Answer
import math

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

for i in range(min(math.ceil(math.log(N)), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))
# Judge status: Wrong Answer
r,g,b = map(int,input().split())
1 <= r <= 9
1 <= g <= 9
1 <= b <= 9
number1 = str(r+g+b)
number2 = int(number1)
if number2%4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
cnt = 0
for i in range(n+1):
    if i%2 ==1:
        cnt += 1
print(cnt/n)
# Judge status: Wrong Answer
datalist=list(map(int,input().split()))
N,A,B=datalist[0],datalist[1],datalist[2]
strings=str(input())
na,nb=0,0
for i in range(len(strings)):
  if strings[i]=="a":
    if na + nb < A+B:
      print("YES")
      na += 1
    else:
      print("NO")
  elif strings[i]=="b":
    if na + nb < A+B:
      if nb < B:
        print("YES")
        nb += 1
      else:
        print("NO")
    else:
      print("NO")
  else:
    print("NO")
# Judge status: Wrong Answer
masu = [list(map(int,input().split())) for _ in range(3)]
import numpy as np
masu = np.array(masu)
a = []
b = []
for i in masu:
    a.append(min(list(i)))
for i in masu.T:
    b.append(min(list(i)))
flag = True
c = 0
p = masu[0][0]
for i in range(3):
    for j in range(3):
        if masu[i][j] != a[i] + b[j]:
            flag = False
        if masu[i][j] == p:
            c += 1
if flag or c==9:
    print('Yes')
else:print('No')
# Judge status: Wrong Answer
n=int(input())
data=[10**i for i in range(1,3+1)]
for i in data:
  if n%i==7:
    print("Yes")
    exit()
print("No")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
num_odd = 0
num_mul4 = 0
for a in A:
    if a % 2 == 1:
        num_odd += 1
    elif a % 4 == 0:
        num_mul4 += 1
if N <= 3:
    if num_odd == 0:
        print('Yes')
    elif num_mul4 >= 1:
        print('Yes')
    else:
        print('No')
    exit()

if num_odd <= num_mul4:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def readinput():
    n=int(input())
    a=[0]
    for _ in range(n):
        a.append(int(input()))
    return n,a

def main(n,a):
    button=[0]*(n+1)
    button[1]=1
    i=1
    count=0
    while(True):
        i=a[i]
        count+=1
        if i==2:
            return count
        if button[i]>0:
            return -1
        button[i]+=1

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)
# Judge status: Wrong Answer
S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a, b, c = map(int, input().split())
ans = max(c-(a-b), 0)
print(ans)
# Judge status: Accepted
n,m=[int(x) for x in input().split()]
r=[input() for _ in range(m)]

r=' '.join(r).split()
for i in range(1,n+1):
    print(r.count(str(i)))
# Judge status: Accepted
N,M=map(int,input().split())
ans=0
ans+= min(N, M//2)
M-=ans*2
ans+=M//4
print(ans)
# Judge status: Accepted
from math import gcd
from functools import reduce


def lcm(a, b):
    return (a * b) // gcd(a, b)


def main():
    n = int(input())
    t = [int(input()) for _ in range(n)]
    print(reduce(lcm, t))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
ans = ''
p = -2
while n!=0:
    n,r = divmod(n,p)
    if r < 0:
        r -= p
        n += 1
    ans = str(r) + ans
if ans == '': ans = '0'
print(ans)
# Judge status: Accepted
n = int(input())
lis = [0]+list(map(int, input().split())) +[0]

total = 0

for i in range(1, n+1):
    if i == lis[i]:
        t = lis[i]
        lis[i] = lis[i+1]
        lis[i+1] = t
        total += 1

print(total)
# Judge status: Accepted
N = int(input())
l = []
for _ in range(N):
    a, b = map(int, input().split())
    l.append((a, b))

cnt = 0
for t in l:
    if t[0] == t[1]:
        cnt += 1
        if cnt >= 3:
            break
    else:
        cnt = 0
if cnt >= 3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
w,h,n = map(int, input().split())
x_left = 0
x_right = w
y_up = h
y_down = 0
for _ in range(n):
  x,y,a = map(int, input().split())
  if a==1 and x_left <= x:
    x_left = x
  elif a==2 and x_right >= x:
    x_right = x
  elif a==3 and y_down <= y:
    y_down = y
  elif a==4 and y_up >= y:
    y_up = y

if x_right <= x_left or y_up <= y_down:
  print(0)
else:
  print((x_right - x_left)*(y_up - y_down))
# Judge status: Accepted
n = int(input())
s = list(input())
b = [0] * n
w = [0] * n
x,y = 0,0
ans = 0
for i in range(n):
    if s[i] == '#':
        x += 1
    else:
        y += 1
    b[i] = x
    w[i] = y

ans = float('inf')
for i in range(n):
    ans = min(ans, b[i] + w[n-1] - w[i])
print(min(ans, b[n-1], w[n-1]))
# Judge status: Wrong Answer
N = int(input())
S = list(map(int,input().split()))

cnt = 0
while True:
  check = sum(S)
  if check % 2 == 0 and check > 0:
    S = [n//2 for n in S]
    cnt += 1
  else:
    break
    
print(cnt)
# Judge status: Accepted
from collections import Counter

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

cntA = Counter(A)
B = []
for a, c in cntA.items():
    if c // 2 == 0:
        continue
    for _ in range(c // 2):
        B.append(a)

B.sort(reverse=True)
ans = B[0] * B[1] if len(B) >= 2 else 0

print(ans)
# Judge status: Accepted
N,K = map(int, input().split())
xo=N%K
xn=abs(xo-K)
while True:
    if xo>xn:
        xo=xn
        xn=abs(xn-K)
    else:
        break
print(xo)
# Judge status: Wrong Answer
# C - X: Yet Another Die Game
def main():
    x = int(input())

    if x <= 11:
        print(2)
    else:
        print(x//11*2+1)
  
        
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
S = input()

d = [0] * n
nl = 0
nr = 0
for i in range(n):
    if S[i] == '(': nl += 1
    if S[i] == ')': nr += 1
    d[i] = nl - nr

x = min(d)
# print(d)
# print(x)

print('('*(-x) + S + ')'*(d[-1]-x))
# Judge status: Accepted
import math

N = int(input())

As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

if sum(As) > sum(Bs):
  print('No')
  exit()
  
dif = sum(Bs) - sum(As)
A = 0
for i in range(N):
  if Bs[i] > As[i]:
    A += math.ceil((Bs[i]-As[i])/2)
    
if A > dif:
  print('No')
else:
  print('Yes')
# Judge status: Wrong Answer
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
 
if N > K:
  print(K*X + Y*(N-K))
else:
  print(K*X)
# Judge status: Accepted
def LI(): return list(map(int,input().split()))
A,B,K = LI()
ans = []
for i in range(1,min(A,B)+1):
    if A%i==B%i==0:
        ans.append(i)
print(ans[-K])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

x,y=0,0
for i in a:
 if i%4==0:
  x+=1
 if i%2==1:
  y+=1

z=n-y-x

if z==0:
 print('Yes' if y<=x+1 else 'No')
else:
 print('Yes' if y<=x else 'No')
# Judge status: Accepted
x = int(input())
ans = (x // 11) * 2
if x % 11:
    if x % 11 > 6:
        ans += 2
    else:
        ans += 1
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
list=[]
s=[]
if N == 1:
    a, *b=map(int, input().split())
    print(a)
else:
    for i in range(N):
        list.append(input().split())
        s = set(s) & set(list[1:])
        list=[]
    print(len(s))
# Judge status: Accepted
import math
a,b,x =map(int,input().split())

if x <(a*a*b)/2:
  hen=(x*2)/(a*b)
  print(math.degrees(math.atan(b/hen)))
  
  
else:
  taiseki=a*a*b-x
  hen=(taiseki*2)/(a*a)
  print(math.degrees(math.atan(hen/a)))
# Judge status: Accepted
n=int(input())
if n<112:
    print(111)
elif n<223:
    print(222)
elif n<334:
    print(333)
elif n<445:
    print(444)
elif n<556:
    print(555)
elif n<667:
    print(666)
elif n<778:
    print(777)
elif n<889:
    print(888)
else:
    print(999)
# Judge status: Accepted
n = int(input())
b = [int(i) for i in input().split()]

a = [b[0]]
for i in range(1, n-1):
    a.append(min(b[i-1], b[i]))
a.append(b[-1])

print(sum(a))
# Judge status: Accepted
import math
n=int(input())
c=[0]*(n-1)
s=[0]*(n-1)
f=[0]*(n-1)
for i in range(n-1):
  c[i],s[i],f[i] = map(int,input().split())

for i in range(n):
  ans=0
  for j in range(i,n-1):
    ans = max(s[j], math.ceil(ans/f[j])*f[j]) + c[j]
  print(ans)
# Judge status: Accepted
N = int(input())
a = [int(c) for c in input().split()]
c = [0]*8
over = 0
for i in range(N):
    if a[i]>=3200:
        over+=1
    else:
        c[a[i]//400]+=1
 
mi = 8-c.count(0)
ma = mi+over
if mi == 0:
    mi+=1
print(mi,ma)
# Judge status: Accepted
N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(M)]

sortPY = sorted(PY, key=lambda x: x[1])
prefec = [0]*(N+1)
res = []
for p, y, i in sortPY:
    prefec[p] += 1
    strp = str(p)
    ID = '0'*(6-len(strp)) + strp + '0'*(6-len(str(prefec[p]))) + str(prefec[p])
    res.append([ID, i])

sortres = sorted(res, key=lambda x: x[1])
for i in range(M):
    print(sortres[i][0])
# Judge status: Wrong Answer
st, gl = map(int, input().split())
ans = 0

if gl == st:
  print(0)
  exit()
elif gl == -st:
  print(1)
  exit()

if st >= 0:
  if gl > st:
    ans = gl - st
  elif gl < -st:
    ans = - st - gl + 1
  else:
    ans = gl + st + 1

if st < 0:
  if gl > -st:
    ans = gl + st + 1
  elif gl < st:
    ans = st - gl + 2
  else:
    ans = gl - st
  
print(ans)
# Judge status: Wrong Answer
N = int(input())
List = dict()
for i in range(N):
    X,L = map(int,input().split())
    List.update({X:L})
keys= sorted(List,reverse=True)
if len(List)<=1:
    print(len(List))
elif len(List)<3:
    if keys[0]-List[keys[0]]<=keys[1] or keys[1]+List[keys[1]]<=keys[0]:
        del List[keys[i]]
    print(len(List))
else:
    for i in range(1, len(keys)-1):
        if keys[i]-List[keys[i]]<=keys[i+1] or keys[i]+List[keys[i]]>=keys[i-1]:
            del List[keys[i]]
    print(len(List))
# Judge status: Accepted
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
visited = {'1': 0}
route = [1]
next_id = 0
count = 0
while count < K:
    count += 1
    if A[next_id] in visited.keys():
        route = route[visited[A[next_id]]:]
        K -= count
        break
    visited[A[next_id]] = count
    route.append(A[next_id])
    next_id = A[next_id] - 1
print(route[K % len(route)])
# Judge status: Accepted
x = int(input())
c = 0
t = 0
while 1:
    t += 1
    c += t
    if c >= x:
        print(t)
        exit()
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(n*x) if n<k else print(k*x+(n-k)*y)
# Judge status: Accepted
N,A,B=map(int,input().split())
S=list(input())
pas=0
kai=0
for i in range(len(S)):
    if S[i]=='a':
        if pas<A+B:
            print('Yes')
            pas+=1
        else:
            print('No')
    elif S[i]=='b':
        kai+=1
        if pas<A+B and kai<=B:
            print('Yes')
            pas+=1
        else:
            print('No')
    else:
        print('No')
# Judge status: Accepted
words = input()

lst = ['A', 'C', 'G', 'T']
max_count = 0
count = 0
for i in range(len(words)):
  if words[i] in lst:
    count += 1
    if i == len(words) - 1:
      if count > max_count:
        max_count = count
  else:
    if count > max_count:
      max_count = count
    count = 0
print(max_count)
# Judge status: Accepted
D = input()
ans = 0
ans_list = []
if D.count("R") >= 1:
  for i in range(3):
    if D[i] == 'R':
      ans += 1
      ans_list.append(ans)
    elif D[i] == 'S':
      ss = 0
      ans_list.append(ss)
      if i > 0:
        ans = 0
  print(max(ans_list))
elif D.count("R") < 1:
  print(0)
# Judge status: Accepted
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
S = input()

ans = 0
x = 0
for i in range(len(S)):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans, x)

print(ans)
# Judge status: Accepted
a,b,c=sorted(list(map(int,input().split())))
if a+b==c:print("Yes")
else:print("No")
# Judge status: Wrong Answer
s = str(input())

g_count = 0
p_count = 0
point = 0
for i in range(len(s)):
    # 必ずグーを出す状態
    if g_count == p_count:
        g_count += 1
        if s[i] == 'g':
            pass
        else:
            point -= 1
    # パーも出せる状態
    elif s[i] == 'g':
        p_count += 1
        point += 1
    elif s[i] == 'p':
        p_count += 1

ans = point
print(ans)
# Judge status: Wrong Answer
import copy
n = int(input())
s = list(map(int, input().split()))

count = 0

for i in range(n - 2):
  t = copy.copy(s[i:i + 2])
  if(s[i + 1] == sorted(t)[1]):
    count += 1

print(count)
# Judge status: Accepted
def main():
    n = int(input())
    d = {}
    ans = 0
    
    for _ in range(n):
        ss = ''.join(sorted(input()))
        d[ss] = d.get(ss, 0) + 1
        
    for k, v in d.items():
        if v != 1:
            ans += (v*(v-1)) // 2
         
    print(ans)
       
    
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

if A + B <= C:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
s = input()

n = len(s)
count = 0

for i in range(n//2):
    if not s[i] == s[-1-i]:
        count += 1
print(count)
# Judge status: Accepted
import math
k = int(input())

ans = 0
for a in range(1, k+1):
  for b in range(1, k+1):
      m = math.gcd(a, b)
      for c in range(1, k+1):
          ans += math.gcd(m, c)

print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print((c//a)*b)
# Judge status: Accepted
x, n = map(int, input().split())
p = list(map(int,input().split()))
p.sort()
s = x
d = 1
while s in p:
    s = s - d
    d = int((abs(d)+1)*d/abs(d)*(-1))
print(s)
# Judge status: Accepted
s = input()
x="x"
print(x*len(s))
# Judge status: Wrong Answer
N = int(input())

A = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    A.append([c, s, f])

for i in range(N-1):
    ans = 0
    T = 0
    for j in range(i, N-1):
        if T <= A[j][1]:
            T += A[j][0] + A[j][1] - T
        else:
            T += (T-A[j][1])%A[j][2]  + A[j][0] 
    print(T)
        
print(0)
# Judge status: Accepted
a, b = map(int, input().split())

if a <= 0 and 0 <= b:
    print("Zero")
elif 0 < a:
    print("Positive")
elif a < 0 and 0 <= b:
    print("Zero")
else:
    if abs(a - b) % 2 == 1:
        print("Positive")
    else:
        print("Negative")
# Judge status: Accepted
p,q,r=map(int,input().split());print(min(p+q,q+r,r+p))
# Judge status: Accepted
# -*- coding: utf-8 -*-
c = input()
if c=='a' or c=='i' or c=='u' or c=='e' or c=='o':
  print('vowel')
else:
  print('consonant')