peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import fractions
N, M = map(int, input().split())
a_array = list(map(int, input().split()))

Q = 2 ** 35

two_count = fractions.gcd(a_array[0], Q)
lcm = 1

for a in a_array:
    aa = a // 2
    if two_count != fractions.gcd(a, Q):
        print(0)
        exit()
    lcm = int(aa * lcm) // fractions.gcd(aa, lcm)
    if lcm > M:
        print(0)
        exit()

# ans = ((M//lcm)+1) // 2
ans = (M-lcm) // (2*lcm) + 1
print(int(ans))
# Judge status: Accepted
N, K = map(int, input().split())
H = list(map(int, input().split()))

H = sorted(H, reverse=True)

del H[:K]
if H:
  total = sum(H)
else:
  total = 0

print(total)
# Judge status: Accepted
# https://atcoder.jp/contests/abc055/tasks/abc055_b

N = int(input())
MOD = 10**9 + 7

power = 1
for i in range(1, N+1):
    power *= i
    power = power % MOD

print(power)
# Judge status: Accepted
def main():
    N = int(input())
    words = [input()]
    ans = True
    for _ in range(N - 1):
        s = input()
        if words[-1][-1] != s[0] or s in words:
            ans = False
        else:
            words.append(s)

    if ans is True:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


c = 0
for z in make_divisors(n)[1:]:
    if n % z == 0:
        n /= z
        c += 1
print(c)
# Judge status: Accepted
N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [1000000000] * N
dp[0] = 0
for i in range(N):
    for k in range(1, K+1):
        if i+k >= N:
            break
        dp[i+k] = min(dp[i+k], dp[i] + abs(H[i] - H[i+k]))

print(dp[N-1])
# Judge status: Accepted
import re
S=input()
if re.fullmatch(r"[a-z]*keyence",S)==None and re.fullmatch(r"k[a-z]*eyence",S)==None and re.fullmatch(r"ke[a-z]*yence",S)==None and re.fullmatch(r"key[a-z]*ence",S)==None and re.fullmatch(r"keye[a-z]*nce",S)==None and re.fullmatch(r"keyen[a-z]*ce",S)==None and re.fullmatch(r"keyenc[a-z]*e",S)==None and re.fullmatch(r"keyence[a-z]*",S)==None:
  print("NO")
else:
  print("YES")
# Judge status: Accepted
X = int(input())

if  X < 9 and X > 1 and X % 2 == 1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
S,W = map(int,input().split())
if S <= W:
    print("unsafe")
else:
    print("safe")
# Judge status: Wrong Answer
import math
(a,b,x)=map(int, input().split(" "))
print(math.floor(b/x)-math.ceil(a/x)+1)
# Judge status: Accepted
S=list(input())
ki=[]
gu=[]
for i in range(len(S)):
    if i%2==0:
        ki.append(S[i])
    else:
        gu.append(S[i])
if ("L" not in ki) and ("R" not in gu):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=input()
if N.count("9")>0 :
  print("Yes")
else :
  print("No")
# Judge status: Wrong Answer
D,N=map(int,input().split())
if D==0:
  print(N)
elif D==1:
  print(100*N)
else:
  print(10000*N)
# Judge status: Wrong Answer
X, A, B = map(int, input().split())

if B <= A:
  print("delicious")
elif A < B < X:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
A1, A2, A3 = map(int, input().split())
if A1 + A2 + A3 >= 22:
  print("bust")
else:
  print("win")
# Judge status: Wrong Answer
n=int(input())
a = [input() for _ in range(n)]
a.sort()
count = 0
i=0
while i<n-1:
  j=i+1
  ex=1
  while j<n:
    if a[j]==a[i]:
      ex=1-ex
      j+=1
    else:
      i=j+1
      count+=ex
      break
print(count+1)
# Judge status: Accepted
N, M = map(int,input().split())
A = sorted(list(map(int,input().split())))
D = [list(map(int,input().split())) for k in range(M)]
D = sorted(D, key = lambda x: -x[1])
D.append([10**9+1,-1])
t = 0
ans = 0
for k in range(N):
    if A[k] < D[t][1]:
        ans += D[t][1]
        D[t][0] -= 1
        if D[t][0] == 0:
            t += 1
    else:
        ans += A[k]

