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<stdio.h>
int n,i,b;
int syain[4001],a,suu;
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
		}
		int flg=0;
		for(i=1;i<=4000;i++){
			if(syain[i]>=1000000){
				printf("%d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    int employee_sale_num[4000] = {};
    int employee_sale[4000] = {};
    
    while ((scanf("%d", &data_num)) != EOF) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %d %d", &employee_num[i], &employee_sale_num[i],  &employee_sale[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    employee_sale[data_check] += employee_sale[i];
                    employee_sale_num[data_check] += employee_sale_num[i];
                    data_num_update--;
                }

                
            }
            data_check++;
            
        }
        
        //printf("%d", data_num_update);
        
        bool result_flag = true;
        for (int i = 0; i < data_num_update; ++i) {
            if (employee_sale_num[i] * employee_sale[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  
  while (cin >> n, n){
    long long s[4000] = {0}, p, q;
    int e;

    for (int i = 0; i < n; i++){
      cin >> e >> p >> q;
      s[e - 1] += (p * q);
    }
    bool f = false;
    for (int i = 0; i < 4000; i++){
      if (s[i] >= 1000000){
        cout << i + 1 << endl;
        f = true;
      }
    }

    if (!f){
      cout << "NA" << endl;
    }

  }

  return 0;
}

C++:     while (scanf("%d", &data_num)) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &unit_sale_num[i],  &sale_num[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    sale_num[data_check] += sale_num[i];
                    unit_sale_num[data_check] += unit_sale_num[i];
                    data_num_update--;
                }
            }
            data_check++;
        }
        
        bool result_flag = true;
        
        for (int i = 0; i < data_num_update; ++i) {
            if (unit_sale_num[i] * sale_num[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

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




int n;


void solve()
{
	bool ok=false;
	long long  total[4000];
	bool check[4000];
	memset(check,false,sizeof(check));
	memset(total,0,sizeof(total));
	for(int i=0;i<n;i++){
		int num,a,b;
		cin>>num>>a>>b;
		total[num]+=a*b;
		if(total[num]>=1000000 && !check[num]){
			cout<<num<<endl;
			check[num]=true;
			ok=true;
		}
	}
	if(!ok) cout<<"NA"<<endl;
}

int main()
{
	while(cin>>n){
		if(n==0) break;
		solve();
	}
	return 0;
}

C++: #include <iostream>

#define N 1000

using namespace std;

int main(){
	int data[N];
	int n , sum[N];
	int e[N] , p , q;

	while(1){
		int flag = 0;
		
		cin >> n;
		if(n == 0) break;
	
		for(int i = 0; i < n; i++){
			cin >> e[i] >> p >> q;
			sum[i] = p * q;
		
		}for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				if(e[i] == e[j]){
					sum[i] += sum[j];
				}
			}
		}for(int i =  0; i < n; i++){
			if(sum[i] >= 1000000){
				flag = 1;
				cout << e[i] << endl;
			}
		}if(flag == 0){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<map>
#include<utility>
#include<queue>

using namespace std;




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

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

			staff[num] +=  (b*c);
		}
		static map< int, unsigned long long int>::iterator itr;
		for (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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

/*
int main(){
    int n = 100;
    for (int i=0; i<n; i++) {
        cout << 2000+i<<" "<< 123213242%(100000+i*100) +1421%(10+i)*100<<" "<<1421%(100+i)*100<<endl;
    }
}*/


int main(){
    for (;;) {
        ll n;
        cin >> n;
        if(n==0) break;
        vector<ll> num(4001,0),pre(n,0),data(4001,0);
        for (int i=0; i<n; i++) {
            ll a,b,c;
            cin >>a >>b >>c;
            ll inp;
            if(b*c>=1000000){
                inp=1000000;
            }else{
                inp = b*c;
            }
            if(data[a]<1000000) data[a]+=inp;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0; k< 4001; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        ll ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1)

int main(){
  int n;
  while(cin >> n, n){
    map<int,int> e;
    for(int i = 1; i <= 4000; i++){
      e[i] = 0;
    }
    for(int i = 0; i < n; i++){
      int tmp[3];
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      e[tmp[0]] += tmp[1] * tmp[2];
    }
    int cnt = 0;
    for(int i = 1; i <= 4000; i++){
      if(e[i] >= 1000000){
        cout << i << endl;
        cnt++;
      }
    }
    if(cnt == 0){
      cout << "NA" << endl;
    }
  }
}