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<stdio.h>

struct staff_data{
	int num;
	/*long unsigned*/ int price,volume,total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	while(scanf("%d",&n)!=0){
	
		if(n==0){
			break;
		}
		
		staff_data dt[4000]={0};
		
		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			
			for(j=i;j<=i;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					/*dt[j].price=price;
					dt[j].volume=volume;*/
					dt[j].num=num;
					dt[j].total=(price)*(volume)+dt[j].total;
					//dt[j].total=(dt[j].price)*(dt[j].volume)+dt[j].total;
					
					break;
				}
				
			}
		}

		hantei=0;

		for(j=0;j<n;j++){
		
			if(dt[j].total>=1000000){
				printf("%4d\n",dt[j].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#define int long long
using namespace std;

class Input {
public:
	int n;
	vector<int> numbers, tanka, num;
	
	bool input() {
		scanf("%lld", &n);
		if (!n) {
			return false;
		}
		for (int i = 0; i < n; i++) {
			int s, t, u;
			scanf("%lld%lld%lld", &s, &t, &u);
			numbers.push_back(s);
			tanka.push_back(t);
			num.push_back(u);
		}
		return true;
	}
};
class Solver : public Input {
public:

	vector<int> solve() {
		typedef pair<int, int> P;
		map<int, int> data;
		for (int i = 0; i < n; i++) {
			int value = tanka[i] * num[i];
			int number = numbers[i];
			
			if (data.find(number) == data.end() ) {
				data[number] = 0;
			}
			data[number] += value;
		}
		
		vector<int> ret;
		for (map<int, int>::iterator it = data.begin(); it != data.end(); it++) {
			if ((*it).second >= 1000000 ) {
				ret.push_back((*it).first);
			}
		}
		return ret;
	}
};

signed main() {
	while (true) {
		Solver solver;
		if (!solver.input() ) {
			break;
		}
		
		vector<int> res = solver.solve();
		if (res.size() == 0) {
			cout << "NA" << endl;
		}
		else {
			for (int i = 0; i < res.size(); i++) {
				cout << res[i] << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{   
    int n;
    long long int ids[4001];
    int id, price, amount;
    bool exist;
    bool used[4001];
    vector<int> rank;
    while(cin >> n && n)
    {   
        exist=false;
        for(int i=1;i<4001;++i)
        {   
            ids[i] = 0;
            used[i] = false;
        }
        rank.clear();
        for(int i=0;i<n;++i)
        {   
            cin >> id >> price >> amount;
            if(!used[id])
            {   
                rank.push_back(id);
                used[id] = true;
            }
            ids[id] += price * amount;
        }
        for(int i=0;i<rank.size();++i)
        {   
            if(ids[rank[i]] >= 1000000)
            {   
                exist = true;
                cout << rank[i] << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
        for(int i=0;i<rank.size();++i) cout << rank[i] << " ";
        cout << endl;
    }
}

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