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

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

int t[100005];
ll d[100005];
vector<pair<ll,int> >vec;
mp<int,int>mp;

int main() {
	
	int N,K;
	
	scanf("%d %d",&N,&K);
	
	int i,j;
	
	for(i=0;i<N;i++){
		scanf("%d %lld",&t[i],&d[i]);
		vec.push_back(make_pair(d[i],t[i]));
	}
	
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	
	int cnt=0;
	ll ans=0ll;
	ll color=0ll;
	
	while(1){
		if(cnt==K){break;}
		
		for(i=0;i<vec.size();i++){
			if(mp[vec[i].first]==0){break;}
		}
		for(j=0;j<vec.size();j++){
			if(mp[vec[j].first]==1){break;}
		}
		ll add=vec[i].first+((color+1ll)*(color+1ll));
		if(i<j){
			ans+=vec[i].first;
			color+=1ll;
			mp[vec[i].second]=1;
			cnt++;
			vec.erase(vec.begin()+i);
		}
		else{
			if(add<=vec[j].first){
				ans+=vec[j].first;
				cnt++;
				vec.erase(vec.begin()+j);
			}
			else{
				ans+=vec[i].first;
				color+=1ll;
				mp[vec[i].second]=1;
				cnt++;
				vec.erase(vec.begin()+i);
			}
		}
	}
	
	printf("%lld\n",ans+(color*color));
	
	
	return 0;
}

Compiler output:
a.cc:14:1: error: 'mp' does not name a type
   14 | mp<int,int>mp;
      | ^~
a.cc: In function 'int main()':
a.cc:40:28: error: 'mp' was not declared in this scope
   40 |                         if(mp[vec[i].first]==0){break;}
      |                            ^~
a.cc:43:28: error: 'mp' was not declared in this scope
   43 |                         if(mp[vec[j].first]==1){break;}
      |                            ^~
a.cc:49:25: error: 'mp' was not declared in this scope
   49 |                         mp[vec[i].second]=1;
      |                         ^~
a.cc:62:33: error: 'mp' was not declared in this scope
   62 |                                 mp[vec[i].second]=1;
      |                                 ^~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>


using namespace std;
const int MAX = 1e5;
const long long INF = 1e17;
typedef pair<long long, long long> P;
bool flag[MAX + 1] = { 0 };
int k = 0;
long long kmax[MAX + 1] = { 0 };
long long ans = 0;
long long tt[MAX + 1] = { 0 };
priority_queue<P, vector<P>, greater<P>>que;
priority_queue<P, vector<P>>que2;

