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"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct team {
	int id;
	int solve;
	int score;
	bool operator< (const team&t) {
		return solve == t.solve?score == t.score ?id>t.id:score>t.score: solve < t.solve;
	}
};

int main() {
	while(1) {
		int T, P, R; cin >> T >> P >> R;
		vector<vector<int>>miss(T, vector<int>(T));
		vector<vector<int>>scores(T, vector<int>(T));
		if (!T)break;
		for (int i = 0; i < R; ++i) {
			int tid, pid, time;string mes; cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT") {
				if (!scores[tid][pid])
					scores[tid][pid] = 1200 * miss[tid][pid] + time;

			}
			else {
				miss[tid][pid]++;
			}
		}
		vector<team>performs(T);

		for (int i = 0; i < T; ++i) {
			performs[i].id = i + 1;
			for (int j = 0; j < P; ++j) {
				if (scores[i][j]) {
					performs[i].solve++;
					performs[i].score += scores[i][j];
				}
			}
		}
		sort(performs.begin(), performs.end());
		reverse(performs.begin(), performs.end());
		for (int i = 0; i < T; ++i) {
			cout << performs[i].id << " " << performs[i].solve << " "<<performs[i].score << endl;
		}
	}

	
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int t, p, r;
    while (cin >> t >> p >> r && t){
        vector<pair<P, int> > a(t);
        REP(i,t) a[i].second = i+1;
        int w[50][10] = {};
        while (r--){
            int x, y, z;
            string s;
            cin >> x >> y >> z >> s;
            x--;
            y--;
            if (s == "WRONG"){
                w[x][y]++;
            }else{
                a[x].first.first--;
                a[x].first.second += z + 1200 * w[x][y];
            }
        }
        sort(a.begin(), a.end());
        REP(i,t){
            printf("%d %d %d\n", a[i].second, -a[i].first.first, a[i].first.second);
        }
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;

struct hoge{
  bool operator()(const tpair& a, const tpair& b){
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    else if(a.second.second != b.second.second) return a.second.second < b.second.second;
    else return a.first < b.first;
  }
};

int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T+1);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[64];
    rep(i, T+1) t[i] = make_pair(i, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message);
      if(message[0] == 'C'){
	  t[tid].second.first++;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
      }else  fail[tid][pid]++;
    }
    sort(t.begin(), t.end(), hoge());
    rep(i, T+1) if(t[i].first)printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

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

struct Tscore {
    int t_id;
    int AC_num;
    int penalty;
    int WA_num[11];

    Tscore(int id) {
        t_id = id;
        AC_num = 0;
        penalty = 0;
        for (int i = 0; i < 11; i++) WA_num[i] = 0;
    }

    bool operator < (const Tscore& right) const {
        if (AC_num == right.AC_num) {
            if (penalty == right.penalty) {
                return t_id < right.t_id; // ???????????????????°??????????
            }
            return penalty < right.penalty; // ??????????????£????°??????????
        }

        return AC_num > right.AC_num; // ??£?§£??°????????????
    }
};

int main(void) {

    int T, P, R;
    while (cin >> T >> P >> R, T||P||R) {
        vector<Tscore> teams;
        for (int i = 0; i < T; i++) {
            teams.emplace_back(i+1);
        }
        int tID, pID, time;
        string message;
        for (int i = 0; i < R; i++) {
            cin >> tID >> pID >> time >> message;
            if (message == "CORRECT") {
                teams[tID-1].AC_num++;
                teams[tID-1].penalty += teams[tID-1].WA_num[pID]*1200 + time;
            } else {
                teams[tID-1].WA_num[pID]++;
            }
        }

        sort(teams.begin(), teams.end());
        for (int i = 0; i < T; i++) {
            cout << teams[i].t_id << " " << teams[i].AC_num << " " << teams[i].penalty << endl;
        }
    }

    return 0;
}