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

struct Tscore {
    int t_id;
    int AC_num;
    int penalty;
    int WA_num[11];

    Tscore(int id) {
        t_id = id;
        AC_num = 0;
        penalty = 0;
        for (int i = 0; i < 11; i++) WA_num[i] = 0;
    }

    bool operator < (const Tscore& right) const {
        if (AC_num == right.AC_num) {
            if (penalty == right.penalty) {
                return t_id < right.t_id; // ???????????????????°??????????
            }
            return penalty < right.penalty; // ??????????????£????°??????????
        }

        return AC_num > right.AC_num; // ??£?§£??°????????????
    }
};

int main(void) {

    int T, P, R;
    while (cin >> T >> P >> R, T||P||R) {
        vector<Tscore> teams;
        for (int i = 0; i < T; i++) {
            teams.push_back(Tscore(i+1));
        }
        int tID, pID, time;
        string message;
        for (int i = 0; i < R; i++) {
            cin >> tID >> pID >> time >> message;
            if (message == "CORRECT") {
                teams[tID-1].AC_num++;
                teams[tID-1].penalty += teams[tID-1].WA_num[pID]*1200 + time;
            } else {
                teams[tID-1].WA_num[pID]++;
            }
        }

        sort(teams.begin(), teams.end());
        for (int i = 0; i < T; i++) {
            cout << teams[i].t_id << " " << teams[i].AC_num << " " << teams[i].penalty << endl;
        }
    }

    return 0;
}

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

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

void judge_sort(pair<pi,int>score[],int t){
  //sort(score,score+t);reverse(score,score+t);
  rep(j,t)rep(i,t-1){
    //cout<<"DEBUG "<<score[i].first.second<<" "<<score[i+1].first.second<<endl;
    if((score[i].first.first < score[i+1].first.first)||
			(score[i].first.first == score[i+1].first.first && score[i].first.second > score[i+1].first.second)||
                        (score[i].first.first == score[i+1].first.first && score[i].first.second == score[i+1].first.second&&score[i].second > score[i+1].second)){
                               swap(score[i].first.first,score[i+1].first.first);
                               swap(score[i].first.second,score[i+1].first.second);
                               swap(score[i].second,score[i+1].second);
    }
  }
}

int main(){
  pair<pi,int>score[55];
  int wa[55][12];
  string s;
  int t,p,r,tID,pID,time;
  
  while(cin>>t>>p>>r){
    if(t==0&&p==0&&r==0)break;

    rep(i,55){
      score[i].second=i+1;
      score[i].first.first=0;
      score[i].first.second=0;
      rep(j,12){
	wa[i][j]=0;
      }
    }
    
    rep(i,r){
      cin>>tID>>pID>>time>>s;
      
      if(s=="CORRECT"&&wa[tID-1][pID]!=-1){
	score[tID-1].first.first+=1;
	score[tID-1].first.second+=(time+wa[tID-1][pID]*1200);
	wa[tID-1][pID]=-1;
      }else if(s=="WRONG"){
	wa[tID-1][pID]++;
      }
      
    }
    judge_sort(score,t);
    
    rep(i,t)cout<<score[i].second<<" "<<score[i].first.first<<" "<<score[i].first.second<<endl;
    //cout<<endl;
  }
  return 0;
}

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


struct team{

	  int  id, c, p;
	  vector<int> w;
	  team(int i, int correct, int pena, int num_pro){
			id = i; c = correct; p = pena; w = vector<int>(num_pro+1,0);
	  }
	  bool operator < (const team& tgt) const {
			if(c != tgt.c) return c < tgt.c;
			if(p != tgt.p) return p < tgt.p;
			return id > tgt.id;
	  }
	  bool operator > (const team& tgt) const {
			if(c != tgt.c) return c > tgt.c;
			if(p != tgt.p) return p > tgt.p;
			return id > tgt.id;
	  }

};

int main(){
	  
	  while(1){
			int t,p,r; cin >> t >> p >> r;
			if(!t) break;

			vector<team> teams;
			teams.push_back( team(10000,-1,1000000,10) );
			for(int i=1; i<=t; i++)
				  teams.push_back( team(i,0,0,p) );
			
			for(int i=0; i<r; i++){
				  int tid,pid,time;
				  string m;
				  cin >> tid >> pid >> time >> m;

				  if(m == "CORRECT"){
						teams[tid].c ++;
						teams[tid].p += teams[tid].w[pid] * 1200 + time;
				  }
				  else{
						teams[tid].w[pid]++;
				  }
			}
			sort(teams.begin(),teams.end());
			reverse(teams.begin(),teams.end());
			for(int i=0; i<t; i++)
				  cout << teams[i].id << " " << teams[i].c << " " << teams[i].p << endl;
				  
	  }
	  
}