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

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  cin>>n;
  int h[n],mx=0;
  rep(i,n){
      cin>>h[i];
      mx=max(h[i],mx);
  }
  int ans=0,heni;
  rep(i,10001){
      ans++;
    rep(j,n-1){
        if(h[j]!=0)h[j]--;
        if(h[j]!=0&&h[j+1]==0){
            ans++;
        }
    }
    if(h[n-1]!=0)h[n-1]--;
    /*
    for(auto k:h)cout<<k<<" ";
        cout<<ans<<endl;
        
        bool asd=true;
        rep(p,n){
            if(h[p]!=0)asd=false;
        }
        if(asd)break;
    
  }
  */
  cout<<(ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:2: error: expected '}' at end of input
   48 | }
      |  ^
a.cc:17:14: note: to match this '{'
   17 | signed main(){
      |              ^
Language: C

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

vector<ll> u, v;
int n, m = 0, a[1000];

main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    m = a[0];
    for (int i = 1; i < n; i++)
    {
        if (a[i] > a[i - 1])
            m += a[i] - a[i - 1];
    }
    cout << m << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vP p(N);
    rep(i,N){
        cin >> p[i].second >> p[i].first;
    }
    sort(p.begin(),p.end());reverse(p.begin(),p.end())
    set<int> type;
    multiset<int> kaburi;
    ll res=0,ans=0,size=0;
    rep(i,N){
        if(size<K){
            if(type.count(p[i].second)){
                kaburi.insert(p[i].first);
                size++;
                res+=p[i].first;
            }
            else{
                size++;
                type.insert(p[i].second);
                res+=p[i].first;
            }
        }
        else{
            if(type.count(p[i].second)){
                continue;
            }
            else{
                int x=*kaburi.begin();
                res-=x;
                kaburi.erase(kaburi.find(x));
                res+=p[i].first;
                type.insert(p[i].second);
            }
        }
        chmax(ans,(ll)(res+type.size()*type.size()));
    }
    cout << ans << '\n';
}/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:50:55: error: expected ';' before 'set'
   50 |     sort(p.begin(),p.end());reverse(p.begin(),p.end())
      |                                                       ^
      |                                                       ;
   51 |     set<int> type;
      |     ~~~                                                
a.cc:56:16: error: 'type' was not declared in this scope; did you mean 'wctype'?
   56 |             if(type.count(p[i].second)){
      |                ^~~~
      |                wctype
a.cc:68:16: error: 'type' was not declared in this scope; did you mean 'wctype'?
   68 |             if(type.count(p[i].second)){
      |                ^~~~
      |                wctype
a.cc:79:28: error: 'type' was not declared in this scope; did you mean 'wctype'?
   79 |         chmax(ans,(ll)(res+type.size()*type.size()));
      |                            ^~~~
      |                            wctype
Language: C++

#include <bits/stdc++.h>

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll n, k;
  cin >> n >> k;
  vector<pair<ll, ll>> v(n);
  rep(i, n) cin >> v[i].second >> v[i].first;
  sort(v.begin(), v.end(), greater<pair<ll, ll>>());
  vector<bool> vt(n + 1);
  vector<ll> s1, s2, s3;
  ll tn = 0;
  rep(i, n) {
    auto [d, t] = v[i];
    if (i < k) {
      if (vt[t]) {
        s2.push_back(d);
      } else {
        s1.push_back(d);
        vt[t] = true;
        ++tn;
      }
    } else {
      if (!vt[t]) {
        s3.push_back(d);
        vt[t] = true;
      }
    }
  }
  ll s2len = s2.size(), s3len = s3.size();
  sort(s2.begin(), s2.end(), greater<ll>());
  sort(s3.begin(), s3.end(), greater<ll>());
  rep(i, s3len) s3[i] += (tn + i + 1) * (tn + i + 1) - (tn + i) * (tn + i);
  vector<ll> s2sum(s2len + 1), s3sum(s3len + 1);
  rep(i, s2len) s2sum[i + 1] = s2sum[i] + s2[i];
  rep(i, s3len) s3sum[i + 1] = s3sum[i] + s3[i];
  ll score = 0;
  repr(i, max(0ll, s2len - s3len), s2len + 1) updatemax(score, s2sum[i] + s3sum[s2len - i]);
  score += tn * tn;
  itr(x, s1) score += x;
  cout << score << endl;
}


Compiler output:
a.cc:3:10: fatal error: atcoder/all: No such file or directory
    3 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int>t(N),d(N);
  for(int i = 0; i < N; i++) {
    cin>>t[i] >> d[i];
    t[i]--;
  } 
  multiset<P>que1;
  multiset<P>que2;
  for(int i = 0; i < N; i++) {
    que1.insert({d[i],t[i]});
  }
  vector<int>used(N);
  int ans = 0,size = 1;
  while(K--) {
    P X={-1,-1},Y={-1,-1};
    if(!que1.empty()) {
      X = *que1.rbegin();
    }
    if(!que2.empty()) {
      Y = *que2.rbegin();
    }
    if(X.first+size*size-(size-1)*(size-1) >= Y.first){
      ans += X.first+size*size-(size-1)*(size-1);
      size++;
    } 
    else {
      ans += Y.second;
      Y.erase(Y.begin());
    }
  }
  cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'P' {aka 'struct std::pair<long long int, long long int>'} has no member named 'erase'
   34 |       Y.erase(Y.begin());
      |         ^~~~~
a.cc:34:17: error: 'P' {aka 'struct std::pair<long long int, long long int>'} has no member named 'begin'
   34 |       Y.erase(Y.begin());
      |                 ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int>t(N),d(N);
  for(int i = 0; i < N; i++) {
    cin>>t[i] >> d[i];
    t[i]--;
  } 
  multiset<P>que1;
  multiset<P>que2;
  for(int i = 0; i < N; i++) {
    que1.insert({d[i],t[i]});
  }
  vector<int>used(N);
  int ans = 0,size = 1;
  while(K--) {
    P X={-1,-1},Y={-1,-1};
    if(!que1.empty()) {
      X = *que1.rbegin();
    }
    if(!que2.empty()) {
      Y = *que2.rbegin();
    }
    if(X.first+size*size-(size-1)*(size-1) >= Y.first){
      ans += X.first+size*size-(size-1)*(size-1);
      size++;
    } 
  }
  cout << ans << endl:
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:22: error: expected ';' before ':' token
   33 |   cout << ans << endl:
      |                      ^
      |                      ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int>t(N),d(N);
  for(int i = 0; i < N; i++) {
    cin>>t[i] >> d[i];
    t[i]--;
  } 
  multiset<P>que1;
  multiset<P>que2;
  for(int i = 0; i < N; i++) {
    que1.insert({d[i],t[i]});
  }
  vector<int>used(N);
  int ans = 0,size = 1;
  while(K--) {
    P X={-1,-1},Y={-1,-1};
    if(!que1.empty()) {
      X = *que1.rbegin();
    }
    if(!que2.empty()) {
      Y = *que2.rbegin();
    }
    if(X.first+size*size-(size-1)*(size-1) >= Y.first){
      ans += (X.first+size*size-(size-1)*(size-1);
      size++;
    } 
  }
  cout << ans << endl:
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:50: error: expected ')' before ';' token
   29 |       ans += (X.first+size*size-(size-1)*(size-1);
      |              ~                                   ^
      |                                                  )
a.cc:33:22: error: expected ';' before ':' token
   33 |   cout << ans << endl:
      |                      ^
      |                      ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int>t(N),d(N);
  for(int i = 0; i < N; i++) {
    cin>>t[i] >> d[i];
    t[i]--;
  } 
  multiset<P>que1;
  multiset<P>que2;
  for(int i = 0; i < N; i++) {
    que1.insert({d[i],t[i]});
  }
  vector<int>used(N);
  int ans = 0,size = 1;
  while(K--) {
    P X={-1,-1},Y={-1,-1};
    if(!que1.empty()) {
      X = *que1.rbegin();
    }
    if(!que2.empty()) {
      Y = *que2.rbegin();
    }
    if(X.first+size*size-(size-1)*(size-1) >= Y.first){
      ans += (X.first+size*size-(size-1)*(size-1);
      size++;
    } 
              }
  }
  cout << ans << endl:
              }

Compiler output:
a.cc: In function 'int main()':
a.cc:29:50: error: expected ')' before ';' token
   29 |       ans += (X.first+size*size-(size-1)*(size-1);
      |              ~                                   ^
      |                                                  )
a.cc: At global scope:
a.cc:34:3: error: 'cout' does not name a type
   34 |   cout << ans << endl:
      |   ^~~~
a.cc:35:15: error: expected declaration before '}' token
   35 |               }
      |               ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k; cin >> n >> k;
    vector<P> data(n);
    rep(i,n) {
        int t, d; cin >> t >> d;
        t--;
        data[i] = P(d,t);
    }
    sort(rall(data));
    vint num(n,0);
    ll value = 0;
    int id = k - 1;
    int n_kind = 0;
    rep(i,k) {
        value += data[i].first;
        if (num[data[i].second] == 0) n_kind++;
        num[data[i].second]++;
    }
    value += pow(n_kind,2);
    ll ans = value;
    for (int i = k; i < n; i++) {
        if (num[data[i].second] != 0) continue;
        for (int j = id; j >= -1; j--) {
            if (num[data[j].second] != 1 || j == -1) {
                id = j;
                break;
            }
        }
        if (j == -1) break;
        value += data[i].first + 2*n_kind + 1 - data[id].first;
        n_kind++;
        num[data[i].second]++;
        num[data[id].second]--;
        ans = max(ans,value);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:13: error: 'j' was not declared in this scope
   51 |         if (j == -1) break;
      |             ^
Language: C++

#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    int n, k;
    cin >> n >> k;
    P p[100005];
    for(int i = 0; i < n; i++){
        int t;
        ll d;
        cin >> t >> d;
        t--;
        p[i] = P(d, t);
    }
    sort(p, p + n, greater<P>());
    bool b[100005]{0};
    priority_queue<ll, vector<ll>, greater<ll>> que;
    ll s = 0;
    ll c = 0;
    for(int i = 0; i < k; i++){
        if(b[p[i].second]){
            que.push(p[i].first);
        }
        else{
            b[p[i].second] = true;
            c++;
        }
        s += p[i].first;
    }
    ll ans = s + c * c;
    for(int i = k; i < n; i++){
        if(b[p[i].second]) continue;
        s -= que.top();
        que.pop();
        s += p[i].first;
        c++;
        ans = max(ans, s + c * c);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |     sort(p, p + n, greater<P>());
      |     ^~~~
      |     short
Language: C++

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}



ll const mod=1e9+7;
int main() {
  int N,K,tt; ll x=0,d,res=0,tmp=0;
  cin >> N >> K;
  vector<ll> val(N,-1);
  vector<vector<ll>> td(N);
  rep(i,N) {
    cin >> tt >> d;
    t--;
    td[i] = {d,tt};
  }
  sort(td.rbegin(),td.rend());
  priority_queue<ll,vector<ll>,greater<>> pq;
  
  rep(i,N) {
    auto t = td[i];
    if (i<K){
      if (val[t[1]]==-1) {
        x++;val[t[1]]++;tmp+=t[0];
      }
      else {
        tmp+=t[0];
        pq.push({t[0]});
      }
    }
    else{
      if (val[t[1]]==-1) {
        if (pq.empty()) break;
        x++;val[t[1]]++;tmp+=t[0]-pq.top();
        pq.pop();
      }
      else continue;
    }
    chmax(res,tmp+x*x);
  }
  cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 't' was not declared in this scope
   29 |     t--;
      |     ^
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 int long long
 
const int N=1e5+5;
 
int n, k, best=0, ans=0;
int t[N], d[N], f[N];
set<int> types;
multiset<pair<int, int> > removable;
pair<int, int> a[N];
 
int32_t main()
{
    IOS;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>t[i]>>d[i];
        a[i].first=d[i];
        a[i].second=t[i];
    }
    sort(a+1, a+n+1);
    reverse(a+1, a+n+1);
    for(int i=1;i<=k;i++)
    {
        removable.insert({a[i].first, a[i].second});
        f[a[i].second]++;
        ans+=a[i].first;
        types.insert(a[i].second);
    }
    int sz=types.size();
    best=ans + sz*sz;
    for(int i=k+1;i<=n;i++)
    {
        if(types.find(a[i].second)!=types.end())
            continue;
        if(!removable.size())
            break;
        bool check=0;
        while(removable.size())
        {
            auto it=*removable.begin();
            if(f[it.second]==1)
                removable.erase(removable.find(it));
            else
            {
                check=1;
                ans-=it.first;
                f[it.second]--;
                removable.erase(removable.find(it));
                break;
            }
        }
        if(!check)
            break;
        ans+=a[i].first;
        f[a[i].second]++;
        types.insert(a[i].second);
        sz++;
        best=max(best, ans + sz*sz);
    }
    cout<<best;
    return 0;
}

Compiler output:
a.cc:5:1: error: 'cin' does not name a type
    5 | cin.tie(0);
      | ^~~
a.cc:6:2: error: 'cout' does not name a type
    6 |  cout.tie(0);
      |  ^~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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; }

using ll = long long;
using P = std::pair<ll, ll>;

ll N, K;
ll t[100010], d[100010];
std::vector<P> vs;
std::vector<ll> ps[2];
ll S[2][100010];
bool used[100010];
ll ans;

int main()
{
  std::cin >> N >> K;

  rep( i, N )
  {
    std::cin >> t[i] >> d[i];
    vs.emplace_back( P( d[i], t[i] ) );
  }

  std::sort( vs.rbegin(), vs.rend() );
  
  rep( i, N )
  {
    ll snd = 0;

    if( !used[vs[i].second] )
      snd = 1;

    ps[snd].emplace_back( vs[i].first );

    used[vs[i].second] = true;
  }

  rep( i, 2 )
  {
    rep( j, ps[i].size() )
      S[i][j+1] = S[i][j]+ps[i][j];
  }

  repi( y, ll(K-vs[0].size()), K+1 )
  {
    if( y > ps[1].size() )
      continue;

    chmax( ans, S[0][K-y]+S[1][y]+y*y );
  }

  std::cout << ans << std::endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'struct std::pair<long long int, long long int>'} has no member named 'size'
   64 |   repi( y, ll(K-vs[0].size()), K+1 )
      |                       ^~~~
a.cc:14:32: note: in definition of macro 'repi'
   14 | #define repi(i,a,b) for(int i=(a);i<(b);++i)
      |                                ^
Language: C++

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

map<int,int> t2id;
vector<vector<int>> sushis;
long long ans=0;
map<int,long long> mp;

void dp(int i, int topping_count, long long delicious, int k, int n) {
    if ( n<k ) return;
    if ( mp.count(k) && delicious<mp[k]) return; 
    if ( k==0 ) {
        ans=max(ans, delicious+topping_count*topping_count);
        mp[topping_count]=max(mp[topping_count],)
        return;
    }
    long long res, cnt=0;
    dp(i+1, topping_count, delicious, k, n-sushis[i].size());
    for(int j=0; j<sushis[i].size(); j++) {
        if ( j+1>k ) break;
        cnt+=sushis[i][j];
        dp(i+1, topping_count+1, delicious+cnt, k-j-1, n-sushis[i].size());
    }
    if ( mp.count(k)==0 ) mp[k]=0;
    mp[k]=max(mp[k],res);
}

int main() {
    int n, k, tid=0;
    scanf("%d %d", &n, &k);
    sushis.resize(n);
    for(int i=0; i<n; i++) {
        int t,d;
        scanf("%d %d", &t, &d);
        if ( t2id.count(t)==0 ) t2id[t]=tid++;
        sushis[t2id[t]].push_back(d);
    }

    for(int i=0; i<tid; i++) {
        sort(sushis[i].begin(),sushis[i].end(),greater<int>());
    }

    dp(0,0,0,k,n);
    printf("%lld\n", ans);
    return 0;
}

Compiler output:
a.cc: In function 'void dp(int, int, long long int, int, int)':
a.cc:14:49: error: expected primary-expression before ')' token
   14 |         mp[topping_count]=max(mp[topping_count],)
      |                                                 ^
Language: C++

#include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;

int main() {
    int N, K;
    cin>>N>>K;
    map<int, vector<long> > sushimap;
    vector<int> sushiarr;
    long t, d;
    for(int i=0;i<N;++i){
        cin>>t>>d;
        if(sushimap[t].size()==0)sushiarr.push_back(t);
        sushimap[t].push_back(d);
    }
    for(int i=0;i<sushiarr.size();++i){
        sort(sushimap[sushiarr[i]].begin(), sushimap[sushiarr[i]].end());
    }
    vector<long> diffsushis;
    vector<long> sushis;
    priority_queue<long, vector<long>, greater<long> >eat;
    for(int i=0;i<sushiarr.size();++i){
        diffsushis.push_back(sushimap[sushiarr[i]][sushimap[sushiarr[i]].size()-1]);
        for(int j=0;j<sushimap[sushiarr[i]].size()-1;++j){
            sushis.push_back(sushimap[sushiarr[i]][j]);
        }
    }
    sort(diffsushis.begin(), diffsushis.end());
    sort(sushis.begin(), sushis.end(), greater<long>());
    long ans = 0;
    if(diffsushis.size()>=K){
        for(int i=0;i<K;++i){
            eat.push(diffsushis[diffsushis.size()-1-i]);
            ans += diffsushis[diffsushis.size()-1-i];
        }
        ans += K*K;
        long bonus = K;
        for(int i=0;i<sushis.size();++i){
            if(ans < ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i]){
                ans = ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i];
                eat.pop();
                eat.push(sushis[i]);
                bonus--;
            }
            if(bonus == 1)break;
        }
    }
    else{
        for(int i=0;i<diffsushis.size();++i){
            eat.push(diffsushis[i]);
            ans += diffsushis[i];
        }
        ans += diffsushis.size() * diffsushis.size();
        int index = K - diffsushis.size();
        for(int i=0;i<index;++i){
            ans += sushis[i];
        }
        long bonus = diffsushis.size();
        for(int i=index;i<sushis.size();++i){
            if(ans < ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i]){
                ans = ans - bonus*bonus - eat.top() + (bonus-1)*(bonus-1) + sushis[i];
                eat.pop();
                eat.push(sushis[i]);
                bonus--;
            }
            if(bonus == 1)break;
        }
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |         sort(sushimap[sushiarr[i]].begin(), sushimap[sushiarr[i]].end());
      |         ^~~~
      |         short
