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<string>
#include<algorithm>
using namespace std;


struct A{
	int n;
	int pena;
	int id;
	bool operator<(const A &a)const{
		if(n!=a.n)return n>a.n;
		if(pena!=a.pena)return pena<a.pena;
		return id<a.id;
	}
};
int main(){
	int T,P,R;
	int p[50][10];
	A team[50];
	while(cin>>T>>P>>R,T|P|R){
		memset(p,0,sizeof(p));
		for(int i=0;i<T;i++){
			team[i].n=team[i].pena=0;
			team[i].id=i+1;
		}
		while(R--){
			int a,b,c;
			string mes;
			cin>>a>>b>>c>>mes;
			if(mes=="WRONG")p[a-1][b-1]++;
			else{
				team[a-1].n++;
				team[a-1].pena += p[a-1][b-1]*1200+c;
			}
		}
		sort(team,team+T);
		for(int i=0;i<T;i++){
			cout<<team[i].id<<' '<<team[i].n<<' '<<team[i].pena<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1000000;
struct D{
	int tID;
	int p[10];	//the number of incorrect problems
	int c;		//the number of correct problems
	int x;		//penalty points
};

bool rank( const D &a, const D &b ){
	if( a.c == b.c ){
		return a.x == b.x ? a.tID < b.tID : a.x < b.x;
	}else{
		return a.c > b.c;
	}
}

int main(){
	int T, P, R;
	while( cin >> T >> P >> R && T ){
		vector< D > data(T);
		for( int i = 0; i < T; i++ ){
			data[i].tID = i + 1;
		}
		for( int i = 0; i < R; i++ ){
			int tID, pID, t;
			string m;
			cin >> tID >> pID >> t >> m;
			if( m == "CORRECT" ){
				if( data[tID-1].p[pID-1] != inf ){
					data[tID-1].c++;
					data[tID-1].x += t + data[tID-1].p[pID-1] * 1200;
					data[tID-1].p[pID-1] = inf;
				}
			}else{
				data[tID-1].p[pID-1]++;
			}
		}
		sort( data.begin(), data.end(), rank );
		for( int i = 0; i < T; i++ ){
			cout << data[i].tID << " " << data[i].c << " " << data[i].x << endl;
		}
	}
}

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

struct P{
    int team;
    int ans;
    int sum;
    int pro[100];
    static bool less(const P& left,const P& right){
        return left.team < right.team;
    }
    static bool point(const P& pleft,const P& pright){
        return pleft.sum < pright.sum;
    }
    static bool more(const P& mleft,const P& mright){
        return mleft.ans > mright.ans;
    }
};

int main(){
    int t,p,r,tid,pid,time;
    string sta;
    while(cin >> t >> p >> r){
        if(t == 0 && r == 0 && p == 0) break;
        vector <P> data;
        P tmp;
        for(int i=0;i<t;i++){
            tmp.team = i+1;
            tmp.ans = 0;
            tmp.sum = 0;
            for(int j=0;j<=p;j++) tmp.pro[j] = 0;
            data.push_back(tmp);
        }
        while(r--){
            cin >> tid >> pid >> time >> sta;
            if(sta == "CORRECT"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].sum += data[i].pro[pid]*1200+time;
                        data[i].ans += 1;
                        break;
                    }
                }
            }
            else if(sta == "WRONG"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid) data[i].pro[pid] += 1;
                }
            }
        }
        sort(data.begin(),data.end(),P::less);
        sort(data.begin(),data.end(),P::point);
        sort(data.begin(),data.end(),P::more);
        for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<n; i++)

template<typename T>
void fillall(T& arr, const T& value) {
    arr = value;
}
template<typename T,typename ARR>
void fillall(ARR& arr, const T& value) {
    for(auto& i:arr) fillall(i,value);
}


int T,P,R;
int error[50][10];
std::pair<int,std::pair<int,int>> solve[50];

int main(){
    while(true){
        fillall(error, 0);
        fillall(solve, std::pair<int,std::pair<int,int>>{0,{0,0}});
        cin>>T>>P>>R;
        if(T==0&&P==0&&R==0)break;
        REP(i,T){
            solve[i].second.second = i+1;
        }
        REP(i,R){
            int t,p,time;
            string type;
            cin >> t>>p>>time>>type;--t;--p;
            if(type[0] =='W'){
                error[t][p]+=1;
            }
            else{
                solve[t].second.first += 1200*error[t][p]+time;
                solve[t].first-=1;
            }
        }
        std::sort(solve, solve+T);

        REP(i,T){
            cout << solve[i].second.second << ' '
                << -solve[i].first  << ' '
                 << solve[i].second.first << endl;
        }
    }
    return 0;
}

C++: #include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
char M[9];
int main(){
	int T,P,R,t,p,s,m,i;
	for(;scanf("%d%d%d",&T,&P,&R),R;){
		map<int,map<int,int> >z;
		for(i=0;i<R;i++){
			scanf("%d%d%d%s",&t,&p,&s,M);
			if(*M=='W')z[t][p]-=1;else z[t][p]=s-z[t][p]*1200;
		}
		vector<pair<int,pair<int,int> > >v;
		for(i=1;i<=T;i++){
			for(p=s=0,R=1;R<=P;R++)if(z[i][R]>0)p++,s+=z[i][R];
			v.push_back(make_pair(-p,make_pair(s,i)));
		}
		sort(v.begin(),v.end());
		for(i=0;i<T;i++)printf("%d %d %d\n",v[i].second.second,-v[i].first,v[i].second.first);
	}
}