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<algorithm>
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
	int n;
	while(scanf("%d", &n),n){
		long long per[5000]={0};
		int flg[5000]={0};
		int count = 0;
		int cnt[5000]={0};
		int num,t,s;
		int flag = 1;
		
		for(int i = 0; i < n; i++){
			scanf("%d%d%d", &num, &t, &s);
			if(flg[num]==0){
				cnt[count] = num;
				count++;
				flg[num]=1;
			}
			per[num] += (long long)t * (long long)s;
		}
		for(int i = 0; i < count; i++){
			if(per[cnt[i]] >= (long long)1000000){
				flag=0;
				printf("%d\n", cnt[i]);
			}
		}
		if(flag)
			puts("NA");
	}
	return 0;
}

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

int main(){
  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 <vector>
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> p;

int main()
{
    int n, a, b, c;
    while(cin >> n && n) {
        vector<p> v;
        while(n--) {
            cin >> a >> b >> c;
            bool f = true;
            for(int i = 0; i < v.size() ; i++) {
                if(v[i].first == a) {
                    f = false;
                    v[i].second += b * c;
                }
            }
            if(f) {
                v.push_back(p(a, b * c));
            }
        }
        bool f = true;
        for(int i = 0; i < v.size(); i++) {
            if(v[i].second >= 1000000) {
                f = false;
                cout << v[i].first << endl;
            }
        }
        if(f) cout << "NA" << endl;

    }
}

C++: #include<stdio.h>
long long int t[4000];
int k[4000];
bool sub[4000];
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<4000;i++){
            t[i]=0;
            k[i]=0;
            sub[i]=false;
        }
        int o=0;
        for(int i=0;i<a;i++){
            int b,c,d;
             
            scanf("%d%d%d",&b,&c,&d);
            t[b-1]+=(long long)c*(long long)d;
            if(!sub[b-1]){
                k[o++]=b-1;
                sub[b-1]=true;
            }
        }
        bool ok=false;
        for(int i=0;i<o;i++){
            if(t[k[i]]>=1000000LL){
                printf("%d\n",k[i]+1);
                ok=true;
            }
        }
        if(!ok)printf("NA\n");
    }
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n, no[4000], t[4000], num[4000], a[4000], i, j;
	while (cin >> n && n)
	{
		for (i = 0, j = 0; i < n; i++)
		{
			cin >> no[i] >> t[i] >> num[i];
			if (t[i] * num[i] > 1000000)
			{
				a[j] = no[i], j++;
			}
		}
		if (j == 0)
			cout << "NA" << endl;
		else
			for (i = 0; i < j; i++)
				cout << a[i] << endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <set>
#include <string>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n && n) {
        set<string> list;
        string id;
        ll a,b,c = 1000000;
        for(int i = 0; i < n; i++) {
            cin >> id >> a >> b;
            if(a * b >= c && list.find(id) == list.end()) {
                list.insert(id);
                cout << id << endl;
            }
        }
        if(list.size() == 0) cout << "NA" << endl;
    }
}

C++: #include<iostream>
#include<map>
using namespace std;
const int MAXN = 4000;
typedef long long ll;
int i,p,q;
bool isfind;
map<int,ll> total;
int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0)return 0;
    for(int k = 0;k < n;k++){
      cin >> i >> p >> q;
      total[i] += p*q;
    }
    for(map<int, ll>::iterator i = total.begin(); i != total.end(); ++i){
      if(i->second >= 1000000){
	isfind = true;
	cout << i->first << endl;
      }
    }
    if(!isfind)cout << "NA" << endl;
    total.clear();
    isfind =false;
  }
  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)
        {
            //cout <<"NUMBER"<<*it <<endl;
            if(sales[*it] >= 1000000){cout<<*it<<endl;na=1;}
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
 
 

 
int main(void){
	int i,j,k;
	int n,num[4000];
	long long int tanka[4000],sale_num[4000],sale_all[4001];
	bool judge[4001];
	
	while(scanf("%d",&n),n){
		
		//初期化

		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka[i],&sale_num[i]);
		}
		
		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[i]] = sale_all[num[i]] + tanka[i]*sale_num[i];
		}
		
		for(i=0;i<n;i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		
		if(k!=1)printf("NA\n");
	}
	
	return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef long long int Int;
const int NORMA = 1000000;

int main() {
  int N;
  while(cin >>N && N){
    map<Int, Int> m;
    set<Int> s;
    vector<Int> v;
    REP(i, N){
      Int a, b, c; cin >>a >>b >>c;
      m[a] += b * c;
      if(s.find(a) == s.end()) v.push_back(a);
      s.insert(a);
    }
    vector<Int> ans;
    REP(i, v.size()) if(m[v[i]] >= NORMA) ans.push_back(v[i]);
    if(ans.size() == 0) cout <<"NA" <<endl;
    else REP(i, ans.size()) cout <<ans[i] <<endl;
  }
  return 0;
}