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

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);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * (n + 1));
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d", &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++)
	{
		//cout << "Saled " << j << ":" << sl[j].Saled << endl;
		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<iostream>
#include<stdio.h>
#include<map>
#include<utility>
#include<queue>

using namespace std;




int main(){
	static int n;
	while (cin >> n&&n != 0)
	{
		map< int, long long int> staff;
		queue< int> Queue;
		bool cnt = false;

		for (size_t i = 0; i < n; i++)
		{
			int num;
			long long b, c;
			cin >> num >> b >> c;

			staff[num] += (long long int) (b*c);
		}
		for (static map< int, long long int>::iterator itr = staff.begin(); itr != staff.end(); itr++){
			if (itr->second >= 1000000)
				Queue.push(itr->first);

		}
		if (Queue.size() == 0){
			cout << "NA" << endl;
		}
		else
		{
			while (Queue.size() > 0){

				cout << Queue.front() << endl;
				Queue.pop();

			}

		}

	}

	return 0;
}

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

int main()
{
	int n;

	while (cin >> n, n){
		int e[5000] = {0}, p, q, a;
		bool out = false;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 1; i <= 4000; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

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);		// データ個数
	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", &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++)
	{
		//cout << "Saled " << j << ":" << sl[j].Saled << endl;
		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<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int n;
   while(cin>>n&&n)
   {
     long long int arr[1000000+5]={0};
     bool flag=false;
     for(int i=0;i<n;i++)
     {
       int id,p,q;
       cin>>id>>p>>q;
       arr[id]+=(p*q);        
     }           
     for(int i=1;i<=1000000;i++)
     {
       if(arr[i]>=1000000)
       {
         cout<<i<<endl;
         flag=true;
       }        
     }       
     if(!flag) cout<<"NA"<<endl;
   }
   //while(1);
   return 0;
 }

C++: int main(void)
{	
	employee person[4000];
	int a,b,c,d;
	for(b=0;;b=0)
	{
		scanf("%d",&c);
		for(a=0;a<c;a++)
		{
			scanf("%d %lld %lld",&person[a].N,&person[a].P,&person[a].A);
			person[a].M=person[a].P*person[a].A;
			for(d=0;d<a;d++)
				if(person[a].N==person[d].N)
				{
					person[a].M+=person[d].M;
					person[d].M=0;
				}
		}
		for(a=0;a<c;a++)
			if(person[a].M>=1000000 )
			{
				printf("%d\n",person[a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <map>
#define STA 1000000
using namespace std;

int main(){
    int n;
    long long num,price,value;
    bool judge;
    while(1){
        cin >> n;
        if(n == 0) break;
        map <int,long long> data;
        map <long long,long long> data1;
        map <long long,long long>::iterator itr;
        data.clear();
        data1.clear();
        for(int i=1;i<=n;i++){
            cin >> num >> price >> value;
            itr = data1.find(num);
            if(itr != data1.end()) data1[num] += price * value;
            else {
                data.insert(map<int,long long>::value_type(i,num));
                data1.insert(map<long long,long long>::value_type(num,price*value));
            }
        }
        judge = false;
        for(int i=1;i<=n;i++){
            if(data1[data[i]] >= STA){
                cout << data[i] << endl;;
                judge = true;
            }
        }
        if(!judge) cout << "NA" << endl;
    }
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  vector<string> result;

  while (true) {
    cin >> n;
    if (n == 0)
      break;

    bool hoge = true;
    for (int i = 0; i < n; i++) {
      string id;
      long long a, b;
      cin >> id >> a >> b;
      if (a * b >= 1000000) {
        result.push_back(id);
        hoge = false;
      }
    }
    if (hoge)
      result.push_back("NA");
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}