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++: //You Are the Judge
#include<bits/stdc++.h>
using namespace std;

typedef struct TEAM{
  int t, c, p;
  int w[10];
}team;

bool mycomp(const team &a, const team &b){
  if(a.c>b.c)return true;
  if(a.c<b.c)return false;
  if(a.p<b.p)return true;
  if(a.p>b.p)return false;
  return a.t<b.t;
}

int main(){
  int T, P, R;
  while(true){
    cin>>T>>P>>R;
    if(T==0&&P==0&&R==0)break;
    vector<team> p;
    for(int i=0; i<T; i++){
      team tmp;
      tmp.t=i+1; tmp.c=0; tmp.p=0; memset(tmp.w, 0, sizeof(tmp.w));
      p.push_back(tmp);
    }
    for(int i=0; i<R; i++){
      int tid, pid, tim;
      string mes;
      cin>>tid>>pid>>tim>>mes;
      if(mes=="CORRECT"){
        p[tid-1].c++;
        p[tid-1].p+=1200*p[tid-1].w[pid-1]+tim;
      }
      else p[tid-1].w[pid-1]++;
    }
    sort(p.begin(), p.end(), mycomp);
    for(int i=0; i<T; i++)
      printf("%d %d %d\n", p[i].t, p[i].c, p[i].p);
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

bool comp(vector<int>& ids,vector<int>& solves,vector<int>& psums,int i,int j)
{
	if(solves[i]!=solves[j])
		return solves[i]>solves[j];
	if(psums[i]!=psums[j])
		return psums[i]<psums[j];
	if(ids[i]!=ids[j])
		return ids[i]<ids[j];
	return false;
}

void swap(vector<int>& ids,vector<int>& solves,vector<int>& psums,int i,int j)
{
	swap(ids[i],ids[j]);
	swap(solves[i],solves[j]);
	swap(psums[i],psums[j]);
}

int main()
{
	for(int t,p,r;cin>>t>>p>>r,t|p|r;){
		vector<int> teams(r),probs(r),times(r),ress(r);
		for(int i=0;i<r;i++){
			string s;
			cin>>teams[i]>>probs[i]>>times[i]>>s;
			teams[i]--; probs[i]--;
			ress[i]=s=="CORRECT";
		}
		
		vector<vector<int>> wrongs(t,vector<int>(p)),penals(t,vector<int>(p));
		for(int i=0;i<r;i++){
			int te=teams[i],pr=probs[i];
			if(penals[te][pr]>0)
				continue;
			if(ress[i])
				penals[te][pr]=wrongs[te][pr]*1200+times[i];
			else
				wrongs[te][pr]++;
		}
		
		vector<int> ids(t),solves(t),psums(t);
		for(int i=0;i<t;i++){
			ids[i]=i+1;
			solves[i]=count_if(penals[i].begin(),penals[i].end(),[](int x){return x>0;});
			psums[i]=accumulate(penals[i].begin(),penals[i].end(),0);
		}
		
		for(int i=0;i<t;i++)
			for(int j=i;j-->0;)
				if(!comp(ids,solves,psums,j,j+1))
					swap(ids,solves,psums,j,j+1);
		for(int i=0;i<t;i++)
			cout<<ids[i]<<' '<<solves[i]<<' '<<psums[i]<<endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int penalty[50];
int wa[50][10];
bool valid[50][10];
int num_pr[50];

void init(){
    rep(i, 50){
        penalty[i] = 0;
        num_pr[i] = 0;
        rep(j, 10){
            wa[i][j] = 0;
            valid[i][j] = false;
        }
    }
}

int main(void){
    int T, P, R;
    while(true){
        init();
        cin >> T >> P >> R;
        if(T == 0) break;
        rep(i, R){
            int team, pr, tm; string msg;
            cin >> team >> pr >> tm >> msg;
            team--; pr--;
            if(msg == "CORRECT"){
                valid[team][pr] = true;
                num_pr[team]++;
                penalty[team] += tm;
            }
            else{
                wa[team][pr]++;
            }
        }

        //問題数(大がいい), ペナルティ(小がいい), チーム番号(小がいい)
        pair<int, pair<int, int>> res[T];
        rep(i, T){
            res[i].first = -num_pr[i];
            res[i].second.first = penalty[i];
            rep(j, P) res[i].second.first += 1200*wa[i][j]*valid[i][j];
            res[i].second.second = i+1;
        }
        sort(res, res+T);
        for(int i = 0; i < T; i++){
            cout << res[i].second.second << " " << -res[i].first << " " << res[i].second.first << endl;
        }
    }
    return 0;
}

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

int main() {

  int t,p,r;

  while(1) {
  cin >> t >> p >> r;
  if(t ==0 && p == 0 && r ==0) break;
  //cout << t << p << r<<endl;
  
  int tid , pid,time;
  string mes,ans[2];
  ans[0] = "WRONG";
  ans[1] = "CORRECT";
  int tc[51]={0};
  int tw[51]={0};
  int tt[51]={0};
  int pw[51][51];
  int tj[51] = {0};
  for(int i=0;i<51;i++)
    for(int j=0;j<51;j++)
      pw[i][j] = 0;
  for(int i=1;i<=t;i++)
    tj[i] = i;
     
  for(int i=0;i<r;i++) {
    cin >> tid >> pid >> time >> mes;
    // cout << tid <<" " << pid << " " << time << " " << mes << endl; 
    if(mes == ans[0]) {
      pw[tid][pid]++;
    }
    else if(mes == ans[1]){
      tc[tid]++;
      tw[tid]++;
      tt[tid] += time;
      tt[tid] += pw[tid][pid] * 1200;     
    }
  }
  int a = t;
  int t;
  for(int i=1;i<=a;i++) {
    for(int j=i;j<=a;j++) {

      if(tc[i] < tc[j]) {
	t = tc[i];
	tc[i] = tc[j];
	tc[j] = t;

	t = tw[i];
	tw[i] = tw[j];
	tw[j] = t;

	t = tt[i];
	tt[i] = tt[j];
	tt[j] =t;

	t = tj[i];
	tj[i] = tj[j];
	tj[j] =t;
      }
      else if(tc[i] == tc[j]) {
	if(tt[i] > tt[j]) {
	  t = tc[i];
	  tc[i] = tc[j];
	  tc[j] = t;
	
	  t = tw[i];
	  tw[i] = tw[j];
	  tw[j] = t;
	  
	  t = tt[i];
	  tt[i] = tt[j];
	  tt[j] =t;
	  
	  t = tj[i];
	  tj[i] = tj[j];
	  tj[j] = t;
	}
	else if(tt[i] == tt[j]) {
	  if(tw[i] > tw[j]) {
	    t = tw[i];
	    tw[i] = tw[j];
	    tw[j] = t;
	    
	    t = tj[i];
	    tj[i] = tj[j];
	    tj[j] =t;
	  }
	  else if(tw[i] == tw[j] && tj[i] > tj[j]) {
	    t = tj[i];
	    tj[i] = tj[j];
	    tj[j] = t;
	  }
	}
      }
    } 
  }    
  
  for(int i=1;i<=a;i++) 
    cout <<tj[i]<<" " << tc[i] <<" "  << tt[i]<<endl;
  
  }

  return 0;

}

C++: #include<iostream>
#include<string>
#include<algorithm>
#define I (1<<20)
using namespace std;
int x[100], z[100], y[99][20], a, b, c, d, e, f, i, j, k; string S;
int main() {
	while (true) {
		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 = 0; 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]) {
					cout << j << ' ' << x[i] / I << ' ' << x[i] % I << endl;
				}
			}
		}
	}
}