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>
using namespace std;

typedef struct {
  int employee_num;
  int sales_price;
  int sales_value;
}employee_list;

int main(){
  int data_num;
  int i_cnt = 0;
  employee_list employee_list_buff;
  employee_list employee[1000];

  cin >> data_num;

  while(data_num > 0){
    cin >> employee_list_buff.employee_num >> employee_list_buff.sales_price >> employee_list_buff.sales_value;

    if(employee_list_buff.sales_price * employee_list_buff.sales_value >=  1000000){
      employee[i_cnt].employee_num = employee_list_buff.employee_num;
      employee[i_cnt].sales_price = employee_list_buff.sales_price;
      employee[i_cnt].sales_value = employee_list_buff.sales_value;
      i_cnt++;
    }
    data_num--;
  }

  if(i_cnt > 0){
    for(int i_array = 0 ; i_array < i_cnt ; i_array++){
      cout << employee[i_array].employee_num << endl;
    }

  }else{
    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 <iostream>
#include <algorithm>
using namespace std;

int main() {
	long long int i, n, no[4000], tanka[4000], num[4000];
	bool flg=false;
	while (1) {
		flg=false;
		cin>>n;
		if (n==0) break;
		for (i=0; i<n; i++)
			cin>>no[i]>>tanka[i]>>num[i];
		for (i=0; i<n; i++) {
			if (tanka[i]*num[i]>=1000000)
				flg=true, cout<<no[i]<<endl;
		}
		if (flg==false) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

typedef pair<int,long> P;

void solve100(int n) {
    
    vector<P> v(4001, make_pair(0,0));
    long o, p, q;
    int cnt = 1;
    REP(i,n) {
        cin >> o >> p >> q;
        if (v[o].first != 0) {
            v[o].second += p * q;
        }else {
            v[o].first = cnt;
            cnt++;
            v[o].second += p * q;
        }
    }
    vector<P> w;
    REP(i,4001) {
        if (v[i].second >= 1000000) w.push_back(make_pair(v[i].first, i));
    }
    sort(ALL(w));
    if (w.size()) {
        REP(i,w.size()) cout << w[i].second << endl;
    }else {
        cout << "NA" << endl;
    }
}

int main() {
    int n;
    while(cin >> n, n) {
        solve100(n);
    }
    return 0;
}

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

using namespace std;


int main() {
	int n;
	int name, price, number;
	map<int, int> m_Employee;

	while (cin >> n) {
		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> name >> price >> number;

			if (m_Employee.count(name)) {
				m_Employee[name] += price * number;
			}
			else {
				m_Employee.insert(map<int, int>::value_type(name, price*number));
			}
		}

		map<int, int>::iterator it = m_Employee.begin();
		bool flag = false;
		while (it != m_Employee.end()) {
			if ((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}

			it++;
		}

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

		m_Employee.clear();
	}

	return 0;
}

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

int main() {
	while(1){
long long s[4000];int i;int w;int j;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	if(b!=0){
	int g = 1000000 - s[a-1];
	if(g%b==0){j = g/b;}
	else{j = (g/b)+1;}
	if(j<c){s[a-1]=1000001;}
	else{s[a-1]=s[a-1]+b*c;}
	}
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n;
	int ban,tan,buy,flg,ff[4001];
	long long int sum[4001];
	while(1) {
		scanf("%d",&n);
		if(n==0) break;
		flg=0;
		for(i=0;i<4000;i++) {
			ff[i]=0;
			sum[i]=0;
		}
		for(i=0;i<n;i++) {
			scanf("%d %d %d",&ban,&tan,&buy);
			sum[ban]+=(long long)tan*buy;
			if(sum[ban]>=1000000) {
				flg=1;	
				if(ff[ban]==0) {
					ff[ban]=1;
					printf("%d\n",ban);
				}
			}
		}
		if(flg==0) printf("NA\n");
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        vector<int> ord;
        map<int, ll> total;
        int m, x, y;
        LOOP(n){
            cin >> m >> x >> y;
            if(!EXIST(ord, m)) ord.PB(m);
            total[m] += (ll)x*y;
        }
        bool f=true;
        EACH(ord, it)if(total[*it]>=1000000){
            f = false;
            cout << *it << endl;
        }
        if(f)cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>

#define FOR(i,a,b) for(int i=(a); i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

int main(){
  int n;//入力するデータ
  int check;
  while(cin >> n){
    if(n==0) break;
    check=0;
    ll num[4001]={0};//社員番号
    ll emp,cost,count;
    REP(i,n){
      cin >> emp >> cost >> count;
      num[emp] += cost * count;
    }
    REP(i,4001){
      if(num[i]>= 1000000){
        cout << i << endl;
        check++;
  }
    }
    if(check==0)
      cout << "NA" << endl;
  }
}