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(){
	int n;
	int id[4000],cid,price,num;
	long long int sale[4000];
	bool f;
	int i,j,idcount;
	while(scanf("%d",&n),n){

		f=true;
		idcount=0;

		for(i=0;i<n;i++){
			scanf("%d %d %d",&cid,&price,&num);

			for(j=0;j<idcount;j++){
				if(id[j]==cid){
					sale[j]=sale[j]+price*num;
				}
			}

			if(j==idcount){
				id[idcount]=cid;
				sale[idcount]=price*num;
				idcount++;
			}

		}



		for(i=0;i<idcount;i++){
			if(sale[i]>=1000000){
				printf("%d\n",id[i]);
				f=false;
			}
		}
		if(f!=false)printf("NA\n");
	}
	return 0;
}

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

int main() {
	vector<int> emp_nums;
	vector<int> grades;
	int border = 0;
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;
		int e, p, q;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			bool be_already = false;
			int same_emp_index;
			for (int j = 0; j < emp_nums.size(); j++) {
				if (emp_nums[j] == e) {
					be_already = true; same_emp_index = j; break;
				}
			}
			if (be_already) {
				grades[same_emp_index] += p*q;
			}
			else {
				emp_nums.push_back(e);
				grades.push_back(p*q);
				cnt++;
			}
		}
		bool nothing = true;
		for (int i = border; i < emp_nums.size(); i++) {
			if (grades[i] >= 1000000) {
				cout << emp_nums[i] << endl;
				nothing = false;
			}
		}
		if (nothing)cout << "NA" << endl;
		border += cnt;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long lli;

int main(void){
	int a,b,c;
	int n;
	while(cin>>n,n){
		std::map<int,lli> m;
		bool f=false;
		while(n--){
			cin>>a>>b>>c;
			m[a]+=b*c;
			if(m[a]>=1000000)f=true;
		}
		if(f){
		for(__typeof(m.begin()) it=m.begin();it!=m.end();it++){
			if(it->second>=1000000)cout<<it->first<<endl;
		}}
		else cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int n;
	long p[4000];
	int count;
	
	while(cin>>n,n){
		for(int i=0;i<4000;++i)p[i]=0;
		
		for(int i=0;i<n;++i){
			int wn,va,cn;
			cin>>wn>>va>>cn;
			p[wn-1] += va*cn;
		}
		count = 0;
		for(int i=0;i<4000;++i){
			if(p[i] >= 1000000){cout<<i+1<<endl;count++;}
		}
		if(!count)cout<<"NA"<<endl;
		
		
		
		
		
	}
	
	
	
}

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

using namespace std;

vector<int> erase_equal(vector<int> v) {
	vector<int> result;
	map<int, bool> mp;
	for (int i = 0; i < v.size(); i++) {
		auto itr = mp.find(v[i]);
		if (itr == mp.end()) {
			mp[v[i]] = true;
			result.push_back(v[i]);
		}
	}
	return result;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		map<int, int> sales;
		vector<int> ids(n);
		for (int i = 0; i < n; i++) {
			int id;
			int sale_val;
			int sale_num;
			cin >> id;
			cin >> sale_val;
			cin >> sale_num;

			ids.push_back(id);
			auto itr = sales.find(id);
			if (itr != sales.end()) {
				sales[id] += sale_val * sale_num;
			} else {
				sales[id] = sale_val * sale_num;
			}
		}

		vector<int> v = erase_equal(ids);
		bool na_flag = true;
		for (int i = 0; i < v.size(); i++) {
			if (sales[v[i]] >= 1000000) {
				cout << v[i] << endl;
				na_flag = false;
			}
		}
		if (na_flag) {
			cout << "NA" << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  
  while(1){
  
    int n,no[4002],unit,qua;
    int emp[4002]={0};
    int empflag[4002]={0};
    
    scanf("%d",&n);
    
    if(n==0)break;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&no[i],&unit,&qua);
      emp[no[i]]+=unit*qua;	
    }
    
    int flag=0;
    for(int i=0;i<n;i++){
      if(emp[no[i]]>=1000000 && empflag[no[i]]==0){
	printf("%d\n",no[i]);
	flag=1;
	empflag[no[i]]=1;
      }
    
    }
    
    if(flag==0)printf("NA\n");
  }
  return(0);
}

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

struct DATA{
        int id;
        int sales;
};

int main()
{

        while(1){
                int n;
                cin >> n;
                if(!n) break;
                
                list<struct DATA> sales_list;
                for(int i=0; i<n; i++){
                        int id, p, q;
                        cin >> id >> p >> q;
                        int flag = 0;
                        for(list<struct DATA>::iterator i=sales_list.begin(); i!=sales_list.end(); i++){
                                if(i->id==id){
                                        i->sales += p*q;
                                        flag = 1;
                                        break;
                                }
                        }
                        if(!flag){
                                struct DATA d;
                                d.id = id;
                                d.sales = p*q;
                                sales_list.push_back(d);
                        }
                }
                
                int flag = 0;
                for(list<struct DATA>::iterator i=sales_list.begin(); i!=sales_list.end(); i++){
                        if( i->sales >= 1000000 ){
                                cout << i->id << endl;
                                flag = 1;
                        }
                }
                if(!flag) cout << "NA" << endl;
        }

        return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int lint;

int data[4001] = { 0 };

bool AOJ0100() {
	lint n, e, p, q;
	cin >> n;
	if (n == 0) return false;

	lint* data = new lint[4001];
	for (int i = 0; i <= 4000; i++) data[i] = 0;

	for (lint i = 0; i < n; i++) {
		cin >> e >> p >> q;
		data[e] += p * q;
	}

	bool flag = false;
	for (int i = 1; i <= 4000; i++) {
		if (data[i] >= 1000000) {
			flag = true;
			cout << i << endl;
		}
	}
	if (!flag) cout << "NA" << endl;

	delete[] data;
	return true;
}

int main()
{
	while (AOJ0100()) {
	}
	return 0;
}

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

int main()
{
	int num, yen, ko;
	int c = 0;
	
	while (1){
		cin >> num;
		if (!num)	break;

		for (; num > 0; num--){
			cin >> num >> yen >> ko;

			if (yen * ko >= 1000000){
				cout << num << endl;
				c++;
			}
		}

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

	return 0;
}

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

int main(){
	vector<pair<int,long long> > v;
	int n,a;
	long long b,c;
	while(cin>>n&&n){
		v.clear();
		while(n--){
			cin>>a>>b>>c;
			int index = -1;
			for(int i=0;i<v.size();i++){
				if(a==v[i].first){
					index = i;
					break;
				}
			}
			if(index==-1)v.push_back(make_pair(a,b*c));
			else v[index].second += b*c;
		}
		bool flag = false;
		for(int i=0;i<v.size();i++){
			if(v[i].second >= 1000000){
				flag = true;
				cout<<v[i].first<<endl;
			}
		}
		if(!flag)cout<<"NA\n";
	}
	return 0;
}