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 <iostream>

#define N 1000000

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(!n) break;
		bool chk = 0;
		for(int i = 0; i < n; i++){
			int num, val, sum;
			cin >> num >> val >> sum;
			double tmp = val * sum;
			if(tmp >= N){
				chk = 1;
				cout << num << endl;
			} 
		}
		if(!chk) cout << "NA" << endl;
	}
	return 0;
}

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

using namespace std;

int n;
long long id[4000];
long long value[4000];
long long number[4000];
map<long long, long long> total;

int main() {
  while(true){
    cin >> n;
    if(n==0){
        return 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> id[i] >> value[i] >> number[i];
        if(total.find(id[i])==total.end()){
          total.insert(make_pair(id[i], 0));
        }
        total[id[i]] += value[i] * number[i];
    }
    vector<long long> v;
    if(!total.empty()) {
        map<long long, long long>::iterator it = total.begin();
        while (it != total.end()) {
            if ((*it).second >= 1000000) {
                v.push_back((*it).first);
            }
            ++it;
        }
    }
    if (v.empty()) {
        cout << "NA" << endl;
    }
    for (vector<long long>::iterator it = v.begin(); it != v.end(); ++it) {
        cout << *it << endl;
    }
    v.clear();
    total.clear();
  }
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(void) {
    int n, e, flag = 0;
    ll p, q;

    while (scanf("%d", &n), n) {
        vector<int> v;
        map<int, ll> mp;
        for (int i = 0; i < n; i++) {
            scanf("%d %lld %lld", &e, &p, &q);
            if (!mp[e]) v.push_back(e);
            mp[e] += p * q;
        }

        flag = 0;
        for (int i = 0; i < v.size(); i++) {
            if (mp[v[i]] < 1000000) continue;
            printf("%d\n", v[i]);
            flag = 1;
        }
        
        if (!flag) puts("NA");
    }
    return 0;
}

C++: #include <iostream>
#include <string.h>

using namespace std;

int N, M;

int main() {
	long long  goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long  v[4000];
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			long long  e, p, q;
			cin >> e >> p >> q;
			v[e - 1] += p*q;
		}
		bool flag = false;
		for (int i = 0; i < 4000; i++) {
			if (v[i] >= goal) {
				flag = true;
				cout << i + 1 << endl;

			}
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		map<ll,ll>in;
		rep(i,n){
			ll a,b,c;
			cin>>a>>b>>c;
			in[a]+=b*c;
		}
		bool h=false;
		for(map<ll,ll>::iterator it=in.begin();it!=in.end();it++){
			ll d=it->first;
			if(in[d]>=1e6){
				h=true;
				cout<<d<<endl;
			}
		}
		if(!h)cout<<"NA"<<endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,num,price,amount;
	while(cin>>n&&n){
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			long long sum = price*amount;
			if(sum>=1000000) v.push_back(num);
		}
		if(v.size!=0) for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		else cout<<"NA\n";
	}
	return 0;
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int n,f,b;
	long long c,d;

	while(1){
		f=1;int k=0;
		long long a[4000][2]={0};
		cin>>n; if(n==0) return 0;

		for(int i=0;i<n;i++){
			cin>>b>>c>>d;
			for(int j=0;j<k;j++){
				if(a[j][0]==b){ a[j][1]+=c*d; f=0;}
			}
			if(f){
				a[k][0]=b; a[k++][1]=c*d;
			}
		}

		f=1;
		for(int i=0;i<k;i++){
			if(a[i][1]>=1000000) {cout<<a[i][0]<<endl; f=0;}
		}
		if(f) cout<<"NA"<<endl;
	}
}

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

using namespace std;
class saleData
{
public:

	int hireNo;
	int saleValue = 0;

	void addSale(int value)
	{
		if(saleValue < 1000000)
		{
			saleValue += value;
		}
	}

	bool judge()
	{
		if(saleValue >= 1000000)
		{
			return true;
		}
		return false;
	}
};
int main()
{
	while(1)
	{
		int dataCount;
		cin >> dataCount;
		vector<saleData> vobj;

		if(dataCount == 0)
		{
			break;
		}
		bool dataFlag = false;
		for(int i = 0; i < dataCount; i++)
		{
			int hireNo;
			int price;
			int No;
			cin >> hireNo >> price >> No;

			for(int j = 0; j < vobj.size(); j++)
			{
				if(vobj.size() == 0)
				{
					break;
				}
				if(vobj[j].hireNo == hireNo)
				{
					vobj[j].addSale(price * No);
					dataFlag = true;
					break;
				}
			}
			if(dataFlag == false)
			{
				saleData sObj;
				sObj.hireNo = hireNo;
				sObj.addSale(price * No);
				vobj.push_back(sObj);
			}
		}
		dataFlag = false;
		for(int i = 0; i < vobj.size() ; i++)
		{
			if(vobj[i].judge() == true)
			{
				cout << vobj[i].hireNo << endl;
				dataFlag = true;
			}
		}
		if(dataFlag == false)
		{
			cout << "NA" << endl;
		}


	}



}

C++: #include<stdio.h>
int n,i,j,b;
int a,suu;
long long int syain[4001];
int zyun[4001];
int flg=0;
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
			zyun[i]=0;
		}
		int cnt=1;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
			if(zyun[a]==0){
				zyun[a]=cnt;
				cnt++;
			}
		}
		flg=0;
	/*	for(i=1000;i<=1005;i++){
			printf("%d=%d %d\n",i,zyun[i],syain[i]);
		}
	*/	int aa=1;
		for(i=0;i<cnt;i++){
			for(j=1;j<=4000;j++){
				if(zyun[j]==aa && syain[j]>=1000000){
					printf("%.4d\n",j);
					flg=1;
				}
			}
			aa++;
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	struct employee
	{
		int N,P,A;
	};
	employee person[10][4000];
	int a,b=0,c[10],d,e;
	for(d=0;;b=0,d++)
	{
		scanf("%d",&c[d]);
		if(c[d]==0)
		{
			e=d;
			break;
		}
		for(a=0;a<c[d];a++)
			scanf("%d %d %d",&person[d][a].N,&person[d][a].P,&person[d][a].A);
	}
	for(d=0;d<=e;b=0,d++)
	{
		for(a=0;a<c[d];a++)
			if(person[d][a].P*person[d][a].A>=1000000 )
			{
				printf("%d\n",person[d][a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
}

C++: #include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			if(m.find(x) == m.end()) m.insert(make_pair(x,p*q));
			else m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			if(it->second >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}