Language: C++

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

using namespace std;

int time[51][11];
bool memo[51][11];

int main(void){
  int M, T, P, R;
  int m, t, p, j;
  vector<pair<int, pair<int, int> > > v;

  while(cin >> M >> T >> P >> R, M || T || P || R){
    v.clear();

    for(int i=1; i<=T; i++){
      for(int k=1; k<=P; k++){
        time[i][k] = 0;
        memo[i][k] = false;
      }
    }

    for(int i=0; i<R; i++){
      cin >> m >> t >> p >> j;
      if(j == 0){
        time[t][p] += m;
        memo[t][p] = true;
      } else {
        time[t][p] += 20;
      }
    }

    for(int i=1; i<=T; i++){
      int t = 0, c = 0;
      for(int k=1; k<=P; k++){
        if(memo[i][k] == true){
          ++c;
          t += time[i][k];
        }
      }

      v.push_back(make_pair(c, make_pair(-1 * t, i)));
    }
    sort(v.begin(), v.end(), greater<pair<int, pair<int, int> > >());
    
    cout << v[0].second.second;
    int tbuf = v[0].second.first, mbuf = v[0].first;
    for(int i=1; i<v.size(); i++){
      if(tbuf == v[i].second.first && mbuf == v[i].first){
        cout << "=" << v[i].second.second;
      } else {
        cout << "," << v[i].second.second;
        tbuf = v[i].second.first; mbuf = v[i].first;
      }
    }
    cout << endl;
  }

  return 0;
}

Compiler output:
a.cc:9:16: error: 'int time [51][11]' redeclared as different kind of entity
    9 | int time[51][11];
      |                ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:22:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |         time[i][k] = 0;
      |               ^
a.cc:22:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |         time[i][k] = 0;
      |                  ^
a.cc:22:20: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)k)))'
   22 |         time[i][k] = 0;
      |         ~~~~~~~~~~~^~~
a.cc:30:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |         time[t][p] += m;
      |               ^
a.cc:30:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |         time[t][p] += m;
      |                  ^
a.cc:30:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |         time[t][p] += m;
      |         ~~~~~~~~~~~^~~~
a.cc:30:20: error: assignment of read-only location '*(time + (((sizetype)t) + ((sizetype)p)))'
a.cc:33:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |         time[t][p] += 20;
      |               ^
a.cc:33:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |         time[t][p] += 20;
      |                  ^
a.cc:33:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |         time[t][p] += 20;
      |         ~~~~~~~~~~~^~~~~
a.cc:33:20: error: assignment of read-only location '*(time + (((sizetype)t) + ((sizetype)p)))'
a.cc:42:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |           t += time[i][k];
      |                      ^
a.cc:42:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |           t += time[i][k];
      |                         ^
a.cc:42:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   42 |           t += time[i][k];
      |           ~~^~~~~~~~~~~~~
a.cc:42:13: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   42 |           t += time[i][k];
      |           ~~^~~~~~~~~~~~~
      |             |
      |             time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}