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<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int dp[310][310][610];
int main(){
    int n;
    while(cin>>n){
        bool f=true;
        for(int i=0;i<n;i++){
            ll e,p,q;
            cin>>e>>p>>q;
            if(p*q>=1000000){
                f=true;
                cout<<e<<endl;
            }
        }
        if(f){
            cout<<"NA"<<endl;
        }
    }
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    unsigned long long a[5000]={0},c=0,p,o,u;
    rep(i,n){
      scanf("%d%d%d",&p,&o,&u);
      a[p]+=o*u;
      if(a[p]>=1000000){cout<<p<<endl;c++;}
    }
    if(!c)cout<<"NA"<<endl;
  }
}

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

template<typename itr, typename func>
func for_each_withindex(itr fi, itr l, func f){
	unsigned i{};
	for(; fi!=l; ++fi,++i){
		f(*fi,i);
	}
	return f;
}

int main(int argc, char const* argv[])
{
	unsigned n{};
	while (std::cin >> n,n != 0) {
		unsigned e{}, p{}, q{};
		bool isna{true};
		std::array<float,4001> es{};
		for (unsigned i = 0; i < n; i++) {
			std::cin >> e >> p >> q;
				es.at(e) += p * q;
		}
		for_each_withindex(es.begin(), es.end(), [&isna](auto sell,auto e){ 
				if (sell>=1e6) {
				std::cout << e << std::endl;
				isna = false;
				}});
		if (isna) {
			std::cout << "NA" << std::endl;
		}

	}
	return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
using namespace std;
int main (int argc, char const* argv[]) {
  int saler_number;
  while (true) {
    cin >> saler_number;
    if (saler_number == 0) break;
    map<int,long long> result;
    vector<int> history;
    int id, price, num;
    for (int i = 0; i < saler_number; i += 1) {
      cin >> id >> price >> num;
      if (result.count(id) == 0) {
        result.insert(make_pair(id,price * num));
        history.push_back(id);
      } else {
        result[id] += price * num;
      }
    }
    //
    bool valid_NA = true;
    for (int i = 0; i < history.size(); i += 1) {
      if (result[history[i]] >= 1000000) {
        cout << history[i] << endl;
        valid_NA = false;
      }
    }
    /*
    map<int,long long>::iterator it = result.begin();
    while (it != result.end()) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        valid_NA = false;
      }
      //cout << it->first << ":" << it->second << endl;
      it++;
    }
    */
    if (valid_NA) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<stdio.h>

struct staff_data{
	int num;
	/*long unsigned*/ int price,volume,total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	while(scanf("%d",&n)!=0){
	
		if(n==0){
			break;
		}
		
		staff_data dt[4000]={0};
		
		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			
			for(j=i;j<=i;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					/*dt[j].price=price;
					dt[j].volume=volume;*/
					dt[j].num=num;
					dt[j].total=(price)*(volume)+dt[j].total;
					//dt[j].total=(dt[j].price)*(dt[j].volume)+dt[j].total;
					
					break;
				}
				
			}
		}

		hantei=0;

		for(j=0;j<n;j++){
		
			if(dt[j].total>=1000000){
				printf("%4d\n",dt[j].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#define int long long
using namespace std;

class Input {
public:
	int n;
	vector<int> numbers, tanka, num;
	
	bool input() {
		scanf("%lld", &n);
		if (!n) {
			return false;
		}
		for (int i = 0; i < n; i++) {
			int s, t, u;
			scanf("%lld%lld%lld", &s, &t, &u);
			numbers.push_back(s);
			tanka.push_back(t);
			num.push_back(u);
		}
		return true;
	}
};
class Solver : public Input {
public:

	vector<int> solve() {
		typedef pair<int, int> P;
		map<int, int> data;
		for (int i = 0; i < n; i++) {
			int value = tanka[i] * num[i];
			int number = numbers[i];
			
			if (data.find(number) == data.end() ) {
				data[number] = 0;
			}
			data[number] += value;
		}
		
		vector<int> ret;
		for (map<int, int>::iterator it = data.begin(); it != data.end(); it++) {
			if ((*it).second >= 1000000 ) {
				ret.push_back((*it).first);
			}
		}
		return ret;
	}
};

signed main() {
	while (true) {
		Solver solver;
		if (!solver.input() ) {
			break;
		}
		
		vector<int> res = solver.solve();
		if (res.size() == 0) {
			cout << "NA" << endl;
		}
		else {
			for (int i = 0; i < res.size(); i++) {
				cout << res[i] << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{   
    int n;
    long long int ids[4001];
    int id, price, amount;
    bool exist;
    bool used[4001];
    vector<int> rank;
    while(cin >> n && n)
    {   
        exist=false;
        for(int i=1;i<4001;++i)
        {   
            ids[i] = 0;
            used[i] = false;
        }
        rank.clear();
        for(int i=0;i<n;++i)
        {   
            cin >> id >> price >> amount;
            if(!used[id])
            {   
                rank.push_back(id);
                used[id] = true;
            }
            ids[id] += price * amount;
        }
        for(int i=0;i<rank.size();++i)
        {   
            if(ids[rank[i]] >= 1000000)
            {   
                exist = true;
                cout << rank[i] << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
        for(int i=0;i<rank.size();++i) cout << rank[i] << " ";
        cout << endl;
    }
}