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<stdio.h>
int main()
{
	unsigned long int goukei[4001]={0},kazu,tanka;
	int n,i,j,g=0,kazuz[4001]={0};
	while(scanf("%d",&n))
	{
		if(n==0)
		{
			break;
		}
		for(i=1;i<=n;i++)
		{
			scanf("%d %d %d",&j,&tanka,&kazu);
			kazuz[i]=j;
			goukei[i]=goukei[i]+tanka*kazu;
		}
		for(i=1;i<4001;i++)
		{
			if(goukei[i]>=1000000)
			{
				printf("%d\n",kazuz[i]);
				g++;
			}
			goukei[i]=0;
		}
		if(g==0)
		{
			printf("NA\n");
		}
		g=0;
	}
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define f first
#define s second

using namespace std;

typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    map<string,pair<int,ll> > m;
    vector<pair<int,string> > v;
    REP(i,n){
      string a;
      ll b,c;
      cin>>a>>b>>c;
      if(m.find(a) == m.end())
	m[a] = mp(m.size(),b*c);
      else
	m[a].s += b*c;
    }
    FOR(it,m) if(it->s.s >= (ll)1000000) v.push_back(mp(it->s.f,it->f));
    if(v.size() == 0) cout << "NA" << endl;
    else{
      sort(ALL(v));
      FOR(it,v) cout << it->s << endl;
    }
  }
  return 0;
}

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

using namespace std;

int n;
long long id[4000];
long long value[4000];
long long number[4000];
map<long long, long long> total;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> id[i] >> value[i] >> number[i];
        total[id[i]] += value[i] * number[i];
    }
    vector<long long> v;
    if(!total.empty()) {
        map<long long, long long>::iterator it = total.begin();
        while (it != total.end()) {
            if ((*it).second >= 1000000) {
                v.push_back((*it).first);
            }
            ++it;
        }
    }
    if (v.empty()) {
        cout << "NA" << endl;
        return 0;
    }
    for (vector<long long>::iterator it = v.begin(); it != v.end(); ++it) {
        cout << *it << endl;
    }
}

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

int main(){
  int n,i,p,q,f;
  for(;scanf("%d",&n),n;){
    map<int,int>m;
    for(;n--;)
      scanf("%d%d%d",&i,&p,&q),m[i]+=p*q;
    map<int,int>::iterator it=m.begin();
    for(f=0;it!=m.end();it++){
      if((*it).second>=1000000)printf("%d\n",(*it).first),f=1;
    }
    if(!f)puts("NA");
  }
}

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

typedef long long int ll;

ll solve(ll N);

int main(void) {

	ll N = 1;
	while(true) {
		cin >> N;
		if( N == 0 ) { break; }
		solve(N);
	}

	return 0;
}

ll solve( ll N ) {

	map<int, ll> m;
	set<int> s;

	for( int i = 0; i < N; i++ ) {
		int id;
		ll ps, q;
		cin >> id >> ps >> q;
		if( m.find(id) == m.end() ) {
			m[id] = ps*q;
		} else {
			m[id] += ps*q;
		}
		if( m[id] >= 1000000 ) 
			s.insert(id);
			
	}

	if( s.size() == 0 ) {
		cout << "NA" << endl;
	} else {
		for( auto it = s.begin(); it != s.end(); ++it ) {
			cout << (*it) << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#define M map<int,int>
using namespace std;
int main()
{
  int n, i, id, a, b;
  while(cin >> n,n){
    M m;
    vector<int> v;
    vector<int>::iterator p;
    for(i=0;i<n;i++){
      cin >> id >> a >> b;
      m[id] += a * b;
      for(p = v.begin(); p != v.end(); p++){
	if(*p == id) break;
      }
      if(p == v.end()) v.push_back(id);
    }
    bool f = false;
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
      if(m[(*it)] >= 1000000){
	cout << *it << endl;
	f = true;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b,c,bc;
	int i;
	int flg;
	bc=0;
	flg=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		bc=b*c;
		if(bc<1000000){
			printf("%d\n",a);
			flg=1;
		}
	}
	if(flg==0){
		printf("NA");
	}
	return 0;
}

C++: #include <cstdio>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;

int n;

int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		rep(i,n){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			ll tmp = it->second;
			if(tmp >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	vector<int> a;
	vector<double> b;
	vector<double> c;
	int x,y,z;
	int n;
	while(cin>>n){
	      if(n==0) break;
	      map <int,double> sum;
	      for(int i=0;i<n;i++){
		cin>>x>>y>>z;
		a.push_back(x);
		b.push_back(y);
		c.push_back(z);
		sum[x]+=y*z;
	       }
	       int cnt=0;
	       sort(a.begin(),a.end());
	       for(int i=0;i<n;i++){
                     if(sum[a[i]]>=1000000 &&a[i]!=a[i-1]){
				cout<<a[i]<<endl;
				cnt++;
		     }
		}
		if(cnt==0) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

 int main(void)
{
	int data;
	int m,n;
	int number;
	long prise,value;

	float money[4000];



	while(1){
		
		for(n=0;n<4000;n++){
			money[n] = 0;
		}

		scanf("%d",&data);
		if(data == 0) break;

		for(n=0;n<data;n++){
			scanf("%d%d%d",&number,&prise,&value);
			money[number] += (float)prise * value;
		}
		
		m = 0;
		for(n=0;n<4000;n++){
			if(money[n] >= 1000000){
				m = 1;
				printf("%d\n",n);
			}
		}

		if(m == 0){
			printf("NA\n");
		}
	}


	

	return 0;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		ll a[4001];
		rep(i, 4001) { a[i] = 0; }
		rep(i, n) {
			ll d, p, q;
			cin >>  d >> p >> q;
			if (a[d] < 1000000) {
				if (p*q >= 1000000) {
					a[d] = 1000000;
				}
				else {
					a[d] += p*q;
				}
			}
		}
		bool flag = false;
		for (int i = 1; i < 4001; i++) {
			if (a[i] >= 1000000) {
				flag = true;
				cout << i << endl;
			}
		}
		if (!flag) { cout << "NA" << endl; }
	}
	return 0;
}