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<stdio.h>
int main(void)
{
	int n=1;
	int i=0,j=0;
	int tanka[4001]={0};
	int flg=0;
	int uriage[4001]={0};
	int bangou[4001]={0};
	int ccc=0;
	int goukei[4001]={0};
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		for (i=1;i<=n;i++)
		{
			ccc++;
			scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&uriage[ccc]);
			goukei[ccc]=tanka[ccc]*uriage[ccc];
			for (j=0;j<ccc;j++)
			{
				if (bangou[ccc]==bangou[j])
				{
					goukei[j]+=tanka[ccc];
					uriage[j]+=uriage[ccc];
					ccc--;
				}
			}
		}
		for (i=1;i<=ccc;i++)
		{
			if (goukei[i]>=1000000)
			{
				printf("%d\n",bangou[i]);
				flg=1;
			}
		}
		if (flg==0)
		{
			printf("NA\n");
		}
	}
return 0;
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int main(){
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<ll> num(4001,0),pre(n,0),data(4001,0);
        for (int i=0; i<n; i++) {
            ll a,b,c;
            cin >>a >>b >>c;
            ll inp;
            if(b*c>=1000000){
                inp=1000000;
            }else{
                inp = b*c;
            }
            if(data[a]<1000000) data[a]+=inp;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0; k< 4001; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        ll ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

C++: #include<iostream>

using namespace std;


int main(){

	long long all[4001] = {};
	long long code, a, b, n, i,j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}


		cin >> n;
		if (n == 0){
			break;
		}

		for (i = 0; i < n; i++){
			cin >> code >> a >> b;
			all[code] += a*b;
			
		}

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

		if (j == 0){
			cout << "NA" << endl;
		}

	}
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int A[1000000];

int main(){
	int N,B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		bool NAflag=true,used[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("NA");
	}
    return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int i=0;
        int na=0;
        cin>>i;
        if(i==0)
            break;
        else
        {
            int h[4001];
            for(int k=0;k<=4000;k++)
            {
                h[k]=0;
            }
            for(int k=1;k<=i;k++)
            {
                int j=0;int l=0;int m=0;
                cin>>j>>l>>m;
                h[j]+=(l*m);

            }
            for(int k=1;k<=4000;k++)
            {
                if(h[k]>=1000000)
                {
                    cout<<k<<endl;
                    na=1;
                }

            }
            if(na==0)
            {
                cout<<"NA"<<endl;
            }

        }
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

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

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

using namespace std;

int main() {
	int num;
	int LINE = 1000000;

	while(cin>>num, num!=0){
		map<int, long long> employees;
		map<int, long long>::iterator itr;
		bool flg = false;
		for(int i=0; i<num; i++){
			int id =0, q=0, p=0;
			cin>>id>>q>>p;
			employees[id] += (q*p);
		}


		for(itr = employees.begin(); itr != employees.end(); itr++){
			if(itr->second >= LINE){
				cout<<itr->first<<endl;
				flg = true;
			}
		}
		if(!flg){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
int shineI[SHINE_MAX];	//??????????????????
long int shineU[SHINE_MAX];	//?£??????????

int dataN,num,tanka,suryo;
int i,j;

int main(){
while(1){
	//??\???
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 //???????????????????????????????????¨??????????????????
	 for(i=0;i<shineN;i++){
	  if(shineI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  shineI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	//??????
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<ll> cnt(4001);
        int val = 0;
        for (int i = 0; i < n; ++i) {
            int a, b, c;
            scanf("%d %d %d", &a, &b, &c);
            cnt[a] += (ll)b*c;
            if(cnt[a] >= 1000000){
                cnt[a] = -INF<ll>;
                cout << a << "\n";
                val++;
            }
        }
        if(!val) puts("NA");
    }
    return 0;
}