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 <bits/stdc++.h>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(),(c).end()
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

typedef vector<int> vi;
typedef vector<vi> vvi;

struct team {
    team(){}
    team(int id) : id(id), pena(0), solved(0){
        rep(i,20) submit[i].clear();
    }
    int id;
    int pena;
    vi submit[20];
    int solved;
};

int main(){
    int T,P,R;
    while(cin>>T>>P>>R, T|P|R){
        vector<team> ts(T);
        rep(i,T){
            ts[i] = i+1;
        }
        rep(i,R){
            int who, prob, when;
            string res;
            cin >> who >> prob >> when >> res;
            team & t = ts[who-1];
            t.submit[prob].push_back(when);
            if(res[0]=='C'){
                t.solved++;
                t.pena += (t.submit[prob].size()-1) * 1200 + when;
            }
        }

        sort(all(ts),[](team const& a, team const& b){
                if(a.solved != b.solved) return a.solved > b.solved;
                if(a.pena != b.pena) return a.pena < b.pena;
                return a.id < b.id;
            });

        iter(it, ts){
            printf("%d %d %d\n",
                   it->id,
                   it->solved,
                   it->pena);
        }
    }
}

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

int main(){
	int t,p,r;
	string mestype[2] = {"WRONG","CORRECT"};
	while(true){
		cin >> t >> p >> r;
		if( !t && !p && !r){
			break;
		}
		int teams_no[50];
		int teams[50]; // 点数
		int teams_c[50];
		int teams_p[50]; // ペナルティ
		int teams_w[10][50]; // ><;
		for(int i = 0; i < t; i++){
			teams[i] = 0;
			teams_c[i] = 0;
			teams_p[i] = 0;
			teams_no[i] = i + 1;
		}
		for(int i = 0; i < p; i++){
			for(int j = 0; j < t; j++){
				teams_w[i][j] = 0;
			}
		}
		
		
		int teams_in;
		for(int i = 0; i < r; i++){
			int pno, time;
			string mes;
			cin >> teams_in >> pno >> time;
			cin >> mes;
			if(mes == mestype[0]){
				teams_w[pno - 1][teams_in - 1]++;
			}
			else{
				teams_c[teams_in - 1]++;
				teams_p[teams_in - 1] += teams_w[pno - 1][teams_in - 1] * 1200 + time;
				teams[teams_in - 1] += 1000000 - teams_p[teams_in - 1];
			}
		}
		
		for(int i = 0 ; i < t - 1; i++){
			for(int j = i + 1 ; j < t; j++){
				if(teams[i] < teams[j]){
					swap(teams[i], teams[j]);	
					swap(teams_no[i], teams_no[j]);
					swap(teams_p[i], teams_p[j]);
					swap(teams_c[i], teams_c[j]);
				}
			}
		}
		for(int i = 0 ; i < t ; i++){
			for(int j = 0 ; j < t; j++){
				if(teams[i] == teams[j]){
				if(teams_p[i] == teams_p[j]){
					if(teams_no[i] < teams_no[j]){
						swap(teams[i], teams[j]);	
						swap(teams_no[i], teams_no[j]);
						swap(teams_p[i], teams_p[j]);	
						swap(teams_c[i], teams_c[j]);
					}	
				}
				}
			}
		}
		for(int i = 0; i < t; i++){
			printf("%d %d %d\n", teams_no[i], teams_c[i], teams_p[i]);
		}
	}
	return 0;
}

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

class Team {
public:
    int id, solved, penalty;
    int ac[10], wa[10];
    Team(int id) : id(id), solved(0), penalty(0) {
        memset(ac, 0, sizeof ac);
        memset(wa, 0, sizeof wa);
    }
    bool operator<(const Team& obj)const {
        return solved < obj.solved
            || (solved == obj.solved && penalty > obj.penalty)
            || (solved == obj.solved && penalty == obj.penalty && id > obj.id);
    }
    void correct(int pID, int t) {
        if (ac[pID]) return ;
        ++ solved;
        ac[pID] = 1;
        penalty += wa[pID] * 1200 + t;
    }
    void wrong(int pID) {
        ++ wa[pID];
    }
};

int main() {
    int T, P, R;
    while (cin >> T >> P >> R, T) {
        vector<Team> teams;
        for (int i=1; i<=T; ++i) teams.push_back(Team(i));
        int tID, pID, t;
        string msg;
        for (int i=0; i<R; ++i) {
            cin >> tID >> pID >> t >> msg;
            tID --; pID --;
            if (msg == "CORRECT") {
                teams[tID].correct(pID, t);
            } else if (msg == "WRONG") {
                teams[tID].wrong(pID);
            }
        }
        sort(teams.begin(), teams.end());
        reverse(teams.begin(), teams.end());
        for (int i=0; i<(int)teams.size(); ++i) {
            cout << teams[i].id << " " << teams[i].solved << " " << teams[i].penalty << endl;
        }
    }
    return 0;
}

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

typedef struct TreamInfo
{
    int tID;
    int points;
    int pena;
    int ProbMiss[10];

    TreamInfo(int tid) : tID(tid) {}
} TeamInfo;

bool cmp(const TeamInfo &a, const TeamInfo &b)
{
    return (a.points == b.points)?(a.pena == b.pena? a.tID < b.tID:a.pena < b.pena):(a.points > b.points);
}

int main()
{
    while (true)
    {
        int t, p, r;
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0)
            break;

        vector<TeamInfo> v;

        for (size_t i = 0; i < t; i++)
        {
            v.push_back(TeamInfo(i+1));
        }

        for (size_t i = 0; i < r; i++)
        {
            int tID, pID, tim;
            string mess;
            cin >> tID >> pID >> tim >> mess;

            if (mess == "CORRECT")
            {
                v[tID - 1].points += 1;
                v[tID - 1].pena += ((v[tID - 1].ProbMiss[pID - 1]) * 1200) + tim;
            }
            if (mess == "WRONG")
            {
                v[tID - 1].ProbMiss[pID - 1] += 1;
            }
        }
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << "team " << i <<" point is " <<v[i].points << endl;
        //     cout << "team " << i << " pena is " << v[i].pena << endl;
        // }

        sort(v.begin(), v.end(), cmp);
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << v[i].tID <<" "<< v[i].points <<" "<< v[i].pena << endl;
        // }
    }
    return 0;
}