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;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) for(int i=0;i<n;i++)
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vlai=valarray<int>;

struct Team{
    int id,ac,pn;
    vi wa=vi(11);
};

int main(void){
    int t,p,r;
    while(cin>>t>>p>>r,t){
        vector<Team> team(t+1);
        rep(i,t)team[i+1].id=i+1;
        rep(i,r){
            int id,num,tm;
            string stat;
            cin>>id>>num>>tm>>stat;
            if(stat=="CORRECT"){
                team[id].ac++;
                team[id].pn+=team[id].wa[num]*1200+tm;
            }else{
                team[id].wa[num]++;
            }
        }
        sort(all(team), [](Team a,Team b){return a.ac>b.ac || (a.ac==b.ac&&(a.pn<b.pn || (a.pn==b.pn&&a.id<b.id))); });
        rep(i,t+1){
            if(team[i].id) cout<<team[i].id<<" "<<team[i].ac<<" "<<team[i].pn<<endl;
        }
    }
}

C++: #include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <tuple>
#include <utility>

int testcase_ends() {
  size_t T, P, R;
  scanf("%zu %zu %zu", &T, &P, &R);
  if (T == 0 && P == 0 && R == 0) return 1;

  std::vector<std::vector<int>> a(T, std::vector<int>(P, -1));
  for (size_t i = 0; i < R; ++i) {
    size_t t, p;
    int time;
    char m;
    scanf("%zu %zu %d %c%*s", &t, &p, &time, &m);
    --t, --p;
    if (m == 'W') {
      --a[t][p];
      continue;
    }
    ++a[t][p];
    a[t][p] = -1200 * a[t][p] + time;
  }

  std::vector<std::tuple<int, int, size_t>> b;
  for (size_t i = 0; i < T; ++i) {
    int penalty = 0;
    int accepted = 0;
    for (size_t j = 0; j < P; ++j) {
      if (a[i][j] >= 0) {
        penalty += a[i][j];
        ++accepted;
      }
    }
    b.emplace_back(accepted, -penalty, -(i+1));
  }
  std::sort(b.rbegin(), b.rend());

  for (auto const& t: b) {
    int a, b, c;
    std::tie(a, b, c) = t;
    printf("%d %d %d\n", -c, a, -b);
  }
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}

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

struct info
{
    int Team;
    int solved;
    int penalty;
    int mis[10];
    info(int x, int y, int z)
    {
        Team = x;
        solved = y;
        penalty = z;
        for (int i = 1; i <= 10; i++)
        {
            mis[i - 1] = 0;
        }
    }
};

bool asc(info const &left, info const &right)
{
    if (left.solved != right.solved)
        return left.solved > right.solved;
    else if (left.penalty != right.penalty)
        return left.penalty < right.penalty;
    else
        return left.Team < right.Team;
}

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

        vector<info> InfoList;
        for (int i = 1; i <= t; i++)
        {
            info x = info(i, 0, 0);
            InfoList.push_back(x);
        }
        // cout << "Before" << endl;
        // for (int i = 1; i <= t; i++)
        // {
        //     cout << InfoList[i - 1].Team << " " << InfoList[i - 1].solved << " " << InfoList[i - 1].penalty << endl;
        // }

        for (int i = 0; i < r; i++)
        {
            int tID, pID, t;
            string m;
            cin >> tID >> pID >> t >> m;

            if (m == "CORRECT")
            {
                InfoList[tID - 1].solved++;
                InfoList[tID - 1].penalty += InfoList[tID].mis[pID - 1] * 1200 + t;
            }
            if (m == "WRONG")
            {
                InfoList[tID].mis[pID - 1]++;
            }
        }

        sort(InfoList.begin(), InfoList.end(), asc);

        // cout << "after" << endl;
        for (int i = 1; i <= t; i++)
        {
            cout << InfoList[i - 1].Team  << InfoList[i - 1].solved << InfoList[i - 1].penalty << endl;
        }
    }

    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

typedef long long LL;
class Team{
public:
	LL ac,time,id;
	vector<long long> wa;
	
	Team(int n,int _id){
		ac=time=0;
		id=_id;
		wa.resize(n);
	}
	bool operator< (const Team &t) const{
		if(ac>t.ac) return true;
		else if(ac==t.ac && time<t.time) return true;
		else if(ac==t.ac && time==t.time && id<t.id) return true;
		else return false;
	}

};

using namespace std;
int main(void) {
	int t,p,r;
	while ( cin >> t && t != 0 ) {
		cin>>p>>r;
		
		vector<Team> team;
		for(int i=0;i<t;i++) team.push_back(Team(p,i+1)) ;
		
		for(int i=0;i<r;i++){
			int tid,pid,time;
			string m;
			cin>>tid>>pid>>time>>m;
			tid--; pid--;
			
			if(m[0]=='C'){
				team[tid].ac++;
				team[tid].time+=time+team[tid].wa[pid]*1200;
			}else{
				team[tid].wa[pid]++;
			}
		}
		
		sort(team.begin(),team.end());
		
		for(int i=0;i<t;i++){
			cout<<team[i].id<<" "<<team[i].ac<<" "<<team[i].time<<endl;
		}

	}
	return 0;
}