Language: C++

#include<iostream>
using namespace std;

int main(){
	while(true){
		int M,T,P,R;
		cin>>M>>T>>P>>R;
		if(M==0&&T==0&&P==0&&R==0)
			break;
		int CP[50],YY[50],PT[50][10];
		for(int i=0;i<T;i++){
			CP[i]=TT[i]=0;
			for(int j=0;j<P;j++)
				PT[i][j]=0;
		}
		for(int i=0;i<R;i++){
q			int m,t,p,j;
			cin>>m>>t>>p>>j;
			if(j==0){
				CP[t-1]++;
				TT[t-1] += (m+PT[t-1][p-1]);
			}else{
				PT[t-1][p-1] +=20;
			}
		}

		int tnow,tpre=-1;
		bool flg[50];
		for(int i=0;i<T;i++)
			flg=[i]=false;
		for(int i=0;i<T;i++){
			tnow=-1;
			for(int j=0;j<T;j++){
				if(flg[j])
					continue;
				if(tnow==-1){
					tnow=j;
				}else{
					if(CP[j]>CP[tnow]||(CP[j]==CP[tnow]&&TT[j]<=TT[tnow])){
						tnow=j;
					}
				}
			}
		if(tpre!=-1){
			if(CP[tnow]==CP[tpre]&&TT[tnow]==TT[tpre])
				cout<<'=';
			else
				cout<<',';
		}
		cout << tnow+1;
			flg[tnow]=true;
			tpre=tnow;
		}
	cout<<endl;
	}
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:31: error: 'TT' was not declared in this scope; did you mean 'PT'?
   12 |                         CP[i]=TT[i]=0;
      |                               ^~
      |                               PT
a.cc:17:1: error: 'q' was not declared in this scope
   17 | q                       int m,t,p,j;
      | ^
a.cc:18:30: error: 'm' was not declared in this scope
   18 |                         cin>>m>>t>>p>>j;
      |                              ^
a.cc:18:33: error: 't' was not declared in this scope
   18 |                         cin>>m>>t>>p>>j;
      |                                 ^
a.cc:18:36: error: 'p' was not declared in this scope
   18 |                         cin>>m>>t>>p>>j;
      |                                    ^
a.cc:18:39: error: 'j' was not declared in this scope
   18 |                         cin>>m>>t>>p>>j;
      |                                       ^
a.cc:21:33: error: 'TT' was not declared in this scope; did you mean 'PT'?
   21 |                                 TT[t-1] += (m+PT[t-1][p-1]);
      |                                 ^~
      |                                 PT
a.cc: In lambda function:
a.cc:30:32: error: expected '{' before '=' token
   30 |                         flg=[i]=false;
      |                                ^
a.cc: In function 'int main()':
a.cc:30:33: error: no match for 'operator=' (operand types are 'main()::<lambda()>' and 'bool')
   30 |                         flg=[i]=false;
      |                                 ^~~~~
a.cc:30:31: note: candidate: 'main()::<lambda()>& main()::<lambda()>::operator=(const main()::<lambda()>&)' (deleted)
   30 |                         flg=[i]=false;
      |                               ^
a.cc:30:31: note:   no known conversion for argument 1 from 'bool' to 'const main()::<lambda()>&'
a.cc:39:78: error: 'TT' was not declared in this scope; did you mean 'PT'?
   39 |                                         if(CP[j]>CP[tnow]||(CP[j]==CP[tnow]&&TT[j]<=TT[tnow])){
      |                                                                              ^~
      |                                                                              PT
a.cc:45:48: error: 'TT' was not declared in this scope; did you mean 'PT'?
   45 |                         if(CP[tnow]==CP[tpre]&&TT[tnow]==TT[tpre])
      |                                                ^~
      |                                                PT