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

using namespace std;

struct team{
	int tnum, correct, penalty;
};

bool cmp(struct team lhs, struct team rhs){
	if(lhs.correct != rhs.correct)
		return lhs.correct > rhs.correct;
	else if(lhs.penalty != rhs.penalty)
		return lhs.penalty < rhs.penalty;
	else
		return lhs.tnum < rhs.tnum;
}

int main(){
	int T, P, R;
	int t, q, time;
	string judge;
	int wrong[100][100];
	struct team ans[100];
	int i, j;
	
	while(1){
		cin >> T >> P >> R;
		if(T == 0 && P == 0 && R == 0)
			break;
		
		for(i = 0; i < 100; i++){
			ans[i].tnum = i + 1;
			ans[i].correct = ans[i].penalty = 0;
			for(j = 0; j < 100; j++)
				wrong[i][j] = 0;
		}
		
		for(i = 0; i < R; i++){
			cin >> t >> q >> time >> judge;
			
			if(judge == "WRONG")
				wrong[t - 1][q - 1]++;
			else{
				ans[t - 1].correct++;
				ans[t - 1].penalty += time + wrong[t - 1][q - 1] * 1200;
			}
		}
		
		sort(ans, ans + T, cmp);
		for(i = 0; i < T; i++)
			cout << ans[i].tnum << " " << ans[i].correct << " " << ans[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;

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.first)
			return left.first < right.first;
		else
			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;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;


bool cmp(const tpair &a, const tpair &b){
  if(a.second.first != b.second.first) return a.second.first > b.second.first;
  else if(a.second.second != b.second.second) return a.second.second < b.second.second;
  else return a.first < b.first;
}


int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[64][64] = {};
    int tid, pid, time;
    char message[64];
    rep(i, T) t[i] = make_pair(i+1, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d", &tid, &pid, &time);
tid--;
      scanf("%s", message);
      if(message[0] == 'C'){
	  t[tid].second.first += 1;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
      }else  fail[tid][pid]++;
    }
    sort(t.begin(), t.end(), cmp);
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
struct team{
	int p;
	int w[11];
	int num;
	int cnt;
	void init(int n){
		p=cnt=0;
		num=n;
		for(int i=0;i++<10;)w[i]=0;
	}
	bool operator<(team a)
	{
		if(cnt!=a.cnt)return cnt<a.cnt;
		else if(p!=a.p)return p>a.p;
		else return num>a.num;
	}
};
int t,p,r;
main()
{
	while(cin>>t>>p>>r,t)
	{
		team a[55];
		for(int i=0;i++<t;)a[i].init(i);
		for(int i=0;i<r;i++)
		{
			int T,P,M;string s;
			cin>>T>>P>>M>>s;
			if(s=="WRONG")
			{
				a[T].w[P]++;
			}
			else
			{
				a[T].cnt++;
				a[T].p+=a[T].w[P]*1200+M;
			}
		}
		sort(a+1,a+t+1);
		for(int i=t;i>0;i--)cout<<a[i].num<<" "<<a[i].cnt<<" "<<a[i].p<<endl;
	}
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define I (1<<20)
using namespace std;
int x[100], z[100], y[99][20], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		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] += I;
				x[d] += f + 1200 * y[d][e];
			}
		}
		for (i = 1; i <= a; i++) { z[i] = x[i]; }
		sort(x + 1, x + a + 1);
		for (i = a; i >= 1; i--) {
			for (j = 1; j <= a; j++) {
				if (z[j] == x[i]) {
					cout << j << ' ' << x[i] / I << ' ' << x[i] % I << endl;
				}
			}
		}
	}
}