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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<double,double> P;

int main(){
	int n,m,o;
	int num;
	while(~scanf("%d",&num)){
		if(num==0) break;
		bool isok=false;
		map<int,int> val;
		for(int i=0;i<num;i++){
			scanf("%d %d %d",&n,&m,&o);
			val[n] += m*o;
		}

		for(map<int,int>::iterator it = val.begin(); it != val.end(); it++){
			if(it->second >= 1000000){
				cout << it->first << endl;
				isok=true;
			}
		}
		if(!isok) cout <<  "NA" << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	ll t,s;
	int n;
	for(;cin>>n,n;){
		bool f=false;
		rep(i,n){
			int p;
			cin>>p>>t>>s;
			if(t*s>=1000000)cout<<p<<endl,f=true;
		}
		if(!f)cout<<"NA\n";
	}
	return 0;
}

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

int main()
{
	int n = 0;				//  社員の人数;n==0で終了
	bool flag = true;		//  flagはidの重複を確認する
	int id_temp,price_temp,amount_temp;
	vector<int> id;			//  社員のid
	vector<int> price;		//  the corresponding unit price
	vector<int> amount;		//  the amount of sales
	vector<int> result;		//  条件を満たすid郡

	while(true) {
		cin >> n;
		if(n<0) {
			cout << "Error; n must be larger than 0";
			return -1;
		}
		else if(n==0)
			break;
		else {
			result.clear();
			id.clear();
			price.clear();
			amount.clear();
			for(int i=0;i<n;i++) {
				cin >> id_temp >> price_temp >> amount_temp;
				flag = true;
				for(int j=0;j<id.size();j++)
					if(id_temp==id[j]) {
						price[j] += price_temp;
						amount[j] += amount_temp;
						flag = false;
						break;
					}
				if(flag) {
					id.push_back(id_temp);
					price.push_back(price_temp);
					amount.push_back(amount_temp);
				}
			}

			for(int i=0;i<n;i++) 
				if(price[i]*amount[i]>=1000000)
					result.push_back(id[i]);
			
			if(result.size()==0)
				cout << "NA" << endl;
			else
				for(int i=0;i<result.size();i++)
					cout << result[i] << '\n';
		}
	}

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<ll,ll> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c;
  while(cin >> n && n){
    vector<pair<ll,ll>> v;
    vary(ll,v2,4005,0);
    int cnt=0;
    rep(i,n){
      cin >> a >> b >> c;
      if(v2[a] == 0){
        ++cnt;
        v.push_back(make_pair(cnt,a));
      }
      if(v2[a] < 1000000)
        v2[a] += b * c;
    }
    sort(all(v),[](const pii &p,const pii &p2){return p.fi < p2.fi;});
    bool f = false;
//     debug(v.size());
    REP(i,0,v.size()){
      if(v2[v[i].se] < 1000000){
      }
      else{
        cout << v[i].se<<endl;
//         debug(v2[v[i].se]);
        f = true;
      }
    }
    if(!f) cout << "NA"<<endl;
  }
  return 0;
}

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

struct data{
  int a,total;
};

int main(){
  int i,j,n,c,a,yen,ko,f,f2,con;
  data d[4000];
  while(1){
    cin >> n;
    if(n == 0) break;
    c = 0;
    con = 0;
    for(i=0;i<n;i++){
      cin >> a;
      f = 1;
      for(j=0;j<i;j++){
	if(a == d[j].a){
	  cin >> yen >> ko;
	  d[j].total += yen * ko;
	  f = 0;
	  con++;
	  break;
	}
      }
      if(f){
	cin >> yen >> ko;
	d[i-con].a = a;
	d[i-con].total = yen * ko;
	c++;
      }
    }

    f2 = 1;
    for(i=0;i<c;i++){
      if(d[i].total >= 1000000){
	cout << d[i].a << endl;
	f2 = 0;
      }
    }
    if(f2) cout << "NA" << endl;

  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map<int, long long> com;
    vector<int> g;
    com.clear();
    g.clear();
    while(n--){
      int a;
      long long b,c;
      cin >>a>>b>>c;
      if(!com[a]){g.push_back(a);}
      com[a]+=b*c;
    }
    bool f = false;
    for(int i=0; i<g.size(); i++){
      if(com[g[i]]>=1000000){cout <<g[i]<<endl;f = true;}
    }
    if(!f){cout <<"NA"<<endl;}
  }
  return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  long long ans[4000]={0};
  int n,number,money,many,over_many=0,over[4000]={0};
  while(1){
    cin >> n;
    if(n==0)break;
    over_many=0;
    memset(over,0,sizeof(over));
    memset(ans,0,sizeof(ans));
    for(int i=0;i<n;i++){
      cin >> number >> money >> many;
      ans[number]+=money*many;

      if(ans[number]>=1000000){
	if(over[number]==0){
	  over_many++;
	  over[number]=1;
	}
      }

    }
    if(over_many==0){
      cout << "NA" << endl;
    }
    else{
      for(int k=0,j=0;j<over_many;k++){
	if(over[k]==1){
	  cout << k << endl;
	  j++;
	}
      }
    }

  }
}

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

long long owData[4001];
std::vector<int> used;

int main(){
  long long x,input[3];
	bool Person;
	while( std::cin>>x , x ){
		Person=false;
		used.clear();
		memset(owData,0,sizeof(owData));
		while( x-- ){
			std::cin>>input[0]>>input[1]>>input[2];
			if( owData[input[0]] == 0 )used.push_back(input[0]);
			owData[input[0]]+=input[1]*input[2];
		}
		for(auto it = used.begin(); it != used.end(); ++it ){
			if( owData[*it] >= 1000000 )
				std::cout<< *it <<std::endl, Person=true ;
		}
		if(!Person)std::cout<<"NA"<<std::endl;
	}
	return 0;
}