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: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

w = input()
dic = {}

for i in w:
	if not i in dic:
		dic[i] = 1
	else:
		dic[i] += 1

for word in dic:
	if dic[word]%2 != 0:
		print("No")
		break
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
M=[0]*N
for i in range(N):
  M[i]=sorted(list(str(input())))
M.sort()
ans=''
for i in range(N):
  for j in range(L):
    ans+=M[i][j]
print(ans)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
d = {input() for _ in range(n)}
print(sorted(d))

Submission status: Wrong Answer

Solution code:
N, L = input().split(' ')
N = int(N)
L = int(L)
a = []

for i in range(N):
  a.append(input().rstrip())

a.sort()
b = ''.join(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,l = imap()
s = []
for i in range(n): s.append(sinput())

ans = "".join(s)
print(ans)

Submission status: Wrong Answer

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

print(sorted(wordlist))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L = map(int,input().split())
s = []
for i in range(N):
    s.append(input())
ans = s[0]
for i in range(N):
    if s[i]<ans:
        ans = s[i]
print(ans)

Submission status: Wrong Answer

Solution code:
n,l=list(map(int,input().split()))
S=[list(input()) for i in range(n)]
[S[i].sort() for i in range(len(S))]
S.sort()
print(S)
S_sorted=[''.join(S[i]) for i in range(len(S))]
print(S)
ans=''.join(S_sorted)
print(ans)

Submission status: Wrong Answer

Solution code:
n,l=list(map(int,input().split()))
S=[list(input()) for i in range(n)]
[S[i].sort() for i in range(len(S))]
S.sort()
ans=''.join(S[0])
print(ans)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
s = [input() for i in range(n)]
for i in range(n):
    s[i]= sorted(s[i])
    tmp = ''
    for j in range(l):
        tmp += s[i][j]
    s[i] = tmp
s = sorted(s)
show = ''
for i in range(n):
    show += (s[i])
print(show)

Submission status: Wrong Answer

Solution code:
n,l = map(int,input().split())
s = [0]*n
for i in range(n):
    s[i] = input()
s = sorted(s)
ans = []
for i in range(n):
    ans.extend(s[i])
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    *N, = map(str, open(0).read().split())
    S = N[2:]
    L = int(N[1])
    N = int(N[0])

    for i in range(0, L):
        S = sorted(S, key=lambda x: x[i])
    print(''.join(S))


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
print(s[0]+str((len(s)-2))+s[-1])

Submission status: Wrong Answer

Solution code:
l = [x for x in input().split(' ')]
l = sorted(l)
print(''.join(l))

Submission status: Wrong Answer

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

a=[input() for i in range(n)]

print(''.join(a))

Submission status: Wrong Answer

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

a=[]
for i in range(n-1):
    x=input()
    a.append(x[:-1])
a.append(input())

a.sort()
print("".join(a))

Submission status: Wrong Answer

Solution code:
a=input()
b=''
for i in a:
    if i=='0':
        b+='0'
    elif i=='1':
        b+='0'
    else:
        b=b[:-1]
print(b)

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
t = [input() for i in range(s[0])]
for i in range(0, s[0] - 1):
    if t[i] > t[i + 1]:
        u = t[i]
        t[i] = t[i + 1]
        t[i + 1] = u
v = t[0]
for i in range(1, s[0]):
    v = v + t[i]
print(v)

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
t = [input() for i in range(s[0])]
for i in range(0, s[0] - 1):
    if t[i] > t[i + 1]:
        u = t[i]
        t[i] = t[i + 1]
        t[i + 1] = u
v = t[0]
for i in range(1, s[0]):
    v = v + t[i]
v

Submission status: Wrong Answer

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

print(sorted(listA))

Submission status: Wrong Answer

Solution code:
import sys


def main():
    input = sys.stdin.readline
    n, l = map(int, input().split())
    s = [input().rstrip() for i in range(n)]

    s.sort(key=lambda x: x[0])

    print(''.join(s))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())                                                               
moji_array = list(map(str, input().split()))
 
moji_array.sort()
 
result = ''.join(moji_array)
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, l = map(int,input().split())
    s = []

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

    s_sorted = sorted(s)
    answer = ""

    for i in range(N):
        answer += s[i]

    print(answer)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def order(str1, str2):
  for i in range(len(str1)):
    if ord(str1[i]) > ord(str2[i]):
      return False
    elif ord(str1[i]) > ord(str2[i]):
      continue
    else:
      return True

