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>
#include <stdbool.h>

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    long long employee_sale_num[4000] = {};
    long long employee_sale[4000] = {};
    
    while ((scanf("%d", &data_num)) != EOF) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &employee_sale_num[i],  &employee_sale[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    employee_sale[data_check] += employee_sale[i];
                    employee_sale_num[data_check] += employee_sale_num[i];
                    data_num_update--;
                }

                
            }
            data_check++;
            
        }
        
        //printf("%d", data_num_update);
        
        bool result_flag = true;
        for (int i = 0; i < data_num_update; ++i) {
            if (employee_sale_num[i] * employee_sale[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

C++: /*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	int n;
	int num[4000];
	bool appear[4001];
	int howmany;
	int number;
	long int in_price;
	long int in_sales;
	long int price[4001];
	long int sales[4001];
	/*****処理部*****/
	while(1){
		for(int i=0;i<4001;i++){
			if(i < 4001)	num[i] = 0;
			appear[i] = false;
			price[i] = 0;
			sales[i] = 0;
		}
		howmany = 0;
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> number;
			cin >> in_price;
			cin >> in_sales;
			price[number] += in_price;
			sales[number] += in_sales;
			if(!appear[number])	num[i] = number;
			appear[number] = true;
		}
		for(int i=0;i<n;i++){
			if(num[i] != 0){
				if(price[num[i]] * sales[num[i]] >= 1000000){
					cout << num[i] << endl;
					howmany++;
				}
				//cout << i << " " << price[num[i]] << " " << sales[num[i]] << endl;
			}
		}
		if(howmany == 0)	cout << "NA" << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n;
  int a,num[N],tanka,uriage;
  bool judge;

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

    judge = true;
    for(int i=0;i<N;i++){
      num[i] = 0;
    }

    for(int i=0;i<n;i++){
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
    }

    for(int i=1;i<N;i++){
      if(num[i]>=1000000){
	cout << i << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  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 <stdio.h>

int main(int argc, char *argv){
	int n, f;
	int ID, price, num;
	while(1){
		scanf("%d ", &n);
		if(!n) break;
		f=0;
		while(n--){
			scanf("%d %d %d ", &ID, &price, &num);
			if(1000000 <= price * num){
				printf("%d\n", ID);
				f = 1;
			}
		}
	}
	if(!f) printf("NA\n");
	return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map <int,int> com;
    bool f = false;
    while(n--){
      int a,b,c;
      cin >>a>>b>>c;
      com[a]+=b*c;
    }
    map<int,int>::iterator m;
    for(m=com.begin();m!=com.end();m++){
      if((m->second)>=1000000){cout <<m->first<<endl;f = true;}
    }
    if(!f){cout <<"NA"<<endl;}
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
#include<string.h>


int main(){
	long long int uriage[4000][3],n,no,tanka,su,i,j,newflag,naflag;
	
	while(0<=scanf("%lld",&n)){
		if(n==0) break;
		
		memset(uriage,0,sizeof(uriage));
		
		for(i=0;i<n;i++){
			scanf("%lld%lld%lld",&no,&tanka,&su);
			
			newflag=0;
			
			for(j=0;j<n;j++){
				if(uriage[j][0]==no){
					uriage[j][1]+=tanka*su;
					newflag=1;
					break;
				}
			}
			
			if(newflag==0){
				for(j=0;j<n;j++){
					if(uriage[j][0]==0){
						uriage[j][1]+=tanka*su;
						uriage[j][0]=no;
						break;
					}
				}
			}
		}
		naflag=0;
		for(i=0;i<n;i++){
			if(uriage[i][0]==0)break;
			if(uriage[i][1]>=1000000){
				printf("%lld\n",uriage[i][0]);
				naflag=1;
			}
		}
		if(naflag==0)printf("NA\n");
	}
	return 0;
}

C++: #include<stdio.h>
long long int t[4000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			int b,c,d;
			scanf("%d%d%d",&b,&c,&d);
			t[b-1]+=(long long)c*(long long)d;
		}
		bool ok=false;
		for(int i=0;i<4000;i++){
			if(t[i]>=1000000LL){
				printf("%d\n",i+1);
				ok=true;
			}
			t[i]=0;
		}
		if(!ok)printf("NA\n");
	}
}

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

int main(){
    int n;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        int i,p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
        for (int i=0;i<vec.size();i++){
            if(m[vec[i]]>=1000000){
                s=1;
                cout<<vec[i]<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include<iostream>
using namespace std;
int ans[4000];

int main(){
	int N;
	long long int e, p, q;
	int x;
	while (1){
		x = 0;
		cin >> N;
		if (N == 0){ break; }
		while (N){
			cin >> e >> p >> q;
			cout << N<<x << endl;
			if (p*q >= 1000000){
				ans[x] = e;
				x++;
			}
			N--;
		}
			for (int i = 0; i < N; i++)
			{
				if (i == 0 && ans[i] == 0)cout << "NA" << endl;
				if (ans[i] == 0){ break; }
				cout << ans[i] << endl;
			}
	}
	return 0;
}