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++: //Sale Result
//
//?????????????£?????????¨?£??????°???????¨????????????????????????????????????????????????????????£?????????¨?£??????°??????????????????????£???????????????????????????? 1, 000, 000 ?????\??????????????????????????????????????????????????°??????????????????????????????????????????????????°????????´????????????????????????????????\????????????????????????????????????????????????????????????????????????????????????????????????????????????????????´?????????NA?????¨???????????????????????????????????? 4000 ???????????¨??????1??????4000?????§?????????????????????????????????????????????????????????????????????????????¨?????????????????????????£?????????? 1, 000, 000 ?????\?????§????£??????°?????? 100, 000 ?????\?????¨????????????
//Input
//
//?????°???????????????????????????????????????????????\??????????????????0???????????????????????????????????\????????¨?????????
//
//???????????° n
//???????????? ????£??????? ?£??????°???(??´??°;????§????????????????)
//	:
//	:
//
//	Output
//
//	????????????????????????????????????????????????(??´??°)?????? ????????? NA(????§???±??§??????)
//	Sample Input
//
//	4
//	1001 2000 520
//	1002 1800 450
//	1003 1600 625
//	1001 200 1220
//	2
//	1001 100 3
//	1005 1000 100
//	2
//	2013 5000 100
//	2013 5000 100
//	0
//
//	Output for the Sample Input
//
//	1001
//	1003
//	NA
//	2013

#define _CRT_SECURE_NO_WARNINGS 1

using namespace std;

#include <stdio.h>
#include <map>

#define BASE_VALUE 1000000		// ?£?????????????

int main()
{
	char input[1024];					// ??\????????????
	int n = 0;							// ???????????°
	int no = 0;							// ????????????
	int price = 0;						// ????£???????
	int saleNum = 0;					// ?£??????°???
	bool flg = false;					// ????????????????????¨??????????????????
	map<int, int> proceed;				// ?£??????????map
	map<int, int>::iterator ite;		// ?£??????????map????????¬??????

	while (true)
	{
		// ?????????
		n = 0;
		flg = false;
		proceed.clear();
		memset(input, 0x00, sizeof(input));

		// ???????????°??\???
		scanf("%s", &input);

		n = atoi(input);

		if (0 == n)
		{// 0?????\??????????????°??????
			break;
		}

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %d %d", &no, &price, &saleNum);

			proceed[no] += price*saleNum;
		}

		for (ite = proceed.begin(); ite != proceed.end(); ++ite)
		{
			if (BASE_VALUE <= ite->second)
			{// ?£???????????????????????????? 1,000,000 ?????\????????????
				printf("%d\n", ite->first);
				flg = true;
			}
		}

		if (!flg)
		{// ????????????????????¨?????????
			printf("NA\n");
		}
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n, sum;
	
	while(1)
	{
		sum = 0;
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++)
		{
			long long no, x, y;
			cin >> no >> x >> y;
			if(x * y >= 1000000)
			{
				cout << no << endl;
				sum++;
			}
		}
		if(sum == 0) cout << "NA" << endl;
	}
	return 0;
}

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

int main(){
	int total[4000],n,a,b,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(total,0,sizeof(total));
		while(n--){
			scanf("%d%d%d",&a,&b,&c);
			total[a-1]=total[a-1]+b*c;
		}
		int res=0;
		for(int i=0;i<4000;i++){
			if(total[i]>=1000000){
				res=1;
				printf("%d\n",i+1);
			}
		}
		if(res) continue;
		else printf("NA\n");
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
  while(1){
    int i, n;
    int a, b, c;
    scanf("%d", &n);
    if(n!=0){
      int e[4001] ={};
      int flag = 0;
      for(i=0;i<n;i++){
	scanf("%d %d %d", &a, &b, &c);
	if(e[a]+b*c<=2147483647)
	  e[a]+=b*c;
	else
	  e[a]=2147483647;
      }
      for(i=0;i<4001;i++){
	if(e[i]>=1000000){
	  printf("%d\n", i);
	  flag++;
	}
      }
      if(flag==0)
	printf("NA\n");
    }
    else{
      break;
    }
  }
  return 0;
}

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

int main()
{
	int Line = 0, Temp;
	bool Exist;
	while (cin >> Line, Line) {
		//Initialize
		double EmployObj[4001] = { 0 };
		double SellingPrice = 0, SalesVolume = 0;
		Exist = true;

		do {
			cin >> Temp >> SellingPrice >> SalesVolume;
			EmployObj[Temp] += SellingPrice * SalesVolume;
		} while (--Line);
		for (int count = 1; count <= 4001; count++) {
			if (EmployObj[count] >= 1000000) {
				cout << count << endl;
				Exist = false;
			}
		}
		if (Exist) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(void){
     int n;
     cin >> n;
     vector<int> worker;
     for(int i=0;i<n;i++){
	  int q,w,e;
	  cin >> q >> w >> e;
	  if(1000000 <= w*e){
	       worker.push_back(q);
	  }
     }
     if(worker.size() == 0){
	  cout << "NA" << endl;
     }else{
	  for(int i=0;i<worker.size();i++){
	       cout << worker[i] << 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, v, m; cin >> id >> v >> m;
            
            if((in[id] += 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;
}

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

std::vector<std::string> split(const std::string& ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num=0;
std::string str="";
std::vector<std::string> ref;
std::vector<std::string> res;

std::cin >> str;
if(str!="") it_num=std::stoi(str);

while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str,' ');
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
if(res.size()==0){
std::cout << "NA" << std::endl;
}else{
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}
}
}
res.clear();
std::cin >> it_num;
}

return 0;
}