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++: 4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100

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

int A[1000000];

signed main()
{
    int N,B,C;
    while(cin >> N,N){
        int cnt[4001]={};
        bool NAflag=true, used[4001]={};
        for(int i=0;i<N;i++){
            cin>>A[i]>>B>>C;
            cnt[A[i]] += B*C;

        }
        for(int i=0;i<N;i++){
            if(cnt[A[i]]>=1000000 && used[A[i]]==false){
                printf("%d\n",A[i]); used[A[i]]=true; NAflag=false;
            }
        }
    if(NAflag==true) puts("NA");
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

using namespace std;
#define EPS 1e-9
#define MAX 505
#define pb push_back
#define mp make_pair
#define ins insert
#define fi first
#define se second
#define pi acos(-1.0)
#define mod 100000007
#define inf 2147483647
#define ll long long int
#define sss stringstream
#define oss ostringstream
#define iss istringstream
#define llu long long unsigned

#define _sq(a) (a)*(a)
#define sz(a) ((int)a.size())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define _max3(a,b,c) max(a, max(b,c))
#define _min3(a,b,c) min(a, min(b,c))
#define FOR(i, n) for(i=0; i<(int)n; i++)
#define FOR1(i, n) for(i=1; i<=(int)n; i++)
#define mem(a) memset(a, 0, sizeof(a))
#define _set(a) memset(a,-1,sizeof(a))
#define FORI(i, a, b) for(i=a; i>=(int)b; i--)
#define FORab(i, a, b) for(i=a; i<=(int)b; i++)
#define popcount(n) __builtin_popcount(n)
#define popcountl(n) __builtin_popcountll(n)
#define sort_rev(a) sort(a.rbegin(), a.rend())
#define sort_all(a) sort(a.begin(), a.end())
#define dis_twopoints(x1,y1,x2,y2) sqrt(_sq(x1-x2) + _sq(y1-y2))
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)

//If Long Long (mask & (1LL << k))
#define check(mask, k) (mask & (1 << k))
#define set1(mask, k) (mask | (1 << k))
#define set0(mask ,k) (mask & (~(1<<k)))

#define SD(a) scanf("%d",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)
#define SLLD(a) scanf("%lld", &a)
#define Si64(a) scanf("%I64d", &a)

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
struct wor
{
    int mon;
    int fla;
};
int main()
{
    wor id[100000];
    int ta,tan,i,s,p,doc[100],j;
    while(cin>>ta&&ta!=0)
    {
        int f=0;
        for(j=0; j<ta; j++)
        {
            cin>>i>>s>>p;
            doc[j]=i;
            if(id[i].fla==2)
            {
                id[i].mon=id[i].mon+(s*p);

            }
            else
            {
                id[i].mon=s*p;
                id[i].fla=2;
            }
        }
        for(j=0; j<ta; j++)
        {
            if(id[doc[j]].fla==3)
            {
                continue;
            }
            else
            {
                if(id[doc[j]].mon>=1000000)
                {
                    cout<<doc[j]<<endl;
                    id[doc[j]].fla=3;
                    f=1;
                }
            }
        }
        for(j=0;j<ta;j++)
        {
           id[doc[j]].fla=0;
        }
        if(f==0)
        {
            cout<<"NA"<<endl;
        }
    }

    return 0;
}

C++: using namespace std;
typedef long long ll;

ll em[4000];
int flag[4000];

int main(){
	int n;
	while(true){
		int id,p,q;
		cin >> n;
		if(!n) return 0;
		for(int i = 0; i < n; i++){
			cin>>id>>p>>q;
			em[id-1] += (ll)p * q;
			flag[i] = id;
		}
		int f = 1;
		for(int i = 0; i < n; i++){
			if(em[flag[i]-1] >= 1000000){
				cout << flag[i] << endl;
				f = 0;
			}
			em[flag[i]-1] = 0;
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		long table[4096];
		bool flag = false;
		memset(table, 0, sizeof(table));
		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			table[ID] += price * sale;
		}

		for(int i = 0; i < 4096; i++) {
			if(table[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}

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

	return 0;
}

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

// 定数
const int GOAL_PRICE = 1000000;

int main(){
    // 変数
    int n;                              // 項目数
    int number;                         // 社員番号
    long long int price, quantity;      // 単価・数量
    std::map<int, long long int> result;     // 結果
    std::vector<int> contents;               // 入力内容

    while (true){
        std::cin >> n;

        if (n == 0) break;

        bool isExcess = false;
        result.clear();
        contents.clear();

        number = 0;
        price = 0;
        quantity = 0;

        for (int i = 0; i < n; i++){
            std::cin >> number >> price >> quantity;
            // 計算結果の追加
            if (!result[number]){
                contents.push_back(number);
                result[number] = 0;
            }
            result[number] += price * quantity;
        }

        for (int number : contents){
            if (result[number] >= GOAL_PRICE){
                std::cout << number << std::endl;
                isExcess = true;
            }
        }

        if (!isExcess){
            std::cout << "NA" << std::endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long int sales[4010];
#define foreach(r,p,it) for(r::iterator it=p.begin();it!=p.end();++it)

int main()
{
    int n;
    while(cin>>n)
    {
        vector<int> shains;
        if(n==0)break;
    
        memset(sales,0,sizeof(sales));
        int num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
            int f=0;
            foreach(vector<int>,shains,it)
            {
                if(*it == num){f=1;break;}
            }
            if(f==0) shains.push_back(num);
        }
        int na = 0;
        foreach(vector<int>,shains,it)
        {
            if(sales[*it] >= 1000000){cout<<*it<<endl;na=1;}
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}