Harryxun/stf_run huggingface dataset:
a,b,k = map(int,input().split())
m = []
for i in range(min(a,b),0,-1):
    if a%i == 0 and b%i == 0:
        m.append(i)
        if c == k:
            break
print(m[k-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
 
cand = []
for i in range(100,0,-1):
  if A%i == 0 and B%i == 0:
    cand += [i]
    
    
print(cand[K-1])
from collections import deque


def i_to_b(n, N):
    A = [0] * N
    for i in range(N):
        A[i] = (n // 2**i) % 2
    return A


fact = [1] * 17
for i in range(1, 17):
    fact[i] = fact[i-1] * i


def combination(n, r):
    return fact[n] // fact[r] // fact[n-r]


def main():
    N, A, B = map(int, input().split())
    binA = i_to_b(A, N)
    binB = i_to_b(B, N)
    if abs(sum(binA) - sum(binB)) % 2 == 0:
        print("NO")
        return
    visited = set()
    cnt = [0] * (N+1)
    for i in range(N+1):
        cnt[i] = combination(N, i)
    ans = [-1] * (2**i)
    b = i_to_b((2**N-1)-B, N)
    idx = 2**N - 1
    visited.add(B)
    ans[idx] = B
    cnt[sum(i_to_b(B, N))] -= 1
    for i in range(N):
        if b[i] == 1:
            idx -= 1
            B += 2**i
            visited.add(B)
            ans[idx] = B
            cnt[sum(i_to_b(B, N))] -= 1
    current = A
    idx = 0
    while sum(cnt) > 0:
        visited.add(current)
        ans[idx] = current
        b = i_to_b(current, N)
        c = sum(b)
        cnt[c] -= 1
        idx += 1
        if c >= 1 and cnt[c-1] >= 1:
            for i in range(N):
                if b[i] == 1:
                    nxt = current - 2**i
                    if nxt not in visited:
                        current = nxt
                        break
        else:
            for i in range(N):
                if b[i] == 0:
                    nxt = current + 2**i
                    if nxt not in visited:
                        current = nxt
                        break
    print("YES")
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def i_to_b(n, N):
    A = [0] * N
    for i in range(N):
        A[i] = (n // 2**i) % 2
    return A


def b_to_i(A):
    ret = 0
    for i in range(len(A)):
        ret += i**2*A[i]
    return ret


def rm_bit(n, i):
    return n // (2**(i+1)) * (2**i) + (n % (2**i))


def ins_bit(n, i, b):
    return n // (2**i) * (2**(i+1)) + (n % (2**i)) + b * (2**i)


def solve(N, A, B):
    if N == 1:
        return [A, B]
    idx = -1
    for i in range(N):
        if (A ^ B) & (2**i):
            idx = i
            break
    ra = rm_bit(A, idx)
    rb = rm_bit(B, idx)
    a = list(map(lambda x: ins_bit(x, idx, (A >> idx) & 1), solve(N-1, ra, ra ^ 1)))
    b = list(map(lambda x: ins_bit(x, idx, (B >> idx) & 1), solve(N-1, ra ^ 1, rb)))
    return a + b


def main():
    N, A, B = map(int, input().split())
    binA = i_to_b(A, N)
    binB = i_to_b(B, N)
    if abs(sum(binA) - sum(binB)) % 2 == 0:
        print("NO")
        return
    print("YES")
    print(*solve(N, A, B))


if __name__ == "__main__":
    main()
N = int(input())

if N[0] == N[1] and N[1]== N[2]:
    print ('Yes')
elif N[1] == N[2] and N[2]== N[3]:
    print ('Yes')
elif N[2] == N[3] and N[3]== N[4]:
    print ('Yes')
elif N[0] == N[1] and N[1]== N[2] and N[2]== N[3]:
    print ('Yes')
else:
    print ('No')


### FIXED CODE ###

N = input()
if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]):
    print("Yes")
else:
    print("No")
#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(a: int, b: int, x: int):
    y = float(x)/float(a)
    ans = .0
    if (a**2 * b - x) == 0:
        ans = 90.0
    if y >= a*b//2:
        bd = 2.0*(a*b-y)/a
        ans = 90.0-math.degrees(math.atan(a/bd))
    else:
        ad = 2.0*y/b
        ans = 90.0-math.degrees(math.atan(ad/b))

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(a: int, b: int, x: int):
    y = float(x)/float(a)
    ans = .0
    if (a**2 * b - x) == 0:
        ans = 0.0
    elif y >= a*b/2:
        bd = 2.0*(a*b-y)/a
        ans = 90.0-math.degrees(math.atan(a/bd))
    else:
        ad = 2.0*y/b
        ans = 90.0-math.degrees(math.atan(ad/b))

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()
while True:
	(m, f, r) = map(int,raw_input().split())
	if (m == -1 and f == -1 and r == -1):
		break
	elif (m == -1 or f == -1):
		print "F"
	elif (m + f) >= 80:
		print "A"
	elif 65 <= (m + f) <80:
		print "B"
	elif 50 <= (m + f) <65:
		print "C"
	elif (30 <= (m + f) <50 and (r>=50):
		print "C"
	elif 30 <= (m + f) <50:
		print "D"
	else:
		print "F"

### FIXED CODE ###

while True:
	(m, f, r) = map(int,raw_input().split())
	if (m == -1 and f == -1 and r == -1):
		break
	if (m == -1 or f == -1):
		print "F"
	elif (m + f) >= 80:
		print "A"
	elif 65 <= (m + f) <80:
		print "B"
	elif 50 <= (m + f) <65:
		print "C"
	elif (30 <= (m + f) <50) and (r>=50):
		print "C"
	elif 30 <= (m + f) <50:
		print "D"
	else:
		print "F"
s = int(input())

y = s//10**9
x = s%10**9
if x == 0:
    result = [0,0,10**9,1,x,y+]
else:
    result = [0,0,10**9,1,10**9-x,y+1]
print(*result)

### FIXED CODE ###

s = int(input())

y = s//10**9
x = s%10**9
if x == 0:
    result = [0,0,10**9,1,x,y]
else:
    result = [0,0,10**9,1,10**9-x,y+1]
print(*result)
import sys
input = sys.stdin.readlines

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])

### FIXED CODE ###

#import sys
#input = sys.stdin.readline

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])
def func(pos, t, x):
    if pos + t == x:
        return t
    elif pos + t < x:
        new_pos = pos + t
        t += 1
        return func(new_pos, t, x)
    else:
        new_pos = pos - t
        t -= 1
        return func(new_pos, t, x)
      
