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){
                    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 <iostream>
using namespace std;

typedef struct {
    int tid;
    int pid;
    int time;
    string message;
} record;

typedef struct {
    int tid;
    int solved;
    int penalty;
    int penalArray[11];
} team;

int main(){
    team teams[51];
    record rec[501];
    int t, p, r;
    while (1){
	cin >> t >> p >> r;
	if (t == 0 && p == 0 && r == 0) break;

	for (int i = 0; i < r; i++){
	    cin >> rec[i].tid >> rec[i].pid >> rec[i].time >> rec[i].message;
	}
	
	for (int i = 0; i < t+1; i++){
	    teams[i].penalty = teams[i].solved = 0;
	    teams[i].tid = i;
	    for (int j = 1; j <= p; j++){
		teams[i].penalArray[j] = 0;
	    }
	}
	// for (int i = 0; i < t+1; i++)
	//     cout << teams[i].tid << " " << teams[i].solved << endl;
	
	for (int i = 0; i < r; i++){
	    if(rec[i].message == "CORRECT") {
		teams[rec[i].tid].solved++;
		teams[rec[i].tid].penalty += teams[rec[i].tid].penalArray[rec[i].pid] * 1200 + rec[i].time;
	    }
	    else if (rec[i].message == "WRONG") teams[rec[i].tid].penalArray[rec[i].pid]++;
	}

	// sort with solved
	team b;
	for (int j = 0; j < t*t*t; j++){
	    for (int i = 1; i < t; i++){
		if (teams[i].solved < teams[i+1].solved){
		    b = teams[i];
		    teams[i] = teams[i+1];
		    teams[i+1] = b;
		}
	    }
	}

	for (int j = 0; j < t*t*t; j++){
	    for (int i = 1; i < t; i++){
		if (teams[i].solved == teams[i+1].solved && teams[i].penalty > teams[i+1].penalty){
		    b = teams[i];
		    teams[i] = teams[i+1];
		    teams[i+1] = b;
		}
	    }
	}
	for (int j = 0; j < t*t*t; j++){
	    for (int i = 1; i < t; i++){
		if (teams[i].solved == teams[i+1].solved && teams[i].penalty > teams[i+1].penalty && teams[i].tid > teams[i+1].tid){
		    b = teams[i];
		    teams[i] = teams[i+1];
		    teams[i+1] = b;
		}
	    }
	}

	for (int i = 1; i <= t; i++){
	    cout << teams[i].tid << " " << teams[i].solved << " " << teams[i].penalty << endl;
	}
    }
}