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

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int lint;

int data[4001] = { 0 };

bool AOJ0100() {
	lint n, e, p, q;
	cin >> n;
	if (n == 0) return false;

	lint* data = new lint[4001];
	for (int i = 0; i <= 4000; i++) data[i] = 0;

	for (lint i = 0; i < n; i++) {
		cin >> e >> p >> q;
		data[e] += p * q;
	}

	bool flag = false;
	for (int i = 1; i <= 4000; i++) {
		if (data[i] >= 1000000) {
			flag = true;
			cout << i << endl;
		}
	}
	if (!flag) cout << "NA" << endl;

	delete[] data;
	return true;
}

int main()
{
	while (AOJ0100()) {
	}
	return 0;
}

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

int main()
{
	int num, yen, ko;
	int c = 0;
	
	while (1){
		cin >> num;
		if (!num)	break;

		for (; num > 0; num--){
			cin >> num >> yen >> ko;

			if (yen * ko >= 1000000){
				cout << num << endl;
				c++;
			}
		}

		if (c == 0)
			cout << "NA" << endl;
	}

	return 0;
}

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

int main(){
	vector<pair<int,long long> > v;
	int n,a;
	long long b,c;
	while(cin>>n&&n){
		v.clear();
		while(n--){
			cin>>a>>b>>c;
			int index = -1;
			for(int i=0;i<v.size();i++){
				if(a==v[i].first){
					index = i;
					break;
				}
			}
			if(index==-1)v.push_back(make_pair(a,b*c));
			else v[index].second += b*c;
		}
		bool flag = false;
		for(int i=0;i<v.size();i++){
			if(v[i].second >= 1000000){
				flag = true;
				cout<<v[i].first<<endl;
			}
		}
		if(!flag)cout<<"NA\n";
	}
	return 0;
}

C++: #include <stdio.h>
 
 

 
int main(void){
	int i,j,k;
	int n,num[4000];
	long long int tanka,sale_num,sale_sum[4000],sale_all[4001];
	bool judge[4001];
	
	while(scanf("%d",&n),n){
		
		//初期化

		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka,&sale_num);
			sale_sum[i]=tanka*sale_num;
		}
		
		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[i]] = sale_all[num[i]] + sale_sum[i];
		}
		
		for(i=0;i<n;i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		
		if(k!=1)printf("NA\n");
	}
	
	return 0;
}

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

int p[4001];
int result[1000000];

int main(){
	int i ,j=0 , n , id , price , num , cnt;
	while(cin>>n){
		cnt=0;
		memset(p,0 , sizeof(p)/sizeof(p[0]));
		if (n==0) break;
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
				p[id]+=price*num;
			}
		for(i=0 ; i<4001 ; i++){
			if(p[i]>=1000000){
				result[j++]=i;
				cnt++;
			}
		}
		if (cnt==0) {
				result[j++]=0;
			}
	}
	for(i=0;i<j;i++){
		if (result[i]==0) {
			cout << "NA" << endl;
		} else {
		cout << result[i] << endl;
		}
	}
	return 0;
}

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

using namespace std;

// ベクターに売り上げを記録していく。
// 同じ社員が複数のデータを持つこともあるので、
// 記録がある場合には加算していく。
// 1000000以上の場合に社員番号を出力する。
// 該当する社員0人の場合はNAを出力する。

int main() {

	int N;
	while (cin >> N , N != 0) {
		vector<pair<int, long long>> data;

		for (int i = 0; i < N; ++i) {
			int number, price, sales;
			cin >> number >> price >> sales;
			auto it = find_if(data.begin(), data.end(), [number](pair<int, int> x) {return x.first == number;});
			auto total = static_cast<long long>(price) * sales;
			if (it != data.end()) {
				it->second += total;
			}
			else {
				data.emplace_back(pair<int, long long>{number, total});
			}
		}
		int cnt = 0;
		for (const auto a : data) {
			if (a.second >= 1000000) {
				++cnt;
				cout << a.first << endl;
			}
		}
		if (0 == cnt) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main() {
	while(true) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		vector<int> number;
		vector<int> score;
		for ( int i = 0; i < n; i++ ) {
			int input_number;
			int tanka;
			int kazu;
			cin >> input_number >> tanka >> kazu;
			for ( int j = 0; j <= number.size(); j++ ) {
				if ( j != number.size() ) {
					if ( number[j] == input_number ) {
						score[j] += tanka * kazu;
						break;
					}
				}else {
					number.push_back(input_number);
					score.push_back(tanka * kazu);
					break;
				}
			}
		}
		bool f = true;
		for ( int i = 0; i < number.size(); i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << number[i] << endl;
				f = false;
			}
		}
		if ( f ) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
#define SALES_GOAL 1000000 
using namespace std;
int main(void){
  int i,n;
  int price,qua;
  while(cin>>n,n){
    int tof = 1;
    int staff_info[n];
    for(i=0;i<n;i++){
      cin >> staff_info[i] >> price >> qua;
      staff_info[i] = price>SALES_GOAL && qua? staff_info[i]
                      :price*qua>SALES_GOAL ? staff_info[i] : 0;
    }
    for(i=0;i<n;i++){
      if(staff_info[i]){
        cout<<staff_info[i]<<endl;
        tof=false;
      }
    }
    if(tof){
        cout << "NA\n";
    }
  }
}

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

std::vector<std::string> split(std::string ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str," ");
if(std::stoi(ref[1])*std::stoi(ref[2])>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}