Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	for n := getNextInt(scanner); n > 0; n = getNextInt(scanner) {
		tt := make([]team, n)
		for i := 0; i < n; i++ {
			tt[i].id = getNextInt(scanner)
			tt[i].uni = getNextInt(scanner)
			tt[i].ac = getNextInt(scanner)
			tt[i].pn = getNextInt(scanner)
		}
		sort.SliceStable(tt, func(i, j int) bool {
			if tt[i].ac == tt[j].ac {
				if tt[i].pn == tt[j].pn {
					return tt[i].id < tt[j].id
				}
				return tt[i].pn < tt[j].pn
			}
			return tt[i].ac > tt[j].ac
		})
		cc := make([]int, 100005)
		ans := make([]int, 0)
		for i := 0; i < n; i++ {
			if cc[0] < 10 && cc[tt[i].uni] < 3 {
				cc[0]++
				cc[tt[i].uni]++
				ans = append(ans, tt[i].id)
				continue
			}
			if cc[0] < 20 && cc[tt[i].uni] < 2 {
				cc[0]++
				cc[tt[i].uni]++
				ans = append(ans, tt[i].id)
				continue
			}
			if cc[0] < 26 && cc[tt[i].uni] < 1 {
				cc[0]++
				cc[tt[i].uni]++
				ans = append(ans, tt[i].id)
				continue
			}
		}
		for i := 0; i < len(ans); i++ {
			fmt.Fprintln(writer, ans[i])
		}
	}
}

type team struct {
	id, uni, ac, pn int
}

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

typedef pair<int,int> P;

int main() {
    int N;
    while (cin >> N, N) {
        vector<vector<P> > rank(11);
        vector<int> univ_id(1001);

        for (int c = 0; c < N; c++) {
            int i, u, a, p;
            cin >> i >> u >> a >> p;
            rank[a].push_back(P(p,i));
            univ_id[i] = u;
        }

        for (auto& i : rank)
            sort(i.begin(), i.end());

        int count = 0;
        vector<int> univ_cnt(1001);
        for (int i = 10; i > -1; i--) {
            for (auto team : rank[i]) {
                int I = team.second;
                int pena = team.first;
                int limit;
                if (count < 10) limit = 3;
                else if (count < 20) limit = 2;
                else if (count < 26) limit = 1;
                if (univ_cnt[univ_id[I]] < limit) {
                    cout << I << endl;
                    univ_cnt[univ_id[I]]++;
                }
            }
        }
    }

    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX = 1001;
typedef pair<int,int> QQ;
typedef pair<int,int> PP;
typedef pair<PP,QQ> P;

int main(){
  int n;

  while(cin >> n ,n){
    int id,uni,ac,pe;
    int tc[MAX+1];
    fill(tc,tc+MAX,0);
    vector<P> v;

    while(n--){
      cin >> id >> uni >> ac >> pe;
      v.push_back(P(PP(-ac,pe),QQ(id,uni)));
    } 
    sort(v.begin(),v.end());

    int cnt = 0;
    int size = v.size();
    for(int i = 0; i < size ; i++){
      int u = v[i].second.second;
   
      if(cnt < 10){
	if(tc[u] < 3){
	  cout << v[i].second.first << endl;
	  cnt++;
	}
      }
      else if(cnt < 20){
	if(tc[u] < 2){
	  cout << v[i].second.first << endl;
	  cnt++;
	}
      }
      else if(cnt < 26){
	if(tc[u] < 1){
	  cout << v[i].second.first << endl;
	  cnt++;
	}
      }
      tc[u]++;
    } 
  }

  return 0;
}

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

class Team {

    public:
        int id;
        int school;
        int cleared;
        int penalty;

        Team (int a, int b, int c, int d) {
            id = a;
            school = b;
            cleared = c;
            penalty = d;
        }

        friend bool operator<(const Team& lhs, const Team& rhs) {

            if (lhs.cleared != rhs.cleared) {
                return lhs.cleared < rhs.cleared;
            } else if (lhs.penalty != rhs.penalty) {
                return lhs.penalty > rhs.penalty;
            } else {
                return lhs.id > rhs.id;
            }
        }
        
};

int main() {

    int n;
    while(true) {
        cin >> n;
        if (n == 0) break;

        vector<Team> teams;
        for(int i = 0; i < n; i++) {
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            teams.push_back(Team(a, b, c, d));
        }
        sort(teams.begin(), teams.end());
        reverse(teams.begin(), teams.end());

        vector<int> schools;
        int selected = 0;
        for(int i = 0; i < teams.size(); i++) {
            if (selected < 10 && count(schools.begin(), schools.end(), teams[i].school) < 3) {
                cout << teams[i].id << endl;
                selected += 1;
                schools.push_back(teams[i].school);
            } else if (selected < 20 && count(schools.begin(), schools.end(), teams[i].school) < 2) {
                cout << teams[i].id << endl;
                selected += 1;
                schools.push_back(teams[i].school);
            } else if (selected < 26 && find(schools.begin(), schools.end(), teams[i].school) == schools.end() ) {
                cout << teams[i].id << endl;
                selected += 1;
                schools.push_back(teams[i].school);
            }
        }
    }
     
    return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;
const int mod = 1e9 + 7;
const double EPS = 1e-9;


struct team{
	int id, shozoku, ac, pena;
	team(){};
	team(int id, int shozoku, int ac, int pena) : id(id), shozoku(shozoku), ac(ac), pena(pena){};
	bool operator <(const team &t) const{
		if(ac != t.ac) return ac > t.ac;
		if(pena != t.pena) return pena < t.pena;
		return id < t.id;
	}
};


int main(){
	int n;
	while(cin>>n && n > 0){
		vector<team> v(n);
		int a, b, c, d;
		for(int i = 0; i < n; i++){
			cin>>a>>b>>c>>d;
			v[i] = team(a, b, c, d);
		}
		sort(all(v));

		int win = 0;
		vi vwin(10000, 0);

		for(int i = 0; i < n; i++){
			if(win < 10 && vwin[v[i].shozoku] < 3){
				cout<<v[i].id<<endl;
				win++;
				vwin[v[i].shozoku]++;
			}else if(win < 20 && vwin[v[i].shozoku] < 2){
				cout<<v[i].id<<endl;
				win++;
				vwin[v[i].shozoku]++;
			}else if(win < 26 && vwin[v[i].shozoku] == 0){
				cout<<v[i].id<<endl;
				win++;
				vwin[v[i].shozoku]++;
			}
			if(win >= 26){
				break;
			}
		}	
	}
}