a.cc:30:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   30 |     sort(diffsushis.begin(), diffsushis.end());
      |     ^~~~
      |     short
Language: C++

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> t(n), d(n);
    for (Int i = 0; i < n; i++) {
        cin >> t[i] >> d[i];
    }
    map<Int, vector<Int>> mp;
    for (Int i = 0; i < n; i++) {
        mp[t[i]].push_back(d[i]);
    }
    priority_queue<Int, vector<Int>, greater<Int>> q1;
    priority_queue<Int> q2;
    for (auto i : mp) {
        sort(all(i.se), greater<Int>());
        for (Int j = 0; j < (Int)i.se.size(); j++) {
            if (j == 0 and k > 0) {
                q1.push(i.se[j]);
                k--;
            } else {
                q2.push(i.se[j]);
            }
        }
    }
    vector<Int> res;
    while (not q1.empty()) and not q2.empty()) {
        Int dec = (q1.size() * q1.size()) - (q1.size() - 1) * (q1.size() - 1);
        if (q1.top() + dec >= q2.top()) break;
        q1.pop();
        res.push_back(q2.top());
        q2.pop();
    }
    Int ans = q1.size() * q1.size();
    for (Int i = 0; i < (Int)res.size(); i++) {
        ans += res[i];
    }
    while (not q1.empty()) {
        ans += q1.top();
        q1.pop();
    }
    dump(ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:32: error: expected identifier before 'not' token
   39 |     while (not q1.empty()) and not q2.empty()) {
      |                                ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 150000
int maxn,type,sum;
struct str{
	int x,y;
}st[N];
map<int,int> mp;
stack<int> s;
bool cmp(str a,str b){
	return a.y>b.y;
}

int  main(){
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>st[i].x>>st[i].y;
  sort(st+1,st+n+1,cmp);
  for(int i=1;i<=k;i++){
  	if(!mp[st[i].x]){
  		mp[st[i].x]=1;type++;
  	}
  	else s.push(st[i].y);
  	sum+=st[i].y;
  	if(maxn<1ll*type*type+sum)maxn=1ll*type*type+sum;
  }
  for(int i=k+1;i<=n;i++){
  	if(s.empty())break;
  	if(mp[st[i].x])continue;
  	mp[st[i].x]=1;type++;sum-=s.pop();
  	s.pop();sum+=st[i].y;
  	if(maxn<1ll*type*type+sum)maxn=1ll*type*type+sum;
  }
  cout<<maxn;
	return 0*1ll;
}
/*题意：有n个寿司，每个有一个品种，一个美味值，选k个，总美味值等于选的品种数的平方加美味值的和，求最大的总美味值。
分析：选寿司时应该美味值的优先级高。先选出美味值最高的k个，计算他们的总美味值，再依次增加选取种类的数量，每次更新答案。
思路：这个题可以用贪心。第一种情况是把美味值最大的k个加起来，第二种是取的种类数越多越好。在种类数增多的过程中也要更新答案。注意long long。
————————————————

原文链接：https://blog.csdn.net/zekunzhao/article/details/93964955 */

Compiler output:
a.cc: In function 'int main()':
a.cc:31:40: error: void value not ignored as it ought to be
   31 |         mp[st[i].x]=1;type++;sum-=s.pop();
      |                                   ~~~~~^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 150000
ll maxn,type,sum;
struct str{
	ll x,y;
}st[N];
map<int,int> mp;
stack<int> s;
bool cmp(str a,str b){
	return a.y>b.y;
}

int  main(){
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>st[i].x>>st[i].y;
  sort(st+1,st+n+1,cmp);
  for(int i=1;i<=k;i++){
  	if(!mp[st[i].x]){
  		mp[st[i].x]=1;type++;
  	}
  	else s.push(st[i].y);
  	sum+=st[i].y;
  	if(maxn<type*type+sum)maxn=type*type+sum;
  }
  for(int i=k+1;i<=n;i++){
  	if(s.empty())break;
  	if(mp[st[i].x])continue;
  	mp[st[i].x]=1;type++;sum-=s.pop();
  	s.pop();sum+=st[i].y;
  	if(maxn<type*type+sum)maxn=type*type+sum;
  }
  cout<<maxn;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:40: error: void value not ignored as it ought to be
   31 |         mp[st[i].x]=1;type++;sum-=s.pop();
      |                                   ~~~~~^~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    int n,k; cin >> n >> k;
    vector<P> ve;
    rep(i,n){
        int t,d; cin >> t >> d;
        ve.pb({d,t});
    }
    sort(ALL(ve),greater<P>());
    vector<P> v;
    vector<bool> bo(n+1,0);
    rep(i,n){
        if(i==0){
            v.pb({ve[0].fi,1});
            bo[ve[0].se]=1;
            continue;
        }
        if(!bo[ve[i].se]){
            v.pb({ve[i].fi,1});
            bo[ve[i].se]=1;
        }else{
            v.pb({ve[i].fi,0});
        }
    }
    sort(ALL(v),greater<P>());
    priority_queue<P> x;
    priority_queue<P,vector<P>,greater<P>> s;
    vector<ll> ans(n+1,0);
    int st=0;
    ll res=0;
    rep(i,n){
        if(i>=k){
            x.push({v[i].se,v[i].fi});
            continue;
        }
        res+=v[i].fi;
        st+=v[i].se;
        s.push({v[i].se,v[i].fi});
    }
    ans[st]=res;
    for(int i=st+1;i<=n;i++){
        P a=s.top();
        P b=x.top();
        s.pop(); x.pop();
        if(a.fi==0 && b.fi==1){
            ans[i]=ans[i-1]+b.se-a.se;
            s.push(b);
            x.push(a);
        }else break;
    }
    ll ret=0;
    rep(i,n+1){
        //cout << ans[i] << " ";
        if(ans[i]!=0){
            ll ress=ans[i];
            ress+=i*i;
            chmax(ret,ress);
        }
    }
    cout << ret << endl;
}


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

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int N,K;
  cin >> N >> K;
  vector<vector<int>> G(N);
  for(int i=0; i<N; i++){
    int t,d;
    cin >> t >> d;
    t--;
    G[t].push_back(d);
  }
  priority_queue<pair<ll,ll>> que;
  for(auto &v: G){
    sort(v.begin(),v.end(),greater<ll>());
    for(int j=0; j<v.size(); j++){
      if(j){
        que.push(make_pair(G[i][j],0));
      }else{
        que.push(make_pair(G[i][j],1));
      }
    }
  }
  ll ans=0,res=0;
  ll var=0;
  priority_queue<ll,vector<ll>,greater<ll>> que2;
  for(int i=0; i<K; i++){
    pair<ll,ll> p;
    p = que.top();
    que.pop();
    ans += p.first;
    if(p.second == 1){
      var++;
    }else{
      que2.push(p.first);
    }
    res += p.first;
  }
  ans = res + var*var;
  while(!que.empty() || !que2.empty()){
    pair<ll,ll> p;
    p = que.top();
    que.pop();
    if(p.second == 0){
      continue;
    }
    ll q;
    q = que2.top();
    que2.pop();
    var++;
    res -= q;
    res += p.first;
    ans = max(ans,res + var*var);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:30: error: 'i' was not declared in this scope
   52 |         que.push(make_pair(G[i][j],0));
      |                              ^
a.cc:54:30: error: 'i' was not declared in this scope
   54 |         que.push(make_pair(G[i][j],1));
      |                              ^
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, long long K, std::vector<long long> t, std::vector<long long> d){
  vector<vector<long long>> V(N, vector<long long>());
  vector<long long> top;
  vector<long long> rest;
  for (int i = 0; i < N; ++i) {
    V[t[i]-1].push_back(d[i]);
  }
  for (int i = 0; i < N; ++i) {
    if (V[i].size() > 0) {
      sort(V[i].begin(), V[i].end());
      top.push_back(V[i].back());
      for (int j = 0; j < V[i].size()-1; ++j) {
        rest.push_back(V[i][j]);
      }
    }
  }
  sort(top.begin(), top.end());
  sort(rest.begin(), rest.end());
  vector<long long> cumtop(top.size()+1, 0);
  vector<long long> cumrest(rest.size()+1, 0);
  for (int i = 0; i < top.size(); ++i) {
    cumtop[i+1] = cumtop[i] + top[i];
  }
  for (int i = 0; i < rest.size(); ++i) {
    cumrest[i+1] = cumrest[i] + rest[i];
  }
  long long ret = 0;
  long long max_t = staic_cast<long long>(top.size());
  long long max_r = staic_cast<long long>(rest.size());
  long long tmp;
  for (int i = 0; i <= min(max_t, K); ++i) {
    tmp = i*i;
    tmp += cumtop.back() - cumtop[max_t-i];
    if (max_r-(K-i) < 0) continue;
    tmp += cumrest.back() - cumrest[max_r-(K-i)];
    ret = max(ret, tmp);
  }
  std::cout << ret << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> t(N);
  std::vector<long long> d(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&t[i]);
    scanf("%lld",&d[i]);
  }
  solve(N, K, std::move(t), std::move(d));
  return 0;
}


