Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{	
	int n;
	scd(n);
	LL a,b;
	string c;	
	while(n!=0)
	{
		vector<string> e;
		map<string,LL> d;
		int fl=0;
		forin(i,0,n)
		{
			cin>>c>>a>>b;
			fl=0;
			forin(i,0,e.size())
			{
				if(e[i]==c)
				{
					fl=1;
					break;
				}
			}
			if(fl==0)
			e.pb(c);
			
			d[c]+=a*b;
		}
		fl=0;
		int size=e.size();
		forin(i,0,size)
		{
			if(d[e[i]]>=1000000)
			{
				fl=1;
				cout<<e[i]<<endl;
			}
		}
		
		if(fl==0)
		printf("NA\n");
		
		
		scd(n);
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#define X 4001
#define V 1000000
using namespace std;

int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		long a[X];
		int f[X];
		for(int i=0;i<X;i++) a[i] = 0;
		for(int i=0;i<X;i++) f[i] = 0;
		int b;
		long c,d;
		int s = 0;
		for(int i=0;i<n;i++){
			cin >> b >> c >> d;
			if(a[b]<V) a[b] += c*d;
			if(f[b]==0){
				s++;
				f[b] = s;
			}
		}
		bool e = true;
		for(int i=1;i<X;i++){
			for(int j=0;j<X;j++){
				if(f[j]!=i) continue;
				if(a[j]>=V){
					e = false;
					cout << j << endl;
				}
				break;
			}
		}
		if(e) cout << "NA" << endl;
	}
}

C++: #include <iostream>
using namespace std;
typedef struct{
	int number;
	long long sales;
} staff;

int main(void)
{
	int n;
	while(cin>>n){
		if(!n) break;
		staff staff1[4001];
		for(int i=0; i< n; i++){
			cin >> staff1[i].number;
			long price;
			int bnum;
			cin >> price >> bnum;
			staff1[i].sales = price * bnum;
		}
		int count = 0;
		for(int i=0; i < n; i++){
			if(staff1[i].sales >= 1000000){
				count++;
				cout << staff1[i].number << endl;
			}
		}
		if(!count) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;
    while(cin>>n){
    if(n==0)return 0;
    vector<pair<int,ll> > v;
    bool f=true;
    rep(i,0,n){
        int num;
        ll a,b;
        scanf("%d %lld %lld",&num,&a,&b);
        if(i==0)v.pb(mp(num,a*b));
        else {
            bool judge=true;
            rep(j,0,v.size()){
                if(num==v[j].fi) {
                    judge=false;
                    v[j].se+=a*b;
                }
            }
            if(judge)v.pb(mp(num,a*b));
        }
    }
    
    rep(i,0,v.size()){
        if(v[i].se>=1e6){
            cout<<v[i].fi<<endl;
            f=false;   
        }
    }
    if(f)cout<<"NA"<<endl;
    }
    
    return 0;
}

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

int main()
{
	array<int, 4000> ar = {};
	vector<int> ans;
	int n,e,p,q;
	
	while (true) {
		cin >> n;
		ar.fill(0);
		if (!n) {
			break;
		}

		bool isNA = true;
		for (int i = 0; i < n; ++i) {
			cin >> e >> p >> q;
			ar[e] += p*q;
		}
		for (int i = 0; i < 4000;++i) {
			if (ar[i] >= 1000000) {
				ans.push_back(i);
				isNA = false;
			}
		}
		if (isNA) {
			ans.push_back(-1);
		}

	}

	for (auto it : ans) {
		if (it != -1) {
			cout << it;
		}
		else {
			cout << "NA";
		}

		if (it != *ans.end()) {
			cout << endl;
		}
	}
	return 0;
}

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(shineI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  shineI[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<stdio.h>
//#include<stdlib.h>
//#include<time.h>

struct staff_data{
	int num,price,volume;
	unsigned long long int total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	/*srand((unsigned)time(NULL));*/
	
	while(scanf("%d",&n)!=0){
	
		if(n==0){
			break;
		}
		
		for(i=0;i<4000;i++){
			dt[i].num=0;
			dt[i].price=0;
			dt[i].total=0;
			dt[i].volume=0;
		}
		
		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			/*num=rand()%4000;
			price=rand()%1000000;
			volume=rand()%100000;
			printf("%5d %5d %5d ||",num,price,volume);*/
			
			for(j=0;j<=i;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					dt[j].num=num;
					dt[j].total=(price)*(volume)+dt[j].total;
					/*printf("num==%5d total==%d\n",dt[j].num,dt[j].total);*/
					break;
				}
				
			}
		}

		hantei=0;

		for(j=0;j<n;j++){
		
			if(dt[j].total>=1000000){
				printf("%d\n",dt[j].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}