def slove(x):
    ans = func(0,0,x)
    return ans

if __name__ == "__main__":
    x = int(input())
    print(slove(x))

### FIXED CODE ###

def slove(x):
    t = 1
    ans = t
    while ans <x:
        t += 1
        ans += t
    return t
if __name__ == "__main__":
    x = int(input())
    print(slove(x))
def main():
	inp = [int(input()) for i in range(2)]
	a = inp[0]
	s = inp[1]
	red = "red"

  if a < 3200:
    print red
  else:
    print s


### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")
# -*- coding: utf-8 -*-
a = int(input())
if a <=9:
  print("{}".format(a));
elif a <=99:
  print("9")
elif a < 999:
  print("{}".format(9+a-99))
elif a <= 9999:
  print('909')
else
  print("{}".format(909+a-1000))

### FIXED CODE ###

a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')
A = int(input())
B =  int(input())
C = int(input())

if B != C:
	surplus = A - B
	result = C - surplus 
	print(result)
else:
	print(0)

### FIXED CODE ###


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

ans = c - (a - b)
if ans < 0:
	ans = 0
print(ans)
a_card = list(input())
b_card = list(input())
c_card = list(input())

turn = 'a'
while True:
    if turn == 'a':
        turn = a_card.pop(0)
        print(a_card, b_card, c_card)
        if len(a_card) == 0:
            print('A')
            exit()
    elif turn == 'b':
        turn = b_card.pop(0)
        print(a_card, b_card, c_card)
        if len(a_card) == 0:
            print('B')
            exit()
    else:
        turn = c_card.pop(0)
        print(a_card, b_card, c_card)
        if len(a_card) == 0:
            print('C')
            exit()


### FIXED CODE ###

a_card = list(input())
b_card = list(input())
c_card = list(input())

