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<cstring>

long long owData[4001];
std::vector<int> used;

int main(){
  long long x,input[3];
	bool Person;
	while( std::cin>>x , x ){
		Person=false;
		used.clear();
		memset(owData,0,sizeof(owData));
		while( x-- ){
			std::cin>>input[0]>>input[1]>>input[2];
			if( owData[input[0]] == 0 )used.push_back(input[0]);
			owData[input[0]]+=input[1]*input[2];
		}
		for(auto it = used.begin(); it != used.end(); ++it ){
			if( owData[*it] >= 1000000 )
				std::cout<< *it <<std::endl, Person=true ;
		}
		if(!Person)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

C++: #include <stdio.h>

struct employees
{
	int i;
	int p;
	int q;
};

int main(void)
{
	int n, m, x, y, z;
	struct employees number[4000] = {0};

	n = 0;
	while (scanf("%d %d %d", &x, &y, &z) != EOF)
	{
		if (x == 0)
			break;
		if (x <= 4000 && y <= 1000000 && z <= 100000)
		{
			number[n].i = x;
			number[n].p = y;
			number[n].q = z;
			n++;
		}
	}
	for (n = 0, m = 0; n < 4000; n++)
	{
		if (number[n].i == 0)
			break;
		if (number[n].q * number[n].p >= 1000000)
		{
			printf("%d\n", number[n].i);
			m++;
		}
	}
	if (m == 0)
			printf("NA\n");

	return 0;
}

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

typedef pair<int,int> P; //社員番号、売上

int main(void)
{
	int n;

	while(cin >> n,n){
		vector<P> d;
	
		int no,m,k;
		bool f = false;

		for(int i = 0; i < n; i++){
			cin >> no >> m >> k;
			
			int j;
			for(j = 0; j < d.size(); j++){
				if(d[j].first == no){
					d[j].second += m*k;
				}
			}

			if(j == d.size()){
				d.push_back(P(no,m*k));
			}
		}
		int j;
		for(j = 0; j < d.size(); j++)
			if(d[j].second >= 1000000){
				f = true;
				break;
			}
		if(!f)
			cout << "NA\n";

		else{
			for(j = 0; j < d.size(); j++)
				if(d[j].second >= 1000000){
					cout << d[j].first << endl;
				}
		}
	}

	

	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, id, p, q;
    while (cin >> n && n) {
        map<long long, long long> output;
        for (int i=0; i<n; ++i) {
            cin >> id >> p >> q;
            output[id] += p * q;
        }
        bool na = true;
        for (auto x : output) {
            if (1000000 <= x.second) {
                cout << x.first << endl;
                na = false;
            }
        }
        if (na) {
            cout << "NA" << endl;
        }
    }

    return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
#define int long long int
using namespace std;
void main() {
  bool f;
  vector<pair<int, int> > v;
  int n, a, b, c;
  while (cin >> n && n > 0) {
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      f = 0;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first == a) {
          v[j].second += b * c;
          f = 1;
        }
      }
      if (!f) {
        v.push_back(pair<int, int>(a, b * c));
      }
    }
    f = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        cout << v[i].first << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
}

C++: #include<stdio.h>
int main(void){
    int n,i,j,k=0,x[4001],y,z;
    int a[4001]={0};
    long long b[4001]={0};
    int flag[4001]={0};
    for(;;){
        k=0;
        for(j=0;j<n;j++){
            a[j]=0;
            b[j]=0;
            flag[j]=0;
            x[j]=0;
            }
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++){
            scanf("%d%d%d",&x[i],&y,&z);
            if(flag[i]==1);
            else {
                if(a[i]!=0)b[i]=b[i]+y*z;
                else {
                    a[i] = x[i];
                    b[i] = y*z;
                }
            }
            if(b[i]>=1000000){
                printf("%d\n",a[i]);
                flag[i]++;
                k++;
            }

        }
        if(k==0)printf("NA\n");
    }
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#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>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

 
int main(){
	int n;
	while(cin>>n,n){
		vector<int> a;
		for (int i = 0; i < n; i++){
			int d; ll b,c; cin>>d>>b>>c;
			if(b*c >= 1000000L) a.push_back(d);
		}
		if(a.size() == 0){ puts("NA"); continue; }
		for (int i = 0; i < (int)a.size(); i++)
			cout << a[i] << endl;
	}
    return 0;
}

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

int main(){
  int n,id[10000],array[10000],array1[10000],i,j,count;
  
  while(1){
    count = 0;
    cin >> n;
    if(n == 0)break;
    
    for(i=0;i<n;i++){
      cin >> id[i];
      for(j=0;j<2;j++){
	cin >> array[j];
	cin >> array1[j];
      }
    }
    for(i=0;i<n;i++){
      if(array[i] * array1[i] >= 1000000){
	cout << id[i] << endl;
	count++;
      }
    }
    if(count == 0)cout << "NA" << endl;   
  }
}

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


	}



}