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*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	int n;
	int num[4000];
	bool appear[4001];
	int howmany;
	int number;
	long long int in_price;
	long long int in_sales;
	long long int price[4001];
	long long int sales[4001];
	/*****処理部*****/
	while(1){
		for(int i=0;i<4001;i++){
			if(i < 4001)	num[i] = 0;
			appear[i] = false;
			price[i] = 0;
			sales[i] = 0;
		}
		howmany = 0;
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> number;
			cin >> in_price;
			cin >> in_sales;
			price[number] += in_price;
			sales[number] += in_sales;
			if(!appear[number])	num[i] = number;
			appear[number] = true;
		}
		for(int i=0;i<n;i++){
			if(num[i] != 0){
				if(price[num[i]] * sales[num[i]] >= 1000000){
					cout << num[i] << endl;
					howmany++;
				}
				//cout << num[i] << " " << price[num[i]] << " " << sales[num[i]] << endl;
			}
		}
		if(howmany == 0)	cout << "NA" << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct{
    int id;
    int cost;
    int amount;
    int sum;
}employee;

int main(){
    employee getinp;
    int n;
    while(cin >> n,n){
        vector<employee> emps;
        for (int i=0;i<n;i++){
            cin >> getinp.id >> getinp.cost >> getinp.amount;
            getinp.sum=getinp.cost*getinp.amount;
            if(emps.empty()) emps.push_back(getinp);
            else{
                for(int j=0;j<emps.size();j++){
                    if(emps[j].id==getinp.id) {
                        emps[j].sum+=getinp.sum;
                        break;
                    }else if(j==emps.size()-1){
                        emps.push_back(getinp);
                        break;
                    }
                }
            }
        }
        int* ids=new int[emps.size()];
        int j=0;
        for (int i=0;i<emps.size();i++){
            if (emps[i].sum>=1000000){
                ids[j]=emps[i].id;
                j++;
            }
        }
        sort(ids,ids+j);
        if(j==0) cout << "NA" << endl;
        else{
            for(int i=0;i<j;i++){
                cout<<ids[i]<<endl;
            }
        }
        delete ids;
    }
    return 0;
}

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

int main()
{
	while ( true )
	{
		int n; cin>>n;
		if ( n == 0 )
			break;
		vector<pair<int,long long> > E;

		for ( int i=0; i<n; i++ )
		{
			int a, b, c;
			cin>>a>>b>>c;
			int j;
			for ( j=0; j<(int)E.size(); j++ )
				if ( E[j].first==a )
					break;
			if ( j==(int)E.size() )
				E.push_back( make_pair(a,0ll) );
			E[j].second += b*c;
		}
		bool f = false;
		for ( int i=0; i<(int)E.size(); i++ )
			if ( E[i].second >= 1000000 )
				cout << E[i].first << endl,
				f = true;
		if ( ! f )
			cout << "NA" << endl;
	}
}

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

int main(){
	int n;
	while( cin >> n, n ){
		map<int, long long> worker;
		queue<int> order;
		for( int i = 0; i < n; i++ ){
			int id, price, num;
			cin >> id >> price >> num;
			if( worker.find(id) == worker.end() ){
				order.push(id);
			}
			worker[id] += (price * num);
		}
		bool flag = true;
		while( !order.empty() ){
			if( worker[order.front()] >= 1000000 ){
				cout << order.front() << endl;
				flag = false;
			}
			order.pop();
		}
		if( flag ){
			cout << "NA" << endl;
		}
	}
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){	
	int n;
	while(cin>>n){
	      if(n==0) break;
	      vector<int> a;
	      vector<long long> b;
	      vector<long long> c;
	      int x,y,z;
	      map <int,long long> sum;
	      for(int i=0;i<n;i++){
		cin>>x>>y>>z;
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
		sum[x]+=y*z;
	       }
	       int cnt=0;
	       for(int i=0;i<n;i++){
                     if(sum[a[i]]>=1000000){
			   int cnt2=0;
                           for(int j=0;j<i;j++){
				if(a[i]==a[j]) cnt2++;break;}
                            if(cnt2>0) continue;
                            else{   
				cout<<a[i]<<endl;
				cnt++;}
		     }
		}
		if(cnt==0) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int i,j,k,l;
    int n;
    long long id,cost,qty;
    long long data_list[10000];
    int id_list[10000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        fill(data_list,data_list+4000,0);
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(cost*qty);
            cin>>id>>cost>>qty;
            id_flag=true;
            for(i=0;i<=k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

C++: #include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
int main(){
  int n,val,num,inindex;
  vector<int> Index;
  map<int,long long> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    List.clear();
    Index.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(!List[inindex]){
	Index.push_back(inindex);
      }
      List[inindex]+=val*num;
    }
    bool NAf=true;
    for(int i=0;i<Index.size();i++){
      if(List[Index[i]] >= 1000000){
	printf("%d\n",Index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}

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

std::vector<std::string> split(std::string ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(cin,str);
ref=split(str," ");
if(std::stoi(ref[1])*std::stoi(ref[2])>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}