peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
cin = open(0).read().strip().split('\n')
n,m,x = map(int, cin[0].split(' '))
books = []
for i in cin[1:]:
    books.append(tuple(map(int, i.split(' '))))

for i in range(2**n):
    ret = [0] * m
    money = 0
    for j in range(n):
        if i >> j & 1:
            for mi in range(m):
                ret[mi] += books[j][1+mi]
            money += books[j][0]
    if min(ret) >= x:
        print(money)
        break
else:
    print(-1)
# Judge status: Accepted
n = int(input())

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

t_4 = 0
t_2 = 0
for i in a:
  if i%4==0:
    t_4+=1
  elif i%2==0:
    t_2+=1
other = len(a)-t_4-t_2
if other <= t_4:
  print("Yes")
elif other == t_4 +1:
  if t_2 > 0:
    print("No")
    exit()
  else:
    print("Yes")
    exit()
else:
  print("No")
# Judge status: Accepted
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = list(c.values())

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

ans = 0
for i in num:
    if i > 1:
        ans += combinations_count(i, 2)

print(ans)
# Judge status: Accepted
N = int(input())
ans = [0] * 100001
for i in range(6):
    ans[i] = i
s = 6
n = 9
for i in range(6,N+1):
    p = i%3
    if p != 0:
        ans[i] =  ans[i-p] + p
    else:
        if i == s*6:
            s *= 6
        if i == n*9:
            n *= 9
        ans[i] = min(ans[i-s]+1,ans[i-n]+1)
print(ans[N])
# Judge status: Accepted
from operator import itemgetter

n,m= map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab)
money = 0
drink = 0
for i in range(n):
         drink += ab[i][1]
         if drink > m:
                  drink -= ab[i][1]
                  break
         else:
                  money += ab[i][1] * ab[i][0]
                  continue
         break
money += (m - drink)*ab[i][0]
print(money)
# Judge status: Accepted
X = int(input())

ans = -1
x = X
while(ans == -1):
    if all([x % i != 0 for i in range(2, x)]):
        ans = x
    else:
        x += 1
print(ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())


s1 = ""
s2 = ""
for i in range(b):
    s1 = s1 + str(a)

for i in range(a):
    s2 = s2 + str(b)

ans = min(s1,s2)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
R = []

for i in range(N):
	x,l = map(int, input().split())
	R.append([max(x-l,0),x+l])
R.sort(key = lambda r : r[1])

ans = N
lr = -1
for i in range(N):
	if(lr > R[i][0]):
		ans -=1
		continue
	else:
		lr = R[i][1]
print(ans)
# Judge status: Wrong Answer
c = input()
data = []
for s in range(0,int(c)):
  data.append(list(map(int, input().split())) )

nowtime = 0
nowx = 0
nowy = 0

nexttime = 0
nextx = 0
nexty = 0

costtime = 0
diffx = 0
diffy = 0

for s in range(0, len(data)):
  nexttime = data[s][0]
  nextx = data[s][1]
  nexty = data[s][2]
  costtime = nexttime - nowtime
  diffx = abs(nextx - nowx)
  diffy = abs(nexty - nowy)
  if ( (costtime < diffx + diffy) or ((((nextx + nexty) ) % 2) == (nexttime % 2) ) ):
    print("NO")
    exit()
  nowtime = nexttime
  nowx = nextx
  nowy = nexty



print("YES")
# 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

S = input()
Sset = set(S)
# print(Sset)
if len(S) == len(Sset):
    print("yes")
else:
    print("no")
# Judge status: Accepted
# -*- coding: utf-8 -*-

def main():

    S, T = input().split()

    ans = T + S

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
from itertools import combinations_with_replacement

n,m,q =map(int,input().split())
summa=[]
res=[]
for i in range(q):
    a=[int(i) for i in input().split()]
    summa.append(a)
    
for i in combinations_with_replacement(list(range(1,m+1)),n):
    cnt=0
    for j in summa:
            if i[j[1]-1]-i[j[0]-1]==j[2]:
                cnt += j[3]
            
    res.append(cnt)
    
