Harryxun/stf_run huggingface dataset:
https://atcoder.jp/contests/abc142/custom_test
def sieve(n):
    nums = [i+1 for i in range(2, n, 2) if (i+1) % 3 != 0 and (i+1) % 5 !=0] # リスト内包表記で3,5の倍数をはじく
    ans = [2,3,5] # 3,5は素数なので加えてしまう
    while nums[0] <= n**0.5:
        for i in range(nums[0]**2, nums[-1]+1, nums[0]):
            if i in nums: nums.remove(i)
            ans.append(nums.pop(0))
            ans += nums
    return ans


A,B =map(int,input().split())
if A<B:
    A,B =B,A
foo = 1
while foo != 0:
    A,B = B, A%B
    #print(A,B)
    foo = B

foo =A

plis = sieve(1000)
ans = 1
for p in plis:
    if foo%p==0:
        ans += 1
        foo = foo//p
    while foo%p ==0:
        foo = foo//p



plis = sieve(max(7,foo))

for p in plis:
    if  foo % p ==0:
        ans += 1
        foo = foo//p
        if foo < 1:
            break
print(ans)


### FIXED CODE ###


A,B = map(int,input().split())

#素数列挙
def searchPrimeNum(N):
    max = int(N**0.5)
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum



#素因数分解(素数列挙が必要)
def pfact(N):
    plis = searchPrimeNum(int(N**0.5+1))
    ans = 1
    for p in plis:
        if N%p == 0:
            ans += 1
            N = N//p
        while N%p == 0:
            N = N//p
        if N == 1:
            break
    if N != 1:
        ans += 1
    return ans

#互除法(最大公約数)
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

print(pfact(gcd(A,B)))
X, A = list(map(input().split()))
if X < A :
	print(0)
else :
	print(10)

### FIXED CODE ###

X, A = list(map(int, input().split()))
if X < A :
	print(0)
else :
	print(10)
using System;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    long[] a = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long ans = 1;
    a.Sort();
    if(a[0] == 0){
      Console.Write(0);
      return;
    }
    for(int i = 0;i<n;i++){
      if(ans*a[i] > 1e18){
        Console.Write(-1);
      	return;
      }
      ans *= a[i];
    }
    Console.Write(ans);
  }
}

### FIXED CODE ###

def Ii():return int(input())
def Mi():return map(int,input().split())
def Li():return list(map(int,input().split()))
n = Ii()
a = sorted(Li())

mx = 10**18
ans = 1
for i in a:
  
  ans *= i
  if ans > mx:
    ans = -1
    break
  elif ans == 0:
    break
    
