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

struct team{
	int num;
	int ans;
	int time;
};

bool hikaku(const team &right,const team &left){
	return right.ans == left.ans ? right.time < left.time : right.ans > left.ans;
}

int main(){
	int t,p,r;
	int wrong[52][12];
	int res[52];
	int pe[52];
	vector<team> v;
	int tid,pid,time;
	string message;
	team te;
	while(1){
		cin >> t >> p >> r;
		if(t == 0)break;
		for(int i = 0;i <= t;i++){
			res[i] = 0;
			pe[i] = 0;
			for(int j = 0;j <= p;j++){
				wrong[i][j] = 0;	
			}
		}
		v.clear();
		for(int i = 0;i < r;i++){
			cin >> tid >> pid >> time >> message;
			if(message == "CORRECT"){
				res[tid]++;
				pe[tid] += wrong[tid][pid] * 1200 + time;
			}
			else if(message == "WRONG"){
				wrong[tid][pid]++;
			}
		}
		for(int i = 1;i <= t;i++){
			te.num = i;
			te.ans = res[i];
			te.time = pe[i];
			v.push_back(te);
		}
		sort(v.begin(),v.end(),hikaku);
		for(int i = 0;i < t;i++){
			cout << v[i].num << " " << v[i].ans << " " << v[i].time <<endl;
		}
	}
	return 0;
}

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

typedef struct{
  int correct;
  int wrong[10];
  int pena;
  int team_id;
} Log;

bool operator>(const Log &l1,const Log &l2){
  if(l1.correct != l2.correct) return (l1.correct > l2.correct);
  else if(l1.pena != l2.pena) return (l1.pena < l2.pena);
  else return (l1.team_id < l2.team_id);
}

int main(){
  int t,p,r;
  while(cin>>t>>p>>r,t){
    Log log;
    for(int i=0;i<10;i++)
      log.wrong[i]=0;
    log.correct=log.pena=0;
    vector<Log> vec(t,log);
    for(int i=0;i<t;i++)
      vec[i].team_id=i+1;

    for(int i=0;i<r;i++){
      int tid,pid,time;
      string str;
      cin>>tid>>pid>>time>>str;
      tid--;
      pid--;
      if(str=="WRONG"){
	vec[tid].wrong[pid]++;
      }else if(str=="CORRECT"){
	vec[tid].correct++;
	vec[tid].pena+=(vec[tid].wrong[pid]*1200+time);
      }
    }

    sort(vec.begin(),vec.end(),greater<Log>());
    for(int i=0;i<t;i++){
      cout<<vec[i].team_id<<" "<<vec[i].correct<<" "<<vec[i].pena<<endl;
    }

  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct team{
  int tid;
  int pen;
  int ans;
};


bool comp (const struct team x1,const struct team x2)
{
  if(x1.ans>x2.ans)
    return true;
  else if(x1.ans<x2.ans)
    return false;
  else
    {
      if(x1.pen<x2.pen)
	return true;
      else if(x1.pen>x2.pen)
	return false;
      else
	{
	  if(x1.tid<x2.tid)
	    return true;
	  else if(x1.tid>x2.tid)
	    return false;
	}
      
    }
}


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

      vector<team> d;
      for(int i=0;i<p;i++)
	{
	  struct team x;
	  x.tid=i+1;
	  x.pen=0;
	  x.ans=0;
	  d.push_back(x);
	}
      int miss[99][99]={0};

      for(int i=0;i<r;i++)
	{
	  int t,p,time;
	  string mess;
	  cin>>t;
	  cin>>p;
	  cin>>time;
	  cin>>mess;
	  if(mess=="WRONG")
	    {
	      miss[p][t]+=1;
	    }
	  else
	    {
	      d[t-1].ans+=1;
	      d[t-1].pen+=(miss[p][t]*1200)+time;	      
	    }
	}
      sort(d.begin(),d.end(),comp);
      for(int i=0;i<d.size();i++)
	{
	  printf("%d %d %d\n",d[i].tid,d[i].ans,d[i].pen);
	}	  
	  

    }
}

C++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
       // tea.clear();
    }
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int t,p,r;
	while(cin >> t >> p >> r) {
		if(t==0) break;
		vector<int> acc(t, 0);
		vector<vector<int> > wrong(t,vector<int>(p,0));
		vector<int> pena(t, 0);
		for(int i=0;i<r;i++) {
			int a,b,c;
			string cw;
			cin >> a >> b >> c >> cw;
			a--,b--;
			if(cw=="CORRECT") {
				acc[a]++;
				pena[a] += (c+wrong[a][b]*1200);
			}else if("WRONG") {
				wrong[a][b]++;
			}
		}
		vector<pair<pair<int,int>,int> > ans(t);
		for(int i=0;i<t;i++){
			ans[i] = make_pair(make_pair(-acc[i],pena[i]), i);
		}
		sort(ans.begin(),ans.end());
		for(int i=0;i<t;i++) {
			cout << ans[i].second + 1 << " " << -ans[i].first.first <<  " " << ans[i].first.second << endl;
		}
	}
}