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

typedef struct TreamInfo
{
    int tID;
    int points;
    int pena;
    int ProbMiss[10];

    TreamInfo(int tid) : tID(tid) {}
} TeamInfo;

bool cmp(const TeamInfo &a, const TeamInfo &b)
{
    return (a.points == b.points)?(a.pena == b.pena? a.tID < b.tID:a.pena < b.pena):(a.points > b.points);
}

int main()
{


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

        vector<TeamInfo> v;

        for (size_t i = 0; i < t; i++)
        {
            v.push_back(TeamInfo(i+1));
        }

        for (size_t i = 0; i < r; i++)
        {
            int tID, pID, tim;
            string mess;
            cin >> tID >> pID >> tim >> mess;

            if (mess == "CORRECT")
            {
                v[tID - 1].points += 1;
                v[tID - 1].pena += ((v[tID - 1].ProbMiss[pID - 1]) * 1200) + tim;
            }
            if (mess == "WRONG")
            {
                v[tID - 1].ProbMiss[pID - 1] += 1;
            }
        }
        // for (size_t i = 0; i < t; i++)
        // {
        //     cout << "team " << i <<" point is " <<v[i].points << endl;
        //     cout << "team " << i << " pena is " << v[i].pena << endl;
        // }

        sort(v.begin(), v.end(), cmp);
        for (size_t i = 0; i < t; i++)
        {
            cout << v[i].tID <<" "<< v[i].points <<" "<< v[i].pena << endl;
        }
    }
    return 0;
}

C++: 1 3 7200
3 1 2600
2 0 0
5 2 7000
3 1 4000
4 1 4000
1 0 0
2 0 0
4 2 2000
5 2 2000
1 2 2600
3 2 2600
2 0 0
6 0 0

C++: #include<iostream>
#include<algorithm>

using namespace std;

int r[51][11];
int w[51][11];
int p[51];

void init()
{

  for(int i = 0; i < 51; i++)
    {
      p[i] = 0;
      for(int j = 0; j < 11; j++)
	{
	  r[i][j] = w[i][j] = 0;
	}
    }


}


int main(void)
{

  int T,P,R;

  while(cin >> T >> P >> R)
    {

      init();

      for(int i = 0; i < R; i++)
	{

	  int tID , pID , time;
	  string judge;

	  cin >> tID >> pID >> time >> judge;
	  
	  if(judge == "WRONG")
	    {
	      if(r[tID][pID] != 1)
		{
		  w[tID][pID]++;
		}
	    }
	  
	  else if( r[tID][pID] == 0 )
	    {
	      r[tID][pID] = 1;
	      p[tID] += 1200 * w[tID][pID] + time;
	    }

	}
      
      pair< pair<int , int> , int > rank[50];

      for(int i = 0; i < T; i++)
	{
	  rank[i].first.first = -count(r[i + 1] , r[i + 1] + P + 1 , 1);
	  rank[i].first.second = p[i + 1];
	  rank[i].second = i + 1;
	}

      sort(rank , rank + T);

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

    }
  return 0;

}

C++: import java.util.Arrays;
import java.util.Scanner;

public class Main {
	class Team implements Comparable<Team>{
		int id, s;
		int[] p;
		int ac;

		Team(int id, int pro) {
			this.id = id;
			this.p = new int[pro];
			this.s = 0;
			this.ac = 0;
		}

		@Override
		public int compareTo(Team o) {
			if (this.ac != o.ac)
				return o.ac - this.ac;
			return this.s - o.s;
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int r = sc.nextInt();
			if ((n | m | r) == 0) {
				break;
			}

			Team[] t = new Team[n];
			for (int i = 0; i < n; i++) {
				t[i] = new Team(i, m);
			}

			for (int i = 0; i < r; i++) {
				int tid = sc.nextInt() - 1;
				int pid = sc.nextInt() - 1;
				int tim = sc.nextInt();
				String mes = sc.next();

				if (mes.equals("CORRECT")) {
					t[tid].ac++;
					t[tid].s += t[tid].p[pid]*1200 + tim;
				} else {
					t[tid].p[pid]++;
				}
			}

			Arrays.sort(t);
			for (int i = 0; i < n; i++) {
				int tid = t[i].id;
				int ac = t[i].ac;
				int pen = t[i].s;
				System.out.println(++tid + " " + ac + " " + pen);
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct kk{
int id;
int ac;
int wa;
vector<int> p;//核問題に対するペナルティ
vector<bool>acs;
int psum;
};
//
kk ans[105];
int main(){
	int T,P,R;
	while(cin>>T>>P>>R){//Tチーム、P問,R個のログ
	if(T==0&&R==0&&P==0)break;
	for(int i=0;i<105;i++){
	ans[i].p.resize(180);
	ans[i].acs.resize(190);
	for(int j=0;j<103;j++)ans[i].p[j]=0,ans[i].acs[j]=0;
	ans[i].id=i;
	}

	for(int i=0;i<R;i++){
	int a,b,c;//id,問題id,経過時間
	string d;//メッセージ
	cin>>a>>b>>c>>d;
	if(d=="WRONG"){
	ans[a].p[b]++;
	}
	else if(d=="CORRECT"){
	ans[a].ac++;
	ans[a].acs[b]=true;
	ans[a].p[b]=ans[a].p[b]*1200+c;
	}
	}
	for(int i=1;i<=T;i++){
		int sum=0;
		for(int j=0;j<=P;j++)if(ans[i].acs[j])sum+=ans[i].p[j];
		ans[i].psum=sum;
	}

	//for(int i=1;i<=T;i++)cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	for(int i=1;i<=T;i++){
		for(int j=i+1;j<=T;j++){
			if(ans[i].ac<ans[j].ac)swap(ans[i],ans[j]);//右のほうが強ければswap
			else if(ans[i].ac==ans[j].ac){

				if(ans[i].psum>ans[j].psum)swap(ans[i],ans[j]);
				if(ans[i].psum==ans[j].psum&&ans[i].id>ans[j].id)swap(ans[i],ans[j]);
			}
		}
	}
	for(int i=1;i<=T;i++){
	cout<<ans[i].id<<" "<<ans[i].ac<<" "<<ans[i].psum<<endl;
	}
	}
	for(int i=0;i<=T;i++){ans[i].p.clear();ans[i].acs.clear();ans[i].psum=0;ans[i].ac=0;ans[i].wa=0;ans[i].id=0;}
	return 0;
}