Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

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

using namespace std;

int main()
{
  while(1){
    int n;
    cin>>n;
    if(n == 0){
      break;
    }

    vector<pair<int,int>> data;
    vector<int> nanum;
    for(int i = 0;i < n;++i){
      int num,sa,ko;
      cin>>num;
      cin>>sa;
      cin>>ko;

      int sum = sa * ko;

      if(i == 0){
        nanum.push_back(num);
        data.push_back(make_pair(num,sum));
      }
      else{
        auto a = find(nanum.begin(),nanum.end(),num);
        size_t index = distance(nanum.begin(),a);
        if(index == nanum.size()){
          nanum.push_back(num);
          data.push_back(make_pair(num,sum));
        }
      }
    }

    int check = 0;
    for(pair<int,int> e : data){
      if(e.second >= 1000000){
        check = 1;
        cout<<e.first<<endl;
      }
    }
    if(check == 0){
      cout<<"NA"<<endl;
    }
  }

  return 0;
}

C++: #include <cstdio>
#include <utility>
#include <unordered_map>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define is inline bool scan
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
is(int &n) {int c=gcu();return c==EOF?false:(n=in(c),true);}
is(char &c){c=gcu();gcu();return c!=EOF;}
//is(string &s) {int c;for(;;){c=gcu();if(c=='\n'||c==' ')return true;s+=c;}}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

int main() {
	int n;
	while ((n = in())) {
		unordered_map<int, long> m;
		vector<int> e;
		while (n--) {
			int i = in(), p = in(), q = in();
			if (!m.count(i))
				e.push_back(i);
			m[i] += p * q;
		}
		bool NA = true;
		for (int i: e)
			if (m[i] >= 1000000) {
				out(i, '\n');
				NA = false;
			}
		if (NA)
			out("NA\n");
	}
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        map<int,int>M;
        while(n--){
            int a,b,c;
            cin>>a>>b>>c;
            M[a]+=b*c;
        }

        bool flag=true;
        for(map<int,int>::iterator ite=M.begin();ite!=M.end();ite++){
            if(ite->second>=1000000){
                cout<<ite->first<<endl;
                flag=false;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

C++: // a.c.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <map>
#include <iostream>
using namespace std;
//map<int, long long> bango;
long long int bango[4001];
int main(void){
	int n;
	long long ban, tan, suu;
	int flg,i;
	while (1){
		for (i = 1; i <= 4000; i++){
			bango[i] = 0;
		}
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			//scanf("%d %ld %d", &ban, &tan, &suu);
			cin >> ban >> tan >> suu;
			bango[ban] += tan*suu;
		}
		flg = 0;
		for (i = 1; i <= 4000; i++){
			if (bango[i]>=1000000){
				printf("%d\n", i);
				flg = 1;
			}
		}
		if (!flg){
			printf("NA\n");
		}
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#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 repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<ll,ll> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n,a,b,c;
  while(cin >> n && n){
    vector<pair<ll,ll>> v;
    vary(double,v2,4005,0);
    int cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(v2[a] == 0){
        ++cnt;
        v.push_back(make_pair(cnt,a));
      }
      double d = (b/1000)? (b/1000) : 1;
      double e = (c/1000)? (c/1000) : 1;
      v2[a] += d * e;
    }
    sort(all(v),[](const pii &p,const pii &p2){return p.fi < p2.fi;});
    bool f = false;
//     debug(v.size());
    REP(i,0,v.size()){
//       debug(v[i].se);
//       debug(v2[v[i].se]);
      if(v2[v[i].se] < 1){
      }
      else{
        cout << v[i].se<<endl;
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

C++: #include <vector>
#include <iostream>
#include <set>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(a * b >= 1000000 && list.find(id) == list.end()) {
                list.insert(id);
                cout << id << endl;
            }
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}

C++: #include<iostream>
#include<list>
using namespace std;

int main()
{
    std::list<int> Anslist;
    int e[4001],p[100000],q[1000000],n;
    
    
    while(cin>>n){
        
        if(n==0)
            break;
        
        for(int i=0,j=0; i<n; i++){
            cin>>e[i]>>p[i]>>q[i];
        
            if(p[i]*q[i]>=1000000){
                Anslist.push_back(e[i]);
                j++;
            }
        
        }
    
    }
        if(Anslist.empty()){
            cout << "NA" <<endl;
        }
    
        else{
            list<int>::iterator it = Anslist.begin();
            while( it != Anslist.end())
            {
                cout<< *it << endl;
                it++;
            }
        }
    
    
    
    return 0;
}