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

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

int main(){
	int n,number;
	long long a,b;
	bool flag;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number); // 既出だったら表示順記録配列に入れない。単価0円ケースを考慮してません。
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

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

int main()
{
	int num, man, yen, ko;
	int ach;
	int c;
	int g[20][2] = { {} };
	int flag;
	
	while (1){
		c = 0;
		flag = 0;

		cin >> num;
		if (!num)	break;

		for (int i = 1; i <= num; i++){
			int j = i;
			cin >> man >> yen >> ko;
			ach = yen * ko;

			for (; j > 0; j--){
				if (g[j - 1][0] == man)
					g[j - 1][1] += ach;
				else flag = 1;

				if (g[j - 1][1] >= 1000000){
					cout << man << endl;
					c++;
				}
			}

			if (flag){
				g[i][0] = man;
				g[i][1] = ach;
			}

			if (g[i][1] >= 1000000){
					cout << man << endl;
					c++;
			}
		}

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

	return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
long int shineU[SHINE_MAX];	//?£??????????

int num,tanka,suryo;
int i;

int main(){
	while(1){
	 cin>>shineN;
	 if(shineN==0){break;}
	 for(i=0;i<SHINE_MAX;i++){shineU[i]=0;}
	 for(i=0;i<shineN;i++){
	  cin>>num>>tanka>>suryo;
	  shineU[num-1]+=tanka*suryo;
	 }
	 //??¨?????????????????¨
	 eliteN=0;
	 for(i=0;i<SHINE_MAX;i++){
	  if(ELITE<=shineU[i]){
	   cout<<i+1<<endl;
	   eliteN++;
	  }
	 }
	 if(eliteN==0){cout<<AHO<<endl;}
	}
	return 0;
}