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>
using namespace std;

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
int shineI[SHINE_MAX]	//??????????????????
long int shineU[SHINE_MAX];	//?£??????????

int dataN,num,tanka,suryo;
int i,j;

int main(){
while(1){
	//??\???
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 //???????????????????????????????????¨??????????????????
	 for(i=0;i<shineN;i++){
	  if(enemyI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  enemyI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	//??????
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
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<long,long> data;
#define MV(a,b) map<long,long>::value_type(a,b) 

int main()
{
	int n,a,b,c,i,j;
        bool bo;
	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<long,long>::iterator it=data.begin();
		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>
#include<map>
using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        map<long,long long>m;
        int i,p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            m[i]+=p*q;
        }
        for (map<long,long long>::iterator it=m.begin(); it!=m.end(); ++it){
            if(it->second>=1000000){
                s=1;
                cout<<it->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;
ll amount;

const ll MAX = 1000000;

int main(void) {
    while(~scanf("%d", &n)) {
        if(n == 0) break;
        vector<int> ans;
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d", &id, &p, &q);
            amount = p*q;
            if(amount >= MAX) {
                ans.push_back(id);
            }
        }
        if(ans.empty()) {
            printf("NA\n");
        } else {
            for(int i = 0; i < (int) ans.size(); i++) {
                printf("%d\n", ans[i]);
            }
        }
    }
    return 0;
}

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

int main(){
    long long size, id, price, quantity;
    double p, q;
    bool noone = true;
    while (1){
	cin >> size;
	if (!size) break;
	for (int i = 0; i < size; i++){
	    cin >> id >> price >> quantity;
	    p = (double) price/100;
	    q = (double) quantity/100;
	    if (p * q >= 100){
		cout << id << endl;
		noone = false;
	    }
	}
	if (noone) cout << "NA" << endl;
	noone = true;
    }
}

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

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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<pair<int,int> > v;
		int info[4001];
		bool appeared[4001];
		fill(info,info+4001,0);
		fill(appeared,appeared+4001,false);
		vector<int> numList;
		for(int i = 0; i < n; i++){
			int num;
			int val;
			int ko;
			cin>>num>>val>>ko;
			if(!appeared[num]){
				appeared[num]=true;
				numList.push_back(num);
			}

			info[num]+=val*ko;
		}

		bool f=false;
		for(int i = 0; i < numList.size(); i++){
			if(info[numList[i]]>=1000000){
				cout<<numList[i]<<endl;
				f=true;
			}
		}
		if(!f)
			cout<<"NA"<<endl;
	}

	return 0;
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		map<int, long long> data;
		map<int, int> seq;
		for (int i = 0; i < n; ++i) {
			int bangou;
			long long tanka, kazu;
			cin >> bangou >> tanka >> kazu;
			if (data.find(bangou) == data.end()) {
				data[bangou] = 0;
				seq[bangou] = i;
			}
			if (data[bangou] < 1000000)
				data[bangou] += tanka * kazu;
		}
		vector<pair<int, int> > v;
		for (map<int, long long>::iterator it = data.begin(); it != data.end(); ++it)
			if (it->second >= 1000000)
				v.push_back(make_pair(seq[it->first], it->first));
		if (v.empty())
			cout << "NA" << endl;
		else {
			sort(v.begin(), v.end());
			for (int i = 0; i < v.size(); ++i) cout << v[i].second << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(void){
	int n;
	while(cin >> n,n){
		int list[4001]={0};
		int a,b,c;
		for(int i=0;i<n;i++){
			cin >> a >> b >> c;
			list[a]+=b*c;
		}
		bool check=true;
		for(int i=1;i<=4000;i++)
			if(list[i]>=1000000)
				cout << i << endl,check=false;
		if(check)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;

    Mem() {}
    Mem(int _id, ll _c) { id = _id; _c = c; }
};

Mem array[40010];

int main(void) {
    while(cin >> n && n) {
        for(int i = 0; i < n; i++) {
            cin >> array[i].id >> p >> q;
            array[i].c = p * q;
        }
        for(int i = 0; i < n - 1; i++) {
            for(int j = i + 1; j < n; j++) {
                if(array[i].id == array[j].id && array[j].id) {
                    array[i].c += array[j].c;
                    array[j].id = 0;
                }
            }
        }
        bool hap = false;
        for(int i = 0; i < n; i++) {
            if(array[i].id && array[i].c >= MAX) {
                cout << array[i].id << endl;
                hap = true;
            }
        }
        if(!hap) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: //AOJ0100
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long 
int main(){
	int n;
	while(cin>>n,n!=0){
vector< pair<int,__int64> >ta;
ta.clear();
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
bool f=0;
int index=0;
for(int j=0;j<ta.size();j++)if(ta[j].first==a)f=1,index=j;
if(f==0)ta.push_back(pair<int,__int64>(a,b*c));
else ta[index].second+=b*c;
}
bool f=0;
for(int i=0;i<ta.size();i++){
	cout<<ta[i].first<<"   "<<ta[i].second<<endl;
	if(ta[i].second>=1000000){cout<<ta[i].first<<endl;;f=1;}
}
	if(!f)cout<<"NA"<<endl;
}
	return 0;
}