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 <cstdio>
#include <algorithm>

using namespace std;

typedef pair<int,int> pii;
typedef pair<int,pii> pipii;

pipii pt[50];
bool solved[50][10];
int penalty[50][10];

int main() {
  while (true) {
    int T, P, R;
    scanf("%d %d %d", &T, &P, &R);
    if (T == 0 && P == 0 && R == 0) break;
    for (int i=0;i<T;i++) {
      pt[i] = pipii(0, pii(0, i+1));
      for (int j=0;j<P;j++) {
        solved[i][j] = false;
        penalty[i][j] = 0;
      }
    }
    for (int i=0;i<R;i++) {
      int tID, pID, time;
      char msg[8];
      scanf("%d %d %d %s", &tID, &pID, &time, msg);
      tID--, pID--;
      if (solved[tID][pID]) continue;
      if (msg[0] == 'C') {
        solved[tID][pID] = true;
        pt[tID].first--;
        pt[tID].second.first += penalty[tID][pID]*1200+time;
      } else {
        penalty[tID][pID]++;
      }
    }
    sort(pt, pt+T);
    for (int i=0;i<T;i++) {
      printf("%d %d %d\n", pt[i].second.second, -pt[i].first, pt[i].second.first);
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define AC "CORRECT"
#define INF 1e6
using namespace std;
typedef pair<int,int> P;

int main(){
	int t,p,r,tid,qid,time;
	string check;
	while(cin>>t>>p>>r,t||p||r){
		P point[t+1];
		int wc[t+1][p+1];
		int num[t+1];
		rep(i,t+1){
			point[i]=P(0,0);
			rep(j,p+1)wc[i][j]=0;
			num[i]=i;
		}
		point[0]=P(0,INF);
		rep(i,p+1)wc[0][i]=INF;
		rep(i,r){
			cin>>tid>>qid>>time>>check;
			if(check==AC){
				point[tid].first++;
				point[tid].second+=(time+wc[tid][qid]*1200);
			}else wc[tid][qid]++;
		}
		for(int i=t;i>=0;i--){
			loop(j,0,i){
				bool hoge=false;
				if(point[j].first>point[j+1].first){
					hoge=true;
				}else if(point[j].first==point[j+1].first){
					if(point[j].second<point[j+1].second){
						hoge=true;
					}else if(point[j].second==point[j+1].second){
						if(num[j]<num[j+1]){
							hoge=true;
						}
					}
				}
				if(hoge){
					int tmp=num[j];
					num[j]=num[j+1];
					num[j+1]=tmp;
					P alt=point[j];
					point[j]=point[j+1];
					point[j+1]=alt;
				}
			}
		}
		for(int i=t;i>=1;i--)cout<<num[i]<<" "<<point[i].first<<" "<<point[i].second<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int t, p, r, x, y, z; string s;
	while (cin >> t >> p >> r) {
		if (t == 0)break;
		int pena[51] = {}; int score[51] = {}; int wa[51][11];
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 11; j++) {
				wa[i][j] = 0;
			} 
		}
		for (int i = 1; i <= r; i++) {
			cin >> x >> y >> z >> s;
			if (s == "WRONG") {
				wa[x][y]++;
			}
			else {
				score[x]++;
				pena[x] += wa[x][y] * 1200 + z;
			}
		}
		int used[51] = {};
		for (int i = 1; i <= t; i++) {
			int check = 0;
			for (int j = 1; j <=t ; j++) {
				if (used[j] == 0) {
					if (check == 0 || score[j] > score[check] || (score[j] == score[check] && pena[j] < pena[check])) {
						check = j;
					}
				}
			}
			used[check] = 1;
			cout << check << " " <<score[check] << " " <<pena[check] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include<string>
using namespace std;

struct team_data {
    int id;
    int p;
    int solved;
};

int main(){
    int T,R,P;
    while(cin>>T>>P>>R,T){
        int data[51][11]={},data1[51][11]={},ts[51]={};
        for(int i=0;i<R;i++){
            int t,p,time;
            string massage;
            cin>>t>>p>>time>>massage;
            if(massage=="CORRECT"){
                data[t][p]=time;
                data[t][p]+=data1[t][p]*1200;
                data1[t][p]=-1;
                ts[t]++;
            }else{
                data1[t][p]++;
            }
        }
        for(int i=1;i<=T;i++){
            for(int j=1;j<=P;j++){
                data[i][0]+=data[i][j];
            }
        }
        
        vector<team_data> v(T);
        for(int i=0; i<T; ++i) {
            v[i].id = i+1;
            v[i].p=data[i+1][0];
            v[i].solved=ts[i+1];
        }
        
        stable_sort(v.begin(), v.end(), [](team_data const& t1, team_data const& t2) {
            return t1.p < t2.p;
        });
        stable_sort(v.begin(), v.end(), [](team_data const& t1, team_data const& t2) {
            return t1.solved > t2.solved;
        });
        
        for(auto x : v) {
            cout << x.id << " " << x.solved << " " << x.p << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

typedef struct{
  int c,w[10],p,tID;
} score;

void init_score(vector <score> &s, int T, int P){
  rep(i,T){
    s[i].c=1;
    rep(j,P){
      s[i].w[j]=0;
    }
    s[i].p=0;
    s[i].tID=i+1;
  }
}
    
    bool comp(const score &a, const score &b){
  if(a.c==b.c){
    if(a.p==b.p)
      return a.tID < b.tID;
    else
      return a.p < b.p;
  }
  else{
    return a.c > b.c; 
  }
}

int main(){
  for(;;){
    int T,P,R;
    cin >> T >> P >> R;
    if(!(T+P+R)) break;
    vector <score> s(50);

    init_score(s,T,P);

    rep(i,R){
      int tID,pID,time;
      string message;
      cin >> tID >> pID >> time >> message;
      if(message=="WRONG")
	s[tID-1].w[pID-1]++;
      else{
	s[tID-1].c++;
	s[tID-1].p += (s[tID-1].w[pID-1]*1200 + time);
      }
    }
    
    sort(all(s),comp);
    
    rep(i,T){
      cout << s[i].tID << " " << s[i].c-1 << " " << s[i].p << endl;
    } 
  }
}