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 <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef pair<int, int> PII;

struct SCORE {
    VI time;
    int total_time;
    int solve;
    SCORE() {
        total_time = 0; 
        solve = 0; 
    }
};

int main(void) {
    int t;
    int p;
    int r;
    while (1) {
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0) {
            break;
        }
        vector<SCORE> rec(t);
        VI pib(t, false);
        for (int i = 0; i < t; i++) {
            rec[i].time = pib;
        }

        for (int i = 0; i < r; i++) {
            int t2;
            int p2;
            int time;
            string mess;
            cin >> t2 >> p2 >> time >> mess;
            t2--;
            p2--;
            if (mess == "CORRECT") {
              rec[t2].solve++;
              rec[t2].time[p2] += time;  
              rec[t2].total_time += rec[t2].time[p2];
            } else if (mess == "WRONG"){
              rec[t2].time[p2] += 1200;  
            }
        }
        priority_queue<pair<int, pair<int, int> > > pq;
        for (int i = 0; i < t; i++) {
           pq.push(make_pair(rec[i].solve, make_pair(-rec[i].total_time, -(i + 1)))); 
        }
        while (!pq.empty()) {
           cout << -pq.top().second.second << " " << pq.top().first << " " << -pq.top().second.first << endl;
            pq.pop();
        }


    }
    return 0;
}

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, max_i, sum, 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の計算
            num[i] = i + 1;
        for(i = 0;i < t;i++){ // solvepの計算
            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[j] > solvep[max_i])
                    max_i = j;
                else if(solvep[j] == solvep[max_i] && solvet[j] < solvet[max_i])
                    max_i = j;
				else if(solvep[j] == solvep[max_i] && solvet[j] == solvet[max_i] && num[j] < num[max_i])
					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 = 0;i < t;i++)
            printf("%d %d %d\n",num[i],solvep[i],solvet[i]);
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct kk{
int id;
int ac;
int wa;
vector<int> p;//核問題に対するペナルティ
vector<bool>acs;
int psum;
};
//
kk ans[105];
int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&(T+P+R)!=0){//Tチーム、P問,R個のログ
	for(int i=0;i<105;i++){
	ans[i].p.resize(180);
	ans[i].acs.resize(190);
	for(int j=0;j<103;j++)ans[i].p[j]=0,ans[i].acs[j]=0;
	ans[i].id=i;
	}

	for(int i=0;i<R;i++){
	int a,b,c;//id,問題id,経過時間
	string d;//メッセージ
	cin>>a>>b>>c>>d;
	if(d=="WRONG"){
	ans[a].p[b]++;
	}
	else if(d=="CORRECT"){
	ans[a].ac++;
	ans[a].acs[b]=true;
	ans[a].p[b]=ans[a].p[b]*1200+c;
	}
	}
	for(int i=1;i<=T;i++){
		int sum=0;
		for(int j=0;j<=P;j++)if(ans[i].acs[j])sum+=ans[i].p[j];
		ans[i].psum=sum;
	}

	//for(int i=1;i<=T;i++)cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	for(int i=1;i<=T;i++){
		for(int j=i+1;j<=T;j++){
			if(ans[i].ac<ans[j].ac)swap(ans[i],ans[j]);//右のほうが強ければswap
			else if(ans[i].ac==ans[j].ac){

				if(ans[i].psum>ans[j].psum)swap(ans[i],ans[j]);
				if(ans[i].psum==ans[j].psum&&ans[i].id>ans[j].id)swap(ans[i],ans[j]);
			}
		}
	}
	for(int i=1;i<=T;i++){
	cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	}
		for(int i=0;i<=104;i++){ans[i].p.clear();ans[i].acs.clear();ans[i].psum=0;ans[i].ac=0;ans[i].wa=0;ans[i].id=0;}
	}
		return 0;
}