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;
    long int array[n][3];
    int count=0;

    cin>>n;
    if(n==0) goto Exit;

    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n-1;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[i+j][1]=0;
            }
        }
    }

    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";
    }

    Exit:
    ;
}

C++: #include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        int count = 0;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        int* officer_num_old = new int [dataset_num];


        for (int i = 0; i < dataset_num; i++) {
            int officer_num;
            int price;
            int figure;
            int flag = 0;
            officer_num_old[i] = officer_num;
            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            for (int j = 0;j < i; j++) {
                if (officer_num_old[j] == officer_num) {
                    flag = 1;
                }
            }


            if (price * figure >= 1000000 && flag == 0) {
                std::cout << officer_num << std::endl;
                count += 1;
            }
        }
        if (count == 0) {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}

C++: #include<stdio.h>

int main(){
  while(1){
    int n;
    scanf("%d", &n);
    if(n!=0){
      int i,k;
      int a, b, c;
      int j=0;
      int d[4001];
      double e[4001] ={};
      int flag = 0;
      for(i=0;i<n;i++){
	scanf("%d %d %d", &a, &b, &c);
	int flag1=0;
	for(k=0;k<j;k++){
	  if(d[k]==d[j])
	    flag1=1;
	}
	if(flag1==0)
	  {d[j]=a;j++;}

	//if(e[a]+b*c<=2147483647)
	e[a]=e[a]+(double)b*(double)c;
	//else
	  //e[a]=(double)2147483647;//printf("aa\n");
	
      }


      for(i=0;i<4001;i++){
	if(e[d[i]]>=1000000.){
	  printf("%d\n", d[i]);
	  flag++;
	}
      }
      if(flag==0)
	printf("NA\n");
      
    }
    else{
      break;
    }
  }
  return 0;
}

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

int main() {
	int num;
	int data_set = 0;
	bool do_continue = true;
	std::vector<string> result;

	while (do_continue) {
		cin >> num;
		if ((num == 0) || (data_set > 50)) {
			do_continue = false;
		}
		else {
			bool na_flg = true;
			data_set++;
			std::map<int, int> e;
			std::vector<int> employee;
			int fst, snd, thd;

			for (int i = 0; i < num; i++) {
				cin >> fst >> snd >> thd;
				employee.push_back(fst);
				if (e.count(employee[i])) {
					e[employee[i]] += snd * thd;
				}
				else {
					e[employee[i]] = snd * thd;
				}
			}

			for (unsigned int j = 0; j < employee.size(); j++) {
				if (e[employee[j]] >= 1000000) {
					na_flg = false;
					result.push_back(std::to_string(employee[j]));
				}
			}

			if (na_flg) {
				result.push_back("NA");
			}
		}
	}

	for (unsigned int i = 0; i < result.size()-1; i++) {
		cout << result[i] << endl;
	}


	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0)
			break;
		long int c[4001]={};
		int id[100000];
		for (int i=0; i<n; i++){
			long int p , q;
			cin >> id[i] >> p >> q;
			c[id[i]] += p*q;
		}
		bool f=1;
		for (int i=0; i<n; i++){
			if (c[id[i]]>=1000000){
				cout << id[i] << endl;
				c[id[i]]=0;
				f=0;
			}
		}
		if (f)
			cout << "NA" << endl;

	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(void){
	int n;
	while(cin >> n,n){
		map<int,int> name;
		long long int list[4001]={0};
		int a,b,c,j=0;
		for(int i=0;i<n ;i++){
			cin >> a >> b >> c;
			name[j]=a,j++;
			if(list[a]<1000000)
				list[a]+=b*c;
		}
		bool check=true;
		for(int i=0;i<4000;i++)
			if(list[name[i]]>=1000000)
				cout << (name[i]) << endl,check=false,list[name[i]]=0;
		if(check)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <stdio.h>

 int main(void)
{
	int data;
	int m,n;
	int number;
	long prise,value;

	long int  money[4000];



	while(1){
		
		for(n=0;n<4000;n++){
			money[n] = 0;
		}

		scanf("%d",&data);
		if(data == 0) break;

		for(n=0;n<data;n++){
			scanf("%d%d%d",&number,&prise,&value);
			money[number] += prise * value;
		}
		
		m = 0;
		for(n=0;n<4000;n++){
			if(money[n] >= 1000000){
				m = 1;
				printf("%d\n",n);
			}
		}

		if(m == 0){
			printf("NA\n");
		}
	}


	

	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
	ll n;
	while(scanf("%d\n", &n), n){
		vector<pair<ll, ll> > v;
		rep(i,n) {
			ll x, y, z;
			cin >> x >> y >> z;
			bool f = false;
			for(int j = 0; j < v.size(); ++j) {
				if(v[j].first == x) {
					v[j].second += y * z;
					f = true;
					break;
				}
			}
			if(!f) {
				v.push_back(make_pair(x, y * z));
			}
		}
		bool flag = false;
		for(int j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <stdio.h>

struct {
  int i, v;
} d[50][4000];

int main() {
  int i, j, k;
  int p, n, f;
  int id, v1, v2;

  for (i = 0; scanf("%d", &n), n != 0; i++) {
    p = 0;
    for (j = 0; j < n; j++)
      d[i][j].v = 0;
    for (j = 0; j < n; j++) {
      scanf("%d %d %d", &id, &v1, &v2);
      f = 0;
      for (k = 0; k < j; k++) {
        if (id == d[i][k].i) {
          d[i][k].v += v1 * v2;
          f = 1;
          break;
        }
      }
      if (f == 0) {
        d[i][p].i = id;
        d[i][p].v = v1 * v2;
        p++;
      }
    }
  }

  n = i;
  for (i = 0; i < n; i++) {
    f = 0;
    for (j = 0; j < 50; j++) {
      if (d[i][j].v >= 1000000) {
        f = 1;
        printf("%d\n", d[i][j].i);
      }
    }
    if (f == 0)
      printf("NA\n");
  }
  return 0;
}

C++: #include <stdio.h>
 
 
int n;
long long num[4000],tanka[4000],sale_num[4000];
int sale_all[4001],judge[4001];
 
int main(void){
	int i,j,k;
	
	while(scanf("%d",&n),n){
		
		for(i=0;i<n;i++){
			scanf("%d%d%d",&num[i],&tanka[i],&sale_num[i]);
		}
		
		//初期化
		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[i]] = sale_all[num[i]] + tanka[i]*sale_num[i];
		}
		
		for(i=0;i<n;i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		
		if(k!=1)printf("NA\n");
	}
	
	return 0;
}