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 <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;

class Team{
public:
    int id, solved, penalty;
    vector<int> wrongs;
    
    Team(int _id, int p): id(_id){
        solved = 0;
        penalty = 0;
        wrongs = vector<int>(p);
    }
    
    bool operator < (const Team &r) const{
        return solved==r.solved ? (penalty==r.penalty ? id<r.id : penalty<r.penalty) :solved>r.solved;
    }
};

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int T, P, R;
    while(cin>>T>>P>>R, T|P|R){
        vector<Team> teams;
        for(int i=0; i<T; i++)
            teams.push_back(Team(i, P));
        
        while(R--){
            int tid, pid, time;
            string message;
            cin >> tid >> pid >> time >> message;
            tid--; pid--;
            auto &team = teams[tid];
            
            if(message == "WRONG"){
                team.wrongs[pid]++;
            }else if(message == "CORRECT"){
                team.solved++;
                team.penalty += team.wrongs[pid] * 1200 + time;
            }
        }
        
        sort(teams.begin(), teams.end());
        for(Team team: teams)
            cout << team.id+1 << " " << team.solved << " " << team.penalty << endl;
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem2400 : You Are the Judge **/
struct Team {
	int id, ac, penalty;
	Team(int i, int c, int p):id(i), ac(c), penalty(p){}
	Team(){id=0; ac=0; penalty=0;}
};

bool comp(const Team &a, const Team &b) {
	if (a.ac == b.ac) {
		if (a.penalty == b.penalty) return a.id<b.id;
		return a.penalty<b.penalty;
	}
	return a.ac>b.ac;
}

int main()
{
	int T, P, R;
	while (cin>>T>>P>>R, T) {
		vector<Team> result(T);
		vector<vector<int> > wrong(T, vector<int>(P));
		
		for (int i=0; i<T; i++) {
			result[i].id = i+1;
		}
		
		for (int r=0; r<R; r++) {
			int tid, pid, time; string m;
			cin>>tid>>pid>>time>>m; tid--, pid--;
			
			if (m == "CORRECT") {
				result[tid].ac++;
				result[tid].penalty += 1200*wrong[tid][pid] + time;
			} else {
				wrong[tid][pid]++;
			}
		}
		
		sort(result.begin(), result.end(), comp);
		
		for (int i=0; i<T; i++) {
			cout << result[i].id << " " << result[i].ac << " " << result[i].penalty << endl;
		}
	}
}

C++: #include <bits/stdc++.h>
#define REP(i,n) for(i=0; i<n; i++)
#define IREP(i,n) for(i=n-1; i>=0; i--)
#define X first
#define Y second;
using namespace std;

int main() {
	int T,P,R,i,j,t,p,ti;
	string m;
	while(cin >> T >> P >> R, T!=0 || P!=0 || R!=0);
	int a[T][P];
	int c[T];
	int x[T];
	REP(i,T) {
		REP(j,P) a[i][j]=0;
		c[i]=0;
	}
	REP(i,R) {
		cin >> t >> p >> ti >> m;
		if(m.compare("WRONG")==0) a[t][p]++;
		else if(m.compare("CORRECT")==0) {
			c[i]++;
			x[i]+=1200*a[t][p]+ti;
		}
	}
	int b[T];
	REP(i,T) {
		int junni=1;
		REP(j,T) {
			if(i==j) continue;
			if(c[i]<c[j]) junni++;
			else if(x[i]>x[j]) junni++;
			else if(i>j) junni++;
			b[j]=i;
		}
	}
	REP(i,T) {
		cout << b[i] << c[b[i]] << x[b[i]] << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> tp;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
void solve(int T,int P,int R){
    vector<tp> V(T);// cnt time tID
    int error[T][P];
    rep(i,0,T)rep(j,0,P)error[i][j] = 0;
    rep(i,0,T)get<2>(V[i]) = i+1;

    rep(i,0,R){
        int t,p,time;
        string res;
        cin >> t >> p >> time >> res;
        t--,p--;
        if(res == "CORRECT"){
            get<0>(V[t])++;
            get<1>(V[t]) += time + error[t][p] * 1200;
        }else{
            error[t][p]++;
        }
    }
    sort(V.begin(), V.end(), [](tp a, tp b){
        if(get<0>(a) != get<0>(b))return get<0>(a) > get<0>(b);
        if(get<1>(a) != get<1>(b))return get<1>(a) < get<1>(b);
        return get<2>(a) < get<2>(b);
    });
    rep(i,0,T){
        cout << get<2>(V[i]) << " " << get<0>(V[i]) << " " << get<1>(V[i]) << endl;
    }
}
main(){
    int T,P,R;
    cin >> T >> P >> R;
    while(T){
        solve(T, P, R);
        cin >> T >> P >> R;
    }
}

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

struct team{
  int ans,id,pena,p[10];
  bool operator<(const team &a)const{
    if(this->ans == a.ans){
      return this->pena < a.pena;
    }else{
      return this->ans > a.ans;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(t==0)return 0;
    int tid,tm,pid;
    string mes;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
      }else{
	T[tid].p[pid]++;
      }
    }
    sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}