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

class TEAM{
  public:
    int solved;
    int wrong;
    int pen;
    int id;
    vector<bool> problem;
    TEAM(int n){
      solved = 0;
      wrong = 0;
      pen = 0;
      problem = vector<bool>(n, false);
    }
    bool operator<(const TEAM &a)const{
      if(solved == a.solved){
        return pen < a.pen;
      }else{
        return solved > a.solved;
      }
    }
    bool operator==(const TEAM &a)const{
      return solved == a.solved && pen == a.pen;
    }
};

int main(void){
  int T, P, R;
  while(cin >> T >> P >> R, T | P | R){
    vector<TEAM> team(T, TEAM(P));
    for(int i=0; i < T; i++){
      team[i].id = i+1;
    }
    while(R--){
      int tID, pID, time; string message;
      cin >> tID >> pID >> time >> message;
      tID--; pID--;
      if(team[tID].problem[pID] == true) continue;
      if(message == "CORRECT"){
        team[tID].problem[pID] = true;
        team[tID].solved++;
        team[tID].pen += team[tID].wrong * 1200 + time;
      }else{
        team[tID].wrong++;
      }
    }
    stable_sort(team.begin(), team.end());
    for(int i=0;  i< T; i++){
      cout << team[i].id << " " << team[i].solved << " " << team[i].pen << endl;
    }
  }
  return 0;
}

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

using namespace std;

struct team{
	int tID;
	int pID;		//問題ID
	vector<int> p;	//誤答数
	int ansnum;		//正答数
	int penalty;	//ペナルティ
	int time;		//時間

	bool operator<( const team& right ) const {
        return ( ansnum == right.ansnum ? 
			( penalty == right.penalty ? tID > right.tID : penalty > right.penalty )  : ansnum < right.ansnum );
    }
};

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int T, P, R;
		cin >> T >> P >> R;
		if( T == 0 && P == 0 && R == 0 ) break; 

		//■■■■チームテーブル作成■■■■
		vector<team> teams;
		team newteam;
		for(int i = 0; i <= P; i++)
			newteam.p.push_back(0);

		for(int i = 0; i < T; i++) {
			newteam.tID = i + 1;
			newteam.ansnum = 0;
			newteam.penalty = 0;
			teams.push_back( newteam );
		}

		//■■■■レコード取得■■■■
		for(int i = 0; i < R; i++) {
			int tID, pID, time_i;
			char s[7];
			cin >> tID >> pID >> time_i;
			cin >> s;

			switch( s[0] ) {
				case 'C':
					teams.at(tID - 1).ansnum ++;
					teams.at(tID - 1).penalty += teams.at(tID-1).p.at(pID)*1200 + time_i;
					break;
				case 'W':
					teams.at(tID - 1).p.at(pID) ++;
					break;
			}

		}

		sort( teams.begin(), teams.end() );

		for(int i = teams.size() - 1; i >= 0 ; i--) {
			cout << teams.at(i).tID << " " << teams.at(i).ansnum << " " << teams.at(i).penalty << endl;
		}

	}

	//while(1){}

	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<n;i++)
#define ll long long
#define ALL(x) x.begin(),x.end()
using namespace std;


int main(){
    int t,p,r;
    while(true){
        cin >> t >> p >> r;
        if(t == 0 && p == 0 && r == 0) break;
        vector<map<int,int>> mp(t);
        map<int,int> mp2;
        rep(i,r){
            int id, pid, ti;
            string  mes;
            cin >> id >> pid >> ti >> mes;
            id--; pid--;
            if(mes == "CORRECT"){
                if( mp[id][pid] < 0) mp[id][pid] =    abs(mp[id][pid]) *1200 + ti;
                else mp[id][pid] = ti;
                mp2[id]++;
            }else{
                mp[id][pid]--;
            }
        }
        vector<tuple<int,int,int> > ans(t);
        rep(i,t){
            get<2>(ans[i]) = -i;
            for(auto x :mp[i]){
                if(x.second >= 0 ) get<1>(ans[i]) += x.second;
            }
            get<0>(ans[i]) = mp2[i];
            get<1>(ans[i]) = -get<1>(ans[i]);

        }
        sort(ALL(ans));
        reverse(ALL(ans));
        rep(i,t){
            cout << -get<2>(ans[i]) + 1 << " " << get<0>(ans[i]) << " " << -get<1>(ans[i]) << endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define pb         push_back

const int INF = 1000000000;
const int MOD = 1000000007;

typedef struct _team{
	int tid;
	int solve;
	int wr[100] = {};
	int pen;
}Team;

bool CmpSolve(const Team& a, const Team& b){
	return (a.solve == b.solve) ? a.pen < b.pen : a.solve > b.solve ;
}

bool CmpPen(const Team& a, const Team& b){
	if(a.pen <= b.pen) return true;
	else return false;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);

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

		vector<Team> teams;

		for(int i=1; i<=t; i++){
			Team tmp;
			tmp.tid = i;
			tmp.solve = 0;
			tmp.pen = 0;
			teams.push_back(tmp);
		}

		for(int i=0; i<r; i++){
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;

			if(mes == "WRONG"){
				teams[tid].wr[pid]++;
			}else if(mes == "CORRECT"){
				teams[tid].solve++;
				teams[tid].pen += teams[tid].wr[pid]*1200 + time;
			}
		}

		sort(teams.begin(), teams.end(), CmpSolve);
		/*
		for(int i=0; i<t; i++){
			printf("%d %d %d\n", teams[i].tid, teams[i].solve, teams[i].pen);
		}
		*/
		//stable_sort(teams.begin(), teams.end(), &CmpSolve);
		for(int i=0; i<t; i++){
			printf("%d %d %d\n", teams[i].tid, teams[i].solve, teams[i].pen);
		}

	}
	

	return 0;
}