Problem:


Score : 200 points

Problem Statement

Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.

She will concatenate all of the strings in some order, to produce a long string.

Among all strings that she can produce in this way, find the lexicographically smallest one.

Here, a string s=s_1s_2s_3...s_n is lexicographically smaller than another string t=t_1t_2t_3...t_m if and only if one of the following holds:

There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.

s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Constraints

1 ≦ N, L ≦ 100

For each i, the length of S_i equals L.

For each i, S_i consists of lowercase letters.

Input

The input is given from Standard Input in the following format:

N L
S_1
S_2
:
S_N

Output

Print the lexicographically smallest string that Iroha can produce.

Sample Input 1

3 3
dxx
axx
cxx

Sample Output 1

axxcxxdxx

The following order should be used: axx, cxx, dxx.



Sample input:
3 3
dxx
axx
cxx


Sample output:
axxcxxdxx

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
for i in range(n):
    l.append(input())
l.sort()
print(''.join(l))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
print(''.join(s))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = []
for i in range(N):
    S.append(input())
S.sort()
print(''.join(S))

Submission status: Accepted

Solution code:
n,l=map(int,input().split())
s=[input()for i in range(n)]
print("".join(sorted(s)))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
s = list(input() for i in range(n))
s.sort()

x = "".join(s)

print(x)

Submission status: Accepted

