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>
#include<vector>
#include<map>
#define SALES_GOAL 1000000
using namespace std;
int main(void){
  int i,n;
  vector<int> data;
  vector<int>::iterator vc_it;
  while(cin>>n,n){
    int tof = 1;
    int num,price,qua;
    map<int,long long int> staff;
    map<int,long long int>::iterator itr;
    while(n-- > 0){
      cin >> num >> price >> qua;
      staff[num] = staff[num]? staff[num]+(long long int)price*qua : (long long int)price*qua;

    }
    for(itr = staff.begin(); itr != staff.end(); itr++){

      if(itr->second >= SALES_GOAL){
        data.push_back(itr->first);
        tof = 0;
      }
    }
    if(tof)data.push_back(0);
  }
  for(vc_it = data.begin(); vc_it != data.end(); vc_it++){
    if(*vc_it)cout << *vc_it << endl;
    else cout << "NA" << endl;
  }

}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  long long int nin;
  while(1){ 
    scanf("%d",&nin);
    if(!nin)break;

    long long int human[4002]={0};
    long long int no[4002],tanka,kazu,outflag=0;;
    
    for(int i=0;i<nin;i++){
      scanf("%d %d %d",&no[i],&tanka,&kazu);
      human[no[i]]+=tanka*kazu;
    }
    
    for(int i=0;i<nin;i++){
      if(human[no[i]]>=1000000 && human[no[i]]!=-1){
	printf("%d\n",no[i]);
	human[no[i]]=-1;
	outflag=1;
      }
    }
    
    if(outflag==0)printf("NA\n");
    
  }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        map<int, long long> m;
        int i;
        long long p, q;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q;
            m[i] += p * q;
        }
        bool na = true;
        for (auto it=m.begin(); it!=m.end(); ++it) {
            if (1000000LL <= it->second) {
                cout << it->first << endl;
                na = false;
            }
        }
        if (na) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

long long int nums[10000];

bool flags[10000];
int index[10000];

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < 10000; i++){
			nums[i] = 0;
			flags[i] = true;
		}
		
		for(int i = 0; i < n; i++){
			long long int e, p, q;
			cin >> e >> p >> q;
			nums[e] += p * q;
			index[i] = e;
		}
		
		bool check = false;
		
		for(int i = 0; i < n; i++){
			if(nums[index[i]] >= 1000000 && flags[index[i]]){
				cout << index[i] << endl;
				check = true;
				flags[index[i]] = false;
			}
		}
		
		if(!check){
			cout << "NA" << endl;
		}
	}
	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[9999];
    int ta,tan,i,s,p,doc[50],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++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
#define MAXN 4096
typedef long long ll;
bool done[MAXN];
vector<int> syain;
int main(void) {
    int n;
    while (1) {
        cin >> n;
        int flag = 0;
        if (n == 0) break;
        map<int, ll> m;
        m.clear();
        syain.clear();
        for (int i = 0; i < MAXN; i++) done[i] = false;
        for (int i = 0; i < n; i++) {
            int bango, tanka, num;
            cin >> bango >> tanka >> num;
            if (!done[bango]) {
                done[bango] = true;
                syain.push_back(bango);
            }
            m[bango] += (m[bango] >= 1000000) ? 0 : tanka * num;
        }
        for (int i = 0; i < syain.size(); i++) {
            if (m[syain[i]] >= 1000000) {
                cout << syain[i] << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
    }
    return 0;
}