Language: Java

/**
 * Heaps - Maximum Heap
 */

#include <iostream>

using namespace std;

int H, A[500000];

void heapfy(int *a, int i) {

    int l, r;
    l = i * 2;
    r = i * 2 + 1;

    int i_ = i;

    if (l <= H && a[l] > a[i]) i_ = l;
    if (r <= H && a[r] > a[i_]) i_ = r;

    if (i_ != i) {
        int tmp = a[i];
        a[i] = a[i_];
        a[i_] = tmp;
        heapfy(a, i_);
    }
}

int main() {

    cin >> H;

    for (int i = 1; i <= H; i++) {
        cin >> A[i];
    }

    for (int i = H / 2; i >= 1; i--) {
        heapfy(A, i);
    }

    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}


Compiler output:
Main.java:5: error: illegal character: '#'
#include <iostream>
^
Main.java:5: error: class, interface, enum, or record expected
#include <iostream>
         ^
Main.java:9: error: class, interface, enum, or record expected
int H, A[500000];
^
Main.java:11: error: unnamed classes are a preview feature and are disabled by default.
void heapfy(int *a, int i) {
^
  (use --enable-preview to enable unnamed classes)
Main.java:11: error: <identifier> expected
void heapfy(int *a, int i) {
               ^
Main.java:11: error: class, interface, enum, or record expected
void heapfy(int *a, int i) {
                    ^
Main.java:14: error: class, interface, enum, or record expected
    l = i * 2;
    ^
Main.java:15: error: class, interface, enum, or record expected
    r = i * 2 + 1;
    ^
Main.java:19: error: class, interface, enum, or record expected
    if (l <= H && a[l] > a[i]) i_ = l;
    ^
Main.java:20: error: class, interface, enum, or record expected
    if (r <= H && a[r] > a[i_]) i_ = r;
    ^
Main.java:22: error: class, interface, enum, or record expected
    if (i_ != i) {
    ^
Main.java:24: error: class, interface, enum, or record expected
        a[i] = a[i_];
        ^
Main.java:25: error: class, interface, enum, or record expected
        a[i_] = tmp;
        ^
Main.java:26: error: class, interface, enum, or record expected
        heapfy(a, i_);
        ^
Main.java:27: error: class, interface, enum, or record expected
    }
    ^
Main.java:34: error: class, interface, enum, or record expected
    for (int i = 1; i <= H; i++) {
    ^
Main.java:34: error: class, interface, enum, or record expected
    for (int i = 1; i <= H; i++) {
                    ^
Main.java:34: error: class, interface, enum, or record expected
    for (int i = 1; i <= H; i++) {
                            ^
Main.java:36: error: class, interface, enum, or record expected
    }
    ^
Main.java:38: error: class, interface, enum, or record expected
    for (int i = H / 2; i >= 1; i--) {
                        ^
Main.java:38: error: class, interface, enum, or record expected
    for (int i = H / 2; i >= 1; i--) {
                                ^
Main.java:40: error: class, interface, enum, or record expected
    }
    ^
Main.java:42: error: class, interface, enum, or record expected
    for (int i = 1; i <= H; i++) {
                    ^
Main.java:42: error: class, interface, enum, or record expected
    for (int i = 1; i <= H; i++) {
                            ^
Main.java:44: error: class, interface, enum, or record expected
    }
    ^
Main.java:46: error: class, interface, enum, or record expected
}
^
26 errors