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 <vector>
using namespace std;

int main(int argc, char *argv[])
{
    int t, p, r, tid, pid, time, score, team;
    string msg;
    while (cin >> t >> p >> r, t) {
        vector<int> ans(t + 1, 0);
        vector<int> penalty(t + 1, 0);
        vector<vector<int> > wrong(t + 1, vector<int>(p + 1, 0));
        for (int i = 0; i < r; ++i) {
            cin >> tid >> pid >> time >> msg;
            if (msg[0] == 'W') {
                wrong[tid][pid]++;
            } else {
                ans[tid]++;
                penalty[tid] += 1200 * wrong[tid][pid] + time;
            }
        }
        for (int i = 0; i < t; ++i) {
            score = -1;
            for (int j = t; j > 0; --j) {
                if (score < ans[j]) {
                    score = ans[j];
                    team = j;
                } else if (score == ans[j]) {
                    team = (penalty[team] < penalty[j]) ? team : j;
                }
            }
            cout << team << ' ' << score << ' ' << penalty[team] << endl;
            ans[team] = -2;
        }
    }
    return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"	[";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct Team
{
	Team():
	ac(0), pena(0)
	{
		for (int i = 0; i < 10; ++i) {
			tried[i] = 0;
		}
	}

	int id;
	int ac = 0;
	int pena = 0;
	int tried[10] = {};
};
int main(int argc, char const *argv[]) {
	int T, P, R;

	while(cin >> T >> P >> R)
	{
		if(T == 0 && P == 0 && R == 0) break;

		vector<Team> teams(T);

		for(int i = 0; i < T; ++i)
		{
			teams[i].id = i + 1;
		}

		for (int i = 0; i < R; ++i) {
					int tID;
					int pID;
					int itime;
					string str;
					cin >> tID >> pID >> itime >> str;
					tID--;
					pID--;
					if(str == "CORRECT")
					{
						teams[tID].ac++;
						teams[tID].pena += teams[tID].tried[pID] * 1200 + itime; 
					}
					else
					{
						teams[tID].tried[pID]++;
					}
				}

		stable_sort(all(teams), [](Team a, Team b){return a.pena < b.pena;});
		stable_sort(all(teams), [](Team a, Team b){return a.ac > b.ac;});

		for(auto e : teams)
		{
			cout << e.id << ' ' << e.ac << ' ' << e.pena << endl;
		}
	}

	return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define _D(p) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p)<<std::endl;
#define _D2(p,q) std::cout<<"L"<<__LINE__<<" : " #p " = "<<(p) << ", " #q " = "<<(q)<<std::endl;
#define _DN(v) std::cout<<"L"<<__LINE__<<" : " #v " = ["; rep(i,(v).size()) {std::cout<<v[i]<<(i==v.size()-1?"":", ");}std::cout<<"]"<<std::endl;
#define _DNN(v) std::cout<<"L"<<__LINE__<<" : " #v " = [" << std::endl; rep(i,(v).size()) {std::cout<<"	[";rep(j,(v)[0].size()){std::cout<<v[i][j]<<(j==v[0].size()-1?"":", ");}std::cout<<"],"<<std::endl;}std::cout<<"]"<<std::endl;
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

struct Team
{
	Team():
	ac(0), pena(0)
	{
		for (int i = 0; i < 10; ++i) {
			tried[i] = 0;
		}
	}

	int id;
	int ac;
	int pena;
	int tried[10];
};
int main(int argc, char const *argv[]) {
	int T, P, R;

	while(cin >> T >> P >> R)
	{
		if(T == 0 && P == 0 && R == 0) break;

		vector<Team> teams(T);

		for(int i = 0; i < T; ++i)
		{
			teams[i].id = i + 1;
		}

		for (int i = 0; i < R; ++i) {
					int tID;
					int pID;
					int itime;
					string str;
					cin >> tID >> pID >> itime >> str;
					tID--;
					pID--;
					if(str == "CORRECT")
					{
						teams[tID].ac++;
						teams[tID].pena += teams[tID].tried[pID] * 1200 + itime; 
					}
					else
					{
						teams[tID].tried[pID]++;
					}
				}

		stable_sort(all(teams), [](Team a, Team b){return a.pena < b.pena;});
		stable_sort(all(teams), [](Team a, Team b){return a.ac > b.ac;});

		for(auto e : teams)
		{
			cout << e.id << ' ' << e.ac << ' ' << e.pena << endl;
		}
	}

	return 0;
}