turn = 'a'
while True:
    if turn == 'a':
        if len(a_card) == 0:
            print('A')
            exit()
        turn = a_card.pop(0)

    elif turn == 'b':
        if len(b_card) == 0:
            print('B')
            exit()
        turn = b_card.pop(0)

    else:
        if len(c_card) == 0:
            print('C')
            exit()
        turn = c_card.pop(0)
N=int(input())
A=list(map(int,input().split()))
arrN=[0]*n
for i in range(N):
    arrN[A[i]-1]=i+1
print(*arrN)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
arrN=[0]*N
for i in range(N):
    arrN[A[i]-1]=i+1
print(*arrN)
from operator import mul


def test(a):
    print(*a)
    for i in range(len(a) - 1):
        a = [abs(a1 - a0) for a0, a1 in zip(a, a[1:])]
        print(' ' * i, *a)


def first(aaa):
    aaa = list(map(int, aaa))
    aaa = [abs(a1 - a0) for a0, a1 in zip(aaa, aaa[1:])]
    return aaa


def last(aaa):
    for i in range(len(aaa) - 1):
        aaa = [abs(a1 - a0) for a0, a1 in zip(aaa, aaa[1:])]
    return aaa[0]


def prepare():
    # for v in product([0, 1, 2], repeat=10):
    ret = [0] * (3 ** 10)
    for i in range(3 ** 10):
        v = i
        v, m1 = divmod(v, 3)
        tmp = []
        for _ in range(9):
            v, m2 = divmod(v, 3)
            tmp.append(abs(m1 - m2))
            m1 = m2
        tmp.reverse()
        for _ in range(8):
            tmp = [abs(a1 - a0) for a0, a1 in zip(tmp, tmp[1:])]
        ret[i] = tmp[0]
    return ret


# test([2, 3, 1, 1, 3, 1, 2, 3, 1, 2])
# test([2, 3, 1, 1, 3, 2, 2, 3, 1, 2])
# test([2, 3, 1, 1, 3, 3, 2, 3, 1, 2])
# test([1, 3, 1, 3, 1, 3, 1, 3, 1, 3])

n = int(input())
aaa = input()
aaa = first(aaa)
ppp = prepare()
pow3 = [3 ** (9 - i) for i in range(10)]
while len(aaa) >= 10:
    aaa = [ppp[sum(map(mul, zip(aaa[i:i + 10], pow3)))] for i in range(len(aaa) - 9)]
ans = last(aaa)
print(ans)


### FIXED CODE ###

def test(a):
    print(*a)
    for i in range(len(a) - 1):
        a = [abs(a1 - a0) for a0, a1 in zip(a, a[1:])]
        # print(' ' * i, *a)
        print(*a)


# test([2, 3, 1, 1, 3, 1, 2, 3, 1, 2])
# test([2, 3, 1, 1, 3, 2, 2, 3, 1, 2])
# test([2, 3, 1, 1, 3, 3, 2, 3, 1, 2])
# test([1, 2, 0, 1, 2, 2, 2, 0, 0, 2, 1])
# test([1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0])
# test([0, 0, 0, 0, 0, 1, 0, 0, 1, 2, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ])
# test([0] * 21 + [2] + [0] * 21)
# exit()

def solve(n, aaa):
    # シェルピンスキーの三角形
    if '2' not in aaa:
        factor = '3'
        effect = 2
    else:
        factor = '2'
        effect = 1
    # print(factor, effect)

    try_list = []
    m = n - 1
    while m:
        l = 1 << (m.bit_length() - 1)
        m ^= l
        try_list.append((l, m))
    # print(try_list)

    ans = 0
    for i, a in enumerate(aaa):
        if a == factor:
            for l, m in try_list:
                if i >= l:
                    i -= l
                if i == 0:
                    ans ^= effect
                    break
                elif i > m:
                    break
    return ans


n = int(input())
aaa = input()
print(solve(n, aaa))
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
a=0
for co,i in enumerate(A):
    if co==0 :
        a+=B[i-1]
    if co>=1 :
        if A[co-1]+1==A[co]:
            a+=B[i-1]
            a+=C[A[co-1]-1]
        else:
            a+=B[i-1]
print(a)

### FIXED CODE ###

N=int(input())
print(N**3)
H, W, M = map(int,input().split())
R = [0] * H
C = [0] * W

L = []

for _ in range(M):
    h, w = map(int,input().split())
    R[h-1] += 1
    C[w-1] += 1
    L.append([h-1, w-1])

