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 <vector>
#include <iostream>
#include <algorithm>
#include <utility>


typedef std::pair<int,int> Sale;

int main(){
  int n;

  while(1){
    std::cin>>n;
    if(n==0)break;
    std::vector<Sale> data(n);

    for(auto &d:data){
      int price,num;
      std::cin>>d.first>>price>>num;
      d.second=price*num;
    }

    std::vector<Sale> unduplicate_data;

    for(auto &d:data){
      auto s=std::find_if(unduplicate_data.begin(),unduplicate_data.end(),[d](const Sale& s)->bool{ return s.first==d.first; });
      if(s==unduplicate_data.end()){
        unduplicate_data.push_back(d);
      }else{
        s->second+=d.second;
      }
    }

  
    bool isNA=true;
    for(auto d:unduplicate_data){
      if(d.second>=1000000){
        std::cout<<d.first<<std::endl;
        isNA=false;
      }
    }
    if(isNA)std::cout<<"NA"<<std::endl;
  }
}

C++: #include<iostream>
#include <sstream>
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);
	memcpy(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;
			}
			if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		if(sl[i].Saled >= 1000000)
		{
			cout << sl[i].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
end_scope:
    return 0;
}

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

int main(){
	int n;
	
	while(cin>>n,n){
		int printed=0;
		long table[4001];
		for(int i=0;i<4001;i++){
			table[i]=0;
		}
		for(int i=0;i<n;i++){
			int b,t,k;
			cin>>b>>t>>k;
			if(table[b]<1000000){
				table[b]+=t*k;
				if(table[b]>=1000000){
					cout<<b<<endl;
					printed=1;
				}
			}
		}
		if(printed==0){
			cout<<"NA"<<endl;
		}
	}

	return 0;
}

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

using namespace std;

const int kSum = 1000000;

int getSum(int price, int sales)
{
  return price * sales;
}

int main()
{
  int n_employee;
  int number, price, sales;
  bool flag;
  map<int, int> checkEmp;

  while(cin >> n_employee){
    if(n_employee == 0){
      break;
    }

    flag = true;

    for(int i = 0; i < n_employee; ++i){
      cin >> number >> price >> sales;

      if(checkEmp.find(number) != checkEmp.end()){
	checkEmp[number] += getSum(price, sales);
      } else {
	checkEmp[number] = getSum(price, sales);
      }
    }

    for(map<int,int>::iterator iter = checkEmp.begin(); iter != checkEmp.end(); ++iter){
      if(iter->second >= kSum){
	cout << iter->first << endl;
	flag = false;
      }
    }

    if(flag){
      cout << "NA" << endl;
    }
    checkEmp.clear();
  }

  return 0;
}

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

ll worker[4001];

int main() {
  int n, id;
  long long p, q;
  while(cin >> n && n) {

	fill((ll*)worker, (ll*)(worker + 4001), 0);
	for(int i = 0; i < n; ++i) {
	  cin >> id >> p >> q;
	  worker[id] += p * q;
	}

	bool isNA = 1;
	for(int i = 1; i < 4001; ++i) {
	  if(worker[i] >= 1000000) {
		cout << i << endl;
		isNA = 0;
	  }
	  /*
	  if(worker[i] != 0) {
		cout << "i:" << i << " result:" << worker[i] << endl;;
		isNA = 0;
	  }
	  */
	}
	
	if(isNA) {
	  cout << "NA" << endl;
	}
	
  }
  return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int id, price, amount;
		vector<int> v;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> amount;
			if(price * amount >= 10000){
				vector<int>::iterator itr = find(v.begin(), v.end(), id);
				if(itr == v.end()){
					v.push_back(id);
				}
			}
		}
		if(v.empty()){
			cout << "NA" << endl;
		}
		else{
			for(int i = 0; i < v.size(); i++){
				cout << v[i] << endl;
			}
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int aa[10000]={0},x=0,y=0,z=0,flg=0,a,flgg[4050]={0};
    while(cin>>a)
    {
        if(a==0)break;
        for(int i=0;i<a;i++)
        {
            cin>>x>>y>>z;
            aa[x]+=y*z;
            if(aa[x]>=1000000)
            {
                if(flgg[x]==0)
                {
                    cout<<x<<endl;
                    flgg[x]=1;
                    flg=1;
                }
            }
        }
        //for(int i=0;i<4010;i++)
        //{
        //    if(aa[i]>=1000000)
        //    {
        //        flg=1;
        //        cout<<i<<endl;
        //    }
        //}
        if(flg==0)cout<<"NA"<<endl;
        for(int i=0;i<4010;i++)
        {
            aa[i]=0;
            flg=0;
        }
    }
    return 0;
}

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

int main()
{
    int n;
    while(cin >> n,n){
        bool hantei=true,kaburi[n];
        long long number[n],price[n],quantity[n],sale[n];
        for(int i=0 ; i<n ; i++){
            cin >> number[i] >> price[i] >> quantity[i];
            if(price[i]<0&&quantity[i]<0){
                sale[i]=0;
            }
            else{
                sale[i]=price[i]*quantity[i];
            }
        }
        for(int i=0 ; i<n-1 ; i++){
            for(int j=i+1 ; j<n ; j++){
                if(number[i]==number[j]){
                    kaburi[j]=true;
                    sale[i]+=(price[j]*quantity[j]);
                }
            }
        }
        for(int i=0 ; i<n ; i++){
            if(kaburi[i]){
                continue;
            }
            if(sale[i]>=1000000){
                cout << number[i] << endl;
                hantei=false;
            }
        }
        if(hantei){
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
	int num;
	int LINE = 1000000;
	while(cin>>num, num != 0){
		vector<int> employees;
		int id =0, q=0, p=0;
		for(int i=0; i<num; i++){
			cin>>id>>q>>p;
			if(q*p >= LINE){
				employees.push_back(id);
			}
		}
		for(int i=0; i<employees.size(); i++){
			cout<<employees.at(i)<<endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n=1;
	int i=0,j=0;
	int tanka[4001]={0};
	int flg=0;
	int uriage[4001]={0};
	int bangou[4001]={0};
	int ccc=0;
	while(n!=0)
	{
		flg=0;
		ccc=0;
		scanf("%d",&n);
		if (n==0)
		{
			break;
		}
		for (i=1;i<=n;i++)
		{
			ccc++;
			scanf("%d %d %d",&bangou[ccc],&tanka[ccc],&uriage[ccc]);
			for (j=0;j<ccc;j++)
			{
				if (bangou[ccc]==bangou[j])
				{
					tanka[j]+=tanka[ccc];
					uriage[j]+=uriage[ccc];
					ccc--;
				}
			}
		}
		for (i=1;i<=ccc;i++)
		{
			if (tanka[i]*uriage[i]>=1000000)
			{
				printf("%d\n",bangou[i]);
				flg=1;
			}
		}
		if (flg==0)
		{
			printf("NA\n");
		}
	}
return 0;
}