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 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){
		
		//初期化

		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka,&sale_num);
			sale_sum[i]=tanka*sale_num;
		}
		
		
		//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 <cstring>
using namespace std;

int p[4001];
int result[1000000];

int main(){
	int i ,j=0 , n , id , price , num , cnt;
	while(cin>>n){
		cnt=0;
		memset(p,0 , sizeof(p)/sizeof(p[0]));
		if (n==0) break;
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
				p[id]+=price*num;
			}
		for(i=0 ; i<4001 ; i++){
			if(p[i]>=1000000){
				result[j++]=i;
				cnt++;
			}
		}
		if (cnt==0) {
				result[j++]=0;
			}
	}
	for(i=0;i<j;i++){
		if (result[i]==0) {
			cout << "NA" << endl;
		} else {
		cout << result[i] << endl;
		}
	}
	return 0;
}

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

using namespace std;

// ベクターに売り上げを記録していく。
// 同じ社員が複数のデータを持つこともあるので、
// 記録がある場合には加算していく。
// 1000000以上の場合に社員番号を出力する。
// 該当する社員0人の場合はNAを出力する。

int main() {

	int N;
	while (cin >> N , N != 0) {
		vector<pair<int, long long>> data;

		for (int i = 0; i < N; ++i) {
			int number, price, sales;
			cin >> number >> price >> sales;
			auto it = find_if(data.begin(), data.end(), [number](pair<int, int> x) {return x.first == number;});
			auto total = static_cast<long long>(price) * sales;
			if (it != data.end()) {
				it->second += total;
			}
			else {
				data.emplace_back(pair<int, long long>{number, total});
			}
		}
		int cnt = 0;
		for (const auto a : data) {
			if (a.second >= 1000000) {
				++cnt;
				cout << a.first << endl;
			}
		}
		if (0 == cnt) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main() {
	while(true) {
		int n;
		cin >> n;
		if ( n == 0 ) break;
		vector<int> number;
		vector<int> score;
		for ( int i = 0; i < n; i++ ) {
			int input_number;
			int tanka;
			int kazu;
			cin >> input_number >> tanka >> kazu;
			for ( int j = 0; j <= number.size(); j++ ) {
				if ( j != number.size() ) {
					if ( number[j] == input_number ) {
						score[j] += tanka * kazu;
						break;
					}
				}else {
					number.push_back(input_number);
					score.push_back(tanka * kazu);
					break;
				}
			}
		}
		bool f = true;
		for ( int i = 0; i < number.size(); i++ ) {
			if ( score[i] >= 1000000 ) {
				cout << number[i] << endl;
				f = false;
			}
		}
		if ( f ) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
#define SALES_GOAL 1000000 
using namespace std;
int main(void){
  int i,n;
  int price,qua;
  while(cin>>n,n){
    int tof = 1;
    int staff_info[n];
    for(i=0;i<n;i++){
      cin >> staff_info[i] >> price >> qua;
      staff_info[i] = price>SALES_GOAL && qua? staff_info[i]
                      :price*qua>SALES_GOAL ? staff_info[i] : 0;
    }
    for(i=0;i<n;i++){
      if(staff_info[i]){
        cout<<staff_info[i]<<endl;
        tof=false;
      }
    }
    if(tof){
        cout << "NA\n";
    }
  }
}

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

std::vector<std::string> split(std::string ref,char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str," ");
if(std::stoi(ref[1])*std::stoi(ref[2])>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    long long unit_sale_num[4000] = {};
    long long sale_num[4000] = {};
    
    while ((scanf("%d", &data_num)) != EOF) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &unit_sale_num[i],  &sale_num[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    sale_num[data_check] += sale_num[i];
                    unit_sale_num[data_check] += unit_sale_num[i];
                    data_num_update--;
                }
            }
            data_check++;
        }
        
        bool result_flag = true;
        
        for (int i = 0; i < data_num; ++i) {
            if (unit_sale_num[i] * sale_num[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    while(true){
        int n; cin>>n;
        if(n==0)break;
        map<ll,pair<ll,ll>> m;
        REP(i,n){
            ll e,p,q; cin>>e>>p>>q;
            if(m.find(e)==m.end())m[e]=make_pair(p*q,i);
            else m[e].first+=p*q;
        }
        vector<pair<ll,ll>>ans;
        for(auto itr=m.begin();itr!=m.end();itr++){
            if(itr->second.first>=1000000){
                ans.push_back(make_pair(itr->second.second,itr->first));
            }
        }
        if(ans.size()==0)cout<<"NA"<<endl;
        else{
            sort(ans.begin(),ans.end());
            REP(i,ans.size())cout<<ans[i].second<<endl;
        }
    }
    
    
    
    return 0;
}