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 <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main ()
{
    int T, P, R;
    while (cin >> T >> P >> R, (R || P || T)) {
        vector<vector<int> > w(T, vector<int>(P, 0));
        vector<int> c(T, 0);
        vector<int> s(T, 0);

        while (R--) {
            int id_t, id_p, time;
            string message;
            cin >> id_t >> id_p >> time >> message;
            if (message == "CORRECT") {
                s[id_t - 1] += time + w[id_t - 1][id_p - 1] * 1200;
                c[id_t - 1] += 1;
            } else {
                w[id_t - 1][id_p - 1] += 1;
            }
        }

        set<pair<int,int> > *rank = new set<pair<int,int> >[P + 1];
        for (int i = 0; i < T; i++) {
            rank[c[i]].insert(pair<int,int>(s[i], i));
        }
        for (int i = P; i >= 0; i--) {
            if (rank[i].size() != 0) {
                for (auto j : rank[i]) {
                    cout << j.second + 1 << " " << i << " " << j.first << endl;
                }
            }
        }

        delete [] rank;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int t,r,p;
	while(1){
		cin>>t>>r>>p;
		if(!t&&!r&&!p)break;
		int wrong[50][10],pena[50],team[50];
		bool flag[50][10];
		for(int i=0;i<t;i++){
			pena[i]=0;team[i]=0;
			for(int j=0;j<r;j++){
				wrong[i][j]=0;flag[i][j]=false;
			}
		}
		while(p--){
			string s;
			int a,b,c;
			cin>>a>>b>>c>>s;a--;b--;
			if(s=="WRONG"){
				wrong[a][b]++;
			}else {
				if(!flag[a][b]){
					pena[a]+=wrong[a][b]*1200+c;
					team[a]++;flag[a][b]=true;
				}
			}
		}
		vector<int> ans[11];
		for(int i=0;i<t;i++){
			ans[team[i]].push_back(i);
		}
		for(int i=1;i<11;i++){
			if(ans[i].size()>0){
				for(int j=0;j<ans[i].size();j++){
//					cout<<i<<" "<<ans[i][j]<<" "<<pena[ans[i][j]]<<endl;
				}
			}
		}
		vector<pair<int,int> > data;
		for(int i=10;i>=0;i--){
			data.clear();
			if(ans[i].size()>0){
				for(int j=0;j<ans[i].size();j++){
					data.push_back(make_pair(pena[ans[i][j]],ans[i][j]));
//					cout<<pena[ans[i][j]]<<" "<<ans[i][j]<<" "<<data.size()<<endl;
				}
				sort(data.begin(),data.end());
				for(int j=0;j<ans[i].size();j++){
					int y=data[j].second;
//					cout<<data[i].first<<" "<<y<<endl;
					cout<<y+1<<" "<<team[y]<<" "<<pena[y]<<endl;
				}
			}
		}
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int x[100][2], y[99][20], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		cin >> a >> b >> c;
		if (a == 0) { break; }
		for (i = 0; i < c; i++) {
			cin >> d >> e >> f >> S;
			if (S[0] = 'W') {
				y[d][e] ++;
			}
			else {
				x[d][0]++;
				x[d][1] += f + 1200 * y[d][e];
			}
		}
		for (i = 10; i >= 0; i++) {
			for (j = 0; j < 999999; j++) {
				for (k = 1; k <= a; k++) {
					if (x[k][0] == i && x[k][1] == j) {
						cout << k << ' ' << i << ' ' << j << endl;
					}
				}
			}
		}
	}
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

class team {
  public:
    int tid;
    int score;
    int penalty;
    // bool compare(team, team);
};

bool compare (team i, team j) {
  return i.score > j.score;
}

int main() {
  int t, p, r;

  while (cin >> t >> p >> r) {// && t && p && r) {
    vector<int> corrects(t);
    fill(corrects.begin(), corrects.end(), 0);
    vector<vector<int>> wrongs(t);
    rep (i, t) wrongs[i] = vector<int>(p);
    rep (i, t) fill(wrongs[i].begin(), wrongs[i].end(), 0);
    vector<int> penalties(t);

    int tid, pid, time_;
    string message;
    // vector<int> tID(r);
    // vector<int> pID(r);
    // vector<int> time(r);
    // vector<string> message(r);

    rep (i, r) {
      cin >> tid >> pid >> time_ >> message;
      tid--; pid--;

      if (message == "CORRECT") {
        corrects[tid]++;
        penalties[tid] += wrongs[tid][pid] * 1200 + time_;
      }
      else if (message == "WRONG") {
        wrongs[tid][pid]++;
      }
    }

    vector<team> teams(t);

    rep (i, t) {
      teams[i].tid = i+1;
      teams[i].score = corrects[i];
      teams[i].penalty = penalties[i];
    }

    sort(teams.begin(), teams.end(), compare);

    rep (i, t) {
      cout << teams[i].tid << ' ' << teams[i].score << ' ' << teams[i].penalty << endl;
    }
  }
}

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;

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

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T|P|R) {
		vector< pair<int, pair<int, int> > > vp;
		multiset<int> w;
		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.count(tid * 100 + pid) * 1200 + time;
			}
			else if(message == "WRONG")
				w.insert(tid * 100 + 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;
}