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 <stdio.h>
 
 	int i,j,k;
	int n,num[4000];
	long long int tanka,sale_num,sale_sum[4000],sale_all[4001];
	bool judge[4001];

 
int main(void){

	
	while(scanf("%d",&n),n){
		
		//初期化


		
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka,&sale_num);
			sale_sum[i]=tanka*sale_num;
		}

		k=0;
		for(j=0;j<4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[i]] = sale_all[num[i]] + sale_sum[i];
		}
		
		for(i=0;i<n;i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		
		if(k!=1)printf("NA\n");
	}
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a,b,c,d;
	int num[4001],tan[4001],ans[4001];
	bool flag=false;
	while(1){
		for(a=0;a<=4000;a++){
			num[a]=0;
			tan[a]=0;
			ans[a]=0;
		}
		flag=false;
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			cin >> b >> c >> d;
			num[b]=c,tan[b]=d;
			if(num[b]*tan[b]>ans[b])ans[b]=num[b]*tan[b];
		}
		for(a=1;a<4000;a++){
			if(ans[a]>=1000000)printf("%d\n",a),flag=true;
		}
		if(flag==false)printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <stdlib.h>
#include <map>
using namespace std;
ifstream fin("D:\\txt.txt");
#define for0(i,n) for (i=0;i<n;i++)
map<int,int> data;
#define MV(a,b) map<int,int>::value_type(a,b) 

int main()
{
	int n,a,b,c,i,j;
	while(cin>>n)
	{
		data.clear();
		if(!n)break;
		for0(i,n)
		{
			cin>>a>>b>>c;
			c*=b;
			if (data.find(a)==data.end())
			{
				data.insert(MV(a,c));
			}
			else
			{
				data[a]+=c;
			}
		}

		map<int,int>::iterator it=data.begin();
		bool bo=true;
		while(it!=data.end())
		{
			if (1000000<=it->second)
			{
				cout<<it->first<<endl;
				bo=false;
			}
			it++;
		}
		if (bo)
		{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}//*/

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

int main()
{
	int n,t2,t3;
	while(cin >> n && n)
	{
		unsigned long long int total[n][2];
		bool flag=false;
		for(int i=0;i<n;i++)
		{
			cin >> total[i][1] >> t2 >> t3;
			total[i][0] = t2*t3;
		}
		
		for(int i=0;i<n;i++)
		{
			if(total[i][0]>=1000000)
			{
				cout << total[i][1] << endl;
				flag=true;
			}
		}
		if(!flag)cout << "NA" << endl;
	}
}

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

#define MAX_EMPLOYEE 4000

int main()
{
        
        while(1){
                int n;
                cin >> n;
                if(!n) break;

                double salesOfEmployee[MAX_EMPLOYEE+1];
                for(int i=0; i<=MAX_EMPLOYEE; i++) salesOfEmployee[i]=0;
                
                int id;
                double price, quantity;
                for(int i=0; i<n; i++){
                        cin >> id >> price >> quantity;
                        salesOfEmployee[id] += price*quantity;
                }
                
                int flag = 0;
                for(int i=1; i<=MAX_EMPLOYEE; i++){
                        if( salesOfEmployee[i] >= 1000000 ){
                                cout << i << endl;
                                flag = 1;
                        }
                }
                if( !flag ) cout << "NA\n";
        }

        return 0;
}

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

using namespace std;

int main() {
    int n, e, p, q;
    vector< pair<int, unsigned long long> > data;
    vector< pair<int, unsigned long long> >::iterator it;

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

        data.clear();
        for (int i=0; i<n; i++) {
            cin >> e >> p >> q;

            it = data.begin();
            while (it != data.end()) {
                if(e == it->first) {
                    it->second += (unsigned long long)(p * q);
                    break;
                }
                it++;
            }
            
            if(it == data.end()) data.push_back(make_pair(e, (unsigned long long)(p * q)));
        }

        it = data.begin();
        bool isoutput = false;
        while (it != data.end()) {
            if(it->second >= 1000000) {
                cout << it->first << endl;
                isoutput = true;
            }
            it++;
        }
        if(!isoutput) cout << "NA" << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
 
int main(){
	int N,A[100000],B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		bool NAflag=true,used[4001];
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("\t%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("\tNA");
	}
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n, a, b, c;
    while(true){
        scanf("%lld", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%lld%lld%lld", &a, &b, &c);
            if(b*c>=1000000){
                na = false;
                printf("%lld\n", &a);
            }
        }
        if(na) puts("NA");
    }
}

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

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        unsigned long long int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        int t,cost;
        int num;
        for(int i = 0 ; i < n ; i++){
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
        
        for(int i = 0 ; i < n ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(gs[i]==gs[j]&&i < j){
                    s[gs[i]] += s[j];
                    gs[j] = 4001;
                }
            }
        }
        for(int i = 0 ; i < n ; i++){
            if(s[gs[i]] >= 1000000){
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if(!cnt) cout << "NA" << endl;
    }
    
    return 0;
}