Compiler output:
a.cc: In function 'void solve(long long int, long long int, std::vector<long long int>, std::vector<long long int>)':
a.cc:46:21: error: 'staic_cast' was not declared in this scope; did you mean 'static_assert'?
   46 |   long long max_t = staic_cast<long long>(top.size());
      |                     ^~~~~~~~~~
      |                     static_assert
a.cc:46:32: error: expected primary-expression before 'long'
   46 |   long long max_t = staic_cast<long long>(top.size());
      |                                ^~~~
a.cc:47:32: error: expected primary-expression before 'long'
   47 |   long long max_r = staic_cast<long long>(rest.size());
      |                                ^~~~
Language: C++

#include <iostream>
#include <queue>
#include <algorithm>
#include <numeric>
using namespace std;

long long INF = 1LL<<40;



int main() {
    long long N, K; 
  cin >> N >> K;
  
    long long int s[100010][100010]={0};
  
    for (int i = 0; i < N; ++i) {
        long long t, d; 
      
      cin >> t >> d; --t;
        s[t].push_back(d);
    }

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

   
    sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) {
            return a[0] > b[0];});
 
    
    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]);

    
    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:21:14: error: request for member 'push_back' in 's[t]', which is of non-class type 'long long int [100010]'
   21 |         s[t].push_back(d);
      |              ^~~~~~~~~
