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

int main(){
	int n, num;
	long long price, amount;
	map<int, long long> member;
	vector<int> array;

	while(cin >> n, n){
		member.clear();
		array.clear();
		for(int i = 0; i < n; i++){
			cin >> num >> price >> amount;
			member[num] +=  price * amount;
			for(int i = 0; i < array.size(); i++){
				if(num == array[i]){
					continue;
				}
			}
			if(member[num] >= 1000000){
				array.push_back(num);
			}
		}
		if(array.empty()){
			cout << "NA" << endl;
		}
		else{
			for(int i = 0; i < array.size(); i++){
				cout << array[i] << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int lli;

const lli kSum = 1000000;

lli getSum(int price, int sales)
{
  return price * sales;
}

int main()
{
  int n_employee;
  int number;
  lli price, sales;
  bool flag;
  map<int, lli> checkEmp;
  vector<int> empNumbers;

  while(cin >> n_employee){
    if(n_employee == 0){
      break;
    }

    flag = true;

    for(int i = 0; i < n_employee; ++i){
      cin >> number >> price >> sales;

      if(checkEmp.find(number) != checkEmp.end()){
	checkEmp[number] += getSum(price, sales);
      } else {
	checkEmp[number] = getSum(price, sales);
	empNumbers.push_back(number);
      }
    }

    int length = empNumbers.size();
    for(int i = 0; i < length; ++i){
      if(checkEmp[empNumbers[i]] >= kSum){
	cout << empNumbers[i] << endl;
	flag = false;
      }
    }

    if(flag){
      cout << "NA" << endl;
    }
    checkEmp.clear();
  }

  return 0;
}

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

using namespace std;

int main(void){
	vector<int> staffNumber;
	vector<int> sellingPrice;
	vector<int> qty;
	int count=0;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int sN,sP,qt;
		cin >> sN >> sP >> qt;
		staffNumber.push_back(sN);
		sellingPrice.push_back(sP);
		qty.push_back(qt);
	}
	for(int i=0;i<n;i++){
		if(sellingPrice[i]*qty[i]>=1000000){
			cout << staffNumber[i] << endl;
			count++;
		}
	}
	if(count==0 and  n != 0){
		cout << "NA" << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#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(scanf("%d\n", &n) != EOF) {
		map<int, ll> m;
		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) {
			auto it = m.find(id.at(i));
			if(it == m.end()) {
				m.insert(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
			} else {
				(*it).second += p.at(i) * q.at(i);
			}
		}
		bool flag = false;
		for(auto it = m.begin(); it != m.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
	long long int i, j, n, no[4000], tanka[4000], num[4000], ans[4000];
	bool flg=false;
	while (1) {
		j=0;
		flg=false;
		cin>>n;
		if (n==0) break;
		for (i=0; i<n; i++)
			cin>>no[i]>>tanka[i]>>num[i];
		for (i=0; i<n; i++) {
			if (tanka[i]*num[i]>=1000000)
				flg=true, ans[j]=no[i], j++;
		}
		sort(ans, ans+(j+1));
		if (flg==false) cout<<"NA"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){

  int n, id, val, num, cnt;
  long long member[4000];
  int index[4000];

  while(cin >> n){

    if(!n) break;

    cnt = 0;
    memset(member, -1, sizeof(member));
    memset(index, -1, sizeof(index));

    for(int i = 0; i < n; ++i){

      cin >> id >> val >> num;

      if(member[id - 1] == -1){
        index[cnt] = id - 1; ++cnt;
        member[id - 1] += 1 + val * num;
      } else {
        member[id - 1] += val * num;
      }

    }

    bool flag = false;

    for(int i = 0; i < cnt; ++i){
      if(member[index[i]] >= 1000000){
        cout << index[i] + 1 << endl;
        flag = true;
      }
    }

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

  }

}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

#define INF 10000000
#define MAX_N 4001

int n;
int meibo[MAX_N];

struct kanri{

	int number;
	long long sum;

}syain[MAX_N];

void shoki();

int main(){

	while(true){
	
		scanf("%d", &n);

		if(n == 0)
			break;

		shoki();

		int num = 0;
		int kari;

		for(int i = 0; i < n; i++){
			scanf("%d", &kari);
			bool flag = false;
			for(int j = 0; j < num; j++){
				if(syain[j].number == kari){
					int kari1, kari2;
					scanf("%d%d", &kari1, &kari2);
					syain[j].sum += kari1*kari2;
					flag = true;
					break;
				}
			}

			if(!flag){
				int kari1, kari2;
				syain[num].number = kari;
				scanf("%d%d", &kari1, &kari2);
				syain[num].sum += kari1 * kari2;
				num++;
			}

		}

		bool flag2 = false;

		for(int i = 0; i < n; i++){
			if(syain[i].sum >= 1000000){
				printf("%d\n", syain[i].number);
				flag2 = true;
			}
		}

		if(!flag2){
			printf("NA\n");
		}

	
	}


	return 0;

}

void shoki(){
	for(int i = 0; i < MAX_N; i++){
		syain[i].number = 0;
		syain[i].sum = 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 main() {
	int n;
	while(scanf("%d\n", &n), n){
		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;
}