Solution code:
#
# abc042 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
dxx
axx
cxx"""
        output = """axxcxxdxx"""
        self.assertIO(input, output)


def resolve():
    N, L = map(int, input().split())
    S = []
    for _ in range(N):
        S.append(input())
    S.sort()
    ans = ""
    for i in range(len(S)):
        ans += S.pop(0)
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
n,l = map(int,input().split())
s = list(input() for i in range(n))
s = sorted(s)
print(''.join(s))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = sorted(list(input() for i in range(N)))
ans = str()
for i in range(N):
    ans += S[i]
print(ans)

Submission status: Accepted

Solution code:
N, LEN = list(map(int, input().split()))
a = []
for i in range(N):
    s = input()
    a.append(s)
b = sorted(a)
ans = "".join(b)
print(ans)

Submission status: Accepted

Solution code:
N,L = map(int,input().split())
S = sorted([input() for _ in range(N)])

print("".join(S))

Submission status: Accepted

Solution code:
N,L = [int(i) for i in input().split()]
S = [input() for _ in range(N)]

S.sort()
[print(i,end='') for i in S]

Submission status: Accepted

Solution code:
n, _ = [int(x) for x in input().split()]
ss = sorted([input() for _ in range(n)])
print(''.join(ss))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
k = [input() for _ in range(n)]
s = sorted(k)
print("".join(s))

Submission status: Accepted

Solution code:
def main():
	N, L = map(int, input().split())
	S = []

	for _ in range(N):
		S.append(input())

	S.sort()
	
	print("".join(S))


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
 
C = [input() for i in range(N)]
 
C.sort()
 
i=0
 
while i < N:
    print(C[i] , end ="")
    i += 1

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = [input() for _ in range(N)]
S.sort()
ans = ""
for s in S:
    ans += s
print(ans)

Submission status: Accepted

Solution code:
N, L = map(int, input().split())

C = [input() for i in range(N)]

C.sort()

i=0

while i < N:
    print(C[i] , end ="")
    i += 1

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
s = sorted([input () for i in range(x)])
print("".join(s))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = sorted([input() for i in range(N)])
print("".join(S))

Submission status: Accepted

Solution code:
N, L = map(int,input().split())
A = []
for i in range(N):
    S = input()
    A.append(S)
    
A = sorted(A)
ans = ''
for i in A:
    ans += i

print(ans)

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = [input() for _ in range(N)]

S.sort()

print("".join(S))

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 042
# B - 文字列大好きいろはちゃんイージー

N,L=map(int,input().split())
arr=[]
for i in range (N):
    a=input()
    arr.append(a)
arr.sort()
print("".join(arr))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
sl = []
for i in range(n):
    s = input()
    sl.append(s)
sl.sort()
#print(sl)
ans = ""
for i in range(n):
    ans += sl[i]
print(ans)

Submission status: Accepted

Solution code:
n,l = map(int,input().split())
string_list=[input() for i in range(n)]

string_list.sort()
for X in string_list:
  print(X, end="")

Submission status: Accepted

Solution code:
n,l = map(int,input().split())
s = sorted([input() for i in range(n)])
print("".join(s))

Submission status: Accepted

Solution code:
INP=list(map(int, input().split()))
N,L=INP[0],INP[1]
Slist=[]
for i in range(N):
  Slist.append(str(input()))
print("".join(sorted(Slist)))

Submission status: Accepted

Solution code:
def check(s1, s2):
    for i in range(len(s1)):
        if s1[i] < s2[i]:
            return s1
        elif s1[i] > s2[i]:
            return s2
    return s1
        

def s(a, l):
    for i in range(len(a)):
        m_step = 'z' * l
        ind = -1
        for j in range(i, len(a)):
            m_step = check(m_step, a[j])
            if m_step == a[j]:
                ind = j
        a[i], a[ind] = a[ind], a[i]
    return a
        
        
            

n, l = map(int, input().split())
strs = []
for i in range(n):
    strs.append(input())
print(''.join(s(strs, l)))

Submission status: Accepted

Solution code:
n,l = map(int, input().split())
s = []
for i in range(n):
  x = input()
  s.append(x)
  
s.sort()
ans = ''

for i in s:
  ans += i
  
print(ans)

Submission status: Accepted

Solution code:
N,L = map(int, input().split())
S = [input() for l in range(N)]

S.sort()

s1 = S[0]

for i in range(1,N):
  s1 += S[i]
  
print(s1)

Submission status: Accepted

Solution code:
# B - 文字列大好きいろはちゃんイージー
def main():
    n, _ = map(int, input().split())
    s = [input() for i in range(n)]
    s.sort()

    print(''.join(s))


if __name__ ==  "__main__":
    main()

Submission status: Accepted

Solution code:
N,L=map(int,input().split())
s = [input() for _ in range(N)]
s = sorted(s)
print(''.join(s))

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, l = inintm()

s = []

for _ in range(n):
    s.append(input())

s.sort()

print("".join(s))

Submission status: Accepted

Solution code:
N, L = map(int,input().split())
S = [input() for _ in range(N)]

print("".join(sorted(S)))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
print(''.join(s))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())

S.sort()
ans = "".join(S)
print(ans)

Submission status: Accepted

Solution code:
N,L=map(int,input().split())
s=[]
for i in range(N):
  s.append(input())
s.sort()
ans=""
for j in s:
  ans+=j
print(ans)

Submission status: Accepted

Solution code:
N, L = list(map(lambda a: int(a), input().split(" ")))
A = []
for i in range(N):
  A.append(input())
  
A.sort()
print("".join(A))

Submission status: Accepted

Solution code:
n,x = (int(i) for i in input().split())
l = []
for i in range (n):
  s = input ()
  l.append (s)
list.sort(l)
print(''.join(l))

Submission status: Accepted

Solution code:
n,l =map(int,input().split())
ss = [input() for _ in range(n)]
s =sorted(ss)
ans =""
for i in s:
  ans += i
print(ans)

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = []
for i in range(N):
    S.append(input())

S.sort()
for X in S:
    print(X, end="")

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = [input().strip() for _ in range(N)]
print("".join(sorted(S)))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
ll = []
for i in range(n):
    ll.append(input())
ll.sort()
ans = ""
for j in ll:
    ans += j

print(ans)

Submission status: Accepted

Solution code:
N,J = map(int,input().split())
S = [str(input()) for _ in range(N)]
S.sort()
print("".join(S))

Submission status: Accepted

Solution code:
n,l = input().split()
S = []
for i in range(int(n)):
  S.append(input())
S.sort()
str = ''
for s in S:
  str += s
print(str)

Submission status: Accepted

Solution code:
n,l=map(int,input().split())
li=[input() for _ in range(n)]
li.sort()
res=""
for i in range(n):
    res+=li[i]
print(res)

Submission status: Accepted

Solution code:
N,L=map(int,input().split())
X=[]*N
B=0
Ans=""
x=[]*N
s=[]*N
for i in range(N):
    X.append(input())
 
X.sort()

for i in range(N):
    Ans+=(X[i])

print(Ans)

Submission status: Accepted

Solution code:
n,l = map(int,input().split())

word_list = []

for i in range(n):
    word_list.append(input())

answer = ''.join(sorted(word_list))
print(answer)

Submission status: Accepted

Solution code:
N,L = map(int,input().split())
list1 = []
for l in range(N):
    list1.append(str(input()))
list1.sort()
print(''.join(list1))

Submission status: Accepted

Solution code:
N,L= map(int,input().split())
list=[]
for I in range(N):
    S=str(input())
    list.append(S)
list.sort()
c="".join(list)
print(c)

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
s = [str(input()) for i in range(N)]
s.sort()
S=""
for i in range(N):
    S+=s[i]
print(S)

Submission status: Accepted

Solution code:

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

s = [str(input()) for _ in range(l)]
s.sort()

print(''.join(s))

Submission status: Accepted

Solution code:
n,l=map(int,input().split())
ans=[]
for i in range(n):
    ans.append(input())
ans=sorted(ans)

a=ans[0]
for i in range(n-1):
    a=a+ans[i+1]
print(a)

Submission status: Accepted

Solution code:
val = input()
splited_val = val.split()

val_list=[]

for x in range(int(splited_val[0])):
    val = input()
    val_list.append(val)

print("".join(sorted(val_list)))

Submission status: Accepted

Solution code:
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print("".join(s))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
a = []
if n == 1:
  print(input())
  exit()
for i in range(n):
  a.append(input())
a.sort()
a = ''.join(a)
print(a)

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
lst = []
for i in range(N):
  lst.append(input())

slst = sorted(lst)
print("".join(slst))

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

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

strs = []
for i in range(n):
    strs.append(input())

for i in range(1,l+1):
    strs.sort(key=lambda x:x[l-i])

for i in range(n):
    print(strs[i], end="")

Submission status: Accepted

Solution code:
N, L = map(int,input().split())
a = []
for i in range(N):
    a.append(input())
a.sort()
ans= ''
for i in a:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
first= input()
first = first.split()

N = int(first[0])
L =[]
for i in range(N):
  s = input()
  L.append(s)
  
L.sort()
for i in L:
  print(i,end="")

Submission status: Accepted

Solution code:
first = input()
first = first.split()

N = int(first[0])
L = []
for i in range(N):
  s = input()
  L.append(s)
  
L.sort()
for i in L:
  print(i,end="")

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
print(*sorted([input() for _ in range(n)]), sep='')

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
s = sorted([input() for _ in range(n)])
print(*s, sep='')

Submission status: Accepted

Solution code:
n, l = input().split()
n = int(n)
s = [input() for _ in range(n)]
s.sort()
print(*s, sep='')

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
input_line1 = [input() for i in range(N)]
input_line2 = []
for i in range(N):
	input_line2.append(min(input_line1))
	input_line1.remove(min(input_line1))
print("".join(input_line2))

Submission status: Accepted

Solution code:
N,L = map(int, input().split())
string_list = [input() for i in range(N)]
string_list.sort()
print(''.join(string_list))

Submission status: Accepted

Solution code:
N,L = map(int, input().split())
string_list = [input() for i in range(N)]
string_list.sort()
print(''.join(string_list),sep='\n')

Submission status: Accepted

Solution code:
n, _l = map(int,input().split())
s = [input() for _ in range(n)]
print("".join(sorted(s)))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = []
for i in range(N):
    S.append(input())


list.sort(S)

ans = ''.join([str(i) for i in S])
    
print(ans)

Submission status: Accepted

Solution code:
N,L=map(int, input().split(" "))
s=[]
for i in range(N):
    s.append(input())

s.sort()

l = ''.join([str(n) for n in s])

print(l)

Submission status: Accepted

Solution code:
# N, L = 3, 3
# SRR = [
#     "dxx",
#     "axx",
#     "cxx"
# ]

N, L = map(int,input().split())
SRR = []

for i in range(N):
    SRR.append(input())


srr2 = sorted(SRR)


result = "".join(srr2)

print(result)

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
slst = [input() for _ in range(n)]
slst.sort()
ans = ""
for s in slst:
    ans += s
print(ans)

Submission status: Accepted

Solution code:

def main():
    N, L = map(int,input().split())
    S = [input() for _ in range(N)]
    S.sort()
    for i in S:
        print(i, end = "")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, l = map(int, input().split())
    ss = [list(input()) for _ in range(n)]

    for i in range(l-1, -1, -1):
        ss = sorted(ss, key=lambda x: x[i])

    ans = ''
    for i in range(n):
        for j in range(l):
            ans += ss[i][j]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,L = map(int,input().split())
array = [input() for i in range(N)]
array.sort()
for i in array:
    print(i,end='')

Submission status: Accepted

Solution code:
N,L=map(int,input().split())
S=[input() for i in range(N)]
S.sort()
print("".join(S))

Submission status: Accepted

Solution code:
n,l=map(int, input().split())
s=[input() for i in range(n)]
s.sort()
print(*s,sep="")

Submission status: Accepted

Solution code:
N = list(map(int, input().split()))
dic = []

for ins in range(N[0]):
  dic.append(input())

s = ""
for ins in sorted(dic):
  s += ins

print(s)

Submission status: Accepted

Solution code:
N,L=map(int,input().split())
S=[input() for _ in range(N)]
S.sort()
print(''.join(S))

Submission status: Accepted

Solution code:
N,L = map(int,input().split())
S = [input() for _ in range(N)]
S.sort()
for i in S:
    print(i, end = "")

Submission status: Accepted

Solution code:
n,l=map(int,input().split())
k=[input() for i in range(n)]
k.sort()
print("".join(k))

Submission status: Accepted

Solution code:
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    n,k=mp()
    l=[]
    for i in range(n):
        s=input()
        l.append(s)
    l.sort()
    print(''.join(l))
        

for _ in range(1):
    solve()

Submission status: Accepted

Solution code:
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():
    N, L = LI()
    S = [SS() for _ in range(N)]

    S.sort()
    print(''.join(S))

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
str_list = []
i = 1
n_number, l_length = map(int, input().split())
while i <= n_number:
    w_1 = input()
    str_list.append(w_1)
    i += 1


str_list.sort()
print(''.join(str_list))

Submission status: Accepted

Solution code:
N,L = map(int, input().split())
S = sorted(input() for _ in range(N))

print(''.join(S))

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n, l = map(int, input().split())
    s = [input() for _ in range(n)]
    for i in range(l):
        s.sort()
    print("".join(s))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
val1=list(map(int,input().split()))
val2=[input() for i in range(val1[0])]

val2.sort()
print("".join(val2))

Submission status: Accepted

Solution code:
def main():
    n,l=map(int,input().split(' '))
    li=[input() for i in range(n)]
    for i in range(n):
        print(min(li),end='')
        li.remove(min(li))

main()

Submission status: Accepted

Solution code:
FirstLine = input()
FirstLine = FirstLine.split()
L1 = []
for i in range(int(FirstLine[0])):
  s = input()
  L1.append(s)
L1.sort()
a = ""
for i in L1:
  a += i
 
print(a)

Submission status: Accepted

Solution code:
Firstline = input()
Firstline = Firstline.split()

List = []
for i in range(int(Firstline[0])):
  List.append(input())

List.sort()
s = ""
for i in List:
  s += i

print(s)

Submission status: Accepted

Solution code:
def resolve():
    N, L = map(int, input().split())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    S = sorted(S)
    ans = ""
    for i in range(N):
        ans += S[i]
    print(ans)
resolve()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ar=[input() for _ in range(n)]
ar=sorted(ar)
print(''.join(ar))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = [input() for _ in range(N)]
print(''.join(sorted(S)))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
A = []
for i in range(N):
	S = input()
	A.append(S)

A.sort()
for i in range(N-1):
	print(A[i], end="")
print(A[N-1])

Submission status: Accepted

Solution code:
print("".join(sorted(input() for _ in range(int(input().split()[0])))))

Submission status: Accepted

Solution code:
N, L = [int(x) for x in input().split()]                                   
S = [input() for _ in range(N)]

def f(s, p=0):
    for i, c in enumerate("abcdefghijklmnopqrstuvwxyz"):
        if s[p] == c:
            if p == L - 1:
                return (i, )
            else:
                return (i, ) + f(s, p + 1)

print("".join([x[1] for x in sorted([(f(s), s) for s in S])]))

Submission status: Accepted

Solution code:
def main():
  N,L=map(int,input().split())
  a=[input() for _ in range(N)]
  print(''.join(sorted(a)))

if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
SSS = [input() for _ in range(N)]
SSS.sort()
print(''.join(SSS))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
s = []
for i in range(N):
  s.append(input())
  
s = sorted(s)

print("".join(s))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
lst = []
for i in range(n):
  lst.append(input())
lst.sort()
print(''.join(lst))

Submission status: Accepted

Solution code:
N, L = map(int, input().split())

S = []

for _ in range(N):
    s = input()
    S.append(s)

S.sort()

for obj in S:
    print(obj, end="")

print()

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
S = [input() for s in range(N)]
S.sort()
output = ""
for i in S:
  output+=i
print(output)

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
s = sorted(input() for _ in range(n))
print(*s, sep="")

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
s = sorted([input() for _ in range(n)])
print(''.join(s))

Submission status: Accepted

Solution code:
n, l = map(int, input().split())
S = list(input() for _ in range(n))
print(''.join(sorted(S)))