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

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

struct Info
{
    int solved, time, tid, wrong[11];
    bool operator< (const Info &rhv) const {
        return solved == rhv.solved ?
        (time == rhv.time ? tid < rhv.tid : time < rhv.time) :
        solved > rhv.solved;
    }
};

int main()
{
    int T, P, R, tid, pid, time;
    string msg;
    Info info[55];
    
    while(cin >> T >> P >> R && T)
    {
        memset(info, 0, sizeof(info));
        rep(i, T) info[i].tid = i + 1;
        rep(i, R)
        {
            cin >> tid >> pid >> time >> msg;
            --tid;
            if(msg == "CORRECT") {
                ++info[tid].solved;
                info[tid].time += time + 1200 * info[tid].wrong[pid];
            } else
                ++info[tid].wrong[pid];
        }
        sort(info, info + T);
        rep(i, T) {
            cout << info[i].tid << ' ' << info[i].solved << ' ' << info[i].time << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
#define se second.first
#define th second.second
#define fi first
using namespace std;
int main(){

  for(int t,p,r;cin>>t>>p>>r,t;){
    int wa[50][10]={};
    pair<int,pair<int,int> > sc[50]={};
    for(int i=0;i<t;i++) sc[i].th=i+1;
    for(int i=0;i<r;i++){
      string s;
      int t0,p0,time;
      cin>>t0>>p0>>time>>s;
      if(s[0]=='W') wa[t0-1][p0-1]++;
      else{
        sc[t0-1].fi++;
        sc[t0-1].se+=time+wa[t0-1][p0-1]*1200;
      }
    }
    for(int i=10;i!=-1;i--){
      vector <pair<int,int> > b;
      for(int j=0;j<t;j++) if(i==sc[j].fi) b.push_back(make_pair(sc[j].se,sc[j].th));
      sort(b.begin(),b.end());
      for(int j=0;j<(int)b.size();j++) cout<<b[j].second<<" "<<i<<" "<<b[j].fi<<endl;
    }
  }
  return 0;

}

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

typedef struct TreamInfo
{
    int tID;
    int points;
    int pena;
    int ProbMiss[10];

    TreamInfo(int tid) : tID(tid) {}
} TeamInfo;

bool cmp(const TeamInfo &a, const TeamInfo &b)
{
    return (a.points == b.points)?(a.pena == b.pena? a.tID < b.tID:a.pena < b.pena):(a.points > b.points);
}

int main()
{
    while (true)
    {
        int t, p, r;
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0)
            break;

        vector<TeamInfo> v;

        for (size_t i = 0; i < t; i++)
        {
            v.push_back(TeamInfo(i+1));
        }

        for (size_t i = 0; i < r; i++)
        {
            int tID, pID, tim;
            string mess;
            cin >> tID >> pID >> tim >> mess;

            if (mess == "CORRECT")
            {
                v[tID - 1].points += 1;
                v[tID - 1].pena += ((v[tID - 1].ProbMiss[pID - 1]) * 1200) + tim;
            }
            if (mess == "WRONG")
            {
                v[tID - 1].ProbMiss[pID - 1] += 1;
            }
        }
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << "team " << i <<" point is " <<v[i].points << endl;
        //     cout << "team " << i << " pena is " << v[i].pena << endl;
        // }

        sort(v.begin(), v.end(), cmp);
        for (size_t i = 0; i < t; i++)
        {
            cout << v[i].tID <<" "<< v[i].points <<" "<< v[i].pena << endl;
        }
    }
    return 0;
}

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) {
    ll 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] * 100000000 - pena[i+1] - i;
      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 <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct team{int ac,pen,id;};
bool comp(const team &l, const team &r){
	if(l.ac!=r.ac) return l.ac>r.ac;
	if(l.pen!=r.pen) return l.pen<r.pen;
	return l.id<r.id;
}
int main(){
	while(true){
		int t,p,r;
		scanf("%d%d%d",&t,&p,&r);
		if(t==0) break;
		int wa[50][10]={},pen[50]={},ac[50]={};
		rep(i,r){
			int ti,pi,tim;
			string mm;
			cin >> ti >> pi >> tim >> mm;
			ti--,pi--;
			if(mm[0]=='C'){
				ac[ti]++;
				pen[ti]+=tim+wa[ti][pi]*1200;
			}else{
				wa[ti][pi]++;
			}
		}
		team vc[50];
		rep(i,t) vc[i].ac=ac[i],vc[i].pen=pen[i],vc[i].id=i;
		sort(vc,vc+t,comp);
		rep(i,t) printf("%d %d %d\n",vc[i].id+1,vc[i].ac,vc[i].pen);
	}
	return 0;
}