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 <cstring>
#include <map>
using namespace std;

int main() {
	int n;
	while(std::cin >> n){
		if(!n){
			return 0;
		}
		std::map<int, long long> sales;
		while(n--){
			int id, unit, num;
			std::cin >> id >> unit >> num;
			sales[id] += unit * num;
		}
		map<int, long long>::iterator it;
		bool found = false;
		for(it = sales.begin(); it != sales.end(); it++){
			if(it->second >= 1000000){
				found = true;
				std::cout << it->first << std::endl;
			}
		}
		if(!found){
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	while (cin >> n&&n) {
		long long member[4001] = {0};
		long long a, b, c;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			member[a] += b*c;
		}
		int count = 0;
		for (int i = 0; i < 4001; i++) {
			if (member[i] >= 1000000) {
				count++;
				cout << i << endl;
			}
		}
		if (count == 0)cout << "NA" << endl;
	}
}

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

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

int main(){
	int n;
	while( cin >> n, n ){
		map<int, int> worker;
		queue<int> order;
		for( int i = 0; i < n; i++ ){
			int id, price, num;
			cin >> id >> price >> num;
			if( worker.find(id) == worker.end() ){
				order.push(id);
			}
			worker[id] += price * num;
		}
		bool flag = true;
		while( !order.empty() ){
			if( worker[order.front()] >= 1000000 ){
				cout << order.front() << endl;
				flag = false;
			}
			order.pop();
		}
		if( flag ){
			cout << "NA" << endl;
		}
	}
}

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

typedef long long Int;

int main(){
	const int AIM = 1000000;
	int n;
	int num, per, sum;
	bool exist;
	bool comp[4001];
	Int pro[4001];
	
	while(true){
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 1; i <= 4000; i++){
			comp[i] = false;
			pro[i] = 0;
		}
		exist = false;
		for(int i = 0; i < n; i++){
			scanf("%d%d%d", &num, &per, &sum);
			if(comp[num]) continue;
			if(pro[num] + (Int)per * sum >= AIM){
				exist = true;
				comp[num] = true;
				printf("%d\n", num);
			}
			else{
				pro[num] += (Int)per * sum;
			}
		}
		if(!exist) printf("NA\n");
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    while(true){
        int n; cin>>n;
        if(n==0)break;
        map<ll,ll> m;
        REP(i,n){
            ll e,p,q; cin>>e>>p>>q;
            if(m.find(e)==m.end())m[e]=p*q;
            else m[e]+=p*q;
        }
        int cnt=0;
        for(auto itr=m.begin();itr!=m.end();itr++){
            if(itr->second>=1000000){
                cout<<itr->first<<endl;
                cnt++;
            }
        }
        if(cnt==0)cout<<"NA"<<endl;
    }
    
    
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	int number[4000];
	int tanka[4000];
	int ryou[4000];
	long goukei[4000];
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka[i];
			cin>>ryou[i];
			goukei[i]=tanka[i]*ryou[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  int x,emp[4001],val[4001];
  int emp1,val1,con,flag;

  while(1){
    cin >> x;
    if(x==0)break;

    for(int i=0;i<4001;i++){
      emp[i]=0;
      val[i]=0;
    }
    for(int i=0;i<x;i++){
      cin >> emp1 >> val1 >> con;

      flag=0;
      for(int j=0;j<x;j++){
	if(emp[j]==emp1){
	  flag=1;
	  val[j]+=val1*con;
	  break;
	}
      }
      if(flag==0){
	for(int j=0;j<4001;j++){
	  if(emp[j]==0){
	    emp[j]=emp1;
	    val[j]=val1*con;
	    break;
	  }  
	}
      }
    }
      flag=0;
    for(int j=0;j<4001;j++){
      if(val[j]>=1000000){
	cout << emp[j] << endl;
	flag=1;
      }
    }
    if(flag==0)cout << "NA" << endl;
  }
  return 0;
}