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 <algorithm>
#include <iostream>
#include <vector>

struct employee {
    int id;
    int price;
    int quantity;

    int total_sales() const {
        return price * quantity;
    }
};

employee read_employee(std::istream& in) {
    employee e{};
    in >> e.id >> e.price >> e.quantity;
    return e;
}

int main() {
    while (std::cin) {
        std::vector<employee> employees;
        int num;
        std::cin >> num;
        if (num <= 0)
            continue;
        for (int i = 0; i < num; ++i) {
            if (!std::cin) {
                std::cerr << "malformed input\n";
                std::exit(1);
            }
            auto e = read_employee(std::cin);
            employees.push_back(e);
        }
        std::vector<int> checked_ids;
        bool na = true;
        for (auto const& employee: employees) {
            if (std::find(checked_ids.begin(), checked_ids.end(), employee.id) != checked_ids.end())
                continue;
            checked_ids.push_back(employee.id);
            int sum = 0;
            for (auto const& e: employees) {
                if (e.id == employee.id)
                    sum += e.total_sales();
            }
            if (sum >= 1000000) {
                std::cout << employee.id << '\n';
                na = false;
            }
        }
        if (na)
            std::cout << "NA\n";
    }
}

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

using namespace std;

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

    vector<pair<int, long long>> seq;
    long long int id, p, q;
    for (int i = 0; i < n; ++i) {
      cin >> id >> p >> q;

      bool flag = true;
      for (auto &v : seq) {
        if (v.first == id) {
          flag = false;
          v.second += p * q;
          break;
        }
      }
      if (flag)
        seq.push_back(make_pair(id, p * q));
    }

    bool flag2 = true;
    for (auto &v : seq) {
      if (v.second >= 1e6) {
        cout << v.first << endl;
        flag2 = false;
      }
    }

    if (flag2)
      cout << "NA" << endl;
  }
}

C++: #include<iostream>

using namespace std;


int main(){

	long all[4001] = {};
	long code, a, b, n, i,j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}


		cin >> n;
		if (n == 0){
			break;
		}

		for (i = 0; i < n; i++){
			cin >> code >> a >> b;
			all[code] += a*b;
			
		}

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

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

	}
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
int s[4000];int i;int w;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	s[a-1]=s[a-1]+b*c;
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}

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

struct staff {
	int num;
	int price;
	int quan;
	int total;
};

int main()
{
	int num, i, k, j;
	int sn, sp, sq;
	map<int, staff> staffs;

	while(1)
	{
		cin >> num; if(!num) break;
		staffs.clear();

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[sn].num = sn;
			staffs[sn].price = sp;
			staffs[sn].quan = sq;
			staffs[sn].total += staffs[sn].price * staffs[sn].quan;
		}
		map<int, staff>::iterator staffs_it = staffs.begin();
		int over1000000 = 0;
		while(staffs_it != staffs.end())
		{
			if(staffs[(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[(*staffs_it).first].num << endl;
				over1000000++;
			}
			staffs_it++;
		}
		if(over1000000 == 0) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

long long n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,long long> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			if(sk[bg]==0) jun.push_back(bg);
			sk[bg] += tn * su;
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) cout << "NA" << endl;
	}
	return 0;
	
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<string.h>

int main()
{
	int n;
	long long v[4001];
	std::vector<int> vec;
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
		
		memset( v, 0, sizeof( v ) );
		vec.clear();
		
		while( n-- ){
			int num;
			int a, b;
		 	std::cin >> num >> a >> b;
			
			v[num] += (long long)( a * b );
			vec.push_back( num );
		}
		
		for( int i = 1; i <= 4000; i++ ){
			if( v[i] < 1000000 ) v[i] = 0;
			else v[i] = 1;
		}
		
		if( std::count( v + 1, v + 4001, 1 ) == 0 ){
		 	std::cout << "NA" << std::endl;
		}
		else{
			std::set<int> s;
		
			for( std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++ ){
				if( v[*it] && s.find( *it ) == s.end() ){
				 	std::cout << *it << std::endl;
				}
				
				s.insert( *it );
			}
		}
	}

 	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n;
  while(cin >> n, n){
    map<ll, ll> info;
    for(int i = 0; i < n; i++){
      int id, x, y;
      cin >> id >> x >> y;
      info[id] += x*y;
    }
    bool isAns = false;
    for(map<ll,ll>::iterator it = info.begin(); it != info.end(); it++){
      if(it->second >= 1000000){
	isAns = true;
	cout << it->first << endl;
      }
    }
    if(!isAns)cout << "NA" << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>
 
using namespace std;
 
int main(void){
 
    int n,flag,number;
    long double money,sum;
    int data[4001]={0},dataF[4001]={0};
    queue<int> ok;
 
    while(1){
 
        for(int i=0;i<4001;i++) data[i]=0,dataF[i]=0;
        flag=0;
 
        cin>>n;
        if(n==0) break;
 
        for(int i=0;i<n;i++){
            cin>>number>>money>>sum;
            data[number]+=money*sum;
            if(dataF[number]==0){
                dataF[number]=1;
                ok.push(number);
            }
        }
            while(!ok.empty()){
                if(data[ok.front()]>=1000000){
                    cout<<ok.front()<<endl;
                    flag=1;
                }
                ok.pop();
            }
            if(flag==0) cout<<"NA"<<endl;
    }
 
    return 0;
}