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++: #include <iostream>

using namespace std;

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

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

typedef pair<long long, long long> pairLL;
typedef vector<pairLL> resArr;

//#include <fstream>

int main(void)
{
	//ifstream fin("in.txt");
	istream& in=cin;
	resArr result;

	while(1)
	{
		int n;
		in >> n;
		if(n == 0)break;

		result.clear();

		for(int i=0; i<n; i++)
		{
			long long id, p, q;
			in >> id >> p >> q;

			resArr::iterator it;
			for(it=result.begin(); it!=result.end(); it++)
				if(it->first == id)
					break;
			
			if(it == result.end())
				result.push_back( pairLL(id, p*q) );
			else
				it->second += p*q;
		}

		bool exist=false;
		resArr::iterator it=result.begin();
		for(it; it!=result.end(); it++)
		{
			if((*it).second >= 1000000)
			{
				cout << (*it).first << endl;
				exist=true;
			}
		}
		if(!exist)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        map<int,long long> sl;
        sl.clear();
        for(int i=0;i<n;++i){
            int sn;
            long long t,v;
            cin>>sn>>t>>v;
            map<int,long long>::iterator it=sl.find(sn);
            if(it==sl.end())sl.insert(make_pair(sn,t*v));
            else it->second=t*v;
        }
        map<int,long long>::iterator it=sl.begin();
        while(it!=sl.end())
        {
            if(it->second>=1000000){cout<<it->first<<endl;++count;}
            ++it;
        }
        if(!count)cout<<"NA"<<endl;
    }
}

C++: #include<stdio.h>
long long d;

int main(){
	int n,i,num,c,k;
	int ar[4000],car;
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		car=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&num,&c,&k);
			d=c*k;
			if(d>=1000000)ar[car++]=num;
		}
		if(car==0)printf("NA\n");
		else{for(i=0;i<car;i++)printf("%d\n",ar[i]);}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main(){
	while (1){
		queue<int> q;
		map<int,lint> m;
		bool f[4010] = {};
		int n;
		cin >> n;
		if (n == 0) break;
		int a, b, c;
		rep(i, 0, n){
			cin >> a >> b >> c;
			q.push(a);
			m[a] += b*c;
		}
		int ct = 0;
		while (!q.empty()){
			int x = q.front(); q.pop();
			if (m[x] >= 1000000 && f[x]==0){
				o(x); ct++; f[x] = 1;
			}
		}
		if (ct == 0){
			o("NA");
		}
	}

}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        long long int syain,kakaku,kosuu,syains[5000]={0};
        long long int bango[5000]={0},flag[5000]={0};
        bool flag2=0;
        for(int i=0;i<n;i++){
            cin>>syain>>kakaku>>kosuu;
            bango[i]=syain;
            syains[syain]+=kakaku*kosuu;
        }
        for(int i=0;i<5000;i++){
            if(syains[bango[i]]>=1000000){
                if(flag[bango[i]]==0){
                        cout<<bango[i]<<endl;
                        flag[bango[i]]=1;
                }
            }
        }
        for(int i=0;i<5000;i++){
            if(flag[i]==1)flag2=1;
        }
    if(flag2==0)cout<<"NA"<<endl;
    }
    return 0;
}

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

int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        long long a[5000] = {0};
        int number;
        int jun[5000] = {0};
        long long tanka,kazu;
        for(int i = 0; i < n; i++){
            cin >> number >> tanka >> kazu;
            a[number] += tanka * kazu;
            jun[i] = number;
        }
        bool flg = 0;
        for(int i = n; i >= 0; i--){
            if(a[jun[i]] >= 1000000){
                cout << jun[i] << endl;
                a[jun[i]] = 0;
                flg = 1;
            }
        }


        if(!flg) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cmath>

using namespace std;

int n, e, p, q;

int main() {
  while(scanf("%d", &n), n) {
    for(int i = 0; i < n; i++) {
      scanf("%d %d %d", &e, &p, &q);
      if(p * q >= 1e6) printf("%d\n", e);
    }
  }
}

C++: #include <iostream>
#include <vector>
#include <map>

using namespace std;

const int kSum = 1000000;

int getSum(int price, int sales)
{
  return price * sales;
}

int main()
{
  int n_employee;
  int number, price, sales;
  bool flag;
  map<int, int> checkEmp;
  vector<int> empNumbers;

  while(cin >> n_employee){
    if(n_employee == 0){
      break;
    }

    flag = true;

    for(int i = 0; i < n_employee; ++i){
      cin >> number >> price >> sales;

      if(checkEmp.find(number) != checkEmp.end()){
	checkEmp[number] += getSum(price, sales);
      } else {
	checkEmp[number] = getSum(price, sales);
	empNumbers.push_back(number);
      }
    }

    int length = empNumbers.size();
    for(int i = 0; i < length; ++i){
      if(checkEmp[empNumbers[i]] >= kSum){
	cout << empNumbers[i] << endl;
	flag = false;
      }
    }

    if(flag){
      cout << "NA" << endl;
    }
    checkEmp.clear();
  }

  return 0;
}

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

long long worker[4001];

void init() {
  for(int i = 0; i < 4001; ++i) {
	worker[i] = 0;
  }
}

int main() {
  int n, id;
  long long p, q;
  while(cin >> n) {
	if(!n) break;

	init();
	for(int i = 0; i < n; ++i) {
	  cin >> id >> p >> q;
	  worker[id] += p * q;
	}

	bool ret = 0;
	for(int i = 1; i < 4001; ++i) {
	  if(worker[i] >= 1000000) {
		cout << i << endl;
		ret = 1;
	  }
	}
	
	if(!ret) {
	  cout << "NA" << endl;
	}
	
  }
  return 0;
}