void Solve(StreamScanner ss, StreamWriter sw) { //--------------------------------- var S = ss.Next(String); var K = ss.Next(int.Parse); var sos = new SortedSet <string>(); for (var j = 1; j <= 5; j++) { for (var i = 0; i <= S.Length - j; i++) { sos.Add(S.Substring(i, j)); } } sw.WriteLine(sos.ToArray()[K - 1]); //--------------------------------- }