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 <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main(void){
	int t, p, r, tid, pid, time, i, j, k, flag[50][10], pena[50][10], max, sum, max_i, min_i, count, num[50], solvep[50], solvet[50], head, tail;
	char message[8], c;
	int tmp1, tmp2, tmp3;
	const char correct[8] = {"CORRECT"},wrong[6] = {"WRONG"};
	while(1){
		scanf("%d%d%d",&t,&p,&r);
		if(t == 0 && p == 0 && r == 0)
			break;
		memset(pena,0,sizeof(pena));
		memset(flag,0,sizeof(flag));
		for(i = 0;i < r;i++){
			scanf("%d%d%d%*c",&tid,&pid,&time);
			j = 0;
			while((c = getchar()) != '\n')
				message[j++] = c;
			message[j] = '\0';
			if(!strncmp(correct,message,7))
				flag[tid - 1][pid - 1] = 1200 * pena[tid - 1][pid - 1] + time;
			else if(!strncmp(wrong,message,5))
				pena[tid - 1][pid - 1]++;
		}
		for(i = 0;i < t;i++)
			num[i] = i + 1;
		for(i = 0;i < t;i++){
			count = 0;
			for(j = 0;j < p;j++){
				if(flag[i][j])
					count++;
			}
			solvep[i] = count;
		}
		for(i = 0;i < t;i++){
			sum = 0;
			for(j = 0;j < p;j++)
				sum += flag[i][j];
			solvet[i] = sum;
		}

		for(i = 0;i < t - 1;i++){
			max_i = i;
			for(j = i + 1;j < t;j++){
				if(solvep[max_i] < solvep[j])
					max_i = j;
			}
			if(max_i != i){
				tmp1 = num[max_i];
				tmp2 = solvep[max_i];
				tmp3 = solvet[max_i];
				num[max_i] = num[i];
				solvep[max_i] = solvep[i];
				solvet[max_i] = solvet[i];
				num[i] = tmp1;
				solvep[i] = tmp2;
				solvet[i] = tmp3;
			}
		}
		for(i = 10;i >= 0;i--){
			for(j = 0;j < t;j++){
				if(solvep[j] == i){
					k = j + 1;
					while(solvep[k] == i)
						k++;
					break;
				}
			}
			if(j == t)
				continue;
			head = j;
			tail = k - 1;
			for(j = head;j <= tail - 1;j++){
				min_i = j;
				for(k = j + 1;k <= tail;k++){
					if(solvet[min_i] > solvet[k])
						min_i = k;
				}
				if(min_i != j){
					tmp1 = num[min_i];
					tmp2 = solvep[min_i];
					tmp3 = solvet[min_i];
					num[min_i] = num[j];
					solvep[min_i] = solvep[j];
					solvet[min_i] = solvet[j];
					num[j] = tmp1;
					solvep[j] = tmp2;
					solvet[j] = tmp3;
				}
			}
		}
		for(i = 0;i < t - 1;i++){
			for(j = i + 1;j < t;j++){
				if(solvep[i] == solvep[j] && solvet[i] == solvet[j])
					continue;
				break;
			}
			sort(num + i, num + j);
		}
		for(i = 0;i < t;i++)
			printf("%d %d %d\n",num[i],solvep[i],solvet[i]);
	}
	return 0;
}

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

struct team{
  int ans,id,p[10],pena;
  bool operator<(const team &a)const{
    if(this->ans != a.ans){
      return this->ans > a.ans;
    }else if(this->pena != a.pena){
      return this->pena < a.pena;
    }else{
      return this->id < a.id;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(t==0)break;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;

    int tid,pid,tm;
    string mes;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
      }else{
	T[tid].p[pid]++;
      }
    }
    sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

typedef struct record_{
	public:
	int c;
	int p;
	int id;
	record_(int a1,int a2,int a3){
		c=a1;p=a2;id=a3;
	}
}record;

bool cmp(record a,record b){
	if(a.c > b.c)return true;
	if(a.c==b.c && a.p < b.p)return true;
	if(a.c==b.c && a.p==b.p &&  a.id < b.id)return true;
	return false;
}

int score[50][10];
vector<record> data;
int main(){
	//record d = record(1,2,3);
	while(true){
		data.clear();
		int t,p,r;
		memset(score,0,sizeof score);
		cin >> t >> p >> r;
		if(t==0&&p==0&&r==0)return 0;
		for(int i=0;i<t;i++)data.push_back(record(0,0,i));

		for(int i=0;i<r;i++){
			int tid,pid,time;
			string str;
			cin >> tid >> pid >> time >> str;
			tid--;
			pid--;
			if(str=="WRONG"){
				score[tid][pid]++;
			}else{
				data[tid].c++;
				data[tid].p+=time;
				data[tid].p+=score[tid][pid]*1200;
			}
		}
		sort(data.begin(),data.end(),cmp);
		for(int i=0;i<data.size();i++){
			cout << data[i].id+1 <<" "<< data[i].c<<" " << data[i].p << endl;
		}
	}
}

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

struct P{
    int team;
    int ans;
    int sum;
    int pro[100];
    static bool less(const P& left,const P& right){
        return left.team < right.team;
    }
    static bool point(const P& pleft,const P& pright){
        return pleft.sum < pright.sum;
    }
    static bool more(const P& mleft,const P& mright){
        return mleft.ans > mright.ans;
    }
};

int main(){
    int t,p,r,tid,pid,tim;
    string sta;
    while(cin >> t >> p >> r){
        if(t == 0 && r == 0 && p == 0) break;
        vector <P> data;
        P tmp;
        for(int i=0;i<t;i++){
            tmp.team = i+1;
            tmp.ans = 0;
            tmp.sum = 0;
            for(int j=0;j<=p;j++) tmp.pro[j] = 0;
            data.push_back(tmp);
        }
        while(r--){
            cin >> tid >> pid >> tim >> sta;
            if(sta == "CORRECT"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].sum += data[i].pro[pid]*1200+tim;
                        data[i].ans += 1;
                        break;
                    }
                }
            }
            else if(sta == "WRONG"){
                for(int i=0;i<t;i++){
                    if(data[i].team == tid){
                        data[i].pro[pid] += 1;
                        break;
                    }
                }
            }
        }
        sort(data.begin(),data.end(),P::less);
        sort(data.begin(),data.end(),P::point);
        sort(data.begin(),data.end(),P::more);
        for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
    }
}