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>
#include <vector>
#include <utility>

class employee {
public:
	int id;
	int p, q;
	bool more_than_million() {
		return (p * q >= 1000000);
	}
};

int n;
std::vector<employee> data;

void init()
{
	n = 0;
	data.clear();
}

bool get_input()
{
	init();
	std::cin >> n;
	if (n == 0) {
		return false;
	}
	for (int i = 0; i < n; i++) {
		employee tmp;
		std::cin >> tmp.id >> tmp.p >> tmp.q;
		data.push_back(tmp);
	}
	return true;
}

void solve()
{
    std::vector<employee>::iterator i = data.begin();
    std::vector<int> top_salers;
    while(i != data.end()){
       if((*i).more_than_million()){
    	   top_salers.push_back((*i).id);
        }
       i++;
     }
    if (top_salers.empty()) {
    	std::cout << " NA" << std::endl;
    } else {
    	for (std::vector<int>::iterator j = top_salers.begin(); j != top_salers.end(); j++) {
    		std::cout << (*j) << std::endl;
    	}
    }
}

int main()
{
	while (get_input()) {
		solve();
	}
	return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
map<int,ll> data;
int main(){
	int n;
	while(cin>>n,n){
		data.clear();
		std::vector<int> a;
		a.clear();
		rep(i, n){
			ll e,c,s;
			cin>>e>>c>>s;
			if(!data[e]){
				a.push_back(e);
				
			}
			data[e]+=(c*s);
		}
		bool flag =false;
		for(int i =0;i < a.size();i++){
			if(data[a[i]]>= 1000000){
				cout <<a[i]<<endl;
				flag =true;
			}
		}
		if(!flag){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long long n,a,b,c,f,i,s[4001];
while(cin>>n){
if(n==0)break;
for(i=1;i<=4000;i++)s[i]=0;
for(i=0;i<n;i++){
cin>>a>>b>>c;
if(s[a]<1000000)s[a]+=b*c;
}
f=0;
for(i=1;i<=4000;i++)
if(s[i]>=1000000){cout<<i<<endl;f=1;}
if(f==0)cout<<"NA"<<endl;
}
return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		map<int, long long int>mp;
		vector<int>vs;
		for (int i = 0; i < N; ++i) {
			long long int a, b, c; cin >> a >> b >> c;
			mp[a] += b*c;
			if (find(vs.begin(), vs.end(), a) == vs.end())vs.emplace_back(a);
		}
		bool flag = false;
		for (auto v : vs) {
			if (mp[v] >= 1000000) {
				cout << v << endl;
				flag = true;
			}
		}
		if (!flag)cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
	int n;
	while(scanf("%d", &n),n){
		long long per[5000]={0};
		int flg[5000]={0};
		int count = 0;
		int cnt[5000]={0};
		int num,t,s;
		int flag = 1;
		
		for(int i = 0; i < n; i++){
			scanf("%d%d%d", &num, &t, &s);
			if(flg[num]==0){
				cnt[count] = num;
				count++;
				flg[num]=1;
			}
			per[num] += (long long)t * (long long)s;
		}
		for(int i = 0; i < count; i++){
			if(per[cnt[i]] >= (long long)1000000){
				flag=0;
				printf("%d\n", cnt[i]);
			}
		}
		if(flag)
			puts("NA");
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int nin;
  while(1){ 
    scanf("%d",&nin);
    if(!nin)break;

    long long int human[4002]={0};
    long long int no[4002],tanka,kazu,outflag=0;
    
    for(int i=0;i<nin;i++){
      scanf("%d %d %d",&no[i],&tanka,&kazu);
      human[no[i]]+=tanka*kazu;
    }
    
    for(int i=0;i<nin;i++){
      if(human[no[i]]>=1000000 && human[no[i]]!=-1){
	printf("%d\n",no[i]);
	human[no[i]]=-1;
	outflag=1;
      }
    }
    
    if(outflag==0)printf("NA\n");
    
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

int main()
{
    int n, a, b, c;
    while(cin >> n && n) {
        vector<p> v;
        while(n--) {
            cin >> a >> b >> c;
            bool f = true;
            for(int i = 0; i < v.size() ; i++) {
                if(v[i].first == a) {
                    f = false;
                    v[i].second += b * c;
                }
            }
            if(f) {
                v.push_back(p(a, b * c));
            }
        }
        bool f = true;
        for(int i = 0; i < v.size(); i++) {
            if(v[i].second >= 1000000) {
                f = false;
                cout << v[i].first << endl;
            }
        }
        if(f) cout << "NA" << endl;

    }
}

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

C++: #include <iostream>
using namespace std;
int main()
{
	int n, no[4000], t[4000], num[4000], a[4000], i, j;
	while (cin >> n && n)
	{
		for (i = 0, j = 0; i < n; i++)
		{
			cin >> no[i] >> t[i] >> num[i];
			if (t[i] * num[i] > 1000000)
			{
				a[j] = no[i], j++;
			}
		}
		if (j == 0)
			cout << "NA" << endl;
		else
			for (i = 0; i < j; i++)
				cout << a[i] << endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <set>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b,c = 1000000;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(a * b >= c && list.find(id) == list.end()) {
                list.insert(id);
                cout << id << endl;
            }
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}