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++: #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;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<map>
using namespace std;

int main(){

	while (true) {
		int cnt = 0;
		cin >> cnt;
		if (cnt == 0) break;

		std::map<int, int> data;
		for (int i = 0; i < cnt; ++i) {
			int id, price, amount;
			cin >> id >> price >> amount;
			int g = price * amount;

			if (data.find(id) == data.end()) data[id] = 0;
			data[id] += g;
		}
		bool bHitted = false;
		for (std::map<int, int>::iterator it = data.begin(); it != data.end(); ++it) {
			// cout << "--" << it->first << ", " << it->second << "\n";
			if (it->second >= 1000000) {
				cout << it->first << "\n";
				bHitted = true;
			}
		}
		if (!bHitted) {
			cout << "NA\n";
		}
	}
	return 0;
}

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

int main() {
  int num = 0;
  while (cin >> num, num) {
    int data[4000] = { 0 };
    int count = 0;
    for (int i = 0; i < num; i++) {
      int id, price, sold_num;
      cin >> id >> price >> sold_num;
      data[id] += price*sold_num;
    }
    for (int i = 0; i < 4000; i++) {
      if (data[i] >= 1000000) {
        cout << i << endl;
        count++;
      }
    }
    if (count == 0) {
      cout << "NA" << endl;
    }
  }
}