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

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

  while(cin>>t>>p>>r&&t|p|r){
    vector<pair<int, pair<int, int> > > team(t);
    vector<pair<int, int> > problem;

    // initialize
    for(int i=0;i<t;i++){
      team[i].first=0;
      team[i].second.first=0;
      team[i].second.second=i+1;
    }

    for(int i=0;i<r;i++){
      int tid,pid,time;
      string message;
      cin >> tid >> pid >> time >> message;

      if(message=="WRONG"){
        problem.push_back(make_pair(pid, tid));
      }else{
        team[tid-1].first++;
        for(int j=0;j<problem.size();j++){
          if(problem[j].first==pid&&problem[j].second==tid){
            team[tid-1].second.first+=1200;
          }
        }
        team[tid-1].second.first+=time;
      }
    }

    sort(team.begin(), team.end(), greater<pair<int, pair<int, int> > >());

    for(int i=0;i<=t-1;i++){
      for(int j=i+1;j<=t-1;j++){
        if(team[i].first==team[j].first&&team[i].second.first>team[j].second.first){
          swap(team[i],team[j]);
          break;
        }
      }
    }

    for(int i=0;i<=t-1;i++){
      for(int j=i+1;j<=t-1;j++){
        if(team[i].first==team[j].first&&team[i].second.first==team[j].second.first&&team[i].second.second>team[j].second.second){
          swap(team[i],team[j]);
          break;
        }
      }
    }

    for(int i=0;i<t;i++){
      cout << team[i].second.second << " " << team[i].first << " " << team[i].second.first << endl;
    }

  }

  return 0;
}

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

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 vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct team{
	int a,t,n;
	bool operator<(team &arg){
		if(a==arg.a&&t==arg.t) return n<arg.n;
		if(a==arg.a) return t<arg.t;
		return a>arg.a;
	}
};

team info[55];

int wrong[55][11];

int main(void){
	int t,p,r;
	while(cin >> t >> p >> r){
		if(t==0)
			break;
		rep(i,55)rep(j,11) wrong[i][j]=0;
		rep(i,55) info[i].a=info[i].t=0,info[i].n=i+1;
		rep(i,r){
			int tid,pid,times;
			cin >> tid >> pid >> times;
			string m;
			cin >> m;
			if(wrong[tid][pid]!=-1){
				if(m=="CORRECT"){
					info[tid-1].a++;
					info[tid-1].t+=(times+1200*wrong[tid][pid]);
					wrong[tid][pid]=-1;
				}else
					wrong[tid][pid]++;
			}
		}
		sort(info,info+t);
		rep(i,t) cout << info[i].n << " " << info[i].a << " " << info[i].t << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define I 900000
int x[99],z[99],y[99][20],h[99],a,b,c,d,e,f,i,j,k;string S;
main(){
while(true){
for(i=0;i<99;i++){x[i]=I;h[i]=0;}
memset(y,0,sizeof(y));
cin>>a>>b>>c;
if(!a){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>0;i--){
for(j=1;j<=a;j++){
if(z[j]==x[i]&&!h[j]){
printf("%d %d %d\n",j,(x[i]+I-1)/I-1,(99*I-x[i])%I);
h[j]=1;
}
}
}
}
}

C++: #include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<pair<int,pair<int,int> > > inf_team(t,make_pair(0,make_pair(0,0)));//problem,time,number
		REP(i,t)inf_team[i].second.second = -i;
		vector<vector<int> > penalty(t,vector<int>(p,0));
		REP(i,r){
			int t_id,p_id,time;
			string mes;
			cin >> t_id >> p_id >> time >> mes;
			t_id--;p_id--;
			if(mes=="WRONG"){
				penalty[t_id][p_id]++;
			}else{
				inf_team[t_id].second.first -= time + 1200*penalty[t_id][p_id];
				inf_team[t_id].first++;
			}
		}
		sort(inf_team.begin(),inf_team.end(),greater<pair<int,pair<int,int> > >());
		REP(i,t){
			cout << -inf_team[i].second.second + 1 << " " << inf_team[i].first << " " << -inf_team[i].second.first << endl;
		}
	}
	return 0;
}

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

struct Team{
  int team_num,time,correct;
};

int main(){
  Team data[51];
  while(1){
    int i,j,T,P,R; cin >> T >> P >> R;
    if ( T == 0 && P == 0 && R == 0 ) break;
    for( i = 1; i <= T; i++ ){
      data[i].time = 0;
      data[i].correct = 0;
      data[i].team_num = i;
    }

    int t,p,jikan,twrong[51][11];
    for( i = 0; i < 51; i++ ){
      for( j = 0; j < 11; j++ ){
	twrong[i][j]=0;
      }
    }
    string str;
    for( i = 0; i < R; i++ ){
      cin >> t >> p >> jikan >> str;
      if( str == "CORRECT" ){
	data[t].correct++;
	data[t].time = data[t].time + twrong[t][p] * 1200 + jikan;
      }else if( str == "WRONG" ){
	twrong[t][p]++;
      }
    }
    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].team_num > data[j+1].team_num ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].time > data[j+1].time ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 0; i < T; i++ ){
      for( j = 1; j < T; j++ ){
	if( data[j].correct < data[j+1].correct ) 
	  swap( data[j],data[j+1] );
      }
    }

    for( i = 1; i <= T; i++ ){
      cout << data[i].team_num << " "
	   << data[i].correct << " " << data[i].time << endl;
    }
    
  }
  return 0;
}