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<stdio.h>


int main(){
	int n;
	int id,price,num;
	bool f=false;
	int i;
	while(scanf("%d",&n),n){

		for(i=0;i<n;i++){
			scanf("%d %d %d",&id,&price,&num);
			if(price*num>1000000){
				printf("%d\n",id);
				f=true;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		bool printed = false;
		rep(i, n){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			if(1000000 <= b*c){
				printf("%d\n", a);
				printed = true;
			}
		}
		if(!printed)
			puts("NA");
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[4000];
	int a,b,c;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<4000;i++)
		s[i]=0;
	for(int i=0;i<n;i++){
		cin>>a>>b>>c;
		s[a]+=b*c;
	}
	bool t=false;
	for(int i=0;i<4000;i++){
		if(s[i]>=1000000){
			cout<<i<<endl;
			t=true;
		}
	}
	if(t==false)
		cout<<"NA"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int n;
ll need = (int)1e6;

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		
		map<ll, ll> sum;
		set<ll> ids;
		for (int i = 0; i < n; i++) {
			ll id, p, q; cin >> id >> p >> q;
			ids.insert(id);
			sum[id] += (p * q);
		}
		
		bool na = true;
		set<ll>::iterator it;
		for (it = ids.begin(); it != ids.end(); it++) {
			if (sum[(*it)] >= need) {
				cout << (*it) << endl;
				na = false;
			}
		}
		
		if (na) cout << "NA" << endl;
	}
	
	return 0;
}

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){
		ll id[4005]={0};
		int a[8000]={0};
		
		rep(i,n){
			ll t1,t2,t3;
			cin>>t1>>t2>>t3;
			a[i]=t1;
			//if(id[t1]>0){
				id[t1]+=t2*t3;
			//}
			/*
			else{
				id[t1]=t2*t3;
			}
			*/
		}
		bool f=true;
		rep(i,4005){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
	return 0;
}

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

struct data {
	int ID;
	long total;
	int order;

	data() {
		ID = -1;
		total = 0;
		order = 100000;
	}

	data(int n) {
		ID = n;
		total = 0;
		order = 100000;
	}

	bool operator<(const data d) const {
		return order < d.order;
	}
};

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		data table[4096];
		bool flag = false;
		int order_count = 0;

		for(int i = 0; i < sizeof(table) / sizeof(table[0]); i++) {
			table[i] = data(i);
		}

		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			if(table[ID].order != 100000) {
				table[ID].order = order_count;
				order_count++;
			}

			table[ID].total += price * sale;
		}

		sort(table, table + 4096);

		for(int i = 0; i < 4096; i++) {
			if(table[i].total >= 1000000) {
				cout << table[i].ID << endl;
				flag = true;
			}
		}

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

	return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  int n;
  while (cin >> n, n) {
    long xs[4002];
    rep (i, 4002) xs[i] = 0;
    rep (i, n) {
      long a,b,c; cin >> a >> b >> c;
      xs[a] += b * c;
    }
    bool bl = true;
    rep (i, 4002) {
      if (xs[i] >= 1000000) {
        cout << i << endl;
        bl = false;
      }
    }
    if (bl) {
      cout << "NA" << endl;
    }
  }

  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int a[4000];
bool check[4000];
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<4000;i++){
		a[i]=0;
		check[i]=true;
	}
	bool na=true;
	long long b,c,d;
	for(int i=0;i<n;i++){
		cin>>b>>c>>d;
		a[b-1]+=c*d;
		if(a[b-1]>=1000000&&check[b-1]==true){
			check[b-1]=false;
			na=false;
			cout<<b<<endl;
		}
	}
	if(na==true)
		cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

typedef unsigned long long ll;

ll data[4001];
int status;

void print(){
  for(int i = 0; i < 4001; i++)
    if(data[i] >= 1000000){
      cout << i << endl;
      status = 0;
    }
}
int main(){
  ll in;
  while(cin >> in && in){
    status = 1;
    fill(data,data+4001,0);
    for(int i = 0; i < in; i++){
      ll num,p,q;
      cin >> num >> p >> q;
      data[num] += p*q;
    }
    print();
    if(status) cout << "NA" << endl;
  }
  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 >> 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;
}