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++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
        tea.clear();
    }
    
    return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll solve[55][15] = {};
ll pena[55][15] = {};

int main(){
	while(1){
		ll T,P,R; cin >> T >> P >> R;
		if(!T && !P && !R) break;
		ll t,p,time; string ver;
		while(R--){
		cin >> t >> p >> time >> ver; t--; p--;
			if(ver == "CORRECT"){
				solve[t][p] = 1;
				pena[t][p] -= time;
			}else{
				pena[t][p] -= 1200;
			}
		}
		vector<tapu> ans(T);
		rep(i,T){
			ll a=0,b=0,c=-i-1;
			rep(j,P){
				if(solve[i][j]){
					a++;
					b += pena[i][j];
				}
			}
			ans[i] = tie(a,b,c);
		}
		sort(rall(ans));
		rep(i,T){
			ll a,b,c; tie(a,b,c) = ans[i];
			print3(-c,a,-b);
		}
		rep(i,T) rep(j,P) solve[i][j] = pena[i][j] = 0;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
struct team{
	int id,ac,p;
	int pp[11];
};

bool comp(const team &a,const team &b){
	if(a.ac==b.ac){
		if(a.p==b.p)return a.id<b.id;
		return a.p<b.p;
	}
	return a.ac>b.ac;
}

int it,p,r;
team t[51];
int main(void){
	while(1){
		scanf("%d%d%d",&it,&p,&r);
		if(r==0)break;
		memset(t,0,sizeof(t));
		for(int i=0;i<it;i++)t[i].id=i+1;
		for(int i=0;i<r;i++){
			int ti,pi,time;
			string str;
			scanf("%d%d%d",&ti,&pi,&time);
			cin >> str;
			ti--;
			if(str=="CORRECT"){
				t[ti].ac++;
				t[ti].p+=t[ti].pp[pi]*1200+time;
			}else{
				t[ti].pp[pi]++;
			}
		}
		sort(t,t+it,comp);
		for(int i=0;i<it;i++){
			printf("%d %d %d\n",t[i].id,t[i].ac,t[i].p);
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

struct Team {
    int id;
    int cnt;
    int penalty;
    int problem[10];

    bool operator<(const Team &r) const {
        if(cnt > r.cnt) {
            return true;
        } else if(cnt == r.cnt) {
            if(penalty < r.penalty) {
                return true;
            } else if(penalty == r.penalty) {
                if(id < r.id) return true;
                else return false;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
};

int main() {

    int t, p, r;
    int tid, pid, time;
    string message;

    while(cin >> t >> p >> r, t | p | r) {

        vector<Team> team(t);

        // Init
        for(int i = 0; i < t; ++i) {
            team[i].id = i + 1;
            team[i].cnt = 0;
            team[i].penalty = 0;
            memset(team[i].problem, 0, sizeof(team[i].problem));
        }

        // SCAN
        for(int i = 0; i < r; ++i) {
            cin >> tid >> pid >> time >> message;
            if(message == "CORRECT") {
                team[tid - 1].cnt++;
                team[tid - 1].penalty += team[tid - 1].problem[pid - 1] * 1200 + time;
            } else if(message == "WRONG") {
                ++team[tid - 1].problem[pid - 1];
            }
        }

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

        for(int i = 0; i < t; ++i) {
            cout << team[i].id << " " << team[i].cnt << " " << team[i].penalty << endl;
        }

    }

}