Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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

C++: #include <iostream>
#include <vector>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<int, bool> IB;

struct P{
	int id;
	int tanka;
	int kosuu;
};

ll shain[4001];
bool used[4001];
bool more[4001];

int main()
{
	int n;

	while (cin >> n && n ){
		memset (shain, 0LL, sizeof (shain ) );
		memset (used, false, sizeof (used ) );
		memset (more, false, sizeof (more ) );
		vector<P> data (n );

		rep (i, n )
			cin >> data[i].id >> data[i].tanka >> data[i].kosuu;

		rep (i, n ){
			ll total = (ll)data[i].tanka*(ll)data[i].kosuu;
			shain[data[i].id] += total;
		} // end if

		for (int i = 1; i <= 4000; i++ )
			if (shain[i] >= 1000000LL )
				more[i] = true;

		bool found = false;
		rep (i, n ){
			if (more[data[i].id] && !used[data[i].id] ){
				cout << data[i].id << endl;
				used[data[i].id] = true;
				if (!found )
					found = true;
			} // end if
		} // end rep

		if (!found )
			cout << "NA" << endl;
	} // end loop
		
	return 0;
}

C++: #include <cstdio>
#include <queue>
using namespace std;

bool employee[4000]={false}; 
const int sales = 1000000;

int main()
{
	int n;
	while(scanf("%d",&n)!=EOF) {
		if(n==0){break;}
		queue<int> employee_n;
		for(int i=0;i<n;++i) {
			int number,a,b;
			scanf("%d %d %d",&number,&a,&b);
			if(sales>a*b||employee[number-1]) continue;
			employee[number-1]=true;
			employee_n.push(number);
		}
		if(employee_n.empty()) puts("NA");
		else {
			while(!employee_n.empty()){
				printf("%d\n",employee_n.front());
				employee_n.pop();
			}
		}
	}
	return 0;
}