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;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int t,p,r;
  while(true){
    cin >> t >> p >> r;//???????????°???????????°?????¬???????????°
    if(t==0) break;
    int seikai[t+1]={0},penalty[t+1]={0},gotou[t+1][p+1]={0};
    for(int i=0;i<r;i++){
      int tID,pID,time;
      string s;
      cin >> tID >> pID >> time >> s;
      if(s=="CORRECT"){
        seikai[tID]++;
        penalty[tID] += gotou[tID][pID]*1200+time;
      }
      else{
        gotou[tID][pID]++;
      }
    }
    bool checked[t+1]={false};
    for(int i=1;i<=t;i++){
      int team,seikaimax=-1,pena=INF;
      for(int j=1;j<=t;j++){
        if(!checked[j]){
          if(seikaimax<seikai[j]){
            seikaimax=seikai[j];
            team=j;
            pena=penalty[j];
          }
          else if(seikaimax==seikai[j]){
            if(pena>penalty[j]){
              team=j;
              pena=penalty[j];
            }
          }
        }
      }
      checked[team]=true;
      cout << team <<" " << seikaimax <<" " << pena << endl;
    }
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int t,p,r;
//int snum[55],pnum[55][11],penalty[55];
struct team{
	int id,snum,pnum[11],penalty;
};
bool comp(const team& a,const team& b){
	if(a.snum==b.snum){
		if(a.penalty==b.penalty)return a.id<b.id;
		else return a.penalty<b.penalty;
	}else return a.snum>b.snum;
}
team teams[55];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>t>>p>>r;
		if(t==0)break;
		rep(i,t){
			teams[i].id=i;
			teams[i].snum=0;
			teams[i].penalty=0;
			rep(j,p)teams[i].pnum[j]=0;
		}
		rep(i,r){
			int tid,pid,time; string mes;
			cin>>tid>>pid>>time>>mes;
			tid--; pid--;
			if(mes=="CORRECT"){
				teams[tid].snum++;
				teams[tid].penalty+=teams[tid].pnum[pid]*1200+time;
			}else{
				teams[tid].pnum[pid]++;
			}
		}
		sort(teams,teams+t,comp);
		rep(i,t){
			cout<<teams[i].id+1<<" "<<teams[i].snum<<" "<<teams[i].penalty<<endl;
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct team_t {
  array<uint32_t, 11> wrongs;
  uint32_t penalty;
  uint32_t corrects;
  uint32_t id;
  team_t() : wrongs({}), penalty(0), corrects(0), id(0) {}

  void correct(uint32_t pid, uint32_t time) {
    corrects++;
    penalty += 1200 * wrongs[pid] + time;
  }

  void wrong(uint32_t pid) { wrongs[pid]++; }

  void println() { cout << id << " " << corrects << " " << penalty << endl; }

  bool operator<(const team_t &team) const {
    return corrects == team.corrects ? penalty < team.penalty
                                     : corrects > team.corrects;
  }
};

int32_t main() {
  while (true) {
    uint32_t T, P, R;
    cin >> T >> P >> R;
    if (T == 0) break;

    vector<team_t> teams(T + 1);
    for (uint32_t i = 1; i <= T; i++) {
      teams[i].id = i;
    }

    for (uint32_t i = 0; i < R; i++) {
      uint32_t tid, pid, t;
      string msg;
      cin >> tid >> pid >> t >> msg;
      if (msg == "WRONG") {
        teams[tid].wrong(pid);
      } else if (msg == "CORRECT") {
        teams[tid].correct(pid, t);
      }
    }

    sort(teams.begin() + 1, teams.begin() + T+1);

    for (uint32_t i = 1; i <= T; i++) {
      teams[i].println();
    }
  }

  return 0;
}