print(ans)
A, B, C = map(int, input().split())
if A + B >= C - 1:
    print("{}".format(B+C)
else:
    print("{}".format(A+2*B+1))

### FIXED CODE ###

A, B, C = map(int, input().split())
if A + B >= C - 1:
    print(B+C)
else:
    print(A+2*B+1)
from sys import stdin
A = stdin.readline()
B = stdin.readline()
C = stdin.readline()

X = A + B - C
if X >= 0:
    print(X)
else:
    print(0)


### FIXED CODE ###

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

X = b + c - a
if X >= 0:
    print(X)
else:
    print(0)
n = int(input())
f = []
s = []
p = []
for i in range(n):
    f += [list(map(str, input().split(" ")))]
    s += [f[i][0]]
    p += [int(f[i][1])]
print(p)
s.sort()
p.sort(reverse=True)
print(p)
ans = [0] * n
count = 0
for i in s:
    for j in p:
        if [i, str(j)] in f:
            ans[count] = f.index([i, str(j)]) + 1
            p[p.index(j)] = 0
            s[s.index(i)] = 0
            count += 1

for i in range(n):
    print(ans[i])


### FIXED CODE ###

n = int(input())
sr = []
ans = [0]*n
for _ in range(n):
    s,r = input().split()
    sr += [[str(s), int(r)]]
se = sorted(sr, key=lambda x: (x[0], -x[1]))
for i in range(n):
    ans[i] = sr.index(se[i])+1
for i in range(n):
    print(ans[i])
A,B = (int(i) for i in input().split())

import math

def lcm(x, y):
	return (x * y) // math.gcd(x, y)

print(lcm(A,B))

### FIXED CODE ###

A,B = (int(i) for i in input().split())

import fractions

def lcm(a, b):
    #return a * b // math.gcd(a, b)
    return  a*b // fractions.gcd(a, b)

print(lcm(A,B))
_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = [[int(p) for p in i.split()] for i in _input[1:n]]

if not edge:
    print(k)
else:
    import collections
    import math
    from scipy.special import perm


### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

_input = [i for i in open(0).read().split('\n') if i]
n, k = [int(i) for i in _input[0].split()]
edge = tuple([tuple([int(p) for p in i.split()]) for i in _input[1:n]])

factorial = [0] * (k + 1)
inverse = [0] * (k + 1)
MOD = 1000000007

# Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/175024
def mod_pow1(n, k, mod):
    a = 1
    while k:
        if (k & 1) == 1:
            a = (a * n) % mod
        n = (n * n) % mod
        k >>= 1
    return a

# Ref: https://www.smartbowwow.com/2018/10/mod1097.html
def mod_pow2(n, k, mod):
    if k == 0:
        return 1
    if k % 2 == 0:
        a = mod_pow2(n, k // 2, mod)
        return (a * a) % mod
    else:
        return (n * mod_pow2(n, k - 1, mod)) % mod

#mod_pow = mod_pow1
# It's better to use built-in function for speed.
mod_pow = pow

def mod_factorial_inverse(k, mod):
    factorial[0] = 1
    inverse[0] = 1

    # Ref: http://keita-matsushita.hatenablog.com/entry/2016/12/05/184011
    for i in range(1, k + 1):
        factorial[i] = ((i * factorial[i - 1]) % mod) # factrial[i]
        inverse[i] = mod_pow(factorial[i], mod - 2, mod) # inverse[i]
 
total = 1

if not edge:
    print(k)
else:
    all_edge = tuple([[] for _ in range(n + 1)])
    for e in edge:
        all_edge[e[0]].append(e[1])
        all_edge[e[1]].append(e[0])
    all_edge = [set(v) for v in all_edge]

    if [v for v in all_edge if len(v) >= k]:
        print(0)
    else:
        mod_factorial_inverse(k, MOD)

        root = edge[0]
        total = (factorial[k] * inverse[k - len(all_edge[root[0]]) - 1]) % MOD

        def dfs(current, from_):
            global total
            child = all_edge[current]
            if len(child) - 1 > 0:
                total = (total * factorial[k - 2] * inverse[k - 2 - (len(child) - 1)]) % MOD
            for c in child:
                if c != from_:
                    dfs(c, current)
        for c in all_edge[root[0]]:
            dfs(c, root[0])
        print(total)
from collections import defaultdict
N, M = map(int, input().split())
P = [input().split() for _ in range(M)]
X = defaultdict(int)
ac = 0
wa = 0
for pi in P:
    i = int(pi[0])
    s = pi[1]
    if X[i-1] == 0:
        if s == 'WA':
            wa += 1
        else:
            ac += 1
            X[i-1] = 1

print(ac, wa)

### FIXED CODE ###

C = input()
C_next = chr(ord(C) + 1)
print(C_next)
a = int(input())
b = int(input())
 
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")

### FIXED CODE ###

a, b = map(int,input().split())
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")
a = input()
b = input()
X = b - a 
s = int((X*(X+1))/2 - b)
print(s)

### FIXED CODE ###

N = int(input())
if N > 999:
    print('ABD')
elif N <= 999:
    print('ABC')
n = input()
s = input()
x = 0
y = 0

for i in range(n - 1):
  if s[i] == "I":
    y += 1
    x = max(x,y)
  if s[i] == "D":
    y = y - 1

print(x)

### FIXED CODE ###

input()
s=input()
c,m=0,0
for i in range(len(s)):
    if s[i]=="I":
        c+=1
        m=max(c,m)
    if s[i]=="D":
        c=c-1
        m=max(c,m)
print(m)
import numpy as np
import itertools

H, W, K = list(map(int, input().split())) 
c = [list(input()) for i in range(H)]

c.replace("." , 0)
c.replace("#" , 1)

C_arr = np.array(c)

In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertolls.product([0,1] , repeat=W)))

ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
    
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
    
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
    
    if ICO.count(1) == k:
      ans += 1
      
