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

int main(){
    int n,k;
    cin>>n>>k;
    int c,g,dp[2001];
    vector<int> bks[11];
    for(int i=0;i<n;++i){
        cin>>c>>g;
        bks[g-1].push_back(c);
    }
    for(int i=0;i<10;++i){
        sort(bks[i].begin(),bks[i].end(),greater<int>());
    }
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<10;++i){
        if(bks[i].empty()) continue;
        for(int j=k-1;j>=0;--j){
            if(dp[j]==-1) continue;
            int sum=0;
            for(int l=0;l<bks[i].size()&&j+l<k;++l){
                sum +=bks[i][l];
                dp[j+l+1]=max(dp[j+l+1],dp[j]+sum+(l+1)*l);
            }
        }
    }
    cout<<dp[k]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin>>n>>k;
      |     ^~~
a.cc:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> bks[11];
      |     ^~~~~~
a.cc:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> bks[11];
      |            ^~~
a.cc:8:9: error: 'bks' was not declared in this scope
    8 |         bks[g-1].push_back(c);
      |         ^~~
a.cc:11:14: error: 'bks' was not declared in this scope
   11 |         sort(bks[i].begin(),bks[i].end(),greater<int>());
      |              ^~~
a.cc:11:42: error: 'greater' was not declared in this scope
   11 |         sort(bks[i].begin(),bks[i].end(),greater<int>());
      |                                          ^~~~~~~
a.cc:11:50: error: expected primary-expression before 'int'
   11 |         sort(bks[i].begin(),bks[i].end(),greater<int>());
      |                                                  ^~~
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |         sort(bks[i].begin(),bks[i].end(),greater<int>());
      |         ^~~~
      |         short
a.cc:13:5: error: 'memset' was not declared in this scope
   13 |     memset(dp,-1,sizeof(dp));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | int main(){
a.cc:16:12: error: 'bks' was not declared in this scope
   16 |         if(bks[i].empty()) continue;
      |            ^~~
a.cc:20:27: error: 'bks' was not declared in this scope
   20 |             for(int l=0;l<bks[i].size()&&j+l<k;++l){
      |                           ^~~
a.cc:22:27: error: 'max' was not declared in this scope
   22 |                 dp[j+l+1]=max(dp[j+l+1],dp[j]+sum+(l+1)*l);
      |                           ^~~
a.cc:26:5: error: 'cout' was not declared in this scope
   26 |     cout<<dp[k]<<endl;
      |     ^~~~
a.cc:26:18: error: 'endl' was not declared in this scope
   26 |     cout<<dp[k]<<endl;
      |                  ^~~~
Language: C++

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

int n, k;
vector<int> c[10];
int memo[10][5000];

int calc(int g, int b)
{
	int ret = 0;

	if(b == 0) return 0;
	if(g == 0) {
		for(int i = 0; i < b; ++i)
			ret += c[g][i];
		return ret;
	}

	if(memo[b][g] != -1)
		return memo[b][g];

	int sum = 0;

	ret = calc(g - 1, b);

	for(int i = 1; i <= b; ++i) {

		sum += [i - 1];
		ret = max(ret, sum + calc(g - 1, b - i));	
	}

	return memo[b][g] = ret;
}


int main()
{
	memset(memo, -1, sizeof(memo));

	scanf("%d%d", &n, &k);
	for(int i = 0; i < 10; ++i) c[i].reserve(n);
	for(int i = 0; i < n; ++i) {
		int tc, tg;
		scanf("%d%d", &tc, &tg);
		c[tg - 1].push_back(tc);
	}

	for(int i = 0; i < 10; ++i) {

		sort(c[i].rbegin(), c[i].rend());
		for(int j = 1; j < c[i].size(); ++j)
			c[j] += (2 * (j + 1) - 2);
	}

	
	

	return 0;
}

Compiler output:
a.cc: In function 'int calc(int, int)':
a.cc:30:26: error: expected ',' before '-' token
   30 |                 sum += [i - 1];
      |                          ^~
      |                          ,
a.cc:30:27: error: expected identifier before '-' token
   30 |                 sum += [i - 1];
      |                           ^
a.cc: In lambda function:
a.cc:30:31: error: expected '{' before ';' token
   30 |                 sum += [i - 1];
      |                               ^
a.cc: In function 'int calc(int, int)':
a.cc:30:21: error: no match for 'operator+=' (operand types are 'int' and 'calc(int, int)::<lambda()>')
   30 |                 sum += [i - 1];
      |                 ~~~~^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:40:9: error: 'memset' was not declared in this scope
   40 |         memset(memo, -1, sizeof(memo));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc:54:30: error: no match for 'operator+=' (operand types are 'std::vector<int>' and 'int')
   54 |                         c[j] += (2 * (j + 1) - 2);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

int n, k;
vector<int> c[10];
int memo[10][5000];

int calc(int g, int b)
{
	int ret = 0;

	if(b == 0) return 0;
	if(g == 0) {
		for(int i = 0; i < b; ++i)
			ret += c[g][i];
		return ret;
	}

	if(memo[b][g] != -1)
		return memo[b][g];

	int sum = 0;

	ret = calc(g - 1, b);

	for(int i = 1; i <= b; ++i) {

		sum += c[i - 1];
		ret = max(ret, sum + calc(g - 1, b - i));	
	}

	return memo[b][g] = ret;
}


int main()
{
	memset(memo, -1, sizeof(memo));

	scanf("%d%d", &n, &k);
	for(int i = 0; i < 10; ++i) c[i].reserve(n);
	for(int i = 0; i < n; ++i) {
		int tc, tg;
		scanf("%d%d", &tc, &tg);
		c[tg - 1].push_back(tc);
	}

	for(int i = 0; i < 10; ++i) {

		sort(c[i].rbegin(), c[i].rend());
		for(int j = 1; j < c[i].size(); ++j)
			c[i][j] += (2 * (j + 1) - 2);
	}

	
	

	return 0;
}

Compiler output:
a.cc: In function 'int calc(int, int)':
a.cc:31:21: error: no match for 'operator+=' (operand types are 'int' and 'std::vector<int>')
   31 |                 sum += c[i - 1];
      |                 ~~~~^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'memset' was not declared in this scope
   41 |         memset(memo, -1, sizeof(memo));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define reps(i,j,n) for(int i = j ; i < n ; ++i)
#define rep(i,n) reps(i,0,n)
vector<int> book[10];
int dp[11][2001],n,k;

int solve(int ct,int ja){
  if(ct >= k || ja > 10) return 0;
  if(dp[ja][ct]!=-1) return dp[ja][ct];
  int res = solve(ct,ja+1),sum = 0;
  rep(i,min(k-ct,(int)book[ja].size())){
    sum += book[ja][i];
    res = max(res,solve(ct+i+1,ja+1) + sum + i*(i+1));
  }
  return dp[ja][ct] = res;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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


int N, K;
vector<int> books[16];
int memo[16][2048];


int rec(int i, int used)
{
  if(memo[i][used] != -1) return memo[i][used];

  if(i == N) return 0;

  int best = 0;
  for(int t = 0; t < books[i].size() && used + t <= K; t++) {
    int cost = accumulate(books[i].begin(), books[i].begin() + t, 0) + (t - 1) * t;
    best = max(best, rec(i+1, used + t) + cost);
  }

  return memo[i][used] = best;
}


int main()
{
  memset(memo, -1, sizeof memo); // memoを全て-1で初期化 この関数は-1以外では0でしか初期化出来ないので注意
  cin >> N >> K;

  for(int i = 0; i < N; i++) {
    int C, G;
    cin >> C >> G;
    books[G-1].push_back(C);
  }

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

  cout << rec(0, 0) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:3: error: 'memset' was not declared in this scope
   32 |   memset(memo, -1, sizeof memo); // memoを全て-1で初期化 この関数は-1以外では0でしか初期化出来ないので注意
      |   ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <functional>
  +++ |+#include <cstring>
    5 | #include <vector>
Language: C++

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

int main(){
  int N,K,C,G,dp[11][2001]={};
  vector<int> type[10],price[10];
  cin>>N>>K;
  
  for(int i=0;i<N;i++){
    cin>>C>>G;
    type[--G].push_back(C);
    // cout<<type[G][i]<<endl;
  }
  for(int i=0;i<10;i++){
    sort(type[i].begin(),type[i].end(),greater<int>());
    int sum=0;
    price[i].push_back(0);
    for(int j=0;j<type[i].size;j++){
      sum+=type[i][j];
      price[i].push_back(sum+j*(j+1));
    }
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<prise[i].size();j++){
      for(int k=0;k+j<=K;k++){
       dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]:dp[i][k+1])
      }
    }
  }
  cout<<dp[10][K]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(type[i].begin(),type[i].end(),greater<int>());
      |     ^~~~
      |     short
a.cc:20:27: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   20 |     for(int j=0;j<type[i].size;j++){
      |                   ~~~~~~~~^~~~
      |                               ()
a.cc:26:19: error: 'prise' was not declared in this scope; did you mean 'price'?
   26 |     for(int j=0;j<prise[i].size();j++){
      |                   ^~~~~
      |                   price
a.cc:28:60: error: expected ')' before ':' token
   28 |        dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]:dp[i][k+1])
      |                          ~                                 ^
      |                                                            )
a.cc:28:72: error: expected ':' before '}' token
   28 |        dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]:dp[i][k+1])
      |                                                                        ^
      |                                                                        :
   29 |       }
      |       ~                                                                 