r = max(R)
c = max(C)

print(r + c - (R.count(r) * C.count(c) == sum(R[h] + C[w] == r + c for h, w in L))

### FIXED CODE ###

import sys

H, W, M = map(int,input().split())
R = [0] * H
C = [0] * W
S = set()
for _ in range(M):
    h, w = map(int,input().split())
    S.add((h-1, w-1))
    R[h-1] += 1
    C[w-1] += 1

r = max(R)
c = max(C)

HL = [i for i in range(H) if R[i] == r]
WL = [i for i in range(W) if C[i] == c]

for h in HL:
    for w in WL:
        if not (h, w) in S:
            print(r + c)
            sys.exit()

print(r + c - 1)
n_500 = int(input())
n_100 = int(input())
n_50 = int(input())
price = int(input())
count = 0

for i in range(n_500+1):
    for j in range(n_100+1):
        for k in range(n_50+1):
            if(price ==500*i+100*j+50*k):
                count+=1S

print(count)

### FIXED CODE ###

n_500 = int(input())
n_100 = int(input())
n_50 = int(input())
price = int(input())
count = 0

for i in range(n_500+1):
    for j in range(n_100+1):
        for k in range(n_50+1):
            if(price ==500*i+100*j+50*k):
                count+=1

print(count)
mod = 10**9+7
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    G[y-1].append(x-1)
    
def dfs(i, pi):
    b, w = 1, 1
    for ni in G[i]:
        if ni == pi:
            continue
        nb, nw = dfs(ni, i)
        b *= nw
        b %= mod
        w *= nw + nb
        w %= mod
    return b, w

print(sum(dfs(0, -1))%mod)



### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7
N = int(input())
G = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    G[x-1].append(y-1)
    G[y-1].append(x-1)
    
def dfs(i, pi):
    b = 1
    w = 1
    for ni in G[i]:
        if ni == pi:
            continue
        [nb, nw] = dfs(ni, i)
        b *= nw
        b %= mod
        w *= nw + nb
        w %= mod
    return [b, w]

print(sum(dfs(0, -1))%mod)
n = int(input())
s = str(input())

ans_s = s
ans_head = 0
ans_tail = 0

def remove(s):
    while True:
        pre_len = len(s)
        s = s.replace("()", "")
        if len(s) == pre_len:
            break
    return s

while len(s) > 0:
    s = remove(s)
    if s[0] == ')':
        ans_head += 1
        s = remove('(' + s)
    else:
        ans_tail += 1
        s = remove(s + ')')
    # print(s)
print('('*ans_head + ans_s + ')' * ans_tail)



### FIXED CODE ###

n = int(input())
s = str(input())

ans_s = s
ans_head = 0
ans_tail = 0

def remove(s):
    while True:
        if len(s) <= 0:
            break
        pre_len = len(s)
        s = s.replace("()", "")
        if len(s) == pre_len:
            break
    return s

s = remove(s)
while len(s) > 0:
    s = remove(s)
    if s[0] == ')':
        ans_head += 1
        s = remove('(' + s)
    else:
        ans_tail += 1
        s = remove(s + ')')
    # print(s)
print('('*ans_head + ans_s + ')' * ans_tail)
#import math
def round_up_mean(a,b):
#  ans = math.ceil((a+b)/2)
#  print(ans)
  ans = -(-(a+b)//2)
  print(ans)


a = int(input())
b = int(input())
round_up_mean(a, b)

### FIXED CODE ###

#import math
def round_up_mean(a,b):
#  ans = math.ceil((a+b)/2)
#  print(ans)
  ans = -(-(a+b)//2)
  print(ans)

a, b = map(int, input().split(" "))
round_up_mean(a, b)
import math

n = int(input())
a = [0]*10001
b = int(math.sqrt(n)) + 2
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])

### FIXED CODE ###

import math

n = int(input())
a = [0]*100001
b = math.ceil(math.sqrt(n)) + 1
for i in range(1,b):
    for j in range(1,b):
        for k in range(1,b):
            ans = ((i + j) ** 2 + (j + k) ** 2 + (k + i) ** 2) //2
            a[ans] += 1

for i in range(1,n+1):
    print(a[i])
s = str(input())
t = str(input())


### FIXED CODE ###

import math

a,b,c = map(int,input().split())
lst = []
lst.append(a)
lst.append(b)
lst.append(c)
lst.sort()

print(lst[2] - lst[1] + (lst[1] - lst[0]))
T=input()
S=input()
print(T + S)

### FIXED CODE ###

s,t=input().split()
print(t+s)
n=int(input())
a=list(map(int,input().split()))
j=0
k=0
l=0
for i in a:
  if i%4==0:
    l+=1
  elif i%2==0:
    k+=1
  else:
    j+=1
if l<=j :
  print("Yes")
else:
  print("No")


### FIXED CODE ###

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

b = []
for i in range(N):
    b.extend([i + 1] * a[i])

for i in range(H):
    row = b[i * W:(i + 1) * W]
    if i % 2 == 1:
        row.reverse()
    print(' '.join([str(c) for c in row]))
a = input()
b = range(1, a + 1)
res = 0
max_cnt = 0

for bb in b:
  cnt = 0
  bb_org = bb
  while True:
    if bb % 2 == 0:
      bb /= 2
      cnt += 1
    else:
      break
  if cnt > max_cnt:
    max_cnt = cnt
    res = bb_org
    
print(res)

### FIXED CODE ###

a = int(input())
b = range(1, a + 1)
res = 1
max_cnt = 0

for index, bb in enumerate(b):
  cnt = 0
  while True:
    if bb % 2 == 0:
      bb /= 2
      cnt += 1
    else:
      break
  if cnt > max_cnt:
    max_cnt = cnt
    res = index + 1
    
print(res)
points = []
for _ in range(6):
    points.append(int(input())
print(sum(sorted(points, reverse=True)[:3]))


### FIXED CODE ###

points_1 = []
points_2 = []
for _ in range(4):
    points_1.append(int(input()))

for _ in range(2):
    points_2.append(int(input()))

print(sum(sorted(points_1)[1:]) + max(points_2))
#ABC160A
s = input()
print("Yes" if s[3]==s[4] and s[5]==s[6] else "No")


### FIXED CODE ###

#ABC160A
s = input()
print("Yes" if s[2]==s[3] and s[4]==s[5] else "No")
A,B,C = (int(i) for i in input().split())
 
if A = B and B = C:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

A,B,C = (int(i) for i in input().split())
 
if A == B == C:
  print("Yes")
else:
  print("No")
n=int(input())
a=list(int(input()) for _ in range(n))
i=1
c=1
i=a[a.index(i)-1]
while  c!=n or i == 2:
    i=a[a.index(i)-1]
    print(i)
    c+=1
print(-1 if c==n+1 else c)
print(c)
    


### FIXED CODE ###

N=int(input())
a=list(int(input()) for _ in range(N))
ans=1
c=0
for i in range(N):
    if ans != 2:
        ans=a[ans-1]
        c+=1
    else:
        print(c)
        exit()
print(-1)
pair = [[1,2],[2,5],[3,5],[4,4],[5,5],[6,6],[7,3],[8,7],[9,6]]
n,m =[int(x) for x in input().split()]
given = sorted([int(i) for i in input().split()])
given_pair = sorted([pair[x-1] for x in given],key = lambda x :x[1])
def rec(n,t_list,pair_list):
  if n==0:
    return t_list
  elif n< pair_list[0][1]:
    return t_list[:-1]
  else:
    a = rec(n-pair_list[0][1],t_list+[pair_list[0][0]],pair_list)
    if pair_list[1:]!=[]:
        b = rec(n,t_list,pair_list[1:])
        if len(a)>=len(b):
                return a
        else:
                return b
    else:
        return a

kotae = map(str,sorted(rec(n,[],given_pair),reverse=True))
print("".join(kotae))

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
am = sorted([int(i) for i in input().split()],reverse=True)
c = [2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [-1 for i in range(n+1)]
dp[0]=0
for i in range(n+1):
    #max_tmp = -float("inf")
    for j in am:
        if i+c[j-1]<=n:
            dp[i+c[j-1]] = max(dp[i+c[j-1]], dp[i]+1)
#print(dp)
tmp_n = n
ans =""
for i in range(dp[n]):
    for j in range(m):
        if i==dp[n]-1 and tmp_n- c[am[j]-1] != 0:
            continue
        if tmp_n - c[am[j]-1] >= 0 and dp[tmp_n - c[am[j]-1]] == dp[tmp_n] -1:
            ans+=(str(am[j]))
            tmp_n -= c[am[j]-1]
            break


print(ans)
N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
diff = 10 ** 9

for i in range(N - 1):
    diff = min(A[i + 1] - A[i], diff)

if abs(A[0] - diff) > 0:
    diff = min(abs(A[0] - diff), diff)

can_make = False
for i in range(N):
    if A[i] % diff == K % diff and A[i] >= K:
        can_make = True

if can_make:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

import fractions

N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
A.sort()
diff = 10 ** 9

if max(A) < K:
    print('IMPOSSIBLE')
else:
    gcd = max(A)
    for i in range(N):
        gcd = fractions.gcd(gcd, A[i])

    if K % gcd == 0:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
def kaijo(a):
    if a==0:
        return 1
    else:
        return a*kaijo(a-1)

def combination(a,b):
    if a<b:
        return 0
    else:
        return kaijo(a)//(kaijo(b)*kaijo(a-b))

N = int(input())
names = []
for i in range(N):
    names.append(input())

M,A,R,C,H,MARCH = 0,0,0,0,0,0

for i in range(N):
    if names[i][0]=='M':
        M+=1
    elif names[i][0]=='A':
        A+=1
    elif names[i][0]=='R':
        R+=1
    elif names[i][0]=='C':
        C+=1
    elif names[i][0]=='H':
        H+=1
MARCH = M + A + R + C + H
Num = [M,A,R,C,H]
ans = combination(MARCH,3)-sum([combination(i,3)+combination(i,2)*(MARCH-i) for i in Num])
print(ans)

### FIXED CODE ###

N = int(input())
names = []
for i in range(N):
    names.append(input())

M,A,R,C,H= 0,0,0,0,0

for i in range(N):
    if names[i][0]=='M':
        M+=1
    elif names[i][0]=='A':
        A+=1
    elif names[i][0]=='R':
        R+=1
    elif names[i][0]=='C':
        C+=1
    elif names[i][0]=='H':
        H+=1

print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H)
N,A,B=map(int, input().split())
D=list(map(int, input().split()))
D=sorted(D)[::-1]
import math
import bisect
print(sum(D[:A])/A)
ans=0
if D==[D[0]]*N:
  for i in range(A,B+1):
    ans+=math.factorial(N)//(math.factorial(i)*math.factorial(N-i))
else:
  a=D.count(D[a-1])
  if a>1:
    b=D[:A].count(D[a-1])
    print(math.factorial(a)//(math.factorial(b)*math.factorial(a-b)))
  else:
    print(1)

### FIXED CODE ###

N,A,B=map(int, input().split())
D=list(map(int, input().split()))
D=sorted(D)[::-1]
import math
from math import comb
print(sum(D[:A])/A)
ans=0
if D[0]!=D[A-1]:
  n=D.count(D[A-1])
  k=D[:A].count(D[A-1])
  print(comb(n,k))
else:
  ans=0
  n=D.count(D[A-1])
  for i in range(A,min(n,B)+1):
    ans+=comb(n,i)
  print(ans)
A,B=input()
coin=0
for i in range(0,2):
    pre=max(A,B)
    coin+=pre
    if(pre==A):
        A-=1
    else:
        B-=1

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
sum=0
for i in range(1,3):
    sum += max(a,b)
    if (sum == a ):
        a -=1
    elif (sum==b):
        b -=1
print(sum)
h, w, a, b = map(int, input().split())

s = [[0 for _ in range(w)] for _ in range(h)]

num = ["0", "1"]
flag = True
for i in range(h):
    for j in range(w):
        if b <= i and flag:
            num.reverse()
            flag = False
        if j < a:
            s[i][j] = num[0]
        else:
            s[i][j] = num[1]


for row in s:
    print("".join(tmp))

### FIXED CODE ###

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

s = [[0 for _ in range(w)] for _ in range(h)]

num = [0, 1]
flag = True
for i in range(h):
    for j in range(w):
        if b <= i and flag:
            num.reverse()
            flag = False
        if j < a:
            s[i][j] = num[0]
        else:
            s[i][j] = num[1]


for row in s:
    tmp = list(map(str, row))
    print("".join(tmp))