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 <bits/stdc++.h>

using namespace std;

struct team{
  int id;
  int correct;
  int penalty;
  int wrong[10];
  bool accept[10];
  bool operator < (const team &right) const {
    if(correct != right.correct) return correct > right.correct;
    if(penalty != right.penalty) return penalty < right.penalty;
    return id < right.id;
  }
};

int main()
{
  int T, P, R;
  while(cin >> T >> P >> R, T || P || R){
    team t[50];
    for(int i = 0; i < T; i++){
      t[i].id = i + 1;
      t[i].correct = 0;
      t[i].penalty = 0;
      memset(t[i].wrong, 0, sizeof(t[i].wrong));
      memset(t[i].accept, false, sizeof(t[i].accept));
    }
    for(int i = 0; i < R; i++){
      int tid, pid, tim;
      string message;
      cin >> tid >> pid >> tim >> message;
      tid--, pid--;
      if(message == "CORRECT"){
	if(!t[tid].accept[pid]){
	  t[tid].correct++;
	  t[tid].accept[pid] = true;
	  t[tid].penalty += t[tid].wrong[pid]*1200 + tim;
	}
      } else if(message == "WRONG"){
	if(!t[tid].accept[pid]){
	  t[tid].wrong[pid]++;
	}
      }
    }
    sort(t, t + T);
    for(int i = 0; i < T; i++){
      cout << t[i].id << " " << t[i].correct << " " << t[i].penalty << endl;
    }
  }
  return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int t, p, r;
	while (cin >> t >> p >> r, t) {
		vvi pena(t, vi(p, 0));
		vector<pair<int, pii>> point(t);//ac time team
		REP(i, t) {
			point[i].second.second = (i + 1);
		}
		REP(i, r) {
			int t2, p2, time;
			string res;
			cin >> t2 >> p2 >> time >> res;
			t2--;
			p2--;
			if (res == "CORRECT") {
				point[t2].first--;
				point[t2].second.first += time + pena[t2][p2]*1200;
			}
			else {
				pena[t2][p2]++;
			}
		}
		SORT(point);
		REP(i,t) {
			cout << point[i].second.second << " " << -point[i].first << " " << point[i].second.first << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

int main(){
	while(true){
		int T, P, R;
		cin >> T >> P >> R;
		if(T == 0 && P == 0 && R == 0){ break; }
		vector<int> accepted(T), penalty(T);
		vector< vector<int> > wrong(T, vector<int>(P));
		while(R--){
			int tid, pid, time;
			string status;
			cin >> tid >> pid >> time >> status;
			--tid; --pid;
			if(status == "CORRECT"){
				++accepted[tid];
				penalty[tid] += time + wrong[tid][pid] * 1200;
			}else{
				++wrong[tid][pid];
			}
		}
		vector<pipii> v(T);
		for(int i = 0; i < T; ++i){
			v[i] = pipii(P - accepted[i], pii(penalty[i], i));
		}
		sort(v.begin(), v.end());
		for(int i = 0; i < T; ++i){
			cout << v[i].second.second + 1 << " ";
			cout << P - v[i].first << " ";
			cout << v[i].second.first << endl;
		}
	}
	return 0;
}