a.cc:29:7: error: expected primary-expression before '}' token
   29 |       }
      |       ^
Language: C++


#include <stdio.h>
#include <queue>
#include <vector>
#include <functional>

using namespace std;
using P = pair<int, int>;

struct edge { int to, cost; };

const int MAX_N = 3000;

int dist[MAX_N + 1];
vector<edge>graph[MAX_N + 1];

int n, m, k;

void dijkstra()
{
	for (int i = 0; i <= n; ++i)dist[i] = 123456789;
	dist[0] = 0;
	priority_queue<P, vector<P>, greater<P>>que;
	que.push(make_pair(0, 0));
	while (!que.empty())
	{
		P u = que.top(); que.pop();
		if (dist[u.second] < u.first)continue;
		for (edge e : graph[u.second])
		{
			int alt = u.first + e.cost;
			if (dist[e.to] > alt)
			{
				dist[e.to] = alt;
				que.push(make_pair(alt, e.to));
			}
		}
	}
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 0; i < m; ++i)
	{
		int a, b, l;
		scanf("%d %d %d", &a, &b, &l);
		graph[a].push_back({ b,l });
		graph[b].push_back({ a,l });
	}
	for (int i = 0; i < k; ++i)
	{
		int s;
		scanf("%d", &s);
		graph[0].push_back({ s,0 });
	}
	dijkstra();
	int ans = 0;
	for (int v = 1; v <= n; ++v)
	{
		for (edge e : graph[v])
		{
			int u = e.to;
			int cost = e.cost;
			int a = min(dist[u], dist[v]);
			int b = max(dist[u], dist[v]);
			ans = max(ans, (int)round((b - a + cost) / 2.0) + a);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:45: error: 'round' was not declared in this scope
   67 |                         ans = max(ans, (int)round((b - a + cost) / 2.0) + a);
      |                                             ^~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<queue>
#include<functional>
#include<vector>
#include<algorithm>
#define int long long
#define P pair<int,int>//cost to
using namespace std;

int kiriage(int a) {
	if (a&1)return a / 2 + 1;
	return a / 2;
}
vector<P>rinsetu[3000];
int mincost[3000];
signed main() {
	int a, b, c; cin >> a >> b >> c;
	fill(mincost, mincost + a, LLONG_MAX/3);
	for (int d = 0; d < b; d++) {
		int e, f, g; scanf("%d%d%d", &e, &f, &g); e--; f--;
		rinsetu[e].push_back(P(g, f));
		rinsetu[f].push_back(P(g, e));
	}
	priority_queue<P, vector<P>, greater<P>>Q;
	for (int h = 0; h < c; h++) {
		int i; scanf("%d", &i); i--;
		mincost[i] = 0;
		Q.push(P(0,i));
	}
	while (Q.size()) {
		P o = Q.top(); Q.pop();
		if (mincost[o.second] < o.first)continue;
		for (P t : rinsetu[o.second]) {
			if (o.first + t.first < mincost[t.second]) {
				mincost[t.second] = o.first + t.first;
				Q.push(P(mincost[t.second],t.second));
			}
		}
	}
	int MAX = 0;
	for (int x = 0; x < a; x++) {
		for (P y : rinsetu[x]) {
			y.first -= abs(mincost[x] - mincost[y.second]);
			MAX = max(MAX, max(mincost[x], mincost[y.second]) + kiriage(y.first));
		}
	}
	cout << MAX << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:36: error: 'LLONG_MAX' was not declared in this scope
   19 |         fill(mincost, mincost + a, LLONG_MAX/3);
      |                                    ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<algorithm>
  +++ |+#include <climits>
    7 | #define int long long
Language: C++

#include<bits/stdc++,h>
#define int long long
#define P pair<int,int>//cost to
using namespace std;

int kiriage(int a) {
	if (a&1)return a / 2 + 1;
	return a / 2;
}
vector<P>rinsetu[3000];
int mincost[3000];
signed main() {
	int a, b, c; cin >> a >> b >> c;
	fill(mincost, mincost + a, LLONG_MAX/3);
	for (int d = 0; d < b; d++) {
		int e, f, g; scanf("%d%d%d", &e, &f, &g); e--; f--;
		rinsetu[e].push_back(P(g, f));
		rinsetu[f].push_back(P(g, e));
	}
	priority_queue<P, vector<P>, greater<P>>Q;
	for (int h = 0; h < c; h++) {
		int i; scanf("%d", &i); i--;
		mincost[i] = 0;
		Q.push(P(0,i));
	}
	while (Q.size()) {
		P o = Q.top(); Q.pop();
		if (mincost[o.second] < o.first)continue;
		for (P t : rinsetu[o.second]) {
			if (o.first + t.first < mincost[t.second]) {
				mincost[t.second] = o.first + t.first;
				Q.push(P(mincost[t.second],t.second));
			}
		}
	}
	int MAX = 0;
	for (int x = 0; x < a; x++) {
		for (P y : rinsetu[x]) {
			y.first -= abs(mincost[x] - mincost[y.second]);
			MAX = max(MAX, max(mincost[x], mincost[y.second]) + kiriage(y.first));
		}
	}
	cout << MAX << endl;
}

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

10 30 3
2 5 831
1 7 478
10 9 435
4 7 841
10 4 399
6 8 85
9 8 433
3 7 109
9 4 325
2 4 323
5 10 410
8 2 979
3 6 818
1 10 566
9 2 781
5 4 634
8 1 248
2 1 234
4 8 497
10 3 324
8 7 137
6 7 565
1 6 357
3 1 870
2 6 36
2 3 821
3 9 884
8 10 345
3 5 901
3 4 427
2
1
5

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

#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<int,int> P;
/*int main(){
	cout<<8979879<<endl;
}*/
int ri[3001][3001];
int main(void){
	int n,m,k,
		i,j,
		mx,t,
		a[100001],b[100001],l[100001],s[3000],
		d[3001];
		
	priority_queue<P,vector<P>,greater<P> > que;
	
	cin>>n>>m>>k;
	for(i=0;i<m;i++) cin>>a[i]>>b[i]>>l[i];
	for(i=0;i<k;i++) cin>>s[i];
//	for(i=0;i<k;i++) cout<<s[i]<<endl;
	
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) ri[i][j]=M;
	for(i=0;i<m;i++) ri[a[i]][b[i]]=l[i],ri[b[i]][a[i]]=l[i];
/*	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)cout<<ri[i][j]<<' ';
		cout<<endl;
	}*/
	
	mx=0;
	int leng[3001];
	for(i=1;i<=n;i++) leng[i]=M;
	for(i=0;i<k;i++){
		leng[s[i]]=0;
		que.push(P(0,s[i]));
	}
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(leng[v]<p.first) continue;
		for(j=1;j<=n;j++){
			t=leng[v]+ri[v][j];
//			cout<<j<<' '<<leng[j]<<' '<<t<<endl;
			if(leng[j]>t){
				leng[j]=t;
//				cout<<leng[j]<<' '<<j<<endl;
				que.push(P(leng[j],j));
			}
		}
	}
/*	for(i=1;i<=n;i++) cout<<leng[i]<<' ';
	cout<<endl;*/
	for(i=1;i<=n;i++){
		double cnt=0,sum=0;
		for(j=1;j<=n;j++){
			if(ri[i][j]!=M) cnt++,sum+=ri[i][j]+leng[j];
		}
		if(sum%cnt>=cnt/2) mx=max(mx,sum%cnt+1);
		else mx=max(mx,sum%cnt);
	}
	
	cout<<mx<<endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:23: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   59 |                 if(sum%cnt>=cnt/2) mx=max(mx,sum%cnt+1);
      |                    ~~~^~~~
      |                    |   |
      |                    |   double
      |                    double
a.cc:59:49: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   59 |                 if(sum%cnt>=cnt/2) mx=max(mx,sum%cnt+1);
      |                                              ~~~^~~~
      |                                              |   |
      |                                              |   double
      |                                              double
a.cc:60:35: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   60 |                 else mx=max(mx,sum%cnt);
      |                                ~~~^~~~
      |                                |   |
      |                                |   double
      |                                double
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<int,int> P;
/*int main(){
	cout<<8979879<<endl;
}*/
int ri[3001][3001];
int main(void){
	int n,m,k,
		i,j,
		mx,t,ans,
		a[100001],b[100001],l[100001],s[3000],
		d[3001];
		
	priority_queue<P,vector<P>,greater<P> > que;
	
	cin>>n>>m>>k;
	for(i=0;i<m;i++) cin>>a[i]>>b[i]>>l[i];
	for(i=0;i<k;i++) cin>>s[i];
//	for(i=0;i<k;i++) cout<<s[i]<<endl;
	
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) ri[i][j]=M;
	for(i=0;i<m;i++) ri[a[i]][b[i]]=l[i],ri[b[i]][a[i]]=l[i];
/*	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)cout<<ri[i][j]<<' ';
		cout<<endl;
	}*/
	
	int leng[3001];
	for(i=1;i<=n;i++) leng[i]=M;
	for(i=0;i<k;i++){
		leng[s[i]]=0;
		que.push(P(0,s[i]));
	}
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(leng[v]<p.first) continue;
		for(j=1;j<=n;j++){
			t=leng[v]+ri[v][j];
//			cout<<j<<' '<<leng[j]<<' '<<t<<endl;
			if(leng[j]>t){
				leng[j]=t;
//				cout<<leng[j]<<' '<<j<<endl;
				que.push(P(leng[j],j));
			}
		}
	}
/*	for(i=1;i<=n;i++) cout<<leng[i]<<' ';
	cout<<endl;*/
	ans=0;
	for(i=1;i<=n;i++){
		int mx=0,y;
		double x;
		for(j=1;j<=n;j++){
			if(ri[i][j]!=M){
					mx=max(mx,ri[i][j]+leng[j]);
				}
				else{
					mx=max(mx,ri[i][j]);
				}
			}
		}
		x=(double)mx/2;
//		cout<<x<<' '<<mx<<' '<<mi<<endl;
		y=round(x);
		ans=max(ans,y);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:17: error: 'x' was not declared in this scope
   66 |                 x=(double)mx/2;
      |                 ^
a.cc:68:17: error: 'y' was not declared in this scope
   68 |                 y=round(x);
      |                 ^
a.cc: At global scope:
a.cc:72:9: error: 'cout' does not name a type
   72 |         cout<<ans<<endl;
      |         ^~~~
a.cc:74:9: error: expected unqualified-id before 'return'
   74 |         return 0;
      |         ^~~~~~
a.cc:75:1: error: expected declaration before '}' token
   75 | }
      | ^
