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<map>
#include<iostream>
using namespace std;
int main()
{
    map<int,int> total;

	int d,num,item,ko,cont=0;
	bool ok;

	while(cin>>d, d)
	{
		for(int i=0;i<d;i++)
		{
			cin>>num>>item>>ko;
			item *= ko;
			if(total.count(num))
			{
				total[num] += item;
			}
			else
			{
				total.insert(make_pair(num, item));
			}
		}

		ok = false;
		map<int,int>::iterator it;
		for(it = total.begin(); it != total.end(); it++)
		{
			if((*it).second >= 1000000)
			{
				cout << (*it).first <<endl;
				ok = true;
			}
		}

		if(ok == false)
		{
			cout<<"NA"<<endl;
		}
		
		total.clear();
	}
}

C++: #include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i>0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            if(N[x]>=0){
                N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-1;
                }
            }
        }
        if(c<1){
            printf("NA\n");
        }else{
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        }
        for(j=0;j<4001;j++){
            N[j]=0;
            f[j]=0;
        }
        scanf("%d",&i);
    }
    return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
	while(1)
	{
		int n; cin >> n ;
		if(!n) break;
		map<int,long long> a;
		for(int i=0;i<n;i++)
		{
			long num,b,c;
			cin >> num >> b	>> c ;
			a[num]+=(long long) b*c;
		}
		map<int,long long>::iterator p;
		bool flag=false;
		for(p=a.begin(); p!=a.end();p++)
			if(p->second >= 1000000) {cout << p->first << endl; flag=true;}
		if(flag==false) cout << "NA" << endl;
	}
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
while(cin>>n,n){
long long int tmp[4001]={0};
rep(i,n){
int a,b,c;
cin>>a>>b>>c;
tmp[a]+=b*c;
}
int co=0;
rep(i,4001){
if(tmp[i]>=1000000){
co++;
cout<<i<<endl;
}
}
if(!co)cout<<"NA"<<endl;
}
}

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

int main(void)
{
	int n;
	while (cin >> n, n){
		int a, b, c;
		vector <int> v;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c;
			if (1000000 <= b * c) v.push_back(a);
		}
		for (int i = 0; i < v.size(); i++){
			cout << v[i] << endl;
		}
		if (v.size() == 0) puts("NA");
	}
	
	return 0;
}

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

struct EmployeeSale {
	long employee_number;
	long long sales;
};

int main()
{
	int data_count = 0;
	while (std::cin >> data_count) {
		if (data_count == 0) {
			break;
		}
		std::vector<EmployeeSale> sales_per_employee;
		for (int i = 0; i < data_count; ++i) {
			long employee_number = 0;
			long unit_price = 0;
			long quantity = 0;
			if (std::cin >> employee_number >> unit_price >> quantity) {
				long long each_sales = static_cast<long long>(unit_price) * quantity;
				auto it = std::find_if(
					sales_per_employee.begin(),
					sales_per_employee.end(),
					[=](EmployeeSale const& sale){ return sale.employee_number == employee_number; });
				if (it != sales_per_employee.end()) {
					it->sales += each_sales;
				} else {
					EmployeeSale sales = { employee_number, each_sales };
					sales_per_employee.push_back(sales);
				}
			}
		}

		std::vector<EmployeeSale> sales_achieved;
		std::copy_if(
			sales_per_employee.begin(),
			sales_per_employee.end(),
			std::back_inserter(sales_achieved),
			[](EmployeeSale const& sale){ return sale.sales >= 1000000; });
		if (!sales_achieved.empty()) {
			std::for_each(
				sales_achieved.begin(),
				sales_achieved.end(),
				[](EmployeeSale const& sale){ std::cout << sale.employee_number << std::endl; });
		} else {
			std::cout << "NA\n";
		}
	}

	return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int main(void){
	int N;
	int i,p,q;
	while(cin >> N){
		int check = 0;
		if(!N) break;
		for(int i=0; i<N; ++i){
			cin >> i >> p >> q;
			if(p*q >= 1000000) check = 1, cout << i << endl;
		}
		if(check = 0) cout << "NA" << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
	long long N, X, Y, Z;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		vector<long long> P(4001, 0);

		vector<bool> ok(4001, false);

		int count_ = 0;

		for (int i = 0; i < N; i++)
		{
			cin >> X >> Y >> Z;

			P[X] += Y * Z;

			if (P[X] >= 1000000 && ok[X] == false)
			{
				cout << X << endl; ok[X] = true; count_++;
			}
		}

		if (!count_)
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
	int n,id,i,f,k,a,b,jun[4001],ch[4001],da[4001];
	while (cin >> n) {
		if (n==0) break;
		memset(da,0,sizeof(da));
		memset(ch,0,sizeof(ch));
		k=0;
		for (i=0;i<n;i++) {
			cin >> id >> a >> b;
			if (ch[id]==0) { ch[id]=1; jun[k++]=id; }
			if ((a/100)*(b/100)>100 || da[id]+a*b>999999) da[id]=1000000; else da[id]+=a*b; 
		}
    f=0;
	for (i=0;i<k;i++) if (da[jun[i]]>999999) { cout << jun[i] << endl; f=1; }
	if (f==0) cout << "NA" << endl;
	}
	return 0;
	}

C++: #include <stdio.h>
 
 

 
int main(void){
	int i,j,k;
	int n,num[4000];
	long long int tanka,sale_num,sale_sum[4000],sale_all[4001];
	bool judge[4001];
	
	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[j]=0;
		}
		
		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[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 <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, id;
	long long int a, b;

	while( cin >> n , n ){
		map<int,int> employees;
		vector<int> vc;
		bool flag = true;
		
		for(int i=0 ; i<n ; ++i ){
			cin >> id >> a >> b;
			if( !employees[id] ) vc.push_back( id );
			employees[id] += a * b;	
		}
		for(int i=0 ; i<vc.size() ; ++i ){
			if( employees[ vc[i] ] >= 1000000 ){
				cout << vc[i] << endl;
				flag = false;
			}
		}
		if( flag ){
			cout << "NA" << endl;
		}
	}
}