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++: // 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;
      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>
#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++: dfdf

C++: #include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
long long s[4000];
P p[4000];
int min(int a,int b){return a<b?a:b;}
int main(){
	int n,i;
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		for(i=0;i<4000;i++){
			s[i]=0;
			p[i].first=5000;
			p[i].second=i;
		}
		for(i=0;i<n;i++){
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			s[a-1]+=(long long)b*c;
			p[a-1].first=min(p[a-1].first,i);
		}
		sort(p,p+4000);
		bool f=true;
		for(i=0;i<4000;i++){
			if(p[i].first==5000)break;
			if(s[p[i].second]>=1000000){
				printf("%d\n",p[i].second+1);
				f=false;
			}
		}
		if(f)printf("NA\n");
	}
}

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

#define TAR 1000000

int main() {
	int n,num,ch;
	unsigned long t,k;
	while(cin >> n){
		ch = 0;
		while(n){
			scanf("%d %ld %ld",&num,&t,&k);
			if((t!=0)&&(k!=0)){
				if((k > TAR/t)&&(t > TAR/k)){
					cout << num << endl;
					ch++;
				}else if((t >= TAR/k)&&(TAR%k == 0)){
					cout << num << endl;
					ch++;
				}else if((k >= TAR/t)&&(TAR%t == 0)){
					cout << num << endl;
					ch++;
				}
				if(((--n)==0)&&(ch==0)){
					cout << "NA" << endl;
				}
			}
		}
	}
	return 0;
}

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

int in;
cin >> in
int p[in][in * 3],i,ii,c = 0,uri[in],k;	
	for(i = 1;in >= i;i++){ cin >> p[i][0] >> p[i][1] >> p[i][2];uri[i] = 0;}	
	for(i = 1;in >= i;i++){
		for(ii = 1;in >= ii;ii++){if(p[i][0] == p[ii][0]){ uri[ii] = uri[ii] + p[i][1] * p[i][2];}}
	}
	for(i = 1;in >= i;i++){
		k = 0;
		for(ii = 1;i > ii;ii++){if(p[i][0] == p[ii][0]){ k = 1;} }		
			if(uri[i] >= 1000000 and k == 0){cout << p[i][0] << endl; c++;} 
	}
	if(c == 0 and in != 0) cout << "NA" << endl;

}

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

main() {
  int n;
  while((cin >> n) && n) {
    map<int, unsigned long long> m;
    vector<int> id;
    for(int i = 0; i < n; ++i) {
      int r, p, q;
      cin >> r >> p >> q;
      if(!m[r]) id.push_back(r);
      m[r] += p*q;
    }
    bool flag = true;
    for(int i = 0; i < id.size(); ++i) {
      if(m[id[i]] >= 1000000) {
	cout << id[i] << endl;
	flag = false;
      }
    }
    if(flag) cout << "NA" << endl;
  }
}

C++: #include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int n,a,b,c;
    while(cin>>n,n){
        vector<int>V;
        map<int,long long>M;
        while(n--){
            cin>>a>>b>>c;
            if(M[a]==0)V.push_back(a);
            M[a]+=b*c;

        }

        bool flag=true;
        for(int i=0;i<V.size();i++){
            if(M[V[i]]>=1000000){
                flag=false;
                cout<<V[i]<<endl;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

C++: //AOJ 0100
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define MAX_N 100

unsigned long long int a[4001] = {0}, b, i, j, k, ans, n;
char str[1000];

int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  while(scanf("%lld", &n) != 0){
    if(n == 0) return 0;
    ans = 0;
    for(i = 0; i < 4001; i++)
      a[i] = 0;
    for(i = 0; i < n; i++){
      scanf("%lld %lld %lld", &b, &k, &j);
      if(a[b] >= 1000000) continue;
      a[b] += k * j;
      if(a[b] >= 1000000){
	printf("%d\n", b);
	ans++;
      }
    }
    if(ans == 0) printf("NA\n");
  return 0;
}

C++: #include<cstdio>
#include<cstring>

int main(){
long long int data[4000],n;
scanf("%d",&n);
if(n==0) return 0;
memset(data,0,sizeof(data));
while(n--){
int a
long long int b,c;
scanf("%d%lld%lld",&a,&b,&c);
data[a-1]+=b*c;
}
int k=0;
for(int i=0;i<4000;i++){
if(data[i]>=1000000){
 printf("%d\n",i+1);
 k=1;
  } 
}
if(k==0) printf("NA\n");
}

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

int main(void){
	int n,count=0;
	vector<int> vec1,vec2,vec3,vec4;
	//½l©
	cin >> n;
	//lªf[^üêéæÁ
	for(int i=0;i<n;i++){
		int j,m,l;
		cin >> j >> m >> l;
		vec1.push_back(j);
		vec2.push_back(m);
		vec3.push_back(l);
	}
	//ÊÌ\¦
	for(int i=0;i<n;i++){
		if(vec2[i]*vec3[i]>=1000000){
			cout << vec1[i] << endl;
			count++;
		}
	}
	if(count==0){
		cout << "NA" << endl;
	}
	
	return 0;
}