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 <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    map<int,int> m;
    vector<pair<pi,pi > >data;
    pair<pi,pi> d;
    rep(i,n){
      cin>>d.second.first>>d.second.second>>d.first.first>>d.first.second;
      d.second.first=(-d.second.first);
      d.first.second=(-d.first.second);
      data.pb(d);
    }
    sort(all(data));reverse(all(data));
    int win=0;
    rep(i,n){
      if(win<=10&&m[data[i].second.first]<3){
	cout<<-data[i].second.first<<endl;
	m[data[i].second.first]++;
	win++;
      }else if(win<=20&&m[data[i].second.first]<2){
	cout<<-data[i].second.first<<endl;
	m[data[i].second.first]++;
	win++;
      }else if(win<=26&&m[data[i].second.first]==0){
	cout<<-data[i].second.first<<endl;
	m[data[i].second.first]++;
	win++;
      }
    }
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, pair<int, int>>> v;
        map<int, int> m, af;
        for(int i=0; i < n; i++){
            int id, u, a, p;
            cin >> id >> u >> a >> p;
            m[i] = u;
            v.push_back(make_pair(a*-1, make_pair(p, id)));
        }
        sort(v.begin(), v.end());
        int count = 0;
        for(int i=0; i< n; i++){
            if(count < 10 && af[m[i]] < 3 || count < 20 && af[m[i]] < 2 && count < 26 || af[m[i]] < 1){cout << v[i].second.second << endl; af[m[i]]++; count++;}
        }
    }
}

C++: #include<stdio.h>
#include<map>
#include<algorithm>
struct S{int i,u,a,p;}a[300];
int C(S l,S r)
{
	if(l.a-r.a)return l.a>r.a;
	if(l.p-r.p)return l.p<r.p;
	return l.i<r.i;
}
int main()
{
	int i,n,c;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)scanf("%d%d%d%d",&a[i].i,&a[i].u,&a[i].a,&a[i].p);
		std::sort(a,a+n,C);
		std::map<int,int>m;
		for(c=i=0;i<n;++i)
		{
			if(c<10&&m[a[i].u]<3 || c<20&&m[a[i].u]<2 || c<26&&m[a[i].u]<1)
				printf("%d\n",a[i].i),m[a[i].u]++,++c;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//const int RULE[3] = {10,20,26};
//const int MEM[3] = {3,2,1};

int main(){
  while(1){
    int n;
    cin >> n;

    if(n == 0)break;///// テヲツュツ」ティツァツ」テヲツ閉ー,テ「ツ按津ッツシツ妥ッツシツ甘」ツδ堙」ツδ甘」ツδォテ」ツδ?ID,テヲツ可?・ツアツ?
    
    vector<pair<pair<int,int>,
		pair<int,int>		
		>
	   > vec(n,pair<pair<int,int>,pair<int,int> >());
    for(int i = 0;i < n;i++){
      int l,u,a,p;
      cin >> l >> u >> a >> p;
      vec[i].first = pair<int,int>(a,-1*p);
      vec[i].second = pair<int,int>(-1*l,u);
    }
    sort(vec.begin(),vec.end());
    vector<int> cnt(1000,0);
    int ii = 0;
    for(int i = n-1;i >= 0;i--){
      //      cout << vec[i].second.second << "DEGG" << cnt[vec[i].second.second]<< endl;
      
      cnt[vec[i].second.second]++;
      if(ii < 10 && cnt[vec[i].second.second] > 3){
      }else if(10 <= ii && ii < 20&& cnt[vec[i].second.second] > 2){
      }else if(20 <= ii && ii < 26 && cnt[vec[i].second.second] > 1){
      }else{
	cout << -1*vec[i].second.first << endl;
      } 
      ii++;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
struct team{int i, u, a, p;team(int,int,int,int);};
team::team(int _i, int _u, int _a, int _p)
	:i(_i), u(_u), a(_a), p(_p) {}

bool tsort(const team& l, const team& r){
	if(l.a == r.a){
		if(l.p == r.p)return l.i < r.i;
		return l.p < r.p;
	}
	return l.a > r.a;
}

int main(){
	int n;
	while(std::cin >> n, n){
		int i, u, a, p;
		std::vector<team> v;
		while(n--){
			std::cin >> i >> u >> a >> p;
			team t = team(i, u, a, p);
			v.push_back(t);
		}
		
		std::sort(v.begin(), v.end(), tsort);
		
		int steam = 0;
		std::map<int, int> m;
		std::vector<team>::iterator it = v.begin();
		while(it != v.end()){
			int mteam = 0;
			if(steam < 10)mteam = 3;
			else if(steam < 20)mteam = 2;
			else if(steam < 26)mteam = 1;

			if(m[(*it).u] < mteam){
				std::cout << (*it).i << std::endl;
				steam++, m[(*it).u]++;
			}
			it++;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> Pi;

int main(){
  int n;
  Pi team[333];
  while(cin >> n,n){
    for(int i=0;i<n;i++){
      int I,U,A,B;
      cin >> I >> U >> A >> B;
      P tmp1; tmp1.first = A; tmp1.second = -B;
      P tmp2; tmp2.first = U; tmp2.second = -I;
      team[i].first = tmp1; team[i].second = tmp2;
    }
    sort(team,team+n,greater<Pi>() );
    int idx = 0;
    int cnt = 0;
    int flg[1111]={0};
    while(idx < n && cnt < 26){
      int num = team[idx].second.first;
      int ID = -team[idx].second.second;
      if(cnt < 10){
	if(flg[num] < 3){
	  flg[num]++;
	  cout << ID << endl;
	}
      } else if(cnt < 20){
	if(flg[num] < 2){
	  flg[num]++;
	  cout << ID << endl;
	}
      } else if(cnt < 26){
	if(flg[num] < 1){
	  flg[num]++;
	  cout << ID << endl;
	}
      }
      idx++;
    }
  }
}