public static class Program
                  
                  
                      {
                  
                  
                          private static readonly Dictionary<string, int> Triples = new ();
                  
                  
                          public static async Task Main()
                  
                  
                          {
                  
                  
                              var content = await File.ReadAllTextAsync(Console.ReadLine()!);
                  
                  
                              var threads = content.Length / 200;
                  
                  
                              for (; threads > -1; threads--)
                  
                  
                              {
                  
                  
                                  await Task.Run(() => ParseString(content.Length > 200 ? content.Substring(0, 200) : content));
                  
                  
                                  content = content.Remove(0, content.Length > 200 ? 200 : content.Length);
                  
                  
                              }
                  
                  
                  
                  
                  
                              var sorted = Triples.OrderBy(x => x.Value);
                  
                  
                              var res = sorted.TakeLast(10).Reverse();
                  
                  
                              Console.WriteLine(res);
                  
                  
                          }
                  
                  
                  
                  
                  
                          private static void ParseString(string input)
                  
                  
                          {
                  
                  
                              var spl = input.Split();
                  
                  
                  
                  
                  
                              foreach (var @string in spl)
                  
                  
                              {
                  
                  
                                  StringBuilder stringBuilder = new (@string);
                  
                  
                                  while (stringBuilder.Length > 3)
                  
                  
                                  {
                  
                  
                                      string triple = stringBuilder.ToString().Substring(0, 3);
                  
                  
                                      if (Triples.ContainsKey(triple)) Triples[triple]++;
                  
                  
                                      else Triples.Add(triple, 1);
                  
                  
                                      stringBuilder.Remove(0, 1);
                  
                  
                                  }
                  
                  
                              }
                  
                  
                          }
                  
                  
                      }
                  
                  
                  } @i_van_ga
                  
                  
                
ну делай через string builder
кому написать код, который сожрёт терабайт памяти?)))
это я еще остановил выполнение кода
Обсуждают сегодня