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 <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

class Team
{
private:
  int m_id;
  int m_solved;
  int m_penalty;
  int m_incorrect[10];
public:
  void setID(int id);
  void incSolved();
  void setPenalty(int penalty);
  void incIncor(int pid);
  int getID();
  int getSolved();
  int getPenalty();
  int getIncor(int pid);
  Team(int id) {
    setID(id);
    m_solved = 0;
    m_penalty = 0;
    for (int i = 0; i < 10; i++) {
      m_incorrect[i] = 0;
    }
  }
};

void Team::setID(int id) {
  m_id = id;
}

void Team::incSolved() {
  m_solved++;
}

void Team::setPenalty(int penalty) {
  m_penalty += penalty;
}

void Team::incIncor(int pid) {
  m_incorrect[pid-1]++;
}

int Team::getID() {
  return m_id;
}

int Team::getSolved() {
  return m_solved;
}

int Team::getPenalty() {
  return m_penalty;
}

int Team::getIncor(int pid) {
  return m_incorrect[pid-1];
}

int main() {
  int T, P, R, tid, pid, time;
  string message;
  while (cin >> T >> P >> R, T | P | R) {
    vector<Team> teams;
    for (int i = 0; i <= T; i++) {
      teams.pb(Team(i));
    }
    while (R--) {
      cin >> tid >> pid >> time >> message;
      if (message == "CORRECT") {
        teams[tid].incSolved();
        teams[tid].setPenalty(teams[tid].getIncor(pid)*1200 + time);
      } else {
        teams[tid].incIncor(pid);
      }
    }
    for (int i = 0; i <= T ; i++) {
      for (int j = i+1; j <= T; j++) {
        if ((teams[i].getSolved() < teams[j].getSolved()) || ((teams[i].getSolved() == teams[j].getSolved()) && (teams[i].getPenalty() > teams[j].getPenalty())) || ((teams[i].getSolved() == teams[j].getSolved()) && (teams[i].getPenalty() == teams[j].getPenalty()) && teams[i].getID() > teams[j].getID())) {
          swap(teams[i], teams[j]);
        }
      }
    }
    for (int i = 0; i <= T; i++) {
      if (teams[i].getID() == 0) continue;
      cout << teams[i].getID() << " " << teams[i].getSolved() << " " << teams[i].getPenalty() << el;
    }
  }
}

C++: 
#include <cstdlib>
#include <iostream>
#include <string>
#include <list>
#include <map>
using namespace std;

class Team
{
	static int mCount;
	int mTeamID;
	int mCorrect;
	map< int, int > mWorng;
	int mPenalty;

public:
	int Correct()const{ return mCorrect; }
	int Penalty()const{ return mPenalty; }
	int TeamID()const{ return mTeamID; }
	bool IsHigherThan(const Team& t)const
	{
		if(mCorrect > t.Correct())
			return true;
		else if(mCorrect==t.Correct() && mPenalty < t.Penalty())
			return true;
		return false;
	}

private:
	Team():mCorrect(0), mPenalty(0),mTeamID(++mCount){}

public:
	Team(const Team& t):mCorrect(t.mCorrect), mPenalty(t.mPenalty), mTeamID(t.mTeamID){}

	static void* operator new[](size_t s){ mCount=0; return malloc(s); }
	static Team* New(size_t s){ return new Team[s]; }
	void Correct(int pID, int time)
	{
		mCorrect++;
		if(mWorng.count(pID) == 0)
		{
			mPenalty += time;
		}
		else
		{
			map<int, int>::iterator i=mWorng.find(pID);
			mPenalty += (*i).second*1200 +time;
			mWorng.erase(i);
		}
	}
	void Worng(int pID)
	{
		if(mWorng.count(pID) == 0)
		{
			pair<int, int> worngData;
			worngData.first  = pID;
			worngData.second = 1;
			mWorng.insert(worngData);
		}
		else
		{
			map<int, int>::iterator i=mWorng.find(pID);
			(*i).second++;
		}
	}
};
int Team::mCount = 0;

int main(void)
{
	istream& in =cin;
	ostream& out=cout;
	const string correct="CORRECT", worng="WORNG";
	int teamN, probN, logN;
	while(1)
	{
		in >> teamN >> probN >> logN;
		if(teamN == 0)break;
		Team* team=Team::New(teamN);
		for(int i=0; i<logN; i++)
		{
			string command;
			int tID, pID, time;
			in >> tID >> pID >> time >> command;
			
			if(command == correct)
				team[tID-1].Correct(pID, time);
			else
				team[tID-1].Worng(pID);
		}

		list<Team> teamRank;
		teamRank.push_back(team[0]);
		for(int i=1; i<teamN; i++)
		{
			list<Team>::iterator it=teamRank.begin();
			while(it != teamRank.end())
			{
				if(team[i].IsHigherThan(*it))
				{
					teamRank.insert(it, (team[i]));
					break;
				}
				it++;
			}
			if(it == teamRank.end())
				teamRank.push_back(team[i]);
		}
		
		list<Team>::iterator it=teamRank.begin();
		while(it != teamRank.end())
		{
			out << (*it).TeamID() << ' ' << (*it).Correct() << ' ' << (*it).Penalty() << endl;
			it++;
		}
		delete[] team;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

class P{
public:
  int tID;
  bool solve[12];
  int penalty;
  int ac;
  int wa[12];

  P(){}

  bool operator<(const P &p)const{
    if(ac == p.ac){
      if(penalty == p.penalty){
        return tID < p.tID;
      }
      return penalty < p.penalty;
    }
    return ac > p.ac;
  }
};

P t[102];

int main(){
  int T, P, R;

  while(cin >> T >> P >> R, T || P || R){
    memset(t, 0, sizeof(t));

    for(int i = 0; i < T; i++){
      t[i].tID = i;
    }

    for(int i = 0; i < R; i++){
      int tID, pID, tm;
      string mes;

      cin >> tID >> pID >> tm >> mes;
      tID--;

      if(t[tID].solve[pID]){
        continue;
      }

      if(mes == "CORRECT"){
        t[tID].solve[pID] = true;
        t[tID].ac++;
        t[tID].penalty += tm + t[tID].wa[pID] * 1200;
      }
      else{
        t[tID].wa[pID]++;
      }
    }

    sort(t, t + T);

    for(int i = 0; i < T; i++){
      cout << t[i].tID + 1 << " " << t[i].ac << " " << t[i].penalty << endl;
    }
  }
}