Language: C++

#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int i,j;
	int n,m,l;;
	scanf("%d%d%d",&n,&m,&l);
	vector<pair<int,int> > a[3000];
	for(i=0;i<m;++i){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		--p;
		--q;
		a[p].push_back(make_pair(q,r));
		a[q].push_back(make_pair(p,r));
	}
	int b[3000];
	memset(b,0x7f,sizeof(b));
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > c;
	for(i=0;i<l;++i){
		int p;
		scanf("%d",&p);
		--p;
		b[p]=0;
		c.push(make_pair(0,p));
	}
	while(!c.empty()){
		int p,q;
		p=c.top().first;
		q=c.top().second;
		c.pop();
		for(i=0;i<(int)a[q].size();++i){
			if(b[a[q][i].first]<=p+a[q][i].second)
				continue;
			b[a[q][i].first]=p+a[q][i].second;
			c.push(make_pair(p+a[q][i].second,a[q][i].first));
		}
	}
	int mx=0;
	for(i=0;i<n;++i)
		for(j=0;j<(int)a[i].size();++j)
			mx=max(mx,max(b[i],b[a[i][j].first])+(a[i][j].second-abs(b[i]-b[a[i][j].first])+1)/2);
	printf("%d\n",mx);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(b,0x7f,sizeof(b));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include<cstdio>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
