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

10 10
100
IJJOIIJOOJ
OIOOOJIIIJ
IJJOJOIIOI
JJJOJOOIJJ
JJJIIJOIJI
JIOJOOOIIJ
OJJIIOJJOI
OIOJIIJJJJ
IJOOOOOJJO
OIIJJJOIII
2 1 7 4
7 6 9 6
8 2 9 8
2 1 5 5
4 1 7 9
6 6 6 10
1 4 10 8
8 1 10 6
2 2 5 7
2 2 5 3
6 2 10 5
2 5 7 8
4 4 9 10
2 3 10 6
1 1 10 8
6 6 6 9
3 1 3 8
3 4 3 10
5 1 6 4
1 1 10 8
1 3 1 9
2 2 2 4
1 1 6 6
2 3 10 7
3 3 7 4
7 4 8 6
3 5 9 9
6 10 10 10
6 6 8 9
2 8 10 8
3 5 10 7
5 6 5 7
3 5 6 6
3 6 6 8
7 3 10 9
6 1 9 2
2 1 8 6
1 1 4 10
4 3 6 8
4 4 5 4
5 2 6 8
1 1 4 6
5 4 10 9
4 3 10 7
1 2 2 7
8 1 10 2
1 9 2 10
7 1 8 2
7 2 9 3
1 6 1 8
7 7 10 10
2 1 5 3
1 7 4 7
1 3 6 8
7 1 10 7
6 7 9 9
9 4 10 5
3 2 9 3
4 1 10 6
4 5 6 8
2 8 3 9
8 2 10 9
2 4 4 6
1 7 5 9
3 1 8 4
10 2 10 8
2 1 9 3
6 6 7 8
3 2 6 4
3 1 5 1
4 2 10 2
3 3 8 7
8 7 9 7
2 5 7 6
3 4 4 6
1 3 7 7
1 4 6 7
8 3 8 8
4 4 8 9
2 3 8 8
3 9 5 10
3 3 7 8
2 1 5 3
5 3 7 10
2 4 7 5
4 7 8 9
3 5 10 5
4 5 8 9
3 1 8 6
1 4 3 9
8 8 8 9
3 2 10 7
5 6 10 8
8 1 9 4
6 3 7 6
2 1 9 4
3 1 8 6
2 5 8 6
3 4 6 5
2 7 2 9

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

#include <iostream>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
//小数制度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back


	int map_j[1010][1010];
	int map_o[1010][1010];
	int map_i[1010][1010];

