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 <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)
	{
		if(!n) break;

		bool f = true;
		rep(i, n)
		{
			ll a, s, num;
			scanf("%lld %lld %lld", &num, &a, &s);

			if(1000000 <= a * s)
			{
				f = false;
				printf("%d\n", num);
			}
		}
		if(f) cout << "NA" << endl;
	}
}

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf_s("%d", &data);
		if (data == 0)break;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			int num, sell, cnt;
			scanf_s("%d %d %d", num, sell, cnt);
			if (sell*cnt >= target)
			{
				printf("%d\n", num);
				hero = true;
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
    int n;
    int i=1,j,k;
    int x,y,z,flag=0;
    int a[4001]={0};
    int b[4001]={0};
    int c[4001]={0};
    int o[4001]={0};
    for(;;){
        i=1,flag=0;
        k=0;
        for(k=0;k<=4000;k++){
            a[k]=0;
            b[k]=0;
            c[k]=0;
            o[k]=0;
            }
    scanf("%d",&n);
    if(n==0)break;
    for(j=1;j<=n;j++){
        flag=0;
        scanf("%d%d%d",&x,&y,&z);
        if(a[x]!=0){
            a[x]=a[x]+y*z;

            }
        else {
            c[i]=x;
            a[x]=y*z;
            i++;
        }
        if(o[x]==0&&a[x]>=1000000){
            b[j]=1;
            o[x]=1;
            }
        }
	for(i=1;i<=n;i++){
	    if(b[i]==1){
        printf("%d\n",c[i]);
        flag=1;
        }

	}
	if(flag==0){
            printf("NA\n");
            }
    }
return 0;
}

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

int main(){

  int num, v, n, m, len, cnt;
  vector<long long> vc[2];

  while(cin >> n){
    if(n == 0) break;
    vc[0].clear();
    vc[1].clear();
    len = 0;

    for(int i=0; i<n; i++){
      cin >> num >> v >> m;
      for(int j=0; j<=len; j++){
        if(j == len){
          vc[0].push_back(num);
          vc[1].push_back(v * m);
          len++;
          break;
        }
        if(vc[0][j] == num){
          if(vc[1][j] < 1000000){
            vc[1][j] += (long long)v * m;
          }
          break;
        }
      }
    }
    
    cnt = 0;
    for(int i=0; i<len; i++){
      if(vc[1][i] >= 1000000){
        cout << vc[0][i] << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;

  }

  return 0;

}

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

int main() {
	int n;
	while(std::cin >> n){
		if(!n){
			return 0;
		}
		std::map<int, long long> sales;
		while(n--){
			int id;
			long long unit, num;
			std::cin >> id >> unit >> num;
			sales[id] += unit * num;
		}
		map<int, long long>::iterator it;
		bool found = false;
		for(it = sales.begin(); it != sales.end(); it++){
			if(it->second >= 1000000){
				found = true;
				std::cout << it->first << std::endl;
			}
		}
		if(!found){
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int n; cin >> n;
    do {
        int e[n], p[n], q[n];
        int tmp[4001] = {};
        int flag = 0;
        rep(i, n) cin >> e[i] >> p[i] >> q[i];
        for (int i = 0; i < n; i++) {
            tmp[e[i]] += p[i] * q[i];
        }
        for (int i = 0; i < 4001; i++) {
            if (tmp[i] >= 1000000) {
                cout << i << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
        cin >> n;
    } while(n != 0);

    return 0;
}

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

int main()
{
	array<int, 4000> ar = {};
	vector<int> ans;
	int n,e,p,q;
	
	while (true) {
		cin >> n;
		ar.fill(0);
		if (!n) {
			break;
		}

		bool isNA = true;
		for (int i = 0; i < n; ++i) {
			cin >> e >> p >> q;
			ar[e] += p*q;
		}
		for (int i = 0; i < 4000;++i) {
			if (ar[i] >= 1000000) {
				ans.push_back(i);
				isNA = false;
			}
		}
		if (isNA) {
			ans.push_back(-1);
		}

	}

	for (auto it : ans) {
		if (it != -1) {
			cout << it;
		}
		else {
			cout << "NA";
		}

		if (it != *ans.end()) {
			cout << endl;
		}
	}
	return 0;
}

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

int n;
int a[3];
std::vector<std::pair<int, int>> vec;
bool x[4001];

int main() {
	while (1) {
		std::cin >> n;
		if (n == 0)
			break;
		int count = 0;
		vec.clear();
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j)
				std::cin >> a[j];
			if (x[a[0]]) {
				for (int k = 0; k < vec.size(); ++k) {
					if (vec[k].first == a[0])
						vec[k].second += a[1] * a[2];
				}
			}
			else {
				vec.push_back(std::make_pair(a[0], a[1] * a[2]));
				x[a[0]] = true;
			}
		}
		for (auto it = vec.begin(); it != vec.end(); ++it) {
			if ((*it).second >= 1000000) {
				std::cout << (*it).first << std::endl;
				++count;
			}
		}
		if (count==0)
			std::cout << "NA" << std::endl;
	}
	return 0;
}

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

int main(){

	while (true) {
		int cnt = 0;
		cin >> cnt;
		if (cnt == 0) break;

		typedef std::vector<std::pair<int, int> > dataType;
		dataType data;
		for (int i = 0; i < cnt; ++i) {
			int id, price, amount;
			cin >> id >> price >> amount;
			int g = price * amount;

			bool found = false;
			for (int i = 0; i < data.size(); ++i) {
				if (data[i].first == id) {
					data[i].second += g;
					found = true;
				}
			}
			if (!found) data.push_back(std::pair<int, int>(id, g));
		}
		bool bHitted = false;
		for (dataType::iterator it = data.begin(); it != data.end(); ++it) {
			if (it->second >= 1000000) {
				cout << it->first << "\n";
				bHitted = true;
			}
		}
		if (!bHitted) {
			cout << "NA\n";
		}
	}
	return 0;
}