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 <algorithm>
#include <vector>

using namespace std;

const int MAX = 51;
typedef pair<int,int> PP;
typedef pair<int,PP> P;
 
int main(){
    int t,p,r,tID,pID,time;
    string judge;
 
    while(cin >> t >> p >> r ,t + p + r){
	int ans[MAX][MAX] = {{0}},pe[MAX][MAX] = {{0}},AC[MAX]={0};
	while(r--){
	    cin >> tID >> pID >> time >> judge;
 
	    if(judge == "CORRECT"){
		ans[tID][pID] += time+pe[tID][pID];
		AC[tID]++;
	    }
	    else{
		pe[tID][pID] += 1200;
	    }
	}
 
	vector<P> v(t);
	for(int i = 0 ; i < t ; i++){
	    for(int j = 0 ; j < p ; j++){
		v[i].second.first += ans[i+1][j+1];
	    }
	    v[i].first = -AC[i+1];
	    v[i].second.second = i+1;
	}
	sort(v.begin(),v.end());
	for(int i = 0 ; i < t ; i++){
	    cout << v[i].second.second << ' ' << -v[i].first 
		 << ' ' << v[i].second.first << endl; 
	}
    }
    return 0;
}

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

using namespace std;

struct Team
{
    int id, cnt, time;
    vector<bool> b;
    vector<int> es;
};


int main()
{
    int T, P, R;
    while(cin >> T >> P >> R, T){
        vector<Team> ts{};
        
        for(int i=0;i<T;++i){
            Team t = {i+1, 0, 0, vector<bool>(P, false), vector<int>(P, 0)};
            ts.emplace_back(move(t));
        }
        
        for(int i=0;i<R;++i){
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            auto& t = ts[tid-1];
            if(msg == "CORRECT"){
                t.b[pid-1] = true;
                t.time += t.es[pid-1]*1200 + time;
                t.cnt += 1;
            }else{
                t.es[pid-1] += 1;
            }
        }
        
        sort(ts.begin(), ts.end(), [&](Team const& t1, Team const& t2){
            if(t1.cnt == t2.cnt){
                if(t1.time == t2.time) return t1.id < t2.id;
                else return t1.time < t2.time;
            }else return t1.cnt > t2.cnt;
        });
        
        for(auto& e: ts){
            cout << e.id << ' ' << e.cnt << ' ' << e.time << endl;
        }
    }
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
	while(1){
		int t,p,r;
		cin>>t>>p>>r;
		if(t==0)return 0;
		V<ll> score(t,0),time(t,0);
		V<V<ll>> wa(t,V<ll>(p,0));
		V<V<bool>> ac(t,V<bool>(p,false));
		for(int i=0;i<r;i++){
			ll a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			string s;
			cin>>s;
			if(s=="CORRECT"){
				if(ac[a][b])continue;
				ac[a][b]=true;
				score[a]++;
				time[a]-=wa[a][b]*1200+c;
			}else{
				wa[a][b]++;
			}
		}
		map<P,V<int>,greater<P>> mp;
		for(int i=0;i<t;i++){
			mp[P(score[i],time[i])].emplace_back(i+1);
		}
		for(auto p: mp){
			for(int v:p.se){
			cout<<v<<" "<<p.fi.fi<<" "<<-p.fi.se<<"\n";
			}
		}
	}
}

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);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[64];
    rep(i, T) t[i] = make_pair(i+1, make_pair(0, 0));
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); --tid; --pid;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	  t[tid].second.first++;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1;
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    }
    sort(t.begin(), t.end(), hoge());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define I 900000
int x[99],z[99],y[99][20],h[99],a,b,c,d,e,f,i,j,k;string S;
int main(){
while(true){
for(i=0;i<99;i++){x[i]=I;h[i]=0;}
memset(y,0,sizeof(y));
cin>>a>>b>>c;
if(!a){break;}
for(i=0;i<c;i++){
cin>>d>>e>>f>>S;
if(S[0]=='W'){
y[d][e]++;
}
else{
x[d]+=I;
x[d]-=f+1200*y[d][e];
}
}
for(i=1;i<=a;i++){z[i]=x[i];}
sort(x+1,x+a+1);
for(i=a;i>=1;i--){
for(j=1;j<=a;j++){
if(z[j]==x[i]&&!h[j]){
printf("%d %d %d\n",j,(x[i]+I-1)/I-1,(99*I-x[i])%I);
h[j]=1;
}
}
}
}
}