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 <algorithm>

using namespace std;

struct Team {
    int number, correct, penalty;

    bool operator <(const Team &t) const {
        if(correct != t.correct) return correct > t.correct;
        if(penalty != t.penalty) return penalty < t.penalty;
        return number < t.number;
    }
};

int main() {
    while(true) {
        int T, P, R;
        cin >> T >> P >> R;
        if(!T && !P && !R) break;

        vector<Team> teams(T);
        for(int i = 0; i < T; ++i) teams[i].number = i+1;
        vector<vector<int> > wa_count(T, vector<int>(P, 0));

        for(int i = 0; i < R; ++i) {
            int tid, pid, tim;
            string message;
            cin >> tid >> pid >> tim >> message;
            --tid; --pid;
            if(message == "CORRECT") {
                teams[tid].correct++;
                teams[tid].penalty += tim + wa_count[tid][pid] * 1200;
            }
            else {
                wa_count[tid][pid]++;
            }
        }

        sort(teams.begin(), teams.end());
        for(int i = 0; i < teams.size(); ++i) {
            cout << teams[i].number << ' ' << teams[i].correct << ' ' << teams[i].penalty << endl;
        }
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define eb emplace_back

int in(){int x;cin>>x;return x;}
main(){
    while(1){
        int t=in();
        int p=in();
        int r=in();
        if(!t and !p and !r)exit(0);
        vector<vector<int>> pen(t,vector<int>(p));
        vector<int> T(t),cnt(t);
        rep(i,r){
            int id=in()-1;
            int pid=in()-1;
            int tim=in();
            string val;cin>>val;
            if(val[0]=='C'){
                T[id]+=tim;
                T[id]+=pen[id][pid]*1200;
                cnt[id]++;
            }
            else pen[id][pid]++;
        }
        vector<int> id(t);
        iota(id.begin(),id.end(),0);
        sort(id.begin(),id.end(),[&](int x,int y){
            if(cnt[x]!=cnt[y]) return cnt[x]>cnt[y];
            else if(T[x]!=T[y]) return T[x]<T[y];
            else return x<y;
        });
        rep(i,t){
            cout<<id[i]+1<<" "<<cnt[id[i]]<<" "<<T[id[i]]<<endl;
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

bool comp(vector<int> lhs, vector<int> rhs) {
  if (lhs[0] != rhs[0]) {
    return lhs[0] > rhs[0];
  } else if (lhs[1] != rhs[1]) {
    return lhs[1] < rhs[1];
  } else {
    return lhs[2] < rhs[2];
  }
}

int main(void) {
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if(!t && !p && !r) break;
    VVI record(r);
    REP(i, r) {
      int tid, pid, Time, message;
      string mess;
      cin >> tid >> pid >> Time >> mess;
      if (mess == "CORRECT")
        message = 1;
      else
        message = 0;
      record[i] = (vector<int>{Time, tid, pid, message});
    }
    sort(ALL(record));

    VVI ans(t, VI(3, 0));
    int pen[55][15] = {0};
    REP(i, t) ans[i][2] = i + 1;
    REP(i, r) {
      int Time = record[i][0], tid = record[i][1], pid = record[i][2];
      tid--;
      if (record[i][3] == 1) {
        ans[tid][0]++;
        ans[tid][1] += pen[tid][pid] * 1200 + Time;
      } else {
        pen[tid][pid]++;
      }
      //cout << tid << " " << pid << " " << ans[tid][2] << " " << ans[tid][0]
           //<< " " << ans[tid][1] << endl;
    }

    sort(ALL(ans), comp);

    REP(i, t) {
      cout << ans[i][2] << " " << ans[i][0] << " " << ans[i][1] << endl;
    }
  }

  return 0;
}

C++: 
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 1e9;

const int M = 100;
int main()
{
	int t, p, r;

	while (cin >> t >> p >> r && t){

		int pe[M]; clr(pe);
		int wr[M][M]; clr(wr);
		int w[M]; clr(w);


		rep(i, r){
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if (mes == "CORRECT"){
				w[tid]++;
				pe[tid] += wr[tid][pid] * 1200 + time;
			}
			else{
				wr[tid][pid]++;
			}
		}

		for (int i = p; i >= 0; i--){
			bool f[M]; clr(f);
			For(j, 1, t + 1){
				if (w[j] == i)f[j] = 1;
			}
			vector<P> v;
			For(j, 1, t + 1){
				if (f[j]){
					v.push_back(P(pe[j], j));
				}
			}
			sort(all(v));

			rep(j, v.size()){
				cout << v[j].second << " " << i << " " << v[j].first << endl;

			}

		}


	}


	return 0;
}