a.cc:26:16: error: request for member 'begin' in 'v', which is of non-class type 'long long int [100010]'
   26 |         sort(v.begin(), v.end(), greater<long long>());
      |                ^~~~~
a.cc:26:27: error: request for member 'end' in 'v', which is of non-class type 'long long int [100010]'
   26 |         sort(v.begin(), v.end(), greater<long long>());
      |                           ^~~
a.cc:28:15: error: request for member 'empty' in 'v', which is of non-class type 'long long int [100010]'
   28 |         if (v.empty()) v.push_back(-INF);
      |               ^~~~~
a.cc:28:26: error: request for member 'push_back' in 'v', which is of non-class type 'long long int [100010]'
   28 |         if (v.empty()) v.push_back(-INF);
      |                          ^~~~~~~~~
a.cc:32:12: error: request for member 'begin' in 's', which is of non-class type 'long long int [100010][100010]'
   32 |     sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) {
      |            ^~~~~
a.cc:32:23: error: request for member 'end' in 's', which is of non-class type 'long long int [100010][100010]'
   32 |     sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) {
      |                       ^~~
a.cc:40:34: error: request for member 'size' in 's[i]', which is of non-class type 'long long int [100010]'
   40 |         for (int j = 1; j < s[i].size(); ++j) que.push(s[i][j]);
      |                                  ^~~~
a.cc:42:58: error: request for member 'size' in 's[i]', which is of non-class type 'long long int [100010]'
   42 |     for (int i = K; i < N; ++i) for (int j = 0; j < s[i].size(); ++j) que.push(s[i][j]);
      |                                                          ^~~~
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 k = sc.nextInt();
 
        int[][] arr = new int[n][2];
        for (int i = 0; i < n; i++) {
            arr[i] = new int[] {sc.nextInt(), sc.nextInt()};
        }
        Arrays.sort(arr, (a1, a2) -> a2[1] - a1[1]);
 
        long sum = 0;
        long kind = 0;
 
        int[] countKind = new int[n+1];
        for (int i = 0; i < k; i++) {
            sum += arr[i][1];   // summing delicious
            if (countKind[arr[i][0]] == 0) kind++;
            countKind[arr[i][0]]++;
        }
 
        long ans = kind * kind + sum;
        int idx = k-1;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
 
        int[][] arr = new int[n][2];
        for (int i = 0; i < n; i++) {
            arr[i] = new int[] {sc.nextInt(), sc.nextInt()};
        }
        Arrays.sort(arr, (a1, a2) -> a2[1] - a1[1]);
 
        long sum = 0;
        long kind = 0;
 
        int[] countKind = new int[n+1];
        for (int i = 0; i < k; i++) {
            sum += arr[i][1];   // summing delicious
            if (countKind[arr[i][0]] == 0) kind++;
            countKind[arr[i][0]]++;
        }
 
        long ans = kind * kind + sum;
        int idx = k-1;
        for (int i = k; i < n; i++) {
            if (countKind[arr[i][0]] == 0) {
                while (idx > 0 && countKind[arr[idx][0]] == 1) idx--;

                if (idx > 0) {
                    countKind[arr[i][0]]++;
                    countKind[arr[idx][0]]--;
                    kind++;

                    sum = sum - arr[idx--][1] + arr[i][1];
                    ans = Math.max(ans, sum + kind * kind);
                }
            }
        }
        System.out.println(ans);
    }
}
        System.out.println(ans);
    }
}

