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++: //45
#include<iostream>
#include<algorithm>

using namespace std;

struct S{
  int n,p,i;
  bool operator<(S a)const{
    if(n!=a.n){
      return n>a.n;
    }else if(p!=a.p){
      return p<a.p;
    }else{
      return i<a.i;
    }
  }
};

int main(){
  for(int n,p,r;cin>>n>>p>>r,n|p|r;){
    S t[50]={{}};
    for(int i=0;i<n;i++){
      t[i].i=i+1;
    }
    int nw[51][11]={{}};
    while(r--){
      int ti,pi,tm;
      char mes[10];
      cin>>ti>>pi>>tm>>mes;
      if(mes[0]=='W'){
	nw[ti][pi]++;
      }else{
	t[ti-1].n++;
	t[ti-1].p+=tm+1200*nw[ti][pi];
      }
    }
    sort(t,t+n);
    for(int i=0;i<n;i++){
      cout<<t[i].i<<' '<<t[i].n<<' '<<t[i].p<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define ppii pair<int,pair<int,int>>
#define mk_ppii(a,b,c) make_pair(a,make_pair(b,c))

int main(){
	int t,p,r;
	while(cin >> t >> p >> r,t||p||r){
		vector<pair<int,int>> WAs;
		vector<pair<int,pair<int,int>>> result(t,mk_ppii(p,0,0));
		for(int i=0;i<t;i++) result[i].second.second = i+1;
		for(int i=0;i<r;i++){
			int tid,pid,time;
			string message;
			cin >> tid >> pid >> time >> message;
			if(message == "WRONG"){
				WAs.emplace_back(make_pair(tid,pid));
			}
			if(message == "CORRECT"){
				int c = count(WAs.begin(),WAs.end(),make_pair(tid,pid));
				result[tid-1].first--;
				result[tid-1].second.first += c*1200+time;
			}
		}
		sort(result.begin(),result.end());
		for(int unsigned i = 0;i<result.size();i++){
			cout << result[i].second.second << " " << p-result[i].first << " " << result[i].second.first << endl;
		}
	}
	return 0;
}

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

using namespace std;

struct td {
	int cn;
	int pnp;
	int pn[10];
	td(){
		cn = 0;
		pnp = 0;
		for(int i = 0;i < 10;i++){
			pn[i] = 0;
		}
	}
};

struct ad{
	int atn;
	int acn;
	int apnp;
};

vector<ad> ans;

int main(){
	while(1){
		int t,p,r;
		cin >> t >> p >> r;
		
		if(t + p + r == 0)break;
		
		td tdata[50];
		for(int i = 0;i < r;i++){
			int tid,pid,time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			if(mes == "CORRECT"){
				tdata[tid - 1].cn++;
				tdata[tid - 1].pnp += tdata[tid-1].pn[pid - 1] * 1200 + time;
			}else{
				tdata[tid - 1].pn[pid - 1]++;
			}
		}
		
		int sortidx[50];
		for(int i = 0;i < 50;i++) sortidx[i]=i;
		
		for(int i = 0;i < t;i++){
			int now = sortidx[i];
			for(int j = t-1;j > i;j--){
				int next = sortidx[j];
				if(tdata[now].cn < tdata[next].cn){
					sortidx[i] = next;
					sortidx[j] = now;
					now = next;
				}else if(tdata[now].cn == tdata[next].cn){
					if(tdata[now].pnp > tdata[next].pnp){
						sortidx[i] = next;
						sortidx[j] = now;
						now = next;
					}else if(tdata[now].pnp == tdata[next].pnp){
						if(now > next){
							sortidx[i] = next;
							sortidx[j] = now;
							now = next;
						}
					}
				}
			}
		}
		
		for(int i= 0;i < t;i++){
			ad tans;
			tans.atn = sortidx[i] + 1;
			tans.acn = tdata[sortidx[i]].cn;
			tans.apnp = tdata[sortidx[i]].pnp;
			ans.push_back(tans);
		}
	}
	
	for(int i = 0;i < ans.size();i++)cout << ans[i].atn << " " << ans[i].acn << " " << ans[i].apnp << endl;
	
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back

typedef long long ll;
typedef pair<int,int> P;

//-----------------------------------------------------------------------

pair<P,int> t[50];
int wrong[50][50];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);


    int a,b,c;
    while(cin>>a>>b>>c,a)
    {
        REP(i,a){
            t[i]=make_pair(P(0,0),i);
            REP(j,b) wrong[i][j]=0;
        }
        REP(i,c){
            int tID,pID,time;
            string s;
            cin>>tID>>pID>>time>>s;
            tID--,pID--;
            if(s[0]=='W'){
                wrong[tID][pID]++;
            }else{
                t[tID].first.first--;
                t[tID].first.second+=1200*wrong[tID][pID]+time;
            }
        }
        sort(t,t+a);
        REP(i,a) cout<<t[i].second+1<<" "<<-t[i].first.first<<" "<<t[i].first.second<<endl;
    }

}

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

using namespace std;

int main()
{
	int T, P, R, A, B, C; string M;

	while (true)
	{
		cin >> T >> P >> R;

		if (T == 0 && P == 0 && R == 0) { break; }

		vector<int> S(T, 0);

		vector<vector<int> > W(T, vector<int>(P, 0));

		for (int i = 0; i < R; i++)
		{
			cin >> A >> B >> C >> M;

			if (M == "WRONG")
			{
				W[A - 1][B - 1] += 1;
			}
			else
			{
				S[A - 1] += (1000000 - W[A - 1][B - 1] * 1200 - C);
			}
		}

		vector<int> Q(T); iota(Q.begin(), Q.end(), 1);

		for (int i = 0; i < T; i++)
		{
			for (int j = i + 1; j < T; j++)
			{
				if (S[i] < S[j])
				{
					swap(S[i], S[j]); swap(Q[i], Q[j]);
				}
			}
		}

		for (int i = 0; i < T; i++)
		{
			cout << Q[i] << ' ' << S[i] % 1000000 << ' ' << 1000000 - S[i] % 1000000 << endl;
		}
	}

	return 0;
}