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
//------------------------------------------
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n)  FOR(i,0,n)

//conversion
//------------------------------------------
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();}

//debug
//-------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(1) {
        cin >> n;
        if (!n) break;
        int c = 0;
        long long data[4001] = {0};
        REP(i, n) {
            int e;
            long long p, q;
            cin  >> e >> p >> q;

            if (data[e] < 1000000 && data[e] + p * q >= 1000000) {
                cout << e << endl;
                ++c;
            }
            data[e] += p * q;
        }
        if (!c) cout << "NA" << endl;
    }
    return 0;
}

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

int main()
{
	int n = 0;				//  社員の人数;n==0で終了
	bool flag = true;		//  flagはidの重複を確認する
	int id_temp,price_temp,amount_temp;
	vector<int> id;			//  社員のid
	vector<int> price;		//  the corresponding unit price
	vector<int> amount;		//  the amount of sales
	vector<int> result;		//  条件を満たすid郡

	while(true) {
		cin >> n;
		if(n<0) {
			cout << "Error; n must be larger than 0";
			return -1;
		}
		else if(n==0)
			break;
		else {
			result.clear();
			id.clear();
			price.clear();
			amount.clear();
			for(int i=0;i<n;i++) {
				cin >> id_temp >> price_temp >> amount_temp;
				flag = true;
				for(int j=0;j<id.size();j++)
					if(id_temp==id[j]) {
						price[j] += price_temp;
						amount[j] += amount_temp;
						flag = false;
						break;
					}
				if(flag) {
					id.push_back(id_temp);
					price.push_back(price_temp);
					amount.push_back(amount_temp);
				}
			}

			for(int i=0;i<n;i++) 
				if(price[i]*amount[i]>=1000000)
					result.push_back(id[i]);
			
			if(result.size()==0)
				cout << "NA" << '\n';
			else
				for(int i=0;i<result.size();i++)
					cout << result[i] << '\n';
		}
	}

	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void) {
    int n;
    int employees[4000] = {0};
    while (1) {
        scanf("%d", &n);
        if (!n) break;

        for (int i = 0; i < n; i++) {
            int id, price, sales;
            scanf("%d %d %d", &id, &price, &sales);
            employees[id] += price * sales;
        }

        int found = 0;
        for (int i = 0; i < 4000; i++) {
            if (employees[i] >= 1000000) {
                printf("%d\n", i);
                found = 1;
            }
        }
        memset(employees, 0, sizeof employees);
        if (!found) {
            printf("NA\n");
        }

    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
long long sum[10000];
int main(){
    int a[10000];
    long long int n, b, c;
    while(true){
        scanf("%lld", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%d%lld%lld", &a[i], &b, &c);
            sum[a] += b*c;
            /*if(b*c>=1000000){
                na = false;
                printf("%lld\n", a);
            }*/
        }
        for(int i = 0; i < n; i++){
            if(sum[a[i]] >= 1000000){
                na = false;
                printf("%lld\n", a);
            }
        }
        
        if(na) puts("NA");
    }
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int find(vector<pair<int,long long> > &in,int n){
	for(int i=0;i<in.size();++i){
		if(in[i].first==n) return i;
	}
	return -1;
}
int main(){
	int n,num,price,amount;
	while(cin>>n&&n){
		vector<pair<int,long long> > v;
		while(n--){
			cin>>num>>price>>amount;
			if(find(v,num)!=-1) v[find(v,num)].second+=(long long)price*amount;
			else v.push_back(make_pair(num,(long long)price*amount));
		}
		bool f=false;
		for(vector<pair<int,long long> >::iterator it=v.begin();it<v.end();++it){
			if((*it).second>=1000000){
				cout<<(*it).first<<"\n";
				f=true;
			}
		}
		if(!f) cout<<"NA\n";
	}
	return 0;
}

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

const int lim = 1000000;

int main()
{
    int n; long long en, price, qty;

    while(cin >> n && n) {
        if (n == 0) break;

        int check[4001] = {0}; queue<int> que;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= 0) check[en] += price*qty;
            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) cout << "NA" << endl;
        else {
            while(!que.empty()) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

int main(void){

	int n,number,money,sum,flag;
	int data[4001]={0},dataF[4001]={0};
	queue<int> ok;

	while(1){

		for(int i=0;i<4000;i++) data[i]=0,dataF[i]=0;
		flag=0;

		cin>>n;
		if(n==0) break;

		for(int i=0;i<n;i++){
			cin>>number>>money>>sum;
			data[number]+=money*sum;
			if(dataF[number]==0){
				dataF[number]=1;
				ok.push(number);
			}
		}
			while(!ok.empty()){
				if(data[ok.front()]>=1000000){
					cout<<ok.front()<<endl;
					flag=1;
				}
				ok.pop();
			}
			if(flag==0) cout<<"NA"<<endl;
	}

	return 0;
}

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

typedef long long ll;

#define BORDER 1000000LL

int main() {
	map<int, ll> dat;
	vector<int> ord;
	int n, id, c; ll e, s;
	while(1) {
		cin >> n;
		if(!n) break;
		dat.clear(); ord.clear();
		for(int i=0; i<n; ++i) {
			cin >> id >> e >> s;
			if(!dat.count(id)) {
				ord.push_back(id);
				dat[id] = e*s;
			}else dat[id] += e*s;
		}
		c = 0;
		for(int i=0; i<(signed)ord.size(); ++i) {
			id = ord[i];
			if(dat[id]>=BORDER) {
				cout << ord[i] << endl;
				++c;
			}
		}
		if(!c) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int main(){

	int n=1, i, x[4000] = {}, xx[4000] = {}, xxx[4000] = {}, r, y=0;

	while (n > 0){
		scanf("%d", &n);

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[i],&xx[i],&xxx[i]);
		}

		for (r = 0; r < 4000; r++){
			
			if (xx[r] * xxx[r] > 1000000){
				printf("%d\n", x[r]);
			}	
		}
		if (y == 0){ printf("NA\n"); (y = 0); }
	}
	return 0;
}