print(ans)
# Judge status: Accepted
from numpy import log
def f(k):
  c=0
  while k % 2 == 0:
    k //= 2
    c+=1
    if c==2:
      break
  return c
def g(k):
  return f(int(k))
n=int(input())
a=list(map(g,input().split()))
ct0=a.count(0)
ct1=a.count(1)
ct2=a.count(2)
if ct0 <= ct2 or (ct0 == ct2 + 1 and ct1==0):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
s = input();
t = input();
ls = len(s);
lt = len(t);
if(ls == (lt - 1)):
    print("Yes");
else:
    print("No");
# Judge status: Accepted
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10**9
for i in range(n - k + 1):
    cand = x[i + k - 1] - x[i] + min(abs(x[i + k - 1]), abs(x[i]))
    ans = min(ans, cand)

print(ans)
# Judge status: Wrong Answer
import math
print(int(math.sqrt(int(input()))))
# Judge status: Accepted
x, y = map(int, input().split())
cnt = abs(abs(x) - abs(y))
if x * y < 0:
  cnt += 1
elif x > y:
  cnt += 2
  if x == 0 or y == 0:
    cnt -= 1
print(cnt)
# Judge status: Accepted
def ceil(a, b):
	return -(-a//b)

n,x,t = map(int,input().split())
print(ceil(n, x)*t)
# Judge status: Accepted
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    r, g, b = LI()

    if (r * 100 + g * 10 + b) % 4 == 0:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()
# Judge status: Accepted
X,Y,Z=[int(x) for x in input().split()]
(X,Y)=(Y,X)
(X,Z)=(Z,X)
print(X,Y,Z)
# Judge status: Wrong Answer
n = int(input())

if n / 10 == 9 or n % 10 == 9:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())

for i in range(1,10**9):
  if (N <= i*(i+1)/2):
    break
print(i)
# Judge status: Wrong Answer
A = list(map(int,input().split()))
fr = 0
for i in range(A[3]):
    if abs(A[0]-A[1]) > 10**18:
        print('Unfair')
        fr += 1
        break
    else:
        A[0] = A[1] + A[2]
        A[1] = A[0] + A[2]
        A[2] = A[0] + A[1]
if fr == 0:
    print(A[0]-A[1])
# Judge status: Wrong Answer
#!/usr/bin/env python3

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

count2 = 0
count4 = 0

for a in A:
    if a % 4 == 0: count4 += 1
    elif a % 2 == 0: count2 += 1

if count2 % 2 == 1: count2 -= 1
if count4*3 + count2 >= N: print('Yes')
else: print('No')
# Judge status: Accepted
def main():
    S = str(input())
    front = int(S[0:2])
    latter = int(S[2:4])
    if front < 13 and latter < 13 and (front > 0 and latter > 0):
        print('AMBIGUOUS')
    elif front < 13 and latter < 100 and front > 0:
        print('MMYY')
    elif front < 100 and latter < 13 and latter > 0:
        print('YYMM')
    else:
        print('NA')
main()
# Judge status: Accepted
S = input()
T = input()
ans = len(T)

for i in range(len(S) - len(T) + 1):
    temp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            temp += 1
    if ans > temp:
        ans = temp

