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 <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	ll u[4010];
	vector<int> v;
	bool k;
	while(1)
	{
		for(int i=0;i<4010;i++)
		{
			u[i]=0;
		}
		k=true;
		int n;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int x,y,z;
			cin >> x >> y >> z;
			u[x]+=(ll)y*(ll)z;
		}
		for(int i=0;i<4010;i++)
		{
			if(u[i]>=1000000)
			{
				k=false;
				cout << i << endl;
			}
		}
		if(k)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    map<int,long long int>m;
    vector<int>num;
    rep(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      if(m.find(a)==m.end()){
	num.pb(a);
	m[a]=b*c;
      }else{
	m[a]+=b*c;
      }
    }
    bool h=false;
    rep(i,num.size()){
      if(m[num[i]]>=1000000){
	cout<<num[i]<<endl;
	h=true;
      }
    }
    if(!h)cout<<"NA"<<endl;
  }
}

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

using namespace std;

int main() {

	int n;

	while(cin >> n) {
		if(!n) {
			break;
		}
		deque<int> x;
		for(int i=0; i<n; i++) {
			long long int num, v, q;
			cin >> num >> v >> q;
			if(v*q>=1000000) {
				int f=0;
				for(int j=0; j<x.size(); j++) {
					if(x[j]==num) {
						f=1;
						break;
					}
				}
				if(!f) {
					x.push_back(num);
				}
			}
		}

		if(x.empty()) {
			cout << "NA" << endl;
		}
		for(int i=0; i<x.size(); i++) {
			cout << x[i] << endl;
		}
		
	}

	return 0;

}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	int x[4001] = {0};
	int m[4001] = {0};
	
	while(1){
		int e, p, q;
		cin >> n;
		if(n == 0) break;
		x[4001] = {0};
		
		bool flag = true;
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			m[i] = e;
			x[e] += p * q;
			}
		
		for(int i = 1; i <= n; i++){
			if(x[m[i]] >= 1000000){
				cout << m[i] << end;
				x[m[i]] = 0;
				flag = false;
			}
		}
		if(flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
int main() {
	std::vector<int> v;
	while (1) {
		int count=0;
		int n;
		std::cin >> n;
		if (n == 0) {
			break;
		}
		std::vector<std::vector<int>> a(n, std::vector<int>(3));
		
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j) {
				std::cin >> a[i][j];
			}
		}
		std::vector<int>num(n);
		for (int i = 0; i < n; ++i) {
			for (int j = 1; j < n; ++j) {
				if (a[i][0] == a[j][0]) {
					num[i] += a[i][1] * a[i][2] + a[j][1] * a[j][2];
					++count;
					break;
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			if (count == 0) {
				v.push_back(0);
			}
			if (num[i] >= 1000000) {
				if (count >= 2) {
					sort(num.begin(), num.end());
				}
				v.push_back(num[i]);
			}
		}
	}
	for (int i = 0; i < v.size(); ++i) {
		if (v[i] == 0) {
			std::cout << "NA" << std::endl;
		}
		else {
			std::cout << v[i] << std::endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum,unitcost,amount,flag;
	long long int total[MAX];
	while( 1 ){

		for(i=0;i<MAX;i++){
			total[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %d %d",&snum,&unitcost,&amount);
			total[snum]+=unitcost*amount;
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( total[i] >= 1000000 ){
				flag=1;
				printf("%d\n",i);
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        bool flag=0;
        double result[4001]={};
        for(int i=0,con;i<n;i++){
            double sale,num;
            cin>>con>>sale>>num;
            sale/=1000;num/=1000;
            result[con]+=sale*num;
            if(result[con]>=1){
                cout<<con<<endl;
                result[con]=-50;
                flag=1;
            }
        }
        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 count[4000];

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

C++: #include <iostream>
using namespace std;
int main(){
  int i, n;
  long long int p, q;
  while(cin >> n, n){
    bool NAflg = false;
    while(n--){
      cin >> i >> p >> q;
      if((p * q) >= 1000000){
	cout << i << endl;
	NAflg = true;
      }
    }
    if(!NAflg)
      cout << "NA" << endl;
  }
  return 0;
}

C++: // a.c.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	int ban, tan, suu;
	int bango[4001];
	int flg,i;
	while (1){
		for (i = 1; i <= 4000; i++){
			bango[i] = 0;
		}
		scanf_s("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf_s("%d %d %d", &ban, &tan, &suu);
			bango[ban] += tan*suu;
		}
		flg = 0;
		for (i = 1; i <= 4000; i++){
			if (bango[i]>=1000000){
				printf("%d\n", i);
				flg = 1;
			}
		}
		if (!flg){
			printf("NA\n");
		}
	}
	return 0;
}