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<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
int main(){
  while(1){
    ll i,b[4010],a[4010],n,e[4010],p,q,k=0;
    scanf("%lld\n",&n);
    if(n==0){
      return 0;
    }
    for(i=0;i<=4000;i++){
      a[i]=0,b[i]=0;
    }
    for(i=0;i<n;i++){
      scanf("%lld %lld %lld\n",&e[i],&p,&q);
      a[e[i]]+=p*q;
    }
    for(i=0;i<n;i++){
      if(b[e[i]]==0 && a[e[i]]>=1000000){
        b[e[i]]=1;
        printf("%lld\n",e[i]);
        k++;
      }
    }
    if(k==0){
      printf("NA\n");
    }
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>

#define int64 long long int
using namespace std;

typedef pair<int, int> P;

int main()
{
	int n, num, val, sale, c;
	P data[4000];
	int flag[4001];
	bool na;
	while(1){
		na = true;
		memset(flag, 0, sizeof(int)*4001);
		c = 1;

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

		for(int i=0; i<n; i++){
			cin >> num >> val >> sale;
			if(!flag[num]){
				flag[num] = c;
				data[c].first = num, data[c].second = val * sale;
				c++;
			}else data[flag[num]].second += val * sale;
		}

		for(int i=1; i<c; i++){
			if(data[i].second >= 1000000){
				na = false;
				cout << data[i].first << endl;
			}
		}
		if(na) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
long sum[4001],p,q;
int n,e;
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i++<4000;)sum[i]=0;
		for(;n--;)
		{
			cin>>e>>p>>q;
			sum[e]+=p*q;
		}
		bool f=0;
		for(int i=0;i++<4000;)
		{
			if(sum[i]>=1e6)
			{
				f=1;
				cout<<i<<endl;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
}

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

int main(){
    int n;
    int array[n][3];
    int count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]<=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }
    if(count==0) cout<<"NA\n";
}

C++: #include<cstdio>
#include<iostream>
#include<queue>
 
using namespace std;
 
int main(void){
 
    long long n,flag,number;
    long long money,sum;
    long long data[4001*5]={0},dataF[4001*5]={0};
    queue<long long> ok;
 
    while(1){
 
        for(int i=0;i<=4001*5;i++) data[i]=0,dataF[i]=0;
        flag=0;
 
        cin>>n;
        if(n==0) break;
 
        for(int i=0;i<n;i++){
            cin>>number>>money>>sum;
            data[number]+=money*sum;
            if(dataF[number]==0){
                dataF[number]=1;
                ok.push(number);
            }
        }
            while(!ok.empty()){
                if(data[ok.front()]>=1000000){
                    cout<<ok.front()<<endl;
                    flag=1;
                }
                ok.pop();
            }
            if(flag==0) cout<<"NA"<<endl;
    }
 
    return 0;
}

C++: #include "stdio.h"
#include "string.h"
long long  N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i!=0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            if(N[x]!=-1){
                N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-1;
                }
            }
        }
        if(c==0)
            printf("NA\n");
        else 
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        memset(N,0L,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
}

C++: #include <iostream>
#include <map>
using namespace std;
int main() {
  int n;
  map<int, long> mp;
  map<int, long>::iterator itr;

  while(cin >> n) {
	if(n == 0) break;
	int e, p, q;

	for(int i = 0; i < n; ++i) {
	  cin >> e >> p >> q;
	  itr = mp.find(e);
	  if(itr == mp.end()) {// not found
		mp[e] = int(p * q);
	  }
	  else {
		itr->second += p * q;
		if(itr->second >= 1000000) {
		  itr->second = -1;
		}
	  }
	}

	bool isNA = true;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  if(itr->second -1) {
		cout << itr->first << endl;
		isNA = false;
	  }
	}
	if(isNA) {
	  cout << "NA" << endl;
	}

	mp.clear();
  }
  return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#define int long long int
using namespace std;
signed main() {
  bool f;
  vector<pair<int, int> > v;
  int n, a, b, c;
  while (cin >> n && n > 0) {
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      f = 0;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first == a) {
          v[j].second += b * c;
          f = 1;
        }
      }
      if (!f) {
        v.push_back(pair<int, int>(a, b * c));
      }
    }
    f = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        cout << v[i].first << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include<stdio.h>
int n,i,b;
int syain[4001],a,suu;
int flg=0;
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
		}
		flg=0;
		for(i=1;i<=4000;i++){
			if(syain[i]>=1000000){
				printf("%d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,c,q;
    long long data_list[4001];
    int id_list[4000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        k=0;
        memset(data_list,0,sizeof(data_list));
        for(l=0;l<n;l++){
            cin>>id>>c>>q;
            data_list[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;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}