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 <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int N; cin >> N, N;) {
		bool f = false;
		rep(i,N) {
			int num, a, b;
			cin >> num >> a >> b;
			if(a * b >= 1000000) {
				cout << num << endl;
				f = true;
			}
		}
		if(!f) cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;

void Swap(int&, int&);

int main(){
  int i, j, n, id, x, y, sum;
  vector<int> data;

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

    for(i=0; i<n; ++i){
      cin >> id >> x >> y;
      if(x < y) Swap(x, y);

      for(j=0, sum=0; j<y; ++j){
	sum += x;
	if(sum >= 1000000){
	  data.push_back(id);
	  break;
	}
      }
    }

    if(data.size() == 0){
      cout << "NA" << endl;
    }else{
      for(i=0; i<data.size(); ++i)
	cout << data[i] << endl;
    }

    data.clear();
  }
  return 0;
}

void Swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}

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

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

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

		int num,x,y;
		int mon=0,cnt=0;
		for(int i=0 ;i<n ;i++){
			cin >> num >> x >> y;

			mon = x*y;
			if(mon >=1000000){
				cout << num << endl;
				cnt++;
			}
		}
		if(cnt==0)
			cout << "NA" << endl;

	}
	return 0;
}

C++: #include <iostream>
using namespace std;main(){int n,m;while(cin>>n&&n){m=1;while(n--){long U,p,s;cin>>U>>p>>s;if(p*s>=1000000)m=0,cout<<U<<endl;}if(m)cout<<"NA\n";}}

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		int company[4000] = { 0 };
		int num, sell, cnt;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			company[num - 1] += sell*cnt;
		}
		for (int i = 0; i < 4000; i++)
		{
			if (company[i] >= target)
			{
				printf("%d\n", i + 1);
				hero = true;
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include<cstdio>

int main(){
int a,i;
bool fl;
unsigned long int b,c;
while(1){
scanf("%d",&i);
fl=false;
for(;i>0;i--){


 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%d",&b);
 scanf("%d",&c);
if(a*c>=1000000) {
 fl=true;
 printf("%d\n",a);
}
if(fl==false) pritnf("NA\n");
}
}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    int id, price, amount;
    vector<int> rank;
    map<int, long long> ids;
    bool exist;
    while(cin >> n && n)
    {
        exist=false;
        rank.clear();
        ids.clear();
        for(int i=0;i<n;++i)
        {
            cin >> id >> price >> amount;
            if(!ids[id]) rank.push_back(id);
            ids[id] += price * amount;
        }
        for(int i=0;i<rank.size();++i)
        {
            if(ids[rank[i]] >= 1000000)
            {
                exist = true;
                cout << rank[i] << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
}

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

int main(){
	int N;
	
	while(cin>>N,N){
		map<int,long long int> mp,mp2;
		vector <int> vi;
		priority_queue<int, vector<int>, greater<int> >pq;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			mp[num]+=tanka*suuryo;
			vi.push_back(num);
			if(mp[num]>=1000000){
				mp2[num]++;
			}
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
                        int a=*it;
			if(mp2[a]>=2){
				mp2[a]--;
			}
			else if(mp2[a]==1){
				pq.push(a);
				mp2[a]--;
			}
		}
		if(pq.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=pq.size();
			for(int i=0;i<len;i++){
				cout<<pq.top()<<endl;
				pq.pop();
			}
		}
	}
	return 0;
}

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

const int sales = 1000000;

int main()
{
	int n;
	while(scanf("%d",&n),n) {
		bool flag[4000]={false};
		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||flag[number-1]) continue;
			flag[number-1]=true;
			employee_n.push(number);
		}
		while(!employee_n.empty()){
			printf("%d\n",employee_n.front());
			employee_n.pop();
		}
		if(employee_n.empty()) puts("NA");
	}	
	return 0;
}

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

int main(){
	int n, No, unit, number;

	while( cin >> n , n ){
		map<int,int> employees;
		vector<int> vc;
		bool flag = false;
		for(int i=1 ; i<=4000 ; ++i ){
			employees[i] = 0;
		}
		
		for(int i=0 ; i<n ; ++i ){
			cin >> No >> unit >> number;
			if( count( vc.begin() , vc.end() , No ) == 0 ){
				vc.push_back( No );
			}
			employees[No] += unit * number;	
		}
		for(int i=0 ; i<vc.size() ; ++i ){
			if( employees[ vc[i] ] >= 1000000 ){
				cout << vc[i] << endl;
				flag = true;
			}
		}
		if( flag == false ){
			cout << "NA" << endl;
		}
	}
}