Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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

using namespace std;

long long int n,a,b,c;



int main(){
    
        
    while(cin >> n){
        if(n==0)break;
        
        long long int ans[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            
            ans[a]+=b*c;
        }
        
        for(int i=1; i<=4000; i++){
            if(ans[i]>=1000000){
                cout<<i<<endl;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int number[4000];
	int tanka[4000];
	int ryou[4000];
	int goukei[4000];
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka[i];
			cin>>ryou[i];
			goukei[i]=tanka[i]*ryou[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int main(){
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<ll> num(4001,0),pre(n,0),data(4001,0);
        for (int i=0; i<n; i++) {
            ll a,b,c;
            cin >>a >>b >>c;
            if(data[a]<1000000) data[a]+=b*c;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0; k< 4001; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        ll ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n == 0){
			break;
		}
		map<int, int> m;
		for(int i = 0; i < n; i++){
			int id, price, amount;
			cin >> id >> price >> amount;
			m[id] += price * amount;
		}
		bool applicable = false;
		for(map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++){
			if(itr->second >= 1000000){
				applicable = true;
				cout << itr->first << endl;
			}
		}
		if(!applicable){
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(){
  int n;
  std::map<int,long long> m;
  std::vector<int> v;
  //mlÛ¶vÛ¶
  long long a,b,c;
  //aÔbP¿cÊ
  bool f;
  while(std::cin>>n && n){
     m.clear();
     v.clear();
     f=true;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
	f=false;
	std::cout<<v[i]<<std::endl;}
    }
    if(f)std::cout<<"NA"<<std::endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        bool flag=0;
        double result[4001]={};
        for(int i=0,str,ans=0;i<n;i++){
            double sale,num;
            cin>>str>>sale>>num;
            sale/=1000;num/=1000;
            result[str]+=sale*num;
            if(result[str]>=1){
                cout<<str<<endl;
                result[str]=-50;
                flag=1;
            }
        }
        if(!flag)cout<<"NA"<<endl;
    }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pint;
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main(){
	ll t,s,total[4010];
	int n;
	for(;cin>>n,n;){
		bool f=false;
		rep(i,4010)total[i]=0;
		rep(i,n){
			int p;
			cin>>p>>t>>s;
			total[p]+=t*s;
		}
		rep(i,4001){
			if(total[i]>=1000000){
				cout<<i<<endl;
				f=true;
			}
		}
		if(!f)cout<<"NA\n";
	}
	return 0;
}

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

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,cost,qty;
    long long data_list[100000];
    int id_list[100000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        memset(data_list,0,sizeof(data_list));
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(cost*qty);
            cin>>id>>cost>>qty;
            id_flag=true;
            for(i=0;i<=k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, i, p, q;
    while(cin >> n && n) {
        bool isExist = false;
        map<int, long long int> emp;
        rep(l, n) {
            cin >> i >> p >> q;
            if(emp[i] != -1) {
                emp[i]+=p*q;
                if(emp[i] >= 1000000) {
                    cout << i << endl;
                    emp[i] = -1;
                    isExist = true;
                }
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

C++: #include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
#define min(x,y) ((x<y)?x:y)
#define L 1000000
int m[4005];
int main(){
	int i,j,n,a,b,c,f;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		f=0;
		memset(m,0,sizeof(m));
		while(n--){
			scanf("%d%d%d",&a,&b,&c);
			if(m[a]>=0){
				if(b!=0 && (L-m[a])/b<=c){
					printf("%d\n",a);
					m[a]=-1;
					f=1;
				}else m[a]+=b*c;
			}
		}
		if(f==0)printf("NA\n");
	}
	return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
long int shineU[SHINE_MAX];	//?£??????????

int num,tanka,suryo;
int i;

int main(){
	white(1){
	 cin>>shineN;
	 if(shineN==0){break;}
	 for(i=0;i<SHINE_MAX;i++){shineU[i]=0;}
	 for(i=0;i<shineN;i++){
	  cin>>num,tanka,suryo;
	  shineU[num]+=tanka*suryo;
	 }
	 //??¨?????????????????¨
	 eliteN=0;
	 for(i=0;i<SHINE_MAX && eliteN<shineN;i++){
	  if(ELITE<=shineU[i]){
	   cout<<i<<endl;
	   eliteN++;
	  }
	 }
	 if(eliteN==0){cout<<AHO<<endl;}
	}
	return 0;
}