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 <stdio.h>
#include <string.h>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define fst first
#define snd second

bool c[64][16];
int w[64][16], num[64], pen[64];

int main() {
    for (;;) {
        int T, P, R;
        scanf("%d%d%d", &T, &P, &R);
        if (T == 0) return 0;
        memset(c, 0, sizeof(c));
        memset(w, 0, sizeof(w));
        memset(num, 0, sizeof(num));
        memset(pen, 0, sizeof(pen));
        rep (_, R) {
            int t, p, ti;
            char msg[16];
            scanf("%d%d%d%s", &t, &p, &ti, msg);
            t--, p--;
            if (msg[0] == 'C') c[t][p] = true, pen[t] += ti;
            else w[t][p]++;
        }
        rep (i, T) rep (j, R) if (c[i][j]) {
            num[i] += 1;
            pen[i] += 1200*w[i][j];
        }
        vector<pair<pair<int, int>, int> > vs;
        rep (i, T) vs.push_back(mp(mp(-num[i], pen[i]), i));
        sort(vs.begin(), vs.end());
        rep (i, T) {
            printf("%d %d %d\n", vs[i].snd+1, -vs[i].fst.fst, vs[i].fst.snd);
        }
    }
}

C++: #include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int
#define rep(i,n) for(i=0;i<(n);i++); 

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

class Team{
	public:
		int id = 0;
		int solve = 0;
		int time = 0;
		vector<int> check;
		
		void setP(int num,int id){
			for (int i = 0; i < num; i++){
				check.push_back(0);
			}
			this->id = id + 1;
		}
};

bool compare(Team maxT,Team T){
	if (maxT.solve < T.solve){
		return true;
	}else if(maxT.solve > T.solve){
		return false;
	}else{
		if (maxT.time > T.time){
			return true;
		}else if (maxT.time < T.time){
			return false;
		}else{
			if (maxT.id > T.id){
				return true;
			}else{
				return false;
			}
		}
	}
}

void sort_Team(vector<Team> &T){
	int i,j;
	Team maxT;
	//rep(i,T.size()){
	int maxj;
	for (int i = 0; i < T.size(); i++){
		//rep(j,T.size()){
		maxj = i;
		maxT.id = 51;
		maxT.solve = 0;
		maxT.time = INF;
		for (int j = i; j < T.size(); j++){
			if(compare(maxT,T[j])){
				maxT = T[j];
				maxj = j;
			}
		}
		Team tmp = T[i];
		T[i] = T[maxj];
		T[maxj] = tmp;
	}
}

void print_result(vector<Team> T){
	int i;
	//rep(i,T.size()){
	for (int i = 0; i < T.size(); i++){
		cout << T[i].id << " " << T[i].solve << " " << T[i].time << endl;
	}
}

int main() {
	while(1){
		int t,p,r; cin >> t >> p >> r;
		if (t + p + r == 0) break;
		vector<Team> T(t);

		for (int i = 0; i < t; i++){
			T[i].setP(r,i);
		}
		for (int i = 0; i < r; i++){
			int tID,pID,time;
			string msg;
			cin >> tID >> pID >> time >> msg;

			if (msg == "CORRECT"){
				if (T[tID-1].check[pID-1] != 1){
					T[tID-1].time += T[tID-1].check[pID-1] * (-1200) + time;
					T[tID-1].solve++;
					T[tID-1].check[pID-1] = 1;
				}
			}else if(msg == "WRONG"){
				if (T[tID-1].check[pID-1] != 1){
					T[tID-1].check[pID-1]--;
				}
			}
		}
		sort_Team(T);
		print_result(T);
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;



int main(){
  
    while(true){
        
        int penarty[51][11]={};
        int time_solve[51][11]={};
    
    int T,P,R;
    cin>>T>>P>>R;
        
        if(T==0&&P==0&&R==0)break;
    
    REP(i,R){
        int tID,pID,time;
        string Judge;
        cin>>tID>>pID>>time>>Judge;
        if(Judge=="WRONG"){
            if(time_solve[tID][pID]==0)penarty[tID][pID]++;
        }else{
            if(time_solve[tID][pID]==0)time_solve[tID][pID]=time;
        }
    }
    
    int cor[51]={};
    for(int i=1;i<=50;i++){
        for(int j=1;j<=10;j++){
            if(time_solve[i][j]!=0)cor[i]++;
        }
    }
    
    int pena[51]={};
    for(int i=1;i<=50;i++){
        for(int j=1;j<=10;j++){
            if(time_solve[i][j]!=0)pena[i]+=1200*penarty[i][j];
            pena[i]+=time_solve[i][j];
        }
    }
    
    vector<vector<int>> ans;
        for(int i=0;i<T;i++){
        ans.push_back({cor[i+1],1000000000-pena[i+1],50-(i+1)});
    }
    
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    
    REP(i,T){
        int ju=50-ans[i][2];
        cout<<ju<<" "<<ans[i][0]<<" "<<pena[ju]<<endl;
    }
    }
    
    return 0;
}