int main() {
	for (int i = 0; i < MAX + 1; i++) {
		kmax[i] = -INF;
	}
	int K, N;
	cin >> N >> K;
	vector<P> p;
	long long temp, tempp;
	for (int i = 0; i < N; i++) {
		cin >> temp >> tempp;
		p.push_back(P(tempp, temp));
	}
	sort(p.rbegin(), p.rend());
	temp = 0;
	for (int i = 0; i < K; i++) {
		temp += p[i].first;
		if (flag[p[i].second] == false) {
			flag[p[i].second] = true;
			k++;
		}
		else {
			que.push(P(p[i].first, p[i].second));
		}
	}
	kmax[k] = temp;
	for (int i = k; i < N; i++) {
		if (!flag[p[i].second]) {
			flag[p[i].second] = 1;
			if (que.empty == 0) {
				P x = que.top(); que.pop();
				long long cc = x.first;
				kmax[i + 1] = kmax[i] - p[i].first + cc;
			}
		}
	}
	/*
	for (int i = K; i < N; i++) {
		if (flag[p[i].second] == false) {
			tt[p[i].second] = max(tt[p[i].second], p[i].first);
		}
	}
	
	for (int i = 0; i <= N; i++) {
		if (tt[i] != 0)que2.push(P(tt[i], i));
	}
	if (que.empty() == true || que2.empty() == true) {}
	else {
		for (int i = k + 1; i <= N; i++) {
			kmax[i] = kmax[i - 1];
			P temporary = que.top(); que.pop();
			kmax[i] -= temporary.first;
			P temporary2 = que2.top(); que2.pop();
			kmax[i] += temporary2.first;
			if (que.empty() == true || que2.empty() == true)break;
		}
	}
	*/

	for (int i = k; i <= N; i++) {
		if (kmax[i] == -INF)continue;
		ans = max(kmax[i] + i * i, ans);
	}

	cout << ans << endl;

	return 0;
}
/*
int N;
cin >> N;
int h[100];
for (int i = 0; i < N; i++) {
cin >> h[i];
}
int ans = 0;
bool flag = 0;
for (int i = 0; i < 100; i++) {
flag = false;
for (int j = 0; j < N; j++) {
if (h[j] > 0) {
h[j]--;
flag = true;
}
else if (flag == true) {
flag = false;
ans++;
}
}
if (flag == true) {
ans++;
}
}
cout << ans << endl;
return 0;
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:48:33: error: invalid use of member function 'bool std::priority_queue<_Tp, _Sequence, _Compare>::empty() const [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >]' (did you forget the '()' ?)
   48 |                         if (que.empty == 0) {
      |                             ~~~~^~~~~
      |                                      ()
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;
const int MAX = 1e5;
typedef pair<long long,long long> P;
bool flag[MAX+1] = { 0 };
int k = 0;
long long kmax[MAX+1] = { 0 };
long long ans = 0;
long long tt[MAX+1] = { 0 };
priority_queue<P, vector<P>, greater<P>>que;
priority_queue<P, vector<P>>que2;

int main() {
	int K, N;
	cin >> N >> K;
	vector<P> p;
	long long temp, tempp;
	for (int i = 0; i < N; i++) {
		cin >> temp >> tempp;
		p.push_back(P(tempp, temp));
	}
	sort(p.rbegin(), p.rend());
	temp = 0;
	for (int i = 0; i < K; i++) {
		temp += p[i].first;
		if (flag[p[i].second] == false) {
			flag[p[i].second] = true;
			k++;
		}
		else {
			que.push(P(p[i].first, p[i].second));
		}
	}
	kmax[k] = temp;

	for (int i = K; i < N; i++) {
		if (flag[p[i].second] == false) {
			tt[p[i].second] = max(tt[p[i].second], p[i].first);
		}
	}
	for (int i = 0; i < N; i++) {
		if (tt[i]!=0)que2.push(P(tt[i], i));
	}
	if (que.empty() == true || que2.empty() == true) {}
	else {
	for (int i = k + 1; i <= N; i++) {
		kmax[i] = kmax[i - 1];
		P temporary = que.top(); que.pop();
		kmax[i] -= temporary.first;
		P temporary = que2.top(); que2.pop();
		kmax[i] += temporary.first;
		if (que.empty() == true || que2.empty() == true)break;
	}
}
	for (int i = k; i <= N; i++) {
		if (kmax[i] == 0)continue;
		ans = max(kmax[i] + i * i, ans);
	}

	cout << ans << endl;	
	
	return 0;
}
	/*
	int N;
	cin >> N;
	int h[100];
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int ans = 0;
	bool flag = 0;
	for (int i = 0; i < 100; i++) {
		flag = false;
		for (int j = 0; j < N; j++) {
			if (h[j] > 0) {
				h[j]--;
				flag = true;
			}
			else if (flag == true) {
				flag = false;
				ans++;
			}
		}
		if (flag == true) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
	*/

Compiler output:
a.cc: In function 'int main()':
a.cc:55:19: error: redeclaration of 'P temporary'
   55 |                 P temporary = que2.top(); que2.pop();
      |                   ^~~~~~~~~
a.cc:53:19: note: 'P temporary' previously declared here
   53 |                 P temporary = que.top(); que.pop();
      |                   ^~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;
const int MAX = 1e5;
typedef pair<long long,long long> P;
bool flag[MAX+1] = { 0 };
int k = 0;
long long kmax[MAX+1] = { 0 };
long long ans = 0;
long long tt[MAX+1] = { 0 };
priority_queue<P, vector<P>, greater<P>>que;
priority_queue<P, vector<P>>que2;

