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<iostream>
#include<map>
#include<string>
using namespace std;
typedef long long int ll;
int main(){
	for(;;){
		int n;
		cin >> n;
		if(n == 0) break;
		map<string, ll> mpa;
		for(int i = 0; i < n; i++){
			string e;
			int p, q;
			cin >> e;
			cin >> p >> q;
			mpa[e] += p * q;
		}
		map<string, ll>::iterator itr;
		bool flag = false;
		for(itr = mpa.begin(); itr != mpa.end(); itr++){
			if(itr->second >= 1e6){
				cout << itr->first << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n, i, j;
	while (cin >> n && n)
	{
		unsigned long long int no, t, num, sum[4000] = {0}, a[4000], f[4000] = {0};
		for (i = 0, j = 0; i < n; i++)
		{
			cin >> no >> t >> num;
			if (!f[no-1] && (sum[no-1] += t * num) >= 1000000)
			{
				a[j] = no;
				f[no-1] = 1;
				j++;
			}
		}
		if (j == 0)
			cout << "NA" << endl;
		else
			for (i = 0; i < j; i++)
				cout << a[i] << endl;
	}
	return 0;
}

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

struct tEmploy{
	int num;
	int sold;
	tEmploy(){
		num = -1;
		sold = 0;
	}
};

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

		emp = new tEmploy[n];
		for( int i=0; i<n; i++ ){
			int num, val, amo;
			cin >> num >> val >> amo;
			int j=0;
			for( ; j<n; j++ ){
				if( emp[j].num == num )	break;
			}
			if( j == n ){
				for( j=0; j<n; j++ ){
					if( emp[j].num == -1 ){
						emp[j].num = num;
						break;
					}
				}
			}
			emp[j].sold += val * amo;
		}

		bool exist = false;
		for( int i=0; (emp[i].num!=-1)&&(i<n); i++ ){
			cout << emp[i].num << endl;
			if( emp[i].sold >= 1000000 ){
				cout << emp[i].num << endl;
				exist = true;
			}
		}
		if( !exist ){
			cout << "NA" << endl;
		}

		delete[] emp;
		emp = 0;
	}
	
	return 0;
}

C++: #include<stdio.h>
int main(void){
	int n;
	long long int ban[4001],tan,suu;
	long long int bansum[4001],banf[4001],i;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=1;i<=4000;i++){
			bansum[i]=banf[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&ban[i],&tan,&suu);
			bansum[ban[i]]+=tan*suu;
		}
		int flg=0;
		for(i=0;i<n;i++){
			if(bansum[ban[i]]>=1000000 && banf[ban[i]]==0){
				printf("%d\n",ban[i]);
				banf[ban[i]]=1;
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    map<int,long long int>in;
    vector<int>in2;
    rep(i,n){
      int a;
      long long int b,c;
      cin>>a>>b>>c;
      if(in[a])in[a]+=b*c;
      else {in[a]+=b*c;in2.pb(a);}
    }
    bool han=false;
    rep(i,in2.size())if(in[in2[i]]>=1000000){han=true;cout<<in2[i]<<endl;}
    if(!han)cout<<"NA"<<endl;
  }
}

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;
    for(int i = 0;i < n;++i){
      int num,sa,ko;
      cin>>num;
      cin>>sa;
      cin>>ko;

      data.push_back(make_pair(num,sa * ko));
    }

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

  return 0;
}

C++: 
#include <iostream>
#include <vector>
#include <utility>

class employee {
public:
	int id;
	int p, q;
	bool more_than_million() {
		return (p * q >= 1000000);
	}
};

int n;
std::vector<employee> data;

void init()
{
	n = 0;
	data.clear();
}

bool get_input()
{
	init();
	std::cin >> n;
	if (n == 0) {
		return false;
	}
	for (int i = 0; i < n; i++) {
		employee tmp;
		std::cin >> tmp.id >> tmp.p >> tmp.q;
		data.push_back(tmp);
	}
	return true;
}

void solve()
{
    std::vector<employee>::iterator i = data.begin();
    std::vector<int> top_salers;
    while(i != data.end()){
       if((*i).more_than_million()){
    	   top_salers.push_back((*i).id);
        }
       i++;
     }
    if (top_salers.empty()) {
    	std::cout << " NA" << std::endl;
    } else {
    	for (std::vector<int>::iterator j = top_salers.begin(); j != top_salers.end(); j++) {
    		std::cout << (*j) << std::endl;
    	}
    }
}

int main()
{
	while (get_input()) {
		solve();
	}
	return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
map<int,ll> data;
int main(){
	int n;
	while(cin>>n,n){
		data.clear();
		std::vector<int> a;
		a.clear();
		rep(i, n){
			ll e,c,s;
			cin>>e>>c>>s;
			if(!data[e]){
				a.push_back(e);
				
			}
			data[e]+=(c*s);
		}
		bool flag =false;
		for(int i =0;i < a.size();i++){
			if(data[a[i]]>= 1000000){
				cout <<a[i]<<endl;
				flag =true;
			}
		}
		if(!flag){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long long n,a,b,c,f,i,s[4001];
while(cin>>n){
if(n==0)break;
for(i=1;i<=4000;i++)s[i]=0;
for(i=0;i<n;i++){
cin>>a>>b>>c;
if(s[a]<1000000)s[a]+=b*c;
}
f=0;
for(i=1;i<=4000;i++)
if(s[i]>=1000000){cout<<i<<endl;f=1;}
if(f==0)cout<<"NA"<<endl;
}
return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, long long int>mp;
		vector<int>vs;
		for (int i = 0; i < N; ++i) {
			long long int a, b, c; cin >> a >> b >> c;
			mp[a] += b*c;
			if (find(vs.begin(), vs.end(), a) == vs.end())vs.emplace_back(a);
		}
		bool flag = false;
		for (auto v : vs) {
			if (mp[v] >= 1000000) {
				cout << v << endl;
				flag = true;
			}
		}
		if (!flag)cout << "NA" << endl;
	}
	return 0;
}