Language: Java

#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;
typedef pair<int,int> P;
int N;
P A[500000];
bool compare_y(P a, P b) {
  return a.second < b.second;
}

int closest_pair(P *a ,int n) {
  if(n <= 1) return 2 << 27;
  int m = n /2;
  int x = a[m].first;
  int d = min(closest_pair(a,m),closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, compare_y);

  vector<P> b;
  for(int i = 0; i < n; i++) {
    if(abs(a[i].first - x) >= d) continue;
    for(int j = 0; j < b.size(); j++) {
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j - 1].second;
      if(dy >= d) break;
      d = min(d,(dx * dx + dy * dy));
    }
    b.push_back(a[i]);
  }
  return d;
}

void solve() {
  sort(A,A + N);
  printf("%d\n", closest_pair(A,N));
}

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x;
    cin >> y;
    A[i] = P(x,y);
  }
  solve();

}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <vector>
^
Main.java:3: error: illegal character: '#'
#include <math.h>
^
Main.java:4: error: illegal character: '#'
#include <stdio.h>
^
Main.java:5: error: illegal character: '#'
#include <algorithm>
^
Main.java:8: error: class, interface, enum, or record expected
typedef pair<int,int> P;
^
Main.java:9: error: unnamed classes are a preview feature and are disabled by default.
int N;
^
  (use --enable-preview to enable unnamed classes)
Main.java:10: error: class, interface, enum, or record expected
P A[500000];
^
Main.java:15: error: <identifier> expected
int closest_pair(P *a ,int n) {
                  ^
Main.java:15: error: class, interface, enum, or record expected
int closest_pair(P *a ,int n) {
                       ^
Main.java:20: error: class, interface, enum, or record expected
  inplace_merge(a, a + m, a + n, compare_y);
  ^
Main.java:23: error: class, interface, enum, or record expected
  for(int i = 0; i < n; i++) {
  ^
Main.java:23: error: class, interface, enum, or record expected
  for(int i = 0; i < n; i++) {
                 ^
Main.java:23: error: class, interface, enum, or record expected
  for(int i = 0; i < n; i++) {
                        ^
Main.java:25: error: class, interface, enum, or record expected
    for(int j = 0; j < b.size(); j++) {
    ^
Main.java:25: error: class, interface, enum, or record expected
    for(int j = 0; j < b.size(); j++) {
                   ^
Main.java:25: error: class, interface, enum, or record expected
    for(int j = 0; j < b.size(); j++) {
                                 ^
Main.java:28: error: class, interface, enum, or record expected
      if(dy >= d) break;
      ^
Main.java:29: error: class, interface, enum, or record expected
      d = min(d,(dx * dx + dy * dy));
      ^
Main.java:30: error: class, interface, enum, or record expected
    }
    ^
Main.java:32: error: class, interface, enum, or record expected
  }
  ^
Main.java:34: error: class, interface, enum, or record expected
}
^
Main.java:38: error: class, interface, enum, or record expected
  printf("%d\n", closest_pair(A,N));
  ^
Main.java:39: error: class, interface, enum, or record expected
}
^
Main.java:43: error: class, interface, enum, or record expected
  for(int i = 0; i < N; i++) {
  ^
Main.java:43: error: class, interface, enum, or record expected
  for(int i = 0; i < N; i++) {
                 ^
Main.java:43: error: class, interface, enum, or record expected
  for(int i = 0; i < N; i++) {
                        ^
Main.java:45: error: class, interface, enum, or record expected
    cin >> x;
    ^
Main.java:46: error: class, interface, enum, or record expected
    cin >> y;
    ^
Main.java:47: error: class, interface, enum, or record expected
    A[i] = P(x,y);
    ^
Main.java:48: error: class, interface, enum, or record expected
  }
  ^
Main.java:51: error: class, interface, enum, or record expected
}
^
32 errors