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++: #define _CRT_SECURE_NO_WARNINGS 1

using namespace std;

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

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

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

	while (true)
	{
		// ?????????
		flg = false;
		proceed.clear();

		// ???????????°??\???
		scanf("%d", &n);

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

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %lld %lld", &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<queue>

std::map<int,long long> staff;
std::queue<int> que;

int main()
{
	int n;
	while(1)
	{
		bool isNA=true;
		int number,price,amount;
		std::cin>>n;
		if(n==0)break;
		staff.clear();
		for(int i=0;i<n;i++)
		{
			std::cin>>number>>price>>amount;
			if(staff.find(number)==staff.end())
			{
				staff.insert(std::pair<int,long long>(number,price*amount));
				que.push(number);
			}
			else
			{
				staff[number]+=price*amount;
			}
		}
		while(!que.empty())
		{
			if(staff[que.front()]>=1000000)
			{
				isNA=false;
				std::cout<<que.front()<<std::endl;
			}
			que.pop();
		}
		if(isNA)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int n;

int main() {
	while(true) {	
		cin >> n;
		if(n == 0) break;
		vector<pair<int, ll>> v;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			vector<pair<int, ll>>::iterator it = v.begin();
			for(; it != v.end(); ++it) {
				if((*it).first == id.at(i)) {
					(*it).second += p.at(i) * q.at(i);
					break;
				}
			}
			if(it == v.end()) {
				v.push_back(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
				}
		}
		bool flag = false;
		for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

int s[4001],n,a,b,N;
string d;

int main(){
    while(cin>>N){
	if(N==0)return 0;
	fill(s,s+4001,0);
	for(int i=0;i<N;i++){
	    cin>>n>>a>>b;
	    s[n]+=a*b;
	}
	int flag=0;
	for(int i=0;i<4001;i++)if(s[i]>999999){cout<<i<<endl;flag=1;}
	if(flag==0)cout<<"NA"<<endl;
    }
}

C++: #include <iostream>
#include <string.h>

using namespace std;

int N, M;

int main() {
	int goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long v[4000];
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			long long e, p, q;
			cin >> e >> p >> q;
			v[e - 1] += p*q;
		}
		bool flag = false;
		for (int i = 0; i < 4000; i++) {
			if (v[i] >= goal) {
				flag = true;
				cout << i + 1 << endl;

			}
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

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

int main()
{
    int n;
    bool used[4001];
    while(cin >> n,n){
        bool hantei=true,kaburi[n];
        long long number[n],price[n],quantity[n],sale[n];
        for(int i=0 ; i<n ; i++){
            cin >> number[i] >> price[i] >> quantity[i];
            sale[i]=price[i]*quantity[i];
        }
        for(int i=0 ; i<n-1 ; i++){
            for(int j=i+1 ; j<n ; j++){
                if(number[i]==number[j]){
                    kaburi[j]=true;
                    sale[i]+=(price[j]*quantity[j]);
                }
            }
        }
        for(int i=0 ; i<n ; i++){
            if(kaburi[i]){
                continue;
            }
            if(sale[i]>=1000000&&used[number[i]]==false){
                cout << number[i] << endl;
                hantei=false;
                used[number[i]]=true;
            }
        }
        if(hantei){
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

typedef struct {
  int employee_num;
  int sales_price;
  int sales_value;
}employee_list;

int main(){
  int data_num;
  int i_cnt = 0;
  employee_list employee_list_buff;
  employee_list employee[1000];

  cin >> data_num;

  while(data_num > 0){
    cin >> employee_list_buff.employee_num >> employee_list_buff.sales_price >> employee_list_buff.sales_value;

    if(employee_list_buff.sales_price * employee_list_buff.sales_value >=  1000000){
      employee[i_cnt].employee_num = employee_list_buff.employee_num;
      employee[i_cnt].sales_price = employee_list_buff.sales_price;
      employee[i_cnt].sales_value = employee_list_buff.sales_value;
      i_cnt++;
    }
    data_num--;
  }

  if(i_cnt > 0){
    for(int i_array = 0 ; i_array < i_cnt ; i_array++){
      cout << employee[i_array].employee_num << endl;
    }

  }else{
    cout << "NA";
  }
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
	int n,num,price,amount;
	while(cin>>n&&n){
		map<int,long long> m;
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			long long sum = (long long)price*amount;
			if(m.find(num)!=m.end()) m[num]+=sum;
			else m[num]=sum;
		}
		for(map<int,long long>::iterator it=m.begin();it!=m.end();++it){
			if((*it).second>=1000000) v.push_back((*it).first);
		}
		if(v.size()!=0) for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		else cout<<"NA\n";
	}
	return 0;
}

C++: #include <iostream>

int main()
{
	const int threshold = 1000000;
	int n;
	
	while (std::cin >> n, n) {
		bool naFlag = true;
		while (n--) {
			int id;
			//__int64 unit, quantity;
			long long unit, quantity;
			std::cin >> id >> unit >> quantity;
			
			if (unit * quantity >= threshold)  {
				naFlag = false;
				std::cout << id << std::endl;
			}
		}
		if (naFlag) std::cout << "NA" << std::endl;
	}
	
	return 0;
}