int main(){
	int h,w;
	ll int kk;
	cin >> h >> w;
	cin >> kk;
	string st;
	vector < string > joi;
	REP(i,h){
		cin >> str;
		joi.pb(st);
	}

	string hit = "JOI";

	int tmp = 0;
	
		FOR(j,1,w+2){
			if(joi[0][j-1]==hit[0]) tmp++;
			map_j[1][j] = tmp;
		}
		FOR(j,2,h+2){
			tmp = 0;
			FOR(k,1,w+2){
				if(joi[j-1][k-1]==hit[0]) tmp++;
				map_j[j][k] = map_j[j-1][k]+tmp;
			}
		}
		FOR(j,1,w+2){
			if(joi[0][j-1]==hit[1]) tmp++;
			map_o[1][j] = tmp;
		}
		FOR(j,2,h+2){
			tmp = 0;
			FOR(k,1,w+1){
				if(joi[j-1][k-1]==hit[1]) tmp++;
				map_o[j][k] = map_o[j-1][k]+tmp;
			}
		}
		FOR(j,1,w+2){
			if(joi[0][j-1]==hit[2]) tmp++;
			map_i[1][j] = tmp;
		}
		FOR(j,2,h+2){
			tmp = 0;
			FOR(k,1,w+2){
				if(joi[j-1][k-1]==hit[2]) tmp++;
				map_i[j][k] = map_i[j-1][k]+tmp;
			}
		}	

	REP(i,kk){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int t[3];
			t[0] = map_j[x2][y2]+map_j[x1-1][y1-1]-map_j[x1-1][y2]-map_j[x2][y1-1];
			t[1] = map_o[x2][y2]+map_o[x1-1][y1-1]-map_o[x1-1][y2]-map_o[x2][y1-1];
			t[2] = map_i[x2][y2]+map_i[x1-1][y1-1]-map_i[x1-1][y2]-map_i[x2][y1-1];
		
		cout << t[0] << " " << t[1] << " " << t[2]<<endl;
 	}
 	return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:24: error: 'str' was not declared in this scope; did you mean 'st'?
   35 |                 cin >> str;
      |                        ^~~
      |                        st
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
#include <cmath>
#include <string>
//#include <sstream>
#include <iomanip>
//#include <complex>
//小数制度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back


int map_j[1010][1010];
int map_o[1010][1010];
int map_i[1010][1010];

int main(){
	int h,w;
	ll int kk;
	cin >> h >> w >> k;
	string st;
	vector < string > joi;
	REP(i,h){
		cin >> st;
		joi.pb(st);
	}

	string hit = "JOI";

	int tmp = 0;
	
		FOR(j,1,w+2){
			if(joi[0][j-1]==hit[0]) tmp++;
			map_j[1][j] = tmp;
		}
		FOR(j,2,h+2){
			tmp = 0;
			FOR(k,1,w+2){
				if(joi[j-1][k-1]==hit[0]) tmp++;
				map_j[j][k] = map_j[j-1][k]+tmp;
			}
		}
		FOR(j,1,w+2){
			if(joi[0][j-1]==hit[1]) tmp++;
			map_o[1][j] = tmp;
		}
		FOR(j,2,h+2){
			tmp = 0;
			FOR(k,1,w+1){
				if(joi[j-1][k-1]==hit[1]) tmp++;
				map_o[j][k] = map_o[j-1][k]+tmp;
			}
		}
		FOR(j,1,w+2){
			if(joi[0][j-1]==hit[2]) tmp++;
			map_i[1][j] = tmp;
		}
		FOR(j,2,h+2){
			tmp = 0;
			FOR(k,1,w+2){
				if(joi[j-1][k-1]==hit[2]) tmp++;
				map_i[j][k] = map_i[j-1][k]+tmp;
			}
		}	

	REP(i,kk){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int t[3];
			t[0] = map_j[x2][y2]+map_j[x1-1][y1-1]-map_j[x1-1][y2]-map_j[x2][y1-1];
			t[1] = map_o[x2][y2]+map_o[x1-1][y1-1]-map_o[x1-1][y2]-map_o[x2][y1-1];
			t[2] = map_i[x2][y2]+map_i[x1-1][y1-1]-map_i[x1-1][y2]-map_i[x2][y1-1];
		
		cout << t[0] << " " << t[1] << " " << t[2]<<endl;
 	}
 	return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:26: error: 'k' was not declared in this scope; did you mean 'kk'?
   30 |         cin >> h >> w >> k;
      |                          ^
      |                          kk
Language: C++

#include<iostream>
#include<string>

using namespace std;

#define NMAX 999
#define MMAX 999

int main(){

    int M,N;
    int K;
    int J[NMAX+1][MMAX+1]={0};
    int O[NMAX+1][MMAX+1]={0};
    int a,b,c,d;
    string in;

    cin>>M>>N;
    cin>>K;

    for(int i=1;i<=M;i++){
        cin>>in;
        for(int j=0;j<N;j++){
            if(in[j]=='J') J[i][j+1]=1;
            else if(in[j]=='O') O[i][j+1]=1;
            else if(in[j]=='I') I[i][j+1]=1;
        }
    }

    for(int i=1;i<=M;i++){
        for(int j=1;j<=N;j++){
            J[i][j]+=J[i][j-1];
            O[i][j]+=O[i][j-1];
            I[i][j]+=I[i][j-1];
        }
    }

    for(int i=1;i<=N;i++){
         for(int j=1;j<=M;j++){
            J[j][i]+=J[j-1][i];
            O[j][i]+=O[j-1][i];
            I[j][i]+=I[j-1][i];
        }
    }

    for(int i=0;i<K;i++){
        cin>>a>>b>>c>>d;
        cout<<J[c][d]-J[c][b-1]-J[a-1][d]+J[a-1][b-1]<<" "<<O[c][d]-O[c][b-1]-O[a-1][d]+O[a-1][b-1]<<" "<<I[c][d]-I[c][b-1]-I[a-1][d]+I[a-1][b-1]<<endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:33: error: 'I' was not declared in this scope
   26 |             else if(in[j]=='I') I[i][j+1]=1;
      |                                 ^
a.cc:34:13: error: 'I' was not declared in this scope
   34 |             I[i][j]+=I[i][j-1];
      |             ^
a.cc:42:13: error: 'I' was not declared in this scope
   42 |             I[j][i]+=I[j-1][i];
      |             ^
a.cc:48:107: error: 'I' was not declared in this scope
   48 |         cout<<J[c][d]-J[c][b-1]-J[a-1][d]+J[a-1][b-1]<<" "<<O[c][d]-O[c][b-1]-O[a-1][d]+O[a-1][b-1]<<" "<<I[c][d]-I[c][b-1]-I[a-1][d]+I[a-1][b-1]<<endl;
      |                                                                                                           ^
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int M, N; cin >> M >> N;
	int K; cin >> K;
	map<char, int>mp;
	mp['J'] = 0;
	mp['O'] = 1;
	mp['I'] = 2;
	vector<vector<vector<int>>>sums(M+1, vector<vector<int>>(N+1, vector<int>(3)));
	for (int i = 0; i < M; ++i) {
		string st; cin >> st;
		for (int j = 0; j < N; ++j) {
			sums[i + 1][j + 1][mp[st[j]]]++;
		}
	}
	for (int k = 0; k < 3; ++k) {
		for (int i = 1; i <= M; ++i) {
			for (int j = 1; j <= N; ++j) {
				sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
			}
		}
	}
	nums.clear();
	for (int i = 0; i < K; ++i) {
		int a, b, c, d; cin >> b >> a >> d >> c;
		b--; a--;
		vector<int> anss(3);
		for (int j = 0; j < 3; ++j) {
			anss[j] = sums[d][c][j]-sums[d][a][j] -sums[b][c][j] + sums[b][a][j];
		}
		cout << anss[0] << " " << anss[1] << " " << anss[2] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:114: error: 'nums' was not declared in this scope; did you mean 'sums'?
   29 |                                 sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
      |                                                                                                                  ^~~~
      |                                                                                                                  sums
a.cc:33:9: error: 'nums' was not declared in this scope; did you mean 'sums'?
   33 |         nums.clear();
      |         ^~~~
      |         sums
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int M, N; cin >> M >> N;
	int K; cin >> K;
	map<char, int>mp;
	mp['J'] = 0;
	mp['O'] = 1;
	mp['I'] = 2;
	vector<vector<vector<int>>>sums(M+1, vector<vector<int>>(N+1, vector<int>(3)));
	for (int i = 0; i < M; ++i) {
		string st; cin >> st;
		for (int j = 0; j < N; ++j) {
			sums[i + 1][j + 1][mp[st[j]]]++;
		}
	}
	for (int k = 0; k < 3; ++k) {
		for (int i = 1; i <= M; ++i) {
			for (int j = 1; j <= N; ++j) {
				sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
			}
		}
	}
	for (int i = 0; i < K; ++i) {
		int a, b, c, d; cin >> b >> a >> d >> c;
		b--; a--;
		vector<int> anss(3);
		for (int j = 0; j < 3; ++j) {
			anss[j] = sums[d][c][j]-sums[d][a][j] -sums[b][c][j] + sums[b][a][j];
		}
		cout << anss[0] << " " << anss[1] << " " << anss[2] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:114: error: 'nums' was not declared in this scope; did you mean 'sums'?
   29 |                                 sums[i][j][k] += sums[i][j - 1][k] + sums[i - 1][j][k] - sums[i - 1][j - 1][k] + nums[i][j][k];
      |                                                                                                                  ^~~~
      |                                                                                                                  sums
Language: C++

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

#define loop(i,n) for(int i=1;i<=n;i++)
int jj[1002][1002];
int oo[1002][1002];
int ii[1002][1002];

int main(){
  int m,n,k;
  cin>>m>>n>>k;
  char c;
  loop(i,m)loop(j,n){
    cin>>c;
    jj[i][j]=jj[i-1][j]+jj[i][j-1]-jj[i-1][j-1];
    oo[i][j]=oo[i-1][j]+oo[i][j-1]-oo[i-1][j-1];
    ii[i][j]=ii[i-1][j]+ii[i][j-1]-ii[i-1][j-1];
    if(c=='J')jj[i][j]++;
    if(c=='O')oo[i][j]++;
    if(c=='I')ii[i][j]++;
  }
  int a,b,c,d;
  loop(i,k){
    cin>>a>>b>>c>>d;
    a--;
    b--;
    cout<<(jj[c][d]-jj[a][d]-jj[c][b]+jj[a][b]);
    cout<<" ";
    cout<<(oo[c][d]-oo[a][d]-oo[c][b]+oo[a][b]);
    cout<<" ";
    cout<<(ii[c][d]-ii[a][d]-ii[c][b]+ii[a][b]);
    cout<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:11: error: conflicting declaration 'int c'
   22 |   int a,b,c,d;
      |           ^
a.cc:12:8: note: previous declaration as 'char c'
   12 |   char c;
      |        ^
Language: C++

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;

int a[100000] = {}, b[100000] = {}, c[100000] = {}, d[100000] = {};
int memo[1000][1000][1000][3]= {};
char w[1000][1000] = {};

signed main(){
	int M, N, K; cin >> M >> N >>K;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			cin >> w[i][j];
		}
	}
	for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++){
			int t1 = 0, t2 = 0, t3 = 0;
			for (int k = j; k < N; k++) {
				if (w[i][k] == 'J') t1++;
				else if (w[i][k] == 'O')t2++;
				else t3++;
				memo[j][k][i][0] = t1;
				memo[j][k][i][1] = t2;
				memo[j][k][i][2] = t3;
//<<"i"<<i<<" j"<<j<<" k"<<k<<" "<< t1 << " " << t2 << " " << t3 << endl;
			}
		}
	}
	
	for (int i = 0; i < K; i++) {
		int t1 = 0, t2 = 0, t3 = 0;
		for (int j = a[i]-1; j < c[i]; j++) {
			t1 += memo[b[i]-1][d[i]-1][j][0];
			t2 += memo[b[i]-1][d[i]-1][j][1];
			t3 += memo[b[i]-1][d[i]-1][j][2];
		}
		cout << t1 << " " << t2 << " " << t3 << endl;
	}
	
}

Compiler output:
/tmp/ccytGWTN.o: in function `main':
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytGWTN.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytGWTN.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccytGWTN.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;

int a[100000] = {}, b[100000] = {}, c[100000] = {}, d[100000] = {};
int memo[1000][1000][1000][3]= {};
char w[1000][1000] = {};

signed main(){
	int M, N, K; cin >> M >> N >>K;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			cin >> w[i][j];
		}
	}
	for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++){
			int t1 = 0, t2 = 0, t3 = 0;
			for (int k = j; k < N; k++) {
				if (w[i][k] == 'J') t1++;
				else if (w[i][k] == 'O')t2++;
				else t3++;
				memo[j][k][i][0] = t1;
				memo[j][k][i][1] = t2;
				memo[j][k][i][2] = t3;
//<<"i"<<i<<" j"<<j<<" k"<<k<<" "<< t1 << " " << t2 << " " << t3 << endl;
			}
		}
	}
	
	for (int i = 0; i < K; i++) {
		int t1 = 0, t2 = 0, t3 = 0;
		for (int j = a[i]-1; j < c[i]; j++) {
			t1 += memo[b[i]-1][d[i]-1][j][0];
			t2 += memo[b[i]-1][d[i]-1][j][1];
			t3 += memo[b[i]-1][d[i]-1][j][2];
		}
		cout << t1 << " " << t2 << " " << t3 << endl;
	}
	
}

Compiler output:
/tmp/ccjasESf.o: in function `main':
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccjasESf.o
a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccjasESf.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccjasESf.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>
 
using namespace std;
#define int long long
const int mod = 1000000007;
 
int a[1000001] = {}, b[1000001] = {}, c[1000001] = {}, d[1000001] = {};
int memo[10001][10001][3]= {};
char w[10001][10001] = {};
 
signed main(){
    int M, N, K; cin >> M >> N >>K;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            cin >> w[i][j];
        }
    }
    for (int i = 0; i < K; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    for (int i = 0; i < M; i++) {
        int t1 = 0,t2=0,t3=0;
        for (int j = 0; j < N; j++) {
            if (w[i][j] == 'J')t1++;
            else if (w[i][j] == 'O')t2++;
            else t3++;
 
            if (i == 0) {
                memo[i][j][0] = t1;
                memo[i][j][1] = t2;
                memo[i][j][2] = t3;
            }
            else {
                memo[i][j][0] = memo[i-1][j][0] + t1;
                memo[i][j][1] = memo[i-1][j][1] + t2;
                memo[i][j][2] = memo[i-1][j][2] + t3;
            }
            //cout << " i" << i << " j" << j << " " << memo[i][j][0] << memo[i][j][1] << memo[i][j][2];
        }
        //cout << endl;
    }
    for (int i = 0; i < K; i++) {
        int a1, a2, a3;
        a1 = memo[c[i] - 1][d[i] - 1][0] - memo[a[i]-2][d[i]-1][0] - memo[c[i]-1][b[i]-2][0] + memo[a[i]-2][b[i]-2][0];
        a2 = memo[c[i] - 1][d[i] - 1][1] - memo[a[i] - 2][d[i] - 1][1] - memo[c[i] - 1][b[i] - 2][1] + memo[a[i] - 2][b[i] - 2][1];
        a3 = memo[c[i] - 1][d[i] - 1][2] - memo[a[i] - 2][d[i] - 1][2] - memo[c[i] - 1][b[i] - 2][2] + memo[a[i] - 2][b[i] - 2][2];
        cout << a1 << " " << a2 << " " << a3 << endl;
 
 
    }
     
}

Compiler output:
/tmp/cctLCG6G.o: in function `main':
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctLCG6G.o
a.cc:(.text+0x19d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctLCG6G.o
a.cc:(.text+0x1c7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cctLCG6G.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string s[9999];
int h,w,dp[1002][10002][3],a,b,c,d,n;
main(){
  cin>>h>>w>>n;
  r(i,w+1)s[0]+='@';
  r(i,h)cin>>s[i+1],s[i+1]='@'+s[i+1];
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++){
      r(k,3)dp[i][j][k]+=dp[i][j-1][k];
      if(s[i][j]=='J')dp[i][j][0]++;
      if(s[i][j]=='O')dp[i][j][1]++;
      if(s[i][j]=='I')dp[i][j][2]++;
    }
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      r(k,3)dp[i][j][k]+=dp[i-1][j][k];
  while(n--){
    scanf("%d%d%d%d",&a,&b,&c,&d)a--;b--;
    cout<<dp[c][d][0]-dp[a][d][0]-dp[c][b][0]+dp[a][b][0]<<' ';
    cout<<dp[c][d][1]-dp[a][d][1]-dp[c][b][1]+dp[a][b][1]<<' ';
    cout<<dp[c][d][2]-dp[a][d][2]-dp[c][b][2]+dp[a][b][2]<<endl;
  }
}

Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:21:34: error: expected ';' before 'a'
   21 |     scanf("%d%d%d%d",&a,&b,&c,&d)a--;b--;
      |                                  ^
      |                                  ;
Language: C++

#include <iostream>
using namespace std;
int main(){
int m;
cin >>m;
int n;
cin >>n;
int k;
cin >>k;
int a[m][n];//上からm 左からnまでにあるJの個数
int b[m][n];//O
int c[m][n];//I
int j;//ある行においてマスまでに何個Jがあるか
int o;
int i;
char d;
int e;
int f;
e=0;
j=0;
o=0;
i=0;
while(e<n){
cin >>d;
if(d=="J"){j=j+1;}
if(d=="O"){o=o+1;}
if(d=="I"){i=i+1;}
a[0][e]=j;
b[0][e]=o;
c[0][e]=i;
e=e+1;}
f=1;
while(f<m){
e=0;
j=0;
o=0;
i=0;
while(e<n){
cin >>d;
if(d=="J"){j=j+1;}
if(d=="O"){o=o+1;}
if(d=="I"){i=i+1;}
a[f][e]=a[f-1][e]+j;
b[f][e]=b[f-1][e]+o;
c[f][e]=c[f-1][e]+i;
e=e+1;}
f=f+1;}
int p;
int q;
int r;
int s;
int t;
int u;
int v;
e=0;
while(e<k){
cin >>p;
cin >>q;
cin >>r;
cin >>s;
t=a[r-1][s-1]-a[r-1][q-2]-a[p-2][s-1]+a[p-2][q-2];
u=b[r-1][s-1]-b[r-1][q-2]-b[p-2][s-1]+b[p-2][q-2];
v=c[r-1][s-1]-c[r-1][q-2]-c[p-2][s-1]+c[p-2][q-2];
cout <<t<<" "<<u<<" "<<v<<endl;
e=e+1;}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 | if(d=="J"){j=j+1;}
      |    ~^~~~~
a.cc:26:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 | if(d=="O"){o=o+1;}
      |    ~^~~~~
a.cc:27:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 | if(d=="I"){i=i+1;}
      |    ~^~~~~
a.cc:40:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   40 | if(d=="J"){j=j+1;}
      |    ~^~~~~
a.cc:41:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   41 | if(d=="O"){o=o+1;}
      |    ~^~~~~
a.cc:42:5: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   42 | if(d=="I"){i=i+1;}
      |    ~^~~~~
Language: C++

#include <cstdio>
int exist[1001][1001][3]={};
char field[1001][1001];
int m,n,Q;
int main(){
	scanf("%d %d %d",&m,&n,&Q);
	for(int i=0;i<m;i++){
			scanf("%s",field[i]);
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			for(int g=i;g<m;g++){
				for(int k=j;k<n;k++){
					if(field[i][j]=='J'){
						exist[g][k][0]++;
					}else if(field[i][j]=='O'){
						exist[g][k][1]++;
					}else{
						exist[g][k][2]++;
					}
				}
			}
		}
	}
	for(int i=0;i<Q;i++){
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		printf("%d %d %d\n",exist[c-1][d-1][0]-exist[c-1][b-2][0]-exist[a-2][d-1][0]+exist[a-2][b-2][0],exist[c-1][d-1][1]-exist[c-1][b-2][1]-exist[a-2][d-1][1]+exist[a-2][b-2][1],exist[c-1][d-1][2]-exist[c-1][b-2][2]-exist[a-2][d-1][2]+exist[a-2][b-2][2]);
	return 0;
}

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

#include <cstdio>

int joi2num(char c)
{
if(c == 'J') return 0;
if(c == 'O') return 1;
return 2;
}

int main()
{
int m, n, k;
char fld[1024][1024];
int sum[1024][1024][3];
scanf("%d%d%d", &m, &n, &k);
for(int x = 0; x < m; ++x)
scanf("%s", fld[x]);
for(int i = 0; i < 3; ++i)
sum[0][0][i] = (i == joi2num(fld[0][0]));
for(int x = 1; x < m; ++x) {
for(int i = 0; i < 3; ++i)
sum[x][0][i] = sum[x - 1][0][i] + (i == joi2num(fld[x][0]));
}
for(int y = 1; x < n; ++y) {
for(int i = 0; i < 3; ++i)
sum[0][y][i] = sum[x0][y - 1][i] + (i == joi2num(fld[0][y]));
}
for(int x = 1; x < m; ++x) {
for(int y = 1; y < n; ++y) {
for(int i = 0; i < 3; ++i) {
int temp = 0;
temp += sum[x - 1][y][i];
temp += sum[x][y - 1][i];
temp -= sum[x - 1][y - 1][i];
sum[x][y][i] = temp;
}
}
}
for(int i = 0; i < k; ++i) {
int ax, ay, bx, by;
scanf("%d%d%d%d", &ax, &ay, &bx, &by);
ax -= 1, ay -= 1, bx -= 1, by -= 1;
int ans[3] = {0};
for(int  j = 0; j < 3; ++j) {
ans[j] += sum[bx][by][j];
ans[j] -= ax > 0 ? sum[ax - 1][by][j] : 0;
ans[j] -= ay > 0 ? sum[bx][ay - 1][j] : 0;
ans[j] += ax > 0 && ay > 0 ? sum[ax - 1][ay - 1][j] : 0;
}
printf("%d %d %d\n", ans[0], ans[1], ans[2]);
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:16: error: 'x' was not declared in this scope
   24 | for(int y = 1; x < n; ++y) {
      |                ^
a.cc:26:20: error: 'x0' was not declared in this scope
   26 | sum[0][y][i] = sum[x0][y - 1][i] + (i == joi2num(fld[0][y]));
      |                    ^~
Language: C++

#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

char tt[1000][1000];
int jj[1000][1000];
int oo[1000][1000];
int ii[1000][1000];
int n, m , k;

void f(int, int);

int main(){
  cin >> m >> n;
  cin >> k;
  for(int i = 0; i < m; i++){
    scanf("%s", tt[i]);
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      f(i, j);
    }
  }
  while( cin >> y1 >> x1 >> y2 >> x2){
    int y1, x1, y2, x2;
    x1--; x1--; y1--; y1--; x2--; y2--;
    int jm = (jj[y1][x2] - jj[y1][x1]) + jj[y2][x1];
    int om = (oo[y1][x2] - oo[y1][x1]) + oo[y2][x1];
    int im = (ii[y1][x2] - ii[y1][x1]) + ii[y2][x1];
    printf("%d %d %d\n", jj[y2][x2] - jm, oo[y2][x2] - om, ii[y2][x2] - im);
  }

  return 0;
}

void f(int x, int y){
  if(x == 0 && y == 0){
    jj[0][0] = 0;
    ii[0][0] = 0;
    ii[0][0] = 0;
  }else if(x == 0){
    jj[y][0] = jj[y - 1][0];
    ii[y][0] = ii[y - 1][0];
    oo[y][0] = oo[y - 1][0];
  }else if(y == 0){
    jj[0][x] = jj[0][x - 1];
    ii[0][x] = ii[0][x - 1];
    oo[0][x] = oo[0][x - 1];
  }else{
    jj[y][x] = (jj[y - 1][x] - jj[y - 1][x - 1]) + jj[y][x - 1];
    oo[y][x] = (oo[y - 1][x] - oo[y - 1][x - 1]) + oo[y][x - 1];
    ii[y][x] = (ii[y - 1][x] - ii[y - 1][x - 1]) + ii[y][x - 1];
  }
    if(tt[y][x] == 'J')
      jj[y][x]++;
    else if(tt[y][x] == 'O')
      oo[y][x]++;
    else if(tt[y][x] == 'I')
      ii[y][x]++;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: 'y1' was not declared in this scope
   27 |   while( cin >> y1 >> x1 >> y2 >> x2){
      |                 ^~
a.cc:27:23: error: 'x1' was not declared in this scope
   27 |   while( cin >> y1 >> x1 >> y2 >> x2){
      |                       ^~
a.cc:27:29: error: 'y2' was not declared in this scope
   27 |   while( cin >> y1 >> x1 >> y2 >> x2){
      |                             ^~
a.cc:27:35: error: 'x2' was not declared in this scope
   27 |   while( cin >> y1 >> x1 >> y2 >> x2){
      |                                   ^~
Language: C++

12 7 5
0 2 1
5 6 3
10 6 4
16 11 9
1 2 2
15 19 16
5 7 6
10 9 5
6 1 1
7 6 7
6 9 9
16 14 12
13 16 7
29 27 24
0 2 2
3 2 3
1 3 3
5 1 2
29 27 24
2 3 2
0 2 1
16 12 8
15 21 9
5 3 2
1 1 4
12 13 10
2 1 2
5 4 3
3 0 6
7 12 5
1 1 0
3 4 1
1 6 5
12 9 7
3 2 3
17 15 10
15 13 12
5 8 5
0 1 1
4 5 5
10 9 5
14 11 11
12 16 7
4 4 4
1 2 3
2 1 1
1 2 1
3 2 1
1 1 1
8 4 4
8 2 2
1 1 2
10 15 11
9 11 8
7 3 2
2 2 0
9 3 2
17 14 11
2 6 4
0 1 3
10 7 7
3 6 0
3 5 7
13 6 5
3 1 3
12 7 5
2 3 1
7 3 2
2 0 1
4 0 3
11 12 7
1 1 0
4 6 2
2 4 0
12 15 8
6 12 6
3 1 2
11 9 10
14 15 13
3 1 2
10 11 9
8 2 2
8 7 9
3 5 4
7 4 4
3 2 3
9 8 8
16 11 9
3 8 7
2 0 0
19 18 11
7 7 4
2 4 2
2 4 2
14 11 7
16 11 9
4 6 4
3 3 2
0 0 3

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

#include <cstdio>
#include <algorithm>
using namespace std;
int field[1005][1005][3];
char field[1005][1005];
int n;
int w,h;
int main(){

Compiler output:
a.cc:5:6: error: conflicting declaration 'char field [1005][1005]'
    5 | char field[1005][1005];
      |      ^~~~~
a.cc:4:5: note: previous declaration as 'int field [1005][1005][3]'
    4 | int field[1005][1005][3];
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:8:12: error: expected '}' at end of input
    8 | int main(){
      |           ~^
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;
int rui[1005][1005][3]={};
char field[1005][1005];
int n;
int w,h;
int main(){
  scanf("%d %d",&w,&h);
  scanf("%d",&n);
  for(int i=1;i<=w;i++){
    scanf("%s",&field[i]);
  }
  for(int i=1;i<=w;i++){
    for(int j=h;j>=1;j--){
      field[i][j]=field[i][j-1];
    }
  }
  for(int i=1;i<=w;i++){
    for(int j=1;j<=h;j++){
      for(int k=0;k<3;k++){
        rui[i][j][0]=rui[i][j-1][0]+rui[i-1][j][0]-rui[i-1][j-1];
      }
    if(field[i][j]=='J') rui[i][j][0]++;
    else if(field[i][j]=='O') rui[i][j][1]++;
    else rui[i][j][2]+++
    }
  }
  for(int i=0;i<n;i++){
    

Compiler output:
a.cc: In function 'int main()':
a.cc:22:51: error: invalid operands of types 'int' and 'int [3]' to binary 'operator-'
   22 |         rui[i][j][0]=rui[i][j-1][0]+rui[i-1][j][0]-rui[i-1][j-1];
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
      |                                    |                           |
      |                                    int                         int [3]
a.cc:27:5: error: expected primary-expression before '}' token
   27 |     }
      |     ^
a.cc:29:24: error: expected '}' at end of input
   29 |   for(int i=0;i<n;i++){
      |                       ~^
a.cc:29:24: error: expected '}' at end of input
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: C++

#include<cstdio>

int d[3][1002][1002], N, M, K;

int main()
{
        char buf[1024];

        scanf("%d%d%d", &N, &M, &K);

        for (int i = 1; i <= N; i++) {
                scanf("%s", buf + 1);
                for (int j = 1; j <= M; j++)  {
                        for (int k = 0; k < 3; k++) {
                                d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
                        }
                        switch (buf[j]) {
                                case 'J': d[0][i][j]++;break;
                                case 'O': d[1][i][j]++;break;
                                case 'I': d[2][i][j]++;
                        }
                }
        }

        while (K--) {
                int x1, y1, x2, y2;
                scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
                for (int i = 0; i < 3; i++) {
                        printf("%d ", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
                }
                k?puts(""):0;
        }

        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: 'k' was not declared in this scope
   31 |                 k?puts(""):0;
      |                 ^
Language: C++

#include<cstdio>

int d[3][1002][1002], N, M, K;

int main()
{
        char buf[1024];

        scanf("%d%d%d", &N, &M, &K);

        for (int i = 1; i <= N; i++) {
                scanf("%s", buf + 1);
                for (int j = 1; j <= M; j++)  {
                        for (int k = 0; k < 3; k++) {
                                d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
                        }
                        switch (buf[j]) {
                                case 'J': d[0][i][j]++;break;
                                case 'O': d[1][i][j]++;break;
                                case 'I': d[2][i][j]++;
                        }
                }
        }

        while (K--) {
                int x1, y1, x2, y2;
                scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
                for (int i = 0; i < 3; i++) {
                        printf("%d ", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
                }
                if(k)puts("");
        }

        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:20: error: 'k' was not declared in this scope
   31 |                 if(k)puts("");
      |                    ^
Language: C++

#include<cstdio>

int d[3][1002][1002], N, M, K;

int main()
{
        char buf[1024];

        scanf("%d%d%d", &N, &M, &K);

        for (int i = 1; i <= N; i++) {
                scanf("%s", buf + 1);
                for (int j = 1; j <= M; j++)  {
                        for (int k = 0; k < 3; k++) {
                                d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
                        }
                        switch (buf[j]) {
                                case 'J': d[0][i][j]++;break;
                                case 'O': d[1][i][j]++;break;
                                case 'I': d[2][i][j]++;
                        }
                }
        }

        while (K--) {
                int x1, y1, x2, y2;
                scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
                for (int i = 0; i < 3; i++) {
                        putchar(i?' ':'');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
                }
                puts("");
        }

        return 0;
}

Compiler output:
a.cc:29:39: error: empty character constant
   29 |                         putchar(i?' ':'');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
      |                                       ^~
Language: C++

#include<cstdio>

int d[3][1002][1002], N, M, K;

int main()
{
        char buf[1024];

        scanf("%d%d%d", &N, &M, &K);

        for (int i = 1; i <= N; i++) {
                scanf("%s", buf + 1);
                for (int j = 1; j <= M; j++)  {
                        for (int k = 0; k < 3; k++) {
                                d[k][i][j] = d[k][i][j-1] + d[k][i-1][j] - d[k][i-1][j-1];
                        }
                        switch (buf[j]) {
                                case 'J': d[0][i][j]++;break;
                                case 'O': d[1][i][j]++;break;
                                case 'I': d[2][i][j]++;
                        }
                }
        }

        while (K--) {
                int x1, y1, x2, y2;
                scanf("%d%d%d%d", &y1, &x1, &y2, &x2);
                for (int i = 0; i < 3; i++) {
                        i?putchar(' ');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
                }
                puts("");
        }

        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:39: error: expected ':' before ';' token
   29 |                         i?putchar(' ');printf("%d", d[i][y2][x2] - d[i][y1-1][x2] - d[i][y2][x1-1] + d[i][y1-1][x1-1]);
      |                                       ^
      |                                       :
a.cc:29:39: error: expected primary-expression before ';' token
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, k;
	cin >> n>>K;
	vector<vector<int> > pr(10, vector<int>(n+1,0));
	vector<int> ko(10, 0);
	for (int i = 0; i < n; i++) {
		int c, g; cin >> c >> g;
		g--;
		pr[g][ko[g]] = c;
		ko[g]++;
	}
	for (int i = 0; i < 10; i++) {
		sort(pr[i].begin(), pr[i].end());
		reverse(pr[i].begin(), pr[i].end());
	}
	vector<vector<int> > sum(10,vector<int> (n+1,0));
	for (int i = 0; i < n; i++) {
		int su = 0;
		for (int j = 1; j <= ko[i]; j++) {
			su += pr[i][j-1];
			sum[i][j] = su + j * (j - 1);
		}
	}
	vector<vector<int> > dp(10, vector<int>(n + 1, 0));
	dp[0] = sum[0];
	for (int i = 1; i < 10; i++) {
		for (int j = 0; j <= k; j++) {
			for (int kk = j; kk <= k; kk++) {
				dp[i][kk] = max(dp[i][kk], dp[i - 1][j] + sum[i][kk - j]);
			}
		}
	}
	cout << dp[9][k] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:19: error: 'K' was not declared in this scope
    8 |         cin >> n>>K;
      |                   ^
Language: C++

#include <stdio.h>

int dp[2 << 10][2001];
int books[10][2001];
int book_nums[10];
int sell_prices[10][2001];

int greater_int(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main() {
    int a, b, c, d;
    int n, k;
    int book_bits;
    int max;

    scanf("%d %d", &n, &k);
    for (a=0; a<n; a++) {
        int c, g;
        int ind;

        scanf("%d %d", &c, &g);
        --g;
        ind = book_nums[g];
        books[g][ind] = c;
        ++book_nums[g];
    }
        
    for (a=0; a<10; a++) {
        qsort(books[a], book_nums[a], sizeof(int), greater_int);

        sell_prices[a][1] = books[a][0];
        for (b=2; b<=book_nums[a]; b++) {
            sell_prices[a][b] = sell_prices[a][b-1] + books[a][b-1] + (b-1)*2;
        }
    }

    book_bits = 1 << 10;
    for (a=0; a<k; a++) {
        for (b=0; b < book_bits; b++) {
            for (c=0; c<10; c++) {
                int num;

                if ((b >> c) & 1) continue;

                num = book_nums[c];
                if (num > k-a) {
                    num = k-a;
                }

                for (d=1; d<=num; d++) {
                    int val = dp[b][a] + sell_prices[c][d];
                    int *p = &dp[b | 1 << c][a+d];

                    if (*p < val) *p = val;
                }
            }
        }
    }

    max = 0;
    for (a=0; a < book_bits; a++) {
        if (max < dp[a][k]) {
            max = dp[a][k];
        }
    }

    printf("%d\n", max);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'qsort' was not declared in this scope
   31 |         qsort(books[a], book_nums[a], sizeof(int), greater_int);
      |         ^~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct books
{
	int n;
	int j;
};
int n;
int k;
vector<books> bok;
int memo[2100][2100][2];
int jj[2100][2100][2][11] = {};
int check(int now,int w,int use)
{
	if (now == n)return 0;
	if (w > k)return 0;
	//if (memo[now][w][use] != -1)return memo[now][w][use];
	int ans = 0;
	if (use)
	{
		ans += bok[now].n;
		jj[now][w][use][bok[now].j]++;
		ans += 2 * (jj[now][w][use][bok[now].j] - 1);
	}
	for (int i = 1; i < 11; i++)
	{
		jj[now + 1][w + 1][1][i] = jj[now][w][use][i];
		jj[now + 1][w][0][i] = jj[now][w][use][i];
	}
	ans += max(check(now + 1, w + 1, 1), check(now + 1, w, 0));


	return memo[now][w][use]=ans;
}


int main()
{
	memset(memo, -1, sizeof(memo));
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		books a;
		cin >> a.n >> a.j;
		bok.push_back(a);
	}
	cout << max(check(0, 0, 0), check(0, 1, 1)) << endl;


}

Compiler output:
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: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;
Language: C++

#include <stack>
using namespace std;
int n, k, a[11], fir[11], i, j, save[11], sum, sum2, roop[11], mini;
stack <int>st[11];
int books[2001][3], books2[2001], books3[2001], books4[11];
int main(){
	cin >> n >> k;
	sum = 0;
	for (i = 1; i <= 10; i++)
		st[i].push(0);
	for (i = 1; i <= n; i++){
		cin >> books[i][0] >> books[i][1];
		if (fir[books[i][1]] == 0)
			fir[books[i][1]] = i;
		books[a[books[i][1]]][2] = i;
		a[books[i][1]] = i;
	}
	for (i = 1; i <= 10; i++){
		if (a[i])
			books[a[i]][2] = -1;
		books4[i] = 1;
	}
	for (i = 1; i <= 10; i++){
		roop[i] = 0;
		j = fir[i];
		if (j == 0)
			break;
		while (j != -1){
			books3[roop[i]] = books[j][0];
			roop[i]++;
			j = books[j][2];
		}
		sort(books3, books3 + roop[i], greater<int>());
		for (int l = 0; l < roop[i]; l++){
			st[i].push(books3[l] + l * 2);
			roop[0]++;
			sum += books3[l] + l * 2;
		}
	}
	for (int i = 0; i < roop[0] - k;){
		mini = 1000000;
		for (int j = 1; j <= 10; j++){
			if (mini>st[j].top()&&st[j].top()!=0){
				mini = st[j].top();
			}
		}
		for (int j = 1; j <= 10; j++){
			if (mini == st[j].top()){
				st[j].pop();
				sum -= mini;
				i++;
				if (i == n - k){
					cout << sum << endl;
					break;
				}
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> n >> k;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <stack>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:33:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   33 |                 sort(books3, books3 + roop[i], greater<int>());
      |                 ^~~~
      |                 short
a.cc:53:41: error: 'cout' was not declared in this scope
   53 |                                         cout << sum << endl;
      |                                         ^~~~
a.cc:53:41: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:53:56: error: 'endl' was not declared in this scope
   53 |                                         cout << sum << endl;
      |                                                        ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <stack>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include<bits/stdc++.h>
#define int long long
#define FOR(i,a,b) for(int i=a;i<=b;++i)
static const int INF = 1<<50;
static const int mod = 10007;

using namespace std;

int N,K,C[100010],G[11];
int mem[2020][11][11];

int cal(int n,int pp,int conect){
    int res=0;
    if(mem[n][pp][num]!=0)return mem[n][pp][num];
    if(n==K)return 0;
    FOR(i,1,N){
    int t=conect;
        if(pp==G[i]){
            t++;
            res=max(cal(n+1,G[i],t,i)+C[i],res);
        }
        else{
            t=0;
            res=max(cal(n+1,G[i],0,i)+C[i]+t,res);
        }
    }
    return mem[n][pp][num]=res;
}

signed main(){
    cin>>N>>K;
    FOR(i,1,N){
        cin>>C[i]>>G[i];
    }
    /*FOR(i,1,N-1){
        FOR(j,i+1,N){
            if(G[i]<G[j]){
                int temp=G[i];
                G[i]=G[j];
            }
        }
    }*/
    cout<<cal(0,0,0,0)<<endl;
}

Compiler output:
a.cc:4:25: warning: left shift count >= width of type [-Wshift-count-overflow]
    4 | static const int INF = 1<<50;
      |                        ~^~~~
a.cc: In function 'long long int cal(long long int, long long int, long long int)':
a.cc:14:19: error: 'num' was not declared in this scope; did you mean 'enum'?
   14 |     if(mem[n][pp][num]!=0)return mem[n][pp][num];
      |                   ^~~
      |                   enum
a.cc:20:24: error: too many arguments to function 'long long int cal(long long int, long long int, long long int)'
   20 |             res=max(cal(n+1,G[i],t,i)+C[i],res);
      |                     ~~~^~~~~~~~~~~~~~
a.cc:12:5: note: declared here
   12 | int cal(int n,int pp,int conect){
      |     ^~~
a.cc:24:24: error: too many arguments to function 'long long int cal(long long int, long long int, long long int)'
   24 |             res=max(cal(n+1,G[i],0,i)+C[i]+t,res);
      |                     ~~~^~~~~~~~~~~~~~
a.cc:12:5: note: declared here
   12 | int cal(int n,int pp,int conect){
      |     ^~~
a.cc:27:23: error: 'num' was not declared in this scope; did you mean 'enum'?
   27 |     return mem[n][pp][num]=res;
      |                       ^~~
      |                       enum
a.cc: In function 'int main()':
a.cc:43:14: error: too many arguments to function 'long long int cal(long long int, long long int, long long int)'
   43 |     cout<<cal(0,0,0,0)<<endl;
      |           ~~~^~~~~~~~~
a.cc:12:5: note: declared here
   12 | int cal(int n,int pp,int conect){
      |     ^~~
Language: C++

#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 
using namespace std;

int dp[2020][11];

void solve(){
 int n,k,c,g;
 cin>>n>>k;
 vector<int> book[10],pr[10];
 ZERO(dp);
 FOR(i,n){
  cin>>c>>g;
  g--;
  book[g].pb(c);
 }
 FOR(i,10) sort(ALL(book[i]),greater<int>());
 FOR(i,10){
  int tot=0;
  pr[i].pb(tot);
  FOR(j,v[i].size()){
   tot+=v[i][j];
   pr[i].pb(tot+j*(j+1));
  }
 }
 for(int i=n;i>=0;i--){
  FOR(j,10){
   FOR(k,pr[j].size()){
    if(i+k<=n) dp[i][j]=max(dp[i][j],dp[i+k][j+1]+pr[j][k]);
    else break;
   }
  }
 }
 cout<<dp[0][0]<<endl;
}

int main(){
 solve();
 return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:31:9: error: 'v' was not declared in this scope
   31 |   FOR(j,v[i].size()){
      |         ^
a.cc:2:38: note: in definition of macro 'FOR'
    2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++)
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int n,k;
vector<int> b[10];
int d[2001];

int main(){
    cin >> n >> k;
    memset(dp,-1,sizeof(dp));
    memset(d,0,sizeof(d));
    REP(i,10){
	b[i].PB(0);
    }
    REP(i,n){
	int c,g;
	cin >> c >> g;
	b[g-1].PB(c);
    }
    REP(i,10){
	sort(b[i].begin()+1,b[i].end(),greater<int>());
	if(b[i].size() <= 0) continue;
	REP(j,b[i].size()-1){
	    b[i][j+1] += b[i][j];
	}
	REP(j,b[i].size()){
	    b[i][j] += (j-1)*j;
	}
    }

    d[0] = 0;
    REP(i,10){
	RREP(j,n+1){
	    if(d[j] < 0) continue;
	    int s = min(n-j,(int)b[i].size() - 1);
            for(int l=s;l >= 0;l--){
		d[j+l] = max(d[j+l],d[j]+b[i][l]);
	    }
	}
    }
    int ans = 0;
    cout << d[k] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:12: error: 'dp' was not declared in this scope; did you mean 'dy'?
   24 |     memset(dp,-1,sizeof(dp));
      |            ^~
      |            dy
Language: C++

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

int n, k;
std::vector<int> cat[10];

int dp[11][2010];

int main() {
    for(int i = 0; i < 10; ++i) {
        cat[i].push_back(0);
    }
    std::cin >> n >> k;

    for(int i = 0; i < n; ++i) {
        int a, b;
        std::cin >> a >> b;
        --b;
        cat[b].push_back(a);
    }
    for(int i = 0; i < 10; ++i) {
        std::sort(cat[i].begin() + 1, cat[i].end(), std::greater<int>());
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 0; i < 10; ++i) {
        for(int j = 1; j < cat[i].size(); ++j) {
            cat[i][j] += cat[i][j - 1] + (j - 1) * j - (j - 2) * (j - 1);
        }
        for(int m = 0; m <= k; ++m) {
            if(dp[i][m] != -1) {
                for(int j = 0; j < cat[i].size(); ++j) {
                    dp[i + 1][m + j] = std::max(dp[i + 1][m + j], dp[i][m] + cat[i][j]);
                }
            }
        }
    }

    std::cout << dp[10][k] << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'memset' was not declared in this scope
   26 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
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 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[11][2001],n,K,a1,a2;
vector<int>v[11];
main(){
  cin>>n>>K;
  r(i,n){
    cin>>a1>>a2;
    v[a2-1].push_back(a1);
  }
  r(i,10){
    sort(v[i].begin(),v[i].end(),greater<int>());
    r(j,v[i].size())if(j)v[i][j]+=v[i][j-1]+j;
  }
  r(i,10){r(j,K+1)
    for(int k=0;k<v[i].size();k++){
      dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
    }
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
  }
  cout<<dp[10][K]<<endl;
}

Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'i' was not declared in this scope
    7 |   r(i,n){
      |     ^
a.cc:7:3: error: 'r' was not declared in this scope
    7 |   r(i,n){
      |   ^
Language: C++

#include<bits/stdc++.h>
#define r(I,n) for(int I=0;i<n;i++)
#define int long long
using namespace std;
int dp[11][2001],n,K,a1,a2;
vector<int>v[11];
main(){
  cin>>n>>K;
  r(i,n){
    cin>>a1>>a2;
    v[a2-1].push_back(a1);
  }
  r(i,10){
    sort(v[i].begin(),v[i].end(),greater<int>());
    r(j,v[i].size())if(j)v[i][j]+=v[i][j-1]+j;
  }
  r(i,10){r(j,K+1)
    for(int k=0;k<v[i].size();k++){
      dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
    }
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
  }
  cout<<dp[10][K]<<endl;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:21:13: error: 'j' was not declared in this scope
   21 |     dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      |             ^
Language: C++

#include<bits/stdc++.h>
#define r(I,n) for(int I=0;i<n;i++)
#define int long long
using namespace std;
int dp[11][2001],n,K,a1,a2;
vector<int>v[11];
main(){
  cin>>n>>K;
  r(i,n){
    cin>>a1>>a2;
    v[a2-1].push_back(a1);
  }
  r(i,10){
    sort(v[i].begin(),v[i].end(),greater<int>());
    r(j,v[i].size())if(j)v[i][j]+=v[i][j-1]+j;
  }
  r(i,10){r(j,K+1){
    for(int k=0;k<v[i].size();k++){
      dp[i+1][k+j+1]=max(dp[i+1][k+j+1],dp[i][j]+v[i][k]);
    }
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
  }
  cout<<dp[10][K]<<endl;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:24:2: error: expected '}' at end of input
   24 | }
      |  ^
a.cc:7:7: note: to match this '{'
    7 | main(){
      |       ^