int main() {
	int K, N;
	cin >> N >> K;
	vector<P> p;
	long long temp, tempp;
	for (int i = 0; i < N; i++) {
		cin >> temp >> tempp;
		p.push_back(P(tempp, temp));
	}
	sort(p.rbegin(), p.rend());
	temp = 0;
	for (int i = 0; i < K; i++) {
		temp += p[i].first;
		if (flag[p[i].second] == false) {
			flag[p[i].second] = true;
			k++;
		}
		else {
			que.push(P(p[i].first, p[i].second));
		}
	}
	kmax[k] = temp;

	for (int i = K; i < N; i++) {
		if (flag[p[i].second] == false) {
			tt[p[i].second] = max(tt[p[i].second], p[i].first);
		}
	}
	for (int i = 0; i < N; i++) {
		if (tt[i])que2.push(P(tt[i], i));
	}
	if (que.empty() == true || que2.empty() = true) {}
	else {
	for (int i = k + 1; i < N; i++) {
		kmax[i] = kmax[i - 1];
		P temporary = que.top(); que.pop();
		kmax[i] -= temporary.first;
		temporary = que2.top(); que2.pop();
		kmax[i] += temporary.first;
		if (que.empty() == true || que2.empty() == true)break;
	}
}
	for (int i = k; i <= N; i++) {
		if (kmax[i] == 0)continue;
		ans = max(kmax[i] + i * i, ans);
	}

	cout << ans << endl;	
	
	return 0;
}
	/*
	int N;
	cin >> N;
	int h[100];
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int ans = 0;
	bool flag = 0;
	for (int i = 0; i < 100; i++) {
		flag = false;
		for (int j = 0; j < N; j++) {
			if (h[j] > 0) {
				h[j]--;
				flag = true;
			}
			else if (flag == true) {
				flag = false;
				ans++;
			}
		}
		if (flag == true) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
	*/

Compiler output:
a.cc: In function 'int main()':
a.cc:49:33: error: lvalue required as left operand of assignment
   49 |         if (que.empty() == true || que2.empty() = true) {}
      |             ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
Language: C++

#include <cstdio>
#include <algorithm>
#include <map>
typedef long long ll;
#define PII pair<ll, ll>
#define T second
#define D first
using namespace std;

