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 <stdio.h>

int output[49000];
int count=0;

void input(int);
int main(void){
	int n,i;
	while(true){
		scanf("%d",&n);
		if(n>0){
			input(n);
		}else{
			break;
		}
	}
	for(i=0;i<count;i++){
		if(output[i]!=0){
			printf("%d\n",output[i]);
		}else{
			printf("NA\n");
		}
	}
	
	return 0;
}
void input(int n){
	int nb = n;
	
	int e[n];
	int p[n];
	int q[n];
	int c[n];
	
	int i;
	
	for(i=0;i<n;i++){
		scanf("%d",&e[i]);
		scanf("%d",&p[i]);
		scanf("%d",&q[i]);
		c[i] = p[i]*q[i];
	}
	
	int j;
	
	for(i=0;i<n-1;i++){
		for(j=1;j<n;j++){
			if(e[i]==e[j]){
				c[i]=c[i]+c[j];
				c[j]=0;
			}
		}
	}
	int ch = 0;
	
	for(i=0;i<n-1;i++){
		if(c[i]>=1000000){
			output[count]=e[i];
			count++;
			ch = 1;
		}
	}
	if(ch == 0){
		output[count]=0;
		count++;
	}
}

C++: #include <stdio.h>

struct employees
{
	int i;
	int q;
	int p;
};

int main(void)
{
	int n,m;
	struct employees number[4000];
	
	for (n = 0, m = 0; n < 4000; n++)
	{
		if (number[n].i == 0)
			break;
		if (number[n].q * number[n].p >= 1000000)
		{
			printf("%d\n", number[n].i);
			m++;
		}
		if (m == 0)
			printf("NA\n");
	}

	return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
int shineI[SHINE_MAX];	//??????????????????
long int shineU[SHINE_MAX];	//?£??????????

int dataN,num;
long int tanka,suryo;
int i,j;

int main(){
while(1){
	//??\???
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 //???????????????????????????????????¨??????????????????
	 for(i=0;i<shineN;i++){
	  if(shineI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  shineI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	//??????
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
return 0;
}

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

struct data{
  int a;
  long long total;
};

int main(){
  int i,j,n,c,a,yen,ko,f,f2;
  data d[4000];
  while(1){
    cin >> n;
    if(n == 0) break;
    c = 0;
    for(i=0;i<n;i++){
      cin >> a >> yen >> ko;
      f = 1;
      for(j=0;j<c;j++){
	if(a == d[j].a){
	  d[j].total += (long long) yen * ko;
	  f = 0;
	  break;
	}
      }
      if(f){
	d[c].a = a;
	d[c].total = (long long)yen * ko;
	c++;
      }
    }

    f2 = 1;
    for(i=0;i<c;i++){
      if(d[i].total >= 1000000){
	cout << d[i].a << endl;
	f2 = 0;
      }
    }
    if(f2) cout << "NA" << endl;

  }
  return 0;
}

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

#define ll long long

bool debug = true;

int main(void){
  map<int,ll> m;
  vector<int> order;
  int n;
  int no,amount,price;

  while(cin >> n){
	bool exist = false;
	if(!n) break;
	for(int i=0;i<n;i++){
	  cin >> no >> amount >> price;
	  if(find(order.begin(), order.end(), no) == order.end()){
		order.push_back(no);
		if(debug) cout << "pushed " << no << endl;
	  }
	  m[no] += (ll)amount*price;
	}
	for(int i=0;i<order.size();i++){
	  if(m[order[i]] >= 1e+6){
		cout << order[i] << endl;
		exist = true;
	  }
	}
	if(!exist) cout << "NA" << endl;
	m.clear();
	order.clear();
  }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    unsigned long long a[5000]={0},c=0,p,o,u;
    rep(i,n){
      cin>>p>>o>>u;
      a[p]+=o*u;
      if(a[p]>=1000000){cout<<p<<endl;c++;}
    }
    if(!c)cout<<"NA"<<endl;
  }
}

C++: #include <stdio.h>
#include <stdlib.h>
#define u_int unsigned int
int main(void){
  struct ID{
    u_int id;
    u_int unit;
    u_int number;
  };
  u_int n,k,i,p,q,pro,count;
  struct ID *member;
  while(scanf("%d",&n)&&n!=0){
    member=(struct ID *)calloc(n,sizeof(struct ID));
    for(k=0;k<n;k++){
      scanf("%u %u %u",&((member+k)->id),&((member+k)->unit),&((member+k)->number));
    }
    count=0;
    for(k=0;k<n;k++){
      pro=((member+k)->unit)*((member+k)->number);
      if(pro>=1000000){
	printf("%u\n",(member+k)->id);
	count++;
      }
    }
    if(count==0) printf("NA\n");
    free(member);
  }
  return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
int main(void){
	int n;
	while(cin >> n,n){
		map<int,int> name;
		long long int list[4001]={0};
		long long 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 <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;
ll amount;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;

    Mem() {}
    Mem(int _id, ll _c) { id = _id; _c = c; }
};

Mem array[4010];

int main(void) {
    while(~scanf("%d", &n)) {
        if(n == 0) break;
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d", &id, &p, &q);
            array[i].c = p * q;
            array[i].id = id;
        }
        for(int i = 0; i < n; i++) {
            ll cost = 0;
            for(int j = i + 1; j < n; j++) {
                if(array[i].id == array[j].id && array[j].id) {
                    array[i].c += array[j].c;
                    array[j].id = 0;
                }
            }
        }
        bool hap = false;
        for(int i = 0; i < n; i++) {
            if(array[i].id && array[i].c >= MAX) {
                printf("%d\n", array[i].id);
                hap = true;
            }
        }
        if(!hap) {
            printf("NA\n");
        }
    }
    return 0;
}