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 <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


ll n;

int main(){
	while(cin>>n,n!=0){
		map <ll,ll> id;
		vector<ll> a;
		rep(i,n){
			ll t1,t2,t3;
			a.push_back(t1);
			cin>>t1>>t2>>t3;
			if(id[t1]>0){
				id[t1]+=t2*t3;
			}
			else{
				id[t1]=t2*t3;
			}
		}
		bool f=true;
		rep(i,a.size()){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<pair<int,ll>> s(4000, {inf, 0});
        vector<bool> ip(4000,false);
        REP(i,n) {
            ll e,p,q;
            cin >> e >> p >> q;
            e--;
            if (ip[e]) {
                s[e].se += p*q;
            }
            else {
                s[e] = make_pair(i,p*q);
                ip[e] = true;
            }
        }
        vector<pair<int,int>> ans;
        REP(i, 4000) {
            if (s[i].se >= 1000000) {
                ans.pb({s[i].fi, i+1});
            }
        }
        sort(ALL(ans));
        REP(i,ans.size()) cout << ans[i].se << endl;
        if (ans.size() == 0) cout << "NA" << endl;
    }
    return 0;
}

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;
typedef long long ll;
#define INF 1000000000
#define EPS 0.000001

int n;
struct date{
	int num;
	ll total;
	bool flag;
}D[4000];
 
int main(){
 
	while(true){
	
		cin >> n;
		if(n == 0)
			break;
		int count = 0;
		bool flag = false;
		for(int i = 0; i < n; i++){
			int kari;
			cin >> kari;
			for(int j = 0; j < count; j++){
				if(D[j].num == kari){
					flag = true;
					int kari1, kari2;
					cin >> kari1 >> kari2;
					if(D[j].total + kari1*kari2 >= 1000000){
						D[j].flag = true;
					}
				}
			}
			if(!flag){
				D[count].num = kari;
				int kari1, kari2;
				cin >> kari1 >> kari2;
				D[count].total = kari1*kari2;
				D[count].flag = false;
				if(D[count].total >= 1000000)
					D[count].flag = true;
				count++;
			}
		}

		bool flag2 = false;
		for(int i = 0; i < count; i++){
			if(D[i].flag){
				flag2 = true;
				printf("%d\n", D[i].num);
			}
		}
		if(!flag2){
			printf("NA\n");
		}

	}

	


	return 0;
 
}

C++: #include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  int n,f;
  long long a,b,c;
  while(std::cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)cout<<"NA"<<endl;
  }
  return 0;
}

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

#define N 4000

int main(void) {
	int shine[N+1];
	bool shinef[N+1];
	bool na;
	int n,a,b,c;

	while (cin >> n, n) {
		na = true;
		for (int i = 0; i < N; i++) {
			shine[i] = 0;
			shinef[i] = false;
		}
		while (n--) {
			cin >> a >> b >> c;
			shine[a] += c*b;
			if (shine[a] >= 1000000 && shinef[a] == false) {
				cout << a << endl;
				shinef[a] = true;
				na = false;
			}
		}
		if (na) cout << "NA" << endl;
	}
	return 0;
}

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

int main()
{
	int n = 0;               //  社員の人数;n==0で終了
	bool flag = true;        //  flagはidの重複を確認する; trueは重複無し
	int id_temp,price_temp,amount_temp;
	vector<int> id;          //  社員のid
	vector<int> price;       //  the corresponding unit price
	vector<int> amount;      //  the amount of sales
	vector<int> result;      //  条件を満たすid郡

	while(true) {
		cin >> n;
		if(n==0)
			return 0;
		// 1つのデータセットに対する処理
		else {
			result.clear(); id.clear(); price.clear(); amount.clear(); // データをクリアする
			for(int i=0;i<n;i++) {
				cin >> id_temp >> price_temp >> amount_temp;
				flag = true;
				// idが重複している場合はすでにあるデータに上書きする
				for(int j=0;j<id.size();j++) {
					if(id_temp==id[j]) {
						price[j] += price_temp;
						amount[j] += amount_temp;
						flag = false;
						break;
					}
				}
				// 新しいidの場合は配列の末尾に追加する
				if(flag) {
					id.push_back(id_temp);
					price.push_back(price_temp);
					amount.push_back(amount_temp);
				}
			}
			// 売り上げ金額が1,000,000円以上の社員idを追加
			for(int i=0;i<n;i++) 
				if(price[i]*amount[i]>=1000000)
					result.push_back(id[i]);
			// 結果を出力
			if(result.size()==0)
				cout << "NA" << endl;
			else
				for(int i=0;i<result.size();i++)
					cout << result[i] << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    vector<int> sale;
    map<int, long long> comp;
    int a;
    long long b,c;
    bool f = true;
    while(n--){
      cin >>a>>b>>c;
      if(!comp[a]){sale.push_back(a);}
      comp[a]+=b*c;
    }
    for(int i=0; i<sale.size(); i++){
      if(comp[sale[i]] >= 1000000){cout <<sale[i]<<endl;f =false;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n, i, buf[3], *idlist, index_idlist = 0, milcount = 0;
	unsigned long long int *sale;

	scanf("%d", &n);

	sale = (unsigned long long int *)calloc(4000, sizeof(unsigned long long int));
	idlist = (int *)calloc(n, sizeof(int));

	while (n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &buf[0], &buf[1], &buf[2]);
			sale[buf[0] - 1] += buf[1] * buf[2];
			idlist[index_idlist++] = buf[0];
		}

		for (i = 0; i < n; i++){
			if (sale[idlist[index_idlist]] >= 1000000){
				printf("%d\n", idlist[index_idlist]);
				sale[idlist[index_idlist--]] = 0;
			}
			milcount++;
		}

		if (milcount == 0){
			puts("NA");
		}
		milcount = 0;
		scanf("%d", &n);
	}

	return 0;
}