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 rep(i,n) for(int i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()

struct Info
{
    int AC,penalty,tid;
    Info (int tid_){
        AC = penalty = 0;
        tid = tid_;
    }
    bool operator<(const Info &right) const {
        if(AC != right.AC){
            return AC > right.AC;
        }else if(penalty != right.penalty){
            return penalty < right.penalty;
        }else{
            return tid < right.tid;
        }
    }
};


int main(void){
    int T,P,R;
    while(cin>>T>>P>>R, T|P|R){
        vector<Info> info;
        rep(tid,T){
            info.push_back(Info(tid));
        }
        int wa[50][10] = {};
        rep(i,R){
            int tid, pid, time;
            string message;
            cin>>tid>>pid>>time>>message;
            tid--, pid--;
            if(message == "WRONG"){
                wa[tid][pid]++;
            }else{
                info[tid].AC++;
                info[tid].penalty += wa[tid][pid]*1200 + time;
            }
        }
        sort(all(info));
        for(Info i : info){
            printf("%d %d %d\n",i.tid+1, i.AC, i.penalty);
        }
    }

    return 0;
}

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

struct Team{
  int tid, cntWrong[11], penalty, AC;
  Team(int i){
    tid = i;
    for(int i = 1; i <= 10; i++) cntWrong[i] = 0;
    penalty = 0;
    AC = 0;
  }
};

vector<Team> teams;

void init(int T){
  for(int i = 1; i <= T; i++){
    teams.push_back(Team(i));
  }
}

bool compare(Team &t1, Team &t2){
  if(t1.AC != t2.AC) return t1.AC > t2.AC;
  else if(t1.penalty != t2.penalty) return t1.penalty < t2.penalty;
  else return t1.tid < t2.tid;
}

int main(void){
  int T, P, R;
  while(cin >> T >> P >> R && T != 0 && P != 0 && R != 0){
    int tid, pid, time;
    string message;
    teams.clear();
    init(T);
    for(int i = 0; i < R; i++){
      cin >> tid >> pid >> time >> message;
      if(message == "WRONG"){
        teams[tid-1].cntWrong[pid]++;
      }else if(message == "CORRECT"){
        teams[tid-1].penalty += teams[tid-1].cntWrong[pid] * 1200 + time;
        teams[tid-1].AC++;
      }
    }
    sort(teams.begin(), teams.end(), compare);
    for(int i = 0; i < T; i++){
      cout << teams[i].tid << " " << teams[i].AC << " " << teams[i].penalty << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;
const int MAX_T = 55;
const int MAX_P = 20;

bool com(const pair<int, pair<int, int> >& left, const pair<int, pair<int, int> >& right) {
	if(left.second.first == right.second.first) {
		if(left.second.second == right.second.second)
			return left.first < right.first;
		else
			return left.second.second < right.second.second;
	}
	else
		return left.second.first > right.second.first;
}

int w[MAX_T][MAX_P];

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T|P|R) {
		vector< pair<int, pair<int, int> > > vp;
		REP(i, T)
			vp.push_back(make_pair(i+1, make_pair(0, 0)));
		REP(j, R) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT") {
					vp[tid-1].second.first++;
					vp[tid-1].second.second += w[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG")
        ++w[tid][pid];
		}
		sort(vp.begin(), vp.end(), com);
		REP(i, vp.size())
			cout << vp[i].first << ' ' << vp[i].second.first << ' ' << vp[i].second.second << endl; 
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int t,p,r;
    while (cin>>t>>p>>r) {
        if (t==0&&p==0&&r==0) {
            break;
        }
        long long int tID,pID,times;
        string message;
        std::map<long long int, long long int> correct;
        for (int i=1;i<=t;i++) {
            correct[i]=0;
        }
        std::map<pair<long long int,long long int>, long long int> incorrect;
        std::map<long long int, long long int> penalty;
        for (int i=0;i<r;i++) {
            cin>>tID>>pID>>times>>message;
            if (message=="CORRECT") {
                correct[tID]++;
                penalty[tID]+=incorrect[make_pair(tID,pID)]*1200+times;
            } else {
                incorrect[make_pair(tID,pID)]++;
            }
        }
        std::multimap<long long int, long long int,greater<long long int>> rank;
        std::map<long long int, long long int,greater<long long int>> correct_num;
        for (auto itr=correct.begin();itr!=correct.end();itr++) {
            rank.emplace(itr->second,itr->first);
            correct_num[itr->second]=1;
        }
        for (auto itr=correct_num.begin();itr!=correct_num.end();itr++) {
            auto p=rank.equal_range(itr->first);
            multimap<long long int,long long int> penalty_check;
            std::map<long long int, long long int> penalty_num;
            for (auto itr2=p.first;itr2!=p.second;itr2++) {
                penalty_check.emplace(penalty[itr2->second],itr2->second);
                penalty_num[penalty[itr2->second]]=1;
            }
            for (auto itr3=penalty_num.begin();itr3!=penalty_num.end();itr3++) {
                auto q=penalty_check.equal_range(itr3->first);
                for (auto itr4=q.first;itr4!=q.second;itr4++) {
                    cout<<itr4->second<<" "<<itr->first<<" "<<itr3->first<<endl;
                }
            }
        }
    }
}