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 <stdlib.h>
using namespace std;
int main() {
	int n;
	int e[1000];
	int p[1000];
	int q[1000];
	int total[1000];
	cin >> n;
	while (n!=0){
		e[1000] = { 0 };
		p[1000] = { 0 };
		q[1000] = { 0 };
		total[1000] = { 0 };
		for (int i = 0; i < n; i++) {
			cin >> e[i] >> p[i] >> q[i];
			total[i] = p[i] * q[i];
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j && e[i] == e[j]) {
					total[i] += total[j];
					total[j] = 0;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (total[i] >= 1000000)printf("%d\n", e[i]);
			else printf("NA\n");
		}
		cin >> n;
	}
	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] + b * a >= 1000000) v2[a] = 1000000;
      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){
      }
      else{
        cout << v[i].se<<endl;
//         debug(v2[v[i].se]);
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

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

int main() {

	while(true) {

		int n;
		cin >> n;
		if ( n == 0 ) break;

		vector<int> number;
		vector<long long int> score;

		for ( int i = 0; i < n; i++ ) {

			int input_number;
			long long int tanka;
			long long int kazu;
			cin >> input_number >> tanka >> kazu;

			for ( int j = 0; j <= number.size(); j++ ) {
				if ( j != number.size() ) {
					if ( number[j] == input_number ) {
						score[j] += tanka * kazu;
						break;
					}
				}else {
					number.push_back(input_number);
					score.push_back(tanka * kazu);
					break;
				}
			}
		}

		bool f = true;
		for ( int i = 0; i < number.size(); i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << number[i] << endl;
				f = false;
			}
		}

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

	}

	return 0;
}

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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int main()
{
    int n; ll en, price, qty, check[4001]; qi que;
    while(cin >> n && n) {
        if (n == 0) break;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= 0) {
                check[en] += price*qty;
            }

            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) {
            cout << "NA" << endl;
        } else {
            for(int i=0,len=que.size(); i < len; ++i) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}

C++: //11
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    long long total[4001]={};
    bool out=false;
    for(int i=0;i<n;i++){
      int id;
      long long t,ns;
      cin>>id>>t>>ns;
      if(total[id]<1000000){
	total[id]+=t*ns;
	if(total[id]>=1000000){
	  cout<<id<<endl;
	  out=true;
	}
      }
    }
    if(!out){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    bool found = false;
    for (int i = 0; i < n; ++i) {
      int num;
      long long int price, count;
      cin >> num >> price >> count;
      if (price*count >= 1000000LL) {
	cout << num << endl;
	found = true;
      }
    }

    if (!found)
      cout << "NA" << endl;
  }
  return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	while (cin >> n&&n) {
		long long member[4001] = {0};
		int a, b, c;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			member[a] += b*c;
		}
		int count = 0;
		for (int i = 0; i < 4001; i++) {
			if (member[i] >= 1000000) {
				count++;
				cout << i << endl;
			}
		}
		if (count == 0)cout << "NA" << endl;
	}

}

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

long long worker[4001];

void init() {
  for(int i = 0; i < 4001; ++i) {
	worker[i] = 0;
  }
}

int main() {
  int n, id, p, q;
  while(cin >> n) {
	if(!n) break;

	init();
	for(int i = 0; i < n; ++i) {
	  cin >> id >> p >> q;
	  worker[id] += p * q;
	}

	bool ret = 0;
	for(int i = 1; i < 4001; ++i) {
	  if(worker[i] >= 1000000) {
		cout << i << endl;
		ret = 1;
	  }
	}
	
	if(!ret) {
	  cout << "NA" << endl;
	}
	
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

	int i, j = 0;

	while(true){
		int n;

		cin >> n;

		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		else if(n < 0 || 4000 < n){
			continue;
		}
		int* a = new int[n];
		int* b = new int[n];
		int* c = new int[n];

		for(i = 0; i < n; i++){
			cin >> a[i] >> b[i] >> c[i];
		}

		for(i = 0; i < n; i++){
			if(b[i] * c[i] >= 1000000){
				cout << a[i] << endl;
				j++;
			}
		}
		if(j == 0){
			cout << "na" << endl;
		}


	}
}