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 <deque>
#include <map>
#include <queue>

using namespace std;

typedef int teamID;

struct TeamResult
{
    int id;
    int correctCount;
    int penalty;
};

struct ICPCResult
{
    map<teamID, TeamResult> tResult;
};

struct ProblemStatus
{
    bool clear;
    int wrongCount;
};

struct TeamStatus
{
    typedef int problemID;
    map<problemID, ProblemStatus> pStatuses;
};

struct MyComp : public binary_function<TeamResult, TeamResult, bool>
{
    bool operator()(const TeamResult& x, const TeamResult& y) const
    {
        if (x.correctCount > y.correctCount) return false;
        if (x.correctCount == y.correctCount)
        {
            if (x.penalty < y.penalty) return false;
            if (x.penalty == y.penalty) return x.id > y.id;
        }
        return true;
    }
};

int main()
{
    deque<ICPCResult> results;
    string result;
    int T, P, R;
    while (cin >> T >> P >> R)
    {
        if (T == 0 && T == 0 && R == 0) break;
        results.push_back(ICPCResult());
        ICPCResult& curICPCResult = results.back();
        map<teamID, TeamStatus> tStatuses;
        for (int log = 0; log < R; ++log)
        {
            int tID, pID, time;
            string msg;
            cin >> tID >> pID >> time >> msg;
            ProblemStatus& thisProblemStatus = tStatuses[tID].pStatuses[pID];
            if (msg == "CORRECT")
            {
                TeamResult& thisTeamResult = curICPCResult.tResult[tID];
                thisTeamResult.id = tID;
                ++thisTeamResult.correctCount;
                thisTeamResult.penalty += thisProblemStatus.wrongCount*1200 + time;
            }
            else ++thisProblemStatus.wrongCount;
        }
        
        priority_queue<TeamResult, vector<TeamResult>, MyComp> sorted;
        for (int tID = 1; tID <= T; ++tID)
        {
            TeamResult& tResult = curICPCResult.tResult[tID];
            tResult.id = tID;
            sorted.push(tResult);
        }
        
        while (sorted.size() != 0)
        {
            const TeamResult& team = sorted.top();
            char buf[256];
            sprintf(buf, "%d %d %d\n", team.id, team.correctCount, team.penalty);
            result += buf;
            sorted.pop();
        }
    }
    cout << result << endl;
}

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

typedef struct {
  int tnum;
  int num;
  int pen;
  int wro[15];
} rec;

int t, p, r;
string s;

bool asc(const rec l, const rec r) {
  if(l.num > r.num)
    return 1;
  else if(l.num == r.num && l.pen < r.pen)
    return 1; /*if(l.pen < r.pen)
return 1;
else if(l.pen == r.pen && l.tnum < r.tnum)
return 1;*/
  else if(l.num == r.num && l.pen == r.pen && l.tnum < r.tnum)
    return 1;

  else
    return 0;
}

int main() {
  int i, j, ti, pi, time;
  rec dummy;
  dummy.tnum = 0;
  dummy.num = 0;
  dummy.pen = 0;
  for(i = 0; i < 15; ++i) dummy.wro[i] = 0;
  while(1) {
    cin >> t >> p >> r;
    if(t + p + r == 0) break;
    vector<rec> memo;
    for(i = 0; i < t; ++i) {
      memo.push_back(dummy);
      memo[i].tnum = i + 1;
    }
    for(i = 0; i < r; ++i) {
      cin >> ti >> pi >> time >> s;
      if(s == "CORRECT" && memo[ti - 1].wro[pi] != -1) {
        ++memo[ti - 1].num;
        memo[ti - 1].pen += memo[ti - 1].wro[pi] * 1200 + time;
      }
      else
        ++memo[ti - 1].wro[pi];
    }
    /*for(i = 0; i < memo.size(); ++i)
      cout << memo[i].tnum << " " << memo[i].num << " " << memo[i].pen << " "
           << endl;*/

    sort(memo.begin(), memo.end(), asc);
    for(i = 0; i < memo.size(); ++i)
      cout << memo[i].tnum << " " << memo[i].num << " " << memo[i].pen << endl;
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

	while(cin >> T >> P >> R, T) {
		vvi solve(T, vi(P, 0)), time(T, vi(P, 0)), penal(T, vi(P, 0));

		int tid, pid, t;
		string message;
		REP(i, R) {
			cin >> tid >> pid >> t >> message;

			if(message == "CORRECT") {
				solve[tid-1][pid-1]++;
				time[tid-1][pid-1] += (t+penal[tid-1][pid-1]*1200);
			} else {
				penal[tid-1][pid-1]++;
			}
		}

		vi score(T), times(T);
		REP(i, T) {
			REP(j, P) {
				score[i] += solve[i][j];
				times[i] += time[i][j];
			}
		}

		REP(i, T) {
			int maxteam = 0, maxscore = -1;
			REP(j, T) {
				if(maxscore < score[j]) {
					maxscore = score[j];
					maxteam = j;
				} else if(maxscore == score[j]) {
					if(times[maxteam] > times[j]) {
						maxscore = score[j];
						maxteam = j;
					}
				}
			}
			cout << maxteam+1 << " " << score[maxteam] << " " << times[maxteam] << endl;
			score[maxteam] = -2;
			times[maxteam] = -2;
		}
	}

	return 0;
}