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<map>
using namespace std;
int main(){
  long long ans[4000]={0};
  int n,number,money,many,over_many=0,over[4000]={0};
  while(1){
    cin >> n;
    if(n==0)break;
    over_many=0;
    memset(over,0,sizeof(over));
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++){
      cin >> number >> money >> many;
      ans[number]+=money*many;

      if(ans[number]>=1000000){
	if(over[number]==0){
	  over_many++;
	  over[number]=1;
	}
      }

    }
    if(over_many==0){
      cout << "NA" << endl;
    }
    else{
      for(int k=0,j=0;j<over_many;k++){
	if(over[k]==1){
	  cout << k << endl;
	  j++;
	}
      }
    }

  }
}

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

long long owData[4001];
std::vector<int> used;

int main(){
  long long x,input[3];
	bool Person;
	while( std::cin>>x , x ){
		Person=false;
		used.clear();
		memset(owData,0,sizeof(owData));
		while( x-- ){
			std::cin>>input[0]>>input[1]>>input[2];
			if( owData[input[0]] == 0 )used.push_back(input[0]);
			owData[input[0]]+=input[1]*input[2];
		}
		for(auto it = used.begin(); it != used.end(); ++it ){
			if( owData[*it] >= 1000000 )
				std::cout<< *it <<std::endl, Person=true ;
		}
		if(!Person)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    Vi v;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      v.pb( a );
      m[a] += b * c;
    }
    Uniq( v );
    
    Rep(i, v.size()) {
      if( m[v[i]] >= 1000000 ) {
	cout << v[i] << endl;
	flag = true;
      }
    }

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

C++: #include <iostream>

using namespace std;
class MAN{
public:
	unsigned int uriage;
	int number;
};

int main(int argc, char const* argv[])
{
	MAN person[4000];
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		for( int i = 0;i < n;i++ ){
			person[i].uriage = 0;
			person[i].number = 0;
		}

		for( int i = 0;i < n;i++ ){
			int target;
			unsigned int a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,h,h2,ib;
  while(cin>>n){
    if(n==0) break;
    h = 0;
    ib = 0;
    int b[n],p[n],q[n],ansb[n],ans[n];
    for(int i=0;i<n;i++){
      cin >> b[i] >> p[i] >> q[i];
      h2 = 0;
      for(int j=0;j<i;j++){
	if(ansb[j]==b[i]){
	  ans[j] += p[i] * q[i]; 
	  h2 = 1;
	  break;
	}
      }
      if(h2==0){
	ans[ib] = p[i] * q[i];
	ansb[ib] = b[i];
	ib++;
      }
    } 
    for(int i=0;i<ib;i++){
      if(ans[i]>=1000000){
	cout << ansb[i] << endl;
	if(h==0) h = 1;
      }
    }
    if(h==0) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long> info;
        map<int, long long>::iterator it;
        vector<long long> name;
        rep(i,n){
            long long a, b, c;
            cin >> a >> b >> c;
            if(!info[a])name.push_back(a);
            info[a] += b * c;
        }
        bool c = true;
        rep(i, name.size()){
            if(info[name[i]]>= 1000000){
                cout << name[i] << endl;
                c = false;
            }
        }
        if(c) cout << "NA" << endl;
    }
}

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

map<int,unsigned long long> man;

int main(){
    int n;
    while(cin>>n,n){
        man=map<int,unsigned long long>();
        rep(i,n){
            int id,p,n; cin>>id>>p>>n;
            man[id]+=p*n;
        }
        int c=0;
        for(auto&m:man){
            if(m.second>=1000000){
                cout<<m.first<<endl;
                c++;
            }
        }
        if(c==0) cout<<"NA"<<endl;
    }
}

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


int main(void)
{
	int n;

	while(cin >> n,n){
		int d[4000];
		bool f = false;
		fill(d,d+4000,0);

		int no,m,k;
		for(int i = 0; i < n; i++){
			cin >> no >> m >> k;
			d[no-1] += m*k;
		}

		for(int i = 0; i < 4000;i++)
			if(d[i] >= 1000000){
				cout << i+1 << end;
				f = 1;
			}
		if(!f)
			cout << "NA" << endl;
	}

	

	return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		long long no;
		long long price;
		long long deal;

		set <long long> visited;

		bool f = true;
		for ( int i = 0; i < n; i++ )
		{
			cin >> no >> price >> deal;
			if ( visited.find( no ) == visited.end() && price * deal >= 1000000 )
			{
				visited.insert( no );
				cout << no << endl;
				f = false;
			}
		}

		if ( f )
			cout << "NA" << endl;

	}

	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);
			long long sum = ((long long)b) * c;
			if(1000000ll <= sum){
				printf("%d\n", a);
				printed = true;
			}
		}
		if(!printed)
			puts("NA");
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	int n,id,i,k,f,a,b,da[4001],jun[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,-1,sizeof(da));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			if (da[id]==-1) { jun[k++]=id; da[id]=0; }
			da[id]+=a*b;
		}
		f=0;
		for (i=0;i<k;i++) if (da[jun[i]]>=1000000) { cout << jun[i] << endl; f=1; }
		if (f==0) cout << "NA" << endl;
	}
	return 0;
}