Language: Java

#include<stdio.h>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
LL gcd(LL a,LL b){if(b)while((a%=b)&&(b%=a));return a+b;}
struct XD{
    LL u,d;
    XD(){}
    XD(LL uu,LL dd):u(uu),d(dd){
        LL x=gcd(uu,dd);
        u/=x;d/=x;
        if(d<0){
            d=-d;
            u=-u;
        }
    }
    LL hash(){
        return u*333331+d;
    }
    bool operator<(const XD& b)const{
        return (double)u/d<(double)b.u/b.d;
    }
};
struct PT{
    LL x,y;
    int pos;
    PT(){}
    PT(LL xx,LL yy):x(xx),y(yy){}
    LL operator^(const PT& p)const{
        return x*p.y-y*p.x;
    }
    LL operator*(const PT& p)const{
        return x*p.x+y*p.y;
    }
    void calcPos(){
        pos=(y>0||(y==0&&x>0))?-1:1;
    }
    LL len2()const{return x*x+y*y;}
    bool operator<(const PT& p)const{
        if(pos!=p.pos)return pos<p.pos;
        LL s=(*this)^p;
        if(s==0)return len2()<p.len2();
        else return s>0;
    }
};
LL s[400000];
void lex_smallest_head(vector<LL>& in) {
    int n=in.size();
    for(int i=0;i<n;i++)
        s[i]=s[i+n]=in[i];
    int i=0,j=1,k=0;
    while(j<n&&k<n) {
        if(s[i+k]==s[j+k]) k++;
        else {
            if(s[i+k]<s[j+k]) j+=k+1;
            else i+=k+1;
            k=0;
        }
        if(i==j) j++;
    }
    for(j=0;j<n;j++)in[j]=s[i+j];
}
struct XDD{
    vector<PT> pi;
    int cp;
    LL hs;
    XDD(){
        int n;
        scanf("%d",&n);
        pi.resize(n);
        LL xs=0,ys=0;
        int i;
        for(i=0;i<n;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            pi[i].x=x*n;
            pi[i].y=y*n;
            xs+=x;ys+=y;
        }
        cp=0;
        for(i=0;i<n;i++){
            pi[i].x-=xs;pi[i].y-=ys;
            if(pi[i].x==0&&pi[i].y==0){
                cp++;
                swap(pi[i],pi[n-1]);
                n--;
                i--;
                pi.pop_back();
                continue;
            }
            pi[i].calcPos();
        }
        sort(pi.begin(),pi.end());
        LL mv=-1000000000000000LL;
        vector<XD> val(n);
        vector<bool> issame(n);
        for(i=0;i<n;i++){
            int j=(i==n-1?0:i+1);
            LL x=pi[i]^pi[j];
            if(x==0){
                issame[i]=1;
                val[i]=XD(pi[i].len2(),pi[j].len2());
            }else{
                issame[i]=0;
                val[i]=XD(pi[i]^pi[j],1);
                mv=max(mv,val[i].u);
            }
        }
        for(i=0;i<n;i++)if(!issame[i])val[i]=XD(val[i].u,mv);
        vector<LL> hash(n);
        for(i=0;i<n;i++)hash[i]=(issame[i]?1:0)+val[i].hash()*2;
        lex_smallest_head(hash);
        hs=0;
        for(i=0;i<n;i++)hs=hs*1097774749+hash[i];
    }
    pair<pair<int,int>,LL> hash(){
        return make_pair(make_pair(pi.size(),cp),hs);
    }
};
map<pair<pair<int,int>,LL>,vector<int> > in;
int main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        in[XDD().hash()].push_back(i+1);
    }
    printf("%d\n",in.size());
    for(map<pair<pair<int,int>,LL>,vector<int> >::iterator it=in.begin();it!=in.end();it++){
        for(i=0;i<(it->second).size();i++)printf("%d ",(it->second)[i]);puts("0");
    }
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include<stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<stdio.h>
        ^
Main.java:2: error: illegal character: '#'
#include<map>
^
Main.java:3: error: illegal character: '#'
#include<vector>
^
Main.java:4: error: illegal character: '#'
#include<algorithm>
^
Main.java:6: error: class, interface, enum, or record expected
typedef long long LL;
^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
LL gcd(LL a,LL b){if(b)while((a%=b)&&(b%=a));return a+b;}
^
  (use --enable-preview to enable unnamed classes)
Main.java:8: error: class, interface, enum, or record expected
struct XD{
^
Main.java:10: error: class, interface, enum, or record expected
    XD(){}
    ^
Main.java:13: error: class, interface, enum, or record expected
        u/=x;d/=x;
        ^
Main.java:13: error: class, interface, enum, or record expected
        u/=x;d/=x;
             ^
Main.java:14: error: class, interface, enum, or record expected
        if(d<0){
        ^
Main.java:16: error: class, interface, enum, or record expected
            u=-u;
            ^
Main.java:17: error: class, interface, enum, or record expected
        }
        ^
Main.java:21: error: class, interface, enum, or record expected
    }
    ^
Main.java:24: error: class, interface, enum, or record expected
    }
    ^
Main.java:26: error: class, interface, enum, or record expected
struct PT{
^
Main.java:29: error: class, interface, enum, or record expected
    PT(){}
    ^
Main.java:33: error: class, interface, enum, or record expected
    }
    ^
Main.java:36: error: class, interface, enum, or record expected
    }
    ^
Main.java:39: error: class, interface, enum, or record expected
    }
    ^
Main.java:40: error: class, interface, enum, or record expected
    LL len2()const{return x*x+y*y;}
                                  ^
