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()
{
	int n;
	int number[4000];
	int tanka[4000];
	int ryou[4000];
	long goukei[4000];
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka[i];
			cin>>ryou[i];
			goukei[i]=tanka[i]*ryou[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  int x,emp[4001],val[4001];
  int emp1,val1,con,flag;

  while(1){
    cin >> x;
    if(x==0)break;

    for(int i=0;i<4001;i++){
      emp[i]=0;
      val[i]=0;
    }
    for(int i=0;i<x;i++){
      cin >> emp1 >> val1 >> con;

      flag=0;
      for(int j=0;j<x;j++){
	if(emp[j]==emp1){
	  flag=1;
	  val[j]+=val1*con;
	  break;
	}
      }
      if(flag==0){
	for(int j=0;j<4001;j++){
	  if(emp[j]==0){
	    emp[j]=emp1;
	    val[j]=val1*con;
	    break;
	  }  
	}
      }
    }
      flag=0;
    for(int j=0;j<4001;j++){
      if(val[j]>=1000000){
	cout << emp[j] << endl;
	flag=1;
      }
    }
    if(flag==0)cout << "NA" << endl;
  }
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    map<int, int> t;
    while (n--) {
      int i, p, q;
      cin >> i >> p >> q;
      if (t.count(i))
        t[i] += p * q;
      else
        t[i] = p * q;
    }
    vi v;
    for (auto x : t) {
      if (x.se >= 1000000) v.pb(x.fi);
    }
    if (v.size()) {
      rep(i, v.size()) cout << v[i] << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

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

const int BORDER = 1000000;

int main()
{
	int n;

	while( cin >> n && n ){
		int id, unit, amount, cnt = 0;
		int* list = new int[ n ];
		for( int i = 0; i < n; ++i ){
			cin >> id >> unit >> amount;
			if( unit * amount >= BORDER ){
				list[ cnt ] = id;
				++cnt;
			}
		}
		if( cnt != 0 ){
			for( int i = 0; i < cnt; ++i ){
				cout << list[ i ] << endl;
			}
		}else{
			cout << "NA" << endl;
		}
		delete[] list;
	}

	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],ch[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,0,sizeof(da));
		memset(ch,0,sizeof(ch));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			da[id]+=a*b;
			if (ch[id]==0) { ch[id]=1; jun[k++]=id;} 
			}
		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 <cstring>
using namespace std;

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		int table[4096];
		bool flag = false;
		memset(table, 0, sizeof(table));
		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			table[ID] += price * sale;
		}

		for(int i = 0; i < 4096; i++) {
			if(table[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}

		if(!flag)
			cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
	int data[4001];
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=1;i<=4000;i++){
			data[i]=0;
		}
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a>>b>>c;
			data[a]+=b*c;
		}
		bool f=false;
		for(int i=1;i<=4000;i++){
			if(data[i]>=1000000){
				cout<<i<<endl;
				f=true;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
	return 0;
}

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

int main() {
  int n;
  
  while(cin>>n, n) {
    map<int,int> mp;

    for(int i=0; i<n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool isExist = false;
    for(map<int, int>::iterator it = mp.begin(); it!=mp.end(); it++) {
      if( it->second >= 1000000 ) {
	isExist = true;
	cout << it->first << endl;
      }
    }
    if( !isExist ) cout << "NA" << endl;
  }
  
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int ans[1111],n,an,ban[1111],ba;
	while (1) {
		cin >> n;
		if (n == 0) {
			goto x;
		}
		an = 0;
		ba = 0;
		for (int i = 1; i <= n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			for (int z = 1; z <= an; z++) {
				if (ban[z] == a) {
					ans[z] = ans[z] + b * c;
					goto a;
				}
			}
			an = an + 1;
			ans[an] = b * c;
			ban[an] = a;
		a:;
		}
		int kk;
		kk = 0;
		for (int i = 1; i <= an; i++) {
			if (ans[i] >= 1000000) {
				cout << ban[i] << endl;
				kk = 1;
			}
		}
		if (kk == 1) {
			kk = 0;
		}
		else {
			cout << "NA" << endl;
		}
	}
x:;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main()
{
	int number, value, value_num;
	int num_data;
	int data[4000];
	
 /**Input**/
	while (true){
		bool NA = false;

		cin >> num_data;
		if (num_data == 0)
			break;

		for (int ix = 0; ix != num_data; ++ix){
			cin >> number;
			cin >> value >> value_num;
			data[number] = value * value_num;
		}

		for (int ix = 0; ix != 4000; ++ix){
			if (data[ix] >= 1000000){
				cout << ix << endl;
				NA = true;
			}
		}
		if (!NA)
			cout << "NA" << endl;
	}

	return 0;
}

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




int n;


void solve()
{
	bool ok=false;
	int total[4000];
	bool check[4000];
	memset(check,false,sizeof(check));
	memset(total,0,sizeof(total));
	for(int i=0;i<n;i++){
		int num,a,b;
		cin>>num>>a>>b;
		total[num]+=a*b;
		if(total[num]>=1000000 && !check[num]){
			cout<<num<<endl;
			check[num]=true;
			ok=true;
		}
	}
	if(!ok) cout<<"NA"<<endl;
}

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