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 <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 <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

const int PENALTY_TIME = 1200;
struct Team{
	Team(int quesNum) : acceptCnt(0), penalty(0) {
		wrongCnt.resize(quesNum, 0);
	}
	int id;
	int acceptCnt;
	int penalty;
	vector<int> wrongCnt;
	bool operator < (const Team& t) {
		if (acceptCnt != t.acceptCnt) {
			return acceptCnt < t.acceptCnt;
		}
		if (penalty != t.penalty) {
			return penalty > t.penalty;
		}
		return id > t.id;
	}
	bool operator > (const Team& t) {
		if (acceptCnt != t.acceptCnt) {
			return acceptCnt > t.acceptCnt;
		}
		if (penalty != t.penalty) {
			return penalty < t.penalty;
		}
		return id < t.id;
	}
};


int main(void) {
	int teamNum, quesNum, recordNum;
	while (cin >> teamNum >> quesNum >> recordNum, teamNum) {
		vector<Team> teams(teamNum, quesNum);
		for (int i = 0; i < teamNum; i++) {
			teams[i].id = i + 1;
		}

		int tID, qID, time;
		string mes;
		for (int i = 0; i < recordNum; i++) {
			cin >> tID >> qID >> time >> mes;
			tID--; qID--;
			if (mes == "CORRECT") {
				teams[tID].acceptCnt++;
				teams[tID].penalty += teams[tID].wrongCnt[qID] * PENALTY_TIME + time;
			}else {
				teams[tID].wrongCnt[qID]++;
			}
		}

		sort(teams.rbegin(), teams.rend());

		for (int i = 0; i < teams.size(); i++) {
			printf("%d %d %d\n",
				teams[i].id, teams[i].acceptCnt, teams[i].penalty);
		}
	}

	return 0;
}

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[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); --tid; --pid;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	  t[1].second.first++;
	  t[1].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 <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

typedef struct {
	int id;
	int co_count;
	int miss;
	bool co[15];
	int wr[15];
} team1;
team1 team[60];

class comp_miss {
public:
	bool operator()(const team1& left, const team1& right) const{
		return left.miss < right.miss; 
	}
};

class comp_co {
public:
	bool operator()(const team1& left, const team1& right) const{
		return left.co_count > right.co_count;
	}
};

int main(void){
	int i, j;
	int t, p, l;
	
	while(cin >> t >> p >> l, t){
		memset(team, 0, sizeof(team));
		for(i = 1; i <= t; i++) team[i].id = i;
		for(i = 0; i < l; i++){
			int it, ip, imiss;
			string str;
			cin >> it >> ip >> imiss >> str;
			if(str[0] == 'W'){
				if(team[it].co[ip]) break;
				team[it].wr[ip]++;
			}
			else{
				team[it].co_count++;
				team[it].miss += imiss;
				team[it].co[ip] = true;
			}
		}
		
		for(int it = 1; it <= t; it++){
			for(int ip = 1; ip <= p; ip++){
				if(team[it].co[ip]) team[it].miss += team[it].wr[ip] * 1200;
			}
		}
		stable_sort(team + 1, team + t + 1, comp_miss());
		stable_sort(team + 1, team + t + 1, comp_co());

		for(i = 1; i <= t; i++){
			cout << team[i].id << " " << team[i].co_count << " " << team[i].miss << endl;
		}
	}
	return 0;
}