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, ct, wa[10], pen;
    bool ac[10];
    team(int i=0) : id(i), ct(0), pen(0)
    {
        fill(ac, ac+10, false);
        fill(wa, wa+10, 0);
    }

    void accept(int pid, int time)
    {
        if(!ac[pid-1])
        {
            ac[pid-1] = true;
            ct++;
            pen += time + 1200 * wa[pid-1];
        }
    }
    void wrong(int pid)
    {
        wa[pid-1]++;
    }
};

bool operator<(const team& a, const team& b)
{
    if(a.ct==b.ct)
    {
        if(a.pen==b.pen)
        {
            return a.id<b.id;
        }
        return a.pen<b.pen;
    }
    return a.ct>b.ct;
}

int main()
{
    int t, p, r;
    while(cin >> t >> p >> r, t|p|r)
    {
        team ts[t];
        for(int i=0; i<t; i++)
        {
            ts[i] = team(i+1);
        }
        for(int i=0; i<r; i++)
        {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if(msg=="CORRECT")
            {
                ts[tid-1].accept(pid, time);
            }
            else
            {
                ts[tid-1].wrong(pid);
            }
        }
        sort(ts, ts+t);
        for(team *itr=ts; itr!=ts+t; itr++)
        {
            cout << itr->id << " " << itr->ct << " " << itr->pen << endl;
        }

    }
}

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'){
	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+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 <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int T, P, R;
        cin >> T >> P >> R;
        if (T == 0 && P == 0 && R == 0) {
            return 0;
        }

        struct Problem {
            int time = -1;
            int incorrect = 0;
        };

        vector<vector<Problem>> data(T, vector<Problem>(P));
        for (int i = 0; i < R; ++i) {
            int t, p, m;
            string message;
            cin >> t >> p >> m >> message;

            if (message == "CORRECT") {
                data[t - 1][p - 1].time = m;
            }
            else {
                data[t - 1][p - 1].incorrect += 1;
            }
        }

        struct Team {
            int id = 0;
            int correct = 0;
            int penalty = 0;
        };

        vector<Team> teams(T);
        for (int i = 0; i < T; ++i) {
            teams[i].id = i;
            teams[i].correct = accumulate(begin(data[i]), end(data[i]), 0,
                                          [](int z, const Problem& pp) {
                                              return pp.time >= 0 ? z + 1 : z;
                                          });
            teams[i].penalty = accumulate(
                begin(data[i]), end(data[i]), 0, [](int z, const Problem& pp) {
                    return pp.time >= 0 ? z + pp.time + 1200 * pp.incorrect : z;
                });
        }

        sort(begin(teams), end(teams), [](const Team& a, const Team& b) {
            if (a.correct == b.correct) {
                if (a.penalty == b.penalty) {
                    return a.id < b.id;
                }
                else {
                    return a.penalty < b.penalty;
                }
            }
            else {
                return a.correct > b.correct;
            }
        });

        for (auto& team : teams) {
            cout << (team.id + 1) << ' ' << team.correct << ' ' << team.penalty
                 << endl;
        }
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
int x[100][2], y[99][20], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		cin >> a >> b >> c;
		if (a == 0) { break; }
		for (i = 0; i < c; i++) {
			cin >> d >> e >> f >> S;
			if (S[0] = 'W') {
				y[d][e] ++;
			}
			else {
				x[d][0]++;
				x[d][1] += f + 1200 * y[d][e];
			}
		}
		for (i = 10; i >= 0; i++) {
			for (j = 0; j < 9999999; j++) {
				for (k = 1; k <= a; k++) {
					if (x[k][0] == i && x[k][1] == j) {
						cout << k << ' ' << i << ' ' << j << endl;
					}
				}
			}
		}
	}
}