print(max(res))
# Judge status: Accepted
a,b=input().split()
c=int(a+b)
import math
d=math.sqrt(c)
if int(d)*int(d)==c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
X = int(input())
for a in range(-1000, 1000):
    A = a*a*a*a*a
    for b in range(-1000, 1000):
        if A - b*b*b*b*b == X:
            print(a, b)
            exit()
# Judge status: Wrong Answer

[A,B,K] = list(map(int,input().split()))

for i in range(K):
    dammy = A+i
    if dammy<B:
        print(dammy)

for j in range(K):
    dammy = B-K+1+j
    if A+K-1<dammy and 0<dammy and dammy<=B:
        print(dammy)
# Judge status: Wrong Answer
K,S=map(int,input().split())
ans=0
for i in range(K+1):
    for j in range(K+1):
        if (i+j)>S:
            break
        if (S-K)<=(i+j):
            break
        ans+=1

print(ans)
# Judge status: Accepted
s = input()
n = len(s)
ans = 0
now = 0
mp = [0 for i in range(2019)]
mp[0] += 1
tmp = [0 for i in range(2019)]

id = [0 for i in range(2019)]
for i in range(2019):
    id[i] = i * 10 % 2019

for c in s:
    now *= 10;
    now += ord(c) - ord("0")
    now %= 2019

    ans += mp[now]
    mp[now] += 1
    for i in range(2019):
        tmp[id[i]] = mp[i]
    for i in range(2019):
        mp[i] = tmp[i]

print(ans)
# Judge status: Accepted
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    S = input().rstrip()
    if len(set(S))==3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m = map(int,input().split())
an = n * (n-1)/2
am = m * (m-1)/2
answer = an + am
print(int(answer))
# Judge status: Accepted
a = input()
b = input()
if a == b [::-1]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def main():
    a, b = map(int, input().split())
    if a < 0 and b > 0:
        print('Zero')
    elif a > 0 and b > 0:
        print('Positive')
    elif a == 0 or b == 0:
        print('Zero')
    else:
        if (abs(a) - abs(b) + 1) % 2 == 1:
            print('Negative')
        else:
            print('Positive')


if __name__ == "__main__":
    main()
# Judge status: Accepted
a = list(map(int,input().split()))
a = sorted(a)
x = a[2] * 10 + a[1]
y = a[0]
print(x+y)
# Judge status: Accepted
def main():
    n = int(input())
    h = list(map(int, input().split()))
    for i in reversed(range(1,n)):
        if h[i-1] <= h[i]:
            continue
        h[i-1] = h[i-1] - 1
        if not h[i-1] <= h[i]:
            print('No')
            return
        else:
            continue
    print('Yes')

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]

m = sum(a) / len(a)
num = round(m)

loss = 0
for n in a:
	loss += (n - num)**2

print(loss)
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
*D, = map(int, input().split())
mod = 998244353
c = Counter(D)

keys = sorted(c.keys())
if keys[0]!=0:
    print(0)
else:
    size = len(keys)

    ans = 1
    for i in range(1, size):
        a, b = keys[i-1], keys[i]
        ans *= (c[a]**c[b])
        ans %= mod
    print(ans)
# Judge status: Wrong Answer
a=input()
b=int(a[0]+a[1])
c=int(a[2]+a[3])
if b>12 or b==0:
  if c>12 or c==0:
    print("Na")
  else:
    print("YYMM")
elif c>12 or c==0:
  if b>12 or b==0:
    print("Na")
  else:
    print("MMYY")
else:
  print("AMBIGUOUS")
# Judge status: Wrong Answer
n=int(input())
def f(x,y):
  ret=0
  for i in range(1,n):
    s,e=int(str(i)[0]),int(str(i)[-1])
    if x==s and y==e:
      ret+=1
  return ret
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=f(i,j)*f(j,i)
print(ans)
# Judge status: Accepted
from fractions import gcd
def lcm(p,q):
    return p*q//gcd(p,q)
