Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

C++: main()
{
  int kaisuu[100],syain[4000],n=1,tanka[4000],suuryou[4000];
  int i=0,j,flag=0,a=0;
  scanf("%d",&n);
  while(n!=0){
    
    
    for(i=0;i<n;i++){
      scanf("%d %d %d",&syain[i],&tanka[i],&suuryou[i]);
    }

    for(i=0;i<n;i++){
      if(1000000<=tanka[i] * suuryou[i]){
	printf("%d\n",syain[i]);
	flag=1;
      }
    }
    if(flag==0){
      printf("NA\n");
    }
    scanf("%d",&n);
  }
  return 0;
}

C++: 
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
using namespace std;
#define p 1000000 

int main(void){
//	FILE* fp_in = freopen("data.txt", "r", stdin);


	while(1){
		long long int n,tmp[3],cnt = 0, flg = 0;
		vector<long long int> number;
		vector<long long int> sales;
		cin >> n;
		if(n == 0) break;
		for(int i=0; i<n; i++) {
			flg = 0;
			cin >> tmp[0] >> tmp[1] >> tmp[2];
			for(int j=0; j<number.size(); j++){
				if(number.at(j) == tmp[0]) {
					sales.at(j) += tmp[1]*tmp[2];
					flg = 1;
					break;
				}
			}
			if(flg == 1) break;
			number.push_back(tmp[0]);
			sales.push_back(tmp[1]*tmp[2]);
		}
		for(int i=0; i<number.size(); i++) {
			if(sales.at(i) >= p) {
				cout << number.at(i) << endl;
				cnt++;
			}
		}
		if(cnt == 0) {
			cout << "NA" << endl;
		} 
	}


	return 0;
}

C++: #include <stdio.h>
 
 

 
int main(void){
	int i,j,k;
	int n,num[4000];
	long long int tanka[4000],sale_num[4000],sale_all[4001];
	bool judge[4001];
	
	while(scanf("%d",&n),n){
		
		//初期化

		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		for(i=0;i<n;i++){
			scanf("%d%lld%lld",&num[i],&tanka[i],&sale_num[i]);
		}
		
		
		//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;
}

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

using namespace std;

int main(void){
    long long i,l,k;
    long long n;
    long long id,cost,qty;
    long long data_list[100000];
    long long id_list[100000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        memset(data_list,0,sizeof(data_list));
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(cost*qty);
            cin>>id>>cost>>qty;
            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;
}

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]>=0){
                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);
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a,b,c,d;
	int num[4001],tan[4001],data[4001];
	bool flag=false;
	while(1){
		for(a=0;a<=4000;a++){
			data[a]=0;
			num[a]=0;
			tan[a]=0;
		}
		flag=false;
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			cin >> b >> c >> d;
			data[a]=b,num[b]+=c,tan[b]+=d;
		}
		for(a=1;a<=4000;a++){
			if(num[data[a]]*tan[data[a]]>=1000000)printf("%d\n",data[a]),flag=true;
		}
		if(flag==false)printf("NA\n");
	}
	return 0;
}

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

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

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

#define MAX_EMPLOYEES 4000

int main()
{
        while(1){
                int n;
                cin >> n;
                if(!n) break;

                double salesOfEmployee[MAX_EMPLOYEES+1];
                for(int i=0; i<=MAX_EMPLOYEES; i++) salesOfEmployee[i]=0;
                
                int id;
                double price, quantity;
                for(int i=0; i<n; i++){
                        cin >> id >> price >> quantity;
                        salesOfEmployee[id] += price*quantity;
                }
                
                int flag = 0;
                for(int i=1; i<=MAX_EMPLOYEES; i++){
                        if( salesOfEmployee[i] >= 1000000 ){
                                cout << i << endl;
                                flag = 1;
                        }
                }
                if( !flag ) cout << "NA" << endl;
        }

        return 0;
}

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

class meb{
public:
	int num;
	int tanka;
	int count;
	int sum;
};

int main(){
	int n;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1)

int main(){
  long long int n;
  while(cin >> n, n){
    map<long long int,long long int> e;
    vector<long long int> num;
    int cntnum[4000] = {0};
    for(int i = 1; i <= 4000; i++){
      e[i] = 0;
    }
    for(int i = 0; i < n; i++){
      long long int tmp[3];
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      e[tmp[0]] += tmp[1] * tmp[2];
      if(cntnum[tmp[0]] == 0){
        num.push_back(tmp[0]);
        cntnum[tmp[0]]++;
      }
    }
    long long int cnt = 0;
    for(int i = 0; i < num.size(); i++){
      if(e[num[i]] >= 1000000){
        cout << num[i] << endl;
        cnt++;
      }
    }
    if(cnt == 0){
      cout << "NA" << endl;
    }
  }
}