criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    
    int n;
    cin >> n;

    vector<int> cnt(n+1, 0);
    for(int i = 0; i < n; ++i){
        int a; cin >> a;
        ++cnt[a];
    }

    int res = 0;
    for(int i = 1; i <= n; ++i){
        res += cnt[i]*(cnt[i]-1)/2;
    }

    for(int i = 0; i < n; ++i){
        cout << res-cnt[a[i]]+1 << '\n';
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:25: error: 'a' was not declared in this scope
   55 |         cout << res-cnt[a[i]]+1 << '\n';
      |                         ^
Language: C++

#include<iostream>
#include<stack>
#include<string>
#include<iomanip>
#include<vector>
#include<map>

using namespace std;

map<int, int> countSame(vector<int> input) {
    map<int, int> _map;
    for (auto it = input.begin(); it < input.end(); it++) {
        ++_map[*it];
    }
    return _map;
}

int main() {
    vector<int> input;
    int n=0, temp=0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        input.push_back(temp);
    }
    long long result = 0;
    auto _map = countSame(input);
    for (auto& elem : _map) {
        if (elem.second >= 2) {
            result += (long long(elem.second) * long long(elem.second-1)) / 2;
            //cout << elem.first << "," << elem.second << endl;
        }
    }
    for (auto& elem : input) {
        int temp = _map[elem];
        cout << result - temp + 1 << endl;
    }
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:24: error: expected primary-expression before 'long'
   30 |             result += (long long(elem.second) * long long(elem.second-1)) / 2;
      |                        ^~~~
a.cc:30:24: error: expected ')' before 'long'
   30 |             result += (long long(elem.second) * long long(elem.second-1)) / 2;
      |                       ~^~~~
      |                        )
Language: C++

import math
 
def permutations_count(n, r):
    return n*(n-1)/2
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    t = total
    if data[A[i]] - 1 > 0 :
        print( total-permutations_count(data[A[i]]-1,1) )
    else:
        print(total)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import math
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(200010);
  vector<int> vec2(200010);
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    vec.at(x-1)++;
    vec2.at(i)=x;
  }
  int64_t ans=0;
  for(int j=0; j<n; j++){
    ans += vec.at(j)*(vec.at(j)-1)/2;
  }
  for(int i=0; i<n; i++){
    int x=vec2.at(i);
    int y=vec.at(x-1);
    int64_t z=(y*(y-1)/2-(y-1)*(y-2)/2)

    cout << ans-z << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: expected ',' or ';' before 'cout'
   24 |     cout << ans-z << endl;
      |     ^~~~
Language: C++

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;

    int a[200000];
    int ai, a_num[200000] = {0};
    for(int i=0; i<n; i++) {
        cin >> ai;
        a_num[ai]++;
        a[i] = ai;
    }

    long long convs = 0;
    for(int i=0; i<n; i++) {
        convs += long long(a_num[i]) * (a_num[i] - 1) / 2;
    }

    for(int i=0; i<n; i++) {
        cout << convs - (a_num[a[i]] - 1) << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: expected primary-expression before 'long'
   19 |         convs += long long(a_num[i]) * (a_num[i] - 1) / 2;
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define sfi(a) scanf("%d",&a)
#define m_p make_pair
#define inf 1e9
#define ff first
#define ss second
#define pi(x) pair<x,x>
#define mem(x) memset(x,-1,sizeof(x))
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int sz = 200001;
const ll M = 1e9+7;

ll nCr(ll n,int r){
    ll ans = n * n-1;
    ans /= 2;
    return ans;
}

int main()
    int n;
    map<int,int> mp;
    map<ll,ll> save;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
        mp[arr[i]]++;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans = 0;
        auto it = save.find(arr[i]);
        if(it == save.end()){
            for(auto x:mp){
                int val = x.ss;
                if(x.ff==arr[i]) val--;
                ans += nCr(val,2);
            }
            save[arr[i]] = ans;
        }
        cout << save[arr[i]] << endl;
    }

    return 0;
}




Compiler output:
a.cc:29:5: error: expected initializer before 'int'
   29 |     int n;
      |     ^~~
a.cc:32:5: error: 'cin' does not name a type
   32 |     cin >> n;
      |     ^~~
a.cc:33:13: error: 'n' was not declared in this scope; did you mean 'yn'?
   33 |     int arr[n];
      |             ^
      |             yn