print(ans)


### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
D,N = I()
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N*100)
else:
    if N == 100:
        print(1010000)
    else:
        print(N*10000)

### FIXED CODE ###

import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

D,N = I()
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N*100)
else:
    if N == 100:
        print(1010000)
    else:
        print(N*10000)
X, Y, Z, K = map(int, input().split())
A = sorted([int(x) for x in input().split()], reverse=True)
B = sorted([int(x) for x in input().split()], reverse=True)
C = sorted([int(x) for x in input().split()], reverse=True)

bi_comb = []
for i in range(min(X, K)):
    for j in range(min(Y, K)):
        if (i+1)*(j+1) > K:
            break
        bi_comb.append(A[i] + B[j])
bi_comb.sort(reverse=True)

tri_comb = []
for k in range(K):
    for l in range(min(Z, K)):
        if (k+1)*(l+1) > K:
            break
        tri_comb.append(bi_comb[k] + C[l])
tri_comb.sort(reverse=True)

print(*tri_comb[:K], sep="\n")

### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted([int(x) for x in input().split()], reverse=True)
B = sorted([int(x) for x in input().split()], reverse=True)
C = sorted([int(x) for x in input().split()], reverse=True)

bi_comb = []
for i in range(min(X, K)):
    for j in range(min(Y, K)):
        if (i+1)*(j+1) > K:
            break
        bi_comb.append(A[i] + B[j])
bi_comb.sort(reverse=True)

tri_comb = []
for k in range(min(len(bi_comb), K)):
    for l in range(min(Z, K)):
        if (k+1)*(l+1) > K:
            break
        tri_comb.append(bi_comb[k] + C[l])
tri_comb.sort(reverse=True)

print(*tri_comb[:K], sep="\n")
import collections
from itertools import combinations
import math
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def gcd(*numbers):
    return reduce(math.gcd, numbers)

L = collections.Counter(prime_factorize(N-1))
# print(L)
A = 1
for i,v in L.items():
    A *= (v+1)
# 1を抜く
A -= 1 

c = collections.Counter(prime_factorize(N))
prime = list(dict(c).keys())
d = []
for i in range(1,len(c)):
    d += list(combinations(prime,i))
be = list(c.values())


D = 0
if len(be) > 1:
    beki = math.gcd(be)
else:
    beki = be[0]
    while beki%2 == 0:
        beki = beki //2
        D += 1

# C = 1
# for i,v in L.items():
#     C *= (v+1)
# C -= 1

B = 1
for divisor in d:
    a = N
    b = 1
    print(divisor)
    for i in divisor:
        b *= i ** c[i]
        a /= (i ** c[i])
    if b >= a:
        amari = b%a
        print(b,a,amari)
        if amari == 1:
            B += 1

# print(A,B,D)
print(A+B+D)

### FIXED CODE ###

import math
N = int(input())
M = int(math.sqrt(N))
M2 = int(math.sqrt(N-1))
y = []
for i in range(1,M2+1):
    if (N-1)%i == 0:
        m = (N-1)//i
        if not m == 1:
            y.append(m)
        if i == 1 or i == m:
            continue
        else:
            y.append(i)
