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<iostream>
#include<vector>
#include<map>
using namespace std;

int main() {
  int num = 0;
  while (cin >> num, num) {
    vector<int> order;
    int data[4000] = { 0 };
    int count;
    for (int i = 0; i < num; i++) {
      int id, price, sold_num;
      cin >> id >> price >> sold_num;
      for (int i = 0; i < order.size(); i++) {
        if (order[i] == id) {
          break;
        }
        if (i == order.size() - 1) {
          order.push_back(id);
        }
      }
      if (order.size() == 0) {
        order.push_back(id);
      }
      data[id] += price*sold_num;
    }
    count = 0;
    for (int i = 0; i < order.size(); i++) {
      if (data[order[i]] >= 1000000) {
        cout << order[i] << endl;
        count++;
      }
    }
    if (count == 0) {
      cout << "NA" << endl;
    }
  }
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d\n", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d\n", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[j].Saled >= 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}

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;
}