a.cc:34:5: error: expected unqualified-id before 'for'
   34 |     for(int i=0;i<n;i++){
      |     ^~~
a.cc:34:17: error: 'i' does not name a type; did you mean 'pi'?
   34 |     for(int i=0;i<n;i++){
      |                 ^
      |                 pi
a.cc:34:21: error: 'i' does not name a type; did you mean 'pi'?
   34 |     for(int i=0;i<n;i++){
      |                     ^
      |                     pi
a.cc:39:5: error: expected unqualified-id before 'for'
   39 |     for(int i=0;i<n;i++){
      |     ^~~
a.cc:39:17: error: 'i' does not name a type; did you mean 'pi'?
   39 |     for(int i=0;i<n;i++){
      |                 ^
      |                 pi
a.cc:39:21: error: 'i' does not name a type; did you mean 'pi'?
   39 |     for(int i=0;i<n;i++){
      |                     ^
      |                     pi
a.cc:53:5: error: expected unqualified-id before 'return'
   53 |     return 0;
      |     ^~~~~~
a.cc:54:1: error: expected declaration before '}' token
   54 | }
      | ^
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long kaijo(int input)
{
long x, ans;
ans = 1;
  for (x = input; x > 0; --x) {
    ans += x;
  }
  return ans;
}

int main(void)
{
long N, A[200000], ANS[200000], index, k, ans;
  
  scanf("%ld", &N);
  for (index = 0; index < N; ++index) {
    scanf("%ld", &A[index]);
  }
  for (k = 0; k < N; ++k) {
    memset(ANS, 0, sizeof(ANS));
    for (index = 0; index < N; ++index) {
      if (index != k) {
        ANS[A[index]]++;
      }
    }
    ans = (ANS[index])*(ANS[index]-1)/2
    //for (index = 0, ans = 0; index < N; ++index) {
    //  if (ANS[index] < 2) continue;
    //  ans += kaijo(ANS[index]-1);
    //}
    printf("%ld\n", ans);
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:40: error: expected ';' before 'printf'
   31 |     ans = (ANS[index])*(ANS[index]-1)/2
      |                                        ^
      |                                        ;
......
   36 |     printf("%ld\n", ans);
      |     ~~~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long kaijo(int input)
{
long x, ans;
ans = 1;
  for (x = input; x > 0; --x) {
    ans += x;
  }
  return ans;
}

int main(void)
{
long N, A[200000], ANS[200000], index, k, ans;
  
  scanf("%ld", &N);
  for (index = 0; index < N; ++index) {
    scanf("%ld", &A[index]);
  }
  for (k = 0; k < N; ++k) {
    memset(ANS, 0, sizeof(ANS));
    for (index = 0; index < N; ++index) {
      if (index != k) {
        ANS[A[index]]++;
      }
    }
    (ANS[index])*(ANS[index]-1)/2
    //for (index = 0, ans = 0; index < N; ++index) {
    //  if (ANS[index] < 2) continue;
    //  ans += kaijo(ANS[index]-1);
    //}
    printf("%ld\n", ans);
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:34: error: expected ';' before 'printf'
   31 |     (ANS[index])*(ANS[index]-1)/2
      |                                  ^
      |                                  ;
......
   36 |     printf("%ld\n", ans);
      |     ~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int A[n] = {0};
    int counter[n+1] = {0};
    for(int i = 0; i < n; i++){
        cin >> A[i];
        counter[A[i]] += 1;
    }
 
    long long int sum = 0;
    for(int i = 0; i < n; i++){
        if(counter[i] > 1){
            long long int x = counter[i];
            sum += x * (x-1) / 2;
        }
    }
 
    for(int i = 0; i < n; i++){
        long long int a = counter[A[i]];
        if(a >= 2){
            cout << sum - (a-1) << endl;
        }else{
            cout << sum << endl;
        }
    }
    return 0;
}
 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int A[n] = {0};
    int counter[n+1] = {0};
    for(int i = 0; i < n; i++){
        cin >> A[i];
        counter[A[i]] += 1;
    }

    long long int sum = 0;
    for(int i = 0; i < n; i++){
        if(counter[i] > 1){
            long long int x = counter[i];
            sum += x * (x-1) / 2;
        }
    }

    for(int i = 0; i < n; i++){
        long long int a = counter[A[i]];
        if(a > 1){
            cout << sum - (a-1) << endl;
        }else{
            cout << sum << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:36:5: error: redefinition of 'int main()'
   36 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int A[n] = {0};
    int counter[n+1] = {0};
    for(int i = 0; i < n; i++){
        cin >> A[i];
        counter[A[i]] += 1;
    }
 
    long long int sum = 0;
    for(int i = 0; i < n; i++){
        if(counter[i] > 1){
            long long int x = counter[i];
            sum += x * (x-1) / 2;
        }
    }
 
    for(int i = 0; i < n; i++){
        long long int a = counter[A[i]];
        if(a >= 2){
            cout << sum - (a-1) << endl;
        }else{
            cout << sum << endl;
        }
    }
    return 0;
}
 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int A[n] = {0};
    int counter[n+1] = {0};
    for(int i = 0; i < n; i++){
        cin >> A[i];
        counter[A[i]] += 1;
    }

    long long int sum = 0;
    for(int i = 0; i < n; i++){
        if(counter[i] > 1){
            long long int x = counter[i];
            sum += x * (x-1) / 2;
        }
    }

    for(int i = 0; i < n; i++){
        long long int a = counter[A[i]];
        if(a > 1){
            cout << sum - (a-1) << endl;
        }else{
            cout << sum << endl;
        }
    }
    return 0;
}
 

Compiler output:
a.cc:36:5: error: redefinition of 'int main()'
   36 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    int A[] =new long[N];
    long B[] =new long[N];
    long C[] =new long[N+1];
    long D[] =new long[N];
    long W[] =new long[N];
    C[0]=0;
    for(int i=0;i<N;i++){
      A[i]=sc.nextLong();
      B[A[i]-1]=B[A[i]-1]+1;}
    int X=0;
    for(int x=0;x<N;x++){
      if(!(B[x]==0)){X=X+1;}}
    for(int j=0;j<N;j++){
      if(!(D[A[j]-1]==0)){C[j+1]=C[j];continue;}
       D[A[j]-1]=B[A[j]-1]*(B[A[j]-1]-1)/2;
       C[j+1]=C[j]+D[A[j]-1];}
        for(int k=0;k<N;k++){
           W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
      System.out.println(W[k]);}
  }
}


Compiler output:
Main.java:6: error: incompatible types: long[] cannot be converted to int[]
    int A[] =new long[N];
             ^
Main.java:13: error: incompatible types: possible lossy conversion from long to int
      A[i]=sc.nextLong();
                      ^
2 errors
Language: Java

import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		long[] b=new int[n];
		long sum=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[a[i]-1]++;
		}
		for(int j=0;j<n;j++) {
			sum+=b[j]*(b[j]-1)/2;
		}
		for(int i=0;i<n;i++) {
			System.out.println(sum-(b[a[i]-1]-1));
		}
	}
}


Compiler output:
Main.java:8: error: incompatible types: int[] cannot be converted to long[]
		long[] b=new int[n];
		         ^
1 error
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    long A[] =new long[N];
    long B[] =new long[N];
    long C[] =new long[N+1];
    long D[] =new long[N];
    long W[] =new long[N];
    C[0]=0;
    for(int i=0;i<N;i++){
      A[i]=sc.nextLong();
      B[A[i]-1]=B[A[i]-1]+1;}
    int X=0;
    for(int x=0;x<N;x++){
      if(!(B[x]==0)){X=X+1;}}
    for(int j=0;j<N;j++){
      if(!(D[A[j]-1]==0)){C[j+1]=C[j];continue;}
       D[A[j]-1]=B[A[j]-1]*(B[A[j]-1]-1)/2;
       C[j+1]=C[j]+D[A[j]-1];}
        for(int k=0;k<N;k++){
           W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
      System.out.println(W[k]);}
  }
}


Compiler output:
Main.java:14: error: incompatible types: possible lossy conversion from long to int
      B[A[i]-1]=B[A[i]-1]+1;}
            ^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
      B[A[i]-1]=B[A[i]-1]+1;}
                      ^
