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

int main() {

  while( true ) {

    long long int t, p, r;
    cin >> t >> p >> r;
    if ( t == 0 ) break;

    long long int w[51][11] = {0};
    vector< pair< long long int, pair< long long int, long long int > > > score;
    for ( long long int i = 0; i < t; i++ ) {

      score.push_back( make_pair( 0, make_pair( 0, i+1 ) ) );

    }

    for ( long long int i = 0; i < r; i++ ) {

      long long int t_in, p_in, time;
      string m;
      cin >> t_in >> p_in >> time >> m;
      t_in--;
      p_in--;

      if ( m == "WRONG" ) {
	w[t_in][p_in]++;
      }else {
	score[t_in].first--;
	score[t_in].second.first += w[t_in][p_in] * 1200 + time;
      }

    }

    sort( score.begin(), score.end() );

    for ( long long int i = 0; i < t; i++ ) {

      cout << score[i].second.second << " " << -score[i].first << " " << score[i].second.first << endl;

    }

  }

}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main(void){
	int t, p, r, tid, pid, time, i, j, k, flag[50][10], pena[50][10], max, max_i, sum, count, num[50], solvep[50], solvet[50], head, tail;
	char message[8], c;
	int tmp1, tmp2, tmp3;
	const char correct[8] = {"CORRECT"},wrong[6] = {"WRONG"};
	while(1){
		scanf("%d%d%d",&t,&p,&r);
		if(t == 0 && p == 0 && r == 0)
			break;
		memset(pena,0,sizeof(pena));
		memset(flag,0,sizeof(flag));
		for(i = 0;i < r;i++){
			scanf("%d%d%d%*c",&tid,&pid,&time);
			j = 0;
			while((c = getchar()) != '\n')
				message[j++] = c;
			message[j] = '\0';
			if(!strncmp(correct,message,7))
				flag[tid - 1][pid - 1] = 1200 * pena[tid - 1][pid - 1] + time;
			else if(!strncmp(wrong,message,5))
				pena[tid - 1][pid - 1]++;
		}
		for(i = 0;i < t;i++) // numの計算
			num[i] = i + 1;
		for(i = 0;i < t;i++){ // solvepの計算
			count = 0;
			for(j = 0;j < p;j++){
				if(flag[i][j])
					count++;
			}
			solvep[i] = count;
		}
		for(i = 0;i < t;i++){
			sum = 0;
			for(j = 0;j < p;j++)
				sum += flag[i][j];
			solvet[i] = sum;
		}
		for(i = 0;i < t - 1;i++){
			max_i = i;
			for(j = i + 1;j < t;j++){
				if(solvep[j] > solvep[max_i])
					max_i = j;
				else if(solvep[j] == solvep[max_i] && solvet[j] < solvet[max_i])
					max_i = j;
			}
			if(max_i != i){
				tmp1 = num[max_i];
				tmp2 = solvep[max_i];
				tmp3 = solvet[max_i];
				num[max_i] = num[i];
				solvep[max_i] = solvep[i];
				solvet[max_i] = solvet[i];
				num[i] = tmp1;
				solvep[i] = tmp2;
				solvet[i] = tmp3;
			}
		}
		for(i = 0;i < t;i++)
			printf("%d %d %d\n",num[i],solvep[i],solvet[i]);
	}
	return 0;
}

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

class Team {
public:
	int id;
	int correct;
	int wrong[10];
	int penalty;

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

	bool operator < (const Team obj) const
	{
		if (correct != obj.correct) {
			return correct > obj.correct;
		}
		if (penalty != obj.penalty) {
			return penalty < obj.penalty;
		}
		return id < obj.id;
	}
};

int main()
{
	while (true) {
		int T, P, R;
		cin >> T >> P >> R;

		if (T == 0 && P == 0 && R == 0) {
			break;
		}

		vector<Team> team(T);

		for (int i = 0; i < T; i++) {
			team[i].id = i + 1;
		}

		for (int i = 0; i < R; i++) {
			int tID, pID, time;
			string message;

			cin >> tID >> pID >> time >> message;

			if (message == "CORRECT") {
				team[tID - 1].correct++;
				team[tID - 1].penalty += 1200 * team[tID - 1].wrong[pID - 1] + time;
				team[tID - 1].wrong[pID - 1] = 0;
			}
			else {
				team[tID - 1].wrong[pID - 1]++;
			}
		}

		sort(team.begin(), team.end());

		for (int i = 0; i < T; i++) {
			cout << team[i].id << " " << team[i].correct << " " << team[i].penalty << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <list>
#include <string>
#define TEAM_MAX 51
#define PROB_MAX 11
#define PENA_TIME 1200

using namespace std;

struct status{
  int teamNum;
  int ac, wa[ PROB_MAX ];
  int pena;
};

int main(){
  while( 1 ){
    struct status ts[ TEAM_MAX ];
    int t, p, r;
    list< struct status > ranking;
    cin >> t >> p >> r;
    if( !( t || p || r ) ){ return 0; } 
    for( int i = 1; i <= t; i++ ){
      ts[ i ].ac = 0;
      for( int j = 1; j <= p; j++ ){
        ts[ i ].wa[ j ] = 0;
      }
      ts[ i ].pena = 0;
      ts[ i ].teamNum = i;
    }
    for( int i = 0; i < r; i++ ){
      int team, problem, time;
      string message;
      cin >> team >> problem >> time >> message;
      if( message[ 0 ] == 'C' ){ // AC
        ts[ team ].ac++;
        ts[ team ].pena += ( ts[ team ].wa[ problem ] * PENA_TIME + time );
      }else{ // WA
        ts[ team ].wa[ problem ]++;
      }
    }
    for( int i = 1; i <= t; i++ ){
      if( i == 1 ){
        ranking.push_back( ts[ 1 ] );
        continue;
      }
      int counter = 0;
      for(
        list< struct status >::iterator it = ranking.begin();
        it != ranking.end(); it++
      ){
        counter++;
        if( ts[ i ].ac > it -> ac  ){
          ranking.insert( it, ts[ i ] );
          break;
        }else if( ts[ i ].ac == it -> ac ){
          if( ts[ i ].pena < it -> pena ){
            ranking.insert( it, ts[ i ] );
            break;
          }else if( ts[ i ].pena == it -> pena ){
            if( ts[ i ].teamNum < it -> teamNum ){
              ranking.insert( it, ts[ i ] );
              break;
            }
          }
        }
        if( counter == ranking.size() ){
          ranking.push_back( ts[ i ] );
          break;
        }
      }
    }
    for(
        list< struct status >::iterator it = ranking.begin();
        it != ranking.end(); it++
      ){
        cout << it -> teamNum << ' ' <<
        it -> ac << ' ' <<
        it -> pena << endl;
      }
  }
}