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 <cstdio>
#define X 4001
#define V 1000000
using namespace std;

int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int a[X],f[X];
		for(int i=0;i<X;i++) a[i] = 0;
		for(int i=0;i<X;i++) f[i] = 0;
		int b,c,d;
		int s = 0;
		for(int i=0;i<n;i++){
			cin >> b >> c >> d;
			if(a[b]<V) a[b] += c*d;
			if(f[b]==0){
				s++;
				f[b] = s;
			}
		}
		bool e = true;
		for(int i=1;i<X;i++){
			for(int j=0;j<X;j++){
				if(f[j]!=i) continue;
				if(a[j]>=V){
					e = false;
					cout << j << endl;
				}
				break;
			}
		}
		if(e) cout << "NA" << endl;
	}
}

C++: #include<iostream>
#include<map>
using namespace std;
const int MAXN = 4000;
typedef long long ll;
int i,p,q;
bool isfind = false;
map<int,ll> total;
int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)return 0;
    for(int k = 0;k < n;k++){
      cin >> i >> p >> q;
      total[i] += p*q;
    }
    for(map<int, ll>::iterator i = total.begin(); i != total.end(); ++i){
      if(i->second >= 1000000){
	isfind = true;
	cout << i->first << endl;
      }
    }
    if(!isfind)cout << "NA" << endl;
    total.clear();
    isfind =false;
  }
  return 0;
}

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

class employee {
public:
	long long int id;
	long long int p, q;
	bool more_than_million() {
		return (p * q >= 1000000);
	}
};

int n;
std::vector<employee> data;

void init()
{
	n = 0;
	data.clear();
}

bool get_input()
{
	init();
	std::cin >> n;
	if (n == 0) {
		return false;
	}
	for (int i = 0; i < n; i++) {
		employee tmp;
		std::cin >> tmp.id >> tmp.p >> tmp.q;
		data.push_back(tmp);
	}
	return true;
}

void solve()
{
    std::vector<employee>::iterator i = data.begin();
    std::vector<long long int> top_salers;
    while(i != data.end()){
       if((*i).more_than_million()){
    	   top_salers.push_back((*i).id);
        }
       i++;
     }
    if (top_salers.empty()) {
    	std::cout << "NA" << std::endl;
    } else {
    	for (std::vector<long long int>::iterator j = top_salers.begin(); j != top_salers.end(); j++) {
    		std::cout << (*j) << std::endl;
    	}
    }
}

int main()
{
	while (get_input()) {
		solve();
	}
	return 0;
}

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

using namespace std;

int main(void){
  int n, a, b, c;
  map<int, long int> m;
  vector<int> v;

  while(cin >> n, n){
    v.clear();  m.clear();

    for(int i=0; i<n; i++){
      cin >> a >> b >> c;

      if(m.find(a) != m.end()){
        m[a] += b * c;
      } else {
        v.push_back(a);
        m[a] = b * c;
      }
    }

    bool flag = false;
    for(int i=0; i<v.size(); i++){
      if(m[v[i]] >= 1000000){
        flag = true;
        cout << v[i] << endl;
      }
    }

    if(flag == false){
      cout << "NA" << endl;
    }
  }


  return 0;
}

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


main(){
  int n;
  while(cin >> n && n){
    bool flag=0;
    for(int i=0;i<n;i++){
      int num;
      long long a,b;
      cin >> num >> a >> b;
      if ( a*b >= 1000000){
        flag = 1;
        cout << num << endl;
      }
    }
    if ( !flag)puts("NA");
  }
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d\n", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memcpy(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d\n", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[i].Saled >= 1000000)
		{
			cout << sl[i].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
end_scope:
    return 0;
}

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

using namespace std;

typedef pair<int,long long int> PAIR;

int main(int argc, char **argv)
{
	int n, s, t, u, p;
	bool f, a[4001];
	PAIR pa[4001];
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		fill(a, a+4000, true);
		
		for(int i = 0; i < n; i++){
			cin >> s >> t >> u;
			pa[i].first = s;
			pa[i].second = t * u;
		}
		
		f = true;
		for(int i = 0; i < n; i++){
			if(pa[i].second >= 1000000 && a[pa[i].first]){
				cout << pa[i].first << endl;
				a[pa[i].first] = false;
				f = false;
			}
		}
		if(f){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int>  number;
	int d,num,item,ko;
	while(cin>>d){
		if(d==0) break;
		for(int i=0;i<d;i++){
			cin>>num>>item>>ko;
			item *= ko;
			if(item>=1000000){
				number.push_back(num);
			}
		}
		if(number.size()==0) cout<<"NA"<<endl;
		else{
				for(int j=0;j<number.size();j++){
				cout<<number[j]<<endl;
			}
			number.clear();
		}
	}
}

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

int n;
int main(){
	cin >> n;
	int id[n];
	int p[n];
	int q[n];
	int num = 0;
	for(int i = 0; i < n; i++){
		cin >> id[i] >> p[i] >> q[i];
		if(p[i] * q[i] >= 1000000){
			cout << id[i];
			num++;
		} 
	}
	if(num == 0){
		cout << "NA";
	} 
    return 0;
}

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

std::vector<std::string> split(const 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=0;
std::string str="";
std::vector<std::string> ref;
std::vector<std::string> res;

std::cin >> str;
if(str!="") it_num=std::stoi(str);

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;
}

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

int main(){

	int N,Q;
	while(1){
	cin>>N;if(N==0)break;
	long long int n[4001][2]={};
	for(int i=0;i<N;i++){
		long long int x,y,z;
		cin>>x>>y>>z;
		if(n[x][0]+y*z<=1000000)n[x][0]+=y*z;
		else if(n[x][0]+y*z>1000000)n[x][0]=1000000;
		if(n[x][1]==0)n[x][1]=i;
	
	}
	for(int i=0;i<4001;i++){
		for(int j=i;j>i;j--){
			if(n[j][1]<n[j-1][1]){
				int t=n[j][0];n[j-1][0];n[j-1][0]=t;
				int T=n[j][1];n[j-1][1];n[j-1][1]=T;
			}
		}
	}
	bool f=false;
	for(int i=0;i<4001;i++){
		if(n[i][0]>=1000000){cout<<i<<endl;f=true;}
	}
	if(f==false)cout<<"NA"<<endl;

	}
	return 0;
}