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>

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,c,q;
    long long data_list[4001]={0};
    int id_list[4000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(c*q);
            cin>>id>>c>>q;
            id_flag=true;
            for(i=0;i<k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
                data_list[id_list[i]]=0;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

C++: #include <stdio.h>
#include <string.h>
 
int main(void) {
    int n;
    int employees[4000] = {0};
    while (~scanf("%d", &n) && n) {
        for (int i = 0; i < n; i++) {
            int id, price, sales;
            scanf("%d %d %d", &id, &price, &sales);
            employees[id-1] += price * sales;
        }
 
        int found = 0;
        for (int i = 0; i < 4000; i++) {
            if (employees[i] >= 1000000) {
                printf("%d\n", i+1);
                found = 1;
            }
        }
        memset(employees, 0, sizeof employees);
        if (!found) {
            printf("NA\n");
        }
 
    }
 
    return 0;
}

C++: #include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum[MAX],unitcost[MAX],amount[MAX],flag;
	while( 1 ){

		for(i=0;i<MAX;i++){
			unitcost[i]=0;
			amount[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %d %d",&snum[i],&unitcost[i],&amount[i]);
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( (unitcost[i]*amount[i]) >= 1000000 ){
				flag=1;
				printf("%d\n",snum[i]);
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}

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

typedef long long ll;

int main() {
  int n;
  
  while( cin>>n && n ) {
    map<int,ll> mp;
    vector<ll> v;

    for( int i=0; i<n; i++ ) {
      int a;
      ll b, c;
      cin >> a >> b >> c;
      if( !mp[a] )v.push_back( a );
      mp[a] += b * c;
    }

    bool isExist = false;
    for( int i=0; i<v.size(); i++ ) {
      if( mp[v[i]] >= 1000000 ) {
	isExist = true;
	cout << v[i] << endl;
      }
    }
    if( !isExist ) cout << "NA" << endl;
  }
  
  return 0;
}

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

int main() {
	long long number[4001] = {};
	long long e, p, q;
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			number[e - 1] += p*q;
		}

		int x = 0;
		for (int i = 0; i < 4001; i++) {
			if (number[i] >= 1000000) {
				cout << i + 1 << endl;
				x++;
			}
		}
		if (x == 0) { cout << "NA" << 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);
  ll n,a,b,c;
  while(cin >> n && n){
    vector<pair<ll,ll>> v;
    vary(ll,v2,4001,0);
    vary(ll,t,4001,0);
    ll cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(v2[a] == 0){
        v.push_back(make_pair(cnt,a));
        ++cnt;
        v2[a] = 1;
      }
      t[a] += b * c;
    }
    bool f = false;
    REP(i,0,v.size()){
      if(t[v[i].se] >= 1000000){
        cout << v[i].se<<endl;
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,ban,tanka,kazu,i,j,x={0};
	bool y={false};
	for(j=0;j<50;j++){
	cin>>n;
	if(n==0){
	break;
	}
	for(i=0;i<n;i++){
	cin>>ban>>tanka>>kazu;
	if(tanka*kazu>=1000000){
	cout<<ban<<endl;
	y=true;
	x+=ban;
	}
	}
	if(y==false){
	cout<<"NA"<<endl;
	}
	y=false;
	}
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void) {

	int n, e[1000], p[1000], q[1000];
	int cnt = 0;

	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> e[i] >> p[i] >> q[i];
			if (p[i] * q[i] >= 1000000)
				cout << e[i] << endl;
			else
				cnt++;
		}
		if (cnt == n)
			cout << "NA" << endl;
		cnt = 0;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


typedef int ll;


using namespace std;

int main()
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0) break;

		vector<int> order;
		map<int, ll> sale;
		for (int i = 0; i < n; ++i)
		{
			int no, value, num;
			scanf("%d %d %d", &no, &value, &num);
			if (sale.count(no) == 0)
			{
				sale.insert(make_pair(no, 0));
				order.push_back(no);
			}
			ll t = (ll)value * num;
			sale[no] += t;
		}
		bool any = false;
		for (int i = 0; i < order.size(); ++i)
		{
			if (sale[order[i]] >= 1000000)
			{
				printf("%d\n", order[i]);
				any = true;
			}
		}
		if (!any)
			printf("NA\n");
	}

	return 0;
}