N, M = map(int, input().split())
a = [int(i)//2 for i in input().split()]
x = 1
for i in range(N):
  x = lcm(x, a[i])
for i in range(N):
  if (x//a[i])%2==0:
    print(0)
    exit()
num = M//x
print(num//2 if num%2==0 else num//2+1)
# Judge status: Wrong Answer
x=int(input())
if 400<=x<=599:print(8)
elif 600<=x<799:print(7)
elif 800<=x<999:print(6)
elif 1000<=x<1199:print(5)
elif 1200<=x<1399:print(4)
elif 1400<=x<1599:print(3)
elif 1600<=x<1799:print(2)
elif 1800<=x<1999:print(1)
# Judge status: Accepted
from bisect import bisect_right

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

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

b_ac=[0]
for i in range(1,m+1):
  b_ac.append(b_ac[i-1]+b[i-1])

#print(a_ac)
#print(b_ac)

ans=0
for i in range(n+1):
  remain=k-a_ac[i]
  if remain<0:
    continue
  t_ans=i
  t_ans+=bisect_right(b_ac,remain)-1
  ans=max(ans,t_ans)

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

N, M = map(int, input().split())
salary = defaultdict(list)
for i in range(N):
    a, b = map(int, input().split())
    salary[a].append(-b)

sv = []
heapq.heapify(sv)
ans = 0
for i in range(1, M+1):
    for j in range(len(salary[i])):
        heapq.heappush(sv, salary[i][j])
    if(len(sv)):
        ans -= heapq.heappop(sv)
print(ans)
# Judge status: Wrong Answer
import collections

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 0
items = list(set(A))
count = [0]*len(items)
items.reverse()
for i in range(N):
    count[items.index(A[i])] += 1

for i in range(len(count)):
    if ans == 0:
        if count[i] >= 4:
            ans = items[i]**2
            break
        elif count[i] >= 2:
            ans = items[i]
    else:
        if count[i] >= 2:
            ans *= items[i]
            break

print(ans)
# Judge status: Accepted
def main():
    a, b, c = map(int, input().split())
    k = int(input())
    p = pow(2, k)
    print(a + b + c - max(a,b,c) + max(a,b,c)*p)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
if n>=30:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
s=input()
n=len(s)
MOD=2019
l=[]
for i in range(n-1,-1,-1):
  l.append(int(s[i:n])%MOD)
print(l)
from collections import Counter
c=Counter(l)
print(c)
ans=0
for i in c.values():
  ans+=i*(i-1)//2
print(ans)
# Judge status: Wrong Answer
x,a,b = map(int,input().split())

if a > b:
    print('delicious')
elif (b-a) <= x:
    print('safe')
else:
    print('dangerous')
# Judge status: Wrong Answer

A, B, C = sorted(map(int, input().split()))
print(10*C + B + C)
# Judge status: Wrong Answer
i = input()
l = i.split()
print(l)
print(l[2] + ' ' + l[0] + ' ' + l[1])
# Judge status: Accepted
x, n = map(int, input().split())
q = list(map(int, input().split()))
p = []
for i in range(102):
    if not i in q:
        p.append(i)
l = []
for i in p:
    l.append(abs(i - x))
print(p[l.index(min(l))])
# Judge status: Accepted
N=int(input())
A=[int(input()) for x in range(N)]
y=set()
for i in A:
    if i in y:
        y.remove(i)
    else:
        y.add(i)
print(len(y))
# Judge status: Wrong Answer
from collections import defaultdict
d = defaultdict(int)

n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(m):
    d[input()] -= 1
print(max(d.values()))
# Judge status: Accepted
# coding: utf-8

N = int(input())
ans = 800*N - N//15*200
print(ans)
# Judge status: Wrong Answer
N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for i in range(Q)]
ABCD.sort(key=lambda x: x[3], reverse=True)
A = [1 for _ in range(N)]
for i in range(Q):
    if not(A[ABCD[i][0]-1] + ABCD[i][2] > M):
        A[ABCD[i][1]-1] = A[ABCD[i][0]-1] + ABCD[i][2]

ans = 0
for i in range(Q):
    if A[ABCD[i][1]-1] == A[ABCD[i][0]-1] + ABCD[i][2]:
        ans += ABCD[i][3]
print(ans)
# Judge status: Accepted
from collections import defaultdict
dic = defaultdict(int)

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

for i, a in enumerate(A):
    dic[i + a] += 1

counter = 0
for i, a in enumerate(A):
    counter += dic[i-a]

print(counter)
# Judge status: Accepted
n = int(input())
  
print(n*(n-1)//2)
# Judge status: Accepted
inf = 10**9+7
mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))
maxa = max(a)
a.remove(maxa)
if maxa < sum(a):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b=map(int,input().split())
c=(a+b)/2
if c%1==0:
  print(int(c))
else:
  print(int((c//1)+1))
# Judge status: Wrong Answer

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

    x_s = list(map(int,input().split()))
    y_s = list(map(int,input().split()))

    x_max = max(x_s)
    y_min = min(y_s)

    ok = False
    for z in range(X+1,Y+1):
        if z <= x_max or z > y_min:
            ok = True
            break
    answer =  "War" if ok else "No War"
    print(answer)





if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
#!/use/bin/env python3

import math
from collections import defaultdict

(a, b) = [int(s) for s in input().split()]

ans = 'Yay!'

if a > 8 or b > 8:
    ans = ':)'

print(ans)
# Judge status: Wrong Answer
n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        for k in range(d):
            siki=((l[i][k]-l[j][k])**2)
            ans+=siki
        flag=False
        for o in range(ans):
            if o*o==ans:
                flag=True
        if flag:
        	cnt+=1 
print(cnt)
# Judge status: Accepted
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n,k = [int(x) for x in stdin.readline().rstrip().split()]
p = [(int(x)+1)/2 for x in stdin.readline().rstrip().split()]

m = sum(p[0:k])
maxm = m

for i in range(1,n-k+1):
    m = m - p[i-1] + p[i+k-1]
    maxm = max([maxm,m])

print(maxm)
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
B = [A[i]-(i+1) for i in range(N)]
C = sorted(B)
from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left

ans=0

for i in range(N):
    target = -2*(i+1)-B[i]
    l=bisect_left(C, target)
    r=bisect_right(C, target)
    ans+=r-l
print(ans)
# Judge status: Wrong Answer
A, B, C = input().split()

if C >= A:
    if C <= B:
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if c<=(a+2*b):print('Yes')
else:print('No')
# Judge status: Wrong Answer
a = input()
b = input()
c = input()
s = ""
s = a
for i in range(len(a) + len(b) + len(c)):
    if s[0] == "a":
        s = a[1:]
        a = a[1:]
    elif s[0] == "b":
        s = b[1:]
        b = b[1:]
    else:
        s = c[1:]
        c = c[1:]
    if 0 in [len(a), len(b), len(c)]:
        break
    
if len(a) == 0:
    print("A")
elif len(b) == 0:
    print("B")
else:
    print("C")
# Judge status: Wrong Answer
w,h,n = [int(x) for x in input().split()]
xy = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    xy.append(tmp)

r = w
u = h
l = 0
b = 0

for z in xy:
    if z[2] == 1:
        l = max(l, z[0])
    elif z[2] == 2:
        r = min(r, z[0])
    elif z[2] == 3:
        b = max(b, z[1])
    elif z[2] == 4:
        u = min(u, z[1])

print(max((r-l)*(u-b), 0))
# Judge status: Wrong Answer
def main():
    MOD = 10**9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    a_sum = sum(a)
    ans = 0
    
    for i in range(n):
        ans += a[i] * (a_sum - a[i])
        ans %= MOD
    print(ans//2)
        
        
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x = int(input())
ans = 0

if x >= 11:
  ans += x*2 // 11
  x %= 11
while x > 0:
  x -= [6,5][ans%2]
  ans += 1
print(ans)
# Judge status: Accepted
S = input()

W_list = ['Sunny','Cloudy','Rainy','Sunny']

i = 0
while i < 4:
    if W_list[i] == S:
        print(W_list[i+1])
        break
    else:
        i = i+1
# Judge status: Accepted
s = list(input())

for i in range(1<<3):
    form = ""
    for j in range(3):
        form += s[j]
        if i & 1<<j:
            form += "+"
        else:
            form += "-"
    form += s[-1]
    if eval(form) == 7:
        print(form + "=7")
        exit()
# Judge status: Accepted
# 2020/01/12

n,m=map(int,input().split())
ps=[0]*(n+1)
ac=0
wa=0

for i in range(m):
    p,s=input().split()
    p=int(p)
    if ps[p]>0:continue
    if s=='WA':
        ps[p]-=1
    else:
        wa+=-ps[p]
        ps[p]=1
        ac+=1
print(*[ac,wa])
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline

def main():
    ans = 0
    A,B,C = map(int, input().split())
    if A*B*C%2 == 1:
        ans = A*B
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N-K <= 0:
    price = K*X
else:
    price = K*X +(N-K)*Y
print(price)
# Judge status: Accepted
n=int(input())

mod=10**9+7

al=10**n
ex=8**n
a=9**n

x=al-ex

ans=x-(a-ex)*2

print(ans%mod)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    X=input()
    stack=deque()
    for x in X:
        if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):
            stack.append(x)
        elif stack and stack[-1]=='S':
            stack.pop()
    print(len(stack))
if __name__=='__main__':
    main()
# Judge status: Wrong Answer
def adva(a, b) :
  c = (a + b) / 2
  return round(c)
# Judge status: Accepted
N = int(input())
for i in range(1, 10):
    if N%i==0 and N//i<10:
        print("Yes")
        exit(0)
print("No")
# Judge status: Accepted
from sys import stdin
import copy

n = int(input())
S = [stdin.readline()[:-1] for i in [0]*(n)]
#S.append(stdin.readline())
s = []
for i in S:
    s.append("".join(sorted(i)))
s.sort()
arr = []
temp = 1
for i in range(n-1):
    if temp>1 and s[i]!=s[i+1]:
        arr.append(temp)
        temp = 1
    if s[i]==s[i+1]:
        temp += 1
if temp>1:
    arr.append(temp)

ans = 0
for i in arr:
    ans += i*(i-1)//2
print(ans)
# Judge status: Accepted

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

N = lst[0]
L = lst[1]

apple_flavours = []

for i in range(1, N+1):
    apple_flavours.append(L+i-1)


abs_apple_flavours = []

for apple in apple_flavours:
    abs_apple_flavours.append(abs(apple))

min_val = min(abs_apple_flavours)

index = abs_apple_flavours.index(min_val)

total_flavour = 0

for apple in apple_flavours:
    total_flavour += apple

print(total_flavour - apple_flavours[index])
# Judge status: Accepted
S = str(input())
T = str(input())
if T in S*2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,K=map(int,input().split())
h=[int(input())for _ in range(N)]
h.sort()
ans=10**10
for i in range(N-K+1):
	tmp=h[i+K-1]-h[i]
	if tmp<ans:
		ans=tmp
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
ps = [input().split() for i in range(m)]
ac, wa = [0] * n, [0] * n
wa_sum = 0
for i in ps:
    p, s = int(i[0]), i[1]
    if ac[p - 1] == 0 and s == "AC":
        ac[p - 1] += 1
        wa_sum += wa[p - 1]
    else:
        wa[p - 1] += 1
print(sum(ac), wa_sum)
# Judge status: Wrong Answer
import sys
C1 = list(input())
C2 = list(input())

if C2 == C1[::-1]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x,a,b = map(int, input().split())
print("A") if abs(x-a) > abs(x-b) else print("B")
# Judge status: Accepted
# 整数を一つ入力
N = int(input())

res = 0

for i in range(1,N+1):
    if i % 3 == 0:
        continue
    if i % 5 == 0:
        continue
    res += i

print(res)
# Judge status: Wrong Answer
a,b=sorted(map(int,input().split()))
#ユークリッドの互除法
def gcd(a,b):
    if b==0:
        return a
    else:
        return (gcd(b,a%b))
        #recursive function
p=gcd(a,b)

if b%p==0:
    print(b)
elif a%p==0:
    print(a)
elif p!=a and p!=b:
    print(p*a*b)
else:
    print(b)
#ユークリッドの互除法)
# Judge status: Wrong Answer
a = int( input() )
b = int( input() )
h = int( input() )

print( ( a + b ) * h / 2 )
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
print(["Yes","No"][A+2*B<C])
# Judge status: Accepted
from re import finditer
from bisect import bisect_left
from bisect import bisect_right
a,b=map(int,input().split())
c=input()
d=[]
for _ in range(b):
    n,m=map(int,input().split())
    d.append([n-1,m-1])
n=len(d)
ac1=[m.start() for m in finditer('AC', c)]
ac2=[m.end()-1 for m in finditer('AC', c)]
for i in range(n):
    index1=bisect_left(ac1,d[i][0])
    index2=bisect_right(ac2,d[i][1])
    print(index2-index1)
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

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

if a < b:
    for i in range(b):
        print(a, end="")
else:
    for i in range(a):
        print(b, end="")
print("")
# Judge status: Accepted
from collections import deque

n = int(input())
A = list(input().split())
a = [int(A[i]) for i in range(n)]

b = deque([])
b_rev = deque([])

for i in range(n):
    if i % 2 == 0:
        b.append(str(A[i]))
        b_rev.appendleft(str(A[i]))
    else:
        b.appendleft(str(A[i]))
        b_rev.append(str(A[i]))
    
if n % 2 == 0:
    print(' '.join(b))
else:
    print(' '.join(b_rev))
# Judge status: Accepted
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]


ab = a + b

d = int(n / ab)
m = n % ab

if ( a > m):
	sum = a * d + m
else:
	sum = a * d + a

print sum
sys.stdout.flush()
# Judge status: Wrong Answer
#print(1//-2)

n = int(input())
result = ''
while n!=0:
  #print(n)
  if n%-2==0:
    result+='0'
    n = n//-2
    #n+=1
  else:
    result+='1'
    if n<0:
      n = n//-2
      n+=1
    else:
      n = n//-2
      n+=1
result = result[::-1]
print(result)
# Judge status: Accepted
s = list(input())
if len(s)%2 == 0:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2:]
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
#print(s1,s2)
i = 0
j = -1
cnt = 0
while len(s1) > i:
    if s1[i] != s2[j]:
        cnt += 1
    i += 1
    j -= 1
print(cnt)
# Judge status: Accepted
A, B = map(int, input().split())

result = 0
for num in range(A, B+1):
    num_list = list(str(num))
    if (num_list[0] == num_list[4]) and (num_list[1] == num_list[3]):
        result += 1

print(result)
# Judge status: Accepted
h,n = map(int,input().split())
dp = [[10000000000 for i in range(h+1)] for j in range(n+1)]
dp[0][0] = 0


for i in range(n):
    a,b = map(int,input().split())
    for j in range(h+1):
        if dp[i+1][j] > dp[i][j]:
            dp[i+1][j] = dp[i][j]
        nex = min(h,j+a)
        if dp[i+1][nex] > dp[i+1][j] + b:
            dp[i + 1][nex] = dp[i + 1][j] + b


# for line in dp:
#     print(line)

print(dp[-1][h])
# Judge status: Accepted
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
l,r,d = ma()
c= 0
for i in range(l,r+1):
    if i%d==0:
        c+=1
print(c)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print(a * b / 2)
# Judge status: Wrong Answer

#<125>
import itertools
import math
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in itertools.combinations(A, 2):
    ans = max(0, math.gcd(i[0], i[1]))
    
    #print(math.gcd(i[0], i[1]))
print(ans)
# Judge status: Wrong Answer
S = input()
ans = 0
for i in range(len(S)):
    tmp = 0
    for j in range(len(S)):
        if 'ACGT'.count(S[j]) == 1:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0

print(ans)
# Judge status: Accepted
N = int(input())
S = list(input())
E = S[1:].count('E')
W = 0
mi = E+W
for i in range(1,N):
    if S[i] == 'E':E -= 1
    if S[i-1] == 'W':W+=1
    if E+W <= mi:mi = E+W
print(mi)