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 <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
#include <map>
#include <stack>
using namespace std;
 
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,-1,1,-1,1};
 
 
int main() {
int t,p,r;
while(cin>>t>>p>>r && t){
int pe[55][15]={0};
int wr[55][15]={0};
int a,b,c;
string s;
for(int q=0;q<r;q++){
cin>>a>>b>>c>>s;
if(s=="CORRECT"){
pe[a][b]=c+wr[a][b]*1200;
//cout<<pe[a][b]<<endl;
}
else{
wr[a][b]++;
}
}
vector<pair<pair<int,int>,int> > ve;

for(int i=1;i<t+1;i++){
int seikai=0,pena=0;
for(int j=1;j<p+1;j++){
if(pe[i][j]>0){
//cout<<i<<" "<<j<<endl;
seikai++;
pena=pena+pe[i][j];
}
}
//cout<<seikai<<" "<<pena<<endl;
ve.push_back(make_pair(make_pair(-seikai,pena),i));
}
sort(ve.begin(),ve.end());
for(int i=0;i<t;i++){
cout<<ve[i].second<<" "<<-ve[i].first.first<<" "<<ve[i].first.second<<endl;

}




}

	return 0;
 
   }

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

struct Team {

  int teamID;
  int n_accepted;
  int penalty;

  bool operator <(const Team &t) const {
    if(n_accepted != t.n_accepted)
      return n_accepted > t.n_accepted;
    if(penalty != t.penalty)
      return penalty < t.penalty;
    return teamID < t.teamID;
  }

};

int main() {
  int T, P, R;
  while(cin >> T >> P >> R && (T|P|R)) {
    vector<Team> v(T);
    vector< vector<int> > n_wrong( T, vector<int>(P, 0) );
    for(int i = 0; i < T; ++i) {
      v[i].teamID = i;
      v[i].n_accepted = 0;
      v[i].penalty = 0;
    }

    while(R--) {
      int tID, pID, time;
      string message;
      cin >> tID >> pID >> time >> message;
      --tID; --pID;
      if(message[0] == 'C') {
        v[tID].n_accepted += 1;
        v[tID].penalty += n_wrong[tID][pID] * 1200 + time;
      } else {
        n_wrong[tID][pID] += 1;
      }
    }

    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); ++i) {
      cout << v[i].teamID+1 << " "
           << v[i].n_accepted << " "
           << v[i].penalty << endl;
    }

  }
  return 0;
}

C++: #include<iostream>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;
int T,P,R;
class team{
public:
  int probnum,prob[11],pn,num;
  team(int a){
    num=a;probnum=0;pn=0;
    for(int i=0;i<11;i++){
      prob[i]=0;
    }
  }
  void calc(int pid,int time,string M){
    if(M[0]=='C'){
      probnum++;
      pn+=prob[pid]*1200+time;
    }else{
      prob[pid]++;
    }
  }
};
vector<team> vec;
bool inc(const team& a,const team& b){
  if(a.probnum!=b.probnum)return a.probnum>b.probnum;
  if(a.pn!=b.pn)return a.pn<b.pn;
  else return a.num<b.num;
}
int main(){
  while(1){
    vec.clear();
    cin>>T>>P>>R;
    if(T+R+P==0)break;
    for(int i=0;i<T;i++)vec.push_back(team(i));
    for(int i=0;i<R;i++){
      int tid,pid,time0;
      string mess;
      cin>>tid>>pid>>time0>>mess;
      vec[tid-1].calc(pid-1,time0,mess);
    }
    sort(vec.begin(),vec.end(),inc);
    for(int i=0;i<T;i++){
      cout<<vec[i].num+1<<" "<<vec[i].probnum<<" "<<vec[i].pn<<endl;
    }
  }
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, int> Pll;
int main()
{
  int T, P, R;
  while(cin >> T >> P >> R, T || P || R) {
    int point[T+1], miss[T+1][P+1], pena[T+1];
    CLR(pena), CLR(miss), CLR(point);
    FOR(i,0,R) {
      int in[3]; FOR(j,0,3) cin >> in[j];
      string mes; cin >> mes;
      if(mes[0] == 'C') {
        point[in[0]]++;
        pena[in[0]] += miss[in[0]][in[1]] * 1200 + in[2];
      } else {
        miss[in[0]][in[1]]++;
      }
    }
    vector<Pll> sum_point(T);
    FOR(i,0,T) {
      ll p = point[i+1] * 1000000 - pena[i+1] - (i + 1);
      sum_point[i] = Pll(p, i + 1);
    }
    sort(sum_point.rbegin(), sum_point.rend());
    FOR(i,0,T) {
      int j = sum_point[i].second;
      cout << j << " " << point[j] << " " << pena[j] << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <tuple>

using namespace std;

bool cmp(tuple<int, int, int> a, tuple<int, int, int> b) {
	int a1, a2, a3, b1, b2, b3;
	tie(a1, a2, a3) = a, tie(b1, b2, b3) = b;
	if (a1 != b1) return a1 > b1;
	if (a2 != b2) return a2 < b2;
	return a3 < b3;
}

int main() {
	int T, P, R; 
	while (cin >> T >> P >> R, T) {
		vector<vector<int> > pena(T, vector<int>(P));
		vector<tuple<int, int, int> > score(T);
		for (int i = 0; i < T; ++i) get<2>(score[i]) = i + 1;
		while (R--) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--, pid--;
			if (message[0] == 'W') pena[tid][pid]++;
			else {
				get<0>(score[tid])++;
				get<1>(score[tid]) += pena[tid][pid] * 1200 + time;
			}
		}
		sort(score.begin(), score.end(), cmp);
		for (auto ans : score)
			cout << get<2>(ans) << " " << get<0>(ans) << " " << get<1>(ans) << endl;
	}

	return 0;
}