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 <set>
#include <vector>

using namespace std;

int main()
{
    while(1) {
        int N;
        cin >> N;
        if(N<=0) break;

        vector<set<int> > list(N);

        for(int i=0;i<N;++i) {
            int M;
            cin >> M;
            for(int j=0;j<M;++j) {
                int p;
                cin >> p;
                list[i].insert(p);
            }
        }

        int K;
        vector<int> l;
        cin >> K;
        for(int i=0;i<K;++i) {
            int p;
            cin >> p;
            l.push_back(p);
        }

        vector<int> hannin;
        for(int i=0;i<N;++i) {
            int j;
            for(j=0;j<K;++j) {
                if(list[i].find(l[j])==list[i].end()) {
                    break;
                }
            }
            if(j==K) {
                hannin.push_back(i+1);
            }
        }
        if(hannin.size()==1) {
            cout << hannin[0] << endl;
        } else {
            cout << -1 << endl;
        }
    }
}

C++: #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int T, P, R, tid, pid, t;
  string m;
  while (cin >> T >> P >> R, T) {
    vector< vector<int> > V(T, vector<int>(3, 0));
    vector< vector<int> > Problem(T, vector<int>(P, 0));
    for (int i = 0; i < T; ++i) V[i][2] = i+1;
    for (int i = 0; i < R; ++i) {
      cin >> tid >> pid >> t >> m;
      --tid;
      --pid;
      if (Problem[tid][pid] != 1) {
	if (m == "CORRECT") {
	  V[tid][1] += -Problem[tid][pid]*1200 + t;
	  Problem[tid][pid] = 1;
	  --V[tid][0];
	} else {
	  --Problem[tid][pid];
	}
      }
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < T; ++i) {
      cout << V[i][2] << " " << -V[i][0] << " " << V[i][1] << endl;
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
#include <set>
#include <iomanip>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

#define MAX 1500

int main()
{
    int t,p,r;
    while((cin >> t >> p >> r )&&t && p && r){
        vector<int>tID;
        vector<int>pID;
        vector<int>time;
        vector<string>com;
        
        for(int i=0;i<r;i++){
            int a,b,c;
            string d;
            cin >> a >> b >> c >> d;
            tID.pb(a);
            pID.pb(b);
            time.pb(c);
            com.pb(d);
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(pID[i] > pID[j]){
                    swap(pID[i],pID[j]);
                    swap(tID[i],tID[j]);
                    swap(time[i],time[j]);
                    swap(com[i],com[j]);
                }
                
            }
        }
        /*
        for(int i=0;i<r;i++){
            cout << "tID:" <<tID[i] << " pID:" << pID[i] << " time:" << time[i] << " judge:" << com[i] <<  endl;
        }
         
         */
        vector<vector<int> > ans;
        vi temp;
        for(int i=0;i<t;i++){
            temp.pb(i+1);
            for(int j=1;j<4;j++){
                temp.pb(0);
            }
            ans.pb(temp);
            temp.clear();
        }
        
        for(int i=0;i<r;i++){
            if(com[i] == "CORRECT"){
                ans[tID[i]-1][1]++;
                ans[tID[i]-1][2] += (ans[tID[i]-1][3] * 1200 + time[i]);
                ans[tID[i]-1][3] = 0;

            }else{
                ans[tID[i]-1][3]++;
            }
            
        }
        for(int i=0;i<t;i++){
            for(int j=i+1;j<t;j++){
                if(ans[i][1] < ans[j][1]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);

                }
                
                if(ans[i][1] == ans[j][1] && ans[i][2] > ans[j][2]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                }
                
                if(ans[i][1] == ans[j][1] && ans[i][2] == ans[j][2] && ans[i][0] > ans[j][0]){
                    swap(ans[i][0],ans[j][0]);
                    swap(ans[i][1],ans[j][1]);
                    swap(ans[i][2],ans[j][2]);
                    swap(ans[i][3],ans[j][3]);
                }
            }
        }

        
        for(int i=0;i < t;i++){
               cout << ans[i][0] << " " << ans[i][1] <<" " << ans[i][2] << endl;
        }
    }
    return 0;
}