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()
{
    int n;
    while(cin>>n,n){
        bool flag=0;
        double result[4001]={};
        for(int i=0,con;i<n;i++){
            double sale,num;
            cin>>con>>sale>>num;
            sale/=1000;num/=1000;
            result[con]+=sale*num;
            if(result[con]>=1){
                cout<<con<<endl;
                result[con]=-50;
                flag=1;
            }
        }
        if(!flag)cout<<"NA"<<endl;
    }
}

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

using namespace std;

int n;
long long id[4000];
long long value[4000];
long long count[4000];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> id[i] >> value[i] >> count[i] >> endl;
    }
    vector<long long> v;
    for(int i=0;i<n;i++){
        if(value[i]*count[i] >= 1000000 ){
            v.append(id[i]);
        }
    }
    for (vector<long long>::iterator it=v.begin();it!=v.end();++it){
        count << *it << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
  int i, n;
  long long int p, q;
  while(cin >> n, n){
    bool NAflg = false;
    while(n--){
      cin >> i >> p >> q;
      if((p * q) >= 1000000){
	cout << i << endl;
	NAflg = true;
      }
    }
    if(!NAflg)
      cout << "NA" << endl;
  }
  return 0;
}

C++: // a.c.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	int ban, tan, suu;
	int bango[4001];
	int flg,i;
	while (1){
		for (i = 1; i <= 4000; i++){
			bango[i] = 0;
		}
		scanf_s("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf_s("%d %d %d", &ban, &tan, &suu);
			bango[ban] += tan*suu;
		}
		flg = 0;
		for (i = 1; i <= 4000; i++){
			if (bango[i]>=1000000){
				printf("%d\n", i);
				flg = 1;
			}
		}
		if (!flg){
			printf("NA\n");
		}
	}
	return 0;
}

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;
}