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 <bits/stdc++.h>
#define MAX_MEMBER 4000
#define HIGH 1000000
using namespace std;

int main(void) {
    int n;
    while(cin >> n, n != 0) {
        map<int, int> data;
        bool update = false;
        for(int r = 0; r < n; r++) {
            int no, tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no]) {
                data[no] += tanka*quantity;
            } else data[no] = tanka*quantity;
        }
        map<int, int>::iterator it;
        for(it = data.begin(); it != data.end(); it++) {
            if(it->second >= HIGH) {
                cout << it->first << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    
    return(0);
}

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

int main(){
 int id,price,num,count,SaleResult[4000],idOrder[4000],orderCount=1;
 bool isBe=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   SaleResult[id]+=price*num;
   if(SaleResult[id]>=1000000){
    for(int i=0;i<orderCount;i++){
     if(id==idOrder[i]){
      break;
     }
     if(i==orderCount-1){
      idOrder[orderCount]=id;
     }
    }
   }
  }
  for(int i=0;i<4000;i++){
   if(SaleResult[idOrder[i]]>=1000000){
     cout<<i<<'\n';
     isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<4000;i++){
    SaleResult[i]=0;
  }
  }
 return 0;
}

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

std::vector<int> staff;
bool search(int number);

int main()
{
	int n;
	while(1)
	{
		int number,price,amount;
		staff.clear();
		std::cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			std::cin>>number>>price>>amount;
			if((long long)price*amount>=1000000)
			{
				if(search(number)==false)
				{
					staff.push_back(number);
				}
			}
		}
		if(staff.empty())
		{
			std::cout<<"NA"<<std::endl;
		}
		else
		{
			for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
			{
				std::cout<<*p<<std::endl;
			}
		}
	}
	return 0;
}

bool search(int number)
{
	for(std::vector<int>::iterator p=staff.begin();p!=staff.end();p++)
	{
		if(*p==number)return true;
	}
	return false;
}

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

int main(){
 int id,price,num,count;
 int sameid[4000];
 bool isBe=false,isSame=false;

 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   sameid[i]=id;
   for(int j=1;j<i;j++){
    if(id==sameid[j]){
      isSame=true;
      break;
    }
   }
   if(price*num>=100000&&!isSame){
    cout<<id<<'\n';
    isBe=true;
   }
   isSame=false;
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<count;i++){
   sameid[i]=0;
  }
 }
 return 0;
}

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

using namespace std;
#define mp make_pair
int main(){
  int n,a,b;
  long long c;
  map<int,long> data;
  vector<int> id;
  while(true){
    id.clear();
    data.clear();
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      c*=b;
      if(data.find(a)==data.end()){
	data.insert(mp(a,c));
	id.push_back(a);
      }
      else{
	data[a]+=c;
      }
    }
    bool empty = true;
    for(int i=0;i<id.size();i++){
      if(data[id[i]]>=1000000){
	cout<<id[i]<<endl;
	empty = false;
      }
    }
    if (empty)
      cout<<"NA"<<endl;

  }
  return 0;
}

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

int main() {
  int n,ID,price,quantity,sales[4001] = {0},check;
  while(cin >> n) {
    int sales[4001] = {0};
    if(n == 0) break;
    for(int i=0;i<n;i++) {
      cin >> ID >> price >> quantity;
      sales[ID] += price * quantity;
    }
    check = 0;
    for(int i=1;i<4001;i++) {
      if(sales[i] >= 1000000) {
        cout << i << endl;
        check = 1;
      }
    }
    if(check == 0)
      cout << "NA" << endl;
  }
}

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

int main(){
	int n;
	
	while(cin>>n,n){
		int printed=0;
		long long int table[4001];
		for(int i=0;i<4001;i++){
			table[i]=0;
		}
		for(int i=0;i<n;i++){
			int b,t,k;
			cin>>b>>t>>k;
			if(table[b]<1000000){
				table[b]+=t*k;
				if(table[b]>=1000000){
					cout<<b<<endl;
					printed=1;
				}
			}
		}
		if(printed==0){
			cout<<"NA"<<endl;
		}
	}

	return 0;
}

C++: while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    sep = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        if i in d:
            d[i] += p*q
        else:
            d[i] = p*q
            sep.append(i)
    tmp = list(filter(lambda x: x[1] >= 1000000, d.items()))
    if len(tmp):
        for s in sep:
            if s in tmp:
                print(s)
    else:
        print("NA")

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    map<int, int> t;
    while (n--) {
      int i, p, q;
      cin >> i >> p >> q;
      t[i] += p * q;
    }
    bool f = true;
    for (auto x : t) {
      if (x.se >= 1000000) {
        f = false;
        cout << x.fi << endl;
      }
    }
    if (f) cout << "NA" << endl;
  }
}

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

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
        for (map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it){
            if((*it).second>=1000000){
                s=1;
                cout<<(*it).first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}