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 <fstream>
#include <stdlib.h>
#include <map>
using namespace std;
//ifstream fin("D:\\txt.txt");
#define for0(i,n) for (i=0;i<n;i++)
map<long,long> data;
#define MV(a,b) map<long,long>::value_type(a,b) 

int main()
{
	int n,a,b,c,i,j;
        bool bo;
	while(cin>>n)
	{
		data.clear();
		if(!n)break;
		for0(i,n)
		{
			cin>>a>>b>>c;
			c*=b;
			if (data.find(a)==data.end())
			{
				data.insert(MV(a,c));
			}
			else
			{
				data[a]+=c;
			}
		}

		map<long,long>::iterator it=data.begin();
		bo=true;
		while(it!=data.end())
		{
			if (1000000<=it->second)
			{
				cout<<it->first<<endl;
				bo=false;
			}
			it++;
		}
		if (bo)
		{
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

int main(){
    int n;
    while(cin>>n,n){
        map<long,long long>m;
        int i,p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            m[i]+=p*q;
        }
        for (map<long,long long>::iterator it=m.begin(); it!=m.end(); ++it){
            if(it->second>=1000000){
                s=1;
                cout<<it->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

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

const ll MAX = 1000000;

int main(void) {
    while(~scanf("%d", &n)) {
        if(n == 0) break;
        vector<int> ans;
        for(int i = 0; i < n; i++) {
            scanf("%d%d%d", &id, &p, &q);
            amount = p*q;
            if(amount >= MAX) {
                ans.push_back(id);
            }
        }
        if(ans.empty()) {
            printf("NA\n");
        } else {
            for(int i = 0; i < (int) ans.size(); i++) {
                printf("%d\n", ans[i]);
            }
        }
    }
    return 0;
}

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

int main(){
    long long size, id, price, quantity;
    double p, q;
    bool noone = true;
    while (1){
	cin >> size;
	if (!size) break;
	for (int i = 0; i < size; i++){
	    cin >> id >> price >> quantity;
	    p = (double) price/100;
	    q = (double) quantity/100;
	    if (p * q >= 100){
		cout << id << endl;
		noone = false;
	    }
	}
	if (noone) cout << "NA" << endl;
	noone = true;
    }
}

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

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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<pair<int,int> > v;
		int info[4001];
		bool appeared[4001];
		fill(info,info+4001,0);
		fill(appeared,appeared+4001,false);
		vector<int> numList;
		for(int i = 0; i < n; i++){
			int num;
			int val;
			int ko;
			cin>>num>>val>>ko;
			if(!appeared[num]){
				appeared[num]=true;
				numList.push_back(num);
			}

			info[num]+=val*ko;
		}

		bool f=false;
		for(int i = 0; i < numList.size(); i++){
			if(info[numList[i]]>=1000000){
				cout<<numList[i]<<endl;
				f=true;
			}
		}
		if(!f)
			cout<<"NA"<<endl;
	}

	return 0;
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		map<int, long long> data;
		map<int, int> seq;
		for (int i = 0; i < n; ++i) {
			int bangou;
			long long tanka, kazu;
			cin >> bangou >> tanka >> kazu;
			if (data.find(bangou) == data.end()) {
				data[bangou] = 0;
				seq[bangou] = i;
			}
			if (data[bangou] < 1000000)
				data[bangou] += tanka * kazu;
		}
		vector<pair<int, int> > v;
		for (map<int, long long>::iterator it = data.begin(); it != data.end(); ++it)
			if (it->second >= 1000000)
				v.push_back(make_pair(seq[it->first], it->first));
		if (v.empty())
			cout << "NA" << endl;
		else {
			sort(v.begin(), v.end());
			for (int i = 0; i < v.size(); ++i) cout << v[i].second << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(void){
	int n;
	while(cin >> n,n){
		int list[4001]={0};
		int a,b,c;
		for(int i=0;i<n;i++){
			cin >> a >> b >> c;
			list[a]+=b*c;
		}
		bool check=true;
		for(int i=1;i<=4000;i++)
			if(list[i]>=1000000)
				cout << i << endl,check=false;
		if(check)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;

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

Mem array[40010];

int main(void) {
    while(cin >> n && n) {
        for(int i = 0; i < n; i++) {
            cin >> array[i].id >> p >> q;
            array[i].c = p * q;
        }
        for(int i = 0; i < n - 1; i++) {
            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) {
                cout << array[i].id << endl;
                hap = true;
            }
        }
        if(!hap) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: //AOJ0100
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long 
int main(){
	int n;
	while(cin>>n,n!=0){
vector< pair<int,__int64> >ta;
ta.clear();
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
bool f=0;
int index=0;
for(int j=0;j<ta.size();j++)if(ta[j].first==a)f=1,index=j;
if(f==0)ta.push_back(pair<int,__int64>(a,b*c));
else ta[index].second+=b*c;
}
bool f=0;
for(int i=0;i<ta.size();i++){
	cout<<ta[i].first<<"   "<<ta[i].second<<endl;
	if(ta[i].second>=1000000){cout<<ta[i].first<<endl;;f=1;}
}
	if(!f)cout<<"NA"<<endl;
}
	return 0;
}