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

using Sale=std::pair<int,int>;

int main(){
  int n;

  while(1){
    std::cin>>n;
    if(n==0)break;
    std::vector<Sale> data(n);

    for(auto &d:data){
      int price,num;
      std::cin>>d.first>>price>>num;
      d.second=price*num;
    }

    std::vector<Sale> unduplicate_data;

    for(auto &d:data){
      auto s=std::find_if(unduplicate_data.begin(),unduplicate_data.end(),[d](const Sale& s)->bool{ return s.first==d.first; });
      if(s==unduplicate_data.end()){
        unduplicate_data.push_back(d);
      }else{
        s->second+=d.second;
      }
    }

  
    bool isNA=true;
    for(auto d:unduplicate_data){
      if(d.second>=1000000){
        std::cout<<d.first<<std::endl;
        isNA=false;
      }
    }
    if(isNA)std::cout<<"NA"<<std::endl;
  }
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int NORMA = 1000000;

int main() {
  int N;
  while(cin >>N && N){
    map<int, int> m;
    set<int> s;
    vector<int> v;
    REP(i, N){
      int a, b, c; cin >>a >>b >>c;
      m[a] += b * c;
      if(s.find(a) == s.end()) v.push_back(a);
      s.insert(a);
    }
    vector<int> ans;
    REP(i, v.size()) if(m[v[i]] >= NORMA) ans.push_back(v[i]);
    if(ans.size() == 0) cout <<"NA" <<endl;
    else REP(i, ans.size()) cout <<ans[i] <<endl;
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<ll> s(4000, 0);
        REP(i,n) {
            int e,p,q;
            cin >> e >> p >> q;
            s[e-1] += p*q;
        }
        bool flag = false;
        REP(i,4000) {
            if (s[i] >= 1000000) {
                cout << i + 1 << endl;
                flag = true;
            }
        }
        if (!flag) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
ll a[4001];

int main(){
	int n, num, p, q;
	while(cin >> n, n){
		fill(a, a+4001, 0);
		int f = 1;
		
		for(int i = 0;i < n;i++){
			cin >> num >> p >> q;
			a[num] += p * q;
			if(a[num]>999999)cout << num << endl, f = 0;
		}
		
		if(f)cout << "NA" <<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n)
	{
		bool f = true;
		rep(i, n)
		{
			int a, s, num;
			cin >> num >> a >> s;

			if(1000000 <= a * s)
			{
				f = false;
				cout << num << endl;
			}
		}
		if(f) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <map>
using namespace std;
int main() {
  int n, e;
  long long p, q;
  map<int, long long> mp;
  map<int, long long>::iterator itr;

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

	for(int i = 0; i < n; ++i) {
	  cin >> e >> p >> q;
	  itr = mp.find(e);
	  if(itr != mp.end()) {// found
		mp[e] += p * q;
	  }
	  else {// not found
		mp[e] = p * q;
	  }
	}

	bool isNA = true;
	for(itr = mp.begin(); itr != mp.end(); ++itr) {
	  if(itr->second >= 1000000) {
		cout << itr->first << endl;
		isNA = false;
	  }
	}
	if(isNA) {
	  cout << "NA" << endl;
	}

	mp.clear();
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
int main(){
  int n,index[10000],inindex,val,num,couter;
  map<int,ll> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    couter=0;
    List.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(List[inindex] == 0){
	index[couter]=inindex;
	couter++;
      }
      List[inindex]+=val*num;
    }
    int NAf=true;
    for(int i=0;i<couter;i++){
      if(List[index[i]] >= 1000000){
	printf("%d\n",index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}

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

int main(){
	int n, num, count;
	long long int p, q, nu[5000];
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < 5000; i++) {
			nu[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> num >> p >> q;
			nu[num] += p * q;
		}
		count = 0;
		for (int i = 1; i < 5000; i++) {
			if(nu[i]>999999){
				cout << i << endl;
				count++;
			}
		}
		if (count==0){
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

using namespace std;

struct data{
  int id;
  long long  price;
  long long  amount;
  long long rate;
};

int main(){
  int n=0;
  while(1){
    cin>>n;
    if(n==0){return 0;}
    vector<struct data> data(n);
    int c=0;
    for(int i=0;i<n;i++){
      scanf("%d %l %l",&data[i].id,&data[i].price,&data[i].amount);
      data[i].rate=data[i].price*data[i].amount;
    }
    vector<struct data> res(n);
    for(int i=0;i<n;i++){
      res[i].id=0;
      res[i].rate=0;
    }
    for(int i=0;i<n;i++){
      int find=0;
      for(int j=0;j<i;j++){
	if(data[i].id==res[j].id){
	  res[j].rate+=data[i].rate;
	  find=1;
	  break;
	}
      }
      if(find==0){
	res[i].id=data[i].id;
	res[i].rate=data[i].rate;
      }
    }
    for(int i=0;i<n;i++){
      if(res[i].id!=0&&res[i].rate>=1000000){
	cout<<data[i].id<<"\n";
	c++;
      }
    }
    if(c==0){
      cout<<"NA\n";
    }
  }
  return 0;
}