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 <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int j = 0; j < 50; j++)
	{cout << endl;
		long n,e[4000],x[4000],y[4000],co[100];

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

		for (int i = 0; i < n; i++)
		{
			cin >> e[i] >> x[i] >> y[i];
		}

		for (int i = 0; i < n; i++)
		{
			co[i] = 0;
			for (int k = 0; k < n; k++)
			{
				if (i <= k && e[i] == e[k])
				{
					co[i] += x[k] * y[k];
					if (i != k)
					{
						e[k] = -1;
					}
				}
			}
		}
	int gg = 0;
		for (int i = 0; i < n; i++)
		{
			if (e[i] != -1 && co[i] >= 1000000)
			{	gg += -1;
				cout << e[i] << endl;
			}
			if (i == n - 1 && gg == 0)
			{
				cout << "NA" << endl;
			}
		}
	}
}

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

class CMem {
public :
	CMem() { m_check = false; m_sale = 0; m_rank = 0; }
	void Idata(long long sale) { m_sale += sale; m_check = true; }
	void Irank(int rank) { m_rank = rank; }
	int Orank() { return m_rank;}
	bool Ocheck() { return m_check; }
	long long Osale() { return m_sale; }
private :
	bool m_check;
	long long m_sale;
	int m_rank;
};

int main(void)
{
	while(1) {
		CMem member[4001];
		bool NA = true;
		int n, id, asale, scale, rank = 1, mrank;
		long long sale;

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

		for(int i = 0; i < n; i++) {
			cin >> id >> asale >> scale;
			sale = asale * scale;

			if(member[id].Ocheck() == false) { member[id].Irank(rank++); }
			member[id].Idata(sale);
		}

		mrank = rank - 1;

		for(rank = 1; rank <= mrank; rank++) {
			for(int i = 1; i <= 4000; i++) {
				if(member[i].Orank() == rank && member[i].Osale() >= 1000000) {
					cout << i << endl;
					NA = false;
				}
			}
		}

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

C++: #include<stdio.h>

int main()
{
	int i,ryou,bangou[4000],nedan[4000],kazu[4000],check;
	while(1)
	{
		check=0;
		scanf("%d",&ryou);
		if(ryou==0)
			break;
		for(i=0;i<ryou;i++)
		{
			scanf("%d%d%d",&bangou[i],&nedan[i],&kazu[i]);
			{
				if(nedan[i]*kazu[i]>=1000000)
				{
					printf("%d",bangou[i]);
					check=1;
				}
			}
		}
		if(check==0)
				printf("NA");
	}
}

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

int main(){
	
	long long int n , id , price , num, cnt;
	while(cin >> n , n!=0){
		vector<long long int> p(4001,0);
		vector<int> a;
		while(n--){
			cin>>id>>price>>num;
			if(find(a.begin(),a.end(),id)==a.end()) a.push_back(id);
			p[id]+=price*num;
			}
		cnt=0;	
		for(int i=0;i<a.size();i++){
			if(p[a[i]]>=1000000){
				cout << a[i] << endl; 
				cnt++;
			} 
		}
		if (cnt==0) cout << "NA" << endl;
	}
	return 0;
}

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

int main(){
	int n,num[4001];
	while(std::cin>>n){
		int count=0;
		memset(num,0,sizeof(num));
		if(n==0)break;
		for(int a,b,c,i=0;i<n;i++){
			std::cin>>a>>b>>c;
			num[a]+=b*c;
		}
		for(int i=0;i<4001;i++){
			if(num[i]>=1000000)count++,std::cout<<i<<std::endl;
		}
		if(count==0)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n,b;
  int a,num[N],tanka,uriage,jun[N];
  bool judge,nnnn;

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

    judge = true;
    for(int i=0;i<N;i++){
      num[i] = 0;
    }

    for(int i=0,b=0;i<n;i++){
      nnnn = true;
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
      for(int j=0;j<i;j++){
	if(jun[j]==a){
	  nnnn = false;
	  break;
	}
      }
      if(nnnn){
	jun[b] = a;
	b++;
      }
    }

    for(a=0;jun[a]!=0;a++){
      if(num[jun[a]]>=1000000){
	cout << jun[a] << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id[4000],cid;
	long long int price,num,sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&cid,&price,&num);

			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}

		}



		for(i=0;i<idcount;i++){
			if(sale[i]>=1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	vector<unsigned long long> data(4000);
	vector<int> f(4000);
	int i;
	long long a,b,c;
	bool check;

	cin >> i;
	while(i){

		for(int j = 0;j < 4000;j++){
			data[j] = 0;
		}


		for(int j = 0;j < i;j++){
			cin >> a >> b >> c;
			data[a - 1] += (long long)b * c;
			f[j] = a - 1;
		}


		check = false;

		for(int j = 0;j < i;j++){
			if(data[f[j]] >= 1000000){
				printf("%d\n",f[j] + 1);
				data[f[j]] = 0;
				check = true;
			}
		}

		if(!check) printf("NA\n");

		cin >> i;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(!n)break;
		int num,price,amount;
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			if((long)price*(long)amount>=1000000)v.push_back(num);
		}
		if(!v.empty()){
			for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		}else cout<<"NA\n";
	}
	return 0;
}

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		map<int, int> m;
		for(int i = 0; i < n; i++){
			int id, price, amount;
			cin >> id >> price >> amount;
			m[id] += price * amount;
		}
		bool applicable = false;
		for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
			if(itr->second >= 1000000){
				applicable = true;
				cout << itr->first << endl;
			}
		}
		if(!applicable){
			cout << "NA" << endl;
		}

	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
const int MAXN = 4000;
typedef long long ll;
string i;
int p,q;
bool isfind = false;
map<string,ll> total;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)return 0;
    for(int k = 0;k < n;k++){
      cin >> i >> p >> q;
      total[i] += p*q;
    }
    for(map<string, ll>::iterator i = total.begin(); i != total.end(); ++i){
      if(i->second >= 1000000){
	isfind = true;
	cout << i->first << endl;
      }
    }
    if(!isfind)cout << "NA" << endl;
    total.clear();
    isfind =false;
  }
  return 0;
}