Main.java:19: error: incompatible types: possible lossy conversion from long to int
      if(!(D[A[j]-1]==0)){C[j+1]=C[j];continue;}
                 ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
       D[A[j]-1]=B[A[j]-1]*(B[A[j]-1]-1)/2;
             ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
       D[A[j]-1]=B[A[j]-1]*(B[A[j]-1]-1)/2;
                       ^
Main.java:20: error: incompatible types: possible lossy conversion from long to int
       D[A[j]-1]=B[A[j]-1]*(B[A[j]-1]-1)/2;
                                  ^
Main.java:21: error: incompatible types: possible lossy conversion from long to int
       C[j+1]=C[j]+D[A[j]-1];}
                         ^
Main.java:23: error: incompatible types: possible lossy conversion from long to int
           W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
                           ^
Main.java:23: error: incompatible types: possible lossy conversion from long to int
           W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
                                      ^
Main.java:23: error: incompatible types: possible lossy conversion from long to int
           W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
                                                    ^
10 errors
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long kaijo(int input)
{
long x, ans;
ans = 1;
  for (x = input; x > 0; --x) {
    ans += x;
  }
  return ans;
}

int main(void)
{
long N, A[200000], ANS[200000], index, k, ans;
  
  scanf("%ld", &N);
  for (index = 0; index < N; ++index) {
    scanf("%ld", &A[index]);
  }
  for (k = 0; k < N; ++k) {
    memset(ANS, 0, sizeof(ANS));
    for (index = 0; index < N; ++index) {
      if (index != k) {
        ANS[A[index]]++;
      }
    }
    (ANS[index]-1)*(ANS[index]-2)/2
    //for (index = 0, ans = 0; index < N; ++index) {
    //  if (ANS[index] < 2) continue;
    //  ans += kaijo(ANS[index]-1);
    //}
    printf("%ld\n", ans);
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:36: error: expected ';' before 'printf'
   31 |     (ANS[index]-1)*(ANS[index]-2)/2
      |                                    ^
      |                                    ;
......
   36 |     printf("%ld\n", ans);
      |     ~~~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long kaijo(int input)
{
long x, ans;
ans = 1;
  for (x = input; x > 1; --x) {
    ans += x;
  }
  return ans;
}

int main(void)
{
long N, A[200000], ANS[200000], index, k, ans;
  
  scanf("%ld", &N);
  for (index = 0; index < N; ++index) {
    scanf("%ld", &A[index]);
  }
  for (k = 0; k < N; ++k) {
    memset(ANS, 0, sizeof(ANS));
    for (index = 0; index < N; ++index) {
      if (index != k) {
        ANS[A[index]]++;
      }
    }
    (ANS[index]-1)*(ANS[index]-2)/2
    //for (index = 0, ans = 0; index < N; ++index) {
    //  if (ANS[index] < 2) continue;
    //  ans += kaijo(ANS[index]-1);
    //}
    printf("%ld\n", ans);
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:36: error: expected ';' before 'printf'
   31 |     (ANS[index]-1)*(ANS[index]-2)/2
      |                                    ^
      |                                    ;
......
   36 |     printf("%ld\n", ans);
      |     ~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define int long long

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> x(n, 0);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
    x[a[i]]++;
  }
  int conv = 0;
  for(int i = 0; i < n; i++){
    if(x[i] >= 2){
      conv += x[i] * (x[i] - 1) / 2;
    }
  }
  int diff;
  for(int i = 0; i < n; i++){
    if(x[a[i]] < 2){
      cout << conv << endl;
    }
    else{
      diff = x[a[i]] - 1;
      cout << conv-diff << endl;
    }
  }
  
  return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <stdio.h>
#include <vector>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    vector<ll> count(200001, 0);
    for(int i=0; i<n; i++) count[a[i]]++;

    vector<ll> comb(200001, 0);
    for(int i=0; i<count.size(); i++) comb[i] = (count[i] * (count[i]-1)) / 2;
    ll sum = accumulate(comb.begin(), comb.end(), 0);

    for(int k=0; k<n; k++){
        ans = sum - count[a[k]] + 1;
        // ll ans = sum - comb[a[k]];
        // ans += ((count[a[k]] - 1) * (count[a[k]] - 2)) / 2;
        printf("%lld\n", ans);
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |         ans = sum - count[a[k]] + 1;
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  std::cin >> N;
  long long sum = 0;
  long lomg x =0;
  long long ans = 0;
  std::vector<int> A(N,0);
  std::vector<int> X(N,0);
  for (size_t i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    A[a-1]++;
    X[i] = a;
  }
  for (size_t i = 0; i < N; i++) {
    x = A.at(i);
    sum += x*(x-1)/2;
  }
  for (size_t i = 0; i < N; i++) {
     x = A[X[i]-1];
     if (x == 0) {
            ans = sum;
     }
     else{
       ans = sum -x+1;
     }
    std::cout <<ans << '\n';
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: expected initializer before 'x'
    7 |   long lomg x =0;
      |             ^
a.cc:18:5: error: 'x' was not declared in this scope
   18 |     x = A.at(i);
      |     ^
a.cc:22:6: error: 'x' was not declared in this scope
   22 |      x = A[X[i]-1];
      |      ^
Language: Java

import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int arr[] = new int[N];
		int list[] = new int[N+1];

		for (int i = 0; i < N ; i ++){
			arr[i] = scan.nextInt();
			list[arr[i]] += 1;
		}

		for(int k = 0; k < N ; k ++){
			int num = arr[k];
			int sum = 0;
			list[num] -= 1;
			for(int i = 0; i < N; i ++){
				if (list[i] > 1 ){
					for (intj = list[i]-1; j > 0; j-- ){
						sum += j ;
					}
				}	
			}
			System.out.println(sum);
			list[num] += 1;
		}
	}
}

Compiler output:
Main.java:21: error: cannot find symbol
					for (intj = list[i]-1; j > 0; j-- ){
					     ^
  symbol:   variable intj
  location: class Main
Main.java:21: error: cannot find symbol
					for (intj = list[i]-1; j > 0; j-- ){
					                       ^
  symbol:   variable j
  location: class Main
Main.java:21: error: cannot find symbol
					for (intj = list[i]-1; j > 0; j-- ){
					                              ^
  symbol:   variable j
  location: class Main
Main.java:22: error: cannot find symbol
						sum += j ;
						       ^
  symbol:   variable j
  location: class Main
4 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> vec;
    rep(i, n){
        int num;
        cin >> num;
        vec.push_back(num);
        mp[num]++;
    }
    ll sum;
    for(int i=1; i<=n; i++){
        sum += mp[i]*(mp[i]-1)/2;
    }
    rep(i, n){
        cout << sum-((ll)(mp[vec[i]])*((ll)(mp[vec[i]])-1)/2)+(((ll)(mp[vec[i]])-1)*((ll)(mp[vec[i]])-2)/2) << endl;
    }
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:19:5: error: 'll' was not declared in this scope; did you mean 'all'?
   19 |     ll sum;
      |     ^~
      |     all
a.cc:21:9: error: 'sum' was not declared in this scope
   21 |         sum += mp[i]*(mp[i]-1)/2;
      |         ^~~
a.cc:24:17: error: 'sum' was not declared in this scope
   24 |         cout << sum-((ll)(mp[vec[i]])*((ll)(mp[vec[i]])-1)/2)+(((ll)(mp[vec[i]])-1)*((ll)(mp[vec[i]])-2)/2) << endl;
      |                 ^~~
Language: C++

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
//vector<pair<int,int>>p;
using namespace std;
bool is[200001];
long long C[200001][3];
int n, m;
int a[200001], b[200001],c[200001];
int main()
{
    
    n = 200001;
    memset(C, 0, sizeof(C));
    for (int i = 0; i <= n; i++)
    {
        C[i][0] = 1;
        for (int j = 1; j <= 2; j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
    }
    
    cin >> m;
    int k = 1;
    for (int i = 1; i <=m; i++)
    {
        cin >> a[i];
        if (!is[a[i]])
        {
            is[a[i]] = 1;
            c[k++] = a[i];
        }
        b[a[i]]++;
    }
    for (int i = 1; i <= m; i++)
    {
        //cout << "!";
        long long ans = 0;
        for (int j = 1; j <= k; j++)
        {
            if (c[j] != a[i])
                ans += C[b[c[j]]][2];
            else ans += C[b[c[j]] - 1][2];
        }
        cout << ans << "\n";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'memset' was not declared in this scope
   15 |     memset(C, 0, sizeof(C));
      |     ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<vector>
  +++ |+#include <cstring>
    5 | //vector<pair<int,int>>p;
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
    long n;
    cin>>n;
    vector<long> vec1(n,0);
    for(long i=0;i<n;i++){
        cin>>vec1[i];
    }
    auto it=vec1.begin();
        
    for(long i=0;i<n;i++){
        
        set<long> v;
        for(auto x:vec2)
            v.insert(x);
        long sum=0;
        
        for(auto itr = v.begin(); itr != v.end(); itr++){
            long c = count(vec2.begin(),vec2.end(),*itr);
            if(*itr == *it)
                c--;
            sum+=(c*(c-1))/2;
        }
        
        cout<<sum<<endl;
        it++;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:20: error: 'vec2' was not declared in this scope; did you mean 'vec1'?
   16 |         for(auto x:vec2)
      |                    ^~~~
      |                    vec1
a.cc:21:28: error: 'vec2' was not declared in this scope; did you mean 'vec1'?
   21 |             long c = count(vec2.begin(),vec2.end(),*itr);
      |                            ^~~~
      |                            vec1
Language: C++

#include<cstdio>
inline int in();
typedef long long ll;
inline void wr(ll);
const int N=(int)2e5+5;
ll a[N],tong[N],sum[N];
int main(int argc,char**argv){
	register int n=in();
	for(register int i=1;i<=n;++i)
		a[i]=in();
	for(register int i=1;i<=n;++i)
		++tong[a[i]];
	for(register int i=1;i<=n;++i)
		sum[0]+=tong[i]*(tong[i]-1)/2;
	for(register int i=1;i<=n;++i)
		sum[i]=sum[0]-tong[i]*(tong[i]-1)/2;
	for(register int k=1;k<=n;++k){
		--tong[a[k]];
		wr(sum[i]+tong[a[k]]*(tong[a[k]]-1)/2),putchar('\n');
		++tong[a[k]];
	}
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:8:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    8 |         register int n=in();
      |                      ^
a.cc:9:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 |         for(register int i=1;i<=n;++i)
      |                          ^
a.cc:11:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         for(register int i=1;i<=n;++i)
      |                          ^
a.cc:13:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   13 |         for(register int i=1;i<=n;++i)
      |                          ^
a.cc:15:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 |         for(register int i=1;i<=n;++i)
      |                          ^
a.cc:17:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |         for(register int k=1;k<=n;++k){
      |                          ^
a.cc:19:24: error: 'i' was not declared in this scope
   19 |                 wr(sum[i]+tong[a[k]]*(tong[a[k]]-1)/2),putchar('\n');
      |                        ^
a.cc: In function 'int in()':
a.cc:24:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register char c=getchar();
      |                       ^
a.cc:25:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |         register int x=0,f=1;
      |                      ^
a.cc:25:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |         register int x=0,f=1;
      |                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef int long long;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> vec;
    rep(i, n){
        int num;
        cin >> num;
        vec.push_back(num);
        mp[num]++;
    }
    int sum;
    for(int i=1; i<=n; i++){
        sum += mp[i]*(mp[i]-1)/2;
    }
    rep(i, n){
        cout << sum-((mp[vec[i]])*((mp[vec[i]])-1)/2)+(((mp[vec[i]])-1)*((mp[vec[i]])-2)/2) << endl;
    }
    return 0;
}


Compiler output:
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | typedef int long long;
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n;
	cin >> n;
	vector<int> a(n);
	map<ll, ll> mp;
	for(int i=0; i<n; ++i){
		cin >> a[i];
		++mp[a[i]];
	}
	
	ll msum =0;
	for(auto m : mp){
		ll t=m.second;
		ll tmp = t(t-1)/2;
		if(t<2)tmp = 0;
		msum += tmp;
	}
	
	
	for(int i=0;i <n; ++i){
		ll t= mp[a[i]];
		ll tmp = t(t-1)/2;
		if(t<2)tmp = 0;
		--t;
		ll tmp2 = t(t-1)/2;
		if(t<2)tmp = 0;
		ll ans = msum - tmp + tmp2;
		cout << ans << endl;
	}
     return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:27: error: 't' cannot be used as a function
   17 |                 ll tmp = t(t-1)/2;
      |                          ~^~~~~
a.cc:25:27: error: 't' cannot be used as a function
   25 |                 ll tmp = t(t-1)/2;
      |                          ~^~~~~
a.cc:28:28: error: 't' cannot be used as a function
   28 |                 ll tmp2 = t(t-1)/2;
      |                           ~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef int long long;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> vec;
    rep(i, n){
        int num;
        cin >> num;
        vec.push_back(num);
        mp[num]++;
    }
    ll sum;
    for(int i=1; i<=n; i++){
        sum += mp[i]*(mp[i]-1)/2;
    }
    rep(i, n){
        cout << sum-((ll)(mp[vec[i]])*((ll)(mp[vec[i]])-1)/2)+(((ll)(mp[vec[i]])-1)*((ll)(mp[vec[i]])-2)/2) << endl;
    }
    return 0;
}

Compiler output:
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | typedef int long long;
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:19:5: error: 'll' was not declared in this scope; did you mean 'all'?
   19 |     ll sum;
      |     ^~
      |     all
a.cc:21:9: error: 'sum' was not declared in this scope
   21 |         sum += mp[i]*(mp[i]-1)/2;
      |         ^~~
a.cc:24:17: error: 'sum' was not declared in this scope
   24 |         cout << sum-((ll)(mp[vec[i]])*((ll)(mp[vec[i]])-1)/2)+(((ll)(mp[vec[i]])-1)*((ll)(mp[vec[i]])-2)/2) << endl;
      |                 ^~~
Language: Java

import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int N = fs.nextInt();
		String A[] = new String[N];
		String B[] = new String[N];
		int K[] = new int[N];
		for(int i=0; i<N; i++){
			A[i] = fs.next();
			B[i] = A[i];
		}

		for(int k=0; k<N; k++){
			for(int i=0; i<N; i++){
				if(k!=i&&B.equals(A[i])
			     K[k] +=1;
			}
		}

		for(int i=0; i<N; i++){
			System.out.println(K[i]);
		}
 
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
	
}


Compiler output:
Main.java:19: error: ')' expected
				if(k!=i&&B.equals(A[i])
				                       ^
1 error
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll A[200005], B[200005], C[200005];
int main(int argc, char *argv[])
{
	ll N;

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

	ll sum = 0;
	for (int i = 1; i <= N; i++) {
		if (B[i] != 0) {
			C[i] = B[i] * (B[i] - 1) / 2
			sum += C[i];
		}
	}

	for (int i = 1; i <= N; i++) {
		printf("%lld\n", sum - (B[A[i]] - 1));
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:22:53: error: expected ';' before 'sum'
   22 |                         C[i] = B[i] * (B[i] - 1) / 2
      |                                                     ^
      |                                                     ;
   23 |                         sum += C[i];
      |                         ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long int
int count(int arr[], int x, int n) 
{     
  int *low = lower_bound(arr, arr+n, x); 
  if (low == (arr + n) || *low != x) return 0; 
  int *high = upper_bound(low, arr+n, x);      
  return high - low; 
} 
int printNcR(int n, int r) 
{ 

	// p holds the value of n*(n-1)*(n-2)..., 
	// k holds the value of r*(r-1)... 
	long long p = 1, k = 1; 

	// C(n, r) == C(n, n-r), 
	// choosing the smaller value 
	if (n - r < r) 
		r = n - r; 

	if (r != 0) { 
		while (r) { 
			p *= n; 
			k *= r; 

			// gcd of p, k 
			long long m = __gcd(p, k); 

			// dividing by gcd, to simplify product 
			// division by their gcd saves from the overflow 
			p /= m; 
			k /= m; 

			n--; 
			r--; 
		} 

		// k should be simplified to 1 
		// as C(n, r) is a natural number 
		// (denominator should be 1 ) . 
	} 

	else
		p = 1; 

	// if our approach is correct p = ans and k =1 
	return p;
} 
main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>v;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    set<int>s;
    for(int i=0;i<n;i++)
    {
        s.insert(a[i]);
    }
    for(int i=0;i<n;i++)
    {
        v.push_back(make_pair(s[i],count(a,s[i],n)));
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<v.size();j++)
        {
            if(k==v[j].first)
            {
                cout<<printNcR(v[j].second-1, 2)<<endl;
            }
        }
    }

    return 0;
}


Compiler output:
a.cc:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:66:32: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'long long int')
   66 |         v.push_back(make_pair(s[i],count(a,s[i],n)));
      |                                ^
a.cc:66:45: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'long long int')
   66 |         v.push_back(make_pair(s[i],count(a,s[i],n)));
      |                                             ^
a.cc:72:16: error: 'k' was not declared in this scope
   72 |             if(k==v[j].first)
      |                ^
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    int A[] =new int[N];
    int B[] =new int[N];
    int C[] =new int[N+1];
    int D[] =new int[N];
    long W[] =new long[N];
    C[0]=0;
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      B[A[i]-1]=B[A[i]-1]+1;}
    int X=0;
    for(int x=0;x<N;x++){
      if(!(B[x]==0)){X=X+1;}}
    for(int j=0;j<N;j++){
      if(!(D[A[j]-1]==0)){C[j+1]=C[j];continue;}
       D[A[j]-1]=B[A[j]-1]*(B[A[j]-1]-1)/2;
       C[j+1]=C[j]+D[A[j]-1];}
        for(int k=0;k<N;k++){
          long W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
      System.out.println(W[k]);}
  }
}


Compiler output:
Main.java:23: error: ']' expected
          long W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
                 ^
Main.java:23: error: ';' expected
          long W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
                  ^
Main.java:23: error: not a statement
          long W[k]=C[N]-D[A[k]-1]+(B[A[k]-1]-1)*(B[A[k]-1]-2)/2;
                                  ^
3 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
long dpp[max][max];

long nCr(int n, int r)
{
       if(n==r) return dpp[n][r] = 1;
       if(r==0) return dpp[n][r] = 1;
       if(r==1) return dpp[n][r] = n;
       if(dpp[n][r]) return dpp[n][r];
       return dpp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

void solve(){
    //COMinit();
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    map<int, int> mp;
    REP(i, N) mp[A[i]]++;

    ll dp[200000] = {0};
    REP(k,N){
        int index = mp[A[k]];
        if(dp[index]==0){
            mp[A[k]]--;
            ll res = 0;
            for(auto it=mp.begin(); it!=mp.end(); it++){
                int tmp = it->second;
                res += nCr(tmp, 2);
                //cout << res << endl;
            }
            dp[index] = res;
            mp[A[k]]++;
        }
        cout << dp[index] << endl;
    }
}

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

Compiler output:
a.cc:6:18: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
    6 | long dpp[max][max];
      |                  ^
a.cc:6:6: error: size of array 'dpp' has non-integral type '<unresolved overloaded function type>'
    6 | long dpp[max][max];
      |      ^~~
a.cc:6:18: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
    6 | long dpp[max][max];
      |                  ^
a.cc:6:6: error: size of array 'dpp' has non-integral type '<unresolved overloaded function type>'
    6 | long dpp[max][max];
      |      ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long int
int count(int arr[], int x, int n) 
{     
  int *low = lower_bound(arr, arr+n, x); 
  if (low == (arr + n) || *low != x) return 0; 
  int *high = upper_bound(low, arr+n, x);      
  return high - low; 
} 
int printNcR(int n, int r) 
{ 

	// p holds the value of n*(n-1)*(n-2)..., 
	// k holds the value of r*(r-1)... 
	long long p = 1, k = 1; 

	// C(n, r) == C(n, n-r), 
	// choosing the smaller value 
	if (n - r < r) 
		r = n - r; 

	if (r != 0) { 
		while (r) { 
			p *= n; 
			k *= r; 

			// gcd of p, k 
			long long m = __gcd(p, k); 

			// dividing by gcd, to simplify product 
			// division by their gcd saves from the overflow 
			p /= m; 
			k /= m; 

			n--; 
			r--; 
		} 

		// k should be simplified to 1 
		// as C(n, r) is a natural number 
		// (denominator should be 1 ) . 
	} 

	else
		p = 1; 

	// if our approach is correct p = ans and k =1 
	return p;
} 
main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>v;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    set<int>s;
    for(int i=0;i<n;i++)
    {
        s.insert(a[i]);
    }
    for(int i=0;i<n;i++)
    {
        v.push_back(make_pair(s[i],count(a,s[i],n)));
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<v.size();j++)
        {
            if(k==v[j].first)
            {
                cout<<printNcR(int v[j].second int r);
            }
        }
    }

    return 0;
}


Compiler output:
a.cc:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:66:32: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'long long int')
   66 |         v.push_back(make_pair(s[i],count(a,s[i],n)));
      |                                ^
a.cc:66:45: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'long long int')
   66 |         v.push_back(make_pair(s[i],count(a,s[i],n)));
      |                                             ^
a.cc:72:16: error: 'k' was not declared in this scope
   72 |             if(k==v[j].first)
      |                ^
a.cc:3:13: error: expected primary-expression before 'long'
    3 | #define int long long int
      |             ^~~~
a.cc:74:32: note: in expansion of macro 'int'
   74 |                 cout<<printNcR(int v[j].second int r);
      |                                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  std::cin >> N;
  int sum = 0;
  int x =0;
  int ans = 0;
  std::vector<int> A(N,0);
  std::vector<int> X(N,0);
  for (size_t i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    A[a-1]++;
    X[i] = a;
  }
  for (size_t i = 0; i < N; i++) {
    x = A.at(i);
    sum += x*(x-1)/2;
  }
  for (size_t i = 0; i < N; i++) {
     x = A[X[i]-1];
     if (x == 1) {
            ans = sum;
     }
     else{
       ans = sum -x+1;}
    std::cout <<ans << '\n';
  }
}
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  std::cin >> N;
  int sum = 0;
  int x =0;
  int ans = 0;
  std::vector<int> A(N,0);
  std::vector<int> X(N,0);
  for (size_t i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    A[a-1]++;
    X[i] = a;
  }
  for (size_t i = 0; i < N; i++) {
    x = A.at(i);
    sum += x*(x-1)/2;
  }
  for (size_t i = 0; i < N; i++) {
     x = A[X[i]-1];
     if (x == 1) {
            ans = sum;
     }
     else{
       ans = sum -x+1;}
    std::cout <<ans << '\n';
  }
}


Compiler output:
a.cc:33:5: error: redefinition of 'int main()'
   33 | int main() {
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main() {
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,x,y,z,sum;
  map<int,int> mp;
  cin>>N;
  vector<int> A(N,0);
  rep(i,N){cin>>x;mp[x]++;A.at(i)=x;}
  rep(i,mp.size())
  {
    for(auto p:mp)
    {
      auto key=p.first;auto value=p.second;
      sum+=value*(value-1)/2;
    }
  }
  rep(i,N){x=A.at(i);y=mp.at(x);cout<<(sum-y-(y-1)*(y-2))/2<<endl;}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   rep(i,N){cin>>x;mp[x]++;A.at(i)=x;}
      |       ^
a.cc:9:3: error: 'rep' was not declared in this scope
    9 |   rep(i,N){cin>>x;mp[x]++;A.at(i)=x;}
      |   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N,s=0;
  cin >> N;
  vector<int> kosu(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(j!=i){
        int j;
        cin >> j;
        kosu.at(j-1)++;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:2: error: expected '}' at end of input
   14 | }
      |  ^
a.cc:9:25: note: to match this '{'
    9 |     for(int j=0;j<N;j++){
      |                         ^
a.cc:14:2: error: expected '}' at end of input
   14 | }
      |  ^
a.cc:8:23: note: to match this '{'
    8 |   for(int i=0;i<N;i++){
      |                       ^
a.cc:14:2: error: expected '}' at end of input
   14 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
long dpp[max][max];

long nCr(int n, int r)
{
       if(n==r) return dpp[n][r] = 1;
       if(r==0) return dpp[n][r] = 1;
       if(r==1) return dpp[n][r] = n;
       if(dp[n][r]) return dpp[n][r];
       return dpp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}

void solve(){
    //COMinit();
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    map<int, int> mp;
    REP(i, N) mp[A[i]]++;

    ll dp[200000] = {0};
    REP(k,N){
        int index = mp[A[k]];
        if(dp[index]==0){
            mp[A[k]]--;
            ll res = 0;
            for(auto it=mp.begin(); it!=mp.end(); it++){
                int tmp = it->second;
                res += nCr(tmp, 2);
                //cout << res << endl;
            }
            dp[index] = res;
            mp[A[k]]++;
        }
        cout << dp[index] << endl;
    }
}

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

Compiler output:
a.cc:6:18: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
    6 | long dpp[max][max];
      |                  ^
a.cc:6:6: error: size of array 'dpp' has non-integral type '<unresolved overloaded function type>'
    6 | long dpp[max][max];
      |      ^~~
a.cc:6:18: error: cannot resolve overloaded function 'max' based on conversion to type 'long unsigned int'
    6 | long dpp[max][max];
      |                  ^
a.cc:6:6: error: size of array 'dpp' has non-integral type '<unresolved overloaded function type>'
    6 | long dpp[max][max];
      |      ^~~
a.cc: In function 'long int nCr(int, int)':
a.cc:13:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |        if(dp[n][r]) return dpp[n][r];
      |           ^~
      |           dup
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int mysearch( std::vector<int> vec, int N);

int main()
{
  int N;
  cin >> N;

  std::vector<int> A;
  int tmp;
  for(int i=0;i<N;i++)
  {
    cin >>tmp;
	A.push_back(tmp);
  }


  std::vector<int> B=A;
  std::sort(B.begin(), B.end());
  int num;
  int dec[N];
  for(int i=0;i<N;i++)
  {
    num=0;
    for(int j=0;j<N;j++)
    {
  	  if(A[i]==B[j])
      {
        num = num+1;
      }
    }
    dec[i]=num;
  }
  int full = mysearch(A,N);
  
  for(int i=0;i<N;i++)
  {
    cout << full - dec[i] +1 <<endl;
  }    
  
 return 0;
}

int mysearch( std::vector<int> vec, int N)
{
  std::sort(vec.begin(), vec.end());
  std::vector<int> vec2 = vec;
  vec2.erase(std::unique(vec2.begin(), vec2.end()), vec2.end());  
  
  int sum=0;
  int comb=0;  
  for(int i=0; i<vec2.size();i++)
  {
    sum = std::count(vec.begin(), vec.end(), vec2[i]); 
    comb=sum*(sum+1)*0.5+comb;
    }
  }
  
return comb;
}


Compiler output:
a.cc: In function 'int mysearch(std::vector<int>, int)':
a.cc:61:3: warning: no return statement in function returning non-void [-Wreturn-type]
   61 |   }
      |   ^
a.cc: At global scope:
a.cc:63:1: error: expected unqualified-id before 'return'
   63 | return comb;
      | ^~~~~~
a.cc:64:1: error: expected declaration before '}' token
   64 | }
      | ^