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 "bits/stdc++.h"
using namespace std;
struct aa {
	int id;
	int score;
	int num;
	aa() {
		id = 0;
		score = 0;
		num = 0;
	};
};
bool operator<(const aa&l, const aa&r) {
	return l.num == r.num ? l.score == r.score ? l.id<r.id : l.score<r.score : l.num >r.num;
}
int main() {
	while (1) {
		int T, P, R; cin >> T >> P >> R;
		if (!T)break;
		int miss[100][100];
		memset(miss, 0, sizeof(miss));
		int score[100][100];
		memset(score, 0, sizeof(score));
		for (int i = 0; i < R; ++i) {
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			string st; cin >> st;
			if (st == "WRONG") {
				miss[a][b]++;
			}
			else {
				score[a][b] += miss[a][b] * 1200 + c;
			}
		}
		vector<aa>scores(T);
		for (int i = 0; i < T; ++i) {
			scores[i].id = i;
			for (int j = 0; j < P; ++j) {
				scores[i].score += score[i][j];
				if (score[i][j])scores[i].num++;
			}
		}
		sort(scores.begin(), scores.end());
		for (auto s : scores) {
			cout << s.id+1 << " " << s.num << " " << s.score << endl;
		}
	}
	return 0;
}

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

int main(){
  int t,p,r;

  while(cin>>t>>p>>r&&t|p|r){
    vector<pair<int, pair<int, int> > > team(t);
    vector<pair<int, int> > problem;

    // initialize
    for(int i=0;i<t;i++){
      team[i].first=0;
      team[i].second.first=0;
      team[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"){
        problem.push_back(make_pair(pid, tid));
      }else{
        team[tid-1].first++;
        for(int j=0;j<problem.size();j++){
          if(problem[j].first==pid&&problem[j].second==tid){
            team[tid-1].second.first+=1200;
          }
        }
        team[tid-1].second.first+=time;
      }
    }

    sort(team.begin(), team.end(), greater<pair<int, pair<int, int> > >());

    for(int i=0;i<=t-1;i++){
      for(int j=i+1;j<=t-1;j++){
        if(team[i].first==team[j].first&&team[i].second.first>team[j].second.first){
          swap(team[i],team[j]);
          break;
        }
      }
    }

    for(int i=0;i<=t-1;i++){
      for(int j=i+1;j<=t-1;j++){
        if(team[i].first==team[j].first&&team[i].second.first==team[j].second.first&&team[i].second.second>team[j].second.second){
          swap(team[i],team[j]);
          break;
        }
      }
    }

    for(int i=0;i<t;i++){
      cout << team[i].second.second << " " << team[i].first << " " << team[i].second.first << endl;
    }

  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int t,p,r;
  while(cin>>t>>p>>r,t){
    vector<pair<int,pair<int,int> > >piii;
    int pro[t+10][p+10];
    for(int i=0;i<t+10;i++)
      for(int j=0;j<p+10;j++)
	pro[i][j]=0;
    for(int i=0;i<t;i++)
      piii.pb(mp(INF,mp(0,i+1)));
    for(int i=0;i<r;i++){
      int a,b,c;string str;
      cin>>a>>b>>c>>str;
      a--;
      if(str=="CORRECT"){
	piii[a].F--;
	piii[a].S.F+=c+pro[a][b]*1200;
      }else{
	pro[a][b]++;
      }
    }
    sort(piii.begin(),piii.end());
    for(int i=0;i<t;i++)
      cout<<piii[i].S.S<<" "<<INF-piii[i].F<<" "<<piii[i].S.F<<endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define fst first
#define snd second

bool c[64][16];
int w[64][16], num[64], pen[64];

int main() {
    for (;;) {
        int T, P, R;
        scanf("%d%d%d", &T, &P, &R);
        if (T == 0) return 0;
        memset(c, 0, sizeof(c));
        memset(w, 0, sizeof(w));
        memset(num, 0, sizeof(num));
        memset(pen, 0, sizeof(pen));
        rep (_, R) {
            int t, p, ti;
            char msg[16];
            scanf("%d%d%d%s", &t, &p, &ti, msg);
            t--, p--;
            if (msg[0] == 'C') c[t][p] = true, pen[t] += ti;
            else w[t][p]++;
        }
        rep (i, T) rep (j, P) if (c[i][j]) {
            num[i] += 1;
            pen[i] += 1200*w[i][j];
        }
        vector<pair<pair<int, int>, int> > vs;
        rep (i, T) vs.push_back(mp(mp(-num[i], pen[i]), i));
        sort(vs.begin(), vs.end());
        rep (i, T) {
            printf("%d %d %d\n", vs[i].snd+1, -vs[i].fst.fst, vs[i].fst.snd);
        }
    }
}

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

struct st {
	int score, pen, id, wrong[10];
};
int main() {
	int t, p, r;
	while (scanf("%d%d%d", &t, &p, &r), t) {
		st team[50]{};
		rep(i, t)team[i].id = i + 1;
		rep(i, r) {
			int tid, pid, time; string mes;
			scanf("%d%d%d", &tid, &pid, &time);
			tid--; pid--;
			cin >> mes;
			if (mes == "WRONG")team[tid].wrong[pid]++;
			else {
				team[tid].pen += team[tid].wrong[pid] * 1200 + time;
				team[tid].score++;
			}
		}
		sort(team, team + t, [](st a, st b) {
			if (a.score != b.score)return a.score > b.score;
			if (a.pen != b.pen)return a.pen < b.pen;
			return a.id < b.id;
		});
		rep(i, t) {
			printf("%d %d %d\n", team[i].id, team[i].score, team[i].pen);
		}
	}
}