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 <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;
}

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

int main()
{
	int n, i;
	bool f;
	long long int a, b, c;
	map<int, long long int> member;
	vector<int> order;
	vector<int>::iterator it;
	while (cin>>n, n) {
		member.clear();
		order.clear();
		for (i = 0; i < n; i++) {
			cin>>a>>b>>c;
			member[a] += b*c;
			if ( order.end() == find( order.begin(), order.end(), a ) ) {
				order.push_back(a);
			}
		}
		f = true;
		for (it = order.begin(); it != order.end(); it++) {
			if (member[*it] >= 1000000) {
				cout<<*it<<endl;
				f = false;
			}
		}
		if (f) cout<<"NA"<<endl;
	}

	return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    while (1) {
        int id;
        long long int ids[4000],n,cost,amount;
        bool exist = false;
        vector<int> num;
        cin >> n;
        if (n==0) break;
        for(int i=0;i<4000;i++) ids[i]=-1;
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(ids[id]==-1){
                num.push_back(id);
                ids[id]=0;
            }
            ids[id]+=cost*amount;
        }
        for(int i=0;i<num.size();i++){
            if(ids[num[i]]>=1000000){
                cout << num[i] << endl;
                exist = true;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
    
    return 0;
}