Language: Java

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
const int SIZE = 1000000;

int a[20];
int chs[1<<16];
int n,sum;


int cal(int sta){
    int ret=0;
    for (int i=0;i<n;++i) 
        if (sta&(1<<i)) ret+=a[i];
    return ret;
}

int pp[10];
int flag[1<<16];

struct hash{
    vector<pair<int,int> > V[SIZE];
    int calhash(pair<int,int> a){
        unsigned int tmp= a.first;
        return (tmp*500009+a.second)%SIZE;
    }
    void init(){
        for (int i=0;i<SIZE;++i) V[i].clear();
    }
    void insert(pair<int,int> a){
        int t = calhash(a);
        for (int i=0;i<V[t].size();++i)
            if (V[t][i]==a) return;
        V[t].push_back(a);
    }
    bool find(pair<int,int> a){
        int t = calhash(a);
        for (int i=0;i<V[t].size();++i)
            if (V[t][i]==a) return true;
        return false;
    }
}S;
//set<pair<int,int> > S;

int main(){
    int _;
    scanf("%d",&_);
    while (_--){
        S.init();
        scanf("%d",&n);
        
        int lo=0;
        for (int i=0;i<n;++i){ 
            scanf("%d",&a[i]);
            lo+=a[i];
        }
        
        for (int sta=1;sta<(1<<n);++sta)
            chs[sta]=cal(sta);
        chs[0]=0;
        sum=0;
        int ans=0;
        int p1,p2,p3;
        for (int sta=1;sta<(1<<n);++sta){
            if (lo-chs[sta]<=chs[sta]) continue;
            
            int tsta=((1<<n)-1)^sta;
            int tchs=1<<(__builtin_ffs(tsta)-1);
            tsta^=tchs;
            
            int kk=0;
            for (int j=tsta;j>=0;j=(j-1)&tsta){
                if (!j) 
                    if (kk) break;
                    else kk=1;
                int chs2=j+tchs;
                sum++;
                pp[0]=chs[sta];
                pp[1]=chs[j+tchs];
                pp[2]=chs[((1<<n)-1)^sta^chs2];
                
                if (pp[1]>pp[0]) continue;
                if (pp[2]>pp[0]) continue;
                if (!pp[0] || !pp[1] || !pp[2]) continue;
                
                if (pp[1]>pp[2]) swap(pp[1],pp[2]);
                
                if (S.find(make_pair(pp[1],pp[2]))){
                    S.insert(make_pair(pp[1],pp[2]));
                    ++ans;
                }

            }
        }
        cout << ans << "\n";
//        cout << sum << endl;
    }
    return 0;
}
    

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 <string>
^
Main.java:4: error: illegal character: '#'
#include <string.h>
^
Main.java:5: error: illegal character: '#'
#include <algorithm>
^
Main.java:6: error: illegal character: '#'
#include <set>
^
Main.java:7: error: illegal character: '#'
#include <vector>
^
Main.java:9: error: class, interface, enum, or record expected
const int SIZE = 1000000;
^
Main.java:11: error: class, interface, enum, or record expected
int a[20];
^
Main.java:12: error: class, interface, enum, or record expected
int chs[1<<16];
^
Main.java:13: error: class, interface, enum, or record expected
int n,sum;
^
Main.java:16: error: unnamed classes are a preview feature and are disabled by default.
int cal(int sta){
^
  (use --enable-preview to enable unnamed classes)
Main.java:23: error: class, interface, enum, or record expected
int pp[10];
^
Main.java:24: error: class, interface, enum, or record expected
int flag[1<<16];
^
Main.java:26: error: class, interface, enum, or record expected
struct hash{
^
Main.java:29: error: not a statement
        unsigned int tmp= a.first;
        ^
Main.java:29: error: ';' expected
        unsigned int tmp= a.first;
                ^
Main.java:47: error: class, interface, enum, or record expected
}S;
^
Main.java:51: error: unnamed variables are a preview feature and are disabled by default.
    int _;
        ^
  (use --enable-preview to enable unnamed variables)
Main.java:52: error: as of release 9, '_' is a keyword, and may not be used as an identifier
    scanf("%d",&_);
                ^
Main.java:53: error: as of release 9, '_' is a keyword, and may not be used as an identifier
    while (_--){
           ^
Main.java:100: error: not a statement
        cout << ans << "\n";
                    ^
Main.java:51: error: = expected
    int _;
         ^
Main.java:52: error: illegal start of expression
    scanf("%d",&_);
               ^
Main.java:55: error: illegal start of expression
        scanf("%d",&n);
                   ^
Main.java:59: error: illegal start of expression
            scanf("%d",&a[i]);
                       ^
26 errors