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>
#include <stdbool.h>

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4001] = {};
    long long unit_sale_num[4001] = {};
    long long sale_num[4001] = {};
    
    while (scanf("%d", &data_num)) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &unit_sale_num[i],  &sale_num[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    sale_num[data_check] += sale_num[i];
                    unit_sale_num[data_check] += unit_sale_num[i];
                    data_num_update--;
                }
            }
            data_check++;
        }
        
        bool result_flag = true;
        
        for (int i = 0; i < data_num_update; ++i) {
            if (unit_sale_num[i] * sale_num[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c;
  while(cin >> n){
    if(n == 0) break;
    set<int> s;
    vary(pii,v,4001,make_pair(0,0));
    vary(ll,v2,4001,0);
    int cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(s.insert(a).se){
        ++cnt;
        v[a].se = cnt;
        v[a].fi = a;
      }
      if(v2[a] < 1000000){
        if(b * c >= 1000000 || v2[a] + b*c >= 1000000){
          v2[a] = 1000000;
        }
        else
          v2[a] += b * c;
      }
    }
    sort(all(v),[](const pii &p,const pii &p2){return p.se < p2.se;});
    bool f = false;
    REP(i,1,4001){
      if(v2[v[i].fi] >= 1000000){
        cout << v[i].fi<<endl;
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,cnt,b,t,c,s,f;
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		cnt=0;
		vector<pii> v;
		rep(i,n){
			scanf("%d%d%d",&b,&t,&c);
			s=v.size();
			f=1;
			rep(i,s)if(v[i].first==b){
				v[i].second += t*c;
				f=0;
			}
			if(f)v.push_back(pii(b,t*c));
		}
		s=v.size();
		rep(i,s)if(v[i].second >= 1000000){
			printf("%d\n",v[i].first);
			cnt++;
		}
		if(cnt==0)puts("NA");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][4000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<4000; i++) data[0][i]=0,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i;f++){
	if(data[0][f]==id){
	  data[1][f]+=a*b;
	  break;
	}
	if(f==i-1) data[0][i]=id,data[1][i]=a*b;
      }
      if(i==0)data[0][i]=id;data[1][i]=a*b;
    }

    for(i=0,f=0;i<n;i++)
      if(data[1][i]>999999)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){

        int mem[4500] = {0};
        int a,x,y;
        int xx = 0;

        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&a,&x,&y);
            mem[a] += x*y;
            if(xx < a)xx = a;
        }
        bool flg = 0;
        for(int i = 1;i <= xx; i++){
            if(mem[i] >= 1000000){
                printf("%d\n",i);
                flg = 1;
            }
        }
        if(flg == 0)printf("NA\n");
    }
    return 0;
}

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

int main(){
    int n;
    long int array[n][3];
    int count=0;

    cin>>n;

    if(n==0) goto Exit;
    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[i+j][1]=0;
                array[i+j][2]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]>=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }

    Exit;

    if(count==0){
        cout<<"NA\n";
    }
}

C++: #include <iostream>


using namespace std;
class MAN{
public:
	long long uriage;
	short number;
};

int main(int argc, char const* argv[])
{
	MAN *person;
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		person  = new MAN[n];
		for( int i = 0;i < n;i++ ){
			int target;
			int a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
		delete[] person;
	}

	return 0;
}