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++: //
//  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++;
    }
    ~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>

# 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++: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n,m,k;
  while(cin >> n >> m >> k && (n||m||k)) {
    int a,b,t;
    string s;
    int w[n+1][m+1],p[n+1][m+1],c[n+1];
    memset(w,0,sizeof(w));
    memset(p,0,sizeof(p));
    memset(c,0,sizeof(c));
    while(k--) {
      cin >> a >> b >> t >> s;
      if(s[0]=='W') w[a][b]++;
      else {
	p[a][b]+=t;
	c[a]++;
      }
    }
    map<int,vector<P> > x;
    x.clear();
    REP(i,1,n+1) {
      int d=0;
      REP(j,1,m+1) {
	if(p[i][j]) d+=p[i][j]+w[i][j]*1200;
      }
      x[c[i]].pb(P(d,i));
    }
    for(map<int,vector<P> >::reverse_iterator it=x.rbegin(); it!=x.rend(); it++) {
      vector<P> v=it->S;
      sort(all(v));
      rep(i,v.size()) cout << v[i].S << " " << it->F << " " << v[i].F << endl; 
    }
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>

using namespace std;

int T[10000], P[10000], R[10000], tID[10000][500], pID[10000][500], Time[10000][500], msg[10000][500], n = 0;

int main() {
	while (cin >> T[n] >> P[n] >> R[n]) {
		if (T[n] == 0)break;
		for (int j = 0; j < R[n]; j++) {
			string messege;
			cin >> tID[n][j] >> pID[n][j] >> Time[n][j] >> messege;
			if (messege == "CORRECT")msg[n][j] = 1;
			else msg[n][j] = 0;
		}
		n++;
	}
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> AP, temp;
		AP.resize(T[i]);
		int WA[50][10]{ 0 };
		for (int j = 0; j < R[i]; j++) {
			if (msg[i][j] == 0) {
				WA[tID[i][j] - 1][pID[i][j] - 1]++;
			}
			else {
				AP[tID[i][j] - 1].first--;
				AP[tID[i][j] - 1].second += Time[i][j] + WA[tID[i][j] - 1][pID[i][j] - 1] * 1200;
			}
		}
		temp = AP;
		sort(temp.begin(), temp.end());
		int j = 0, k = 0, memo[50]{0};
		while (j < T[i]) {
			if (memo[k] > 0) {
				k++;
				continue;
			}
			if (temp[j] == AP[k]) {
				cout << k + 1 << " " << -temp[j].first << " " << temp[j].second << endl;
				j++;
				memo[k]++;
				k = 0;
			}
			else k++;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define f first 
#define sf second.first 
#define ss second.second 
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P > iP;

int main(){
  int t,p,r;
  while(cin>>t>>p>>r&&t){
    iP a[51];
    int k[11][51]={};
    for(int i=1;i<=t;i++)a[i]=iP(0,P(0,i));
    for(int i=0;i<r;i++){
      int ti,pi,m;
      string s;
      cin>>ti>>pi>>m>>s;
      if(s=="CORRECT")a[ti].f++,a[ti].sf-=m+k[pi][ti]*1200;
      else k[pi][ti]++;
    }
    sort(a+1,a+t+1);
    for(int i=t;i>0;i--)
      cout<<a[i].ss<<" "<<a[i].f<<" "<<-a[i].sf<<endl;    
  }
  return 0;
}