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 <utility>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void){
  while(true){
    int t, p, r;
    cin >> t >> p >> r;
    if(t == 0 && p == 0 && r == 0){ break; }

    vector<vector<int> > wa(t, vector<int>(p, 0));
    vector<pair<pair<int, int>, int> > penalty;
    for(int i = 0; i < t; i++)
      penalty.push_back(make_pair(make_pair(0, 0), -i));

    int tID, pID, time;
    string message;
    for(int i = 0; i < r; i++){
      cin >> tID >> pID >> time >> message;
      --tID;
      --pID;
      if(wa[tID][pID] < 0){ continue; }
      if(message == "CORRECT"){
        ++penalty[tID].first.first;
        penalty[tID].first.second += wa[tID][pID] * 1200 + time;
        wa[tID][pID] = -1;
      }
      else{ ++wa[tID][pID]; }
    }
    sort(penalty.begin(), penalty.end());
    reverse(penalty.begin(), penalty.end());

    for(int i = 0; i < t; i++){
      printf("%d %d %d\n", (-penalty[i].second) + 1, penalty[i].first.first, penalty[i].first.second);
    }
  }

  return 0;
}

C++: #include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
int main(){
    int T,P,R;
    int tid,pid,time;
    string message;
    while(cin>>T>>P>>R,T || P || R){
        pair<int,int> team[51];
        int used[51]={};
        int pena[51][11]={};
        for(int i=0;i<T;i++) team[i+1].S=i+1;
        for(int i=0;i<R;i++){
            cin>>tid>>pid>>time>>message;
            if(message=="WRONG"){
                pena[tid][pid]++;
            }
            else if(message=="CORRECT"){
                used[tid]+=time+pena[tid][pid]*1200;
                team[tid].F++;
            }
        }
        sort(team+1,team+1+T);
        reverse(team+1,team+1+T);
        bool flag=true;
        while(flag){
            flag=false;
            for(int i=0;i<T;i++){
                for(int j=i+1;j<T;j++){
                    if(team[i+1].F==team[j+1].F){
                        if(used[team[i+1].S]>used[team[j+1].S]){
                            swap(team[i+1],team[j+1]);
                            flag=true;
                        }
                        else if(used[team[i+1].S]==used[team[j+1].S] && team[i+1].S > team[j+1].S){
                            swap(team[i+1],team[j+1]);
                            flag=true;
                        }
                    }
                }
            }
        }
        for(int i=0;i<T;i++){
            cout<<team[i+1].S<<" "<<team[i+1].F<<" "<<used[team[i+1].S]<<endl;
        }
        
    }
    
    return 0;
}

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

struct Team{
  int team_num,correct,time;

};

int main(){
  Team data[51];
  int T,P,R,i,j,team_wrong[51][11],t,p,jikan;
  string message;
  while(1){
  cin >> T >> P >> R;
  if( T == 0 && P == 0 && R == 0 ) break;
  for( i = 1; i <= T; i++ ) data[i].team_num = i;
  for( i = 1; i <= T; i++ ) data[i].time = 0;
  for( i = 1; i <= T; i++ ) data[i].correct = 0;
  for( i = 1; i <= 50; i++ ){
    for( j = 1; j <= 10; j++ ){
      team_wrong[i][j] = 0;
    }
  }
  for( i = 0; i < R; i++ ){
    cin >> t >> p >> jikan >> message;
    if( message == "CORRECT" ){
      data[t].correct++;
      data[t].time += jikan + team_wrong[p][t] * 1200;
    }else if( message == "WRONG" ){
      team_wrong[p][t]++;
    }
  }

  for( i = 1; 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 = 1; 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;
}