using System; using System.Linq; namespace ConsoleApplication3 { class Program { private static readonly int[] Count = {20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841}; static void Main(string[] args) { var foo = Console.ReadLine().Where(x => x != '.') .Select(x => int.Parse(x.ToString())) .GroupBy(x => x) .Select(x => new {num = x.Key, cnt = x.Count()}) .OrderBy(x => x.num) .Select(x => x.cnt).ToArray(); var bar = foo.Zip(Count, (act, exp) => new {act, exp}) .Select((x, i) => new {num = i, cond = x.act - x.exp}); Console.WriteLine( $"{bar.Where(x => x.cond > 0).Select(x => x.num).First()} {bar.Where(x => x.cond < 0).Select(x => x.num).First()}"); } } }