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

struct info
{
    int Team;
    int solved;
    int penalty;
    int mis[10];
    info(int x, int y, int z)
    {
        Team = x;
        solved = y;
        penalty = z;
        for (int i = 1; i <= 10; i++)
        {
            mis[i - 1] = 0;
        }
    }
};

bool asc(info const &left, info const &right)
{
    if (left.solved != right.solved)
        return left.solved > right.solved;
    else if (left.penalty != right.penalty)
        return left.penalty < right.penalty;
    else
        return left.Team < right.Team;
}

int main()
{
    while (true)
    {
        int t = 0, p = 0, r = 0;
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0)
            break;

        vector<info> InfoList;
        for (int i = 1; i <= t; i++)
        {
            info x = info(i, 0, 0);
            InfoList.push_back(x);
        }
        // cout << "Before" << endl;
        // for (int i = 1; i <= t; i++)
        // {
        //     cout << InfoList[i - 1].Team << " " << InfoList[i - 1].solved << " " << InfoList[i - 1].penalty << endl;
        // }

        for (int i = 0; i < r; i++)
        {
            int tID, pID, t;
            string m;
            cin >> tID >> pID >> t >> m;

            if (m == "CORRECT")
            {
                InfoList[tID - 1].solved++;
                InfoList[tID - 1].penalty += InfoList[tID].mis[pID - 1] * 1200 + t;
            }
            if (m == "WRONG")
            {
                InfoList[tID].mis[pID - 1]++;
            }
        }

        sort(InfoList.begin(), InfoList.end(), asc);

        // cout << "after" << endl;
        for (int i = 1; i <= t; i++)
        {
            cout << InfoList[i - 1].Team  << " " << InfoList[i - 1].solved << " " << InfoList[i - 1].penalty << endl;
        }
    }

    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

int main() {
	for (;;) {
		int T, P, R; cin >> T >> P >> R;
		if (T == 0) break;
		vector<int> a(T), b(T);
		vector< vector<int> > c(T, vector<int>(P));
		while (R--) {
			int t, p, time; cin >> t >> p >> time;
			t--; p--;
			string s; cin >> s;
			if (s == "CORRECT") {
				a[t]++;
				b[t] += time + c[t][p] * 1200;
			}
			else if (s == "WRONG")
				c[t][p]++;
		}
		vector< pair<i_i, int> > v(T);
		for (int t = 0; t < T; t++)
			v[t] = make_pair(i_i(-a[t], b[t]), t);
		sort(v.begin(), v.end());
		for (int t = 0; t < T; t++)
			cout << v[t].second + 1 << ' ' << -v[t].first.first << ' ' << v[t].first.second << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
  
struct P{
  int team;
  int ans;
  int sum;
  int pro[100];
  static bool less(const P& left,const P& right){
    if(left.ans!=right.ans) return left.ans > right.ans;
    else if(left.sum!=right.sum)return  left.sum < right.sum;
    else return left.team < right.team;
  }
};
  
int main(){
  int t,p,r,tid,pid,time;
  string sta;
  while(cin >> t >> p >> r){
    if(t == 0 && r == 0 && p == 0) break;
    vector <P> data;
    P tmp;
    for(int i=0;i<t;i++){
      tmp.team = i+1;
      tmp.ans = 0;
      tmp.sum = 0;
      for(int j=0;j<=p;j++) tmp.pro[j] = 0;
      data.push_back(tmp);
    }
    while(r--){
      cin >> tid >> pid >> time >> sta;
      if(sta == "CORRECT"){
    for(int i=0;i<t;i++){
      if(data[i].team == tid){
        data[i].sum += data[i].pro[pid]*1200+time;
        data[i].ans += 1;
        break;
      }
    }
      }
      else if(sta == "WRONG"){
    for(int i=0;i<t;i++){
      if(data[i].team == tid) data[i].pro[pid] += 1;
    }
      }
    }
    sort(data.begin(),data.end(),P::less);
    for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
  }
}

C++: #include <bits/stdc++.h>
#define reps(i,j,k) for(int i = j; i < k; ++i)
#define rep(i,j) reps(i,0,j)
#define pb push_back
#define fr first
#define fs fr
#define sc second
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> Pii;
typedef pair<int,int> pii;
typedef long long ll;

/*
template<class T> &ostream<<(ostream &out, const vecotr<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}
*/
struct data{
	int team;
	int ac;
	int score;
	data(){}
	data(int team,int ac,int score){
		this->team = team;
		this->ac = ac;
		this->score = score;
	}
	bool operator<(const data &a)const{
		if(ac == a.ac && score == a.score){
			return team < a.team;
		}
		else if(ac == a.ac){
			return score < a.score;
		}
		else{
			return ac > a.ac;
		}
	}
};
int main(){
	int T,P,R;
	while(cin >> T >> P >> R,(T|P|R)){
		vector < data > D(T);
		rep(i,T){
			D[i] = data(i,0,0);
		}
		int wrong[55][10810] = {{}};
		rep(i,R){
			int t_id,p_id,t;
			string msg;
			cin >> t_id >> p_id >> t >> msg;
			--t_id;--p_id;
			if(msg == "WRONG"){
				wrong[t_id][p_id]++;	
			}
			else{
				D[t_id] = data(t_id,D[t_id].ac+1,D[t_id].score+wrong[t_id][p_id]*1200+t);
			}
		}
		sort(D.begin(),D.end());
		rep(i,T){
			cout << D[i].team+1 << " " << D[i].ac << " " << D[i].score << endl;
 		}

	}
	return 0;
}