Compiler output:
Main.java:27: error: illegal start of expression
import java.util.*;
^
Main.java:27: error: <identifier> expected
import java.util.*;
                 ^
Main.java:27: error: illegal start of expression
import java.util.*;
                  ^
Main.java:29: error: illegal start of expression
public class Main {
^
Main.java:70: error: <identifier> expected
        System.out.println(ans);
                          ^
Main.java:70: error: <identifier> expected
        System.out.println(ans);
                              ^
Main.java:72: error: class, interface, enum, or record expected
}
^
7 errors
Language: Java

import java.util.Comparator;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[][] td = new int[n][2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                td[i][j] = sc.nextInt();
            }
        }
        long ans = solve(n, k, td);
        System.out.println(ans);

    }

    private static long solve(int n, int k, int[][] td) {
        D_VariousSushi2 main = new D_VariousSushi2();

        Queue<Pair> q = new PriorityQueue<>(Comparator.reverseOrder());
        Queue<Pair> old = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            Pair p = main.new Pair(td[i][0], td[i][1]);
            q.add(p);
        }

        long ans = 0;
        Set<Integer> s = new HashSet<>();
        for (int i = 0; i < k; i++) {
            Pair p = q.poll();
            ans += p.delicious;
            s.add(p.typeNum);
            old.add(p);
        }
        long bounus = s.size() * s.size();
        ans += bounus;

        int qLimit = q.size();
        long[] ansarr = new long[k];
        for (int i = 0; i < qLimit; i++) {
            Pair p = q.poll();
            if (s.contains(p.typeNum)) {
                continue;
            }

            long d = p.delicious;
            s.add(p.typeNum);
            long bias = s.size() * s.size();
            long tmp = ans - old.poll().delicious - bounus + bias + d;
            bounus = bias;
            // System.out.printf("ans%s tmp%s \n", ans, tmp);
            ansarr[i] = tmp;
        }


        for (int i = 0; i < k; i++) {
            ans = Math.max(ans, ansarr[i]);
        }
        return ans;
    }

    class Pair implements Comparable<Pair> {
        int typeNum;
        int delicious;

        Pair(int t, int d) {
            this.typeNum = t;
            this.delicious = d;
        }

        @Override
        public int compareTo(Pair o) {
            return this.delicious - o.delicious;
        }

        @Override
        public String toString() {
            return String.format("%s:%s", this.typeNum, this.delicious);
        }
    }
}


