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

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

int main() {
    queue<int> q;
    map<int,int> m;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]==1]) q.push(a[i]);
    }
    rep(i,n){
        int sum = 0;
        m[a[i]]--;
        rep(i,q.size()){
            sum += (m[q[i]]-1)*m[q[i]]/2;
        }
        m[a[i]]++;
        cout << sum << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:24: error: no match for 'operator[]' (operand types are 'std::queue<int>' and 'int')
   24 |             sum += (m[q[i]]-1)*m[q[i]]/2;
      |                        ^
a.cc:24:35: error: no match for 'operator[]' (operand types are 'std::queue<int>' and 'int')
   24 |             sum += (m[q[i]]-1)*m[q[i]]/2;
      |                                   ^
Language: C++


#include"bits/stdc++.h"

#define MOD 1000000007
#define rep(i, N) for(int i = 0;i < N;i++)
#define ll long long
#define int long long

using namespace std;

class Factorial {
public:
	vector<int> memo;
	Factorial(int N) {
		memo = vector<int>(N, -1);
		memo[0] = 1;
		memo[1] = 1;
	}
	int fact(int n) {
		if (memo[n] == -1) return n * fact(n - 1);
		else return memo[n];
	}
	int comb(int n, int r) {
		return fact(n) / (fact(n - r) * fact(r));
	}
};

signed main(void) {
	int N; cin >> N;
	Factorial F(N+1);
	vector<int> A(N), count(N+1, 0), ans(N+1, 0);
	int TotalComb;
	rep(i, N) {
		cin >> A[i];
		count[A[i]]++;
	}

	TotalComb = 0;
	for (int i = 0; i <= N; i++)if(count[i] >= 2) {
		TotalComb += F.comb(count[i], 2);
	}

	for (int i = 0; i < N; i++) {
		ans[A[i]] = max(0, TotalComb - (count[A[i]] - 1));
	}

	for (int i = 0; i < N; i++) {
		cout << ans[A[i]] << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:32: error: no matching function for call to 'max(int, long long int)'
   44 |                 ans[A[i]] = max(0, TotalComb - (count[A[i]] - 1));
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:44:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   44 |                 ans[A[i]] = max(0, TotalComb - (count[A[i]] - 1));
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:44:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   44 |                 ans[A[i]] = max(0, TotalComb - (count[A[i]] - 1));
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
 int n; cin >> n;
 vector<int> a(200000,0);
 vector<int> ent(n);
 rep(i,n){
   cin >> ent[i];   int m=ent[i];
   m--;
   a[m]++;
 }
  long long sum=0;
 rep(i,200000){
   int l=a[i]; sum+=(l*(l-1))/2;
 }
 rep(i,n){
   if(a[ent[i]-1]==0)cout << sum << endl;
   else{
     long long b=a[ent[i]-1]-1;
     cout << sum-b << endl;
   }
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:24:3: error: expected '}' at end of input
   24 |  }
      |   ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
using namespace std;
const double PI = 3.14159265358979323846;


int main() {
    int N;
    cin >> N;
    vector<long long int> balls;
    map<long long int, long long int> sameBalls;
    map<long long int, long long int> memo;
    for (int i = 0; i < N; i++) {
        int A;
        scanf_s("%d", &A);
        balls.push_back(A);
        sameBalls[A]++;
        memo[A] = 0;
    }

    for (int k = 0; k < N; k++) {
        sameBalls[balls[k]]--;
        memo[balls[k]] = 0;

        long long int totalCount = 0;
        for (auto itr = sameBalls.begin(); itr != sameBalls.end(); itr++) {
            if (itr->second >= 2 && memo[itr->first] == 0) {
                long long int calc = itr->second * (itr->second - 1) / 2;
                totalCount += calc;
                memo[itr->first] = calc;
            }
            else if (memo[itr->first] != 0) {
                totalCount += memo[itr->first];
            }
        }
        cout << totalCount << endl;

        memo[balls[k]] = 0;
        sameBalls[balls[k]]++;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   26 |         scanf_s("%d", &A);
      |         ^~~~~~~
      |         scanf
Language: C++

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

int N;

void solve() {
    map<long long, long long> ma;
    for (int i = 0; i < N; ++i) ma[a[i]]++;
    long long res = 0;
    for (auto it : ma) res += it.second * (it.second - 1) / 2;
    for (int i = 0; i < N; ++i) {
        vector<long long> a;
        long long val = ma[a[i]];
        long long before = val * (val - 1) / 2;
        long long after = (val - 1) * (val - 2) / 2;
        cout << res + after - before << endl;
    }
}

int main() {
    cin >> N;
    a.resize(N);//要素数変更
    for (int i = 0; i < N; ++i) cin >> a[i];
    solve();
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:8:36: error: 'a' was not declared in this scope
    8 |     for (int i = 0; i < N; ++i) ma[a[i]]++;
      |                                    ^
a.cc: In function 'int main()':
a.cc:22:5: error: 'a' was not declared in this scope
   22 |     a.resize(N);//要素数変更
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
using ll = long long;

ll choose2(ll n)
{
    return n*(n-1)/2;
}


in main()
{
   int n; cin>>n;
   vector<int>a(n);
   rep(i,n)cin>>a[i];
   rep(i,n)a[i]--;
   vector<int>cnt(n);
   rep(i,n)cnt[a[i]]++;
  
   ll tot=0;
   rep(i,n)tot+=choose2(cnt[i]);

   rep(i,n)
   {
       int ans = tot;
       ans-=choose2(cnt[a[i]]);
       ans+=choose2(cnt[a[i]]-1);
   
       cout<<ans<<endl;
   
   }
  
    return 0;
  
}

Compiler output:
a.cc:12:1: error: 'in' does not name a type; did you mean 'int'?
   12 | in main()
      | ^~
      | int
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;
const double PI=3.14159265358979323846;

ll nc2(ll x){
  return x*(x-1)/2;
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n), d(n);
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  rep(i,n){
    d[a[i]]++;
  }
  ll sum=0;
  rep(i,n){
    sum += nc2(d[i]);
  }
  rep(i,n){
    ll ans = sum;
    ans -= nc2(d[i]);
    ans += nc2(d[i]-1);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int nc2(ll x){
  return n(n-1)/2;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),d(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,n)
    d[a[i]]++;
  ll ans=0;
  rep(i,n)
    ans+=nc2(d[i]);
  rep(i,n){
    ans-=nc2(d[a[i]]);
    ans+=nc2(d[a[i]-1]);
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc: In function 'int nc2(ll)':
a.cc:19:12: error: 'n' was not declared in this scope
   19 |   return n(n-1)/2;
      |            ^
a.cc:19:10: error: 'n' was not declared in this scope
   19 |   return n(n-1)/2;
      |          ^
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   20 | int main()      {
      |         ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
   20 | int main()      {
      |         ^~
      |         --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:17: error: a function-definition is not allowed here before '{' token
   20 | int main()      {
      |                 ^
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:18:14: note: to match this '{'
   18 | int nc2(ll x){
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int nc2(ll x){
  return n(n-1)/2;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),d(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,n)
    d[a[i]]++;
  rep(i,n)
  

Compiler output:
a.cc: In function 'int nc2(ll)':
a.cc:19:12: error: 'n' was not declared in this scope
   19 |   return n(n-1)/2;
      |            ^
a.cc:19:10: error: 'n' was not declared in this scope
   19 |   return n(n-1)/2;
      |          ^
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   20 | int main()      {
      |         ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
   20 | int main()      {
      |         ^~
      |         --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:17: error: a function-definition is not allowed here before '{' token
   20 | int main()      {
      |                 ^
a.cc:3:44: error: expected '}' at end of input
    3 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
      |                                            ^
a.cc:30:3: note: in expansion of macro 'rep'
   30 |   rep(i,n)
      |   ^~~
a.cc:18:14: note: to match this '{'
   18 | int nc2(ll x){
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int nc2(ll x){
  return x(x-1)/2;
}
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  rep(i,n) {
    cin>>a[i];
    a[i]--;
  }
  ll sum=0;
  rep(i,n){
    d[a[i]]++;
  }
  rep(i,n){
    sum+=nc2(d[i]);
  }
  rep(i,n){
    ll ans=sum;
    ans-=nc2(d[a[i]]);
    ans+=nc2(d[a[i]-1]);
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc: In function 'int nc2(ll)':
a.cc:19:11: error: 'x' cannot be used as a function
   19 |   return x(x-1)/2;
      |          ~^~~~~
a.cc: In function 'int main()':
a.cc:31:5: error: 'd' was not declared in this scope
   31 |     d[a[i]]++;
      |     ^
a.cc:34:14: error: 'd' was not declared in this scope
   34 |     sum+=nc2(d[i]);
      |              ^
a.cc:38:14: error: 'd' was not declared in this scope
   38 |     ans-=nc2(d[a[i]]);
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int nc2(ll x){
  return x(x-1)/2;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n),b(n);
  rep(i,n) {
    cin>>a[i];
    a[i]--;
  }
  ll sum=0;
  rep(i,n){
    d[a[i]]++;
  }
  rep(i,n){
    sum+=nc2(d[i]);
  }
  rep(i,n){
    ll ans=sum;
    ans-=nc2(d[a[i]]);
    ans+=nc2(d[a[i]-1]);
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc: In function 'int nc2(ll)':
a.cc:19:11: error: 'x' cannot be used as a function
   19 |   return x(x-1)/2;
      |          ~^~~~~
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   20 | int main()      {
      |         ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
   20 | int main()      {
      |         ^~
      |         --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:17: error: a function-definition is not allowed here before '{' token
   20 | int main()      {
      |                 ^
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:18:14: note: to match this '{'
   18 | int nc2(ll x){
      |              ^
Language: C++

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

int main() {
  int N;
  ll A[200010] = {0};
  ll B[200010];
  
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    A[B[i]]++;
  }
  
  ll sum = 0;

  // N個のときの総数
  for (int i = 0; i < N; i++) {
      sum += (A[i]-1) * (A[i] - 2) / 2;
  }
    ans += A[i] * (A[i]-1) / 2;
  
  // for文でそれぞれi個目のボールがなかったときに引くべき数
  for (int i = 0; i < N; i++) {
    sum -= A[B[i]] -1;
    cout << sum << endl;
    sum += A[B[i]] -1;
  }
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |     ans += A[i] * (A[i]-1) / 2;
      |     ^~~
      |     abs
a.cc:21:14: error: 'i' was not declared in this scope
   21 |     ans += A[i] * (A[i]-1) / 2;
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;
int R,G,B,N;
int ans = 0;


int main(){
    int N;cin >>N;
    map<long long , long lon > m{};
    vector<long long > A(N);
    long long ans = 0;
    for(int i=0;i<N;i++) {cin >> A[i]; A[i]--; m[A[i]]++;}
    for(auto j=m.begin(); j!=m.end();j++){
        int n = j->second;
        ans += n*(n-1)/2;
    }

    for(int i=0; i<N;i++){
        cout << ans - m[A[i]] + 1 << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:30: error: template argument 2 is invalid
   14 |     map<long long , long lon > m{};
      |                              ^
a.cc:14:30: error: template argument 4 is invalid
a.cc:17:49: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   17 |     for(int i=0;i<N;i++) {cin >> A[i]; A[i]--; m[A[i]]++;}
      |                                                 ^
a.cc:18:18: error: request for member 'begin' in 'm', which is of non-class type 'int'
   18 |     for(auto j=m.begin(); j!=m.end();j++){
      |                  ^~~~~
a.cc:18:32: error: request for member 'end' in 'm', which is of non-class type 'int'
   18 |     for(auto j=m.begin(); j!=m.end();j++){
      |                                ^~~
a.cc:24:24: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   24 |         cout << ans - m[A[i]] + 1 << endl;
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;
int R,G,B,N;
int ans = 0;


int main(){
    int N;cin >>N;
    map<long long , long lon > m{};
    vector<long long > A(N);
    long long ans = 0;
    for(int i=0;i<N;i++) {cin >> A[i]; m[A[i]]++;}
    for(auto j=m.begin(); j!=m.end();j++){
        int n = j->second;
        ans += n*(n-1)/2;
    }

    for(int i=0; i<N;i++){
        cout << ans - m[A[i]] + 1 << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:30: error: template argument 2 is invalid
   14 |     map<long long , long lon > m{};
      |                              ^
a.cc:14:30: error: template argument 4 is invalid
a.cc:17:41: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   17 |     for(int i=0;i<N;i++) {cin >> A[i]; m[A[i]]++;}
      |                                         ^
a.cc:18:18: error: request for member 'begin' in 'm', which is of non-class type 'int'
   18 |     for(auto j=m.begin(); j!=m.end();j++){
      |                  ^~~~~
a.cc:18:32: error: request for member 'end' in 'm', which is of non-class type 'int'
   18 |     for(auto j=m.begin(); j!=m.end();j++){
      |                                ^~~
a.cc:24:24: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   24 |         cout << ans - m[A[i]] + 1 << endl;
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;


int main(){
    ios::sync_with_stdio(0);
	cin.tie(NULL);
    int n; cin>>n;
    map <int,int> m;
    vector <Long> v;
    Rep(i,0,n){
        Long a; cin>>a;
        m[a]++;
        v.pb(a);
    }
    Long resp=0;
    for(auto x: m){
        resp+=x.second*(x.second-1)/2;
    }
    Rep(i,0,n){
        cout<<resp-(m[v[i]]-1)<<'\n';
    }
    return 0;


Compiler output:
a.cc:3:30: error: extended character “ is not valid in an identifier
    3 | #define DBG(x) cerr << #x << “ = ” << (x) << endl
      |                              ^
a.cc:3:34: error: extended character ” is not valid in an identifier
    3 | #define DBG(x) cerr << #x << “ = ” << (x) << endl
      |                                  ^
a.cc: In function 'int main()':
a.cc:29:14: error: expected '}' at end of input
   29 |     return 0;
      |              ^
a.cc:11:11: note: to match this '{'
   11 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n; cin>>n;
    vector<int> num(n);
    vector<int> list(n);
    vector<ll> sum(n);
    set<int> lis;

    for (int i = 0; i < n; i++)
    {
      cin >> list[i];
      lis.insert(list[i]);
      num[list[i]-1]++;
    }

    for (int i = 0; i < lis.size(); i++)
    {
      num[lis[i-1]-1]--;
      for (int j = 0; j < n; j++){
        sum[j] += num[j]*(num[j]-1)/2;
      }
      num[lis[i-1]]++;
    }
    
    
    for (int i = 0; i < n; i++)
    {
      cout << sum[list[i]] << endl;
    }
    
    return 0;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:14: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'int')
   28 |       num[lis[i-1]-1]--;
      |              ^
a.cc:32:14: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'int')
   32 |       num[lis[i-1]]++;
      |              ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n; cin>>n;
    vector<int> num(N);
    vector<int> list(N);
    ll sum = 0;

    for (int i = 0; i < n; i++)
    {
      cin >> list[i];
      num[list[i]-1]++;
    }

    for (int i = 0; i < n; i++)
    {
      num[list[i]-1]--;
      for (int j = 0; j < n; j++)
      {
        sum += num[j]*(num[j]-1)/2;
      }
      cout << sum << endl;
      num[list[i]-1]++;
    }
    return 0;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: 'N' was not declared in this scope
   14 |     vector<int> num(N);
      |                     ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n; cin>>n;
    vector<int> num(N);
    vector<int> list(N);
    ll sum = 0;

    for (int i = 0; i < n; i++)
    {
      cin >> list[i];
      num[list[i]-1]++;
    }

    for (int i = 0; i < n; i++)
    {
      num[list[i]-1]--;
      for (int j = 0; j < n; j++)
      {
        sum += num[j]*(num[j]-1)/2
      }
      cout << sum << endl;
      num[list[i]-1]++;
    }
    return 0;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: 'N' was not declared in this scope
   14 |     vector<int> num(N);
      |                     ^
a.cc:29:35: error: expected ';' before '}' token
   29 |         sum += num[j]*(num[j]-1)/2
      |                                   ^
      |                                   ;
   30 |       }
      |       ~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>
//#include <stack>
//#include <tuple>

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> count(N, 0);
    for (int i=0; i<N; i++){
        cin >> A[i];
        A[i]--;
        count[A[i]]++;
    }
    vector<long long> comb(N, 0);
    vector<long long> subcomb(N, 0);
    for (int i=0; i<N; i++){
        int n = count[i];
        if (n == 0) continue;
        comb[i] = n*(n-1)/2;
        subcomb[i] = (n-1)*(n-2)/2;
    }
    long long total = accumulate(comb.begin(), comb.end(), 0);
    vector<long long> table(N, 0);
    for (int i=0; i<N; i++){
        table[i] = total - comb[i] + subcomb[i];
    }
    for (int i=0; i<N; i++){
        cout << table[A[i]] << "\n";
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:29:23: error: 'accumulate' was not declared in this scope
   29 |     long long total = accumulate(comb.begin(), comb.end(), 0);
      |                       ^~~~~~~~~~
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 buf = 0;
		for(int i = 0;i < N;i++){
			A[i] = sc.nextInt();
			B[i] = A[i];
		}
		Arrays.sort(A);
		int count = 1;
		int[] num = new int[N];
		num[A[0]] = 1;
		for(int i = 1;i < N;i++){
			if(A[i - 1] == A[i]){
				count++;
				if(i == N-1){
					num[A[i]] = count;
				}
			}else{
				num[A[i]] = count;
				count = 1;
				if(i == N-1){
					num[A[i]] = 1;
				}
			}
		}
		for(int i = 0;i < N;i++){
			buf += num[i] * (num[i] - 1) / 2;
		}
		for(int i = 0;i < N;i++){
			int ans = buf;
			ans -= (num[A[i]] - 1);
		}
		System.out.println(ans);
	}
}

Compiler output:
Main.java:38: error: cannot find symbol
		System.out.println(ans);
		                   ^
  symbol:   variable ans
  location: class Main
1 error
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int n,a[200001],b[200001],c[200001]={1},d[200001],c[20001],i,j,k=1;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++} {cin>>a[i];b[i]=a[i];}
    sort(b+1,b+1+n);
    d[1]=b[1];
    for(i=2;i<=n;i++){
        if(b[i]==b[i-1]) c[k]++;
        else {k++;d[k]=b[i];}
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=k;j++){
            if(a[i]!=d[j]){
                e[i]+=c[j]*(c[j]-1)/2;
            }
        }
        cout<<e[i]<<endl;
    }
    return 0;
}

Compiler output:
a.cc:4:51: error: conflicting declaration 'int c [20001]'
    4 | int n,a[200001],b[200001],c[200001]={1},d[200001],c[20001],i,j,k=1;
      |                                                   ^
a.cc:4:27: note: previous declaration as 'int c [200001]'
    4 | int n,a[200001],b[200001],c[200001]={1},d[200001],c[20001],i,j,k=1;
      |                           ^
a.cc: In function 'int main()':
a.cc:8:21: error: expected ')' before '}' token
    8 |     for(i=1;i<=n;i++} {cin>>a[i];b[i]=a[i];}
      |        ~            ^
      |                     )
a.cc:8:21: error: expected primary-expression before '}' token
a.cc: At global scope:
a.cc:8:23: error: expected unqualified-id before '{' token
    8 |     for(i=1;i<=n;i++} {cin>>a[i];b[i]=a[i];}
      |                       ^
a.cc:9:9: error: expected constructor, destructor, or type conversion before '(' token
    9 |     sort(b+1,b+1+n);
      |         ^
a.cc:10:5: error: 'd' does not name a type
   10 |     d[1]=b[1];
      |     ^
a.cc:11:5: error: expected unqualified-id before 'for'
   11 |     for(i=2;i<=n;i++){
      |     ^~~
a.cc:11:13: error: 'i' does not name a type
   11 |     for(i=2;i<=n;i++){
      |             ^
a.cc:11:18: error: 'i' does not name a type
   11 |     for(i=2;i<=n;i++){
      |                  ^
a.cc:15:5: error: expected unqualified-id before 'for'
   15 |     for(i=1;i<=n;i++){
      |     ^~~
a.cc:15:13: error: 'i' does not name a type
   15 |     for(i=1;i<=n;i++){
      |             ^
a.cc:15:18: error: 'i' does not name a type
   15 |     for(i=1;i<=n;i++){
      |                  ^
a.cc:23:5: error: expected unqualified-id before 'return'
   23 |     return 0;
      |     ^~~~~~
a.cc:24:1: error: expected declaration before '}' token
   24 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
int main()
{
	ll int n;
	cin>>n;
	ll int a[n];
	for(ll int i=0;i<n;i++)
	{
		a[i]=0;
	} 
	ll int v[n];
	for(ll int i=0;i<n;i++)
	{
		cin>>v[i];
		a[v[i]-1]++;
	}
	ll int k=0;
	for(ll int i=0;i<n;i++)
	{
		if(a[i]>1)
			k+=a[i]*(a[i]-1);
	}
	k/=2;
	for(ll int i=0;i<n;i++)
	{
		if(a[v[i]-1]>1)
			cout<<k-(a[v[i]-1]-1);
		else if
			cout<<k;
		if(i!=n-1){cout<<endl;}
	}
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: expected '(' before 'cout'
   33 |                         cout<<k;
      |                         ^~~~
      |                         (
Language: C++

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

int main(){
  long long int cnt=0,ans=0,N;
  vector<long long int> A(20010);
  
  cin>>N;
  for(int i=0;i<N;i++)cin>>A.at(i);
  
  vector<long long int> B(20010);
  for(int i=0;i<N;i++)B.at(A.at(i)-1)++;
  
  for(int k=0;k<N;i++){
    B.at(A.at(k)-1)--;
    int ans=0;
    for(int i=0;i<N;i++){
      if(B.at(i)>1)ans+=B.at(i)*(B.at(i)-1)/2;
    }
    B.at(A.at(k)-1)++;
    cout<<ans<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'i' was not declared in this scope
   14 |   for(int k=0;k<N;i++){
      |                   ^
Language: C++

#include<iostream>

using namespace std;

int main() {
  long n;
  cin>>n;
  long arr[n];
  for(long i=0;i<n;i++) {
    cin>>arr[i];
  }
  long arr2[n];
  for(long i=0;i<n;i++) {
      arr2[i] = 0;
  }
  
  long j=0;
  int sum = 0;
  while(j<n) {
      for(long i=0;i<n;i++) {
          if(arr[i] == 1+j) {
          arr2[j]++;
          sum++;
          }
      }
      j++;
      if(sum==n) break;
  }
  
  
  for(long i=0;i<n;i++) {
      if()
      long ans = ((arr2[arr[i]-1]-1)*(arr2[arr[i]-1]-2))/2;
    for(long j=0;j<n;j++) {
        if(j!= arr[i]-1) {
          ans = ans + (arr2[j]*(arr2[j]-1))/2;
        }
    }
    cout<<ans<<endl;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:10: error: expected primary-expression before ')' token
   32 |       if()
      |          ^
a.cc:36:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |           ans = ans + (arr2[j]*(arr2[j]-1))/2;
      |           ^~~
      |           abs
a.cc:39:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s, n) for(int i = s; i < (int)n; i++)
#define ll long long 
using namespace std;
ll combination(ll n){
  ll a;
  if(n%2==0) {
    a=n/2*(n-1);
  }else {
    a=(n-1)/2*n;
  }
  return a;
}
int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  map<ll,ll> mp;
  rep(i,1,n+1) mp[i]=0;
  rep(i,n) mp[vec[i]]++;
  ll sum=0;
  rep2(i,1,n+1) sum+=combination(mp[i]);
  rep(i,n){
    if(mp[vec[i]]>=3){
      cout <<sum-mp[vec[i]]+1<<endl;
    }else if(mp[vec[i]]==2){
      cout <<sum-1<<endl;
    }else{
      cout <<sum<<endl;
    }
  }
}

Compiler output:
a.cc:24:14: error: macro "rep" passed 3 arguments, but takes just 2
   24 |   rep(i,1,n+1) mp[i]=0;
      |              ^
a.cc:5:9: note: macro "rep" defined here
    5 | #define rep(i, n) for(int i = 0; i < (int)n; i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:24:3: error: 'rep' was not declared in this scope
   24 |   rep(i,1,n+1) mp[i]=0;
      |   ^~~
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
ll combination(ll n){
  ll a;
  if(n%2==0) {
    a=n/2*(n-1);
  }else {
    a=(n-1)/2*n;
  }
  return a;
}
int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  map<ll,ll> mp;
  rep(i,1,n+1) mp[i]=0;
  rep(i,n) mp[vec[i]]++;
  ll sum=0;
  rep2(i,1,n+1) sum+=combination(mp[i]);
  rep(i,n){
    if(mp[vec[i]]>=3){
      cout <<sum-mp[vec[i]]+1<<endl;
    }else if(mp[vec[i]]==2){
      cout <<sum-1<<endl;
    }else{
      cout <<sum<<endl;
    }
  }
}

Compiler output:
a.cc:23:14: error: macro "rep" passed 3 arguments, but takes just 2
   23 |   rep(i,1,n+1) mp[i]=0;
      |              ^
a.cc:5:9: note: macro "rep" defined here
    5 | #define rep(i, n) for(int i = 0; i < (int)n; i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:23:3: error: 'rep' was not declared in this scope
   23 |   rep(i,1,n+1) mp[i]=0;
      |   ^~~
a.cc:26:8: error: 'i' was not declared in this scope
   26 |   rep2(i,1,n+1) sum+=combination(mp[i]);
      |        ^
a.cc:26:3: error: 'rep2' was not declared in this scope; did you mean 'rep'?
   26 |   rep2(i,1,n+1) sum+=combination(mp[i]);
      |   ^~~~
      |   rep
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i<(int)n;i++)
#define ll long long 
using namespace std;
ll combination(ll n){
  if(n%2==0) {
    ll a=n/2*(n-1);
  }else {
    ll a=(n-1)/2*n;
  }
  return a;
}
int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  map<ll,ll> mp;
  rep(i,n) mp[i]=0;
  rep(i,n) mp[vec[i]]++;
  ll sum=0;
  rep(i,n) sum+=combination(mp[i]);
  rep(i,n){
    if(mp[vec[i]]>=3){
      cout <<sum-mp[vec[i]]+1<<endl;
    }else if(mp[vec[i]]==2){
      cout <<sum-1<<endl;
    }else{
      cout <<sum<<endl;
    }
  }
}

Compiler output:
a.cc: In function 'long long int combination(long long int)':
a.cc:15:10: error: 'a' was not declared in this scope
   15 |   return a;
      |          ^
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i<(int)n;i++)
#define ll long long 
using namespace std;
ll combination(ll n){
  if(n%==2) ll a=n/2*(n-1);
  else ll a=(n-1)/2*n;
  return a;
}
int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  map<ll,ll> mp;
  rep(i,n) mp[i]=0;
  rep(i,n) mp[vec[i]]++;
  ll sum=0;
  rep(i,n) sum+=combination(mp[i]);
  rep(i,n){
    if(mp[vec[i]]>=3){
      cout <<sum-mp[vec[i]]+1<<endl;
    }else if(mp[vec[i]]==2){
      cout <<sum-1<<endl;
    }else{
      cout <<sum<<endl;
    }
  }
}

Compiler output:
a.cc: In function 'long long int combination(long long int)':
a.cc:10:9: error: expected primary-expression before '=' token
   10 |   if(n%==2) ll a=n/2*(n-1);
      |         ^
a.cc:12:10: error: 'a' was not declared in this scope
   12 |   return a;
      |          ^
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i<(int)n;i++)
#define ll long long 
using namespace std;
ll conbination(ll n){
  ll a=(n*(n-1))/2;
  return a;
}
int main(){
  ll n;
  cin >>n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  map<ll,ll> mp;
  rep(i,n) mp[i]=0;
  rep(i,n) mp[vec[i]]++;
  ll sum=0;
  rep(i,n) sum+=conbination(mp[i]);
  rep(i,n){
    if(mp[vec[i]]>=3){
      cout <<sum-mp[vec[i]]+1<<endl;
    }else if{
      (mp[vec[i]]==2)cout <<sum-1<<endl;
    }else{
      mp[vec[i]]==1)cout <<sum<<endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:13: error: expected '(' before '{' token
   26 |     }else if{
      |             ^
      |             (
a.cc:28:6: error: 'else' without a previous 'if'
   28 |     }else{
      |      ^~~~
a.cc:29:20: error: expected ';' before ')' token
   29 |       mp[vec[i]]==1)cout <<sum<<endl;
      |                    ^
      |                    ;
Language: Java

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Hiral {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        HashMap<Integer, Long> hashMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            a[i] = num;
            if(hashMap.containsKey(num)){
                hashMap.put(num, hashMap.get(num) + 1);
            } else {
                hashMap.put(num, 1L);
            }
        }

        long total = 0;
        for(Map.Entry<Integer, Long> entry : hashMap.entrySet()){
            total += (entry.getValue()*(entry.getValue()-1))/2;
        }

        //System.out.println(hashMap);
        //System.out.println(total);

        for (int num: a){
            System.out.println(total - (hashMap.get(num)) + 1);
        }

    }
}


/*

5
1 1 2 1 2

counter =>  key      value
             1   ->    3
             2   ->    2

long total = 0

total += 3;
total = 3
total += 1;
total = 4;

1st ball is 1
remaining balls 1 2 1 2
print => total - (hashMap.get(1)) + 1
            4 - 3 + 1 = 2
            
3rd ball is 2 
remaining balls 1 1 1 2
            total - hashMap.get(2) + 1
            4 - 2 + 1 = 3
            
          
 */

Compiler output:
Main.java:5: error: class Hiral is public, should be declared in a file named Hiral.java
public class Hiral {
       ^
1 error
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> ball(n);
  for(int i=0;i<n;i++){
    cin>>ball.at(i);
  }
  map<int,int> a;
  for(int i=0;i<n;i++){
    if(!a.count(ball.at(i))){
      a[ball.at(i)]=1;
    }
    else{
      a.[ball.at(i)]++;
    }
  }
  for(int i=0;i<n;i++){
    a.[ball.at(i)]--;
    int sum=0;
    for(pair<int,int> p:a){
      int key=p.first;
      int count=p.second;
      sum+=count*(count-1)/2;
    }
    cout<<sum<<endl;
    a.[ball.at(i)]++;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: expected unqualified-id before '[' token
   17 |       a.[ball.at(i)]++;
      |         ^
a.cc:21:7: error: expected unqualified-id before '[' token
   21 |     a.[ball.at(i)]--;
      |       ^
a.cc:29:7: error: expected unqualified-id before '[' token
   29 |     a.[ball.at(i)]++;
      |       ^
Language: C++

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

ll c[200001];

ll cmb2(ll n){
    if(n <= 1) return 0;
    else return n*(n-1)/2;
}

int main(){
    int N; cin >> N;
    ll A[N];
    for(int i = 0; i < 200001; i++) c[i] = 0;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) c[A[i]]++;
    ll sum_cmb = 0;
    for(int i = 0; i < N; i++) sum_cmb += cmb2(c[i]);

    for(int i = 0; i < N; i++) cout << sum_cmb - (c[A[i]] - 1)) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:63: error: expected ';' before ')' token
   21 |     for(int i = 0; i < N; i++) cout << sum_cmb - (c[A[i]] - 1)) << endl;
      |                                                               ^
      |                                                               ;
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:20:4: error: expected '}' at end of input
   20 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long int li;
typedef long long ll;

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

    li n; cin >> n;
    vector<li> a(n+10,0), b(n+10,0); 
    
    for (li i=1; i<=n; i++) {
        cin >> a[i];
        b[a[i]] += 1;
    }
    
    li sum = 0;
    for (li i=1; i<=n; i++) sum += max(0, b[i] * (b[i]-1) / 2);

    for (li i=1; i<=n; i++) {
        cout << sum - (b[a[i]] - 1) << "\n";
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:39: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   19 |     for (li i=1; i<=n; i++) sum += max(0, b[i] * (b[i]-1) / 2);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:19:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   19 |     for (li i=1; i<=n; i++) sum += max(0, b[i] * (b[i]-1) / 2);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:19:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |     for (li i=1; i<=n; i++) sum += max(0, b[i] * (b[i]-1) / 2);
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <map>
using namespace std;
typedef long long int;

int comb(int n, int r)
{
  return (n) * (n - 1) / r;
}

int main()
{
  int n;
  int arr[200100];
  map<int, int> m;
  map<int, int> mp;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> arr[i];
    m[arr[i]] += 1;
  }
  int ret = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++)
  {
    mp[itr->first] = comb(itr->second, 2);
    ret += mp[itr->first];
    // cout << "f" << itr->first << ',' << mp[itr->first] << endl;
  }
  // cout << ret << endl;
  for (int i = 0; i < n; i++)
  {
    cout << ret + comb(m[arr[i]] - 1, 2) - comb(m[arr[i]], 2) << endl;
  }
}

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

#include<bits/stdc++.h>
#define int long long int
using namespace std;
int main(){
	int n; cin>>n;
  	int a[n];
  	int freq[200005] = {0};
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	freq[a[i]]++;
    }
    int ans=0;
    for(int j=0;j<200005;j++){
        	ans += (freq[j]*(freq[j] - 1))/2;
        }
  	for(int i=0;i<n;i++){
        int s = a[i];
        int k = ans - (freq[s]*(freq[s]-1))/2 + (freq[s]-1)*(freq[s]-2)/2;
        cout << k << endl;
    }
}


Compiler output:
a.cc:2:23: error: '::main' must return 'int'
    2 | #define int long long int
      |                       ^~~
a.cc:4:1: note: in expansion of macro 'int'
    4 | int main(){
      | ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x; cin>>n;
  	int a[n];
  	int freq[200005] = {0};
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	freq[a[i]]++;
    }
  	for(int i=0;i<n;i++){
    	freq[a[i]]--;
      	int ans =0;
      	for(j=0;j<200005;j++){
        	ans += (freq[j]*(freq[j] - 1))/2;
        }
      	cout << ans << endl;
      	freq[a[i]]++;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'j' was not declared in this scope
   14 |         for(j=0;j<200005;j++){
      |             ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
   
int main(void){
	int N,sum;
	cin >>N;
	vector<int>v(N);
	for(int i=0 ; i<N ; i++){
		cin>>v[i];
	}
	
	int a[N+1];
	int b[N+1];
	for(int i=1 ; i<=N ; i++){
	a[i] = count(v.begin(), v.end(), i)*(count(v.begin(), v.end(), i)-1)/2;
	b[i] = (count(v.begin(), v.end(), i)-2)*(count(v.begin(), v.end(), i)-1)/2;
	sum +=a[i];
	}
	
	
	
	for(int i=0 ; i<N ; i++){
		int k = v[i];
		cout<<sum+b[k]-a[k]<<endl;
	}
	
	
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 'count' was not declared in this scope
   17 |         a[i] = count(v.begin(), v.end(), i)*(count(v.begin(), v.end(), i)-1)/2;
      |                ^~~~~
Language: C++

#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
typedef long long int ll;

using namespace std;

int main()
{

    cin >> N;

    vector<ll> A(N, 0);

    set<ll> B;

    for (ll i = 0; i < N; i++)
    {

        cin >> A[i];

        B.insert(A[i]);
    }

    vector<ll> num(B.size(), 0);

    for (ll i = 0; i < N; i++)
    {

        for (ll j = 0; j < B.size(); j++)
        {

            if (A[i] == B[j])

                num[j]++;
        }
    }

    ll defo = (N - 1) * N / 2;

    for (ll i = 0; i < B.size(); i++)
    {

        defo = defo - B[j] * (B[j] - 1) / 2;
    }

    for (ll i = 0; i < N; i++)
    {

        for (ll j = 0; j < B.size(); j++)
        {

            if (A[i] == B[j])
            {

                ll ans = defo + B[j] * (B[j] - 1) / 2 - B[j - 1] * (B[j] - 2) / 2;

                cout << ans << endl;
            }
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'N' was not declared in this scope
   12 |     cin >> N;
      |            ^
a.cc:34:26: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   34 |             if (A[i] == B[j])
      |                          ^
a.cc:45:25: error: 'j' was not declared in this scope
   45 |         defo = defo - B[j] * (B[j] - 1) / 2;
      |                         ^
a.cc:54:26: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   54 |             if (A[i] == B[j])
      |                          ^
a.cc:57:34: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   57 |                 ll ans = defo + B[j] * (B[j] - 1) / 2 - B[j - 1] * (B[j] - 2) / 2;
      |                                  ^
a.cc:57:42: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   57 |                 ll ans = defo + B[j] * (B[j] - 1) / 2 - B[j - 1] * (B[j] - 2) / 2;
      |                                          ^
a.cc:57:58: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   57 |                 ll ans = defo + B[j] * (B[j] - 1) / 2 - B[j - 1] * (B[j] - 2) / 2;
      |                                                          ^
a.cc:57:70: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   57 |                 ll ans = defo + B[j] * (B[j] - 1) / 2 - B[j - 1] * (B[j] - 2) / 2;
      |                                                                      ^