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

int main(){
    while(true){
        int t, p, r;
        int tid, pid, ptime;
        string message;
        int team[50][2];
        int problem[50][10];
        set<pair<int, pair<int, int> > > score;
        set<pair<int, pair<int, int> > >::iterator it;
        cin >> t >> p >> r;
        if(!(t||p||r)) break;
        for(int i=0;i<t;++i){
            team[i][0]=0;
            team[i][1]=0;
        }
        for(int i=0;i<p;++i){
            for(int j=0;j<t;++j){
                problem[j][i] = 0;
            }
        }
        for(int i=0;i<r;++i){
            cin >> tid >> pid >> ptime >> message;
            if(message=="CORRECT"){
                ++team[tid-1][1];
                team[tid-1][0] += problem[tid-1][pid-1]*1200 + ptime;
            }else{
                ++problem[tid-1][pid-1];
            }
        }
        for(int i=0;i<t;++i){
            score.insert(make_pair(10-team[i][1], make_pair(team[i][0], i)));
        }
        it = score.begin();
        while(it!=score.end()){
            cout << (*it).second.second + 1 << ' ';
            cout << -(*it).first+10 << ' ';
            cout << (*it).second.first << endl;
            ++it;
        }
    }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<list>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {1, 1, 0, -1, -1, 0};
int dx[] = {1, 0, -1, -1, 0, 1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

bool comp(pair<pii, int> lhs, pair<pii, int> rhs) {
    if (lhs.first.first != rhs.first.first)
        return lhs.first.first > rhs.first.first;
    else if (lhs.first.second != rhs.first.second)
        return lhs.first.second < rhs.first.second;
    else return lhs.second < rhs.second;
    return lhs.first.first > rhs.first.first;
}
int solve() {
    int n, p, r;
    cin >> n >> p >> r;
    if (n == 0 && p == 0 && r == 0) return -1;
    int co[n], wr[p][n], pen[p][n];
    rep(i, n) co[i] = 0;
    rep(i, p) rep(j, n) wr[i][j] = pen[i][j] = 0;
    rep(i, r) {
        int tid, pid, time; string mes;
        //problem id
        cin >> tid >> pid >> time >> mes;
        tid--; pid--;
        if (mes == "WRONG") {
            wr[pid][tid]++;
        } else {
            co[tid]++;
            pen[pid][tid] = wr[pid][tid] * 1200 + time;
        }
    }
    int tmp[n];
    rep(i, n) tmp[i] = 0;
    rep(i, n) rep(j, p) tmp[i] += pen[j][i];
    //rep(i, n) cout << co[i] << " "; cout << endl;
    /*
    rep(i, p) {
        rep(j, n) cout << pen[i][j] << " "; cout << endl;
    }
     */
    
    vector<pair<pii, int> > v(n);
    rep(i, n) {
        v[i].first.first = co[i];
        v[i].first.second = tmp[i];
        v[i].second = i;
        
    }
    sort(v.begin(), v.end(), comp);
    rep(i, n) {
        cout << v[i].second + 1 << " " << v[i].first.first << " " << v[i].first.second << endl;
    }
    return 0;
}
int main() {
    while (solve() == 0) {
        
    }
}

C++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
//    ~team(){
//        solved.clear();
//    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
       // tea.clear();
    }
    
    return 0;
}

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

using namespace std;

int t, r, p;
bool a[51][11];
int sv[51][11];

class St
{
public:
  int tm, sc, pn;

  St() {}
  St(int _tm, int _sc, int _pn): tm(_tm), sc(_sc), pn(_pn) {}

  void print(){
    cout << tm << " " << sc << " " << pn << endl;
  }

  void calc(int _pn){
    ++sc;
    pn += _pn;
  }
};

bool comp(const St& st1, const St& st2)
{
  if(st1.sc == st2.sc) return st1.pn < st2.pn;
  return st1.sc > st2.sc;
}

int main()
{
  string str;
  int td, pd, tm;
  vector<St> vec;

  while(cin>>t>>p>>r && t+r+p){
    for(int i = 1; i <= t; ++i)
      vec.push_back(St(i, 0, 0));

    fill(&a[0][0], &a[51][0], false);
    fill(&sv[0][0], &sv[51][0], 0);

    while(r--){
      cin >> td >> pd >> tm >> str;

      if(a[td][pd]) continue;
      if(str == "WRONG"){
	++sv[td][pd];
      } else {
	a[td][pd] = true;
	vec[td-1].calc(tm+sv[td][pd]*1200);

      }
    }
    sort(vec.begin(), vec.end(), comp);

    for(int i = 0; i < vec.size(); ++i)
      vec[i].print();

    vec.clear();
  }

  return 0;
}