ll n, k, sum, ans;
PII a[100005];
map<ll, ll> mp;
int main() {
	ll i, j;
	scanf("%lld%lld", &n, &k);
	for(i=0; i<n; i++) scanf("%lld%lld", &a[i].T, &a[i].D);
	sort(a, a+n, greater<PII>());
	for(i=0; i<k; i++) {
		mp[a[i].T]++;
		sum += a[i].D;
	}
	ans = sum + mp.size() * mp.size();
	j = k - 1;
	for(; i<n; i++) {
		if(mp.count(a[i].T)) continue;
		mp[a[i].T]++;
		while(j>=0 && mp[a[j].T]==1) j--;
		if(j<0) break;
		sum += a[i].D - a[j].D;
		mp[a[j].T]--;
		ans = max(ans, sum + mp.size() * mp.size());
	}
	printf("%lld", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:26: error: no matching function for call to 'max(ll&, long long unsigned int)'
   31 |                 ans = max(ans, sum + mp.size() * mp.size());
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:31:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   31 |                 ans = max(ans, sum + mp.size() * mp.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:31:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |                 ans = max(ans, sum + mp.size() * mp.size());
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
set<int>s;
long long int dp[100005][100005];
long long int ma=0;
long long int  call(vector<pair<int,int>>v,int n,int k,long long int sum)
{   if(dp[n][k]>0)
       return dp[n][k]; 
   if(n==0&&k==0)
     {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;  
		 return ma ;
	}
	if(n==0) return 0;
    if(k==0)
	 {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;
		   return ma;
		  }	 
	else
	{  s.insert(v[n-1].first);
	 dp[n-1][k-1]= call(v,n-1,k-1,sum+v[n-1].second);
	  s.erase(v[n-1].first);
	  dp[n-1][k]=  call(v,n-1,k,sum);	 
	}
	return max(dp[n-1][k-1],dp[n-1][k]);
}
int main()
{  int n,k;cin>>n>>k;
  vector<pair<int,int>>v;
   int a,b;
  for(int i=0;i<n;i++)
   {
	 cin>>a>>b;
    v.push_back(make_pair(a,b));
   }
 call(v,n,k,0); 
 cout<<ma; 
   
}



Compiler output:
/tmp/ccRZjMMA.o: in function `call(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, int, int, long long)':
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
a.cc:(.text+0x108): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
a.cc:(.text+0x10f): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
a.cc:(.text+0x167): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
a.cc:(.text+0x1aa): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
a.cc:(.text+0x1b1): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
/tmp/ccRZjMMA.o: in function `main':
a.cc:(.text+0x4a3): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccRZjMMA.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
set<int>s;
long long int dp[100005][100005];
long long int ma=0;
long long int  call(vector<pair<int,int>>v,int n,int k,long long int sum)
{   if(dp[n][k]>0)
       return dp[n][k]; 
   if(n==0&&k==0)
     {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;  
		 return ma ;
	}
	if(n==0) return 0;
    if(k==0)
	 {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;
		   return ma;
		  }	 
	else
	{  s.insert(v[n-1].first);
	 dp[n][k]= call(v,n-1,k-1,sum+v[n-1].second);
	  s.erase(v[n-1].first);
	  dp[n-1][k]=  call(v,n-1,k,sum);	 
	}
	return dp[n][k];
}
int main()
{  int n,k;cin>>n>>k;
  vector<pair<int,int>>v;
   int a,b;
  for(int i=0;i<n;i++)
   {
	 cin>>a>>b;
    v.push_back(make_pair(a,b));
   }
 call(v,n,k,0); 
 cout<<ma; 
   
}



Compiler output:
/tmp/ccTLFKlk.o: in function `call(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, int, int, long long)':
a.cc:(.text+0xbb): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
a.cc:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
a.cc:(.text+0x157): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
a.cc:(.text+0x197): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
a.cc:(.text+0x19e): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
/tmp/ccTLFKlk.o: in function `main':
a.cc:(.text+0x43f): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccTLFKlk.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
set<int>s;
int dp[100005][100005];
long long int ma=0;
long long int  call(vector<pair<int,int>>v,int n,int k,long long int sum)
{   if(dp[n][k]>0)
       return dp[n][k]; 
   if(n==0&&k==0)
     {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;  
		 return ma ;
	}
	if(n==0) return 0;
    if(k==0)
	 {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;
		   return ma;
		  }	 
	else
	{  s.insert(v[n-1].first);
	 dp[n][k]= call(v,n-1,k-1,sum+v[n-1].second);
	  s.erase(v[n-1].first);
	  dp[n-1][k]=  call(v,n-1,k,sum);	 
	}
	return dp[n][k];
}
int main()
{  int n,k;cin>>n>>k;
  vector<pair<int,int>>v;
   int a,b;
  for(int i=0;i<n;i++)
   {
	 cin>>a>>b;
    v.push_back(make_pair(a,b));
   }
 call(v,n,k,0); 
 cout<<ma; 
   
}



Compiler output:
/tmp/ccto5IH3.o: in function `call(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, int, int, long long)':
a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
a.cc:(.text+0x101): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
a.cc:(.text+0x19d): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
/tmp/ccto5IH3.o: in function `main':
a.cc:(.text+0x43f): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccto5IH3.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
set<int>s;
int dp[100005][100005];
long long int ma=0;
long long int  call(vector<pair<int,int>>v,int n,int k,long long int sum)
{   if(dp[n][k]>0)
       return dp[n][k]; 
   if(n==0&&k==0)
     {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;  
		 return ma ;
	}
	if(n==0) return 0;
    if(k==0)
	 {  if(ma<s.size()*s.size()+sum)
	 	   ma= s.size()*s.size()+sum;
		   return ma;
		  }	 
	else
	{  s.insert(v[n-1].first);
	 dp[n][k]= call(v,n-1,k-1,sum+v[n-1].second);
	  s.erase(v[n-1].first);
	  dp[n-1][k]=  call(v,n-1,k,sum);	 
	}
	return dp[n][k];
}
int main()
{  int n,k;cin>>n>>k;
  vector<pair<int,int>>v;
   int a,b;
  for(int i=0;i<n;i++)
   {
	 cin>>a>>b;
    v.push_back(make_pair(a,b));
   }
 call(v,n,k,0); 
 cout<<ma; 
   
}



Compiler output:
/tmp/ccmrwZvi.o: in function `call(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >, int, int, long long)':
a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
a.cc:(.text+0x101): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
a.cc:(.text+0x19d): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
/tmp/ccmrwZvi.o: in function `main':
a.cc:(.text+0x43f): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/ccmrwZvi.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	vector<pair<LL,int>> d(N);
	repp(i,0,N) cin >> d[i].second >> d[i].first;
	sort(d.begin(),d.end(),greater<pair<LL,int>>());
	vector<int> b(N+1,0);
	LL x = 0;
	LL s = 0;
	stack<LL> sushi;
	repp(i,0,K){
		s += d[i].first;
		if(b[d[i].second]) sushi.push(d[i].first);
		else {
			b[d[i].second] = 1;
			++x;
		}
	}
	int p = K;
	LL ans = s+x*x;
	while(!sushi.empty()){
		while(p < N && b[d[p].second]) ++p;
		if(p == N) break;
		b[d[p].second] = 1;
		s += d[p].first - sushi.top();
		sushi.pop();
		++x;
		ans = max(ans,s+x*x);
	}
	cout << ans << endl
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:28: error: expected ';' before 'return'
   37 |         cout << ans << endl
      |                            ^
      |                            ;
   38 |         return 0;
      |         ~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct sushi{
  int t;
  LL d;

  bool operator<(const sushi &r) const{
    return d<r.d;
  }
};

int main(){
  int n, k;
  cin>>n>>k;
  priority_queue<sushi> q;
  priority_queue<LL> q2;
  sushi s;
  LL slist[n];
  REP(i, n) slist[i]=0;

  REP(i, n){
    cin>>s.t>>s.d;
    --s.t;
    q.push(s);
  }

  if(n==1){
    cout<<1+s.d<<endl;
    return 0;
  }

  LL sum=0;
  LL kind=0;
  REP(i, k){
    sushi ss = q.top();
    q.pop();
    if(slist[ss.t]==0) ++kind;
    else q2.push(-ss.d);
    ++slist[ss.t];
    sum += ss.d;
  }
  LL ans = sum + kind*kind;

  FOR(i, k, n){
    if(q2.enpty()==true) break;
    sushi ss = q.top();
    q.pop();
    if(slist[ss.t]>0) continue;
    sum = sum + ss.d + q2.top();
    ++kind;
    q2.pop();

    ans=max(ans, sum + kind*kind);
  }
  cout<<ans<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:11: error: 'class std::priority_queue<long long int>' has no member named 'enpty'; did you mean 'empty'?
   64 |     if(q2.enpty()==true) break;
      |           ^~~~~
      |           empty
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct sushi{
  int t;
  LL d;

  bool operator<(const sushi &r) const{
    return d<r.d;
  }
};

int main(){
  int n, k;
  cin>>n>>k;
  priority_queue<sushi> q;
  priority_queue<LL> q2;
  sushi s;
  LL slist[n];
  REP(i, n) slist[i]=0;

  REP(i, n){
    cin>>s.t>>s.d;
    --s.t;
    q.push(s);
  }

  if(n==1){
    cout<<1+s.d<<endl;
    return 0;
  }

  LL sum=0;
  LL kind=0;
  REP(i, k){
    sushi ss = q.top();
    q.pop();
    if(slist[ss.t]==0) ++kind;
    else q2.push(-ss.d);
    ++slist[ss.t];
    sum += ss.d;
  }
  LL ans = sum + kind*kind;

  FOR(i, k, n){
    if(q2.enpty==true) break;
    sushi ss = q.top();
    q.pop();
    if(slist[ss.t]>0) continue;
    sum = sum + ss.d + q2.top();
    ++kind;
    q2.pop();

    ans=max(ans, sum + kind*kind);
  }
  cout<<ans<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:11: error: 'class std::priority_queue<long long int>' has no member named 'enpty'; did you mean 'empty'?
   64 |     if(q2.enpty==true) break;
      |           ^~~~~
      |           empty
Language: Java

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        SUSHI[] sushi = new SUSHI[n];
        for (int i = 0; i < n; i++) {
            sushi[i] = new SUSHI(sc.nextInt() - 1, sc.nextLong());
        }
        Arrays.sort(sushi);

        long ans = 0, sumOfDelicious = 0;
        boolean[] used = new boolean[n];
        PriorityQueue<SUSHI> queue = new PriorityQueue<>(Comparator.reverseOrder());
        int kind = 0;

        for(int i = 0; i < n; i++) {
            SUSHI s = sushi[i];
            if(i < k) {
                sumOfDelicious += s.delicious;
                if(used[s.type]) {
                    queue.offer(s);
                } else {
                    kind++;
                    used[s.type] = true;
                }
                ans = Math.max(ans, sumOfDelicious + kind * kind);
            } else if(!queue.isEmpty() && !used[s.type]) {
                sumOfDelicious -= queue.poll().delicious;
                sumOfDelicious += s.delicious;
                used[s.type] = true;
                kind++;
                ans = Math.max(ans, sumOfDelicious + kind * kind);
            }
        }
        System.out.println(ans);
    }
}

class SUSHI implements Comparable<SUSHI> {
    int type;
    long delicious;

    SUSHI(int t, long d) {
        type = t;
        delicious = d;
    }

    @Override
    public int compareTo(SUSHI o) {
        return this.delicious == o.delicious
                ? Integer.compare(this.type, o.type)
                : Long.compare(o.delicious, this.delicious);
    }
}


Compiler output:
Main.java:6: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: Java

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        SUSHI[] sushi = new SUSHI[n];
        for (int i = 0; i < n; i++) {
            sushi[i] = new SUSHI(sc.nextInt() - 1, sc.nextLong());
        }
        Arrays.sort(sushi);

        long ans = 0, sumOfDelicious = 0;
        boolean[] used = new boolean[n];
        PriorityQueue<SUSHI> queue = new PriorityQueue<>();
        int kind = 0;

        for(int i = 0; i < n; i++) {
            SUSHI s = sushi[i];
            if(i < k) {
                sumOfDelicious += s.delicious;
                if(used[s.type]) {
                    queue.offer(s);
                } else {
                    kind++;
                    used[s.type] = true;
                }
                ans = Math.max(ans, sumOfDelicious + kind * kind);
            } else if(!queue.isEmpty() && !used[s.type]) {
                sumOfDelicious -= queue.poll().delicious;
                sumOfDelicious += s.delicious;
                used[s.type] = true;
                kind++;
                ans = Math.max(ans, sumOfDelicious + kind * kind);
            }
        }
        System.out.println(ans);
    }
}

class SUSHI implements Comparable<SUSHI> {
    int type;
    long delicious;

    SUSHI(int t, long d) {
        type = t;
        delicious = d;
    }

    @Override
    public int compareTo(SUSHI o) {
        return this.delicious == o.delicious
                ? Integer.compare(this.type, o.type)
                : Long.compare(o.delicious, this.delicious);
    }
}

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<40;

int main() {
    int N, K; cin >> N >> K;
    vector<long long> maxd(N, -INF), vals;
    multiset<long long> se;
    for (int i = 0; i < N; ++i) {
        int s; long long v;
        cin >> s >> v;
        --s;
        chmax(maxd[s], v);
        vals.push_back(v);
    }
    sort(vals.begin(), vals.end(), greater<long long>());
    sort(maxd.begin(), maxd.end(), greater<long long>());
    long long sum = 0;
    for (int i = 0; i < K; ++i) sum += vals[i], se.insert(vals[i]);
        
    long long res = 0;
    long long tmp = sum;
    for (long long x = 1; x <= K; ++x) {
        long long add = maxd[x-1];
        long long back = *se.begin();
        tmp += add;
        if (back > add) {
            se.erase(se.begin());
            tmp -= back;
        }
        else {
            se.erase(se.find(add));
            tmp -= add;
        }
        chmax(res, tmp + x * x);
    }
    cout << res << endl;
}


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

#include <bits/stdc++.h>

using namespace std;

int in() {
    int x;
    cin >> x;
    return x;
}

int main() {
    vector<int> a(101010);
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        a[in()].pb(in());
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:17: error: request for member 'pb' in 'a.std::vector<int>::operator[](((std::vector<int>::size_type)in()))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   16 |         a[in()].pb(in());
      |                 ^~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,k;
  	cin >>n >>k;
  	vector<vector<int>> ds(n);
  	rep(i,n){
    	int t,d;
      	cin >>t >>d;t--;
      	ds[t].push_back(d);
    }
  	vector<int> y0,y1;
  	rep(i,n){
    	if(ds[i].size()==0) continue;
      	sort(ds[i].begin(),ds[i].end());
      	y1.push_back(ds[i].back());
      	ds[i].pop_back();
      	y0.insert(y0.end(), ds[i].begin(), ds[i].end());
    }//y1には各種類の最大、y0はそれ以外を昇順で
  	sort(y0.rbegin(), y0.rend());
    sort(y1.rbegin(), y1.rend());//それぞれ降順
  	long long ans=0;
  	int Y=max(0,k-int(y0.size()))
    long long X=0;
  	rep(i,Y)   X +=y1[i]; //種類がk個に満たない時
  	rep(i,k-Y) X +=y0[i];
  	while(1){
    	ans=max(ans, X+(long long)Y*Y);
      	if(Y >= k || Y >= y1.size()) break;
      	X += y1[Y];
      	X -= y0[k-Y-1];
      	++Y;
    }
    cout <<ans <<endl;
  return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: expected ',' or ';' before 'long'
   28 |     long long X=0;
      |     ^~~~
a.cc:29:20: error: 'X' was not declared in this scope
   29 |         rep(i,Y)   X +=y1[i]; //種類がk個に満たない時
      |                    ^
a.cc:30:20: error: 'X' was not declared in this scope
   30 |         rep(i,k-Y) X +=y0[i];
      |                    ^
a.cc:32:22: error: 'X' was not declared in this scope
   32 |         ans=max(ans, X+(long long)Y*Y);
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,k;
    cin>>n>>k;
    vp vec(n);
    REP(i,n){
        cin>>vec[i].se>>vec[i].fi;
    }
    sort(all(vec),greater<>());
    priority_queue<P,vp,greater<>> que;
    ll sum=0;
    set<int> se;
    REP(i,k){
        sum+=vec[i].fi;
        if(se.count(vec[i].se)){
            que.push(vec[i]);
        }else{
            se.insert(vec[i].se);
        }
    }
    ll ans=sum+se.size()*se.size();
    FOR(i,k,n){
        if(!que.size()){
            break;
        }
        if(se.count(vec[i].se)){
            continue;
        }
        P p=que.top();que.pop();
        sum-=p.fi;
        sum+=vec[i].fi;
        se.insert(vec[i].se);
        chmax(ans,sum+1ll*se.size()*se.size());
    }

    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:14: error: no matching function for call to 'chmax(long long int&, long long unsigned int)'
   56 |         chmax(ans,sum+1ll*se.size()*se.size());
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:20:23: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   20 | template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
      |                       ^~~~~
a.cc:20:23: note:   template argument deduction/substitution failed:
a.cc:56:14: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'long long unsigned int')
   56 |         chmax(ans,sum+1ll*se.size()*se.size());
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,k;
    cin>>n>>k;
    vp vec(n);
    REP(i,n){
        cin>>vec[i].se>>vec[i].fi;
    }
    sort(all(vec),greater<>());
    priority_queue<P,vp,greater<>> que;
    ll sum=0;
    set<int> se;
    REP(i,k){
        sum+=vec[i].fi;
        if(se.count(vec[i].se)){
            que.push(vec[i]);
        }else{
            se.insert(vec[i].se);
        }
    }
    ll ans=sum+se.size()*se.size();
    FOR(i,k,n){
        if(!que.size()){
            break;
        }
        if(se.count(vec[i].se)){
            continue;
        }
        P p=que.top();que.pop();
        sum-=p.fi;
        sum+=vec[i].fi;
        se.insert(vec[i].se);
        chmax(ans,sum+se.size()*se.size());
    }

    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:14: error: no matching function for call to 'chmax(long long int&, long long unsigned int)'
   56 |         chmax(ans,sum+se.size()*se.size());
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:20:23: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   20 | template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
      |                       ^~~~~
a.cc:20:23: note:   template argument deduction/substitution failed:
a.cc:56:14: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'long long unsigned int')
   56 |         chmax(ans,sum+se.size()*se.size());
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <assert.h>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<pair<int, int>> v;
  for (int i = 0; i < N; i++)
  {
    int t, d;
    cin >> t >> d;
    v.push_back({d, t});
  }
  sort(v.begin(), v.end(), greater<pair<int, int>>());
  map<int, bool> type;
  priority_queue<int> pq;
  long long base = 0;
  for (int i = 0; i < K; i++)
  {
    if (type[v[i].second])
      pq.push(v[i].first);
    base += v[i].first;
    type[v[i].second] = true;
  }
  long long ans = base + (long long)type.size() * type.size();
  for (int i = K; i < N; i++)
    if (!type[v[i].second])
    {
      base -= pq.top();
      pq.pop();
      type[v[i].second] = true;
      base += v[i].first;
      ans = max(ans, base + (long long)type.size() * type.size());
    }
  cout << ans << endl;

  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> P;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<P> sushis(n);
    for (int i = 0; i < n; ++i) {
        cin >> sushis[i].second >> sushis[i].first;
    }
    sort(sushis.begin(), sushis.end(), greater<P>());
    ll ans = 0;
    set<ll> st;
    stack<P> sk;
    for (int i = 0; i < k; ++i) {
        if (st.count(sushis[i].second)) {
            sk.push(sushis[i]);
        }
        st.insert(sushis[i].second);
        ans += sushis[i].first;
    }
    ll curr = ans;
    ans += st.size() * st.size();
    for (int i = k; i < n; ++i) {
        if (sk.empty()) break;
        if (st.count(sushis[i].second)) continue;
        curr -= sk.top().first;
        sk.pop();
        curr += sushis[i].first;
        st.insert(sushis[i].second);
        ans = max(ans, curr + st.size() * st.size());
    }
    cout << ans << endl;
    return 0;
}

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

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

