title: Lexicographical Concatenation Substrings String
signature: lexicographicalConcatenationSubstringsString :: String -> String
  lexicographicalConcatenationSubstringsString s = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: String -> String -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: String -> String -> String
  driver s expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME s) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver ("sqGOi") ("GGOGOiOOiiqqGqGOqGOissqsqGsqGOsqGOi") )
  
      printf "TEST-1...%s\n" (driver ("ZhWXUKmeiI") ("IKKmKmeKmeiKmeiIUUKUKmUKmeUKmeiUKmeiIWWXWXUWXUKWXUKmWXUKmeWXUKmeiWXUKmeiIXXUXUKXUKmXUKmeXUKmeiXUKmeiIZZhZhWZhWXZhWXUZhWXUKZhWXUKmZhWXUKmeZhWXUKmeiZhWXUKmeiIeeieiIhhWhWXhWXUhWXUKhWXUKmhWXUKmehWXUKmeihWXUKmeiIiiImmemeimeiI") )
  
      printf "TEST-2...%s\n" (driver ("tjP kR") ("  k kRPP P kP kRRjjPjP jP kjP kRkkRttjtjPtjP tjP ktjP kR") )
  
      printf "TEST-3...%s\n" (driver ("qJPHNSJOUj") ("HHNHNSHNSJHNSJOHNSJOUHNSJOUjJJJOJOUJOUjJPJPHJPHNJPHNSJPHNSJJPHNSJOJPHNSJOUJPHNSJOUjNNSNSJNSJONSJOUNSJOUjOOUOUjPPHPHNPHNSPHNSJPHNSJOPHNSJOUPHNSJOUjSSJSJOSJOUSJOUjUUjjqqJqJPqJPHqJPHNqJPHNSqJPHNSJqJPHNSJOqJPHNSJOUqJPHNSJOUj") )
  
source_py: def lexicographical_concatenation_substrings_string(s):
      n = len(s)
      sub_count = ((n * (n + 1)) // 2)
      arr = ([0] * sub_count)
      index = 0
      for i in range(n):
          for j in range(1, ((n - i) + 1)):
              arr[index] = s[i:(i + j)]
              index += 1
      arr.sort()
      res = ''
      for i in range(sub_count):
          res += arr[i]
      return res
source_cpp: string lexicographical_concatenation_substrings_string(string s) {
    int n = s . length ( );
    int sub_count = n * ( n + 1 ) / 2;
    string arr [ sub_count ];
    int index = 0;
    for ( int i = 0;
    i < n;
    i ++ ) for ( int len = 1;
    len <= n - i;
    len ++ ) arr [ index ++ ] = s . substr ( i, len );
    sort ( arr, arr + sub_count );
    string res = "";
    for ( int i = 0;
    i < sub_count;
    i ++ ) res += arr [ i ];
    return res;
  }