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 <vector>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define p 1000000 

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);


	while(1){
		long long int n,tmp[3],cnt = 0;
		vector<long long int> number;
		vector<long long int> sales;
		vector<long long int> flg;
		cin >> n;
		if(n == 0) break;
		for(int i=0; i<4000; i++) {
			sales.push_back(0); 
			flg.push_back(0);
		}
		for(int i=0; i<n; i++) {
			cin >> tmp[0] >> tmp[1] >> tmp[2];
			sales.at(tmp[0]) += tmp[1]*tmp[2];
			if(flg.at(tmp[0]) == 1) continue;
			number.push_back(tmp[0]);
			flg.at(tmp[0]) = 1;
		}
		for(int i=0; i<number.size(); i++) {
			if(sales.at(number.at(i)) >= p) {
				cout << number.at(i) << endl;
				cnt++;
			}
		}
		if(cnt == 0) {
			cout << "NA" << endl;
		} 
	}

	//while(1){}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, i;
    long long int p, q;
    map<int, long long int> emp;
    vector<int> seq;
    while(cin >> n && n) {
        bool isExist = false;
        emp.clear();
        seq.clear();
        rep(l, n) {
            cin >> i >> p >> q;
            if(!emp[i]) seq.push_back(i);
            emp[i]+=p*q;
        }
        rep(i, seq.size()) {
            if(emp[seq[i]] >= 1000000) {
                cout << seq[i] << endl;
                isExist = true;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

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

int main()
{
	int n;
	int ans[4000];
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			int num[4000];
			int flag=1;
			double a[4000],b[4000];
			double ans_max[4000];
			
			cin >> num[i] >> a[i] >> b[i] ;
			ans_max[i]=a[i]/10000.0*b[i];
			for(int l=i-1;l>=0;l--)
			{
				if(num[l]==num[i])
				{
//					cout << "in" << endl;
					ans_max[i]+=ans_max[l];
					break;
				}
			}
			
//			cout << "ans_max[" << i << "]:" << ans_max[i] << " num:" << num[i] << endl;
			
			if(ans_max[i]>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num[i])
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num[i];
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

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

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,cost,qty;
    long long data_list[5000];
    int id_list[5000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        memset(data_list,0,sizeof(data_list));
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(cost*qty);
            cin>>id>>cost>>qty;
            id_flag=true;
            for(i=0;i<=k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void shoki();
	vector<long long> num(4001,0);
	int n,ban,tanka,kazu,i,j;
int main(){
	
	bool y=false;
	for(j=0;j<50;j++){
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>ban>>tanka>>kazu;
			num[ban]+=tanka*kazu;
		}
		//sort(num.begin(),num.end());
		for(int k=0;k<4001;k++){
			if(num[k]==0){
				continue;
			}
			if(num[k]>=1000000){
				y=true;
				cout<<k<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
	}
	
	return 0;
}
void shoki(){
	for(int i=0;i<4000;i++){
		num[i]=0;
	}
}

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

struct data{
	int id;
	int value;
	int num;
};

int main(){
	int n;
	int need;
	int officer[4000];
	while(cin >> n){
		if(n == 0) break;
		int count = 0;
		for(int i = 0; i < n; i++){
			data d;
			cin >> d.id >>
				d.value >> d.num;
			if(d.value > 0){
				need = 1000000 % d.value == 0 ? 1000000 / d.value : 1000000 / d.value + 1;
				if(d.num >= need){
					count++;
					officer[count] = d.id;
				}
			}
		}
		if(!count){
			cout << "NA" << endl;
		} else {
			for(int i = 1; i <= count; i++)
				cout << officer[i] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int n;
    while(cin >> n, n){
        map<ll, ll> mp;
        vector<ll> v;
        for(int i=0; i<n; ++i){
            ll e, p, q; cin >> e >> p >> q;
            mp[e]+=p*q;
            v.push_back(e);
        }
        
        bool check[4010];
        for(int i=0; i<4010; ++i) check[i]=false;
        int cnt=0;
        for(int i=0; i<v.size(); ++i){
            if(mp[v[i]]>=1000000&&!check[v[i]]) {
                cnt++;
                cout << v[i] << endl;
                check[v[i]]=true;
            }
        }
        if(cnt==0) cout << "NA" << endl;
    }
    
    
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int number[n];
    bool useN[n];
    long long int total[4000];
    for (int i = 0; i < n; i++) {
      number[n] = 0;
      useN[n] = true;
    }
    for (int i = 0; i < 4000; i++) total[i] = 0;
    
    for (int i = 0; i < n; i++) {
      int a;
      long long int b,c;
      cin >> a >> b >> c;
      number[i] = a;
      for (int j = 0; j < i; j++) {
	if (number[j] == a) {
	  useN[i] = false;
	  break;
	}
      }
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < n; i++) {
      if ( useN[i] && total[number[i]-1] >= 1000000) {
	cout << number[i] << endl;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}