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>
#include<map>
#include<vector>
using namespace std;

int main()
{
    int n;
    
    while(cin>>n && n){
        
        map<int,int> mp;
        vector<int> v;
        
        for(int i=0; i<n; i++){
            int e,p,q;
            cin>>e>>p>>q;
            if(!mp[e])
                v.push_back(e);
            
            mp[e]+=p*q;
            
        }
        
        bool flg=false;
        
        for(int i=0; i<v.size(); i++){
            if(mp[v[i]]>=1000000){
                flg=true;
                cout<<v[i]<<endl;
            }
            else if(!flg){
                cout<<"NA"<<endl;
            }
        }
    }

C++: #include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

long long n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,int> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			if(sk[bg]==0) jun.push_back(bg);
			sk[bg] += tn * su;
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) cout << "NA" << endl;
	}
	return 0;
	
}

C++: #include <bits/stdc++.h>

using namespace std;

long long employees[4001];
bool checked[4001];

int main()
{
	int n;
	while (cin >> n, n) {
		for (int i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<int> ans;

		for (int i = 0; i < n; ++i) {
			int num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += (long long)a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

		if (ans.empty()) cout << "NA" << endl;

		for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	int x[4001] = {0};
	int m[4001] = {0};
	
	while(1){
		int e, p, q, count = 0;
		cin >> n;
		if(n == 0) break;
		
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			x[e] += p * q;
			if(x[e] >= 1000000){
				if(m[e] == 0){
					cout << e << endl;
					count++;
					m[e]++;
				}
			}
		}
		if(count == 0) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  int n,f;
  //mlÛ¶vÛ¶
  long long int a,b,c;
  //aÔbP¿cÊ
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>999999){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)cout<<"NA"<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	while(cin >> n){
		if(!n){
			break;
		}
		map<unsigned long long int,unsigned long long int> syain;
		bool flag = true;
		unsigned long long int a,b,c;
		for(int i=0;i<n;i++){
			map<unsigned long long int,unsigned long long int> tmp;
			cin >> a >> b >> c;
			if(syain.find(a) != syain.end() && syain[a] < 1000000)
				syain[a] += b*c;
			else
				syain[a] = b*c;
			if(syain[a] >= 1000000){
				cout << a << endl;				
				flag = false;
			}
		}
		if(flag)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int i=0,j=0;
	int tanka[4001]={0};
	int flg=0;
	int uriage[4001]={0};
	int bangou[4001]={0};
	int ccc=0;
	int goukei[4001]={0};
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		for (i=1;i<=n;i++)
		{
			ccc++;
			scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&uriage[ccc]);
			goukei[ccc]=tanka[ccc]*uriage[ccc];
			for (j=0;j<ccc;j++)
			{
				if (bangou[ccc]==bangou[j])
				{
					goukei[j]+=tanka[ccc];
					goukei[j]+=uriage[ccc];
					ccc--;
				}
			}
		}
		for (i=1;i<=ccc;i++)
		{
			if (goukei[i]>=1000000)
			{
				printf("%d\n",bangou[i]);
				flg=1;
			}
		}
		if (flg==0)
		{
			printf("NA\n");
		}
	}
return 0;
}