Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Heap {
	class Program {
		private static int _H;
		private static int[] _A = new int[2000000];

		static void Main(string[] args) {
			_H = int.Parse(Console.ReadLine());
			var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
			foreach (var item in line.Select((v, ix) => new { v, ix })) _A[item.ix + 1] = item.v;

			for (int i = _H / 2; i >= 1; i--) maxHeapify(i);
			foreach (var item in _A.Skip(1).Take(_H)) {
				Console.Write(" {0}", item);
			}
			Console.WriteLine();
		}

		private static void Swap<T>(ref T lhs, ref T rhs) {
			T temp;
			temp = lhs;
			lhs = rhs;
			rhs = temp;
		}

		private static void maxHeapify(int i) {
			int l, r, largest;
			l = 2 * i;
			r = l + 1;

			// 左の子、自分、右の子で値が最大のノードを選ぶ
			if (l <= _H && _A[l] > _A[i]) largest = l;
			else largest = i;
			if (r <= _H && _A[r] > _A[largest]) largest = r;

			if(largest != i) {
				Swap<int>(ref _A[i], ref _A[largest]);
				maxHeapify(largest);
			}
		}
	}
}



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:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Text;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Threading.Tasks;
      |       ^~~~~~
a.cc:9:24: error: expected ':' before 'static'
    9 |                 private static int _H;
      |                        ^~~~~~~
      |                        :
a.cc:10:24: error: expected ':' before 'static'
   10 |                 private static int[] _A = new int[2000000];
      |                        ^~~~~~~
      |                        :
a.cc:10:35: error: expected unqualified-id before '[' token
   10 |                 private static int[] _A = new int[2000000];
      |                                   ^
a.cc:12:34: error: 'string' has not been declared
   12 |                 static void Main(string[] args) {
      |                                  ^~~~~~
a.cc:12:43: error: expected ',' or '...' before 'args'
   12 |                 static void Main(string[] args) {
      |                                           ^~~~
a.cc:24:24: error: expected ':' before 'static'
   24 |                 private static void Swap<T>(ref T lhs, ref T rhs) {
      |                        ^~~~~~~
      |                        :
a.cc:24:37: error: variable or field 'Swap' declared void
   24 |                 private static void Swap<T>(ref T lhs, ref T rhs) {
      |                                     ^~~~
a.cc:24:37: error: expected ';' at end of member declaration
   24 |                 private static void Swap<T>(ref T lhs, ref T rhs) {
      |                                     ^~~~
      |                                         ;
a.cc:24:41: error: expected unqualified-id before '<' token
   24 |                 private static void Swap<T>(ref T lhs, ref T rhs) {
      |                                         ^
a.cc:31:24: error: expected ':' before 'static'
   31 |                 private static void maxHeapify(int i) {
      |                        ^~~~~~~
      |                        :
a.cc:46:10: error: expected ';' after class definition
   46 |         }
      |          ^
      |          ;
a.cc: In static member function 'static void Heap::Program::Main(int*)':
a.cc:13:30: error: expected primary-expression before 'int'
   13 |                         _H = int.Parse(Console.ReadLine());
      |                              ^~~
a.cc:14:25: error: 'var' was not declared in this scope
   14 |                         var line = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
      |                         ^~~
a.cc:15:38: error: expected ')' before 'item'
   15 |                         foreach (var item in line.Select((v, ix) => new { v, ix })) _A[item.ix + 1] = item.v;
      |                                      ^~~~
a.cc:15:33: note: to match this '('
   15 |                         foreach (var item in line.Select((v, ix) => new { v, ix })) _A[item.ix + 1] = item.v;
      |                                 ^
a.cc:15:25: error: 'foreach' was not declared in this scope
   15 |                         foreach (var item in line.Select((v, ix) => new { v, ix })) _A[item.ix + 1] = item.v;
      |                         ^~~~~~~
a.cc:18:38: error: expected ')' before 'item'
   18 |                         foreach (var item in _A.Skip(1).Take(_H)) {
      |                                      ^~~~
a.cc:18:33: note: to match this '('
   18 |                         foreach (var item in _A.Skip(1).Take(_H)) {
      |                                 ^
a.cc:21:25: error: 'Console' was not declared in this scope
   21 |                         Console.WriteLine();
      |                         ^~~~~~~
a.cc: In static member function 'static void Heap::Program::maxHeapify(int)':
a.cc:37:40: error: '_A' was not declared in this scope; did you mean '_H'?
   37 |                         if (l <= _H && _A[l] > _A[i]) largest = l;
      |                                        ^~
      |                                        _H
a.cc:39:40: error: '_A' was not declared in this scope; did you mean '_H'?
   39 |                         if (r <= _H && _A[r] > _A[largest]) largest = r;
      |                                        ^~
      |                                        _H
a.cc:42:33: error: 'Swap' was not declared in this scope
   42 |                                 Swap<int>(ref _A[i], ref _A[largest]);
      |                                 ^~~~
a.cc:42:38: error: expected primary-expression before 'int'
   42 |                                 Swap<int>(ref _A[i], ref _A[largest]);
      |                                      ^~~