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

struct P{
    int team;
    int ans;
    int sum;
    int pro[100];
    static bool less(const P& left,const P& right){
        if(left.ans != right.ans) return left.ans > right.ans;
        else if(left.sum != right.sum) return left.sum < right.sum;
        else return left.team < right.team;
    }
};

int main(){
    int t,p,r,tid,pid,tim;
    string sta;
    while(cin >> t >> p >> r){
        if(t == 0 && r == 0 && p == 0) break;
        vector <P> data;
        P tmp;
        for(int i=0;i<t;i++){
            tmp.team = i+1;
            tmp.ans = 0;
            tmp.sum = 0;
            for(int j=0;j<=p;j++) tmp.pro[j] = 0;
            data.push_back(tmp);
        }
        while(r--){
            cin >> tid >> pid >> tim >> sta;
            if(sta == "CORRECT"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].sum += data[i].pro[pid]*1200+tim;
                        data[i].ans += 1;
                        break;
                    }
                }
            }
            else if(sta == "WRONG"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].pro[pid] += 1;
                        break;
                    }
                }
            }
        }
        sort(data.begin(),data.end(),P::less);
        for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
    }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int t[51][11][3] = {};//?§£????????? ??????????????£ ??????
	for (int T, P, R; cin >> T >> P >> R&&T;) {
		memset(t, 0, sizeof(t));
		int tID, pID, time; string message;
		for (int i = 0; i < R; i++) {
			cin >> tID >> pID >> time >> message;
			if (message[0] == 'C') {
				t[tID][pID][0] = 1;
				t[tID][pID][2] = time;
			}
			else {
				t[tID][pID][1]++;
			}
		}
		vector<pair<int, int>> a[11];
		for (int i = 1; i <= T; i++) {
			int cnt = 0,time=0;
			for (int j = 1; j <= P; j++) {
				if (t[i][j][0]) {
					time += t[i][j][2] + t[i][j][1] * 1200;
					cnt++;
				}
			}
			a[cnt].push_back( make_pair(time, i));
		}
		for (int i = 10; i >= 0; i--) {
			sort(a[i].begin(), a[i].end());
			for (size_t j = 0; j < a[i].size(); j++) {
				cout << a[i][j].second << " " << i << " " << a[i][j].first << endl;
			}
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

struct Score {
  int ac, penalty, idx;
  bool operator<(const Score& other) const {
    if (ac != other.ac) return ac > other.ac;
    if (penalty != other.penalty) return penalty < other.penalty;
    return idx < other.idx;
  }
};

int T, P, R;
Score score[52];
int wa[52][12];

char msg[100];

int main() {
  while (scanf("%d%d%d", &T, &P, &R), T | P | R) {
    rep(i,T) {
      score[i].ac = score[i].penalty = 0;
      score[i].idx = i+1;
    }
    memset(wa, 0, sizeof wa);
    
    int tid, pid, tm;
    rep(i,R) {
      scanf(" %d%d%d%s", &tid, &pid, &tm, msg);
      --tid; --pid;
      if (msg[0] == 'C') {
        score[tid].ac += 1;
        score[tid].penalty += (1200 * wa[tid][pid] + tm);
      } else {
        ++wa[tid][pid];
      }
    }

    sort(score, score + T);
    rep(i,T) {
      printf("%d %d %d\n", score[i].idx, score[i].ac, score[i].penalty);
    }
  }
  return 0;
}