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

class State
{
public:
	int No,ok,pena;
	State(int No = 0,int ok = 0, int pena = 0):
	No(No),ok(ok),pena(pena){}

	bool operator < (const State &ano) const{
		if(ok > ano.ok)return true;
		else if(ok == ano.ok && pena < ano.pena)return true;
		else if(ok == ano.ok && pena == ano.pena && No < ano.No)
			return true;
			return false;
	}
};

int main()
{
	int T,P,R;

	while(cin >> T >> P >> R, T){
		int **d = new int *[T];
		State *a = new State[T];
		for(int i = 0; i < T; i++){
			d[i] = new int [P];
			a[i].No = i+1,a[i].ok = 0,a[i].pena = 0;

			for(int j = 0; j < P; j++)
				d[i][j] = 0;
		}

		int team,prog,time;
		string str;
		while(R > 0){
			R--;
			cin >> team >> prog >> time >> str;

			if(str == "WRONG")
				d[team-1][prog-1]++;
			else {
				a[team-1].pena += d[team-1][prog-1]*1200+time;	//ペナルティ
				a[team-1].ok++;	//正解数
			}
		}

		sort(a,a+T);

		for(int i = 0; i < T; i++)
			printf("%d %d %d\n",a[i].No,a[i].ok, a[i].pena);

			



	}

	return 0;
}

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

// bad knowhow
#define REP(i,n) for(long long i=0;i<(long long)n;++i)

struct Score {
	Score() : ac(0), pn(0) {}
	bool operator<(const Score & other) const {
		if (ac == other.ac){
			if (pn == other.pn) return id < other.id;
			return pn < other.pn;
		}
		return ac > other.ac;
	}
	int ac;
	long long pn;
	int id;
};

int g_wrong[50][10];
bool g_accept[50][10];
Score g_score[50];


int main() {
	while (true) {
		fill(g_score, g_score + 50, Score());
		fill(*g_accept, *g_accept + 500, false);
		fill(*g_wrong, *g_wrong + 500, 0);

		int t, p, r;
		cin >> t >> p >> r;
		if (t == 0) break;

		REP(i, t) g_score[i].id = i;

		REP(i, r) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if (g_accept[tid][pid]) continue;
			if (message == "CORRECT") {
				g_score[tid].ac++;
				g_accept[tid][pid] = true;
				g_score[tid].pn += g_wrong[tid][pid] * 1200 + time;
			} else {
				g_wrong[tid][pid]++;
			}
		}

		sort(g_score, g_score+t);
		REP(i, t) {
			cout << g_score[i].id + 1 << " " << g_score[i].ac << " " << g_score[i].pn << endl;
		}
	}
}

C++: #include <string>
#include <vector>
#include <numeric>
#include <iostream>

using namespace std;

int main()
{
	int T, P, R, A, B, C; string M;

	while (true)
	{
		cin >> T >> P >> R;

		if (T == 0 && P == 0 && R == 0) { break; }

		vector<int> S(T, 0);

		vector<vector<int> > W(T, vector<int>(P, 0));

		for (int i = 0; i < R; i++)
		{
			cin >> A >> B >> C >> M;

			if (M == "WRONG")
			{
				W[A - 1][B - 1] += 1;
			}
			else
			{
				S[A - 1] += (1000000 - W[A - 1][B - 1] * 1200 - C);
			}
		}

		vector<int> Q(T); iota(Q.begin(), Q.end(), 1);

		for (int i = 0; i < T; i++)
		{
			for (int j = i + 1; j < T; j++)
			{
				if (S[i] < S[j])
				{
					swap(S[i], S[j]); swap(Q[i], Q[j]);
				}
			}
		}

		for (int i = 0; i < T; i++)
		{
			cout << Q[i] << ' ' << (S[i] + 999999) / 1000000 << ' ' << (1000000 - S[i] % 1000000) % 1000000 << endl;
		}
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
//#define int long long
#define INF 10000000
using namespace std;
int main(){
    int T,P,R;
    while(1){
        cin >> T >> P >> R;
        if(T == 0 && P == 0 && R == 0) break;
        int time_table[T][P] = {};
        int flag_table[T][P] = {};
        rep(i,R){
            int team,program,t;
            string flag;
            cin >> team >> program >> t >> flag;
            team--; program--;
            if(flag == "CORRECT"){
                time_table[team][program] = flag_table[team][program]*1200+t;
            }
            else if(flag == "WRONG"){
                flag_table[team][program]++;
            }
        }
        int top = -1;
        vector<pair<pair<int,int> , int> > ans(T);
        rep(i,T){
            int correct = 0;
            int fail = 0;
            rep(j,P){
                if(time_table[i][j] != 0) correct++;
                fail += time_table[i][j];
            }
            ans[i].first.first = -correct;
            ans[i].first.second = fail;
            ans[i].second = i+1;
        }
        sort(ans.begin(),ans.end());
        rep(i,ans.size()){
            cout << ans[i].second << " " << -ans[i].first.first << " " << ans[i].first.second << endl;
        }
        /*rep(i,T){
            rep(j,P){
                cout << time_table[i][j] << " ";
            }
            cout << endl;
        }
        rep(i,T){
            rep(j,P){
                cout << flag_table[i][j] << " ";
            }
            cout << endl;
        }*/
    }
    return 0;
}