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 <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std ;

int member[4010][3] ;
int price[4010] ;
int idx[4010] ;

struct ANS{
	bool ans ;
	int num ;
	int s ;
}A[4010];

bool cmp ( int a , int b ) ;

int main ( )
{
	int n ; 
	bool na ;
	while ( scanf ( "%d" , &n ) == 1 && n ){
		na = false ;
		memset ( price , 0 , sizeof ( price ) ) ;
		for ( int i = 0 ; i < 4010 ; i++ ){
			A[i] . ans = false ;
			A[i] . num = 9999 ;
			idx[i] = i ;
		}
		for ( int i = 0 ; i < n ; i++ ){
			scanf ( "%d %d %d" , &member[i][0] , &member[i][1] , &member[i][2] ) ;
			int tmp = member[i][1] * member[i][2] ;
			price[member[i][0]] += tmp ;
			if ( price[member[i][0]] >= 1000000 ){
				A[member[i][0]] . ans = true ;
				na = true ;
			}
			A[member[i][0]] . num = ( A[member[i][0]].num == 9999 ) ? i : A[member[i][0]] . num ;
			A[member[i][0]] . s = member[i][0] ;
		}
		if ( ! na ){
			printf ( "NA\n" ) ;
		}
		else{
			sort ( idx , idx + 4010 , cmp ) ;
			for ( int i = 0 ; i < n - 1 ; i++ ){
				if ( A[idx[i]] . ans == true ){
					printf ( "%d\n" , A[idx[i]] . s ) ;
				}
			}
		}
	}
	return 0 ;
} 

bool cmp ( int a , int b )
{
	return A[a] . num < A[b] . num ;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
#define MAX_N 1000000
long long x[MAX_N], a, b, c, n;
int main() {
	while (1) {
		memset(x, 0, sizeof(x));
		cin >> n; if (!n) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			x[a] += b*c;
			if (x[a] >= 1000000) { cout << a << endl; }
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std ;
#define P pair<int,long long int>

main(){
	int n,num,p,m,j ;
	while( cin >> n , n ){
		vector<P> V ;
		for( int i=0 ; i<n ; i++ ){
			cin >> num >> p >> m ;
			bool t = true ;
			for( j=0 ; j<V.size() ; j++ ){
				if( V[j].first == num ){
					t = false ;
					break ;
				}
			}
			if( t ) V.push_back( P(num,p*m) ) ;
			else V[j].second += p*m ;
		}
		
		bool t2 = false ;
		for( int i=0 ; i<V.size() ; i++ ){
			if( V[i].second >= 1000000 ){
				cout << V[i].first << endl ;
				t2 = true ;
			}
		}
		if( !t2 ) cout << "NA" << endl ;
	}
}

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];
	bool k;
	vector<int> v;
	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;
			ll y,z;
			cin >> x >> y >> z;
			if(!(u[x]))
			{
				v.pb(x);
			}
			u[x]+=y*z;
		}
		for(int i=0;i<v.size();i++)
		{
			if(u[v[i]]>=1000000)
			{
				k=false;
				cout << v[i] << endl;
			}
		}
		if(k)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){

    int n;
    while(cin >> n, n){
        map<int, long long int> m;
        for(int i=0; i < n; i++){
            int num, cost, goodsNum;
            cin >> num >> cost >> goodsNum;
            m[num] += cost*goodsNum;
        }

        bool exist = false;
        map<int, long long int>::iterator it = m.begin();
        while(it != m.end()){
            if(1000000 <= (*it).second){
                cout << (*it).first << endl;
                exist = true;
            }
            ++it;
        }

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

C++: #include<cstdio>
#include<cstring>

#define BUF 4000

typedef struct syaing
{
	int bango[BUF];
	int ne[BUF];
	int kazu[BUF];
} deta;

int main()
{
	deta f;
	int a,i,check[BUF],lek;
	while(1)
	{
		memset(check,0,sizeof(int)*BUF);
		memset(f.bango,0,sizeof(int)*BUF);
		memset(f.kazu,0,sizeof(int)*BUF);
		memset(f.ne,0,sizeof(int)*BUF);
		lek=0;
		scanf("%d",&a);
		if(a==0)
			break;
		for(i=0;i<a;i++)
		{
			scanf("%d%d%d",&f.bango[i],&f.kazu[i],&f.ne[i]);
			if(f.kazu[i]*f.ne[i]>=1000000)
				check[i]=f.bango[i];
		}
		for(i=0;i<a;i++)
		{
			if(check[i]!=0)
			{
				lek++;
				printf("%d\n",check[i]);
			}
		}
		if(lek==0)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;

    Mem() {}
    Mem(int _id, ll _c) { id = _id; _c = c; }
};

Mem array[40010];

int main(void) {
    while(cin >> n && n) {
        for(int i = 0; i < n; i++) {
            scanf("%d %d %d", &id, &p, &q);
            array[i].c = p * q;
            array[i].id = id;
        }
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(array[i].id == array[j].id && array[j].id) {
                    array[i].c += array[j].c;
                    array[j].id = 0;
                }
            }
        }
        bool hap = false;
        for(int i = 0; i < n; i++) {
            if(array[i].id && array[i].c >= MAX) {
                cout << array[i].id << endl;
                hap = true;
            }
        }
        if(!hap) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <bitset>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);

    int n;
    while (cin >> n && n) {
        map<int,int> sum;
        for (int i=0; i<n; ++i) {
            int no, price, quantity;
            cin >> no >> price >> quantity;
            sum[no] += price * quantity;
        }

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