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;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
    int t, p, r;
    while (cin >> t >> p >> r)
    {
        map<int, pair<int, int>> mp; // ID　解いた問題数 ペナルティ
        vector<vector<int>> solved(t + 1, vector<int>(p + 1, false));
        vector<vector<int>> WA(t + 1, vector<int>(p + 1, 0));

        for (int i = 0; i < t; i++)
        {
            mp[i + 1] = {0, 0};
        }

        for (int i = 0; i < r; i++)
        {
            int tid, pid, time;
            string message;
            cin >> tid >> pid >> time >> message;

            if (solved[tid][pid])
                continue;
            if (message == "CORRECT")
            {
                solved[tid][pid] = true;
                mp[tid].first--;
                mp[tid].second += WA[tid][pid] * 1200 + time;
            }
            else
            {
                WA[tid][pid]++;
            }
        }

        vector<pair<pair<int, int>, int>> ans;

        for (auto &p : mp)
        {
            ans.push_back({p.second, p.first});
        }

        sort(ans.begin(), ans.end());

        for (int i = 0; i < t; i++)
        {
            cout << ans[i].second << " " << -ans[i].first.first << " " << ans[i].first.second << "\n";
        }
    }
}

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

int main(){
	while(1){
		int t,p,r;
		cin>>t>>p>>r;
		if(t==0&&p==0&&r==0) break;
		int qstats[50][10];
		int score[50],pn[50];
		lp(i,50){
			score[i]=0;
			pn[i]=0;
			lp(j,10){
				qstats[i][j]=0;
			}
		}
		lp(i,r){
			int a,b,c;
			string d;
			cin>>a>>b>>c>>d;
			if(d=="CORRECT"){
				score[a]++;
				pn[a]+=c+qstats[a][b]*1200;
			}
			else{
				qstats[a][b]++;
			}
		}
		tuple<int,int,int> ans[50];
		lp(i,t){
			ans[i]=make_tuple(score[i+1],-pn[i+1],500-i-1);
		}
		sort(ans,ans+t);
		reverse(ans,ans+t);
		lp(i,t){
			int ans1,ans2,ans3;
			ans1=get<2>(ans[i]);
			ans2=get<0>(ans[i]);
			ans3=get<1>(ans[i]);
			cout<<500-ans1<<" "<<ans2<<" "<<-ans3<<endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
class status {
public:
    int miss[11], solve, time, id;
    bool operator<(const status & rhs) const{
        if(solve > rhs.solve) return true;
        else if(solve==rhs.solve && time < rhs.time) return true;
        else if(solve==rhs.solve && time == rhs.time && id < rhs.id) return true;
        return false;
    }
};

status a[51];

int main(void){
    int T, P, R;
    int team, prob, time;
    string msg;
    while(cin >> T >> P >> R && T) {
        rep(i, 52) {
            a[i].solve = a[i].time = 0;
            a[i].id = i+1;
            rep(j, 11) a[i].miss[j] = 0;
        }
        rep(i, R) {
            cin >> team >> prob >> time >> msg;
            team--;
            if(msg == "CORRECT") {
                a[team].solve++;
                a[team].time += a[team].miss[prob]*1200+time;
            } else {
                a[team].miss[prob]++;
            }
        }
        sort(a, a+T);
        rep(i, T) cout << a[i].id << " "<<  a[i].solve << " " << a[i].time << endl;
    }
}