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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
#include <set>
#include <iomanip>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

#define MAX 1500

int main()
{
    int t,p,r;
    while(cin >>t >> p >> r,t,p,r){
        vector<int>tID;
        vector<int>pID;
        vector<int>time;
        vector<string>com;
        
        for(int i=0;i<r;i++){
            int a,b,c;
            string d;
            cin >> a >> b >> c >> d;
            tID.pb(a);
            pID.pb(b);
            time.pb(c);
            com.pb(d);
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(pID[i] > pID[j]){
                    swap(pID[i],pID[j]);
                    swap(tID[i],tID[j]);
                    swap(time[i],time[j]);
                    swap(com[i],com[j]);
                }
                
            }
        }
        /*
        for(int i=0;i<r;i++){
            cout << "tID:" <<tID[i] << " pID:" << pID[i] << " time:" << time[i] << " judge:" << com[i] <<  endl;
        }
         
         */
        vector<vector<int> > ans;
        vi temp;
        for(int i=0;i<t;i++){
            temp.pb(i+1);
            for(int j=1;j<5;j++){
                temp.pb(0);
            }
            ans.pb(temp);
            temp.clear();
        }
        
        for(int i=0;i<r;i++){
            if(com[i] == "CORRECT"){
                ans[tID[i]-1][1]++;
                ans[tID[i]-1][2] += (ans[tID[i]-1][3] * 1200 + time[i]);
//                cout << "tID:" << ans[tID[i]-1][0] << "??£?????°:" << ans[tID[i]-1][1] << "??????" << ans[tID[i]-1][2] << endl;
                if(ans[tID[i]-1][3]>0){
                    ans[tID[i]-1][3] = 0;
                    ans[tID[i]-1][4]--;
                }
            }else{
                ans[tID[i]-1][3]++;
                ans[tID[i]-1][4]++;
            }
            
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(ans[i][1] < ans[j][1]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][4] > ans[j][4]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][4] == ans[j][4] && ans[i][0] > ans[j][0] ){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
                if(ans[i][1] == ans[j][1] && ans[i][2] == ans[j][2] && ans[i][0] > ans[j][0] && ans[i][2] == 0 && ans[i][1] == 0){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                    swap(ans[i][4],ans[j][4]);
                }
            }
        }

        
        for(int i=0;i < t;i++){
               cout << ans[i][0] << " " << ans[i][1] <<" " << ans[i][2] << endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>

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

int main()
{
    while (true) {
        int t, p, r;
        cin >> t >> p >> r;
        if (t == 0 and p == 0 and r == 0) {
            break;
        }
        vector<vector<int>> wa(t, vector<int>(p, 0));
        vector<pair<pii, int>> score(t, make_pair(make_pair(p, 0), 0));
        for (int i = 0; i < t; i++) {
            score[i].second = i;
        }

        for (int i = 0; i < r; i++) {
            int tid, pid, tim;
            string str;
            cin >> tid >> pid >> tim >> str;
            tid--, pid--;
            if (str == "CORRECT") {
                score[tid].first.second += tim + 1200 * wa[tid][pid];
                score[tid].first.first--;
            } else {
                wa[tid][pid]++;
            }
        }

        sort(score.begin(), score.end());
        for (const auto& s : score) {
            cout << s.second + 1 << " " << p - s.first.first << " " << s.first.second << endl;
        }
    }


    return 0;
}