count = len(y)

y = []
for i in range(1,M+1):
    if N%i == 0:
        m = N//i
        y.append(m)
        if i == 1 or i == m:
            continue
        else:
            y.append(i)

for i in y:
    NN = N
    while NN%i == 0:
        NN /= i
    # print(NN)
    if int(NN) % i == 1:
        count += 1
        # print(i)

print(count)
n,a,b=map(int,input().split())
ans=2**n
n1=1
n2=1
for i in range(1,1+a):
    n1 = n1 * (n - i + 1) / i
    n1%=10**9+7
for j in range(1,1+b):
    n2 = n2 * (n - j + 1) /j
    n2%=10**9+7
ans-=n1+n2
ans=ans%(10**9+7)
print(int(ans-1))

### FIXED CODE ###

def cmb(n, r, mod):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c

n, a, b = map(int, input().split())
MOD = 10**9 + 7
print((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)
n = input()
a = list(map(int, input()))
for i in a:
    i = 1/i
print(sum(i) for i in a)

### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
a = [1/i for i in a]
b = sum(t for t in a )
print(1/b)
s=str(input())
t=str(input())
t.depend(-1)
if(s==t):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=str(input())
t=str(input())
r=t[:len(t)-1]

if(s==r):
  print("Yes")
else:
  print("No")
import sys

h,w = map(int,raw_input().split())
if h == 0 and w == 0:
    break

for i in range(h):
    for j in range(w):
        sys.stdout.write("#")
    if i != h-1:print "\n",

### FIXED CODE ###

while True:
    h,w = map(int, raw_input().split())
    if h == w == 0:
        break
    print (("#" * w + "\n") * h)
from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 7 + 10)


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


@lru_cache(maxsize=None)
def pattern(t, k, x):
    # print('', t, k, x)
    if k * x < t:
        # print(t, k, x, 0)
        return 0
    if k * x == t or t == 0 or k == 1:
        # print(t, k, x, 1)
        return 1
    ans = pattern(t, k, x - 1)
    # print(f'  ({t} {k} {x} 0 {ans})')
    for i in range(1, t // x + 1):
        ans = (ans + pattern(t - x * i, k - i, x - 1) * facts[k] * invs[i] * invs[k - i]) % MOD
        # print(f'  ({t} {k} {x} {i} {ans})')

    # print(t, k, x, ans)
    return ans


MOD = 998244353
n, m = list(map(int, input().split()))
facts, invs = prepare(n, MOD)
print(pattern(3 * m, n, 2 * m))


### FIXED CODE ###

from functools import lru_cache


def prepare(n, MOD):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs):
    @lru_cache(maxsize=None)
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