const int inf = (int)1e9;
int n, m, k;
int ans = inf;
vector<int> dist;
vector<vector<pair<int, int> > > graph;
vector<pair<pair<int, int>, int> > edge;
scanf("%d%d%d", &n, &m, &k);
dist.resize(n, inf);
for(int i = 0; i < m; ++i) {
int a, b, l;
scanf("%d%d%d", &a, &b, &l);
a -= 1, b -= 1;
edge.push_back(make_pair(make_pair(a, b), l));
graph[a].push_back(make_pair(b, l));
graph[b].push_back(make_pair(a, l));
}
for(int i = 0; i < k; ++i) {
int s;
scanf("%d", &s);
s -= 1;
priority_queue<pair<int, int> > q;
q.push_back(make_pair(0, s));
while(!q.empty()) {
int v = q.top().second;
int c = -q.top().first;
q.pop();
if(dist[v] < c)
continue;
dist[v] = c;
for(int i = 0; i < graph[v].size(); ++i) {
int w = graph[v][i].second;
int d = graph[v][i].second + c;
q.push(make_pair(-d, w));
}
}
}
for(int i = 0; i < m; ++i) {
int a = edge[i].first.first;
int b = edge[i].first.second;
int l = edge[i].second;
if(dist[a] > dist[b])
swap(a, b);
int cost;
if(dist[a] + l <= dist[b])
cost = dist[b];
else
cost = (l - (dist[b] - dist[a]) + 1) / 2;
ans = max(ans, cost);
}
printf("%d\n", ans);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:3: error: 'class std::priority_queue<std::pair<int, int> >' has no member named 'push_back'
   30 | q.push_back(make_pair(0, s));
      |   ^~~~~~~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define s size()
