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 <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem2400 : You Are the Judge **/
struct Team {
	int id, ac, penalty;
	Team(int i, int c, int p):id(i), ac(c), penalty(p){}
	Team(){}
};

bool comp(const Team &a, const Team &b) {
	if (a.ac == b.ac) return a.penalty<b.penalty;
	return a.ac>b.ac;
}

int main()
{
	int T, P, R;
	while (cin>>T>>P>>R, T) {
		vector<Team> result(T);
		vector<vector<int> > wrong(T, vector<int>(P));
		
		for (int i=0; i<T; i++) {
			result[i].id = i+1;
		}
		
		for (int r=0; r<R; r++) {
			int tid, pid, time; string m;
			cin>>tid>>pid>>time>>m; tid--, pid--;
			
			if (m == "CORRECT") {
				result[tid].ac++;
				result[tid].penalty += 1200*wrong[tid][pid] + time;
			} else {
				wrong[tid][pid]++;
			}
		}
		
		sort(result.begin(), result.end(), comp);
		
		for (int i=0; i<T; i++) {
			cout << result[i].id << " " << result[i].ac << " " << result[i].penalty << endl;
		}
	}
}

C++: #include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
const string W= "WRONG";
const string C= "CORRECT";

int main() {
  while(1){
    int T,P,R;
    cin >> T >> P >> R;
    if(T==0&&P==0&&R==0)break;
    
    vector<vector<int> > teamW(T,vector<int>(P,0));
    //vector<vector<int> > teamW(T,vector<int>(P,0));
    vector<pair<int,pair<int,int> > > teamSum(T,pair<int,pair<int,int> >(0,pair<int,int>(0,0)));
    for(int i = 0;i < T;i++){
      teamSum[i].second.second = i+1;
	//		teamSum[T-tID].second.second = T-tID;
    }
    
    for(int i = 0;i < R;i++){
      int tID,pID,time;
      string mes;
      cin >> tID >> pID >> time >> mes;
      if(mes == W){
	teamW[tID-1][pID]++;
      }
      //      teamSum[T-tID].second.second = T-tID;
      if(mes == C){
	teamSum[tID-1].first++;
	teamSum[tID-1].second.first = teamSum[tID-1].second.first + time + teamW[tID-1][pID]*1200;
      }
    }
    for(int i = 0;i < T;i++){
      teamSum[i].second.first  = teamSum[i].second.first*(-1);
      teamSum[i].second.second = teamSum[i].second.second*(-1);
      
    }
    sort(teamSum.begin(),teamSum.end());//,greater<pair<int,int> >());
    for(int i = T-1;i >= 0;i--){
      cout << -1*teamSum[i].second.second  << " " << teamSum[i].first << " " << -1*teamSum[i].second.first << 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) {
    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] * 100000 - 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 <bits/stdc++.h>

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

class team {
  public:
    long long tid;
    long long correct;
    long long penalty;
    void print();
    bool operator < (const team&);
};

void team::print() {
  cout << tid << ' ' << correct << ' ' << penalty << endl;
}

bool team::operator < (const team &right) {
  if (correct != right.correct) return correct < right.correct;
  else if (correct == right.correct) return penalty > right.penalty;
  else return tid < right.tid;
}

int main() {
  long long t, p, r;
  long long tid, pid, time_;
  long long point;
  string message;

  while (cin >> t >> p >> r && t && p && r) {
    vector<team> teams(t);
    vector<long long> corrects(t, 0);
    vector<long long> penalties(t, 0);
    vector<vector<long long>> wrongs(t);
    rep (i, t) wrongs[i].resize(p);

    rep (i, r) {
      cin >> tid >> pid >> time_ >> message;
      tid--; pid--;

      if (message == "CORRECT") {
        corrects[tid]++;
        point = wrongs[tid][pid] * 1200 + time_;
        // cout << "team id: " << tid << endl;
        // cout << "penalty: " << penalties[tid] << endl;
        // cout << "wrongs[tid][pid]: " << wrongs[tid][pid] << endl;
        // cout << "point: " << point << endl;
        penalties[tid] += point;
      }
      else if (message == "WRONG") {
        wrongs[tid][pid]++;
      }
    }

    rep (i, t) {
      teams[i].tid = i+1;
      teams[i].correct = corrects[i];
      teams[i].penalty = penalties[i];
    }

    sort(teams.begin(), teams.end());
    reverse(teams.begin(), teams.end());
    rep (i, t) teams[i].print();
  }
}