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>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

struct Data{
	int id, ans, penalty;
	bool operator < ( const Data &right ) const {
		if(ans < right.ans) return 1;
		else if(ans == right.ans){
			if(penalty > right.penalty) return 1;
			else if(penalty == right.penalty) return id > right.id;
		}
		return 0;
	}
};

int main(){
	int t, p, r;
	while(cin >> t >> p >> r, t){

		Data d[50];
		rep(i,t){
			d[i] = Data{i + 1, 0, 0};
		}
		int wa[50][10] = {};

		rep(i,r){
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;

			if(message == "CORRECT"){
				d[tid].ans++;
				d[tid].penalty += wa[tid][pid] * 1200 + time;
			}else{
				wa[tid][pid]++;
			}
		}


		sort(d, d + t);
		for(int i = t - 1; i >= 0; i--){
			cout << d[i].id << ' ' << d[i].ans << ' ' << d[i].penalty << endl;
		}
	}
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define cn first
#define pn second.first
#define tn second.second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int t, p, r; cin >> t >> p >> r, t;){
        vector<vi> wc = vector<vi>(t, vi(p, 0));

        vector< pair<int, pii> > res(t);
        rep(i, t) res[i].tn = i;

        rep(i, r){
            int tid, pid, tm; string msg; cin >> tid >> pid >> tm >> msg;
            tid--, pid--;

            if(msg == "CORRECT"){
                res[tid].cn--;
                res[tid].pn += wc[tid][pid] * 1200 + tm;
            }
            else{
                wc[tid][pid]++;
            }
        }

        sort(all(res));
        rep(i, t){
            cout << res[i].tn + 1 << " "<< res[i].cn * -1 << " " << res[i].pn << endl;
        }
    }

	return 0;
}

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


typedef struct{
	int name;
	int wrong_time[11];
	int pena;
	int AC;
}DATA;

int main(){
	int T,P,R;
	while(cin>>T>>P>>R,T){
		DATA data[51];
		for(int i=1;i<=T;i++){
			data[i].name=i;
			for(int j=0;j<=10;j++)data[i].wrong_time[j]=0;
			data[i].pena=0;
			data[i].AC=0;
		}
		for(;R>0;R--){
			int t,p,time;
			string str;
			cin>>t>>p>>time>>str;
			if(str=="WRONG"){
				data[t].wrong_time[p]++;
			}
			else{
				data[t].AC++;
				data[t].pena+=(time+1200*data[t].wrong_time[p]);
			}
		}
		for(int i=0;i<=T;i++){
			for(int j=1;j<T;j++){
				if(data[j].AC<data[j+1].AC)swap(data[j],data[j+1]);
				if(data[j].AC==data[j+1].AC&&data[j].pena>data[j+1].pena)swap(data[j],data[j+1]);
				if(data[j].AC==data[j+1].AC&&data[j].pena==data[j+1].pena&&data[j].name>data[j+1].name)swap(data[j],data[j+1]);
			}
		}
		for(int i=1;i<=T;i++){
			cout<<data[i].name<<" "<<data[i].AC<<" "<<data[i].pena<<endl;
		}
	}
	
	return 0;
}