#define INF 100000000
int cost[3005][3005];
int d[3005];
int maxi[100005]={};
bool used[3005]={};
P1 ii[100005];
int V;
void dijkstra(int s){
	fill(d,d+V,INF);
	d[s]=0;
	while(1){
		int v=-1;
		for(int u=0;u<V;u++){
			if(!used[u] && (v==-1 || d[u]<d[v])){
				v=u;
			}
		}
		if(v==-1){
			break;
		}
		used[v]=true;
		for(int i=0;i<V;i++){
			d[i]=min(d[i],d[v]+cost[v][i]);
		}
	}
}
int n,m,k;
int main(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0;i<3005;i++){
		for(int j=0;j<3005;j++){
			cost[i][j]=INF;
		}
	}
	for(int i=0;i<m;i++){
		int w,ww,eu;
		scanf("%d %d %d",&w,&ww,&eu);
		ii[i]=mp(eu,mp(w,ww));
		cost[w-1][ww-1]=eu;
		cost[ww-1][w-1]=eu;
	}
	int res=0;
	for(int i=0;i<k;i++){
		int t;
		scanf("%d",&t);
		dijkstra(t-1);
		memset(used,0,sizeof(used));
		for(int j=0;j<m;j++){
			maxi[j]=max(maxi[j],(ii[j].first+d[ii[j].second.first-1]+d[ii[j].second.second-1]+1)/2);
		}
	}
	for(int j=0;j<m;j++){
		res=max(res,maxi[j]);
	}
	printf("%d\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:27: error: invalid conversion from 'int' to 'int (*)()' [-fpermissive]
   65 |                 dijkstra(t-1);
      |                          ~^~
      |                           |
      |                           int
a.cc:19:11: note:   initializing argument 1 of 'void dijkstra(int (*)())'
   19 | #define s size()
      |           ^
a.cc:27:19: note: in expansion of macro 's'
   27 | void dijkstra(int s){
      |                   ^
Language: C++

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define s size()
#define INF 100000000
int cost[3005][3005];
int d[3005];
int maxi[100005]={};
bool used[3005]={};
P1 ii[100005];
int V;
void dijkstra(int os){
	fill(d,d+V,INF);
	d[s]=0;
	while(1){
		int v=-1;
		for(int u=0;u<V;u++){
			if(!used[u] && (v==-1 || d[u]<d[v])){
				v=u;
			}
		}
		if(v==-1){
			break;
		}
		used[v]=true;
		for(int i=0;i<V;i++){
			d[i]=min(d[i],d[v]+cost[v][i]);
		}
	}
}
int n,m,k;
int main(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0;i<3005;i++){
		for(int j=0;j<3005;j++){
			cost[i][j]=INF;
		}
	}
	for(int i=0;i<m;i++){
		int w,ww,eu;
		scanf("%d %d %d",&w,&ww,&eu);
		ii[i]=mp(eu,mp(w,ww));
		cost[w-1][ww-1]=eu;
		cost[ww-1][w-1]=eu;
	}
	int res=0;
	for(int i=0;i<k;i++){
		int t;
		scanf("%d",&t);
		dijkstra(t-1);
		memset(used,0,sizeof(used));
		for(int j=0;j<m;j++){
			maxi[j]=max(maxi[j],(ii[j].first+d[ii[j].second.first-1]+d[ii[j].second.second-1]+1)/2);
		}
	}
	for(int j=0;j<m;j++){
		res=max(res,maxi[j]);
	}
	printf("%d\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'void dijkstra(int)':
a.cc:19:15: error: no matching function for call to 'size()'
   19 | #define s size()
      |           ~~~~^~
a.cc:29:11: note: in expansion of macro 's'
   29 |         d[s]=0;
      |           ^
In file included from /usr/include/c++/14/string:53,
                 from a.cc:5:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   candidate expects 1 argument, 0 provided
Language: C++

#include "stdio.h"
#include "stdlib.h"
#include <iostream>
#include <algorithm>
using namespace std;

int mati[3000];
int matis[3000];
int miti[100000][2];
int miti2[3000][3000];
int matiw[3000];

int main()
{
	int n,m,k;

	{
		scanf("%d %d %d",&n,&m,&k);
	}
	
	{
		for(int i = 0; i < 3000; i++)
		{
			for(int ii = 0; ii < 3000; ii++)
			{
				miti2[i][ii] = -1;
			}
		}
	}

	{
		for(int i = 0; i < m; i++)
		{
			int w1,w2,w3;
			scanf("%d %d %d",&w1,&w2,&w3);
			miti[i][0] = w1 - 1;
			miti[i][1] = w2 - 1;
			miti2[w1 - 1][w2 - 1] = w3;
			miti2[w2 - 1][w1 - 1] = w3;
		}
	}

	{
		for(int i = 0; i < n; i++)
		{
			mati[i] = INT_MAX;
			matis[i] = 0;
		}
	}

	{
		int w;
		for(int i = 0; i < k; i++)
		{
			scanf("%d",&w);
			mati[w - 1] = 0;
		}
	}

	{
		for(int i = 0; i < n; i++)
		{
			for(int ii = 0; ii < n; ii++)
			{
				if(matis[ii] == 0)
				{
					matiw[ii] = mati[ii];
				}
				else
				{
					matiw[ii] = INT_MAX;
				}
			}
			sort(matiw,matiw + n);
			for(int ii = 0; ii < n; ii++)
			{
				if(mati[ii] == matiw[0] && matis[ii] == 0)
				{
					for(int iii = 0; iii < n; iii++)
					{
						if(miti2[ii][iii] != -1)
						{
							if(mati[iii] > mati[ii] + miti2[ii][iii])
							{
								mati[iii] = mati[ii] + miti2[ii][iii];
							}
						}
					}
					matis[ii] = 1;
					break;
				}
			}
		}
	}

	int l = 0;

	{
		int w,w1,w2;
		for(int i = 0; i < m; i++)
		{
			w1 = miti[i][0];
			w2 = miti[i][1];
			if(mati[w1] == mati[w2] + miti2[w1][w2])
			{
				w = mati[w1];
			}
			else if(mati[w2] == mati[w1] + miti2[w1][w2])
			{
				w = mati[w2];
			}
			else
			{
				w = (mati[w1] + mati[w2] + miti2[w1][w2] - 1) / 2 + 1;
			}
			if(l < w)
			{
				l = w;
			}
		}
	}

	printf("%d\n",l);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:35: error: 'INT_MAX' was not declared in this scope
   46 |                         mati[i] = INT_MAX;
      |                                   ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | using namespace std;
a.cc:71:53: error: 'INT_MAX' was not declared in this scope
   71 |                                         matiw[ii] = INT_MAX;
      |                                                     ^~~~~~~
a.cc:71:53: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <iostream>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

int main() {
	int N,M,K;
	vector<pair<int,int> >nGo[3001];
	deque<int> dis;
	int dist[3001];
	int road[3000][3];
	for(int i=1;i<=3000;i++)
		dist[i]=(1 << 30 );
	cin >> N >> M >> K;
	int a,b,c;
	for(int i=0;i<M;i++){
		cin >> a >> b >> c;
		nGo[a].push_back(pair<int,int>(b,c));
		nGo[b].push_back(pair<int,int>(a,c));
		road[i][0]=a;
		road[i][1]=b;
		road[i][2]=c;
	}
	for(int i=0;i<K;i++){
		cin >> a;
	//	dis.insert(multimap<int,int>::value_type(0,a));
		dis.push_back(a);
		dist[a]=0;
	}
	while(!dis.empty()){
		sort(dis.begin(),dis.end());
		int now=dis[0];
		for(int i=0;i<nGo[now].size();i++){
			if(dist[nGo[now][i].first]>dist[now]+nGo[now][i].second){
				dis.push_back(nGo[now][i].first);
				dist[nGo[now][i].first]=dist[now]+nGo[now][i].second;
			}
		}
		dis.pop_front();
	}
	int maxer=0;
	for(int i=0;i<M;i++)
	maxer=max(maxer,(int)(dist[road[i][0]]+dist[road[i][1]]+road[i][2]+0.5)/2);
	for(int i=1;i<=N;i++)
	maxer=max(maxer,dist[i]);
	cout << maxer <<  endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vector' was not declared in this scope
    9 |         vector<pair<int,int> >nGo[3001];
      |         ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <deque>
  +++ |+#include <vector>
    5 | using namespace std;
a.cc:9:30: error: expected primary-expression before '>' token
    9 |         vector<pair<int,int> >nGo[3001];
      |                              ^
a.cc:9:31: error: 'nGo' was not declared in this scope
    9 |         vector<pair<int,int> >nGo[3001];
      |                               ^~~
Language: C

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

typedef __int64 ll;
int max;

ll dist(int x1, int y1, int x2, int y2)
{
    if (abs(x2 - x1) + abs(y2 - y1) > max){
        max = abs(x2 - x1) + abs(y2 - y1);
    }
    return (2 * (abs(x2 - x1) + abs(y2 - y1)));
}

int comp(const void *a, const void * b)
{
    int x, y;
    
    x = *(int *)a;
    y = *(int *)b;
    
    return (x - y);
}

int main(void)
{
    static int hx[100000], hy[100000];
    static int mx[100000], my[100000];
    int i;
    int w, h, n;
    int pivx, pivy;
    ll res;
    
    scanf("%d%d", &w, &h);
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%d%d", &hx[i], &hy[i]);
    }
    
    memcpy(my, hy, sizeof(hy));
    memcpy(mx, hx, sizeof(hx));
    
    qsort(hx, n, sizeof(int), comp);
    qsort(hy, n, sizeof(int), comp);
    
    pivx = hx[(n - 1) / 2];
    pivy = hy[(n - 1) / 2];
    
    res = 0;
    
    for (i = 0; i < n; i++){
        res += dist(pivx, pivy, mx[i], my[i]);
    }
    res -= max;
    
    printf("%I64d\n%d %d\n", res, pivx, pivy);
    
    return (0);
}

Compiler output:
main.c:6:9: error: unknown type name '__int64'; did you mean '__int64_t'?
    6 | typedef __int64 ll;
      |         ^~~~~~~
      |         __int64_t
Language: C++

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

long long h, w, n, x[1000000], y[1000000], ex[1000000], ey[1000000], sum, d[1000000], bx, by;
long long sx[1000000], sy[1000000], sumx, sumy, mn, dx = 1145141145141919810LL, dy = 1145141145141919810LL, cx, cy, minx = 1145141145141919810LL;
vector<int>mx, my;
long long hx, hy, fx, fy;

int main() {
	cin >> h >> w >> n;
	x[0] = 0; y[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
		sumx += x[i];
		sumy += y[i];
		ex[i] = x[i];
		ey[i] = y[i];
	}
	sort(x + 1, x + n + 1);
	sort(y + 1, y + n + 1);

	for (int i = 1; i <= n; i++) {
		sumx += (-n - 2 + i * 2)*(x[i] - x[i - 1]);
		sx[i] = sumx;
	}
	for (int i = 1; i <= n; i++) {
		sumy += (-n - 2 + i * 2)*(y[i] - y[i - 1]);
		sy[i] = sumy;
	}
	for (int i = 1; i <= n; i++) {
		if (dx > sx[i]) { dx = sx[i]; mx.clear(); mx.push_back(x[i]); }
		if (dx == sx[i]) { mx.push_back(x[i]); }
	}
	for (int i = 1; i <= n; i++) {
		if (dy > sy[i]) { dy = sy[i]; my.clear(); my.push_back(y[i]); }
		if (dy == sy[i]) { my.push_back(y[i]); }
	}
	for (int i = 0; i < mx.size(); i++) {
		if (i == 0) { fx++; }
		if (i >= 1) { if (mx[i] == mx[i - 1]) { fx++; } }
		if (fx > hx) { hx = fx; cx = mx[i]; }
	}
	for (int i = 0; i < my.size; i++) {
		if (i == 0) { fy++; }
		if (i >= 1) { if (my[i] == my[i - 1]) { fy++; } }
		if (fy > hy) { hy = fy; cy = my[i]; }
	}
	for (int i = 1; i <= n; i++) {
		d[i] = abs(ex[i] - cx) + abs(ey[i] - cy);
		sum += d[i] * 2;
	}
	sort(d, d + n);
	sum -= d[n - 1];
	cout << sum << endl << cx << ' ' << cy << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:32: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   46 |         for (int i = 0; i < my.size; i++) {
      |                             ~~~^~~~
      |                                    ()
Language: C++

#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;

struct P{
    int x;
    int y;
    p(){};
    P(int p1,int p2){
        x=p1;
        y=p2;
    }
};


int W,H;
int N;
int dis[100010];
vector<int> posx;
vector<int> posy;
vector<P> pos;

int dist(int x,int y){
    int res=0;
    for(int i=0;i<N;++i){
        int disx=abs(x-pos[i].x);
        int disy=abs(y-pos[i].y);
        dis[i]=disx+disy;
    }
    sort(dis,dis+N);
    for(int i=0;i<N-1;++i)res+=dis[i]*2;
    res+=dis[N-1];
    return res;
}

signed main(){
    cin>>W>>H;
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        posx.PB(x);
        posy.PB(y);
        pos.PB(P(x,y));
    }
    if(N%2!=0){
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int x=posx[N/2];
        int y=posy[N/2];
        int ans=dist(x,y);
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
    else{
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int ans=INF;
        int x,y;
        int d1=dist(posx[N/2-1],posy[N/2-1]);
        int d2=dist(posx[N/2-1],posy[N/2]);
        int d3=dist(posx[N/2],posy[N/2-1]);
        int d4=dist(posx[N/2],posy[N/2]);
        if(ans>d1){
            ans=d1;
            x=posx[N/2-1];
            y=posy[N/2-1];
        }
        if(ans>d2){
            ans=d2;
            x=posx[N/2-1];
            y=posy[N/2];
        }
        if(ans>d3){
            ans=d3;
            x=posx[N/2];
            y=posy[N/2-1];
        }
        if(ans>d4){
            ans=d4;
            x=posx[N/2];
            y=posy[N/2];
        }
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
}

Compiler output:
a.cc:14:5: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
   14 |     p(){};
      |     ^
a.cc: In member function 'int P::p()':
a.cc:14:9: warning: no return statement in function returning non-void [-Wreturn-type]
   14 |     p(){};
      |         ^
Language: C++

#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;

struct P{
    int x;
    int y;
    p(){}
    P(int p1,int p2){
        x=p1;
        y=p2;
    }
};


int W,H;
int N;
int dis[100010];
vector<int> posx;
vector<int> posy;
vector<P> pos;

int dist(int x,int y){
    int res=0;
    for(int i=0;i<N;++i){
        int disx=abs(x-pos[i].x);
        int disy=abs(y-pos[i].y);
        dis[i]=disx+disy;
    }
    sort(dis,dis+N);
    for(int i=0;i<N-1;++i)res+=dis[i]*2;
    res+=dis[N-1];
    return res;
}

signed main(){
    cin>>W>>H;
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        posx.PB(x);
        posy.PB(y);
        pos.PB(P(x,y));
    }
    if(N%2!=0){
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int x=posx[N/2];
        int y=posy[N/2];
        int ans=dist(x,y);
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
    else{
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int ans=INF;
        int x,y;
        int d1=dist(posx[N/2-1],posy[N/2-1]);
        int d2=dist(posx[N/2-1],posy[N/2]);
        int d3=dist(posx[N/2],posy[N/2-1]);
        int d4=dist(posx[N/2],posy[N/2]);
        if(ans>d1){
            ans=d1;
            x=posx[N/2-1];
            y=posy[N/2-1];
        }
        if(ans>d2){
            ans=d2;
            x=posx[N/2-1];
            y=posy[N/2];
        }
        if(ans>d3){
            ans=d3;
            x=posx[N/2];
            y=posy[N/2-1];
        }
        if(ans>d4){
            ans=d4;
            x=posx[N/2];
            y=posy[N/2];
        }
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
}

Compiler output:
a.cc:14:5: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
   14 |     p(){}
      |     ^
a.cc: In member function 'int P::p()':
a.cc:14:9: warning: no return statement in function returning non-void [-Wreturn-type]
   14 |     p(){}
      |         ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000000;

int main(){
  int w,h,n;
  scanf("%d%d%d",&w,&h,&n);
  int x[n],y[n],sx[n],sy[n];
  for(int i=0;i<n;i++){
    scanf("%d%d",x+i,y+i);
    sx[i] = x[i], sy[i] = y[i];
  }
  sort(sx,sx+n);
  sort(sy,sy+n);
  int xx[] = {sx[(n-1)/2],sx[(n-1)/2+1]};
  int yy[] = {sy[(n-1)/2],sy[(n-1)/2+1]};
  ll ans = INF;
  int x,y;
  for(int jugontyan=0;jugontyan<2;jugontyan++){
    int dekai = 0;
    ll t = 0;
    int px = xx[jugontyan], py = yy[jugontyan];
    for(int i=0;i<n;i++){
      if(dekai<abs(x[i]-px)+abs(y[i]-py)) dekai = abs(x[i]-px) + abs(y[i]-py);
      t += abs(x[i]-px) + abs(y[i]-py);
    }
    t = t * 2 - dekai;
    if(ans<t){
      ans = t;
      x = px, y = py;
    }
  }
  printf("%lld\n%d %d\n",ans,x,y);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:7: error: conflicting declaration 'int x'
   24 |   int x,y;
      |       ^
a.cc:14:7: note: previous declaration as 'int x [n]'
   14 |   int x[n],y[n],sx[n],sy[n];
      |       ^
a.cc:24:9: error: conflicting declaration 'int y'
   24 |   int x,y;
      |         ^
a.cc:14:12: note: previous declaration as 'int y [n]'
   14 |   int x[n],y[n],sx[n],sy[n];
      |            ^
a.cc:36:9: error: incompatible types in assignment of 'int' to 'int [n]'
   36 |       x = px, y = py;
      |       ~~^~~~
a.cc:36:17: error: incompatible types in assignment of 'int' to 'int [n]'
   36 |       x = px, y = py;
      |               ~~^~~~
Language: Java


import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	Bag[] bags;
	int n;
	
	boolean ok(int x) {
		long sum = 0;
		
		PriorityQueue<Bag> que = new PriorityQueue<P0564.Bag>(1, new Comp());
		
		for(int i=0;i<x-1;i++) que.add(bags[i]);
		
		for(int i=0;i<x-1;i++) sum += bags[i].a;
		
		for(int i=x-1;i<n;i++) {
			long min = x * bags[i].b - bags[i].a;
			if( sum <= min ) return true;
			sum += bags[i].a;
			que.add(bags[i]);
			sum -= que.remove().a;
		}
		
		return false;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		bags = new Bag[n];
		
		for(int i=0;i<n;i++) bags[i] = new Bag(Integer.parseInt( sc.next() ), Integer.parseInt( sc.next() ) );
		sort(bags);
		int l = 0, r = n-1;
		
		while( r-l>1 ) {
			int c = (l+r) / 2;
			if( ok(c) ) l = c;
			else r = c;
		}
		System.out.println(l);
	}
	
	class Bag implements Comparable<Bag>{
		int a, b;
		Bag(int a, int b) {
			this.a = a;
			this.b = b;
		}
		@Override
		public int compareTo(Bag o) {
			// TODO 自動生成されたメソッド・スタブ
			return o.b - b;
		}
	}
	
	class Comp implements Comparator<Bag> {

		@Override
		public int compare(Bag o1, Bag o2) {
			// TODO 自動生成されたメソッド・スタブ
			return o2.a - o1.a;
		}
		
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Compiler output:
Main.java:16: error: package P0564 does not exist
		PriorityQueue<Bag> que = new PriorityQueue<P0564.Bag>(1, new Comp());
		                                                ^
1 error
Language: C

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

typedef __int64 ll;
typedef struct {
    ll a, b;
} BUG;

BUG foo[300000];
int n;

int seg[1 << 19][2];
int seg_size;

ll _max(ll a, ll b)
{
    return (a > b ? a : b);
}

void init(int n)
{
    seg_size = 1;
    
    while (n > seg_size){
        seg_size *= 2;
    }
    memset(seg, -1, sizeof(seg));
}

void update(int k, int x)
{
    k += seg_size;
    
    seg[k][0] = x;
    seg[k][1] = k - seg_size;
    
    while (k != 0){
        k = (k - 1) / 2;
        if (seg[k * 2 + 1][0] > seg[k * 2 + 2][0]){
            seg[k][0] = seg[k * 2 + 1][0];
            seg[k][1] = seg[k * 2 + 1][1];
        }
        else {
            seg[k][0] = seg[k * 2 + 2][0];
            seg[k][1] = seg[k * 2 + 2][1];
        }
    }
}

int comp(const void *a, const void *b)
{
    BUG x, y;
    x = *(BUG *)a;
    y = *(BUG *)b;
    
    if (x.b != y.b){
        return (y.b - x.b);
    }
    else {
        return (x.a - y.a);
    }
}

int canPut(int piv)
{
    int i;
    int pos;
    ll lim;
    
    init(piv);
    
    lim = 0;
    for (i = 0; i < piv - 1; i++){
        lim += foo[i].a;
        update(i, foo[i].a);
    }
    
    while (i < n){
        if (i == piv - 1){
            lim += foo[i].a;
            update(i, foo[i].a);
        }
        else {
            pos = seg[0][1];
            lim -= seg[0][0];
            lim += foo[i].a;
            update(pos, foo[i].a);
        }
        
        if (lim <= foo[i].b * piv){
            return (1);
        }
        i++;
    }
    
    return (0);
}

int main(void)
{
    int i;
    int left, right, center;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%I64d %I64d", &foo[i].a, &foo[i].b);
    }
    
    left = 0;
    right = n;
    
    qsort(foo, n, sizeof(BUG), comp);
    
    while (left != right){
        center = (left + right + 1) / 2;
        
        if (canPut(center)){
            left = center;
        }
        else {
            right = center - 1;
        }
    }
    
    printf("%d\n", left);
    
    return (0);
}

Compiler output:
main.c:5:9: error: unknown type name '__int64'; did you mean '__int64_t'?
    5 | typedef __int64 ll;
      |         ^~~~~~~
      |         __int64_t
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <cstring>
#include <cmath>

using namespace std;
const long double eps = 1e-12;

typedef long long ll;
typedef pair<int , int> pt;

#define sz(a) ((int) a.size() )
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)
#define For(i , a , b) for (int i = a ; i <= b ; i++)
#define Ford(i , a , b) for (int i = a ; i >= b ; i--)
#define Rep(i , n) for (int i = 0 ; i < n ; i++)

const int maxn = 300000 + 1912;
int n;
pt a[maxn];

void ReadData() {
    scanf("%d" , &n);
    For(i , 1 , n) scanf("%d%d" , &a[i].first , &a[i].second);
}

bool cmp(pt a , pt b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
}

priority_queue<int> qu;

void Process() {
    int res = 0;
    long long sum = 0;
    sort(a + 1 , a + 1 + n , cmp);
    For(i , 1 , n) {
        qu.push(a[i].first);
        sum += a[i].first;
        while (sz(qu) && sum > 1LL * a[i].second * sz(qu)) {
             sum -= qu.top();s
             qu.pop();
        }
        res = max(res , sz(qu));
    }
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  //  freopen("/users/youaremysky/documents/workspace/input.inp" , "r" , stdin);
    ReadData();
    Process();
}

Compiler output:
a.cc: In function 'void Process()':
a.cc:49:30: error: 's' was not declared in this scope
   49 |              sum -= qu.top();s
      |                              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

using namespace std;

#define int long long

struct segtree {
    vector<int> dat;
    int n;

    segtree(int n_) {
        n = 1;

        while (n < n_) n *= 2;

        dat.resize(2*n, 0);
    }

    void update(int i, int x) {
        i += n - 1;
        int diff = x - dat[i];
        dat[i] = x;

        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] += diff;
        }
    }

    int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;

        if (r <= a || l >= b) return 0;

        if (a <= l && r <= b) {
            return dat[k];
        }

        int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);

        return lv + rv;
    }
};

int main()
{
    int N; cin >> N;
    vector<int> a(N), b(N);

    segtree P(N), Q(N);
    vector<tuple<int, int, int>> tmp;

    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
        tmp.push_back(make_tuple(a[i], i, b[i]));
    }

    sort(begin(a), end(a));
    sort(begin(tmp), end(tmp));

    vector<pair<int, int>> data;

    for (int i = 0; i < N; ++i) {
        int aaa, bbb, val;
        tie(aaa, bbb, val) = tmp[i];
        data.push_back(make_pair(val, i));
    }

    sort(begin(data), end(data));
    
    for (int i = 0; i < N; ++i) {
        P.update(i, a[i]);
        Q.update(i, 1);
    }

    int ma = 0;

    for (int i = 0; i < N; ++i) {
        pair<int, int> d = data[i];

        int l = d.second, r = N-1;

        int to = 1;

        {
            int n = N;
            while (n>1) {n /= 2; to++;}
        }

        for (int j = 0; j < to; ++j) {
            int mid = (l + r) / 2;
            int PP = P.query(0, mid + 1);
            int QQ = Q.query(0, mid + 1);
            double v = double(PP) / QQ;

            if (v <= d.first) {
                l = mid;
            } else {
                r = mid;
            }
        }

        P.update(d.second, 0);
        Q.update(d.second, 0);

        ma = max(ma, Q.query(0, l+1));
    }

    cout << ma + 1 << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'