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<iostream>
using namespace std;

int main(){
	int n;
	long long p[4000];
	int count;
	
	while(cin>>n,n){
		for(int i=0;i<4000;++i)p[i]=0;
		
		for(int i=0;i<n;++i){
			long long wn,va,cn;
			cin>>wn>>va>>cn;
			p[wn-1] += va*cn;
		}
		count = 0;
		for(int i=0;i<4000;++i){
			if(p[i] >= 1000000){cout<<i+1<<endl;count++;}
		}
		if(!count)cout<<"NA"<<endl;
		
		
		
		
		
	}
	
	
	
}

C++: #include<stdio.h>
#include<stdlib.h>

typedef struct{
	int num;
	long long sale;
	int cnum;
}data;

int min(int a,int b){
	if(a<=b)return a;
	else return b;
}

int comp(const void *a,const void *b){
	data* p=(data*)a;
	data* q=(data*)b;
	return p->num-q->num;
}

int main(){
	int n,i;
	data d[4000];
	int cost,nu,k;
	int c;
	while(1){
		scanf("%d",&n);
		if(n==0)return 0;
		c=0;
		for(i=0;i<4000;i++){
			d[i].num=4000;
			d[i].sale=0;
			d[i].cnum=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&nu,&cost,&k);
			d[nu-1].cnum=nu-1;
			d[nu-1].num=min(d[nu-1].num,c++);
			d[nu-1].sale+=cost*k;
		}
		qsort(d,4000,sizeof(data),comp);
		bool f=false;
		for(i=0;i<c;i++){
			if(d[i].sale>=1000000){
				printf("%d\n",d[i].cnum+1);
				f=true;
			}
			if(d[i].num==4000)break;
		}
		if(!f)printf("NA\n");
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#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 pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int n;
  while( cin >> n, n ) {
    ll a, b, c;
    map<ll, ll> m;
    vector<ll> v;
    bool flag = false;
    Rep(i, n) {
      cin >> a >> b >> c;
      if( m.find( a ) == m.end() ) {
	v.pb( a );
	m[a] = 0;
      }
      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>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n, id, price, num;
	map<int, ll> tbl;
	vector<int> vi;
	
	while (cin >> n, n)
	{
		tbl.clear();
		vi.clear();
		rep(i, n)
		{
			cin >> id >> price >> num;
			if (tbl.find(id) == tbl.end()) vi.push_back(id);
			tbl[id] += price * num;
		}
		bool flag = false;
		rep(i, vi.size())
		{
			if (tbl[vi[i]] >= 1000000)
			{
				cout << vi[i] << endl;
				flag = true;
			}
		}
		if (!flag) cout << "NA" << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

C++: #include <bits/stdc++.h>
#define MAX_MEMBER 4000
#define HIGH 1000000
using namespace std;

int main(void) {
    int n;
    while(cin >> n, n != 0) {
        map<int, int> data;
        bool update = false;
        for(int r = 0; r < n; r++) {
            int no, tanka, quantity;
            cin >> no >> tanka >> quantity;
            if(data[no]) {
                data[no] += tanka*quantity;
            } else data[no] = tanka*quantity;
        }
        for(auto it = data.begin(); it != data.end(); it++) {
            if(it->second >= HIGH) {
                cout << it->first << endl;
                update = true;
            }
        }
        if(!update) cout << "NA" << endl;
    }
    
    return(0);
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){

  int n, id, val, num, cnt;
  int member[4000];
  int index[4000];

  while(cin >> n){

    if(!n) break;

    cnt = 0;
    memset(member, -1, sizeof(member));
    memset(index, -1, sizeof(index));

    for(int i = 0; i < n; ++i){

      cin >> id >> val >> num;

      if(member[id - 1] == -1){
        index[cnt] = id - 1; ++cnt;
        member[id - 1] += 1 + val * num;
      } else {
        member[id - 1] += val * num;
      }

    }

    bool flag = false;

    for(int i = 0; i < cnt; ++i){
      if(member[index[i]] >= 1000000){
        cout << index[i] + 1 << endl;
        flag = true;
      }
    }

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

  }

}

C++: #include <stdio.h>

int main(void)
{

	int n, a, b, No,data[4000],d[4000],c;

	while(scanf("%d", &n), n != 0){
		bool check = false;
		c = 0;
		for(int i = 0; i < 4000; i++)
			data[i] = 0;
		for(int i = 0; i < n; i++){
			scanf("%d %d %d", &No, &a, &b);
			data[No-1] += a*b;
			if(data[No-1] >= 1000000){
				d[c] = No;
				c++;
				data[No-1] = -1000000000;
				check = true;
			}
		}
		if(!check)
			printf("NA\n");
		else
			for(int i = 0; i < c; i++)
				printf("%d\n", d[i]);

	}


	return 0;
}

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

int main(){
    int n, a, b, c, d = 0, com[4001] = {};
    cin >> n;
    if(n != 0){
    for(int i = 0;i < n;i++){
       cin >> a >> b >> c;
       com[a] += b * c;
      }
    for(int j = 0;j < 4001;j++){
       if(com[a] >= 1000000){
       cout << com[a] << endl;
       d++;
       }  
      }    
    if(d == 0) cout << "NA" << endl;
     }
    return 0;
   }