Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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);
  int n,a,b,c;
  while(cin >> n && n){
    vector<pair<ll,ll>> v;
    vary(ll,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));
      }
      if(v2[a] + b * a >= 1000000) v2[a] = 1000000;
      if(v2[a] < 1000000)
        v2[a] += b * c;
    }
    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()){
      if(v2[v[i].se] < 1000000){
      }
      else{
        cout << v[i].se<<endl;
//         debug(v2[v[i].se]);
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

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

int main() {

	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		vector<int> number;
		vector<long long int> score;

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

			int input_number;
			long long int tanka;
			long long int kazu;
			cin >> input_number >> tanka >> kazu;

			for ( int j = 0; j <= number.size(); j++ ) {
				if ( j != number.size() ) {
					if ( number[j] == input_number ) {
						score[j] += tanka * kazu;
						break;
					}
				}else {
					number.push_back(input_number);
					score.push_back(tanka * kazu);
					break;
				}
			}
		}

		bool f = true;
		for ( int i = 0; i < number.size(); i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << number[i] << endl;
				f = false;
			}
		}

		if ( f ) cout << "NA" << endl;

	}

	return 0;
}

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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int main()
{
    int n; ll en, price, qty, check[4001]; qi que;
    while(cin >> n && n) {
        if (n == 0) break;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= 0) {
                check[en] += price*qty;
            }

            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) {
            cout << "NA" << endl;
        } else {
            for(int i=0,len=que.size(); i < len; ++i) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}

C++: //11
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    long long total[4001]={};
    bool out=false;
    for(int i=0;i<n;i++){
      int id;
      long long t,ns;
      cin>>id>>t>>ns;
      if(total[id]<1000000){
	total[id]+=t*ns;
	if(total[id]>=1000000){
	  cout<<id<<endl;
	  out=true;
	}
      }
    }
    if(!out){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

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

    bool found = false;
    for (int i = 0; i < n; ++i) {
      int num;
      long long int price, count;
      cin >> num >> price >> count;
      if (price*count >= 1000000LL) {
	cout << num << endl;
	found = true;
      }
    }

    if (!found)
      cout << "NA" << endl;
  }
  return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	while (cin >> n&&n) {
		long long member[4001] = {0};
		int a, b, c;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			member[a] += b*c;
		}
		int count = 0;
		for (int i = 0; i < 4001; i++) {
			if (member[i] >= 1000000) {
				count++;
				cout << i << endl;
			}
		}
		if (count == 0)cout << "NA" << endl;
	}

}

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

long long worker[4001];

void init() {
  for(int i = 0; i < 4001; ++i) {
	worker[i] = 0;
  }
}

int main() {
  int n, id, p, q;
  while(cin >> n) {
	if(!n) break;

	init();
	for(int i = 0; i < n; ++i) {
	  cin >> id >> p >> q;
	  worker[id] += p * q;
	}

	bool ret = 0;
	for(int i = 1; i < 4001; ++i) {
	  if(worker[i] >= 1000000) {
		cout << i << endl;
		ret = 1;
	  }
	}
	
	if(!ret) {
	  cout << "NA" << endl;
	}
	
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

	int i, j = 0;

	while(true){
		int n;

		cin >> n;

		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		else if(n < 0 || 4000 < n){
			continue;
		}
		int* a = new int[n];
		int* b = new int[n];
		int* c = new int[n];

		for(i = 0; i < n; i++){
			cin >> a[i] >> b[i] >> c[i];
		}

		for(i = 0; i < n; i++){
			if(b[i] * c[i] >= 1000000){
				cout << a[i] << endl;
				j++;
			}
		}
		if(j == 0){
			cout << "na" << endl;
		}


	}
}

C++: #include <cstdio>
#include <vector>
using namespace std;
int main()
{
	long long n;
	while(scanf("%Ld\n", &n), n){
		vector<pair<long long, long long> > v;
		for(long long i = 0; i < n; i++){
			long long p, q, r, f = 1;
			scanf("%Ld %Ld %Ld\n", &p, &q, &r);
			for(long long j = 0; j < v.size(); j++){
				if(v[j].first == p){
					f = 0;
					v[j].second += q * r;
				}
			}
			if(f){
				pair<long long, long long> pa(p, q * r);
				v.push_back(pa);
			}
			
		}
		long long g = 1;
		for(long long i = 0; i < v.size(); i++){
			if(1000000 <= v[i].second){
				g = 0;
				printf("%Ld\n", v[i].first);
			}
		}
		if(g) puts("NA");
	}
	return 0;
}