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 <bits/stdc++.h>
using namespace std;
int main()
{
    while (1)
    {
        int n;
        cin>>n;
        if (n==0)
            break;
        else
        {
            int ara[100000],i,sum[100000];
            for (i=0;i<=4000;i++)
            {
                sum[i]=0;
            }
            int id,b,c;
            for (i=0;i<n;i++)
            {
                cin>>id>>b>>c;
                sum[id]+=(b*c);
                ara[id]=id;
            }
            int ara2[100000],j=0;
            for (i=0;i<=4000;i++)
            {
                if (sum[i]>=1000000)
                {
                    ara2[j]=ara[i];
                    j++;
                }
            }
            if (j==0)
                cout<<"NA"<<endl;
            else
            {
                sort(ara2,ara2+j);
                for (int k=0;k<j;k++)
                {
                    cout<<ara2[k]<<endl;
                }
            }

        }
    }

}

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

using namespace std;

int main(void){
	vector<int> staffNumber;
	vector<int> sellingPrice;
	vector<int> qty;
	int count=0;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int sN,sP,qt;
		cin >> sN >> sP >> qt;
		staffNumber.push_back(sN);
		sellingPrice.push_back(sP);
		qty.push_back(qt);
	}
	for(int i=0;i<n;i++){
		if(sellingPrice[i]*qty[i]>=1000000){
			cout << staffNumber[i] << endl;
			count++;
		}
	}
	if(count==0){
		cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,e[1010]={},p[1010]={},q[1010]={},i,count;
	while(1){
		cin>>n;
		if(n==0)break;
		count=0;
		for(i=0;i<n;i++){
			cin>>e[i]>>p[i]>>q[i];
			if(p[i]*q[i]>=100000){
				cout<<e[i]<<endl;
				count++;
			}
		}
		if(count==0){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

template<typename itr, typename func>
func for_each_withindex(itr fi, itr l, func f){
	unsigned i{};
	for(; fi!=l; ++fi,++i){
		f(*fi,i);
	}
	return f;
}

int main(int argc, char const* argv[])
{
	unsigned n{};
	while (std::cin >> n,n != 0) {
		long long e{}, p{}, q{};
		bool isna{true};
		std::array<long long,4001> es{};
		for (unsigned i = 0; i < n; i++) {
			std::cin >> e >> p >> q;
				es.at(e) += p * q;
		}
		for_each_withindex(es.begin(), es.end(), [&isna](auto sell,auto e){ 
				if (sell>=1000000) {
				std::cout << e << std::endl;
				isna = false;
				}});
		if (isna) {
			std::cout << "NA" << std::endl;
		}

	}
	return 0;
}

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

int main()
{
    int n;
    while(cin >> n && n != 0)
    {
        long long int record[4000]={};
        int cnt = 0;
        for(int i=0; i<n; i++)
        {
            int id;
            int p;
            int q;
            cin >> id >> p >> q;
            record[id] += p * q;
        }
        for(int i=0; i<4000; i++)
        {
            if(record[i] >= 1000000)
            {
                cout << i << endl;
                cnt++;
            }
        }
        if(cnt == 0)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
#define MAX_N 10000000
long long x[MAX_N], a, b, c, n;
int main() {
	while (1) {
		memset(x, 0, sizeof(x));
		cin >> n; if (!n) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			x[a] += b*c;
			if (x[a] >= 1000000) { cout << a << endl; }
		}
	}
}

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

using namespace std;

int main(){
	long long int number,code,tanka,kazu;
	int count,flag;
	int syain[4000];
	long long int total[4000];
	while(cin >> number && number != 0){
		count = 0;
		for(int i=0;i<number;i++){
			cin >> code >> tanka >> kazu;
			count++;
//			cout << code << tanka << kazu << endl;
			for(int j = 0;j<count;j++){
				if(syain[j] == code){
					//cout << "yahoo" << endl;
					total[j] += (tanka * kazu);
					count--;
					break;
				}
				if(j == count - 1){
					//cout << "bb" << endl;
					syain[j] = code;
					total[j] = tanka * kazu;
				}
			}

			//			cout << code << " " << tanka*kazu << endl;
		}
		flag = 0;
		for(int j = 0; j < count;j++){
			if(total[j]>=1000000){
				cout << syain[j] << endl;
				flag = 1;
			}
			syain[j] = 0;
		}
		if(!flag){
			cout << "NA" << endl;
		}
	}

}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
	int n;
	while(scanf("%d\n", &n), n){
		vector<pair<int, ll>> v;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			bool f = false;
			for(int j = 0; j < v.size(); ++j) {
				if(v[j].first == x) {
					v[j].second += (ll) y * z;
					f = true;
					break;
				}
			}
			if(!f) {
				v.push_back(make_pair(x, (ll)(y * z)));
			}
		}
		bool flag = false;
		for(int j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n;
	while (cin >> n, n) {
		map<int, int>mp;
		map<int, bool>check;
		vector<int>id(n);
		bool f(false);
		rep(i, 0, n) {
			int p, q; cin >> id[i] >> p >> q;
			mp[id[i]] += p*q;
			check[id[i]] = false;
		}
		rep(i, 0, n) {
			if (check[id[i]] == false) {
				check[id[i]] = true;
				if (mp[id[i]] >= 1000000) {
					cout << id[i] << endl;
					f = true;
				}
			}
		}
		if (f == false)cout << "NA" << endl;
	}
	return 0;
}