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

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

#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;

int main(){
    int n,k;cin >> n >> k;
    vector<pair<int,int>> p(n);
    map<int,int> mp;
    rep{
        int ai,bi;cin >> ai >> bi;
        p[i] = make_pair(bi,ai);
        if(mp.find(ai) != mp.end()){
            if(mp[ai] < bi) mp[ai] = bi;
        }else{
            mp[ai] = bi;
        }
    }
    set<int> st;
    sort(p.begin(),p.end());
    long long fx = 0;
    for(int i = 0;i<k;i++){
        fx += p[n-1-i].first; 
        st.insert(p[n-1-i].second);
    }
    //cout << mp.size() << " " << st.size() << endl;
    if(mp.size() == st.size()){
        cout << fx + st.size()*st.size() << endl;
    }else{
        for(int j = 1;j<=mp.size()-st.size();j++){
            long long newfx = 
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: expected primary-expression before '}' token
   33 |         }
      |         ^
Language: C++

49 12
7 2
4 7
4 4
4 9
7 1
5 5
7 5
4 1
11 2
6 9
7 3
9 7
8 2
3 7
7 4
6 1
7 9
2 10
3 8
11 1
4 7
7 1
11 3
8 6
11 9
9 9
9 9
5 4
3 3
9 3
8 5
7 8
6 7
10 7
10 9
7 4
7 7
10 10
2 10
6 10
4 5
7 10
8 6
9 3
7 6
8 1
9 5
10 4
7 2

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 49 12
      | ^~
Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<pair<int, int>> vec(N);
  map<int, int> saidai;
  REP(i, N){
    cin >> vec[i].first >> vec[i].second;
    chmax(saidai[vec[i].first], vec[i].second);
  }

  sort(ALL(vec),   // dai -> syou
      [](pair<int, int> const & l, pair<int, int> const &  r){
      return l.second > r.second;
      });

  int ans = 0, oisisa = 0, syurui = 0;;
  vector<pair<int, int>> used;
  map<int, int> m;
  int num = 0;
  for(; num < K; num++){
    oisisa += vec[num].second;
    used.push_back(vec[num]);
    m[vec[num].first]++;
  }
  syurui = m.size();
  ans = oisisa+(int)pow(syurui, 2);

  sort(ALL(used),   // syou -> dai
      [](pair<int, int> const & l, pair<int, int> const &  r){
      return l.second < r.second;
      });

  vector<pair<int, int>> suteru;
  REP(i, K) if(m[used[i].first] > 1){
    suteru.push_back(used[i]);
    m[used[i].first]--;
  }

  vector<pair<int, int>> siyou;
  for(pair<int, int>p:saidai){
    if(m[p.first] == 0) siyou.push_back(p);
  }

  REP(i, min(suteru.size(), siyou.size())){
    oisisa -= suteru[i].second;
    oisisa += siyou[i].second;
    syurui++;
    chmax(ans, oisisa+(int)pow(syurui, 2));
  }
  
  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:21: error: 'pow' was not declared in this scope
   65 |   ans = oisisa+(int)pow(syurui, 2);
      |                     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<P> td(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> td[i].first >> td[i].second;
    }
    sort(ALL(td), [](const auto &a, const auto &b) { return a.second > b.second; });
    ll ans = 0, now = 0;
    map<ll, int> sushi;
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (ll i = 0; i < k; i++)
    {
        now += td[i].second;
        if (sushi[td[i].first] <= 0)
        {
            sushi[td[i].first]++;
        }
        else
        {
            pq.push(td[i].second);
        }
    }
    ll index = k;
    ans = now + (ll)sushi.size() * (ll)sushi.size();
    while (!pq.empty() && index < n)
    {
        if (sushi[td[index].first] <= 0)
        {
            now -= pq.top();
            pq.pop();
            now += td[index].second;
            sushi[td[index].first]++;
            chmax(ans, now + (ll)sushi.size() * sushi.size());
        }
        index++;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:18: error: no matching function for call to 'chmax(ll&, long long unsigned int)'
   76 |             chmax(ans, now + (ll)sushi.size() * sushi.size());
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:13: note: candidate: 'template<class T> bool chmax(T&, T)'
    4 | inline bool chmax(T &a, T b)
      |             ^~~~~
a.cc:4:13: note:   template argument deduction/substitution failed:
a.cc:76:18: note:   deduced conflicting types for parameter 'T' ('long long int' and 'long long unsigned int')
   76 |             chmax(ans, now + (ll)sushi.size() * sushi.size());
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

 #include <iostream>
 #include <queue>
 #include <algorithm>
 #include <numeric>
 using namespace std;
 const long long INF = 1LL << 40 ;

 int main () {
     long long N, K; cin >> N >> K;
     vector <vector < long long >> s (N); // s [i]: = set of delicious flavors of type i
     for ( int i = 0 ; i <N; ++ i) {
         long long t, d; cin >> t >> d; --t;
         s [t] .push_back (d);
     }

     // For each type, arrange in order of taste
     for ( auto & v: s) {
         sort (v.begin (), v.end (), greater < long long > ());
         if (v.empty ()) v.push_back (-INF); // sentinel
     }

     // The order of the news item with the largest value of “deliciousness”
     sort (s.begin (), s.end (), [&] (vector < long long > a, vector < long long > b) {
             return a [ 0 ]> b [ 0 ];});
 
     // First select K types
     long long cur = 0 ;
     priority_queue < long long > que;
     for ( int i = 0 ; i <K; ++ i) {
         cur + = s [i] [ 0 ];
         for ( int j = 1 ; j <s [i] .size (); ++ j) que.push (s [i] [j]);
     }
     //for ( int i = K; i <N; ++ i) for ( int j = 0 ; j <s [i] .size (); ++ j) que.push (s [i] [j]);

     // scan
     long long res = cur + K * K;
     for ( long long x = K- 1 ; x> = 1 ; --x) {
         long long v = s [x] [ 0 ];
         long long w = que.top ();
         if (v <w) {
             que.pop (); cur + = w;
             que.push (v); cur-= v;
         }
         res = max (res, cur + x * x);
     }
     cout << res << endl;
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: expected primary-expression before '=' token
   30 |          cur + = s [i] [ 0 ];
      |                ^
a.cc:37:36: error: expected primary-expression before '=' token
   37 |      for ( long long x = K- 1 ; x> = 1 ; --x) {
      |                                    ^
a.cc:41:32: error: expected primary-expression before '=' token
   41 |              que.pop (); cur + = w;
      |                                ^
Language: C++

 #include <iostream>
 #include <queue>
 #include <algorithm>
 #include <numeric>
 using namespace std;
 const long long INF = 1LL << 40 ;

 int main () {
     long long N, K; cin >> N >> K;
     vector <vector < long long >> s (N); // s [i]: = set of delicious flavors of type i
     for ( int i = 0 ; i <N; ++ i) {
         long long t, d; cin >> t >> d; --t;
         s [t] .push_back (d);
     }

     // For each type, arrange in order of taste
     for ( auto & v: s) {
         sort (v.begin (), v.end (), greater < long long > ());
         if (v.empty ()) v.push_back (-INF); // sentinel
     }

     // The order of the news item with the largest value of “deliciousness”
     sort (s.begin (), s.end (), [&] (vector < long long > a, vector < long long > b) {
             return a [ 0 ]> b [ 0 ];});
 
     // First select K types
     long long cur = 0 ;
     priority_queue < long long > que;
     for ( int i = 0 ; i <K; ++ i) {
         cur + = s [i] [ 0 ];
         for ( int j = 1 ; j <s [i] .size (); ++ j) que.push (s [i] [j]);
     }
     for ( int i = K; i <N; ++ i) for ( int j = 0 ; j <s [i] .size (); ++ j) que.push (s [i] [j]);

     // scan
     long long res = cur + K * K;
     for ( long long x = K- 1 ; x> = 1 ; --x) {
         long long v = s [x] [ 0 ];
         long long w = que.top ();
         if (v <w) {
             que.pop (); cur + = w;
             que.push (v); cur-= v;
         }
         res = max (res, cur + x * x);
     }
     cout << res << endl;
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:30:16: error: expected primary-expression before '=' token
   30 |          cur + = s [i] [ 0 ];
      |                ^
a.cc:37:36: error: expected primary-expression before '=' token
   37 |      for ( long long x = K- 1 ; x> = 1 ; --x) {
      |                                    ^
a.cc:41:32: error: expected primary-expression before '=' token
   41 |              que.pop (); cur + = w;
      |                                ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>

#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define eb emplace_back
#define ef emplace_front
#define dbg(x) cout<<#x" = "<<((x))<<endl
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll N, K;

  cin >> N >> K;
  
  vector<P> lst(N);
  Rep(i, N){
    P tmp;
    cin >> tmp.second >> tmp.first;
    lst[i] = tmp;
  }

  Sort(lst);
  Reverse(lst);

  vector<ll> cnt(N+1, 0);
  priority_queue<ll, vector<ll>, greater<ll>> que;
  ll ans = 0;
  ll tmp = 0;
  ll v = 0;
  Rep(i, K){
    tmp += lst[i].first;
    cnt[lst[i].second]++;
    if(cnt[lst[i].second] >= 2) que.push(lst[i].first);
    else v++;
  }

  ans = tmp + v*v;

  for(int i = K; i < N; ++i){
    if(cnt[lst[i].second] == 0){
      ll subt = que.top(); que.pop();
      tmp = tmp - subt + lst[i].first;
      v++;
      ans = max(ans, tmp + v*v);
    }
  }

  cout << ans << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:73:23: error: expected '}' at end of input
   73 |   cout << ans << endl;
      |                       ^
a.cc:35:11: note: to match this '{'
   35 | int main(){
      |           ^
Language: C++

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
struct sushi
{
    ll id;
    ll t;
    ll d;
};
sushi sushis[100010];

bool comp(const sushi &a,const sushi &b){
    return a.d >= b.d;
}

int main() {
    ll n,k;
    std::cin >> n>>k;
    for (int i = 0; i < n; i++) {
        ll tmp1,tmp2;
        std::cin >> tmp1>>tmp2;
        sushis[i].id = i;
        sushis[i].t = tmp1;
        sushis[i].d = tmp2;
    }
    sort(sushis,sushis+n,comp);
    ll val = 0;
    ll now = 0;

    set<ll> kinds;
    priority_queue<ll, vector<ll>, greater<ll> > que;

    for (int i = 0; i < k; i++) {
        if(kinds.count(sushis[i].t) == 1){
            que.push(sushis[i].d);
        }
        val += sushis[i].d;
        kinds.insert(sushis[i].t);
        now = i;
    }

    ll f[100010];
    Fill(f,(ll)0);
    f[kinds.size()] = val;
    ll si = kinds.size();

    // cout << si<<" "<<que.size()<<" "<<k<<endl;

    for (int i = si+1; i <= k; i++) {
        if(!que.empty()){
            ll current = que.top();
            que.pop();

            for (int j = now+1; j < n; j++) {
                if(kinds.count(sushis[j].t)==0){
                    kinds.insert(sushis[j].t);
                    f[i] = f[i-1]-current+sushis[j].d;
                    now = j;
                    break;
                }else{
                    now = j;
                    continue;
                }
            }
            
        }else{
            break;
        }
    }
    ll ans = 0;
    for (int i = si; i <= k; i++) {
        ll tmp = a;
        ans = max(ans,f[i]+tmp*tmp);
        // cout<<ans<<" "<<i<<endl;
        
    }
    std::cout << ans << std::endl;
}
// 49304328985977


Compiler output:
a.cc: In function 'int main()':
a.cc:76:18: error: 'a' was not declared in this scope
   76 |         ll tmp = a;
      |                  ^
Language: C++

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
struct sushi
{
    ll id,t,d;
};
sushi sushis[100010];

bool comp(const sushi &a,const sushi &b){
    if(a.d!=b.d){
        return a.d >= b.d;
    }else{
        return a.t > b.t;
    }
}

int main() {
    ll n,k;
    std::cin >> n>>k;
    for (int i = 0; i < n; i++) {
        ll tmp1,tmp2;
        std::cin >> tmp1>>tmp2;
        sushis[i].id = i;
        sushis[i].t = tmp1;
        sushis[i].d = tmp2;
    }
    sort(sushis,sushis+n,comp);
    ll val = 0;
    ll now = 0;

    set<ll> kinds;
    priority_queue<ll, vector<ll>, greater<ll> > que;
    
    for (int i = 0; i < k; i++) {
        if(kinds.count(sushis[i].t) == 1){
            que.push(sushis[i].d);
        }
        val += sushis[i].d;
        kinds.insert(sushis[i].t);
        now = i;
    }
    ll f[100010];z
    Fill(f,(ll)-1e20);
    f[kinds.size()] = val;
    ll si = kinds.size();

    for (int i = si+1; i <= k; i++) {
        if(!que.empty()){
            ll current = que.top();
            que.pop();

            for (int j = now+1; j < n; j++) {
                if(kinds.count(sushis[j].t)==0){
                    kinds.insert(sushis[j].t);
                    f[i] = f[i-1]-current+sushis[j].d;
                    now = j;
                    break;
                }else{
                    now = j;
                    continue;
                }
            }
            
        }else{
            break;
        }
    }
    ll ans = 0;
    for (int i = si; i <= k; i++) {
        ans = max(ans,f[i]+i*i);
    }
    std::cout << ans << std::endl;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:47:18: error: 'z' was not declared in this scope
   47 |     ll f[100010];z
      |                  ^
Language: C++

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

struct Sushi{
	int t,d;
	Sushi(){};
	Sushi(int t_,int d_){
		t=t_,d=d_;
	};
	bool operator<(const Sushi& o)const{return tie(d,t)>tie(o.d,o.t);}
}


int main(){
	int n,k;cin>>n>>k;
	vector<Sushi>v(n);
	for(auto&& u:v) cin>>u.t>>u.d;
	sort(begin(v),end(v));
	map<int,int>cnt;
	rep(i,k)cnt[v[i].t]++;
	int s=cnt.size();

	int sm=0,ans=0;	
	rep(i,k)sm+=v[i].d;
	ans=sm+s*s;
	int il=k-1,ir=k;
	while(il>=0&&ir<n){
	while(il>=0&&cnt[v[il].t]<=1)il--;
	while(ir<n&&cnt[v[ir].t]>=1)ir++;
	if(il>=0&&ir<n){
		sm-v[il].d+v[ir].d;
		cnt[v[il].t]--;
		cnt[v[ir].t]++;
		s++;
		ans=max(ans,sm+s*s);
	}
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:12:2: error: expected ';' after struct definition
   12 | }
      |  ^
      |  ;
Language: C++

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

struct Sushi{
	int t,d;
	Sushi(){};
	Sushi(int t_,d_){
		t=t_,d=d_;
	};
	bool operator<(const Sushi& o)const{return tie(d,t)>tie(o.d,o.t);}
}


int main(){
	int n,k;cin>>n>>k;
	vector<Sushi>v(n);
	for(auto&& u:v) cin>>u.t>>u.d;
	sort(begin(v),end(v));
	map<int,int>cnt;
	rep(i,k)cnt[v[i].t]++;
	int s=cnt.size();

	int sm=0,ans=0;	
	rep(i,k)sm+=v[i].d;
	ans=sm+s*s;
	int il=k-1,ir=k;
	while(il>=0&&ir<n){
	while(il>=0&&cnt[v[il].t]<=1)il--;
	while(ir<n&&cnt[v[ir].t]>=1)ir++;
	if(il>=0&&ir<n){
		sm-v[il].d+v[ir].d;
		cnt[v[il].t]--;
		cnt[v[ir].t]++;
		s++;
		ans=max(ans,sm+s*s);
	}
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc:8:22: error: 'd_' has not been declared
    8 |         Sushi(int t_,d_){
      |                      ^~
a.cc:12:2: error: expected ';' after struct definition
   12 | }
      |  ^
      |  ;
a.cc: In constructor 'Sushi::Sushi(int, int)':
a.cc:9:24: error: 'd_' was not declared in this scope; did you mean 'd'?
    9 |                 t=t_,d=d_;
      |                        ^~
      |                        d
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pll pair<long long,long long>
#define ll long long
#define mp make_pair
ll n,k,a,b,ans,res;
long long sz;
priority_queue<pll>q;
ll num[100003];
vector<pll>v;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a>>b,
		q.push(mp(b,--a));
	for(int i=0;i<k;i++){
		pll now=q.top();
		q.pop();
		num[now.y]++;
		res+=now.x;
		v.push_back(mp(now.x,now.y));
		sz+=(num[now.y]==1);
	}
	ans=res+sz*sz;
	while(k--){
	    if(num[v[k].y]>1)
			while(q.size()){
				pll now=q.top();q.pop();
				if(!num[now.y])
				{
					num[now.y]++,num[v[k].y]--,
					res=res+now.x-v[k].x,
					sz++;
					v[x]=now;
					if(ans<res+sz*sz)ans=res+sz*sz;
				}
			}
	}
	cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:11: error: 'first' was not declared in this scope
    3 | #define x first
      |           ^~~~~
a.cc:36:43: note: in expansion of macro 'x'
   36 |                                         v[x]=now;
      |                                           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pll pair<long long,long long>
#define ll long long
#define mp make_pair
ll n,k,a,b,ans,res;
set<ll>s;
priority_queue<pll>q;
ll num[100003];
vector<pll>v;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a>>b,
		q.push(mp(--b,--a));
	for(int i=0;i<k;i++){
		pll now=q.top();
		q.pop();
		num[now.y]++;
		ans+=now.x;
		res+=now.x;
		v.push_back(mp(now.x,now.y));
		s.insert(now.y);
	}
	ans=ans+s.size()*s.size();
	while(k--){
		if(num[q.top().second]>1)
			while(q.size()){
				pll now=q.top();q.pop();
				if(num[now.y])continue;
				num[now.y]=1;num[v[k].y]--;
				res=res-now.x+v[k].x;
				s.insert(now.y);
				ans=max(ans,res+s.size()*s.size());
			}
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:40: error: no matching function for call to 'max(long long int&, long long unsigned int)'
   36 |                                 ans=max(ans,res+s.size()*s.size());
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
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:36:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   36 |                                 ans=max(ans,res+s.size()*s.size());
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:36:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |                                 ans=max(ans,res+s.size()*s.size());
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

struct st
{
	int kt,d;
}a[100010];

bool cmp(st x,st y)
{
	return x.d>y.d;
}

int n,k;
long long cnt,tp,ans,now;
bool vis[100010];
stack<int> s;

int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i].kt>>a[i].d;
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(cnt<k)
		{
			if(!vis[a[i].kt])
			{
				++tp;
				vis[a[i].kt]=true;
			}
			else
				s.push(a[i].d);
			++cnt;
			now+=a[i].d;
			ans=max(ans,now+tp*tp);
		}
		else
		{
			if(s.empty())
				break;
			if(vis[a[i].kt])
				continue;
			vis[a[i].kt]=true;
			now+=a[i].d;
			now-=s.top();
			s.pop();
			++tp;
			++cnt;
			ans=max(ans,now+tp*tp);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:17:1: error: 'stack' does not name a type; did you mean 'obstack'?
   17 | stack<int> s;
      | ^~~~~
      | obstack
a.cc: In function 'int main()':
a.cc:24:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |         sort(a,a+n,cmp);
      |         ^~~~
      |         short
a.cc:35:33: error: 's' was not declared in this scope
   35 |                                 s.push(a[i].d);
      |                                 ^
a.cc:42:28: error: 's' was not declared in this scope
   42 |                         if(s.empty())
      |                            ^
a.cc:48:30: error: 's' was not declared in this scope
   48 |                         now-=s.top();
      |                              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
set<long long>s;
pair<long long,long long>a[100003];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i].second>>a[i].first;
	sort(a,a+n);
	for(int i=0;i<k;i++)
		ans+=a[n-1-i].first,
		s.insert(a[n-1-i].second);
	cout<<ans*s.size()*s.size();
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |                 ans+=a[n-1-i].first,
      |                 ^~~
      |                 abs
a.cc:14:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |         cout<<ans*s.size()*s.size();
      |               ^~~
      |               abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
set<long long>s,s2;
pair<long long,long long>a[100003],c[100003];
vector<long long>v[100003];
bool can[100003];
bool cmp(pair<int,int>a,pair<int,int>b){
	return a.first>b.first;
}
bool cmp2(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].second>>a[i].first;
		if(c[a[i].second-1].first<a[i].first)
			c[a[i].second-1].first=a[i].first,
			c[a[i].second-1].second=i;
		s2.insert(a[i].second);
	}
	int k2=k;
	sort(a,a+n);sort(c,c+n,cmp);
	long long ans=0,ans2=int(min(int(k),int(s2.size())))*int(min(int(k),int(s2.size())));
	for(int i=0;k>=0&&c[i].first!=0;i++,k--)ans2=ans2+c[i].first,can[c[i].second]=1;
	vector<int>v;
	for(int i=0;i<n;i++)if(!can[i])v.push_back(a[i].first);
	sort(v.begin(),v.end(),cmp2);
	for(int i=0;i<k;i++)ans2+=v[i];
	for(int i=0;i<k2;i++)
		ans+=a[n-1-i].first,
		s.insert(a[n-1-i].second);
	cout<<max(1ll*(ans+s.size()*s.size()),ans2);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: no matching function for call to 'max(long long unsigned int, long long int&)'
   35 |         cout<<max(1ll*(ans+s.size()*s.size()),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:35:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   35 |         cout<<max(1ll*(ans+s.size()*s.size()),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:35:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   35 |         cout<<max(1ll*(ans+s.size()*s.size()),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
set<long long>s,s2;
pair<long long,long long>a[100003],c[100003];
vector<long long>v[100003];
bool can[100003];
bool cmp(pair<int,int>a,pair<int,int>b){
	return a.first>b.first;
}
bool cmp2(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].second>>a[i].first;
		if(c[a[i].second-1].first<a[i].first)
			c[a[i].second-1].first=a[i].first,
			c[a[i].second-1].second=i;
		s2.insert(a[i].second);
	}
	int k2=k;
	sort(a,a+n);sort(c,c+n,cmp);
	long long ans=0,ans2=int(min(int(k),int(s2.size())))*int(min(int(k),int(s2.size())));
	for(int i=0;k>=0&&c[i].first!=0;i++,k--)ans2=ans2+c[i].first,can[c[i].second]=1;
	vector<int>v;
	for(int i=0;i<n;i++)if(!can[i])v.push_back(a[i].first);
	sort(v.begin(),v.end(),cmp2);
	for(int i=0;i<k;i++)ans2+=v[i];
	for(int i=0;i<k2;i++)
		ans+=a[n-1-i].first,
		s.insert(a[n-1-i].second);
	cout<<max(long long(ans+s.size()*s.size()),ans2);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:19: error: expected primary-expression before 'long'
   35 |         cout<<max(long long(ans+s.size()*s.size()),ans2);
      |                   ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
set<long long>s,s2;
pair<long long,long long>a[100003],c[100003];
vector<long long>v[100003];
bool can[100003];
bool cmp(pair<int,int>a,pair<int,int>b){
	return a.first>b.first;
}
bool cmp2(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].second>>a[i].first;
		if(c[a[i].second-1].first<a[i].first)
			c[a[i].second-1].first=a[i].first,
			c[a[i].second-1].second=i;
		s2.insert(a[i].second);
	}
	int k2=k;
	sort(a,a+n);sort(c,c+n,cmp);
	long long ans=0,ans2=int(min(int(k),int(s2.size())))*int(min(int(k),int(s2.size())));
	for(int i=0;k>=0&&c[i].first!=0;i++,k--)ans2=ans2+c[i].first,can[c[i].second]=1;
	vector<int>v;
	for(int i=0;i<n;i++)if(!can[i])v.push_back(a[i].first);
	sort(v.begin(),v.end(),cmp2);
	for(int i=0;i<k;i++)ans2+=v[i];
	for(int i=0;i<k2;i++)
		ans+=a[n-1-i].first,
		s.insert(a[n-1-i].second);
	cout<<max(int(ans+s.size()*s.size()),ans2);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: no matching function for call to 'max(int, long long int&)'
   35 |         cout<<max(int(ans+s.size()*s.size()),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:35:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   35 |         cout<<max(int(ans+s.size()*s.size()),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:35:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   35 |         cout<<max(int(ans+s.size()*s.size()),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
set<long long>s,s2;
pair<long long,long long>a[100003],c[100003];
vector<long long>v[100003];
bool can[100003];
bool cmp(pair<int,int>a,pair<int,int>b){
	return a.first>b.first;
}
bool cmp2(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].second>>a[i].first;
		if(c[a[i].second-1].first<a[i].first)
			c[a[i].second-1].first=a[i].first,
			c[a[i].second-1].second=i;
		s2.insert(a[i].second);
	}
	int k2=k;
	sort(a,a+n);sort(c,c+n,cmp);
	long long ans=0,ans2=int(min(int(k),int(s2.size())))*int(min(int(k),int(s2.size())));
	for(int i=0;k>=0&&c[i].first!=0;i++,k--)ans2=ans2+c[i].first,can[c[i].second]=1;
	vector<int>v;
	for(int i=0;i<n;i++)if(!can[i])v.push_back(a[i].first);
	sort(v.begin(),v.end(),cmp2);
	for(int i=0;i<k;i++)ans2+=v[i];
	for(int i=0;i<k2;i++)
		ans+=a[n-1-i].first,
		s.insert(a[n-1-i].second);
	cout<<max(ans+s.size()*s.size(),ans2);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: no matching function for call to 'max(long long unsigned int, long long int&)'
   35 |         cout<<max(ans+s.size()*s.size(),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:35:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   35 |         cout<<max(ans+s.size()*s.size(),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:35:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   35 |         cout<<max(ans+s.size()*s.size(),ans2);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, k;
vector<p> su;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    int used[n];
    for (int i = 0; i < n; i++)
    {
        used[i] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        su.push_back(make_pair(b, a - 1));
    }
    sort(ALL(su), greater<p>());
    int sp = 0;
    ll sum = 0;
    for (int i = 0; i < k; i++)
    {
        if (used[su[i].second] == 0)
        {
            sp++;
        }
        used[su[i].second]++;
        sum += su[i].first;
    }
    ll ans = ll(sum + sp * sp);
    int m = k - 1;
    if (n == k)
    {
        cout << ans << "\n";
        return 0;
    }
    for (int i = k; i < n; i++)
    {
        for (int j = m; j >= 0; j--)
        {
            if (used[su[j].second] > 1)
            {
                m = j;
                break;
            }
            else if (j == 0)
            {
                cout << ans << "\n";
                return 0;
            }
        }
        sum += -su[m].first + su[i].first;
        sp++;
        ans = max(ans, ll(sum + sp * sp);
        used[su[m].second]--;
        used[su[i].second]++;
        m--;
    }
    cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:89:41: error: expected ')' before ';' token
   89 |         ans = max(ans, ll(sum + sp * sp);
      |                  ~                      ^
      |                                         )
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cassert>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

const ll INF = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    vector<Pll> sushi(N); // {d, t}
    for(int i=0;i<N;++i){
        cin >> sushi[i].second >> sushi[i].first;
    }
    sort(sushi.rbegin(), sushi.rend());

    vector<ll> d_total(N+1, -INF);
    priority_queue<Pll, vector<Pll>, greater<Pll>> t_duplicate;
    vector<int> t_eaten(N+1, 0);
    ll d_total_tmp = 0LL;
    int bonus_count = 0;
    for(int i=0;i<K;++i){
        if(!t_eaten[sushi[i].second]) {
            ++bonus_count;
        } else {
            t_duplicate.push(sushi[i]);
        }
        ++t_eaten[sushi[i].second];
        d_total_tmp += sushi[i].first;
    }
    d_total[bonus_count] = d_total_tmp;

    for(int i=K;i<N&&!t_duplicate.empty();++i) {
        if(!t_eaten[sushi[i].second]) {
            ++bonus_count;
            ++t_eaten[sushi[i].second] = 1;
            d_total[bonus_count] = d_total[bonus_count-1] + sushi[i].first - t_duplicate.top().first;
            t_duplicate.pop();
        }
    }

    ll ans = 0LL;
    for(ll i=1;i<=N;++i){
        ans = max(ans, d_total[i] + i*i);
    }

    cout << ans << endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |     sort(sushi.rbegin(), sushi.rend());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <cassert>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

int main() {
    int n,k;
    cin >> n >> k;
    ll t, d;
    priority_queue<Pll, vector<Pll>, greater<Pll>> que1;
    priority_queue<Pll> que2;
    vector<int> count(n+1, 0);
    ll bonus_count = 0;

    for(int i=0;i<n;++i) {
        cin >> t >> d;
        if(count[t]) {
            que2.emplace(d, t);
        } else {
            que1.emplace(d, t);
            ++count[t];
            ++bonus_count;
        }
    }

    while(que1.size() > k) {
        Pll p = que1.top();
        --count[p.second];
        --bonus_count;
        que1.pop();
    }

    while(que1.size() < k) {
        Pll p = que2.top(); que2.pop();
        if(count[p.second] == 0) ++bonuc_count;
        ++count[p.second];
        que1.push(p);
    }

    while(!que2.empty()) {
        Pll p1 = que1.top();
        Pll p2 = que2.top(); que2.pop();
        bool changed = false;
        if(count[p1.second] >= 2) {
            if(count[p2.second] >= 1) {
                changed = (p1.first < p2.first);
            } else {
                changed = (p1.first + bonus_count*bonus_count < p2.first + (bonus_count+1)*(bonus_count+1));
                if(changed) {
                    ++bonus_count;
                }
            }
        } else {
            if(count[p2.second] >= 1) {
                changed = (p1.first + bonus_count*bonus_count < p2.first + (bonus_count-1)*(bonus_count-1));
                if(changed) {
                    --bonus_count;
                }
            } else {
                changed = (p1.first < p2.first);
            }
        }
        if(changed) {
            que1.pop();
            que1.push(p2);
        }
        assert(que1.size() == k);
    }

    ll ans = bonus_count * bonus_count;
    while(!que1.empty()) {
        ans += que1.top().first;
        que1.pop();
    }

    cout << ans << endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:36: error: 'bonuc_count' was not declared in this scope; did you mean 'bonus_count'?
   42 |         if(count[p.second] == 0) ++bonuc_count;
      |                                    ^~~~~~~~~~~
      |                                    bonus_count
Language: C++

#include <bits/stdc++.h>
using namespace std;
bool comparator(pair<long, long> a, pair<long, long> b)
{
    return a.second > b.second;
}

int main()
{
    long n, k, d, t;
    cin >> n >> k;
    vector<pair<long, long>> sushi(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> t >> d;        
        --t;
        sushi[i].first = t;
        sushi[i].second = d;
    }

    sort(sushi.begin(), sushi.end(), comparator);
    
    priority_queue<long> pq;
    long long deli = 0, vari = 0;
    vector<bool>used(n , false);
    for(int i = 0; i < k; ++i)
    {
        deli += sushi[i].second;
        if(!used[sushi[i].first])
        {
            used[sushi[i].first] = true;
            ++vari;
        }
        else
        {
            pq.push(sushi[i].second);
        }
    }
    long long ans = deli + vari*vari;
    for(int i = k; i < n; ++i)
    {
        if(!used[sushi[i].first] && !pq.empty())
        {
            int tp = pq.top();
            pq.pop();
            used[sishi[i].first] = true;
            ++vari;
            deli += sushi[i].second - tp;
        }
        ans = max(ans, deli + vari*vari);
    }
    cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:18: error: 'sishi' was not declared in this scope; did you mean 'sushi'?
   46 |             used[sishi[i].first] = true;
      |                  ^~~~~
      |                  sushi
Language: C++

#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;
typedef pair<ll, ll> pll;

int main(){
	ll n, k; cin >> n >> k;
	vector<pll> v;
	// first: 美味しさ
	// second: ネタの種類
	for( int i = 0; i < n; ++i ){
		ll t, d; cin >> t >> d;
		v.emplace_back(d, t);
	}
	sort( v.begin(), v.end(), greater<pll>() );
	ll cnt = 0;
	ll candy = 0;
	bool used[n]; 
	fill_n( used, n, false );
	priority_queue<ll> pq;
	priority_queue<ll, vector<ll>, greater<ll>> selected;
	for( int ll = 0; i < n; ++i ){
		if( used[v[i].second] || cnt == k ){
			pq.push(v[i].first);
		} else {
			candy += v[i].first;
			used[v[i].second] = true;
			selected.push(v[i].first);
			++cnt;
		}
	}
	if( cnt < k ){
		for( int i = cnt; i < k; ++i ){
			candy += pq.top();
			pq.pop();
		}
	}
	ll ans = candy + cnt*cnt;
	for( ll i = cnt-1; i > 0; --i ){
		if( pq.empty() || pq.top() < selected.top() ) break;
		candy = candy - selected.top() + pq.top();
		selected.pop(); pq.pop();
		ans = max(ans, candy+(i*i));
	} 
	cout << ans << endl;
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
#define repf(i,a,n) for(long long i=a;i<n;i++)
typedef long long ll;
const ll INF=1LL << 40; 

int main(){
    ll n,k;
    cin >> n >> k;
    vector<vector<ll> > v(n);
    rep(i,n){
        ll t,d;
        cin >> t >> d;t--;
        v[t].push_back(d);
    }

    for (auto &s : v) {
        sort(s.begin(), s.end(), greater<long long>());
        if (s.empty()) v.push_back(-INF);
    }

    sort(v.begin(), v.end(), [&](vector<long long> a, vector<long long> b) {
            return a[0] > b[0];});

    ll cur=0;
    priority_queue<ll> que;
    rep(i,k){
        cur+=v[i][0];
        repf(j,1,v[i].size()){
            que.push(v[i][j]);
        }
    }

    repf(i,k,n)rep(j,v[i].size())que.push(v[i][j]);

    ll res=cur+k*k;
    for(int i=k-1;i>=1;--i){
        ll x=v[i][0];
        ll y=que.top();
        if(x<y){
            que.pop();cur+=y;
            que.push(x);cur-=x;
        }
        res=max(res,cur+i*i);
    }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:35: error: no matching function for call to 'std::vector<std::vector<long long int> >::push_back(long long int)'
   20 |         if (s.empty()) v.push_back(-INF);
      |                        ~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; value_type = std::vector<long long int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'long long int' to 'const std::vector<std::vector<long long int> >::value_type&' {aka 'const std::vector<long long int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; value_type = std::vector<long long int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<std::vector<long long int> >::value_type&&' {aka 'std::vector<long long int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#define d_flag 0
typedef long int li;

typedef struct{
  int type;
  int point;
} sushi;

int C(const void* a,const void* b){
  return (((sushi *)b)->point) - (((sushi *)a)->point);
}

int main(){
  int n,k;
  scanf("%d%d",&n,&k);
  sushi* a=malloc(sizeof(sushi)*n);
  int i,t,d;
  int* types=malloc(sizeof(int)*n);
  for(i=0;i<n;i++)types[i]=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&(a[i].type),&(a[i].point));
    a[i].type--;
  }
  qsort(a,n,sizeof(sushi),C);
  
  if(d_flag){
    for(i=0;i<n;i++) printf("%2d ",a[i].type);
    printf(":type\n");
    for(i=0;i<n;i++) printf("%2d ",a[i].point);
    printf(":point\n\n");
  }

  li ans=0;
  li bonus=0;
  for(i=0;i<k;i++){
    ans+=a[i].point;
    if(types[a[i].type]==0)bonus++;
    types[a[i].type]++;
  }
  ans+=bonus*bonus;
  if(d_flag)printf("bonus=%d,%ld,i:%d\n",bonus,ans,i);
  li temp=ans;
  int j=k-1;
  while(bonus<k){
    if(d_flag)printf("j:%d ",j);
    while(types[a[j].type]==1)j--;
    if(d_flag)printf("-> %d\n",j);
    temp-=a[j].point;
    types[a[j].type]--;
    j--;
    if(d_flag)printf("i:%d ",i);
    while(i<n && types[a[i].type]!=0)i++;
    if(d_flag)printf("-> %d\n",i);
    if(i>=n)break;
    types[a[i].type]++;
    temp+=a[i].point;
    bonus++;
    temp+=bonus*2-1;
    if(d_flag)printf("bonus=%d,%ld,i:%d\n",bonus,temp,i);
    if(ans<temp)ans=temp;
    i++;
  }
  printf("%ld",ans);

  free(a);free(types);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: invalid conversion from 'void*' to 'sushi*' [-fpermissive]
   18 |   sushi* a=malloc(sizeof(sushi)*n);
      |            ~~~~~~^~~~~~~~~~~~~~~~~
      |                  |
      |                  void*
a.cc:20:20: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   20 |   int* types=malloc(sizeof(int)*n);
      |              ~~~~~~^~~~~~~~~~~~~~~
      |                    |
      |                    void*