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;

#define MAX_EMPLOYEE 4000

int main()
{
        
        while(1){
                int n;
                cin >> n;
                if(!n) break;

                double salesOfEmployee[MAX_EMPLOYEE+1];
                for(int i=0; i<=MAX_EMPLOYEE; i++) salesOfEmployee[i]=0;
                
                int id;
                double price, quantity;
                for(int i=0; i<n; i++){
                        cin >> id >> price >> quantity;
                        salesOfEmployee[id] += price*quantity;
                }
                
                int flag = 0;
                for(int i=1; i<=MAX_EMPLOYEE; i++){
                        if( salesOfEmployee[i] >= 1000000 ){
                                cout << i << endl;
                                flag = 1;
                        }
                }
                if( !flag ) cout << "NA\n";
        }

        return 0;
}

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

using namespace std;

int main() {
    int n, e, p, q;
    vector< pair<int, unsigned long long> > data;
    vector< pair<int, unsigned long long> >::iterator it;

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

        data.clear();
        for (int i=0; i<n; i++) {
            cin >> e >> p >> q;

            it = data.begin();
            while (it != data.end()) {
                if(e == it->first) {
                    it->second += (unsigned long long)(p * q);
                    break;
                }
                it++;
            }
            
            if(it == data.end()) data.push_back(make_pair(e, (unsigned long long)(p * q)));
        }

        it = data.begin();
        bool isoutput = false;
        while (it != data.end()) {
            if(it->second >= 1000000) {
                cout << it->first << endl;
                isoutput = true;
            }
            it++;
        }
        if(!isoutput) 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 main(){
	int N,A[100000],B,C;
	while(cin>>N,N){
		int cnt[4001]={};
		for(int i=0;i<N;i++){
			cin>>A[i]>>B>>C;
			cnt[A[i]] += B*C;
		}
		bool NAflag=true,used[4001];
		for(int i=0;i<N;i++){
			if(cnt[A[i]]>=1000000 && used[A[i]]==false){
				printf("\t%d\n",A[i]); used[A[i]] = true; NAflag = false;
			}
		}
		if(NAflag==true) puts("\tNA");
	}
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n, a, b, c;
    while(true){
        scanf("%lld", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%lld%lld%lld", &a, &b, &c);
            if(b*c>=1000000){
                na = false;
                printf("%lld\n", &a);
            }
        }
        if(na) puts("NA");
    }
}

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

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        unsigned long long int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        int t,cost;
        int num;
        for(int i = 0 ; i < n ; i++){
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
        
        for(int i = 0 ; i < n ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(gs[i]==gs[j]&&i < j){
                    s[gs[i]] += s[j];
                    gs[j] = 4001;
                }
            }
        }
        for(int i = 0 ; i < n ; i++){
            if(s[gs[i]] >= 1000000){
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if(!cnt) cout << "NA" << endl;
    }
    
    return 0;
}

C++: using namespace std;

#include <stdio.h>
#include <map>

#define BASE_VALUE 1000000llu		// ?£?????????????

int main()
{
	int n = 0;										// ???????????°
	int no = 0;										// ????????????
	unsigned long long price = 0;					// ????£???????
	unsigned long long saleNum = 0;					// ?£??????°???
	bool flg = false;								// ????????????????????¨??????????????????
	map<int, unsigned long long> proceed;			// ?£??????????map
	map<int, unsigned long long>::iterator ite;		// ?£??????????map????????¬??????

	while (true)
	{
		// ?????????
		flg = false;
		proceed.clear();

		// ???????????°??\???
		scanf("%d", &n);

		if (0 == n)
		{// 0?????\??????????????°??????
			break;
		}

		for (int i = 0; i < n; ++i)
		{
			// ?????????????????\???
			scanf("%d %llu %llu", &no, &price, &saleNum);

			proceed[no] += price*saleNum;
		}

		for (ite = proceed.begin(); ite != proceed.end(); ++ite)
		{
			if (BASE_VALUE <= ite->second)
			{// ?£???????????????????????????? 1,000,000 ?????\????????????
				printf("%d\n", ite->first);
				flg = true;
			}
		}

		if (!flg)
		{// ????????????????????¨?????????
			printf("NA\n");
		}
	}
}

C++: #include <stdio.h>
  
int n,num[4000];
long long int tanka,sale_num,sale_sum[4000],sale_all[4001];
short judge[4001];
  
int main(void){
	int i,j,k;
	
	while(scanf("%d",&n),n){
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka,&sale_num);
			sale_sum[i]=tanka*sale_num;
		}
		k=0;
		for(j=0;j<4001;j++){
			judge[j]=0;
			sale_all[i]=0;
		}
		for(i=0;i<n;i++){
			sale_all[num[i]] += sale_sum[i];
		}
		for(i=0; i < n; i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		if(k!=1)printf("NA\n");
	}

    return 0;
}

C++: #include<stdio.h>


int main(){
	int n;
	int id,price,num;
	bool f=false;
	int i;
	while(scanf("%d",&n),n){

		for(i=0;i<n;i++){
			scanf("%d %d %d",id,price,num);
			if(price*num>1000000){
				printf("%d\n",id);
				f=true;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}

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

using namespace std;

int main()
{   
    int n;
    long long int ids[4001];
    int id, price, amount;
    bool exist;
    while(cin >> n && n)
    {   
        exist=false;
        for(int i=1;i<4001;++i) ids[i] = 0;
        for(int i=0;i<n;++i)
        {   
            cin >> id >> price >> amount;
            ids[id] += price * amount;
        }
        for(int i=1;i<4001;++i)
        {   
            if(ids[i] >= 1000000)
            {   
                exist = true;
                cout << i << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
}