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;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct team{
	int a,t,n;
	bool operator<(team &arg) const{
		if(a==arg.a&&t==arg.t) return n<arg.n;
		if(a==arg.a) return t<arg.t;
		return a>arg.a;
	}
};

team info[55];

int wrong[55][11];

int main(void){
	int t,p,r;
	while(cin >> t >> p >> r){
		if(t==0)
			break;
		rep(i,55)rep(j,11) wrong[i][j]=0;
		rep(i,55) info[i].a=info[i].t=0,info[i].n=i+1;
		rep(i,r){
			int tid,pid,times;
			cin >> tid >> pid >> times;
			string m;
			cin >> m;
			if(wrong[tid][pid]!=-1){
				if(m=="CORRECT"){
					info[tid-1].a++;
					info[tid-1].t+=(times+1200*wrong[tid][pid]);
					wrong[tid][pid]=-1;
				}else
					wrong[tid][pid]++;
			}
		}
		sort(info,info+t);
		rep(i,t) cout << info[i].n << " " << info[i].a << " " << info[i].t << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>

#define T 50
#define P 10

struct Cell
{
  int sv;
  int p;
  int no;
};
typedef struct Cell Cell;
#define CELL(X) \
  ( *( (const Cell *)(X) ) )

Cell d[ T + 1 ];
int wa[ T + 1 ][ P + 1 ];

static int
compare (
  const void * a,
  const void * b
  )
{
  int res = CELL( b ).sv - CELL( a ).sv;
  if ( res ) return ( res );
  res = CELL( a ).p - CELL( b ).p;
  if ( res ) return ( res );

  return ( CELL( a ).no - CELL( b ).no );
}

int
main (
  void
  )
{
  int i;

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

    scanf ( " %d %d %d", &t, &p, &r );
    if ( !( t | p | r ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    for ( i = 1; i <= t; ++i )
    {
      d[ i ].no = i;
    }
    memset ( wa, 0, sizeof ( wa ) );

    while ( r-- )
    {
      int tid, pid, time;
      char msg[ 32 ];

      scanf ( " %d %d %d %s", &tid, &pid, &time, msg );
      if ( !strcmp ( msg, "CORRECT" ) )
      {
        d[ tid ].p += time + wa[ tid ][ pid ] * 1200;
        ++d[ tid ].sv;
      }
      else
      {
        ++wa[ tid ][ pid ];
      }
    }
    qsort ( d + 1, t, sizeof ( Cell ), compare );

    for ( i = 1; i <= t; ++i )
    {
      printf ( "%d %d %d\n", d[ i ].no, d[ i ].sv, d[ i ].p );
    }
  }

  return ( 0 );
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back

struct Team {
    int num=0, ac=0, pen=0;
    int wa[15] = {0};
};

void solve(int T,int P,int R) {
    vector<Team> teams(T);
    rep(i,T) teams[i].num=i+1;
    rep(i,R) {
        int tm, prg, time;
        string msg;
        cin>>tm>>prg>>time>>msg;
        tm--; prg--;
        if(msg == "WRONG") {
            teams[tm].wa[prg]++;
        } else {
            teams[tm].ac++;
            teams[tm].pen += teams[tm].wa[prg] * 1200 + time;
        }
    }
    rep(i,T) rep(j,T-1) {
        if(teams[j].ac < teams[j+1].ac) swap(teams[j], teams[j+1]);
        if(teams[j].ac == teams[j+1].ac
                and teams[j].pen > teams[j+1].pen) swap(teams[j], teams[j+1]);
    }

    for(auto& team : teams) {
        cout << team.num << " " << team.ac << " " << team.pen << "\n";
    }
}

int main() {
    int T,P,R;
    while(cin>>T>>P>>R, T) solve(T,P,R);
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
    int t,p,r;
    while(1){
        cin>>t>>p>>r;
        if(t == 0 && p ==0 && r ==0) break;
        vector<vector<int> > wa(t,vector<int>(p,0)),ac(t+1,vector<int>(p+1,0));
        vector<int> tsum(t,0);
        
        for(int i=0; i<r; i++){
            int tid,pid,time;
            string s;
            cin>>tid>>pid>>time>>s;
            tid--,pid--;
            if(s == "CORRECT"){
                ac[tid][pid]++;
                tsum[tid] += wa[tid][pid]*1200+time;
            }

            else if(s == "WRONG"){
                wa[tid][pid]++;
            }
        }

        vector<int> ans(t);

        for(int i=0; i<t; i++){
            for(int j=0; j<p; j++){
                if(ac[i][j])ans[i]++;
            }
        }
        vector<pair<int,pair<int,int> > > data(t);

        for(int i=t-1; i>=0; i--){
            data[i].first = -ans[i];
            data[i].second.second = i+1;
            data[i].second.first = tsum[i];
        }

        sort(data.begin(),data.end());

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