MOD = 998244353
n, m = list(map(int, input().split()))
facts, invs = prepare(n + 3 * m, MOD)
nhr = get_nhr(n, facts, invs)
ans = 0
for odd in range(m % 2, min(m, n) + 1, 2):
    tmp = nhr((3 * m - odd) // 2)
    if odd > 0:
        tmp -= odd * nhr((m - odd) // 2)
    if odd < n and odd <= m - 2:
        tmp -= (n - odd) * nhr((m - odd - 2) // 2)
    ans = (ans + facts[n] * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
print(ans)
from collections import Counter
a,b,n = 0,0,int(input())
n1 = n//2 + n%2
n2 = n//2
z = list(map(int,input().split()))
a,b = Counter(z[0::2]).most_common(2),Counter(z[1::2]).most_common(2)

if a[0] == b[0]:
	print(n2)
elif len(a) == 1 and len(b) == 1:
    print(int(n/2))
else:
	print(n1 - a[0][1]+n2 - b[0][1])

### FIXED CODE ###

n = int(input())
p = 1110

print(p-n)
S = input()
T = 0
for i in range(len(S)//2):
  if S[i] == S[len(S)//2 + 1]:
    T+=1
print(T)

### FIXED CODE ###

S = input()
T = 0
for i in range(len(S)//2):
  if S[i] != S[len(S) -1 -i]:
    T+=1
print(T)
x = raw_input()
a = int(x[0:1])
b = int(x[2:3])
aa = a*2 + b*2
bb = a*b
print bb + " " + aa

### FIXED CODE ###

x = map(int,raw_input().split())
aa = x[0] * x[1]
bb = x[0]*2 + x[1]*2
print aa,bb
import math
n = int(input())
s = [input() for i in range(n)]

ans = 0
b_pre = []
a_suf = []
ab = []
for st in s:
    if st.startswith("B") and st.endswith("A"):
        ans += st.count("AB")
        ab.append(st)
    elif st.startswith("B"):
        ans += st.count("AB")
        b_pre.append(st)
    elif st.endswith("A"):
        ans += st.count("AB")
        a_suf.append(st)
    else:
        ans += st.count("AB")

if len(b_pre) - len(a_suf) > 1:
    while len(b_pre) - len(a_suf) > 1:
        for b in b_pre:
            if b.endswith("A"):
                a_suf.append(b)
                b_pre.remove(b)
            if len(b_pre) - len(a_suf) <= 1:
                break
elif len(a_suf) - len(b_pre) > 1:
    while len(a_suf) - len(b_pre) > 1:
        for a in a_suf:
            if b.startswith("B"):
                b_pre.append(b)
                a_suf.remove(b)
            if len(a_suf) - len(b_pre) > 1:
                break

ans += math.ceil(len(ab)/2)
if len(b_pre) < len(a_suf):
    ans += len(b_pre)
    ans += len(a_suf) - len(b_pre)
else:
    ans += len(a_suf)
    ans += len(b_pre) - len(a_suf)


print(ans)

### FIXED CODE ###

def main():
    N = int(input())
    ab_cnt = 0
    b_cnt = 0
    a_cnt = 0
    ans = 0
    for _ in range(N):
        S = input()
        ans += S.count("AB")
        if S[0] == "B" and S[-1] == "A":
            ab_cnt += 1
        elif S[0] == "B":
            b_cnt += 1
        elif S[-1] == "A":
            a_cnt += 1
    if ab_cnt > 1:
        ans += max(ab_cnt - 1, 0)
        ab_cnt = 1
    if a_cnt <= b_cnt:
        ans += a_cnt
        a_cnt = 0
        b_cnt -= a_cnt
    elif b_cnt < a_cnt:
        ans += b_cnt
        b_cnt = 0
        a_cnt -= b_cnt
    if ab_cnt > 0 and (a_cnt > 0 or b_cnt > 0):
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()
print(n*(n-1)//2)

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
A,B = map(int,input().split())

if 6 <= A <= 12 :
	amswer = B / 2
elif A <=5 :
	answer = 0
else:
answer = B

print(answer)

### FIXED CODE ###

A,B = map(int,input().split())

if 6 <= A <=12 :
	answer = B / 2
elif A <=5 :
	answer = 0
else:
	answer = B

print(int(answer))
n=int(input())
a=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
    for j in range(n):
        dp[i][j]=max(dp[i-1][(j+1)%3]+a[i][(j+1)%3],dp[i-1][(j+2)%3]+a[i][(j+2)%3])
print(max(dp[-1]))

### FIXED CODE ###

n=int(input())
x=[list(map(int, input().split())) for i in range(n)]
dp=[[0]*3 for i in range(n+1)]
for i in range(n):
    for j in range(3):
        dp[i+1][j]=max(dp[i][(j+1)%3],dp[i][(j+2)%3])+x[i][j]
print(max(dp[-1]))
n, k = map(int, input().split())
a = list(map(int, input().split()))

lenbin = len(bin(max(max(a), k))) - 2
bitcnt = [0] * lenbin

for i in range(lenbin):
    for ai in a:
        if ai & (1 << i):
            bitcnt[i] += 1

x = 0
for i in range(n - 1, -1, -1):
    if bitcnt[i] <= n // 2 and x + (1 << i) <= k:
        x += (1 << i)

ans = 0
for ai in a:
    ans += (x ^ ai)

print(ans)

### FIXED CODE ###

#!/usr/bin/python3

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

lenbin = len(bin(max(max(a), k))) - 2
bitcnt = [0] * lenbin

for i in range(lenbin):
    for ai in a:
        if ai & (1 << i):
            bitcnt[i] += 1

x = 0
for i in range(lenbin - 1, -1, -1):
    if bitcnt[i] <= n // 2 and x + (1 << i) <= k:
        x += (1 << i)

ans = 0
for ai in a:
    ans += (x ^ ai)

print(ans)
from collections import defaultdict, Counter

def main():
    num = int(input())
    ans_dic = Counter(list(input()))
    for i in range(num - 1):
        aaa = Counter(list(input()))
        ans = defaultdict(int)
        for ele in ans_dic.keys():
            if ele in aaa.keys():
                ans[ele] += min(ans_dic[ele], aaa[ele])

    ans = sorted(ans.items(), key=lambda x: -x[1])

    for moji, kosuu in ans:
        for i in range(kosuu):
            print(moji, end='')

    print()



if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict, Counter

def main():
    num = int(input())
    hajime = list(input())

    ans = Counter(hajime)

    for i in range(num - 1):
        aaa = Counter(list(input()))
        ans_kari = defaultdict(int)
        for ele in ans.keys():
            if ele in aaa.keys():
                ans_kari[ele] = min(ans[ele], aaa[ele])
        ans = ans_kari

    for i in range(26):
        for j in range(ans[chr(97 + i)]):
            print(chr(97 + i), end='')

    print()



if __name__ == '__main__':
    main()
import numpy as np

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

blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*N)
print(np.count_nonzero(ball[0:N]==1))


### FIXED CODE ###

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

r=N//(A+B)*A
s=N%(A+B)

x=r+min(A,s)
print(x)
A, B = map(int, input().split())
def primes(n):
    ret = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


prime_list = primes(min(A, B))
ans = 1

### FIXED CODE ###

from math import sqrt, ceil
import fractions
A, B = map(int, input().split())


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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


ans = 1

tmp = make_divisors(fractions.gcd(A, B))

for x in tmp:
    if is_prime(x):
        ans += 1

print(ans)
A = 5
  B = 3
  total = 0
  if A < B:
    total += B
    if A < B - 1:
      total += B - 1
    else:
      total += A
  elif B < A:
    total += A
    if B < A - 1:
      total += A - 1 
    else:
      total += B
  else:
    total = A + B 
  return total

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,2*a-1,2*b-1))
axis_1 = '0154' * 2  # 2 -> 3
axis_2 = '0253' * 2  # 4 -> 1
axis_3 = '3124' * 2  # 0 -> 5

right = [axis_3, axis_2[::-1], axis_1, axis_1[::-1], axis_2, axis_3[::-1], ]
a = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    top, front = map(a.index, map(int, input().split()))
    x = '%d%d' % (top, front)
    for i, axis in enumerate(right):
        if x in axis:
            print(a[i])
            break
    else:
        print('------------------')
        print(x)

### FIXED CODE ###

a = list(map(int, input().split()))
commands = input()
for command in commands:
    if command == 'N':
        a[0], a[1], a[5], a[4] = a[1], a[5], a[4], a[0]
    elif command == 'S':
        a[0], a[1], a[5], a[4] = a[4], a[0], a[1], a[5]
    elif command == 'W':
        a[0], a[3], a[5], a[2] = a[2], a[0], a[3], a[5]
    elif command == 'E':
        a[0], a[3], a[5], a[2] = a[3], a[5], a[2], a[0]
print(a[0])