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>

using namespace std;
class saleData
{
public:

	int hireNo;
	long saleValue = 0;

	void addSale(long value)
	{
		if(saleValue < 1000000)
		{
			saleValue += value;
		}
	}

	bool judge()
	{
		if(saleValue >= 1000000)
		{
			return true;
		}
		return false;
	}
};
int main()
{
	while(1)
	{
		int dataCount;
		cin >> dataCount;
		vector<saleData> vobj;

		if(dataCount == 0)
		{
			break;
		}
		bool dataFlag = false;
		for(int i = 0; i < dataCount; i++)
		{
			long hireNo;
			long price;
			long No;
			cin >> hireNo >> price >> No;

			for(int j = 0; j < vobj.size(); j++)
			{
				if(vobj.size() == 0)
				{
					break;
				}
				if(vobj[j].hireNo == hireNo)
				{
					vobj[j].addSale(price * No);
					dataFlag = true;
					break;
				}
			}
			if(dataFlag == false)
			{
				saleData sObj;
				sObj.hireNo = hireNo;
				sObj.addSale(price * No);
				vobj.push_back(sObj);
			}
		}
		dataFlag = false;
		for(int i = 0; i < vobj.size() ; i++)
		{
			if(vobj[i].judge() == true)
			{
				cout << vobj[i].hireNo << endl;
				dataFlag = true;
			}
		}
		if(dataFlag == false)
		{
			cout << "NA" << endl;
		}


	}



}

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

int main(){
    long long size, id, price, quantity;
    vector<int> ids;
    bool noone = true;
    while (1){
	cin >> size;
	if (!size) break;
	for (int i = 0; i < size; i++){
	    cin >> id >> price >> quantity;
	    if (price * quantity >= 1000000){
		for (int k = 0; k < ids.size(); k++){
		    if (id == ids[k]) goto HELL;
		}
		cout << id << endl;
		noone = false;
	    }
	  HELL:;
	}
	if (noone) cout << "NA" << endl;
	noone = true;
    }
}

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

using namespace std;

int main()
{
	int n;
	while(cin>>n,n){
		map<int,long long> mp;
		bool flag=false;
		while(n--){
			int id,unit,num;
			cin>>id>>unit>>num;
			if(mp[id]<1000000 && 1000000<=mp[id]+(long long)unit*num){
				cout<<id<<endl;
				flag=true;
			}
			mp[id]+=(long long)unit*num;
		}
		if(!flag)	cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


struct man{
  int num;
  int money;
};

int main()
{
  int n;
  while(true)
    {
      cin>>n;
      if(n==0)
	exit(0);
      vector<man> d;
      d.clear();
      for(int i=0;i<n;i++)
	{
	  int num,a,b;
	  bool ch=false;
	  cin>>num;
	  cin>>a;
	  cin>>b;
	  for(int j=0;j<d.size();j++)
	    {
	      if(d[j].num==num)
		{
		d[j].money=d[j].money+a*b;
		ch=true;
		break;
		}
	    }
	  if(ch==false)
	    {
	      struct man x;
	      x.num=num;
	      x.money=a*b;
	      d.push_back(x);
	    }
	}

      int count=0;
      for(int j=0;j<d.size();j++)
	if(d[j].money>=1000000)
	  {
	    cout<<d[j].num <<endl;
	    //    cout<<d[j].num << "   "<< d[j].money<<endl;
	    count++;
	  }
      if(count<1)
	cout<<"NA"<<endl;

    }
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;


int main(){

	long long int sales[4001],price,amount;

	int n,id,count;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 1; i <= 4000; i++)sales[i] = 0;

		for(int i = 1; i <= n; i++){
			scanf("%d %lld %lld",&id,&price,&amount);
			sales[id] += price*amount;
		}

		count = 0;

		for(int i = 1; i <= 4000; i++){
			if(sales[i] >= 1000000){
				printf("%d\n",i);
				count++;
			}
		}
		if(count == 0)printf("NA\n");
	}

    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
ll need = (int)1e6;
ll sum[4040];

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		
		memset(sum, 0, sizeof(sum));
		for (int i = 0; i < n; i++) {
			int id, q, p; cin >> id >> q >> p;
			sum[id] += q * p;
		}
		
		bool na = true;
		for (int i = 0; i < 4040; i++) {
			if (sum[i] >= need) {
				cout << i << endl;
				na = false;
			}
		}
		
		if (na) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n,x,y,z;
	int a = 0,b=0;
	int g[4000];

	while(true){
        int b=0;
		cin >> n;

		if(n==0){
			break;
		}
		for(int i=0 ;i<n ;i++){

	       cin >> x >> y >> z;

		   a = y*z;
		   if(a>=1000000){
			
			 g[b] = x;
			 b++;  
		   
		   }
		  
		}
	
		
	if(b>0){
	     	for(int i=0 ;i<b ;i++){
			cout << g[i] << endl;			
		   }	
	}	
	else	
		cout << "NA" << endl;
	
	}
	
	return 0;
}

C++: #include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum,flag;
	long long total[MAX],unitcost,amount;
	while( 1 ){

		for(i=0;i<MAX;i++){
			total[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %d %d",&snum,&unitcost,&amount);
			total[snum]+=unitcost*amount;
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( total[i] >= 1000000 ){
				flag=1;
				printf("%d\n",i);
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}

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

int main(){
  int n;//データ数
  while(cin >> n){
    int arr[4000];//社員番号
    int selling[n];//販売単科
    int sales[n];//売り上げ数量
    int num;
    int check=0;
    //社員は4000人未満
    memset(arr,0,sizeof(arr));
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin >> num >> selling[i] >> sales[i];
      arr[num]+=selling[i]*sales[i];
      if(arr[num]>=1000000){
        cout << num << endl;
        check++;
      }
    }
    if(check==0)
      cout << "NA" << endl;
    check=0;
  }
}

C++: #include <iostream>

using namespace std;

//empoyer,price,quantity;
int main()
{
    
    while (1){
        int num;
        cin >> num;
        if (num == 0) break;
        int employer[4001][2] = {0};
        
        int e, p, q;
        int ans[4001] = {0};
        int count = -1;
        for (int i = 0; i < num; i++) {
            cin >> e >> p >> q;
            ans[i] = e;
            employer[e][0] = employer[e][0] + (p * q);
            if (employer[e][0] >= 1000000 && employer[e][1] != 1) {
                employer[e][1] = 1;
                count++;
                ans[count] = e;
            }
        }
        if (count >= 0) {
            for (int i = 0; i <= count; i++) {
                cout << ans[i] << endl;
            }
        }else {
            cout << "NA" << endl;
        }
    }
    return 0;
}