Language: Java

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;
#define all(v) (v).begin(), (v).end()

#define MOD 1000000007
#define PI acos(-1)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int len = s.size();

    if(len == 0 || len == 1) {
        cout << 0 << endl;
        return 0;
    }

    int cnt0 = 0;
    int cnt1 = 0;

    for(int i = 0; i < len; i++){
        if(s[i] == '0'){
            cnt0++;
        }else{
            cnt1++;
        }
    }

    int num = abs(cnt0 - cnt1);

    cout << len - num << endl;

}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <cstdio>
^
Main.java:3: error: illegal character: '#'
#include <cstdlib>
^
Main.java:4: error: illegal character: '#'
#include <cmath>
^
Main.java:5: error: illegal character: '#'
#include <string>
^
Main.java:6: error: illegal character: '#'
#include <algorithm>
^
Main.java:7: error: illegal character: '#'
#include <vector>
^
Main.java:8: error: illegal character: '#'
#include <set>
^
Main.java:9: error: illegal character: '#'
#include <map>
^
Main.java:10: error: illegal character: '#'
#include <list>
^
Main.java:13: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:14: error: class, interface, enum, or record expected
typedef vector<int> vi;
^
Main.java:15: error: class, interface, enum, or record expected
typedef vector<ll> vll;
^
Main.java:17: error: illegal character: '#'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
^
Main.java:17: error: class, interface, enum, or record expected
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
        ^
Main.java:17: error: class, interface, enum, or record expected
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
                                  ^
Main.java:17: error: class, interface, enum, or record expected
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
                                                ^
Main.java:18: error: illegal character: '#'
#define p(x) cout << x << endl;
^
Main.java:19: error: illegal character: '#'
#define all(v) (v).begin(), (v).end()
^
Main.java:19: error: class, interface, enum, or record expected
#define all(v) (v).begin(), (v).end()
        ^
Main.java:21: error: illegal character: '#'
#define MOD 1000000007
^
Main.java:22: error: illegal character: '#'
#define PI acos(-1)
^
Main.java:26: error: class, interface, enum, or record expected
    ios::sync_with_stdio(false);
    ^
Main.java:28: error: unnamed classes are a preview feature and are disabled by default.
    string s;
    ^
  (use --enable-preview to enable unnamed classes)
Main.java:29: error: class, interface, enum, or record expected
    cin >> s;
    ^
Main.java:33: error: class, interface, enum, or record expected
    if(len == 0 || len == 1) {
    ^
Main.java:35: error: class, interface, enum, or record expected
        return 0;
        ^
Main.java:36: error: class, interface, enum, or record expected
    }
    ^
Main.java:41: error: class, interface, enum, or record expected
    for(int i = 0; i < len; i++){
    ^
Main.java:41: error: class, interface, enum, or record expected
    for(int i = 0; i < len; i++){
                   ^
Main.java:41: error: class, interface, enum, or record expected
    for(int i = 0; i < len; i++){
                            ^
Main.java:44: error: class, interface, enum, or record expected
        }else{
        ^
Main.java:46: error: class, interface, enum, or record expected
        }
        ^
Main.java:51: error: class, interface, enum, or record expected
    cout << len - num << endl;
    ^
Main.java:53: error: class, interface, enum, or record expected
}
^
35 errors