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,4001,0);
    int cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(v2[a] == 0){
        v.push_back(make_pair(cnt,a));
        ++cnt;
      }
      v2[a] += b * c;
    }
    bool f = false;
    REP(i,0,v.size()){
      if(v2[v[i].se] >= 1000000){
        cout << v[i].se<<endl;
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	vector<long long> data(4000);
	int i;
	int a,b,c;
	int max;
	bool check;

	cin >> i;
	while(i){

		for(int j = 0;j < 4000;j++){
			data[j] = 0;
		}


		for(int j = 0;j < i;j++){
			cin >> a >> b >> c;
			data[a - 1] += b * c;
		}


		check = false;

		for(int j = 0;j < 4000;j++){
			if(data[j] >= 1000000){
				printf("%d\n",j+1);
				check = true;
			}
		}

		if(!check) printf("NA\n");

		cin >> i;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 4000;

int n, e, p, q;
ll a[MAX_N];

int main(){
	while(1){
		for(int i = 0; i < MAX_N; i++){
			a[i] = 0;
		}
		cin >> n;
		if(n == 0) break;
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			e--;
			a[e] += p * q;
		}
		bool def = false;
		for(int i = 0; i < MAX_N; i++){
			if(a[i] >= 1000000LL){
				cout << i + 1 << endl;
				def = true;
			}
		}
		if(def == false) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        int count = 0;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        int* officer_num_old = new int [dataset_num];


        for (int i = 0; i < dataset_num; i++) {
            int officer_num;
            int price;
            int figure;
            int flag = 0;
            officer_num_old[i] = officer_num;
            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            for (int j = 0;j < i; j++) {
                if (officer_num_old[j] == officer_num) {
                    flag = 1;
                }
            }


            if (price * figure >= 100000 && flag == 0) {
                std::cout << officer_num << std::endl;
                count += 1;
            }
        }
        if (count == 0) {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}

C++: #include<stdio.h>
int main()
{
	unsigned long int goukei[4001]={0},kazu,tanka;
	int n,i,j,h,g=0,kazuz[4001]={0};
	while(scanf("%d",&n))
	{
		if(n==0)
		{
			break;
		}
		for(i=1;i<=n;i++)
		{
			scanf("%d %d %d",&j,&tanka,&kazu);
			kazuz[i]=j;
			goukei[i]=goukei[i]+tanka*kazu;
		}
		for(i=1;i<4001;i++)
		{
			if(goukei[i]>=1000000)
			{
				printf("%d\n",kazuz[i]);
				for(h=1;h<4001;h++)
				{
					if(kazuz[h]==kazuz[i])
					{
						goukei[h]=0;
					}
				}
				g++;
			}
			goukei[i]=0;
			kazuz[i]=0;
		}
		if(g==0)
		{
			printf("NA\n");
		}
		g=0;
	}
	
	return 0;
}

C++: #include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

string int_to_str(int n) {
	stringstream ss;
	string ret;

	ss << n;
	ss >> ret;

	return ret;
}


int keta(int n) {
	string str = int_to_str(n);

	return str.size();
}

int main() {
	int n;
	while (cin >> n, n) {
		bool f = false;
		map<int, ll> datas;
		vector<int> noes;
		for (int i = 0; i < n; ++i) {
			ll no, a, b; cin >> no >> a >> b;

//			if ( find( noes.begin(), noes.end(), no) == noes.end() )
//				noes.push_back(no);

			if (datas[no] < 1000000) {
				if ((datas[no] += a * b) >= 1000000) {
					cout << no << endl;
					f = true;
				}
			}
		}
/*
		for (int i = 0; i < noes.size(); ++i)
			if (datas[noes[i]] >= 1000000)
				cout << noes[i] << endl;
*/
		if (!f) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(!n)break;
		int num,price,amount;
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			if((long long)price*(long long)amount>=1000000)v.push_back(num);
		}
		if(!v.empty()){
			for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		}else cout<<"NA\n";
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,num,flag=0,flag2=0;
  long long tanka,sell;
  while(cin>>n,n!=0){
    flag=0;flag2=0;
    vector<int> nu;
    vector<int> vi;
    vector<pair<int,long long> > pii;
    for(int i=0;i<n;i++){
      cin>>num>>tanka>>sell;
      for(int j=0;j<vi.size();j++){
	if(num==vi[j]){
	  flag2=1;
	  break;
	}
      }
      if(flag2==0){
	for(int j=0;j<pii.size();j++){
	if(pii[j].first==num){
	  flag=1;
	  pii.push_back(make_pair(num,((tanka*sell)+pii[j].second)));
	  if(((tanka*sell)+pii[i].second)>=1000000)
	    vi.push_back(num);
	  break;
	}
      }
      if(flag==0){
	nu.push_back(num);
	pii.push_back(make_pair(num,tanka*sell));
	if(tanka*sell>=1000000)
	  vi.push_back(num);
      }
    }
    }
    if(vi.empty())
      cout<<"NA"<<endl;
    else{
    for(int k=0;k<nu.size();k++){
      for(int l=0;l<vi.size();l++){
	if(nu[k]==vi[l])
	  cout<<nu[k]<<endl;
      }
    }
    }
  }
  return 0;
}