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

int t, p, r, tID, pID, times;
int point[100], wrong[100][100], penalty[100], ans[100];
string message;

bool AC_comp(const int &a, const int &b){
    if(point[a] == point[b]){
	if(penalty[a] == penalty[b])
	    return  a < b;
	return penalty[a] < penalty[b];
    }
    return point[a] > point[b];
}

int main(){
    while(true){
	cin >> t >> p >> r;
	if(t == 0 && p == 0 && r == 0)return 0;
	memset(point, 0, sizeof(point));
	memset(penalty, 0, sizeof(penalty));
	memset(wrong, 0, sizeof(wrong));
	for(int i = 0;i < r;i++){
	    cin >> tID >> pID >> times >> message;
	    if(message == "CORRECT"){
		point[tID]++;
		penalty[tID] += times + wrong[tID][pID] * 1200;
	    }
	    else{
		wrong[tID][pID]++;
	    }
	}
	for(int i = 0;i < t;i++){
	    ans[i] = i + 1;
	}
	sort(ans, ans + t, AC_comp);
	for(int i = 0;i < t;i++){
	    int team = ans[i];
	    cout << team << ' ' << point[team] << ' ' << penalty[team] << endl;
	}
    }
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

class team {
  public:
    int tid;
    int score;
    int penalty;
    // bool compare(team, team);
};

bool compare (team i, team j) {
  if (i.score > j.score) return i.score > j.score;
  else return i.penalty > j.penalty;
}

int main() {
  int t, p, r;

  while (cin >> t >> p >> r) {// && t && p && r) {
    vector<int> corrects(t);
    fill(corrects.begin(), corrects.end(), 0);
    vector<vector<int>> wrongs(t);
    rep (i, t) wrongs[i] = vector<int>(p);
    rep (i, t) fill(wrongs[i].begin(), wrongs[i].end(), 0);
    vector<int> penalties(t);

    int tid, pid, time_;
    string message;
    // vector<int> tID(r);
    // vector<int> pID(r);
    // vector<int> time(r);
    // vector<string> message(r);

    rep (i, r) {
      cin >> tid >> pid >> time_ >> message;
      tid--; pid--;

      if (message == "CORRECT") {
        corrects[tid]++;
        penalties[tid] += wrongs[tid][pid] * 1200 + time_;
      }
      else if (message == "WRONG") {
        wrongs[tid][pid]++;
      }
    }

    vector<team> teams(t);

    rep (i, t) {
      teams[i].tid = i+1;
      teams[i].score = corrects[i];
      teams[i].penalty = penalties[i];
    }

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

    rep (i, t) {
      cout << teams[i].tid << ' ' << teams[i].score << ' ' << teams[i].penalty << endl;
    }
  }
}

C++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;
class team{
public:    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen = 0;
        sol = 0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};
int main() {
    //freopen("/Users/shitian/Downloads/in.txt", "r", stdin);
    //freopen("/Users/shitian/Downloads/out.txt", "w", stdout);
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
        tea.clear();
    }
    
    return 0;
}

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

int T;
int P;
int R;
char msg[114514];
int penalty[1145];
int correct[1145];
int teams[1145];
int wrong[1145][1419];

bool Compare(int a, int b) {
  if (correct[a] != correct[b]) return correct[a] > correct[b];
  if (penalty[a] != penalty[b]) return penalty[a] < penalty[b];
  return a < b;
}

int main() {
  while (1) {
    scanf("%d%d%d", &T, &P, &R);
    if ((T|P|R) == 0) return 0;

    for (int i=0; i<T; i++) teams[i] = i+1;
    fill(wrong[0], wrong[110], 0); 
    fill(correct, correct+110, 0); 
    fill(penalty, penalty+110, 0); 
  
    for (int i=0; i<R; i++) {
      int tid, pid, time;
      scanf("%d%d%d %s", &tid, &pid, &time, msg);
  
      string s(msg);
      if (s == "WRONG") {
        wrong[tid][pid] += 1;
      } else {
        penalty[tid] += wrong[tid][pid] * 1200 + time;
        correct[tid]++;
      }
    }
  
    sort(teams, teams+T, Compare);
    for (int i=0; i<T; i++) {
      int d = teams[i];
      printf("%d %d %d\n", d, correct[d], penalty[d]);
    }
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if (t + p + r == 0) return 0;
    
    vector<vector<int>> x(t, vector<int>(p));
    vector<vector<int>> ans(t, vector<int>(3)); // -AC数, ペナルティ数, チーム番号
    for (int i = 0; i < t; i++) ans.at(i).at(2) = i + 1;
    for (int i = 0; i < r; i++)  {
      int tid, pid, time;
      string message;
      cin >> tid >> pid >> time >> message;
      tid--;
      pid--;
      if (message == "CORRECT") {
        ans.at(tid).at(0)--;
        ans.at(tid).at(1) += time + x.at(tid).at(pid) * 1200;
      }
      else {
        x.at(tid).at(pid)++;
      }
    }
    
    sort(ans.begin(), ans.end());
    
    for (int i = 0; i < t; i++) {
      cout << ans.at(i).at(2) << " " << -ans.at(i).at(0) << " " << ans.at(i).at(1) << '\n';
    }
  }
}