Harryxun/stf_run huggingface dataset:
# 入力
a, b, h = map(int, input().split())

# 処理
answer = (a + b) * h /2

# 出力
print(answer)

### FIXED CODE ###

# 入力
a = int(input())
b = int(input())
h = int(input())

# 処理
answer = (a + b) * h /2

# 出力
print(int(answer))
import math
N,M = list(map(int,input().split()))
A = set([-1])+set([int(input()) for _ in range(M)])+set([N+1])
cnt = 0
ans = 1
for i in range(M+1):
  cnt = 0
  d = A[i+1]-A[i]-2
  for j in range(d//2+1):
    cnt += math.factorial(d-j)//(math.factorial(d-j*2)*math.factorial(j))
  ans *= cnt
print(ans%1000000007)

### FIXED CODE ###

N,M = map(int,input().split())
dp = [0]*(N+1)
dp[0] = 1
A=[int(input()) for _ in range(M)]
B=[1]*(N+1)
for i in range(M):
    B[A[i]] = 0
for i in range(N):
    if i-1 >= 0:
        dp[i+1] = dp[i]*B[i]+dp[i-1]*B[i-1]
    else:
        dp[i+1] = dp[i]*B[i]
    dp[i+1] %= 10**9+7
print(dp[N])
import math
in_list = list(input().split())
a = float(in_list[0])
b = float(in_list[1])
c = float(in_list[2])
if (math.sqrt(a) + math.sqrt(b)) < math.sqrt(c):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

str_K = input()
k = int(str_K)
tmp_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(tmp_list[k-1])
# -*- coding: utf-8 -*-
from collections import  deque
from heapq import heappush, heappop, heapify, merge
from collections import defaultdict
import sys
sys.setrecursionlimit(10000)
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
A = inpl()
tree = [[-1, 1]  for _ in range(N)]# [next, rank]

def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
  
for _ in range(M):
    x, y = tuple(map(int, input().split()))
    if not int(find(x) == find(y)):
        unite(x, y)

D = defaultdict(list)
for n in range(N):
    D[find(n)].append(A[n])

H = []
S = deque([]) # single
for k, v in D.items():
    if len(v) == 1:
        S.append(v)
    else:
        H.append(sorted(v))
heapify(H)

res = 0 
while len(H) > 1:
    if S:
        A = S.leftpop()
    else:
        A = heappop(H)
    B = heappop(H)
    res += A[0] + B[0]
    C = list(merge(A[1:], B[1:]))
    if len(C) == 1:
        S.append(C)
    else:
        heappush(H, C)

if len(S) > 1:
    print("Impossible")
    exit()
elif len(S) == 1:
    A = S[0]
    if len(H) == 1:
        B = heappop(H)
        res += A[0] + B[0]
else:
    pass
print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
def inpl(): return tuple(map(int, input().split()))
 
N, M = inpl()
A = inpl()
tree = [[-1, 1]  for _ in range(N)] # [next, rank]
 
def find(i):
    if tree[i][0] == -1:
        group = i
    else:
        group = find(tree[i][0]) 
        tree[i][0] = group
    return group
  
def unite(x, y):
    px = find(x)
    py = find(y)
      
    if tree[px][1] == tree[py][1]: # rank is same
        tree[py][0] = px
        tree[px][1] += 1
    else:
        if tree[px][1] < tree[py][1]:
            px, py = py, px
        tree[py][0] = px
  
for _ in range(M):
    x, y = tuple(map(int, input().split()))
    if not int(find(x) == find(y)):
        unite(x, y)
 
D = defaultdict(list)
for n in range(N):
    D[find(n)].append(A[n])
 
H = []
res = 0 

for k, v in D.items():
    v = sorted(v)
    res += v[0]
    H.extend(v[1:])
 
if N < 2*(N-M-1):
    print("Impossible")
elif M == N-1:
    print(0)
else:
    res += sum(sorted(H)[:2*(N-M-1) - len(D.keys())])
    print(res)
S=int(input("Sを入力してください"))
T=int(input("Tを入力してください"))

v='a' or 'b' or 'c' or 'd' or 'e' or 'f' or 'g' or 'i' or 'j' or 'k' or 'l' or 'm' or 'n' or 'o' or 'p' or 'q' or 'r' or 's' or 't' or 'u' or 'v' or 'w' or 'x' or 'y' or 'z'

if S =((v + v + v + v + v + v + v + v + v + v) or (v + v + v + v + v + v + v + v + v) or (v + v + v + v + v + v + v + v ) or (v + v + v + v + v + v + v ) or (v + v + v + v + v + v )or (v + v + v + v + v ) or (v + v + v + v )  or (v + v + v )  or (v + v )  or (v )  
       pass
if S =( T + v ):
  print("YES")
else:
  print("No")

### FIXED CODE ###

S=input()
T=input()

lenS=len(S)
T2=T[0:lenS]

if S == T2:
  print("Yes")
else:
  print("No")
import numpy as np
N = int(input())

ARR = []

for i in range(N):
    ARR.append([int(s) for s in input().split(" ")])

PRR = []

for i in range(N):
    PRR.append([int(s) for s in input().split(" ")])

def calculate(n, arr, prr):
    arr = np.array(arr)

    brr = []
    for i in range(1,2 ** 10):

       a = 1


    return brr

result = calculate(N, ARR, PRR)
print(max(result))



### FIXED CODE ###

n = int(input())

frr = []

for i in range(n):
    frr.append([int(s) for s in input().split(" ")])

prr = []

for i in range(n):
    prr.append([int(s) for s in input().split(" ")])

# n = 2
#
# frr = [
#     [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
#     [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
# ]
#
# prr = [
#     [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1],
#     [0, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1]
# ]


res = []
for i in range(1,2 ** 10):
    count = [0 for s in range(n)]

    mask = []
    for j in range(10):
        m =  i >> j & 1
        mask.append(m)
        if m == 1:
            for k in range(n):
                if frr[k][j] == 1:
                    count[k] = count[k] + 1

    mm = []
    for index,c in enumerate(count):
        mm.append(prr[index][c])

    res.append(sum(mm))

print(max(res))
import math

R = int(input())
ans = R ** 2 math.pi
print(ans)

### FIXED CODE ###

import math
 
R = int(input())
ans = R * 2 * math.pi
print(ans)
X,A = input();

if X<A:
  print(0);
elif X>=A:
  print(10);

### FIXED CODE ###

x, a = map(int, input().split())
 
if x < a:
    print(0)
else:
    print(10)
S = input()

if ("RRR" in S) == true:
  print(3)
elif("RR" in S) == true:
  print(2)
elif("R" in S) == true:
  print(1)
else:
  print(0)



### FIXED CODE ###

S = input()
 
if S.count("R") == 2 and S[1] != "R":
  print(1)
  
else:
  print(S.count("R"))
def main():
    n, x = list(map(int, input().split()))
    ls = list(map(int, input().split()))

    count = 1
    d = 0
    for i in range(n + 1):
        d = d + ls[i]
        if d > x:
            break
        else:
            count += 1

    print(count)


main()

### FIXED CODE ###

def main():
    n, x = list(map(int, input().split()))
    ls = list(map(int, input().split()))

    count = 1
    d = 0
    for i in range(n):
        d = d + ls[i]
        if d > x:
            break
        else:
            count += 1

    print(count)


main()
from itertools import zip_longest

o=input()
e=input()

print(''.join([x+y for x,y in zip_longetst(o,e,fillvalue='')]))


### FIXED CODE ###

from collections import deque
 
O=input()
E=input()
 
o=deque(O)
e=deque(E)
 
s=''
while True:
  if not e  and not o:
    break
  if o:
    s+=o.popleft()
  if e:
    s+=e.popleft()
    
  
print(s)
import sys

lines = sys.stdin.readlines()

H, M = list(map(int, lines[0].split()))
AB = []

max_at = 0
min_mg = 999999
at_min_mg = 0
for i in range(M):
  t = tuple(map(int, lines[i+1].split()))
  AB.append(t)
  if t[0]>max_at:
    max_at = t[0]
  if t[1]<min_mg:
    min_mg = t[1]
    at_min_mg = t[0]

ABlen = len(AB)

DP = [0]
for i in range(1, at_min_mg+1):
  DP.append(min_mg)
  
for i in range(at_min_mg+1,H+max_at):
  mm = sys.maxsize
  for j in range(ABlen):
    if i-AB[j][0]<0:
      continue
    if mm > DP[i-AB[j][0]]+AB[j][1]:
      mm = DP[i-AB[j][0]]+AB[j][1]
  DP.append(mm)
print(min(DP[H:H+max_at-1]))

### FIXED CODE ###

import sys

lines = sys.stdin.readlines()

H, M = list(map(int, lines[0].split()))
AB = []

max_at = 0
min_mg = sys.maxsize
at_min_mg = 0
for i in range(M):
  t = tuple(map(int, lines[i+1].split()))
  AB.append(t)
  if t[0]>=max_at:
    max_at = t[0]
  if t[1]<=min_mg:
    min_mg = t[1]
    at_min_mg = t[0]

ABlen = len(AB)

DP = [0]
for i in range(1, at_min_mg+1):
  DP.append(min_mg)
  
for i in range(at_min_mg+1,H+max_at+1):
  mm = sys.maxsize
  for j in range(ABlen):
    if i-AB[j][0]<0:
      continue
    if mm > DP[i-AB[j][0]]+AB[j][1]:
      mm = DP[i-AB[j][0]]+AB[j][1]
  DP.append(mm)
print(min(DP[H:H+max_at]))
n = input()

a = [] 
flag = {}
for j in range(1, 14):
    flag[('S',j)] = 0
    flag[('H',j)] = 0
    flag[('C',j)] = 0
    flag[('D',j)] = 0

for i in range(n):
    temp = map(str, raw_input().split())
    a.append((temp[0],temp[1]))
    print a[i][0]
    print a[i][1]
#Sについて
for i in range(n):
    if(a[i][0] == 'S'):
        print 'Yes'
        for j in range(1, 14):
            if(int(a[i][1]) == j):
                print 'Yes'
                flag[('S',j)] = 1
#Hについて
for i in range(n):
    if(a[i][0] == 'H'):
        for j in range(1, 14):
            if(int(a[i][1]) == j):
                flag[('H',j)] = 1
#Cについて
for i in range(n):    
    if(a[i][0] == 'C'):
        for j in range(1, 14):
            if(int(a[i][1]) == j):
                flag[('C',j)] = 1
#Dについて
for i in range(n):    
    if(a[i][0] == 'D'):
        for j in range(1, 14):
            if(int(a[i][1]) == j):
                flag[('D',j)] = 1

for j in range(1, 14):
    if(flag[('S',j)] == 0):
        print 'S' ' ' '%d' %(j)
for j in range(1, 14):
    if(flag[('H',j)] == 0):
        print 'S' ' ' '%d' %(j)
for j in range(1, 14):
    if(flag[('C',j)] == 0):
        print 'S' ' ' '%d' %(j)
for j in range(1, 14):
    if(flag[('D',j)] == 0):
        print 'S' ' ' '%d' %(j)

### FIXED CODE ###

import sys

n = input()
a = [] 
flag = {}
for j in range(1, 14):
    flag[('S',j)] = 0
    flag[('H',j)] = 0
    flag[('C',j)] = 0
    flag[('D',j)] = 0

for i in range(n):
    temp = map(str, raw_input().split())
    a.append((temp[0],temp[1]))
    #print a[i][0]
    #print a[i][1]

card = ['S', 'H', 'C', 'D']
#print card

for egara in card:
    for i in range(n):
        if(a[i][0] == egara):
            for j in range(1,14):
                if(int(a[i][1]) == j):
                    flag[(egara, j)] = 1

for egara in card:
    for j in range(1,14):
        if(flag[(egara, j)] == 0):
            sys.stdout.write(egara)
            sys.stdout.write(' ')
            sys.stdout.write(str(j))
            print

exit(0)
import copy

def dfs(i, n, a, L):
    # x + y = n - 1
    # x - y = a
    # x = (n - 1 + a) / 2
    # y = (n - 1 - a) / 2
    if i == n:
        return 1
    if a [i] == 0:
        x = [(n - 1 + a[i]) // 2]
    else:
        x = [(n - 1 + a[i]) // 2, (n - 1 - a[i]) // 2]
    t = 0
    MOD = 10 ** 9 + 7
    for xi in x:
        if L[xi] == 0:
            Li = copy.copy(L)
            Li[xi] = i + 1
            t += dfs(i + 1, n, a, Li)
    return t % MOD

n = int(input())
a = list(map(int, input().split()))
L = [0 for _ in range(n)]
ans = dfs(0, n, a, L)
print(ans)


### FIXED CODE ###

from collections import defaultdict

MOD = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for ai in a:
    d[ai] += 1
ans = 1
if n % 2:
    for k, v in d.items():
        if k > 0 and v == 2:
            ans *= 2
        elif k == 0 and v == 1:
            ans *= 1
        else:
            ans = 0
            break
        ans = ans % MOD
else:
    for v in d.values():
        if v == 2:
            ans *= 2
        else:
            ans = 0
            break
        ans = ans % MOD
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())

num_listx = []
num_listy = []

for num in range(a,b + 1):
  if num >= a:
    num_listx.append(num)
for nums in range(c,d + 1):
  if nums >= c:
    num_listy.append(nums)
x = max(num_listx)
y = max(num_listy)
print(x*y)

### FIXED CODE ###

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

ans = max(a*c,a*d,b*c,b*d)

print(ans)
a,b = map(input().split())

if a < b:
	print("a < b")
elif a > b:
	print("a > b")
else:
	print("a == b")

### FIXED CODE ###

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

if a < b:
	print("a < b")
elif a > b:
	print("a > b")
else:
	print("a == b")
n, m = map(int,input().split())

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni =1
    while ni < n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1


### FIXED CODE ###

n, m = map(int,input().split())

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni = 1
    l = 1
    r = n
    while ni <= n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
h=[-1]*k
s=7
for i in range(k):
  m=s%k
  if h[0]==m:
    l=i+1
    break
  h[i]=m
  s=m*10+7
for i in range(l):
  if h[i]==0:
    print(i+1)
    break

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
s=7
for i in range(k):
  m=s%k
  if m==0:
    print(i+1)
    break
  s=m*10+7
print(x**3)

### FIXED CODE ###

x = input()
print(int(x)**3)
N,M=map(int,input().split())
A=list(map(int,input().split()))
S=sum(A)
l=S/(4*M)
h=0
for i in range(N):
  if A[i]>=l:
    h+=1
  else:
    h+=0
if h=M:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
S=sum(A)
l=S/(4*M)
h=0
for i in range(N):
  if A[i]>=l:
    h+=1
if h>=M:
  print("Yes")
else:
  print("No")
import math
a,b=[int(i) for i in input().split()]
def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))

### FIXED CODE ###

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
  
print(lcm(A,B))
import sys
S = str(input())
i = 0
j = len(S) - 1
c = 0
while(True):
    if i == j:
        break
    if (S[i] == S[j]):
        i += 1
        j -= 1
    else:
        if (S[i] == 'x'):
            i += 1
            c += 1
        elif (S[j] == 'x'):
            j -= 1
            c += 1
        else:
            print('-1')
            sys.exit()
print(c)


### FIXED CODE ###

import sys
S = str(input())
i = 0
j = len(S) - 1
c = 0
while(True):
    if i >= j:
        break
    if (S[i] == S[j]):
        i += 1
        j -= 1
    else:
        if (S[i] == 'x'):
            i += 1
            c += 1
        elif (S[j] == 'x'):
            j -= 1
            c += 1
        else:
            print('-1')
            sys.exit()
print(c)
import math
from functools import reduce
# def gcd(*numbers):
#     return reduce(math.gcd, numbers)

k = int(input())
res = 0
for c in range(1,k+1):
    for b in range(1,k+1):
        for a in range(1,k+1):
            # res += gcd(a,b,c)
            gcd1 = math.gcd(a,b)
            gcd2 = math.gcd(gcd1,c)
            res += gcd2
print(res)

### FIXED CODE ###

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

cnt_l = [0]*(k+1)
MOD = 10**9+7

for i in range(k,0,-1):
    multi_cnt = k//i
    cnt = pow(multi_cnt,n,MOD)
    
    i_multi = i+i
    while i_multi <= k:
        cnt -= cnt_l[i_multi]
        i_multi+=i

    cnt_l[i] = cnt%MOD

ans = 0
for i, cnt in enumerate(cnt_l):
    ans += i*cnt
    ans %= MOD

# print(cnt_l)
print(ans)
int = int(input())
print(a*a*a+a*a+a)

### FIXED CODE ###

i = int(input())
print(i*i*i+i*i+i)
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0]*n
    for i in range(n):
        B[i] = A[i]//2
    
    for i in range(n):
        cnt=0
        while B[i]%2==0:
            B[i]//2
            cnt+=1
        if i==0:
            temp=cnt
        else:
            if cnt!=temp:
                ok=False
                break
            if i==n-1:
                ok=True
    if ok:
        from functools import reduce
        from fractions import gcd

        def lcm(A, B):
            return A * B // gcd(A, B)

        # リストを引数にとる
        l = reduce(lcm, B)
        print(-(-(m//l) // 2))
        
    else:
        print(0)


resolve()


### FIXED CODE ###

import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, m = map(int, input().split())
    if n==1:
        a=int(input())
        print(-(-(m//(a//2)) // 2))

    else:
        A = list(map(int, input().split()))
        B = [0]*n
        for i in range(n):
            B[i] = A[i]//2

        for i in range(n):
            cnt = 0
            val = B[i]
            while val % 2 == 0:
                val //= 2
                cnt += 1
            if i == 0:
                temp = cnt
            else:
                if cnt != temp:
                    ok = False
                    break
                if i == n-1:
                    ok = True

        if ok:
            from functools import reduce
            from fractions import gcd

            def lcm(A, B):
                return A * B // gcd(A, B)

            # リストを引数にとる
            l = reduce(lcm, B)
            print(-(-(m//l) // 2))

        else:
            print(0)


resolve()
class UnionFind:
    def __init__(self, elems):
        self.parent = dict()
        self.children = dict()
        for e in elems:
            self.parent[e] = e
            self.children[e] = 1

    def root(self, e):
        if self.parent[e] == e:
            return e

        self.parent[e] = self.root(self.parent[e])
        return self.parent[e]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        if self.same(x, y):
            return

        self.children[self.root(y)] += self.children[self.root(x)]
        self.parent[self.root(x)] = self.root(y)

    def members(self, x):
        return self.children[self.root(x)]


n, m = map(int, input().split())
bs = []
for _ in range(m):
    bs.append(tuple(map(int, input().split())))

bs.reverse()

uf = UnionFind(list(range(1, n+1)))

inconv = n * (n - 1) // 2
inconvs = [inconv]
for b in bs[:-1]:
    i1, i2 = b
    if not uf.same(i1, i2):
        inconv -= uf.members(i1) * uf.members(i2)

    inconvs.append(inconv)
    uf.unite(i1, i2)

for inc in reversed(inconvs):
    print(inc)

### FIXED CODE ###

class UnionFind:
    def __init__(self, elems):
        self.parent = dict()
        self.children = dict()
        for e in elems:
            self.parent[e] = e
            self.children[e] = 1

    def root(self, e):
        if self.parent[e] == e:
            return e

        return self.root(self.parent[e])

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        if self.same(x, y):
            return

        rx, ry = self.root(x), self.root(y)
        # ry <- rx
        if self.members(ry) < self.members(rx):
            rx, ry = ry, rx

        self.children[ry] += self.children[rx]
        self.parent[rx] = ry

    def members(self, x):
        return self.children[self.root(x)]


n, m = map(int, input().split())
bs = []
for _ in range(m):
    bs.append(tuple(map(int, input().split())))

bs.reverse()

uf = UnionFind(list(range(1, n+1)))

inconv = n * (n - 1) // 2
inconvs = [inconv]
for b in bs[:-1]:
    i1, i2 = b
    if not uf.same(i1, i2):
        inconv -= uf.members(i1) * uf.members(i2)

    inconvs.append(inconv)
    uf.unite(i1, i2)

for inc in reversed(inconvs):
    print(inc)
N = int(input())
a = N[-1]
 
if a == 2, 4, 5, 7, 9:
  print('hon')
elif a == 0, 1, 6, 8:
  print('pon')
else:
  print('bon')

### FIXED CODE ###

N = int(input())
a = N%10
 
if a==3:
  print("bon")
elif a==0 or a==1 or a==6 or a==8:
  print("pon")
else:
  print("hon")
a, s, c = map(int, input().split())
print(a[0] + s[0] + c[0])


### FIXED CODE ###

a, s, c = map(str, input().split())
print(a[0] + s[0] + c[0])
n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
for i in range(n-2):
    if h[n-i-1] == (h[n-i-2]-1):
        h[n-i-1] -= 1
    elif h[n-i] < (h[n-i-1]-1):
        print('No')
        exit()
print('Yes')

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
if n==1:
    print('Yes')
    exit()
ht = h[-1]
for i in reversed(range(n-1)):
    if ht == h[i]-1:
        h[i]-=1
    elif ht < h[i]-1:
        print('No')
        exit()
    ht = h[i]
print('Yes')
n, l = (int(x) for x in input().split())
s_list = []
s = ''
for i in range(n):
  s_list.append(input())
for i in range(l):
  s += s_list.pop(s_list.index(min(x for x in s_list)))
print(s)  

### FIXED CODE ###

n, l = (int(x) for x in input().split())
s_list = []
s = ''
for i in range(n):
  s_list.append(input())
for i in range(n):
  s += s_list.pop(s_list.index(min(x for x in s_list)))
print(s)
n, q = list(map(int, input().split()))
s = list(input())
lr = [list(map(int, input().split())) for i in range(q)]
ac = [0] * 10 ** 5
for i in range(n):
    if i < n:
        if s[i] == "A" and s[i + 1] == "C":
            ac[i + 1] = 1
for i in range(q):
    print(ac[lr[i][0] : lr[i][1]].count(1))



### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input()
t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0)

for i in range(q):
    l, r = list(map(int, input().split()))
    print(t[r - 1] - t[l - 1])
#整数の入力
N = int(input())
#文字列の入力
S = input()

#listを一文字ずつのlistに
S_list = list(S)

ans = ""
for i in range(len(S_list)):
  ans = ans + S_list[N+i]
  
print(ans)

### FIXED CODE ###

#整数の入力
N = int(input())
#文字列の入力
S = input()
#listを一文字ずつのlistに
S_list = list(S)

ans = ""
for i in range(len(S_list)):
  if(ord(S_list[i])+N<=90):
    #インクリンメント 次の文字を表示
    ans = ans + chr(ord(S_list[i]) + N)
  else:
    a = ord(S_list[i])+N - 90
    #print(a)
    ans = ans + chr(a+64)
  
print(ans)
import sys

nbs = list(sorted(map(int, list(sys.stdin)[1].strip().split())))
used = set()
count = 0

for k in reversed(range(1, 31)):
    p = 1 << k
    j = len(nbs) - 1
    for i, a in enumerate(nbs):
        if i not in used:
            while j > i and (nbs[j] > p - a or j in used):
                j -= 1
            if j <= i:
                break
            if nbs[j] == p - a:
                used.add(i)
                used.add(j)
                count += 1

print(count)

### FIXED CODE ###

import re
import sys

line = next(map(str.strip, sys.stdin))

count = 0
nb_bs = 0
for i, c in enumerate(line):
    if c == 'W' and nb_bs > 0:
        count += nb_bs
    elif c == 'B':
        nb_bs += 1

print(count)