const int LIM = 100000;
int n, k, cnt;
pair<int, int> dt[LIM];
ll ans;
map<int, int> cnts;

int main() {
    cin >> n >> k;
    rep(i, n) cin >> dt[i].second >> dt[i].first;
    sort(dt, dt + n, greater<pair<int, int> >());
    
    // まずd多い順にとる
    rep(i, k) {
        int d = dt[i].first, t = dt[i].second;
        if(cnts[t] == 0) {
            // 初体験
            ans += cnt * 2 + 1;
            cnt++;
        }
        ans += d;
        cnts[t]++;
    }

    // 種類だんだん多くする
    int idx1 = k - 1, idx2 = k;
    ll num = ans;
    while (idx1 >= 0) {
        // 2個以上ある種類の寿司を1個減らす
        int d = dt[idx1].first, t = dt[idx1].second;
        idx--;

        if (cnts[t] > 1) {
            cnts[t]--;
            num -= d;
        } else {
            continue;
        }
        
        // 1種類増やす
        while (idx2 < n) {
            d = dt[idx2].first; t = dt[idx2].second;
            idx2++;
            if (cnts[t] > 0) {
                // すでに食べてる
            } else {
                num += d + cnt * 2 + 1;
                cnt++;
                cnts[t]++;
                ans = max(ans, num);
                break;
            }
        }
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'idx' was not declared in this scope; did you mean 'idx2'?
   36 |         idx--;
      |         ^~~
      |         idx2
Language: C++

#include <array>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <assert>

using namespace std;

struct sushi_t {
  int d;
  int t;
};

static int n, k;
static std::array<sushi_t, 100000> sushis{};
static std::array<int, 100000> takenNetas{};
static std::bitset<100000> takenSushis{};

int64_t solve() {
  int64_t ret0 = 0;
  int64_t nn = 0;
  for (int i = 0; i < k; ++i) {
    const auto& s = sushis[i];
    ret0 += int64_t(s.d);
    if (takenNetas[s.t] == 0) {
      nn++;
    }
    takenNetas[s.t]++;
    takenSushis.set(i);
  }
  int64_t ret = ret0 + nn * nn;

  for (++nn; nn <= k; ++nn) {
    bool found = false;
    for (int i = n - 1; i >= 0; --i) {
      if (!takenSushis.test(i)) {
        continue;
      }
      const auto& s = sushis[i];
      assert(takenNetas[s.t] >= 1);
      if (takenNetas[s.t] <= 1) {
        continue;
      }
      ret0 -= int64_t(s.d);
      takenNetas[s.t]--;
      takenSushis.reset(i);
      found = true;
      break;
    }
    if (!found) {
      break;
    }
    found = false;
    for (int i = 0; i < n; ++i) {
      if (takenSushis.test(i)) {
        continue;
      }
      const auto& s = sushis[i];
      if (takenNetas[s.t] > 0) {
        continue;
      }
      ret0 += int64_t(s.d);
      takenNetas[s.t]++;
      takenSushis.set(i);
      ret = std::max(ret0 + nn * nn, ret);
      found = true;
      break;
    }
    if (!found) {
      break;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    auto& s = sushis[i];
    std::cin >> s.t >> s.d;
    s.t--;
  }
  std::sort(sushis.begin(), sushis.begin() + n,
            [](const auto& lhs, const auto& rhs) { return lhs.d > rhs.d; });
  std::cout << solve() << std::endl;
  return 0;
}

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

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	int n,k;
	cin >> n >> k;
	p_int ss[n];
	bool use[100005];
	for (int i = 0;i < 100005;i++) {
		use[i] = false;
	}
	for (int i = 0;i < n;i++) {
		cin >> ss[i].second >> ss[i].first;
	}
	sort(ss,ss+n);
	reverse(ss,ss+n);
	vector<int> y0;
	vector<int> y1;
	for (int i = 0;i < n;i++) {
		if (!use[ss[i].second]) y1.push_back(ss[i].first);
		else y0.push_back(ss[i].first);
		use[ss[i].second] = true;
	}
	ll ans = 0;
	ll Y = max(0,k-y0.size());
	ll X = 0;
	for (int i = 0;i < Y;i++) X += y1[i];
	for (int i = 0;i < k - Y;i++) X += y0[i];
	while (1) {
		ans = max(ans, X + Y*Y);
		if (Y >= k || Y >= y1.size()) break;
		X+=y1[Y];
		X-=y0[k-Y-1];
		Y++;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:19: error: no matching function for call to 'max(int, std::vector<int>::size_type)'
   33 |         ll Y = max(0,k-y0.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:33:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   33 |         ll Y = max(0,k-y0.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:33:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |         ll Y = max(0,k-y0.size());
      |                ~~~^~~~~~~~~~~~~~~