Go: // You Are the Judge(審判は君だ！)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2400&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Team struct {
	TID         int
	Accepted    int
	WrongAnswer map[int]int
	Penalty     int
}

type Teams []Team

func (t Teams) Len() int      { return len(t) }
func (t Teams) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t Teams) Less(i, j int) bool {
	// より多くの問題を解いたチームは順位が上になる
	if t[i].Accepted > t[j].Accepted {
		return true
	} else if t[i].Accepted == t[j].Accepted {
		// 解いた問題が同じ場合、ペナルティの少ないチームのほうが順位が上になる
		if t[i].Penalty < t[j].Penalty {
			return true
		} else if t[i].Penalty == t[j].Penalty {
			// 解いた問題もペナルティも同じ場合、チーム番号が小さいほうのチームが順位が上になる
			if t[i].TID < t[j].TID {
				return true
			}
		}
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		t, p, r := nextInt(sc), nextInt(sc), nextInt(sc)
		if t == 0 && p == 0 && r == 0 {
			break
		}

		teams := []Team{}
		for tID := 0; tID < t; tID++ {
			teams = append(teams, Team{tID + 1, 0, map[int]int{}, 0})
		}

		for i := 0; i < r; i++ {
			tID, pID, time, message := nextInt(sc), nextInt(sc), nextInt(sc), nextString(sc)
			tID--

			if message == "CORRECT" {
				teams[tID].Accepted++
				wa, _ := teams[tID].WrongAnswer[pID]
				teams[tID].Penalty += wa*1200 + time
			} else {
				teams[tID].WrongAnswer[pID]++
			}
		}

		sort.Sort(Teams(teams))

		for _, team := range teams {
			fmt.Println(team.TID, team.Accepted, team.Penalty)
		}
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

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

typedef struct {
  int tnum;
  int num;
  int pen;
  int wro[15];
} rec;

int t, p, r;
string s;

bool asc(rec l, rec r) {
  if(l.num > r.num)
    return 1;
  else if(l.num == r.num) {
    if(l.pen < r.pen)
      return 1;
    else if(l.pen == r.pen && l.tnum < r.tnum)
      return 1;
  }
  else
    return 0;
}

int main() {
  int i, j, ti, pi, time;
  rec dummy;
  dummy.tnum = 0;
  dummy.num = 0;
  dummy.pen = 0;
  for(i = 0; i < 15; ++i) dummy.wro[i] = 0;
  while(1) {
    cin >> t >> p >> r;
    if(t + p + r == 0) break;
    vector<rec> memo;
    for(i = 0; i < t; ++i) {
      memo.push_back(dummy);
      memo[i].tnum = i + 1;
    }
    for(i = 0; i < r; ++i) {
      cin >> ti >> pi >> time >> s;
      if(s == "CORRECT" && memo[ti - 1].wro[pi] != -1) {
        ++memo[ti - 1].num;
        memo[ti - 1].pen += memo[ti - 1].wro[pi] * 1200 + time;
      }
      else
        ++memo[ti - 1].wro[pi];
    }
    sort(memo.begin(), memo.end(), asc);
    for(i = 0; i < t; ++i)
      cout << memo[i].tnum << " " << memo[i].num << " " << memo[i].pen << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<map>
#include<string>

using namespace std;

const int INF=200000000;

int data[51][11];
int pena[51];
int ac[51];
int main(){
	int t,p,r;
	while(cin>>t>>p>>r &&t){
		fill((int*)data,(int*)(data+11),0);
		fill(pena,pena+51,0);
		fill(ac,ac+51,0);

		for(int i=0;i<r;i++){
			int tID,pID,time;
			string str;
			cin>>tID>>pID>>time>>str;
			if(str=="CORRECT"){
				pena[tID]+=data[tID][pID]*1200+time;
				ac[tID]++;
			}
			else{
				data[tID][pID]++;
			}
		}
		for(int i=0;i<t;i++){
			int tmp[2]={-1,INF};
			int ans=-1;
			for(int j=1;j<=t;j++){
				if(ac[j]>tmp[0] || (ac[j]==tmp[0] && pena[j]<tmp[1])){
					tmp[0]=ac[j];
					tmp[1]=pena[j];
					ans=j;
				}
			}
			cout<<ans<<" "<<ac[ans]<<" "<<pena[ans]<<endl;
			ac[ans]=-1;pena[ans]=INF;
		}

	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if (t == 0) return 0;

    int solved[t + 1], wrong[t + 1][p + 1], penalty[t + 1];
    for (int i = 0; i < t + 1; i++) {
      solved[i] = 0;
      penalty[i] = 0;
      for (int j = 0; j < p + 1; j++)
	wrong[i][j] = 0;
    }

    for (int i = 0; i < r; i++) {
      int tid, pid, time;
      string message;
      cin >> tid >> pid >> time >> message;
      if (message == "CORRECT") {
	solved[tid]++;
	penalty[tid] += time + wrong[tid][pid] * 1200;
      } else {
	wrong[tid][pid]++;
      }
    }

    int rank[t + 1];
    for (int i = 1; i < t + 1; i++)
      rank[i] = i;
    
    for (int i = 1; i < t + 1; i++) {
      for (int j = i; j > 1; j--) {
	if (solved[j - 1] < solved[j]) {
	  swap(rank[j - 1], rank[j]);
	  swap(solved[j - 1], solved[j]);
	  swap(penalty[j - 1], penalty[j]);
	} else if (solved[j - 1] == solved[j] && penalty[j - 1] > penalty[j]) {
	  swap(rank[j - 1], rank[j]);
	  swap(solved[j - 1], solved[j]);
	  swap(penalty[j - 1], penalty[j]);
	}
      }
    }

    for (int i = 1; i < t + 1; i++) {
      cout << rank[i] << ' ' << solved[i] << ' ' << penalty[i] << endl;
    }
  }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int t[51][11][3] = {};//?§£????????? ??????????????£ ??????
	for (int T, P, R; cin >> T >> P >> R&&T;) {
		memset(t, 0, sizeof(t));
		int tID, pID, time; string message;
		for (int i = 0; i < R; i++) {
			cin >> tID >> pID >> time >> message;
			if (message[0] == 'C') {
				t[tID][pID][0] = 1;
				t[tID][pID][2] = time;
			}
			else {
				t[tID][pID][1]++;
			}
		}
		vector<pair<int, int> > a[11];
		for (int i = 1; i <= T; i++) {
			int cnt = 0,time=0;
			for (int j = 1; j <= P; j++) {
				if (t[i][j][0]) {
					time += t[i][j][2] + t[i][j][1] * 1200;
					cnt++;
				}
			}
			a[cnt].push_back( make_pair(time, i));
		}
		for (int i = 10; i >= 0; i--) {
			sort(a[i].begin(), a[i].end());
			for (size_t j = 0; j < a[i].size(); j++) {
				cout << a[i][j].second << " " << i << " " << a[i][j].first << endl;
			}
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	typedef tuple<int, int, int> Data;

	cin.sync_with_stdio(false);
	int T, P, R;
	while (cin >> T >> P >> R, T)
	{
		vector<vi> wa(T, vi(P));
		vi ac(T), penalty(T);
		REP(i, R)
		{
			int tid, pid, time; string mes;
			cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT")
			{
				ac[tid]++;
				penalty[tid] += wa[tid][pid] * 1200 + time;
			}
			else
			{
				wa[tid][pid]++;
			}
		}
		vector<Data> v;
		REP(i, T) v.emplace_back(-ac[i], penalty[i], i + 1);
		sort(ALL(v));
		REP(i, T) cout << get<2>(v[i]) << " " << -get<0>(v[i]) << " " << get<1>(v[i]) << endl;
	}
	return 0;
}