print(ans)
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())
s = min(4 * q, 2 * h, s)
d = min(2 * s, d)
ans = (n // 2) * d + (n % 2) * s
print(ans)
# Judge status: Wrong Answer
def pf(n):
  a = []
  N = n
  for i in range(2, int(pow(N,0.5)//1+2)):
    if n%i==0:
      count=0
      while n%i==0:
        count+=1
        n//=i
      a.append(count)
  if n!=1:
    a.append(1)
  if a==[]:
    a.append(1)
  return a
import fractions
A,B=map(int,input().split())
c=fractions.gcd(A,B)
ans=len(pf(c))
print(ans+(1 if ans>1 else 0))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans_list = list(range(1,N+1))
ans_dict = dict(zip(A, ans_list))

for i in ans_dict:
  print(ans_dict[i], end=" ")
# Judge status: Accepted
a,b,c=map(int,input().split())
x=max(a,b,c)
print(x*9+a+b+c)
# Judge status: Accepted
s = input()

if s == "ABC":
  print("ARC")
else:
  print("ABC")
# Judge status: Accepted
N,T = map(int,input().split())
ans = 1001
for i in range(N):
    c,t = map(int,input().split())
    if t <= T:
        ans = min(ans,c)
        
print('TLE' if ans == 1001 else ans)
# Judge status: Accepted
s,c = list(map(int,input().split()))
if 2*s >= c:
    print(c//2)
else:
    suma = s
    c -= 2*s
    suma += c//4
    print(suma)
# Judge status: Accepted
N,K = list(map(int,input().split()))
ans = 0
for i in range(K,N+2):
    ans += ((((N*2)-i+1)*i//2) - ((i-1)*i//2) +1)
print(ans%(10**9+7))
# Judge status: Wrong Answer
N,X,Y=map(int,input().split())


def count(k):
    count=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if min(abs(j-i),abs(X-i)+abs(Y-j)+1)==k:
                count+=1
                if count >= 4:
                    break
    return count

for k in range(1,N):
    print(count(k))
# Judge status: Accepted
s = input()
prev = ""
current = ""
cnt = 0
for i in s:
  current += i
  if current!=prev:
    cnt+=1
    prev = current
    current = ""
print(cnt)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
wl = [input()]
rule = True
for i in range(1,n):
    s = input()
    if s in wl or s[0] != wl[-1][-1]:
        rule = False
    wl.append(s)

if rule:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 0
while True:
    for i in range(len(a)):
        if not a[i]%2==0:
            print(ans)
            exit()
        else:
            a[i] = a[i]//2
    ans += 1
# Judge status: Accepted
import heapq
n, m = map(int, input().split())
ab = sorted([ list(map(int, input().split())) for _ in range(n) ], reverse=True)
que = []
ans = 0
for i in range(1, m+1):
  while ab and ab[-1][0] <= i:
    t = ab.pop()
    heapq.heappush(que, -t[1])
  if que:
    ans -= heapq.heappop(que)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
num_minus = sum([1 if v < 0 else 0 for v in A])
sum_abs = sum([abs(v) for v in A])
min_abs = min([abs(v) for v in A])
print(sum_abs if num_minus % 2 == 0 else sum_abs - min_abs * 2)
# Judge status: Accepted
import math

def main():
    N, K = map(int, input().split())
    prob = 0
    for i in range(1, N+1):
        if K / i <= 1:
            prob += 1
        else:
            coin = math.ceil(math.log2(K / i))
            prob += 0.5 ** coin
    print(prob / N)


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

curr_min = float('inf')
curr_sum = 0
for i in range(1, N + 1):
    curr_flavour = L + i - 1
    curr_sum += curr_flavour
    if curr_min >= 0:
        curr_min = min(curr_min, curr_flavour)
    else:
        curr_min = max(curr_min, curr_flavour)
print(curr_sum - curr_min)
# 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, m = map(int, input().split())

a, b = [0] * n, [0] * n
c, d = [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())
ans = [0] * n
for i in range(n):
    min = 10 * 20
    for j in range(m):
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if min > dis:
            min = dis
            ans[i] = j + 1
    print(ans[i])
# Judge status: Accepted
import math
n = int(input())
a = [int(input()) for i in range(5)]
print(math.ceil(n/min(a))+4)
# Judge status: Accepted
abc=sorted(list(map(int,input().split())))
if abc[0]+abc[1]==abc[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
x, y = list(map(int, input().split()))

print(x + y//2)
# Judge status: Wrong Answer
n = int(input())
line = [int(x) for x in input().split()]
count = 0
for i in range(1, n, 2):
    if line[i] % 2 != 0:
        count += 1
print(count)
# Judge status: Accepted
#071_C
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a).most_common()
edges = []
for l, cnt in c:
    if cnt < 2:
        break
    else:
        edges.append(l)
        if cnt > 3:
            edges.append(l)
edges.sort(reverse= True)
if len(edges) < 2:
    print(0)
else:
    print(edges[0] * edges[1])
# Judge status: Accepted
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

n=IN()
a=LI()
p=1
if 0 in a:
    print(0)
    exit()
for i in a:
    p*=i
    if p>pow(10,18):
        print(-1)
        exit()
print(p)
# Judge status: Wrong Answer
n = int(input())
s = input()
cnt = 1

for i in range(1, n):
    c = 0
    s1 = s[i:]
    s2 = s[:i]
    S = set(s1)

    for j in S:
        if j in s2:
            c += 1
    cnt = max(cnt, c)

print(cnt)
# Judge status: Accepted
def main():
    C = input()
    print(chr(ord(C) + 1))


if __name__ == "__main__":
    main()
# Judge status: Accepted
import itertools
import fractions
n=int(input())
a=list(map(int,input().split()))
a.sort()
mina=a[0]
ans = 10**18
for i in range(n):
	ans = min(ans, fractions.gcd(a[i], mina))
print(ans)
# 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

if K > a:
    b -= K - a - 1
    if b < 0:
        b = 1
if K > b:
    a -= K - b - 1
    if a < 0:
        a = 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
h1, m1, h2, m2, k = map(int, input().split())
piyo = h2*60 + m2 - (h1*60 + m1)
result = (piyo // k - 1) * k
print(result)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())
x=[]
if (B-A) <= K:
    for i in range(A, B+1):
        print(i)
else:
    for i in range(A, A+K):
        x.append(i)
    for i in range(B-K, B+1):
        x.append(i)
for i in x:
    print(i)
# Judge status: Accepted
#a,b = map(int, input().split())
import math
if __name__ == "__main__":
    H,A = map(int,input().split())
    print(math.ceil(H / A))
# Judge status: Accepted
s=input()
l=len(s)
p0=[0]*l
p1=[1]*l
for i in range(l):
    if i%2==1:
        p0[i]=1
        p1[i]=0
c0=0
c1=0
for i in range(l):
    if int(p0[i])!=int(s[i]):
        c0+=1
for i in range(l):
    if int(p1[i])!=int(s[i]):
        c1+=1
print(min(c0,c1))
# Judge status: Accepted
t=int(input())
if t>=30:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
Q, H, S, D = map(int, input().split())
N = int(input())

if N%2:
    if D/2 < min(Q*4, H*2, S):
        print(int(N//2*(D/2))+(N-N//2)*min(Q*4, H*2, S))
    else:
        print(N*min(Q*4, H*2, S))
else:
    print(int(N*min(Q*4, H*2, S, D/2)))
# Judge status: Accepted
k = int(input())

if k%2==1:
    print((k//2+1)*(k//2))
else:
    print(k**2//4)
# Judge status: Wrong Answer
n=int(input())
abc=[[-1,-1,-1]]
memo=[-1 for i in range(n+1)]
for i in range(n):
  a,b,c=map(int,input().split())
  abc.append([a,b,c])
dp=[0 for i in range(n+1)]
for i in range(1,n+1):
  for j in range(3):
    if memo[i-1]==j:
      continue
    elif dp[i]<dp[i-1]+abc[i][j]:
      memo[i]=j
      dp[i]=dp[i-1]+abc[i][j]
print(dp[-1])
# Judge status: Accepted
from math import floor
from decimal import Decimal
a, b = input().split()
a = int(a)
b = Decimal(b)
print(floor(a * b))
# Judge status: Wrong Answer
n = int(input())

sp = []

for i in range(n):
  s,p = map(str,input().split())
  sp.append([s,int(p),i+1])


sp.sort(key = lambda x:x[1],reverse = True)
sp.sort(key = lambda x:x[0],reverse = True)

for i in sp:
  print(i[2])
# Judge status: Wrong Answer
n,a,b,c,d=map(int,input().split())
s=input()
s = list(s)
if c > d:
    x=b
    y=d
    b,d=a,c
    a,c=x,y
s[b-1] = "#"
for i in range(b-1,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
s[b-1] = "."
s[d-1] = "#"
for i in range(a-1,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
a,b=map(int,input().split())

if (a+b)%2==0:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")
# Judge status: Wrong Answer
c = input()
for c in "aiueo":
  print("vowel")
else:
  print("consonant")
# Judge status: Accepted
import numpy as np
import math
A,B,H,M = input().split()
A = int(A)
B = int(B)
H = int(H)
M = int(M)

angle = abs(30* H - 5.5 * M)
if angle > 180:
  angle = 360 - angle

ans = np.sqrt((A**2 + B**2) - (2 * A * B * np.cos(np.radians(angle))))
print(ans)
# Judge status: Accepted

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

print(max(a+a-1,b+b-1,a+b))
# Judge status: Accepted
s = input()
yyyy, mm, dd = [int(n) for n in s.split("/")]
print("Heisei" if mm < 5 else "TBD")
# Judge status: Accepted
N, L = map(int, input().split())

Ts = []
for idx in range(1, N+1):
    taste = idx + L - 1
    Ts.append(taste)

min_t = 20000000000
total = sum(Ts)
for t in Ts:
    if abs(t) < abs(min_t):
        min_t = t
print(total-min_t)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
    if i % 2 == 0 and a[i] % 2 != 0:
        ans += 1

print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())
x = 0
y = 0
if a >= 0 and c >= 0:
  x = b
  y = d
elif a >= 0 and d < 0:
  x = a
  y = d
elif b < 0 and c >= 0:
  x = b
  y = c
elif b <= 0 and d <= 0:
  x = a
  y = c

print(x * y)
# Judge status: Accepted
N, K, S = map(int, input().split())
S2 = S-1 if S == 1000000000 else S+1
As = [S]*K+[S2]*(N-K)
print(" ".join(map(str, As)))
# Judge status: Wrong Answer
s1,s2,s3 = input().split('/')
print('2017/01/'+s3)
# Judge status: Accepted
s = list(input())
t = list(input())

S = sorted(s)
T = sorted(t, reverse = True)


U = min(len(s), len(t))

for i in range(U):
    if S[i] < T[i]:
        print("Yes")
        exit()
    elif S[i] == T[i]:
        continue
    else:
        print("No")
        exit()
    
if len(S) < len(T):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import math
from fractions import Fraction
N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if i >= K:
    ans += Fraction(1, N)
  else:
    ans += Fraction(1, N) * Fraction(1, 2) ** (int(math.log2(K / i)) + 1)
  
print(float(ans))
# Judge status: Wrong Answer
# Code for A - 500 Yen Coins
# Use input() to fetch data from STDIN
print("Hello world")
# Judge status: Accepted
N, M = map(int, input().split())
A = []
for i in range(N):
    A_i = list(map(int, input().split()))
    A.append(A_i[1:])

sum = [0]*M
for i in range(N):
    for j in range(len(A[i])):
        sum[A[i][j]-1] += 1

print(sum.count(N))
# Judge status: Accepted
A,B,C=map(int,input().split(' '))
if A+B >= C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from array import array
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = array("u", list(input()))

for i in range(k, n):
    if t[i] == t[i-k]:
        t[i] = "*"

ans = (t.count("r") * p +
       t.count("s") * r +
       t.count("p") * s)

print(ans)
# Judge status: Accepted
n=int(input())
tmp=n//15
print((800*n)-tmp*200)
# Judge status: Wrong Answer
n = int(input())
s = input()
ans = -1*float('inf')
for i in range(0, n-1):
  x = set(s[:i+1])
  y = set(s[i+1:])
  dif = max(x, y) - min(x, y)
  ans = max(ans, len(max(x, y) - dif))
print(ans)
# Judge status: Wrong Answer
n=input()
ans=0
for i in range(len(n)):
    ans+=int(n[i])
if ans==int(n[0]):
    ans+=9
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ami = [a[i]-(i+1) for i in range(n)]
ami.sort()
# print(ami)
ans = 0
for i in range(n):
    ans += abs(ami[i] - ami[n // 2])
print(ans)
# Judge status: Wrong Answer
import collections
N = int(input())
A = list((map(int,input().split())))

index = list(range(1,N+1))

R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]

R_dict = collections.Counter(R)
L_dict = collections.Counter(L)

ans=0
for i in R_dict.keys()&L_dict.keys():
    ans+=max(R_dict[i], L_dict[i])

print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]

ans = Counter(S[0])
for i in range(1,n):
  tmp = Counter(S[i])
  for a in ans.keys():
    if a in tmp:
      ans[a] = min(ans[a],tmp[a])
    else:
      ans[a] = 0
x = ''
for a in ans.items():
  x += a[0]*a[1]
print(x)
# Judge status: Accepted
N = int(input())
xl = [list(map(int, input().split())) for _ in range(N)]
rl = []
for i in range(N):
    rl.append((xl[i][0] - xl[i][1], xl[i][0] + xl[i][1]))
rl.sort(key=lambda x: x[1])
cnt = 0
tmp = -10 ** 18

for i, j in rl:
    if tmp <= i:
        cnt += 1
        tmp = j
print(cnt)
# Judge status: Accepted
list1 = input()
list2 = list1.split()
a = int(list2[0])
b = int(list2[1])
c = int(list2[2])
d = int(list2[3])

#x = [i for i in range(a,b+1)]
#y = [j for j in range(c,d+1)]

x_min = a
x_max = b
y_min = c
y_max = d

answer_list = [x_max*y_max, x_max*y_min, x_min*y_max, x_min*y_min]

print(max(answer_list))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = list(mapint())
As.sort()

BC = [list(mapint()) for _ in range(M)]
BC.sort(key=lambda x: x[1])

cum = 0
for b, c in BC[::-1]:
    if c<As[0]:
        break
    As.extend([c]*b)
    cum += b
    if cum>=N:
        break

As.sort(reverse=True)
print(sum(As[:N]))
# Judge status: Accepted
#!/usr/bin/env python3

T = list(input())

cnt = 0
for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

print(''.join(T))
# Judge status: Wrong Answer
r,g,b=map(int, input().split())

if (r*100+g*10+b)%4==0:
    print("Yes")

else:
    print('No')
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(1,n-1):
  if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
    c+=1
print(c)
# Judge status: Wrong Answer
import collections
n=int(input())
a=list(map(int,input().split()))
b=collections.deque()

for i,x in enumerate(a):
    if i%2==1:
        b.appendleft(x)
    else:
        b.append(x)
for i in b:
    print(i)
# Judge status: Wrong Answer
import math
lists = list(map(int, input().split()))
n = lists[0]
a,b = lists[1],lists[2]
skip_num = [a,b]
r = 0
for i in range(1,n+1):
    if i not in skip_num:
        print(i)
        r = r + (math.factorial(n)/(math.factorial(n-i)*math.factorial(i)))
print(r)
# Judge status: Accepted
def gcd(x, y):
  while(x % y != 0 and y % x != 0):
    if(x > y):
      x = x % y
    else:
      y = y % x
  if(x > y):
    return y
  else:
    return x
  
N = int(input())
A = list()
for i in range(N):
  A.append(int(input()))

ans = 1
for i in range(N):
  gcd_i = gcd(A[i], ans)
  ans = A[i] * ans // gcd_i
  
print(ans)
# Judge status: Accepted
a,b=map(str,input().split())
a=int(a)
c=''
for i in b:
  if i=='.':
    continue
  else:
    c+=i
c=int(c)
print(int(a*c//100))
# Judge status: Accepted
N, M = [int(i) for i in input().split()]
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        for ii in range(M):
            for jj in range(M):
                if A[i+ii][j+jj] != B[ii][jj]:
                    break
            else:
                continue
            break
        else:
            print("Yes")
            exit()
print("No")
# Judge status: Wrong Answer
ans = "Yes"
s = input()
if s != s[::-1]: # スライスというやつ
  ans = "No"
n = len(s) // 2
if s[:n] != s[0:n:-1]:
  ans = "No"
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
print(((1+(b-a))*(b-a))//2-b)
# Judge status: Wrong Answer
import collections
N = int(input())
a = collections.Counter(list(map(int,input().split())))
p = sorted([i for i in a.items() if i[1]>=2])
if len(p)<2:
    print(0)
else:
    print(p[-1][0]*p[-2][0])