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 <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <queue>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;


int main(){
  P2 team[51];
  int wrongCount[51][11];
  
  string message;
  int T, P, R;
  int Tid, Pid, time;
  
  while(cin >> T >> P >> R){
    if(T == 0 && P == 0 && R == 0) break;
    
    memset(wrongCount, 0, sizeof(wrongCount));
    
    for(int i = 0 ; i < T ; i++){
      team[i].first = 0; // Correct count
      team[i].second.first = 0; // time count
      team[i].second.second = i+1; // team number
    }

    for(int i = 0 ; i < R ; i++){
      cin >> Tid >> Pid >> time >> message;
      
      Tid--;
      
      if(message == "CORRECT"){
	team[Tid].first++;
	team[Tid].second.first += wrongCount[Tid][Pid]*1200 + time;
      }
      else if(message == "WRONG") wrongCount[Tid][Pid]++;
    }
    
    for(int i = 0 ; i < T ; i++){
      team[i].second.first *= -1;
      team[i].second.second *= -1;
    }
    
    stable_sort(team, team+T);
    reverse(team, team+T);
  
    for(int i = 0 ; i < T ; i++){
      printf("%d %d %d\n", team[i].second.second*=-1, team[i].first, team[i].second.first*=-1);
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
//typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int T,P,R;
    while(cin>>T>>P>>R && T){
        vector<vector<int>> AC(T,vector<int>(P,0)),WA(T,vector<int>(P,0));
        vector<int> tim(T,0);
        
        rep(i,0,R){
            int t,p,timee;
            string s;
            cin>>t>>p>>timee>>s;
            t--; p--;
            if(s=="CORRECT"){
                AC[t][p]++;
                tim[t]+=timee+WA[t][p]*1200;
            }else if(s=="WRONG"){
                WA[t][p]++;
            }
        }
        
        vector<int> AC_count(T,0),WA_count(T,0);
        rep(i,0,T){
            rep(j,0,P){
                if(AC[i][j])AC_count[i]++;
                if(WA[i][j])WA_count[i]++;
            }
        }
        
        vector<pair<int,pair<int,int>>> rank(T);
        rep(i,0,T)rank[i]=MP(-AC_count[i],MP(tim[i],i+1));
        Sort(rank);
        
        rep(i,0,T){
            cout<<rank[i].se.se<<" "<<-rank[i].fi<<" "<<rank[i].se.fi<<endl;
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
struct team{
  int point,penalty,wrong[11],id;
  bool operator<(const team& a)  const{
    return point == a.point ? (penalty == a.penalty ? id < a.id : penalty < a.penalty) : point > a.point; 
  }
};
int main(){
  int t,p,r,i,j,k,b,o,tid,pid,time;
  string str;
  cin >> t >> p >> r;
  while(t!=0||p!=0||r!=0){
    vector <team> teams;
    for(i=1;i<=t;i++){
      team t;
      t.id=i;
      t.point=0;
      for(j=0;j<11;j++)
      t.wrong[j]=0;
      t.penalty=0;
      teams.push_back(t);
    }
    for(i=0;i<r;i++){
      cin >> tid >> pid >> time >> str;
      if(str[0]=='C'){
	teams[tid-1].point++;
	teams[tid-1].penalty+=teams[tid-1].wrong[pid]*1200+time;
      }else{
	teams[tid-1].wrong[pid]++;
      }
    }
    sort(teams.begin(),teams.end());
    for(i=0;i<t;i++){
      cout << teams[i].id << " " << teams[i].point << " " << teams[i].penalty << endl;
    }
    cin >> t >> p >> r;
  }
  return 0;
}

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

using namespace std;

struct Team {
	int tID;
	int penalty;
	int correct;
	int wrong[10];
};

int main(void)
{
	int T, P, R, tID, pID, time;
	string message;
	Team t[50];

	while (cin >> T >> P >> R, T && P && R)
	{
		for (int i = 0; i < T; ++i)
		{
			t[i].tID = i+1;
			t[i].penalty = t[i].correct = 0;
			for (int j = 0; j < P; ++j)	t[i].wrong[j] = 0;
		}

		for (int i = 0; i < R; ++i)
		{
			cin >> tID >> pID >> time >> message;
			if (message == "CORRECT")
			{
				++t[tID-1].correct;
				t[tID-1].penalty += t[tID-1].wrong[pID-1] * 1200 + time;
			}
			else	++t[tID-1].wrong[pID-1];
		}

		for (int i = 0; i < T; ++i)
		{
			for (int j = i+1; j < T; ++j)
			{
				if (t[i].correct < t[j].correct)	swap(t[i], t[j]);
				else if (t[i].correct == t[j].correct)
				{
					if (t[i].penalty > t[j].penalty)	swap(t[i], t[j]);
					else if (t[i].penalty == t[j].penalty)	if (t[i].tID > t[j].tID)	swap(t[i], t[j]);
				}
			}
		}

		for (int i = 0; i < T; ++i)	cout << t[i].tID << " " << t[i].correct << " " << t[i].penalty << endl;
	}
	return 0;
}