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 <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

int main() {
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        int c = 0;
        rep (_, n) {
            int id, p, q;
            scanf("%d%d%d", &id, &p, &q);
            if ((Int)p*q >= 1000000) {
                printf("%d\n", id);
                c++;
            }
        }
        if (c == 0) puts("NA");
    }
    return 0;
}

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

int main() {
	long long e, p, q;
	int n;
	while (cin >> n, n) {
		long long number[4001] = {};
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			number[e - 1] += p*q;
		}

		int x = 0;
		for (int i = 0; i < 4001; i++) {
			if (number[i] >= 1000000) {
				cout << i + 1 << endl;
				x++;
			}
		}
		if (x == 0) { cout << "NA" << endl; }
	}
	return 0;
}

C++: 
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()


int main(void){
	int n;	
	while(cin>>n,n){
		vector<vector<ll> > num(n,vector<long long int>(3,0));
		rep(i,n){
			//cout<<num[i][0]<<" "<<num[i][1]<<endl;
			cin>>num[i][0];
			int item,code;
			rep(j,i){
				if(num[i][0]==num[j][0]){
					num[j][1]+=item*code;
					num[i][2]=1;
				}
			}
			cin>>item>>code;
			if(!num[i][2])num[i][1]+=item*code;
		}
		//cout<<"star"<<endl;
		int cnt=0;
		vi ans;
		rep(i,n){
			//cout<<num[i][0]<<" "<<num[i][1]<<endl;
			if(num[i][1]>=1000000){ans.push_back(num[i][0]);cnt++;}
		}
		sort(all(ans));
		rep(i,ans.size())cout<<ans[i]<<endl;
		if(!cnt)cout<<"NA"<<endl;
		//cout<<"NO"<<n<<endl<<endl;;
	}
}

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

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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long long value[4001];
	vector<long long> v;

	int n,num,k,m;
	while(cin >> n && n)
	{
		memset(value,0,sizeof(value));
		v.clear();

		rep(i,n)
		{
			cin >> num >> k >> m;
			value[num] += k*m;

			vector<long long>::iterator ite = find(v.begin(),v.end(),num);
			if(ite == v.end())
			{
				v.push_back(num);
			}
		}

		bool flag = true;
		rep(i,v.size())
		{
			if(value[v[i]] >= 1000000)
			{
				flag = false;
				cout << v[i] << endl;
			}
		}

		if(flag) cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;
class saleData
{
public:

	int hireNo;
	int saleValue = 0;

	void addSale(int value)
	{
		if(saleValue < 1000000)
		{
			saleValue += value;
		}
	}

	bool judge()
	{
		if(saleValue >= 1000000)
		{
			return true;
		}
		return false;
	}
};
int main()
{
	while(1)
	{
		int dataCount;
		cin >> dataCount;
		vector<saleData> vobj;

		if(dataCount == 0)
		{
			break;
		}
		bool dataFlag = false;
		for(int i = 0; i < dataCount; i++)
		{
			int hireNo;
			int price;
			int No;
			cin >> hireNo >> price >> No;

			for(int j = 0; j < vobj.size(); j++)
			{
				if(vobj.size() == 0)
				{
					break;
				}
				if(vobj[j].hireNo == hireNo)
				{
					vobj[j].addSale(price * No);
					dataFlag = true;
					break;
				}
			}
			if(dataFlag == false)
			{
				saleData sObj;
				sObj.hireNo = hireNo;
				sObj.addSale(price * No);
				vobj.push_back(sObj);
			}
		}
		dataFlag = false;
		for(int i = 0; i < vobj.size() ; i++)
		{
			if(vobj[i].judge() == true)
			{
				cout << vobj[i].hireNo << endl;
				dataFlag = true;
			}
		}
		if(dataFlag == false)
		{
			cout << "NA" << endl;
		}


	}



}

C++: #include <cstdio>

int main() {
  int n;
  scanf("%d", &n);

  int e, p, q;
  for(int i = 0; i < n; i++) {
    scanf("%d %d %d", &e, &p, &q);
    if(p * q >  1e6) printf("%d\n", e);
  }
}

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

int main() {
	int n;
	while (cin >> n, n) {
		int e;
		long long p, q;
		long long number[4000];
		vector<int>v;
		for (int i = 0;i < 4000;i++) {
			number[i] = 0;
		}

		for (int i = 0;i < n;i++) {
			cin >> e >> p >> q;
			number[e - 1] += p*q;
		}

		for (int i = 0;i < 4000;i++) {
			if (number[i] >= 1000000) {
				v.push_back((i + 1));
			}
		}

		if (v.empty()) { cout << "NA" << endl; }
		else {
			int a = v.size();
			for (int j = 0;j < a;j++) {
				cout << v[j] << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(T) __typeof((T).begin())
#define each(T, it) for(ITER(T) it =(T).begin(); it!=(T).end(); it++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 4001;
const int B = (int)1e6;

int main(void){
    for(int n, f; cin >> n, n; cout << (f?"":"NA\n")){
        vector<ll> in(N);
        vi p;

        while(f = n --){
            int id; ll v, m; cin >> id >> v >> m;
            
            if((in[id] += (ll)v * m) >= B) in[id] = B;
            if(find(ALL(p), id) == p.end()) p.pb(id);
        }
        each(p, it) if(f = in[*it] == B) cout << *it << endl; 
    }
 
    return 0;
}