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 <cstdio>
#include <queue>
using namespace std;

const int sales = 1000000;

int main()
{
	int n;
	while(scanf("%d",&n),n) {
		bool flag[4000]={flalse};
		queue<int> employee_n;
		for(int i=0;i<n;++i) {
			int number,a,b;
			scanf("%d %d %d",&number,&a,&b);
			if(sales>a*b||flag[number-1]) continue;
			flag[number-1]=true;
			employee_n.push(number);
		}
		while(!employee_n.empty()){
			printf("%d\n",employee_n.front());
			employee_n.pop();
		}
		if(employee_n.empty()) puts("NA");
	}	
	return 0;
}

C++: #include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int n, e, p, q;
    while(cin >> n, n != 0) {
        ll m[4001] = {};
        int a[1000] = {};
        REP(i, n){
            cin >> e >> p >> q;
            m[e] += p * q;
            a[i] = e;
        }
        bool f = true;
        REP(i, n){
            if(m[a[i]] >= 1000000){
                cout << a[i] << '\n';
                m[a[i]] = 0;
                f = false;
            }
        }
        if(f) cout << "NA\n";
    }
    return 0;
}

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

using namespace std;
#define mp make_pair
int main(){
  int n;
  string a;
  long long b,c;
  map<string,long> data;
  vector<string> 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<algorithm>
#include<iostream>
#include<vector>
#include<cstring>

typedef long long ll;

int n;
ll p[4000];
std::vector<int> ord;

int main()
{
	while( std::cin >> n, n )
	{
		memset( p, 0, sizeof( p ) );
		ord.clear();

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			if( p[a-1] == 0 )ord.push_back( a - 1 );	
			p[a-1] += b * c;
		}
		bool fl = false;
		for( int i = 0; i != ord.size(); ++i )
			if( p[ord[i]] >= 1000000 )
				std::cout << ord[i] + 1 << std::endl, fl = true;

		if( !fl )
			std::cout << "NA" << std::endl;
	}
	return 0;
}

C++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool same(vector<pair<int, ll> >& t, int num, ll p)
{
  bool ok = true;
  REP(i, t.size()){
    if (num == t[i].Fi){
      ok = false;
      t[i].Se += p;
      break;
    }
  }

  return ok;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  while (cin >> n, n){
    vector<pair<int, ll> > table;
    REP(i, n){
      bool ok = true;
      int num, price, cnt;
      cin >> num >> price >> cnt;
      if (same(table, num, price * cnt)){
        table.pb(mp(num, price * cnt));
      }
    }
    bool only = true;
    REP(i, table.size()){
      if (table[i].Se >= 1e6){
        print(table[i].Fi);
        only = false;
      }
      //cout << table[i].Fi << " " << table[i].Se << endl;
    }
    if (only) print("NA");
  }

  return (0);
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
 
signed main(){
int a;
while(scanf("%lld",&a),a){
    unordered_map<int,int>c;
    for(int d=0;d<a;d++){int e,f,k;scanf("%lld%lld%lld",&e,&f,&k);c[e]+=f*k;}
    bool s=true;
    for(auto g=c.begin();g!=c.end();g++){
	if(g->second>=1000000){s=false;printf("%lld\n",g->first);}
	}
	if(s)printf("NA\n");
    }
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
        bool flag=false;
        rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        if(b*c>=1000000){cout<<a<<endl;flag=true;}
        }
        if(!flag)cout<<"NA"<<endl;
    }
}

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

using namespace std;

int n;
long long id[4000];
long long value[4000];
long long number[4000];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> id[i] >> value[i] >> number[i];
    }
    vector<long long> v;
    for(int i=0;i<n;i++){
        if(value[i]*number[i] >= 1000000 ){
            v.push_back(id[i]);
        }
    }
    for (vector<long long>::iterator it=v.begin();it!=v.end();++it){
        cout << *it << endl;
    }
}