Compiler output:
Main.java:27: error: cannot find symbol
        D_VariousSushi2 main = new D_VariousSushi2();
        ^
  symbol:   class D_VariousSushi2
  location: class Main
Main.java:27: error: cannot find symbol
        D_VariousSushi2 main = new D_VariousSushi2();
                                   ^
  symbol:   class D_VariousSushi2
  location: class Main
2 errors
Language: C++

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

typedef struct {
  int t;
  int d;
} sushi;

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> sushi(N);
  
  for(int i=0 ,i<N; i++) {
    int T, D;
    cin >> T >> D;
    sushi[i].t = T;
    sushi[i].d = D;
  }
  
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'vector' was not declared in this scope
   14 |   vector<int> sushi(N);
      |   ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <set>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:14:10: error: expected primary-expression before 'int'
   14 |   vector<int> sushi(N);
      |          ^~~
a.cc:16:17: error: expected ';' before '<' token
   16 |   for(int i=0 ,i<N; i++) {
      |                 ^
      |                 ;
a.cc:16:17: error: expected primary-expression before '<' token
a.cc:19:10: error: structured binding declaration cannot have type 'sushi'
   19 |     sushi[i].t = T;
      |          ^~~
a.cc:19:10: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:19:11: error: redeclaration of 'auto i'
   19 |     sushi[i].t = T;
      |           ^
a.cc:16:11: note: 'int i' previously declared here
   16 |   for(int i=0 ,i<N; i++) {
      |           ^
a.cc:19:13: error: expected initializer before '.' token
   19 |     sushi[i].t = T;
      |             ^
a.cc:19:13: error: expected ';' before '.' token
a.cc:20:10: error: structured binding declaration cannot have type 'sushi'
   20 |     sushi[i].d = D;
      |          ^~~
a.cc:20:10: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:20:13: error: expected initializer before '.' token
   20 |     sushi[i].d = D;
      |             ^
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

pair<int, int> d[100000];
int x[100000];

int main() {
    int n, k;
    cin >> n >> k;
    
    rep(i, n) {
        cin >> d[i].first >> d[i].second;
    }

    sort(d, d+n);

    rep(i, n) {
        if( i == n-1 || d[i].first != d[i+1].first ) {
            x[d[i].first - 1] = d[i].second;
            d[i] = {};
        }

        swap(d[i].first, d[i].second);
    }

    sort(d, d+n, greater<pair<int, int>>());
    sort(x, x+n, greater<int>());

    for(int i = 1; i < n; i++) {
        d[i].first += d[i-1].first;
    }

    partial_sum(x, x+n, x);

    int ans = 0;

    for(int i = 1; i <= k; i++) {
        if(i > 1 && x[i-1] == x[i-2]) {
            break;
        }

        ans = max(ans, i*i + x[i-1] + (i < k ? d[k-i-1].first : 0) );
    }
    
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:5: error: 'partial_sum' was not declared in this scope
   44 |     partial_sum(x, x+n, x);
      |     ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 1e+12;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
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; }
#define int long long

//ある量を決めるとどうすべきかがgreedyに決まる
//探索すべきものを絞る

//ちょうどを以上にしても大丈夫
//x種類選んだ状態とx+1種類選んだ状態との間の差分をいかに素早く更新できるようなデータの持ち方を工夫する

void solve() {
    int n, k; cin >> n >> k;
    vector<vector<int>> s(n);
    rep(i, n) {
        int t, d; cin >> t >> d;
        s[t].push_back(d);
    }
    for(auto &v : s) {
        sort(all(v), greater<int>());
        if(v.empty()) v.push_back(-INF); //番兵
    }

    sort(all(s), [&](vector<int> a, vector<int> b) {return a[0] > b[0];});
    
    priority_queue<int> pque;
    int cur = 0;
    rep(i, k) {
        cur += s[i][0];
        rep1(j, (int)s[i].size()) {
            pque.push(s[i][j]);
        }
    }
    Rep(i, k, n) {
        rep(j, (int)s[i].size) {
            pque.push(s[i][j]);
        }
    }

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:80:26: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   80 |         rep(j, (int)s[i].size) {
a.cc:29:32: note: in definition of macro 'rep'
   29 | #define rep(i,n) for(int i=0;i<n;i++)
      |                                ^