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>
#include <map>
#include <list>
#include <cmath>
using namespace std;

struct staff {
	int num;
	int price;
	int quan;
	int total;
};

int main()
{
	int num, i, k, j, datas;
	int sn, sp, sq;
	map<int, staff> staffs[4000];

	datas = 0;
	while(1)
	{
		cin >> num; if(num == 0) break;

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[datas][sn].num = sn;
			staffs[datas][sn].price = sp;
			staffs[datas][sn].quan = sq;
			staffs[datas][sn].total += staffs[datas][sn].price * staffs[datas][sn].quan;
		}
		datas++;
	}
	map<int, staff>::iterator staffs_it;
	for(i = 0; i < datas; i++)
	{
		staffs_it = staffs[i].begin();
		int over = 0;

		while(staffs_it != staffs[i].end())
		{
			if(staffs[i][(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[i][(*staffs_it).first].num << endl;
				over++;
			}
			staffs_it++;
		}
		if(over == 0) cout << "NA" << endl;
	}
}

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,0) );
			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<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int N = 4000;
int n;
ll cost[N+1];
int id;
ll dc, dn;
ll res[N];

int main()
{
  while((cin >> n) && n){
    bool flag = true;
    rep(i, N+1) cost[i] = 0LL;
    int ptr = 0;

    rep(i, n){
      cin >> id >> dc >> dn;
      if(!cost[id]) res[ptr++] = id;
      cost[id] += dc * dn;
    }

    rep(i, ptr) if(cost[res[i]] >= 1000000){
      flag = false;
      cout << res[i] << endl;
    }
    if(flag) puts("NA");
  }

  return 0;
}

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;
	vector<tuple<string,LL,LL>> d;
	while(n!=0)
	{
		d.clear();
		int fl=0;
		forin(i,0,n)
		{
			cin>>c;
			scdlld(a,b);
			d.pb(make_tuple(c,a,b));
		}
		sort(d.begin(),d.end());
		
		int size=d.size();
		LL z=0;
		int l=0;
		int flag;
		for(int i=0 ; i<size ; i++)
		{
			flag=0;
			a=get<1>(d[i])*get<2>(d[i]);
			for(int j=i+1 ; j<size ; j++)
			{
				if(get<0>(d[i])==get<0>(d[j]))
				{
					l=j;
					flag=1;	
					a+=get<1>(d[j])*get<2>(d[j]);
				}
				else
				break;
			}
			//cout<<get<0>(d[i])<<"---"<<i<<endl;
			
			if(a>=1000000)
			{
				cout<<get<0>(d[i])<<endl;
				fl=1;
			}
			
			if(flag==1)
			{
				i+=l;
				//cout<<get<0>(d[i])<<"--"<<i<<endl;
			}
			
			

		}
		
		if(fl==0)
		printf("NA\n");
		
		
		scd(n);
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main(){
  double n ,flag=0 ,num[4001] ,price[4001] ,earnings[4001] ,total[4001] ,overlap;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    for( int i=0 ; i<n ; i++ ){ // ??\?????¨????¨?????¨????
      cin >> num[i] >> price[i] >> earnings[i];
      total[i] = price[i] * earnings[i];
    }
 
    for( int i=0 ; i<n ; i++ ){ // ??????????????????
      overlap = num[i]; // ????????????????????????
      for( int j=0 ; j<n ; j++ ){
    if( num[j] == overlap && i != j ){ // ???????????????
      total[i] += total[j];
      num[j] = -1;
      total[j] = 0;
    }
      }
    }
 
    for( int i=0 ; i<n ; i++ ){ // ??????
      if( total[i] >= 1000000 ){
    cout << num[i] << endl;
    flag = 1;
      }
    }
 
    if( flag == 0 ){ // ???????????£??????
      cout << "NA" << endl;
    }
    flag = 0;
  }
}

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

int main(){
  int n;//データ数
  while(cin >> n){
    int arr[4000];//社員番号
    int selling[n];//販売単科
    int sales[n];//売り上げ数量
    int num;
    int check=0;
    //社員は4000人未満
    memset(arr,0,sizeof(arr));
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin >> num >> selling[i] >> sales[i];
      arr[num]+=selling[i]*sales[i];
      if(arr[num]>=1000000){
        cout << num << endl;
        check++;
      }
    }
    if(check==0)
      cout << "NA" << endl;
    check=0;
  }
}