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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int n;
	map<int, ll> result;
	vi check(4001, 0);
	vi ans;

	int ban, tan, suu;
	while(cin >> n, n) {
		ans.clear();
		result.clear();

		REP(i, n) {
			cin >> ban >> tan >> suu;

			if(!check[ban]) {
				if(!result[ban]) {
					result[ban] = tan*suu;
				} else {
					result[ban] += tan*suu;
				}

				if(result[ban] >= 1000000) {
					ans.push_back(ban);
					check[ban] = 1;

				}
			}
		}

		if(ans.size()) {
			REP(i, ans.size()) {
				cout << ans[i] << endl;
				check[ans[i]] = 0;
			}
		} else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<stdio.h>

int main(){
int N;
int n,m,p;
long P[4003][3]={};
long PT[4003][4]={};

while(1){
scanf("%d",&N);if(N==0)break;

for(int i=1;i<=N;i++){
scanf("%d %d %d",&n,&m,&p);
if(P[n][0]<1000000&&m*p<1000000)P[n][0]+=m*p;
if(m*p>=1000000)P[n][0]=1000000;
if(P[n][1]==0)P[n][1]=i;
}
int c=0;
for(int i=0;i<=4001;i++)
if(1000000<=P[i][0]){PT[c][0]=P[i][0];PT[c][1]=P[i][1];PT[c][2]=i;c++;}

for(int i=0;i<c;i++)
for(int j=c-1;j>i;j--)
if(PT[j][1]<PT[j-1][1])
{long TT=PT[j][1];PT[j][1]=PT[j-1][1];PT[j-1][1]=TT;
 long TTT=PT[j][2];PT[j][2]=PT[j-1][2];PT[j-1][2]=TTT;}

for(int i=0;i<c;i++)
printf("%ld\n",PT[i][2]);
if(c==0)printf("NA\n");
for(int i=0;i<=4001;i++)
{P[i][0]=0;P[i][1]=0;P[i][2]=0;
 PT[i][0]=0;PT[i][1]=0;PT[i][2]=0;PT[i][3]=0;}

}
return  0;
}

C++: #include<stdio.h>
int main()
{
	unsigned long int goukei[4001]={0},kazu,tanka;
	int n,i,j,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]);
				goukei[i]=0;
				g++;
			}
		}
		if(g==0)
		{
			printf("NA\n");
		}
		g=0;
	}
	
	return 0;
}

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

std::vector<int> staff;
bool search(int number);

int main()
{
	int n;
	while(1)
	{
		int number,price,amount;
		staff.clear();
		std::cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			std::cin>>number>>price>>amount;
			if(price*amount>=1000000)
			{
				if(search(number)==false)
				{
					staff.push_back(number);
				}
			}
		}
		if(staff.empty())
		{
			std::cout<<"NA"<<std::endl;
		}
		else
		{
			for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
			{
				std::cout<<*p<<std::endl;
			}
		}
	}
	return 0;
}

bool search(int number)
{
	for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
	{
		if(*p==number)return true;
	}
	return false;
}

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

int main(){
    long long n,num,mn,nm,mon;
    while(cin >> n,n){
        int c=0,sc[4001],cn=0,cc=0;
        map<int,long long> maps;
        for(int i=0;i<n;i++){
            int cnt=0,j=0;
            cin >> num >> mn >> nm;
            mon = mn*nm;
            maps[num] += mon;
            for(;j<c;j++){
                if(sc[j]==num)cn++;
            }
            if(cn==0||j==0){
                sc[c] = num;
                c++;
                //cout << sc[c] << endl;
            }
        }
        for(int i=0;i<c;i++){
            if(maps[sc[i]]>=1000000){
                cout << sc[i] << endl;
                cc++;
            }
        }
        if(cc==0) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<cstdio>

int main(){
int a;
unsigned long int b,c;
while(1){
 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%d",&b);
 scanf("%d",&c);
if(a*c>=1000000) printf("%d\n",a);
}
}

C++: #include<stdio.h>
int main(void)
{
	struct employee
	{
		int N,P,A;
	};
	employee person[10][4000];
	int a,b=0,c[10],d,e;
	for(d=0;;b=0,d++)
	{
		scanf("%d",&c[d]);
		if(c[d]==0)
		{
			e=d;
			break;
		}
		for(a=0;a<c[d];a++)
			scanf("%d %d %d",&person[d][a].N,&person[d][a].P,&person[d][a].A);/
	}
	for(d=0;d<=e;b=0,d++)
	{
		for(a=0;a<c[d];a++)
			if(person[d][a].P*person[d][a].A>=1000000 )
			{
				printf("%d\n",person[d][a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
}

C++: //#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;
void shoki();
void henkan(string);
void shoki2();
int tansaku(int);
pair<string,long long> num[10000];
int n,ban,tanka,kazu,i,j,memo;
bool dp[10000]={false};
int main(){
	int al=0;
	bool y=false;
	while(1){
		shoki();
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>num[i].first>>tanka>>kazu;
			henkan(num[i].first);
			if(dp[memo]==true){
				num[tansaku(i)].second+=tanka*kazu;
			}
			else{
			num[i].second+=tanka*kazu;
			}
			dp[memo]=true;
			memo=0;
		}
		for(int k=0;k<=i;k++){
			if(num[k].second==0){
				continue;
			}
			if(num[k].second>=1000000){
				y=true;
				cout<<num[k].first<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
		shoki2();
	}
	return 0;
}
void shoki(){
	for(int i=0;i<4001;i++){
		num[i].first="0";
		num[i].second=0;
	}
	return;
}
void henkan(string str1){
	long long kake=1;
	for(int i=0;i<str1.size();i++){
		memo+=str1[i]*i;
		i*=10;
	}
	return;
}
int tansaku(int rec){
	int res;
	for(int l=0;l<rec;l++){
		if(num[rec].first==num[l].first){
			return res=l;
		}
	}
}
void shoki2(){
	for(int i=0;i<10000;i++){
		dp[i]=0;
	}
	return;
}