def sort(str_list):
  for i in range(len(str_list) - 1):
    for j in range(i + 1, len(str_list)):
      if not order(str_list[i], str_list[j]):
        temp = str_list[i]
        str_list[i] = str_list[j]
        str_list[j] = temp
  ans = ""
  for i in str_list:
    ans += i
  return ans
 
line1 = input().split()
n = int(line1[0])
l = line1[1]
str_list = []
for i in range(n):
  str_list.append(input())
print(sort(str_list))

Submission status: Wrong Answer

Solution code:
def sort(str_list):
  for i in range(len(str_list) - 1):
    string = str_list[i]
    for j in range(i + 1, len(str_list)):
      next_string = str_list[j]
      for k in range(len(string)):
        if ord(string[k]) > ord(next_string[k]):
          temp = string
          str_list[i] = next_string
          str_list[j] = temp
          break
        elif ord(string[k]) == ord(next_string[k]):
          continue
        else:
          break
  ans = ""
  for i in str_list:
    ans += i
  return ans
 
line1 = input().split()
n = int(line1[0])
l = line1[1]
str_list = []
for i in range(n):
  str_list.append(input())
print(sort(str_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
a = 0
b = 0
for i in s: 
    if i == 5:
        a += 1
    elif i == 7:
        b += 1
        
if a == 2 and b == 1:
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

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

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

words.sort(key=lambda x: x[0])

for word in words:
    print(word, end = '')

Submission status: Wrong Answer

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

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

words.sort(key=lambda x: x[0])

for word in words:
    print(word, end = ' ')

Submission status: Wrong Answer

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

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

words.sort(key=lambda x: x[0])

for word in words:
    print(word)

Submission status: Wrong Answer

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

s_list = sorted(s_list)

answer = ','.join(s_list)
print(answer)

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
S=[]
a=""
for i in range(n):
  s=list(input())
  s.sort()
  for k in range(l):
    a+=s[k]
  S.append(a)
  a=""
S.sort()
ans=""
for j in range(n):
  ans+=S[j]
print(ans)

Submission status: Wrong Answer

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

print(''.join(M))

Submission status: Wrong Answer

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

print(''.join(L))

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
list = []
for s in range(n-1):
  list.append(input())

s_list = sorted(list)
print(*s_list, sep='')

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
list = []
for s in range(n - 1):
  list.append(input())

print(sorted(list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
S=[]
ans=""
for _ in range(N):
    S.append(input())
SS=sorted(S)
for _ in range(N):
    ans+=S[0]
    S.pop(0)
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

w = []
for i in s:
    w.append("".join(sorted(i)))
print("".join(sorted(w)))

Submission status: Wrong Answer

Solution code:
NL = [ x for x in map(int,input().split()) ]
cha = []
i = 0
while i < NL[0]:
  cha.append(input())
  i += 1
print(sorted(cha))

Submission status: Wrong Answer

Solution code:
a = input()
b = []
for i in range(int(a[0])):
    b.append("".join(sorted(input())))
b.sort()
b = "".join(b)
print(b)

Submission status: Wrong Answer

Solution code:
a = input()
b = []
for i in range(int(a[0])):
    b.append(input())
b.sort()
for j in b:
    print(j, end = "")
print("")

Submission status: Wrong Answer

Solution code:
a = input()
b = []
for i in range(int(a[0])):
    b.append(input())
b.sort()
for j in b:
    print(j, end = "")

Submission status: Wrong Answer

Solution code:

n,l = map(int, input().split())
s = [[""]*l for syoki in [""]*n]
flag = [["ok"]*l for syoki in ["ok"]*n]
dummy = ""
#print(s)
for i in range(n):
  dummy = input()
  count = 0
  for q in dummy:
    s[i][count] = q
    count = count + 1

#文字列判定
for j in range(n):
  for k in range(n-1):
    for m in range(l):
      if s[j][m] < s[k][m]:
        dummy =s[j]
        s[j] = s[k]
        s[k] = dummy
        break
out = ""  
for f in range(n):
  for g in range(l):
    out = out + s[f][g]
print(out)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

S = sorted(S)
for x in range(N):
    print(S[x], end=" ")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l = map(int, input().split())
Li = []
i = 0
while i<n:
  li = list(input())
  li.sort()
  Li.append("".join(li))
  i += 1
else:
  Li.sort()
  print("".join(Li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=[input() for _ in range(n)]
t=[]
t.append(s[0])
for i in range(1,n):
  t.append(s[i])
  for j in reversed(range(len(t)-1)):
    for k in range(l):
      if not t[j][:k+1]==t[j+1][:k+1]:
        if ord(t[j][k])>ord(t[j+1][k]):
          t[j],t[j+1]=t[j+1],t[j]
        else:
          break
print("".join(t))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=[input() for _ in range(n)]
t=[]
t.append(s[0])
for i in range(1,n):
  t.append(s[i])
  for j in reversed(range(len(t)-1)):
    for k in range(l):
      if not t[j][:k+1]==t[j+1][:k+1]:
        if ord(t[j][k])>ord(t[j+1][k]):
          t[j],t[j+1]=t[j+1],t[j]
          break
print("".join(t))

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
s=[input() for _ in range(n)]
t=[]
t.append(s[0])
for i in range(1,n):
  t.append(s[i])
  for j in reversed(range(len(t)-1)):
    print(t)
    for k in range(l):
      if not t[j][:k+1]==t[j+1][:k+1]:
        print(t[j][k],t[j+1][k])
        if ord(t[j][k])>ord(t[j+1][k]):
          t[j],t[j+1]=t[j+1],t[j]
          break
print("".join(t))

Submission status: Wrong Answer

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

s = [input() for i in range(int(a[0]))]
b = ''

s.sort()
print(s)

for i in range(int(a[0]),0):
  b = s[i] + b
  
print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
try:
  N, L = map(int, input().split())
  l = []
  for i in range(N):
      l.append(input())
  l_ = sorted(l)
  print(l_)
except EOFError:
  pass

Submission status: Wrong Answer

Solution code:
a = input().split()
a.sort()
print("".join(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def hikaku(n1, n2):
    for x, y in zip(n1, n2):
        if ord(x) == ord(y):
            continue
        else:
            if ord(x) < ord(y):
                return False
    return True
num, length = map(int, input().split())
wlist = []
for i in range(num):
    wlist.append(input())
kumi = [(x, y) for x in range(num) for y in range(x, num) if x != y]
for x, y in kumi:
    if hikaku(wlist[x], wlist[y]):
        wlist[x], wlist[y] = wlist[y], wlist[x]
dst = ""
for w in wlist:
    dst += w
print(dst)

Submission status: Wrong Answer

Solution code:
n,m = map(int , input().split())
li=[]
for i in range(n):
 li.append(input())
sorted(li)
st=''
for e in li:
    st=st+e
print(st)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
a = list(map(int, input().split()))
b = []
for i in sys.stdin:
  b.append(i)

b.sort()

c = ""
for j in b:
  c += j

print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N,L = list(map(int, input().split()))
l=[]
for i in range(N):
    l.append(input())
l.sort()
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ins = list(map(int, input().split()))
N = ins[0]
L = ins[1]
Ss = []

for i in range(N):
  Ss.append(input().strip())

Ss.sort()

print(' '.join(Ss))

Submission status: Wrong Answer

Solution code:
ins = list(map(int, input().split()))
N = ins[0]
L = ins[1]
Ss = []

for i in range(N):
  Ss.append(input().strip())

for i, a in enumerate(Ss):
  key = a
  j = i - 1

  while j >= 0 and Ss[j] > a:
    Ss[j + 1] = Ss[j]
    j = j - 1

  Ss[j + 1] = key

print(' '.join(Ss))

Submission status: Wrong Answer

Solution code:
ins = list(map(int, input().split()))
N = ins[0]
L = ins[1]
Ss = []

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

for i, a in enumerate(Ss):
  key = a
  j = i - 1

  while j >= 0 and Ss[j] > a:
    Ss[j + 1] = Ss[j]
    j = j - 1

  Ss[j + 1] = key

print(' '.join(Ss))

Submission status: Wrong Answer

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

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

for j in range(n-1):    
    for i in range(n):
         if(s[i] < s[i-1]):
            s[i], s[i-1] = s[i-1], s[i]

print(''.join(s))

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
strs = [[]] * N
for i in range(N):
  strs[i] = str(input())
strs.sort()
print(strs)
x = strs[0]
for j in range(1,N):
   x += strs[j]
print(x)

Submission status: Wrong Answer

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

l.sort
result = ''.join(l)
print(result)

Submission status: Wrong Answer

Solution code:
def calord(tmp):
  sumord = 0
  jisu = 1
  for c in reversed(tmp):
    sumord = sumord + ord(c)*jisu
    jisu *= 10
  return int(sumord)

n, l = map(int, input().split())
l1 = [0]*n
for i in range(n):
  tmp = input()
  sum_ord = calord(tmp)
  l1[i] = (sum_ord, tmp)
l2 = sorted(l1)  
r = ""
for i in range(n):
  r = r + l2[i][1]
  
print(r)

Submission status: Wrong Answer

Solution code:
def calord(tmp):
  sumord = ""
  for c in tmp:
    sumord = sumord + str(ord(c))
  return int(sumord)

n, l = map(int, input().split())
l1 = [0]*n
for i in range(n):
  tmp = input()
  sum_ord = calord(tmp)
  l1[i] = (sum_ord, tmp)
l2 = sorted(l1)  
r = ""
for i in range(n):
  r = r + l2[i][1]
  
print(r)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
l1 = [0]*n
for i in range(n):
  tmp = input()
  l1[i] = ((sum([ord(c) for c in tmp]), tmp))
l2 = sorted(l1)  
r = ""
for i in range(n):
  r = r + l2[i][1]
  
print(r)

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
dic1 = {}
for i in range(n):
  tmp = input()
  dic1[sum([ord(c) for c in tmp])] = tmp
dic1_s = sorted(dic1.items())
vs = [d[1] for d in dic1_s]
r = ""
for v in vs:
  r += v
  
print(r)

Submission status: Wrong Answer

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

print(''.join(S))

Submission status: Wrong Answer

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

S = ''.join(S)

print(''.join(sorted(S)))

Submission status: Wrong Answer

Solution code:
str = input()

Submission status: Wrong Answer

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

for i in range(N):
  li.append("".join(sorted(input())))

li.sort()
print("".join(li))

Submission status: Wrong Answer

Solution code:
num = input().split()
str = [input()]
strc = ''
print(str)
flg = 0
res = ''
for i in range(int(num[0])-1):
#	print(1)
	strc = input()
	for j in range(len(str)):
		if str[j] < strc:
			print(2)
			flg = 0
		else:
			print(3)
			flg = j
			break
		j += 1
	flg = -1
	if flg == 0:
		str.append(strc)
	else:
		str.insert(j,strc)
	print(str)
for x in str:
	res += x
print(res)

Submission status: Wrong Answer

Solution code:
num = input().split()
str = [input()]
strc = ''
flg = 0
res = ''
for i in range(int(num[0])-1):
#	print(1)
	strc = input()
	for j in range(len(str)):
		if str[j] < strc:
#			print(2)
			flg = 0
		else:
#			print(3)
			flg = j
	if flg == 0:
		str.append(strc)
	else:
		str.insert(j,strc)
for x in str:
	res += x
print(res)

Submission status: Wrong Answer

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

str = input()
strc = ''
for i in range(int(num[0])-1):
  strc = input()
  if str > strc:
    str = strc + str
  else:
    str = str + strc
print(str)

Submission status: Wrong Answer

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

s.sort(key=lambda x: x[0])
print(''.join(s))

Submission status: Wrong Answer

Solution code:
def str_to_num(_str):
    _str = _str[::-1]
    n = 0
    for i in range(len(_str)):
        n += ((ord(_str[i]) - 96) * 27**i)
    return n

def num_to_str(_num):
    _str = ''
    while True:
        q, mod = divmod(_num, 27)
        _str = chr(mod + 96) + _str
        if q < 27:
            _str = chr(q + 96) + _str
            break
        else:
            _num = q
    return _str

N, L = map(int, input().split())

l = []
for i in range(N):
    l += [str_to_num(input())]

result = ''
while l:
    result += num_to_str(min(l))
    l.remove(min(l))

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=input().split()
b=int(a[0])
data = [input() for i in range(b)]
data.sort()
print(data)

k=""
for i in data:
    k=k+i
print(k)

Submission status: Wrong Answer

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

for i in range(N-1):
    token = input()

    for j in range(L): 
        if token[j] < iroha[j]:
            iroha = token + iroha
            break
        elif token[j] > iroha[j]:
            iroha = iroha + token
            break
        elif j == L-1:
            iroha = token + iroha

print(iroha)

Submission status: Wrong Answer

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

for i in range(N-1):
    token = input()

    for j in range(L): 
        if token[j] < iroha[j]:
            iroha = token + iroha
            break
        elif token[j] > iroha[j]:
            iroha = iroha + token
            break
        elif j == L-1:
            iroha = iroha + token

print(iroha)

Submission status: Wrong Answer

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

for i in range(N):
    token = input()
    if i == 0:
        iroha = token
   
    for j in range(L): 
        if token[j] < iroha[j]:
            iroha = token + iroha
            break
        elif token[j] > iroha[j] or j == L-1:
            iroha = iroha + token
            break

print(iroha)

Submission status: Wrong Answer

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

for i in range(N):
    token = input()
    if i == 0:
        iroha = token
   
    for j in range(L): 
        if token[j] < iroha[j]:
            iroha = token + iroha
            break
        elif token[j] > iroha[j]:
            iroha = iroha + token
            break

print(iroha)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:



line = input()


five_cnt = line.count('5')
seven_cnt = line.count('7')


if five_cnt == 2 and seven_cnt == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
#まずは入力から
nums = input("NとLスペース区切りで入力").split()
N = int(nums[0])
L = int(nums[1])
print("N=" + str(N))
print("L=" + str(L))

#繰り返しの要素入力
count = 0
print("start")
list = []

while count < N:
    list.append(input())
    count += 1

s_list = sorted(list)
print(''.join(s_list))

Submission status: Wrong Answer

Solution code:
#まずは入力から
nums = input("NとLスペース区切りで入力").split()
N = int(nums[0])
L = int(nums[1])
print("N=" + str(N))
print("L=" + str(L))

#繰り返しの要素入力
count = 0
print("start")
list = []

while count < N:
    list.append(input())
    count += 1

s_list = sorted(list)
print(s_list)
print(''.join(s_list))

Submission status: Wrong Answer

Solution code:
NL=input().split()
N=int(NL[0])
L=int(NL[1])

S=[]
rank=[]
for i in range(N):
    S.append(input())
    rank.append(0)
temp=[]
for i in range(N):
    for j in range(N):
        if(S[i]<S[j]):
           temp.append(int(1))
        else:
            temp.append(int(0))        

for i in range(N*N):
    a=i%3
    rank[a]+=temp[i]
j=0
moji=""
for i in range(N):
    for j in range(N):
        if(i==rank[j]):
            moji=moji+S[j]

print(moji)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
R = []
K = ""
R.append(S[0])
for i in range(1, N):
    for j in range (0, i):
        if S[i] < R[j]:
            R.insert(j,S[i])
        if S[i] >= R[i-1]:
            R.append(S[i])
for i in range(0,N):
    K = K + R[i]
print(K)

Submission status: Wrong Answer

Solution code:
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
R = []
K = ""
R.append(S[0])
for i in range(1, N):
    for j in range (0, i):
        if S[i] < R[j]:
            R.insert(j,S[i])
            break
        if S[i] >= R[i-1]:
            R.append(S[i])
for i in range(0,N):
    K = K + R[i]
print(K)

Submission status: Wrong Answer

Solution code:
x,y = map(int,input().split())
li = input().split()
li=sorted(li)
string = "".join(li)
print(string)

Submission status: Wrong Answer

Solution code:
li = input().split()
li=sorted(li)
string = "".join(li)
print(string)

Submission status: Wrong Answer

Solution code:
NL = input()

iroha = []
i=0
while i < int(NL[0]):
    inp = input()
    iroha.append(inp)
    i+=1

for value in sorted(iroha):
    print(value, end='')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
arr_len_int = int(input().split(' ')[0])
a = [input() for i in range(arr_len_int)]
a.sort()
b = set(a)
print(''.join(b ))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print('hello')

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

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

s.sort()

for i in range(n):
    print(s[i],end ='')

print('')

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
for i in range(N):
  s=input()
s=sorted(s)
print(*s,sep='')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split(" "))
ln = []

for i in range(n):
  ln.append(input())
  
ln.sort()

s = ""
for word in ln:
  s += word
  
print(ln)
print(s)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
N, L = F.readline().rstrip().split()
print(type(int(N)))
N = int(N)
L = int(L)
a = [F.readline().rstrip() for x in range(N)]

a.sort()
answer = ''.join(a)
print(answer)

Submission status: Wrong Answer

Solution code:
n = input()
l = ''
for i in n:
  c = 0
  if i == '1' or i == '0':
    l += i
  else:
    l = l[:len(l)-1]
print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, l = map(int, input().split())
sorted_list = sorted(sorted(input()) for _ in range(n))

for s_1 in sorted_list:
  for s_2 in s_1:
    print(s_2, sep = '', end = '')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 入力のNとLを読み取る
N, L = map(int, input().split())

#S1 ~ SNをリスト化
list_a = [input() for i in range(N)]

list_a.sort()

"".join(list_a)

print(list_a)

Submission status: Wrong Answer

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

list_a = [str(input()) for i in range(N)]

list_a.sort()

print(list_a[0])

Submission status: Wrong Answer

Solution code:
A = list(map(str, input().split()))
A.sort()

res = ''
for a in A:
    res += a

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

s.sort()
print(s)