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,time;
  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 >> time >> sta;
      if(sta == "CORRECT"){
    for(int i=0;i<t;i++){
      if(data[i].team == tid){
        data[i].sum += data[i].pro[pid]*1200+time;
        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;
    }
      }
    }
    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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <fstream>
 
using namespace std;
 
#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;

#define MAX_T 51
#define MAX_P 11
#define MAX_R 501


int main(){

  while(true){

    int T, P, R;
    int pID[MAX_T][MAX_P];
    int sum_time[MAX_T];
    int correct_count[MAX_T];
    bool used[MAX_T];

    memset(pID, 0, sizeof(pID));
    memset(sum_time, 0, sizeof(sum_time));
    memset(correct_count, 0, sizeof(correct_count));
    memset(used, 0, sizeof(used));

    cin >> T >> P >> R;
    if(T == 0)
      break;

    while(R > 0){
      R--;

      int id,p,t;
      string str;
      cin >> id >> p >> t >> str;

      if(str == "CORRECT"){
	correct_count[id]++;
	sum_time[id] += t + pID[id][p]*1200;
      }
      else{
	pID[id][p]++;
      }

    }

    int ret = 0;

    while(ret < T){
      ret++;
      int id,count,time;
      count = -1;
      time = INF;
      for(int i = 1; i <= T; i++){
	if(!used[i] && count < correct_count[i]){
	  id = i;
	  count = correct_count[i];
	  time = sum_time[i];
	}
	else if(!used[i] && count == correct_count[i] && time > sum_time[i]){
	  id = i;
	  time = sum_time[i];
	}
      }

      used[id] = true;
      cout << id << " " << count << " " << time << endl;

    }

  }

  return 0;

}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

class Team{
public:
	int tid,correct,penalty;
	int wrong[11];
	bool operator< (const Team &opp) const{
		if(correct!=opp.correct) return correct>opp.correct;
		if(penalty!=opp.penalty) return penalty<opp.penalty;
		return tid<opp.tid;
	}
	Team();
	Team(int id);
};

Team::Team(){
	correct=0;penalty=0;
}
Team::Team(int id){
	tid=id;correct=0;penalty=0;
	for(int i=1;i<=10;i++)wrong[i]=0;
}

Team T[50];

int main(){
	int i,t,p,r;
	while(cin>>t>>p>>r, t){
		int tid, pid, time;
		string mes;
		for(i=1;i<=t;i++) T[i]=Team(i);
		while(r--){
			cin>>tid>>pid>>time>>mes;
			if(mes=="CORRECT"){
				T[tid].correct ++;
				T[tid].penalty += T[tid].wrong[pid]*1200+time;
			}else{
				T[tid].wrong[pid] ++;
			}
		}
		sort(T+1, T+1+t);
		for(i=1;i<=t;i++) cout<<T[i].tid<<" "<<T[i].correct<<" "<<T[i].penalty<<endl;
	}
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int sort(int result[55][4], int n){
    range(i,1,n){
        range(j,1,n-1){
            if( (result[j][3] < result[j + 1][3]) || (result[j][3] == result[j + 1][3] && result[j][0] > result[j + 1][0]) ){
                rep(k,4){
                    int temp = result[j][k];
                    result[j][k] = result[j + 1][k];
                    result[j + 1][k] = temp;
                }
            }
        }
    }
}

int main(){
    int T, P, R;
    while(cin >> T >> P >> R, T||P||R){
        int tID, pID, time, list[55][15] = {0}, result[55][4]= {0};
        string massage;
        rep(i,54) result[i][2] = i;
        rep(i,R){
            cin >> tID >> pID >> time >> massage;
            if(massage == "CORRECT" & list[tID][pID] <= 0){
                result[tID][0]+= abs(list[tID][pID]) * 1200 + time;
                result[tID][1]+= abs(list[tID][pID]);
                result[tID][3]++;
                list[tID][pID] = 1;
            }else if(massage == "WRONG" && list[tID][pID] <= 0){
                list[tID][pID]--;
            }
        }
        sort(result, T + 1);
        range(i,1,T + 1){
            cout << result[i][2] << ' ' << result[i][3] << ' ' << result[i][0] << endl;
        }
    }   
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define I (1<<21)
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;
				}
			}
		}
	}
}