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++: #include <cstring>
#include <iostream>
using namespace std;
int main() {
  bool f;
  int n, a, b, c, d[4001], i;
  while (cin >> n && n > 0) {
    memset(d, 0, sizeof(d));
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      d[a] += b * c;
    }
    for (i = 1, f = 0; i <= 4000; i++) {
      if (d[i] >= 1000000) {
        cout << i << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	ll n;
	map<int, ll> field;
	vi jun;

	while(cin >> n, n) {
		field.clear();
		jun.clear();

		int ban;
		ll tan, suu;
		bool flag = true;

		REP(i, n) {
			cin >> ban >> tan >> suu;

			if(!field[ban]) {
				jun.push_back(ban);
			}

			if(field[ban] < 1000000) {
				field[ban] += tan*suu;
			}
		}

		if(jun.size() == 0) {
			cout << "NA" << endl;
		} else {
			REP(i, jun.size()) {
				if(field[jun[i]] >= 1000000) {
					cout << jun[i] << endl;
					flag = false;
				}
			}
			if(flag) {
				cout << "NA" << endl;
			}
		}
	}

	return 0;
}

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

template<typename itr, typename func>
func for_each_withindex(itr fi, itr l, func f){
	unsigned i{};
	for(; fi!=l; ++fi,++i){
		f(*fi,i);
	}
	return f;
}

int main(int argc, char const* argv[])
{
	unsigned n{};
	while (std::cin >> n,n != 0) {
		double e{}, p{}, q{};
		bool isna{true};
		std::array<double,4001> es{};
		for (unsigned i = 0; i < n; i++) {
			std::cin >> e >> p >> q;
				es.at(e) += p * q;
		}
		for_each_withindex(es.begin(), es.end(), [&isna](auto sell,auto e){ 
				if (sell>=1e6) {
				std::cout << e << std::endl;
				isna = false;
				}});
		if (isna) {
			std::cout << "NA" << std::endl;
		}

	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std; 
#define pb push_back
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef vector<int> Vi;

int main()
{
  int n;
  while( cin >> n, n ) {
    int a, b, c;
    map<int, int> m;
    Vi v;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      if( m.find( a ) == m.end() ) {
	v.pb( a );
      }
      m[a] += b * c;
    }
    
    Rep(i, v.size()) {
      if( m[v[i]] >= 1000000 ) {
	cout << v[i] << endl;
	flag = true;
      }
    }

    if( !flag ) cout << "NA" << endl;
  }
}

C++: #include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        itn count = 0;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        for (int i = 0; i < dataset_num; i++) {
            int officer_num;
            int price;
            int figure;
            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            if (price * figure >= 1000000) {
                std::cout << officer_num;
                count +=1;
            }
        }
        if (count == 0) {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}

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

int main()
{
	int num, man, yen, ko;
	int c;
	int p[10] = {};
	
	while (1){
		c = 0;

		cin >> num;
		if (!num)	break;

		for (int i = 0; i < num; i++){
			int j = i;
			cin >> man >> yen >> ko;

			if (yen * ko >= 1000000){
				for (; j > 0; j--){
					if (p[j - 1] == man)
						man = 0;
				}
				if (man != 0){
					p[i] = man;
					cout << man << endl;
					c++;
				}
			}
		}

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

	return 0;
}

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

using namespace std;

const int Target = 1000000;

struct Shain {
	int no;
	long long sum;
};

bool operator==( const Shain &a, const Shain &b )
{
	return a.no == b.no;
}

int main( void )
{
	vector<Shain> shain;
	int n;
	while(cin >> n, n) {
		shain.clear();
		for(int i=0; i < n; ++i) {
			int no, kin, num;
			cin >> no >> kin >> num;
			bool hit = false;
			vector<Shain>::iterator it = shain.begin();
			while(it != shain.end()) {
				if(it->no == no) {
					if(it->sum < Target) {
						it->sum += (kin * num);
						Shain tmp2 = *it;
						if(it->sum >= Target) {
							shain.erase(it);
							shain.push_back(tmp2);
						}
					}
					hit = true;
					break;
				}
				++it;
			}
			if(!hit) {
				Shain tmp;
				tmp.no = no;
				tmp.sum = kin * num;
				shain.push_back(tmp);
			}
		}
		bool hit = false;
		vector<Shain>::iterator it = shain.begin();
		while(it != shain.end()) {
			if(it->sum >= Target) {
				cout << it->no << endl;
				hit = true;
			}
			++it;
		}
		if(!hit)
			cout << "NA" << endl;
	}
	return 0;
}

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

typedef pair<int,int> P;

int main(void)
{
	int N;
	while(cin >> N, N){
		P d[4001] = {};
		bool f = false;

		int a,b,c;
		for(int i = 0; i < N; i++){
			cin >> a >> b >> c;

			int j;
			for(j = 0; d[j].first != 0; j++){
				if(d[j].first == a){
					d[j].second += b*c;
					if(d[j].second >= 1000000)
						f = true;
				}
			}
			if(d[j].first == 0){
				d[j].first = a;
				d[j].second += b*c;
			}
		}

		if(!f)
			printf("NA\n");

		else
			for(int i = 0; d[i].first != 0; i++)
				if(d[i].second >= 1000000)
					printf("%d\n", d[i].first);
	}
		





	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,h,h2,ib;
  while(cin>>n){
    if(n==0) break;
    h = 0;
    ib = 0;
    int b[n],p[n],q[n],ansb[n];
    long int ans[n];
    for(int i=0;i<n;i++){
      cin >> b[i] >> p[i] >> q[i];
      h2 = 0;
      for(int j=0;j<i;j++){
	if(ansb[j]==b[i]){
	  ans[j] += p[i] * q[i]; 
	  h2 = 1;
	  break;
	}
      }
      if(h2==0){
	ans[ib] = p[i] * q[i];
	ansb[ib] = b[i];
	ib++;
      }
    } 
    for(int i=0;i<ib;i++){
      if(ans[i]>=1000000){
	cout << ansb[i] << endl;
	if(h==0) h = 1;
      }
    }
    if(h==0) cout << "NA" << endl;
  }
  return 0;
}