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

struct score {
    int id;
    int solve;
    int penalty;

    score(){}
    score(int a, int b, int c): id(a), solve(b), penalty(c) {} ~score(){}

    bool operator< (const score& o) const {
        if(solve != o.solve) return solve > o.solve;
        if(penalty != o.penalty) return penalty < o.penalty;
        return id < o.id;
    }
};

int main() {
    int T; // number of teams
    int P; // number of problems
    int R; // number of records
    while(true) {
        cin >> T >> P >> R;
        if(T == 0) break;
        int solve[50][10];
        int penalty[50][10];

        for(int i = 0; i < T; ++i) {
            fill(solve[i], solve[i] + P, 0);
            fill(penalty[i], penalty[i] + P, 0);
        }

        for(int i = 0; i < R; ++i) {
            int tid, pid, time; string mes;
            cin >> tid >> pid >> time >> mes; 
            --tid; --pid;
            if(mes == "CORRECT") {
                solve[tid][pid] = time;
            } else {
                ++penalty[tid][pid];
            }
        }

        vector<score> scores(T);

        for(int i = 0; i < T; ++i) {
            int slv = 0, pnl = 0;
            for(int j = 0; j < P; ++j) {
                if(solve[i][j] > 0) {
                    ++slv;
                    pnl += 1200 * penalty[i][j] + solve[i][j];
                }
            }
            scores[i] = score(i + 1, slv, pnl);
        }

        sort(begin(scores), end(scores));

        for(score s: scores) {
            cout << s.id << ' ' << s.solve << ' ' << s.penalty << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001

bool calc(){
  int t,p,r;
  int tid,pid,ti;
  char mes[20];
  int wa[SIZE][SIZE]={},ac[SIZE]={},pen[SIZE]={};

  pair<int,pair<int,int> > team[SIZE];
  
  scanf("%d%d%d",&t,&p,&r);
  if(t==0) return false;

  for(int i=0;i<r;i++){
    scanf("%d%d%d%s",&tid,&pid,&ti,mes);

    if(mes[0]=='C'){
      ac[tid]++;
      pen[tid] += wa[tid][pid] * 1200 + ti;
    }else{
      wa[tid][pid]++;
    }
  }

  for(int i=1;i<=t;i++){
    team[i-1] = {-ac[i],{pen[i],i}};
  }

  sort(team,team+t);

  for(int i=0;i<t;i++){
    printf("%d %d %d\n",team[i].second.second,-team[i].first,team[i].second.first);
  }
    
  
  return true;
}
  
int main(){
  
  while(calc());
  
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

struct Info {
	int t;
	int c;
	int p = 0;
	bool operator < (const Info &r) const {
		if (c != r.c) return c > r.c;
		if (p != r.p) return p < r.p;
		return t < r.t;
	};
};

vector<Info> info;
vector<VI> cnt;
int t, p, r;

int main(void) {
	while (1) {
		info.clear();
		cnt.clear();
		cin >> t >> p >> r;
		if (t == 0 && p == 0 && r == 0) break;
		info.resize(t + 1);
		cnt.resize(t + 1, VI(p + 1));
		REP (i, 1, info.size()) {
			info[i].t = i;
		}
		rep (i, r) {
			int tid, pid, time;
			string msg;
			cin >> tid >> pid >> time >> msg;
			if (msg == "WRONG") {
				cnt[tid][pid]++;
			} else {
				info[tid].c++;
				info[tid].p += time + cnt[tid][pid] * 1200;
			}
		}
		sort(ALL(info));
		rep (i, info.size()) {
			if (info[i].t == 0) continue;
			cout << info[i].t << " " << info[i].c << " " << info[i].p  << endl;
		}
	}
    return 0;
}

C++: #include <vector>
#include <utility>
#include <algorithm>
#include <iostream>
using namespace std;
#define PB push_back
#define F first
#define S second
int main(){
    int a[60][20],t,p,r,team,prob,time;
    vector<pair<pair<int,int>,int>>v;
    string s;
    while(true){
        cin>>t>>p>>r;
        v.clear();
        if(t==0&&p==0&&r==0)return 0;
        for(int i=1;i<=t;i++){
            v.PB({{0,0},i});
            for(int j=1;j<=p;j++)a[i][j]=0;
        }
        while(r--){
            cin>>team>>prob>>time>>s;
            if(a[team][prob]==-1)continue;
            if(s[0]=='W')a[team][prob]++;
            else {
                v[team-1].F.F--;
                v[team-1].F.S+=time+a[team][prob]*1200;
                a[team][prob]=-1;
            }
        }
        sort(v.begin(),v.end());
        for(pair<pair<int,int>,int> i:v)printf("%d %d %d\n",i.S,-i.F.F,i.F.S);
    }
}