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<stdio.h>
#include<string>
#include<iostream>
using namespace std;

struct R{
int num;
int su;
int k;
};

int main(){

int N,M;

while(1){

struct R n[4001];
cin>>N;if(N==0)break;
for(int i=0;i<=4000;i++)
	n[i].su=0;

for(int i=1;i<=N;i++){
	int r,q,nu;
	cin>>nu;n[nu].num=nu;cin>>r>>q;
	if(n[nu].su==0){n[nu].k=i;}
	n[nu].su+=r*q;
	
}/*
for(int i=0;i<N;i++)
	for(int j=i+1;j<N;j++)
	{if(n[i].num==n[j].num){n[i].su+=n[j].su;n[j].su=0;}
	}*/
bool f=false;
for(int i=0;i<N;i++)
for(int j=0;j<4001;j++)
	if(n[j].k==i&&n[j].su>=1000000)
	{cout<<n[j].num<<endl;f=true;}

	if(f==false)cout<<"NA"<<endl;
}
return 0;
}

	

/*


string str;int s=0;
for(int iii=0;iii<M;iii++){
	cin>>str;
	for(int i=0;i<N;i++){bool f=true;
		for(int j=0;j<8;j++)
			if((n[i].y[j]!=str[j])&&n[i].y[j]!='*'){f=false;}//cout<<n[i].y[j]<<"#"<<str[j]<<endl;}
		if(f==true)s+=n[i].C;
	}

}

cout<<s<<endl;



}
return 0;
}*/

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

int main()
{
    int n;
    
    while(cin>>n && n){
        
        map<int,int> mp;
        vector<int> v;
        
        for(int i=0; i<n; i++){
            int e,p,q;
            cin>>e>>p>>q;
            if(!mp[e])
                v.push_back(e);
            
            mp[e]+=p*q;
            
        }
        
        bool flg=false;
        
        for(int i=0; i<v.size(); i++){
            if(mp[v[i]]>=1000000){
                flg=true;
                cout<<v[i]<<endl;
            }
        }
            if(!flg){
                cout<<"NA"<<endl;
            }
        
    }
    
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int ct,num[4000],tanka[4000],kosu[4000],many[4000];
	while(scanf("%d",&ct)){
		if(ct==0){
			return 0;
		}
		for(int f1=0;f1<ct;f1++){
			scanf("%d %d %d",&num[f1],&tanka[f1],&kosu[f1]);
			many[f1]=tanka[f1]*kosu[f1];
		}
		for(int f1=0;f1<ct;f1++){
			for(int f2=0;f2<ct;f2++){
				if((num[f1]==num[f2])&&f1!=f2){
					many[f1]=many[f1]+many[f2];
					num[f2]=-1;
				}
			}
		}
		int flg=0;
		for(int f1=0;f1<ct;f1++){
			if(many[f1]>=1000000){
				printf("%d\n",num[f1]);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN;
int eliteN;
int elite[SHINE_MAX];

int num,tanka,suryo;
int i;

int main(){
	while(1){
	 cin>>shineN;
	 if(shineN==0){break;}
	 
	 eliteN=0;
	 for(i=0;i<shineN;i++){
	  cin>>num>>tanka>>suryo;
	  if(ELITE<=tanka*suryo){	//??¨???????????????
	   elite[eliteN]=num;
	   eliteN++;
	  }
	 }
	 
	 //??¨???????????????
	 for(i=0;i<eliteN;i++){
	  cout<<elite[i]<<endl;
	 }
	 if(eliteN==0){cout<<AHO<<endl;}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<ll,ll> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c;
  while(cin >> n && n){
    vector<pair<ll,ll>> v;
    vary(ll,v2,4005,0);
    int cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(v2[a] == 0){
        ++cnt;
        v.push_back(make_pair(cnt,a));
      }
      if(v2[a] <= 1000000)
        v2[a] += b * c;
    }
    sort(all(v),[](const pii &p,const pii &p2){return p.fi < p2.fi;});
    bool f = false;
//     debug(v.size());
    REP(i,0,v.size()){
      if(v2[v[i].se] >= 1000000){
        cout << v[i].se<<endl;
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

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

typedef map<int,long long> M;
typedef queue<int> P;

int N[4000];

int main()
{
    int count;
    while (cin >> count, count > 0) {
        M m;
        int t = 1;
        P p;
        for (int i = 0; i < count; i++) {
            int t1;
            long long t2, t3;
            cin >> t1 >> t2 >> t3;
            if (N[t1 - 1] == 0) {
                N[t1 - 1] = t;
                t++;
                p.push(t1);
                m[t1] = 0;
            }
            m[t1] += t2 * t3;
        }

        bool flag = true;
        while (p.size()) {
            t = p.front(); p.pop();
            if (m[t] >= 1000000) {
                cout << t << endl;
                flag = false;
            }
            N[t - 1] = 0;
        }
        if (flag)
            cout << "NA" << endl;
    }

    return 0;
}

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

main() {
  int n;
  while((cin >> n) && n) {
    bool flag = true;
    for(int i = 0; i < n; ++i) {
      int i, p, q;
      cin >> i >> p >> q;
      if(p*q >= 1000000) {
	flag = false;
	cout << i << endl;
      }
    }
    if(flag) cout << "NA" << endl;
  }
}