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 <cstdio>
#include <cstdlib>
#include <cstring>

#define T 50
#define P 10

#define INT(X) \
  ( *( (const int *)(X) ) )

using namespace std;

static int t;
static int p;
static int r;

static int d[ T ];
static int ac[ T ];
static int wa[ T ][ P ];
static int pen[ T ];

static int
compare (
  const void * a,
  const void * b
  )
{
  int v;

  v = ac[ INT( b ) ] - ac[ INT( a ) ];
  if ( v ) return ( v );

  v = pen[ INT( a ) ] - pen[ INT( b ) ];
  if ( v ) return ( v );

  return ( INT( a ) - INT( b ) );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    scanf ( " %d %d %d", &t, &p, &r );
    if ( !( t | p | r ) ) break ;

    memset ( ac, 0, sizeof ( ac ) );
    memset ( wa, 0, sizeof ( wa ) );
    memset ( pen, 0, sizeof ( pen ) );

    while ( r-- )
    {
      int tid, pid, time;
      char msg[ 16 ];

      scanf ( " %d %d %d %s", &tid, &pid, &time, msg );
      if ( *msg == 'W' )
      {
        wa[ tid - 1 ][ pid - 1 ] += 1;
      }
      else
      {
        ac[ tid - 1 ] += 1;
        pen[ tid - 1 ] += wa[ tid - 1 ][ pid - 1 ] * 1200 + time;
      }
    }
    for ( i = 0; i < t; ++i )
    {
      d[ i ] = i;
    }
    qsort ( d, t, sizeof ( int ), compare );

    for ( i = 0; i < t; ++i )
    {
      printf ( "%d %d %d\n", d[ i ] + 1, ac[ d[ i ] ], pen[ d[ i ] ] );
    }
  }

  return ( 0 );
}

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

ll wrong[50][10];
ll pnum[50];
ll penalty[50];

struct P  {
    ll num;
    ll penalty;
    int id;
    P(ll num, ll p, int id) : num(num),penalty(p),id(id) {}
};

bool operator<(const P &a, const P&b ) {
    return a.num!=b.num?a.num>b.num:a.penalty!=b.penalty?a.penalty<b.penalty:
        a.id<b.id;
}
int main() {
    int T,PP,R;
    while(cin>>T>>PP>>R,T||PP||R) {
        memset(wrong,0,sizeof(wrong));
        memset(pnum,0,sizeof(pnum));
        memset(penalty,0,sizeof(penalty));
        for (int i=0; i<R; ++i) {
            int t, p, time;
            string s;
            cin >> t >> p >> time >> s;
            t--;p--;
            if (s == "WRONG") {
                wrong[t][p]++;
            } else {
                penalty[t] += wrong[t][p]*1200 + time;
                pnum[t]++;
            }
        }
        vector<P> v;
        for (int i=0; i<T; ++i) {
            v.push_back(P(pnum[i], penalty[i], i));
        }
        sort(v.begin(), v.end());
        for (int i=0; i<T; ++i) {
            cout << v[i].id+1 << " " << v[i].num << " " << v[i].penalty << endl;
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;

struct hoge{
  bool operator()(const tpair& a, const tpair& b){
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    else if(a.second.second != b.second.second) return a.second.second < b.second.second;
    else return a.first < b.first;
  }
}; 

int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); --tid; --pid;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	  t[tid>=0?tid:0].second.first++;
	//  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1; 
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    } 
    sort(t.begin(), t.end(), hoge());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define I (1<<21)
using namespace std;
int x[100], z[100], y[99][20], h[100], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		memset(h, 0, sizeof(h));
		cin >> a >> b >> c;
		if (a == 0) { break; }
		for (i = 0; i < c; i++) {
			cin >> d >> e >> f >> S;
			if (S[0] == 'W') {
				y[d][e] ++;
			}
			else {
				x[d] += I;
				x[d] += f + 1200 * y[d][e];
			}
		}
		for (i = 1; i <= a; i++) { z[i] = x[i]; }
		sort(x + 1, x + a + 1);
		for (i = a; i >= 1; i--) {
			for (j = 1; j <= a; j++) {
				if (z[j] == x[i] && h[j]==0) {
					cout << j << ' ' << x[i] / I << ' ' << x[i] % I << endl;
					h[j] = 1;
				}
			}
		}
	}
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <utility>
using namespace std;

typedef struct{
	int num;
	int pr[11]; //waの数，acしたら-1
	int ac;
	long time;
}team;

int main(){
	while(1){
		int T, P, R;
		team a[51];
		
		scanf(" %d %d %d", &T, &P, &R);
		if(T==0) break;
		
		//初期化
		for(int i=1; i<=50; ++i){
			a[i].num=i;	
			for(int j=1; j<=10; ++j) a[i].pr[j]=0;
			a[i].ac=0;
			a[i].time=0;
		}
		
		
		for(int i=0; i<R; ++i){
			int t, p, m;
			string j;
			scanf(" %d %d %d", &t, &p, &m);
			cin >> j;
			if(j=="WRONG"){ //不正解
				a[t].pr[p]++;
			}
			else{ //正解
				if(a[t].pr[p]==-1) continue;
				
				a[t].ac++;
				a[t].time+=m+1200*a[t].pr[p];	
				a[t].pr[p]=-1;
			}
		}	
		
		//sort
		for(int i=1; i<=T; ++i){
			for(int j=i; j<=T; ++j){
				if(a[i].ac < a[j].ac) swap(a[i], a[j]);
				else if(a[i].ac == a[j].ac){
					
					if(a[i].time > a[j].time) swap(a[i], a[j]);
					else if(a[i].time == a[j].time){
						
						if(a[i].num > a[j].num) swap(a[i], a[j]);
					}					
				}
				
			}
		}
			
		for(int i=1; i<=T; ++i) printf("%d %d %ld\n", a[i].num, a[i].ac, a[i].time);
		
	}
	return 0;
}