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++: using System;
using System.Collections.Generic;
class _0100
{
    public static void Main()
    {
        bool flag;
        string[] data;
        long sum, val;
        Dictionary<string, long> d = new Dictionary<string, long>();
        List<string> sortDKey;
        int n = int.Parse(Console.ReadLine());
        while (n != 0)
        {
            d.Clear();
            flag = false;
            for (int i = 0; i < n; i++)
            {
                data = Console.ReadLine().Split();
                sum = long.Parse(data[1]) * long.Parse(data[2]);
                if (d.TryGetValue(data[0], out val))
                {
                    d.Remove(data[0]);
                    d.Add(data[0], val + sum);
                }
                else d.Add(data[0], sum);
            }
            sortDKey = new List<string>(d.Keys);
            sortDKey.Sort();
            foreach (string k in sortDKey)
            {
                if(d[k] >= 1000000)
                {
                    flag = (!flag) ? true : flag;
                    Console.WriteLine(k);
                }
            }
            if (!flag) Console.WriteLine("NA");
            n = int.Parse(Console.ReadLine());
        }
    }
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        map<int,long long> sl;
        for(int i=0;i<n;++i){
            int sn,t,v;
            cin>>sn>>t>>v;
            sl.insert(make_pair(sn,t*v));
        }
        map<int,long long>::iterator it=sl.begin();
        while(it!=sl.end())
        {
            if((*it).second>=1000000){cout<<(*it).first<<endl;++count;}
            ++it;
        }
        if(!count)cout<<"NA"<<endl;
    }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, long long int>mp;
		vector<int>vs;
		for (int i = 0; i < N; ++i) {
			long long int a, b, c; cin >> a >> b >> c;
			mp[a] += b*c;
			if (find(vs.begin(), vs.end(), a) == vs.end())vs.emplace_back(a);
		}
		bool flag = false;
		for (auto v : vs) {
			if (mp[v] >= 1000000) {
				cout << v << endl;
				flag = true;
			}
		}
		if (!flag)cout << "NA" << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(all(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      m[a] += b * c;
    }

    for(map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
      if( it->second >= 1000000 ) {
	cout << it->first << endl;
	flag = true;
      }
    }

    if( !flag ) cout << "NA" << endl;
  }
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while (scanf("%d",&n)&&n!=0) {
		vector<int> sales(4000, 0);
		vector<int> log;
		long long int prc, mnt;
		int num;
		for (int i=0; i<n; i++) {
			scanf("%d%d%d",&num,&prc,&mnt);
			if (log.empty()||find(log.begin(),log.end(),num)==log.end()) {
				log.push_back(num-1);
			}
			sales[num-1] += prc * mnt;
		}
		bool flag = true;
		for (int i=0; i<log.size(); i++) {
			printf("%d ", sales[log[i]]);
			if (sales[log[i]]>=1000000) {
				flag = false;
				printf("%d\n", log[i]+1);
			}
		}
		if (flag) printf("NA\n");
	}
}

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

int A[1000000];

int main()
{
    long long N,B,C;
    while(cin >> N,N){
        long long cnt[4001]={};
        bool NAflag=true,used[4001]={};
        for(int i=0;i<N;i++){
            cin>>A[i]>>B>>C;
            cnt[A[i]] += B*C;

        }
        for(int i=0;i<N;i++){
            if(cnt[A[i]]>=1000000 && used[A[i]]==false){
                printf("%d\n",A[i]);
                used[A[i]]=true;
                NAflag=false;
            }
        }
        if(NAflag==true){
            cout<<"NA"<<endl;
        }
    }
    return 0;
}

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

using namespace std;
const int target = 1000000;
vector<int> heros;

int main()
{
	int data;
	while (1)
	{
		scanf_s("%d", &data);
		if (data == 0)break;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			int num, sell, cnt;
			scanf_s("%d %d %d", &num, &sell, &cnt);
			if (sell*cnt >= target)
			{
				bool already = false;
				for (int j = 0; j < heros.size(); j++)
				{
					if (heros[j] == num)
						already = true;
				}
				if (already == false)
				{
					printf("%d\n", num);
					heros.push_back(num);
					hero = true;
				}
			}
		}
		if (hero==false)
			printf("NA\n");
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
typedef long long ll;
using namespace std;
#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++: #include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  while(cin>>n,n){
    map<int,int> M;
    REP(i,n){
      int e,p,q;
      cin>>e>>p>>q;
      M[e]+=p*q;
    }
    bool f=false;
    for(auto itr=M.begin();itr!=M.end();itr++){
      if((itr->second)>=1000000){
        cout<<(itr->first)<<endl;
        f=true;
      }
    }
    if(!f)cout<<"NA"<<endl;
  }
  return 0;
}