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<string>
using namespace std;

int main(){
	int datasuu = 0;
	int flag[4000][4000];
	int sbangou[4000][4000];
	int hanbai[4000][4000];
	int uriage[4000][4000];
	int goukei[4000][4000];
	int kaisuu = 0;
	for (int j = 0;; j++){
		cin >> datasuu;
		if (datasuu == 0){
			kaisuu = j;
			break;
		}
		for (int i = 0; i < datasuu; i++){
			scanf("%d%d%d", &sbangou[j][i], &hanbai[j][i], &uriage[j][i]);
			for (int z = 0; z < i; z++){
				if (hanbai[j][i] == hanbai[j][z]){
					goukei[j][i] += goukei[j][z];
				}
			}
			goukei[j][i] += hanbai[j][i] * uriage[j][i];
			if (goukei[j][i] >= 1000000){
				flag[j][i] = 1;
				goukei[j][i] = hanbai[j][i] * uriage[j][i];
			}

		}
	}
	int on = 0;
	for (int i = 0; i < 4000; i++){
		for (int j = 0; j < 4000; i++){
			if (flag[i][j] == 1){
				cout << sbangou[i][j] << endl;
				on = 1;
			}
			if (on == 0)cout << "NA";
		}
	}
	return  0;
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	scd(n);
	LL a,b;
	string c;
	vector<tuple<string,LL,LL>> d;
	while(n!=0)
	{
		d.clear();
		int fl=0;
		forin(i,0,n)
		{
			cin>>c;
			scdlld(a,b);
			d.pb(make_tuple(c,a,b));
		}
		sort(d.begin(),d.end());
		
		int size=d.size();
		LL z=0;
		int l=0;
		int flag;
		for(int i=0 ; i<size ; i++)
		{
			flag=0;
			a=get<1>(d[i])*get<2>(d[i]);
			for(int j=i+1 ; j<size ; j++)
			{
				if(get<0>(d[i])==get<0>(d[j]))
				{
					l=j;
					flag=1;	
					a+=get<1>(d[j])*get<2>(d[j]);
				}
				else
				break;
			}
			//cout<<get<0>(d[i])<<"---"<<i<<endl;
			if(flag==1)
			{
				i+=l;
				//cout<<get<0>(d[i])<<"--"<<i<<endl;
			}
			
			
			if(a>=1000000)
			{
				cout<<get<0>(d[i])<<endl;
				fl=1;
			}
		}
		
		if(fl==0)
		printf("NA\n");
		
		
		scd(n);
	}
	
	return 0;
}

C++: #include<stdio.h>

int main()
{
	int i,ryou,bangou[4000],nedan[4000],kazu[4000],check;
	while(1)
	{
		check=0;
		scanf("%d",&ryou);
		if(ryou==0)
			break;
		for(i=0;i<ryou;i++)
		{
			scanf("%d%d%d",&bangou[i],&nedan[i],&kazu[i]);
			
				if(nedan[i]*kazu[i]>=1000000)
					check=1;
				else
					bangou[i]=0;
			
		}
		if(check==1)
		{
			for(i=0;i<ryou;i++)
			{
				if(bangou[i]!=0)
					printf("%d\n",bangou[i]);
			}
		}
		if(check==0)
				printf("NA\n");
	}
}

C++: #include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
    int n;

    while(cin>>n,n){
        int id;
        ll p,q;
        vector<ll> v(4001,0);
        priority_queue<int,vector<int>,greater<int>> que;

        while(n--){
            cin>>id>>p>>q;
            if(p*q+v[id]>=1e6){
                que.push(id);
            }else{
                v[id]+=p*q;
            }
        }

        if(que.empty()){
            cout<<"NA"<<endl;
            continue;
        }

        while(!que.empty()){
            cout<<que.top()<<endl;
            que.pop();
        }
    }

    return 0;
}

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

main(){
 int n,m=0;
 int id[4000],tanka[4000],suryou[4000];

cin>>n;
while(n!=0){
 for(int i=0;i<n;i++){
  cin>>id[i]>>tanka[i]>>suryou[i];
 }

 for(int i=0;i<n;i++){
  if(tanka[i]*suryou[i]>=1000000){
   cout<<id[i]<<endl;
   m++;
  }
 if(m==0) cout<<"NA"<<endl;
 cin>>n;
}
}

C++: #include <bits/stdc++.h>

using namespace std;

long long employees[4001];
bool checked[4001];

int main()
{
	int n;
	while (cin >> n, n) {
		for (int i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<int> ans;

		for (int i = 0; i < n; ++i) {
			int num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

		if (ans.empty()) cout << "NA" << endl;

		for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
	}
}

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

int main(){

  int n;

  while(cin>>n,n){

	long long e,p,q;
	map<long long,long long> total;
	bool flag = false;

	for(int i=0;i<n;++i){
	  cin>>e>>p>>q;

	  if(total[e] <1000000){
		total[e]+=p*q;
		if(total[e] >= 1000000){
		  cout<<e<<endl;
		  flag = true;	  
		}
	  }

	}
	
	if(flag == false)
	  cout<<"NA"<<endl;
	
  }

  return 0;
  
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	long long int g[1001],s[1001],d[1001],f[1001];
	int j,i,k,a,h[1001];
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		for(i=0;i<a;i++){
			h[i]=0;
			g[i]=0;
		}
		for(i=0;i<a;i++){
			scanf("%lld %lld %lld",&s[i],&d[i],&f[i]);
		//	if(d[i]*f[i]>=1000000) h[i]=1;
			if(h[i]==0) g[i]=d[i]*f[i];
			else g[i]=0;
		}
		for(i=0;i<a;i++){
			for(j=i+1;j<a;j++){
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
				if(s[i]==s[j]){
					if(h[i]==0){
						g[i]+=g[j];
						g[j]=0;
					}
					else g[j]=0;
				}
				if(g[i]>=1000000&&h[i]==0){
					h[i]=1;
				}
			}
		}
		k=0;
		for(i=0;i<a;i++){
			if(h[i]==1){
				printf("%lld\n",s[i]);
				k=1;
			}
		}
		if(k==0) printf("NA\n");
	}
	return 0;
}