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<sstream>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define each(i, c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef pair<int, int> pi;

int t, p, r, wrong[100][100];
pair<int, pi> team[100];
bool ac[100][100];

int main(){
	while(cin >> t >> p >> r, t){
		rep(i, t) rep(j, p) wrong[i][j] = ac[i][j] = 0;
		memset(team, 0, sizeof(team));
		rep(i, t) team[i].second.second = i + 1;
		
		rep(i, r){
			int tid, pid, time;
			string msg;
			cin >> tid >> pid >> time >> msg;
			tid--; pid--;
			if(msg[0] == 'W') wrong[tid][pid]++;
			else{
				if(ac[tid][pid]) continue;
				ac[tid][pid] = 1;
				team[tid].first--;
				team[tid].second.first += 1200 * wrong[tid][pid] + time;
			}
		}
		sort(team, team + t);
		
		rep(i, t) cout << team[i].second.second << " " << -team[i].first
		<< " " << team[i].second.first << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#include <stdint.h>

typedef uint32_t u32;
typedef uint64_t u64;

class Team {
public:
  Team();
  void AC(int problem_id, int time);
  void WA(int problem_id, int time);
  int Point() const;
  int Num_AC() const;
  void Dump();
  void Setid(int id_);
private:
  int miss[16];
  bool correct[16];
  int point;
  int num_ac;
  int id;
};

Team::Team() {
  for(int i = 0; i < 16; ++i) {
    miss[i] = 0;
    correct[i] = false;
  }
  point = 0;
  num_ac = 0;
}

void Team::AC(int problem_id, int time) {
  correct[problem_id] = true;
  point += miss[problem_id] * 1200 + time;
  num_ac += 1;
}

void Team::WA(int problem_id, int time) {
  correct[problem_id] = false;
  miss[problem_id] += 1;
}

int Team::Point() const {
  return point;
}

int Team::Num_AC() const {
  return num_ac;
}

void Team::Setid(int id_) {
  id = id_;
}

void Team::Dump() {
  std::cout << id << ' ' << Num_AC() << ' ' << point << std::endl;
}

bool operator < (const Team& left, const Team& right) {
  if( left.Num_AC() != right.Num_AC() ) return -left.Num_AC() < -right.Num_AC();
  return left.Point() < right.Point();
}

int main() {

  for(;;) {
    int T, P, R;
    std::cin >> T >> P >> R;
    if( T == 0 and P == 0 and R == 0 ) break;
    int tID, pID, time;
    std::string message;
    Team team[64];
    for(int i = 0; i < 64; ++i) {
      team[i].Setid(i);
    }                                 
    for(int i = 0; i < R; ++i) {
      std::cin >> tID >> pID >> time;
      std::cin >> message;
      if( message == "CORRECT" ) {
        team[tID].AC(pID, time);
      }
      else {
        team[tID].WA(pID, time);
      }
    }
    std::sort(team+1, team+T+1);
    for(int i = 1; i <= T; ++i) {
      team[i].Dump();
    }
  }  
  
  return 0;
}

C++: #include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
const string W= "WRONG";
const string C= "CORRECT";
int main() {
  while(1){
    int T,P,R;
    cin >> T >> P >> R;
    if(T==0&&P==0&&R==0)break;
    vector<vector<int> > teamW(T,vector<int>(P,0));
    vector<pair<int,pair<int,int> > > teamSum(T,pair<int,pair<int,int> >(0,pair<int,int>(0,0)));
    for(int i = 0;i < T;i++){
      teamSum[i].second.second = i+1;
    }
    for(int i = 0;i < R;i++){
      int tID,pID,time;
      string mes;
      cin >> tID >> pID >> time >> mes;
      if(mes == W){
	teamW[tID-1][pID-1]++;
      }
      //      teamSum[T-tID].second.second = T-tID;
      if(mes == C){
	teamSum[tID-1].first++;
	teamSum[tID-1].second.first = teamSum[tID-1].second.first + time + teamW[tID-1][pID-1]*1200;
      }
    }
    for(int i = 0;i < T;i++){
      teamSum[i].second.first  = teamSum[i].second.first*(-1);
      teamSum[i].second.second = teamSum[i].second.second*(-1);
      
    }
    sort(teamSum.begin(),teamSum.end());//,greater<pair<int,int> >());
    for(int i = T-1;i >= 0;i--){
      cout << (-1)*teamSum[i].second.second  << " " << teamSum[i].first << " " << (-1)*teamSum[i].second.first << endl;

    } 
    
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
#define F first
#define S second
using namespace std;

int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&T&&P&&R){
		int tID,pID,time;
		string mes;
		bool flag[51][11]={false};
		pair<int,pair<int,int>> ans[51];//ans,time,tID
		REP(i,1,T+1){
			ans[i].F=0;
			ans[i].S.F=0;
			ans[i].S.S=i;
		}
		int pena[51][11]={0};
		REP(i,0,R){
			cin>>tID>>pID>>time>>mes;
			if(flag[tID][pID]) continue;
			if(mes=="CORRECT"){
				ans[tID].F--;
				flag[tID][pID]=true;
				ans[tID].S.F+=time+pena[tID][pID]*1200;
			}else{
				pena[tID][pID]++;
			}
		}
		sort(ans+1,ans+T+1);
		REP(i,1,T+1){
			cout<<ans[i].S.S<<" "<<-ans[i].F<<" "<<ans[i].S.F<<endl;
		}
	}

	return 0;
}