Language: C++

using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main() {
        for (string line; (line = Console.ReadLine()) != "0";) {
            var n = int.Parse(line);
            var teams = new Dictionary<int, int>();

            for (var i = 0; i < n; i++) {
                var l = Console.ReadLine().Split();
                var id = int.Parse(l[0]);
                var time = int.Parse(l[1]) * 60 + int.Parse(l[2])
                         + int.Parse(l[3]) * 60 + int.Parse(l[4])
                         + int.Parse(l[5]) * 60 + int.Parse(l[6])
                         + int.Parse(l[7]) * 60 + int.Parse(l[8]);

                teams.Add(id, time);
            }

            var sortedTeams = teams.OrderBy(kv => kv.Value).ToArray();
            Console.WriteLine(sortedTeams[0]);
            Console.WriteLine(sortedTeams[1]);
            Console.WriteLine(sortedTeams[n - 2]);
        }
    }
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:28:2: error: expected ';' after class definition
   28 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Program::Main()':
a.cc:7:14: error: 'string' was not declared in this scope
    7 |         for (string line; (line = Console.ReadLine()) != "0";) {
      |              ^~~~~~
a.cc:7:28: error: 'line' was not declared in this scope
    7 |         for (string line; (line = Console.ReadLine()) != "0";) {
      |                            ^~~~
a.cc:7:35: error: 'Console' was not declared in this scope
    7 |         for (string line; (line = Console.ReadLine()) != "0";) {
      |                                   ^~~~~~~
a.cc:8:13: error: 'var' was not declared in this scope
    8 |             var n = int.Parse(line);
      |             ^~~
a.cc:9:17: error: expected ';' before 'teams'
    9 |             var teams = new Dictionary<int, int>();
      |                 ^~~~~
a.cc:11:22: error: expected ';' before 'i'
   11 |             for (var i = 0; i < n; i++) {
      |                      ^
a.cc:11:29: error: 'i' was not declared in this scope
   11 |             for (var i = 0; i < n; i++) {
      |                             ^
a.cc:11:33: error: 'n' was not declared in this scope
   11 |             for (var i = 0; i < n; i++) {
      |                                 ^
a.cc:12:21: error: expected ';' before 'l'
   12 |                 var l = Console.ReadLine().Split();
      |                     ^
a.cc:13:21: error: expected ';' before 'id'
   13 |                 var id = int.Parse(l[0]);
      |                     ^~
a.cc:14:21: error: expected ';' before 'time'
   14 |                 var time = int.Parse(l[1]) * 60 + int.Parse(l[2])
      |                     ^~~~
a.cc:19:17: error: 'teams' was not declared in this scope
   19 |                 teams.Add(id, time);
      |                 ^~~~~
a.cc:19:27: error: 'id' was not declared in this scope; did you mean 'void'?
   19 |                 teams.Add(id, time);
      |                           ^~
      |                           void
a.cc:19:31: error: 'time' was not declared in this scope
   19 |                 teams.Add(id, time);
      |                               ^~~~
a.cc:1:1: note: 'time' is defined in header '<ctime>'; this is probably fixable by adding '#include <ctime>'
  +++ |+#include <ctime>
    1 | using System;
a.cc:22:17: error: expected ';' before 'sortedTeams'
   22 |             var sortedTeams = teams.OrderBy(kv => kv.Value).ToArray();
      |                 ^~~~~~~~~~~
a.cc:23:31: error: 'sortedTeams' was not declared in this scope
   23 |             Console.WriteLine(sortedTeams[0]);
      |                               ^~~~~~~~~~~
a.cc:25:43: error: 'n' was not declared in this scope
   25 |             Console.WriteLine(sortedTeams[n - 2]);
      |                                           ^