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

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

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 <stdio.h>

struct employees
{
	int i;
	int p;
	int q;
};

int main(void)
{
	int n, m, x, y, z;
	struct employees number[4000] = {0};

	n = 0;
	while (scanf("%d %d %d", &x, &y, &z) != EOF)
	{
		if (x == 0)
			break;
		if (x <= 4000 && y <= 1000000 && z <= 100000)
		{
			number[n].i = x;
			number[n].p = y;
			number[n].q = z;
			n++;
		}
	}
	for (n = 0, m = 0; n < 4000; n++)
	{
		if (number[n].i == 0)
			break;
		if (number[n].q * number[n].p >= 1000000)
		{
			printf("%d\n", number[n].i);
			m++;
		}
	}
	if (m == 0)
			printf("NA\n");

	return 0;
}