Main.java:43: error: illegal start of expression
        LL s=(*this)^p;
              ^
Main.java:44: error: class, interface, enum, or record expected
        if(s==0)return len2()<p.len2();
        ^
Main.java:45: error: class, interface, enum, or record expected
        else return s>0;
        ^
Main.java:46: error: class, interface, enum, or record expected
    }
    ^
Main.java:48: error: class, interface, enum, or record expected
LL s[400000];
^
Main.java:49: error: <identifier> expected
void lex_smallest_head(vector<LL>& in) {
                                 ^
Main.java:65: error: class, interface, enum, or record expected
struct XDD{
^
Main.java:69: error: class, interface, enum, or record expected
    XDD(){
    ^
Main.java:71: error: class, interface, enum, or record expected
        scanf("%d",&n);
        ^
Main.java:72: error: class, interface, enum, or record expected
        pi.resize(n);
        ^
Main.java:75: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
        ^
Main.java:75: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
                ^
Main.java:75: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
                    ^
Main.java:77: error: class, interface, enum, or record expected
            scanf("%d%d",&x,&y);
            ^
Main.java:78: error: class, interface, enum, or record expected
            pi[i].x=x*n;
            ^
Main.java:79: error: class, interface, enum, or record expected
            pi[i].y=y*n;
            ^
Main.java:80: error: class, interface, enum, or record expected
            xs+=x;ys+=y;
            ^
Main.java:80: error: class, interface, enum, or record expected
            xs+=x;ys+=y;
                  ^
Main.java:81: error: class, interface, enum, or record expected
        }
        ^
Main.java:83: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
        ^
Main.java:83: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
                ^
Main.java:83: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
                    ^
Main.java:84: error: class, interface, enum, or record expected
            pi[i].x-=xs;pi[i].y-=ys;
                        ^
Main.java:85: error: class, interface, enum, or record expected
            if(pi[i].x==0&&pi[i].y==0){
            ^
Main.java:87: error: class, interface, enum, or record expected
                swap(pi[i],pi[n-1]);
                ^
Main.java:88: error: class, interface, enum, or record expected
                n--;
                ^
Main.java:89: error: class, interface, enum, or record expected
                i--;
                ^
Main.java:90: error: class, interface, enum, or record expected
                pi.pop_back();
                ^
Main.java:91: error: class, interface, enum, or record expected
                continue;
                ^
Main.java:92: error: class, interface, enum, or record expected
            }
            ^
Main.java:94: error: class, interface, enum, or record expected
        }
        ^
Main.java:96: error: ';' expected
        LL mv=-1000000000000000LL;
                                ^
Main.java:97: error: <identifier> expected
        vector<XD> val(n);
                        ^
Main.java:98: error: <identifier> expected
        vector<bool> issame(n);
                             ^
Main.java:99: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
        ^
Main.java:99: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
                ^
Main.java:99: error: class, interface, enum, or record expected
        for(i=0;i<n;i++){
                    ^
Main.java:102: error: class, interface, enum, or record expected
            if(x==0){
            ^
Main.java:104: error: class, interface, enum, or record expected
                val[i]=XD(pi[i].len2(),pi[j].len2());
                ^
Main.java:105: error: class, interface, enum, or record expected
            }else{
            ^
Main.java:107: error: class, interface, enum, or record expected
                val[i]=XD(pi[i]^pi[j],1);
                ^
Main.java:108: error: class, interface, enum, or record expected
                mv=max(mv,val[i].u);
                ^
Main.java:109: error: class, interface, enum, or record expected
            }
            ^
Main.java:111: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)if(!issame[i])val[i]=XD(val[i].u,mv);
                ^
Main.java:111: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)if(!issame[i])val[i]=XD(val[i].u,mv);
                    ^
Main.java:112: error: <identifier> expected
        vector<LL> hash(n);
                         ^
Main.java:113: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)hash[i]=(issame[i]?1:0)+val[i].hash()*2;
        ^
Main.java:113: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)hash[i]=(issame[i]?1:0)+val[i].hash()*2;
                ^
Main.java:113: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)hash[i]=(issame[i]?1:0)+val[i].hash()*2;
                    ^
Main.java:114: error: class, interface, enum, or record expected
        lex_smallest_head(hash);
        ^
Main.java:115: error: class, interface, enum, or record expected
        hs=0;
        ^
Main.java:116: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)hs=hs*1097774749+hash[i];
        ^
Main.java:116: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)hs=hs*1097774749+hash[i];
                ^
Main.java:116: error: class, interface, enum, or record expected
        for(i=0;i<n;i++)hs=hs*1097774749+hash[i];
                    ^
Main.java:117: error: class, interface, enum, or record expected
    }
    ^
Main.java:120: error: class, interface, enum, or record expected
    }
    ^
Main.java:130: error: not a statement
    for(map<pair<pair<int,int>,LL>,vector<int> >::iterator it=in.begin();it!=in.end();it++){
           ^
Main.java:130: error: not a statement
    for(map<pair<pair<int,int>,LL>,vector<int> >::iterator it=in.begin();it!=in.end();it++){
                                                                           ^
Main.java:125: error: illegal start of expression
    scanf("%d",&n);
               ^
Main.java:130: error: ';' expected
    for(map<pair<pair<int,int>,LL>,vector<int> >::iterator it=in.begin();it!=in.end();it++){
                                                ^
Main.java:130: error: ';' expected
    for(map<pair<pair<int,int>,LL>,vector<int> >::iterator it=in.begin();it!=in.end();it++){
                                                                                          ^
83 errors