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 <cstdio>
#define X 4001
#define V 1000000
using namespace std;

int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		long a[X];
		int f[X];
		for(int i=0;i<X;i++) a[i] = 0;
		for(int i=0;i<X;i++) f[i] = 0;
		int b;
		long c,d;
		int s = 0;
		for(int i=0;i<n;i++){
			cin >> b >> c >> d;
			if(a[b]<V) a[b] += c*d;
			if(f[b]==0){
				s++;
				f[b] = s;
			}
		}
		bool e = true;
		for(int i=1;i<X;i++){
			for(int j=0;j<X;j++){
				if(f[j]!=i) continue;
				if(a[j]>=V){
					e = false;
					cout << j << endl;
				}
				break;
			}
		}
		if(e) cout << "NA" << endl;
	}
}

C++: #include <iostream>
using namespace std;
typedef struct{
	int number;
	long long sales;
} staff;

int main(void)
{
	int n;
	while(cin>>n){
		if(!n) break;
		staff staff1[4001];
		for(int i=0; i< n; i++){
			cin >> staff1[i].number;
			long price;
			int bnum;
			cin >> price >> bnum;
			staff1[i].sales = price * bnum;
		}
		int count = 0;
		for(int i=0; i < n; i++){
			if(staff1[i].sales >= 1000000){
				count++;
				cout << staff1[i].number << endl;
			}
		}
		if(!count) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;
    while(cin>>n){
    if(n==0)return 0;
    vector<pair<int,ll> > v;
    bool f=true;
    rep(i,0,n){
        int num;
        ll a,b;
        scanf("%d %lld %lld",&num,&a,&b);
        if(i==0)v.pb(mp(num,a*b));
        else {
            bool judge=true;
            rep(j,0,v.size()){
                if(num==v[j].fi) {
                    judge=false;
                    v[j].se+=a*b;
                }
            }
            if(judge)v.pb(mp(num,a*b));
        }
    }
    
    rep(i,0,v.size()){
        if(v[i].se>=1e6){
            cout<<v[i].fi<<endl;
            f=false;   
        }
    }
    if(f)cout<<"NA"<<endl;
    }
    
    return 0;
}

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

int main()
{
	array<int, 4000> ar = {};
	vector<int> ans;
	int n,e,p,q;
	
	while (true) {
		cin >> n;
		ar.fill(0);
		if (!n) {
			break;
		}

		bool isNA = true;
		for (int i = 0; i < n; ++i) {
			cin >> e >> p >> q;
			ar[e] += p*q;
		}
		for (int i = 0; i < 4000;++i) {
			if (ar[i] >= 1000000) {
				ans.push_back(i);
				isNA = false;
			}
		}
		if (isNA) {
			ans.push_back(-1);
		}

	}

	for (auto it : ans) {
		if (it != -1) {
			cout << it;
		}
		else {
			cout << "NA";
		}

		if (it != *ans.end()) {
			cout << endl;
		}
	}
	return 0;
}

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

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

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

int dataN,num,tanka,suryo;
int i,j;

int main(){
while(1){
	//??\???
	cin>>dataN;
	if(dataN==0){break;}
	shineN=0;
	for(j=0;j<dataN;j++){
	 cin>>num>>tanka>>suryo;num--;
	 //???????????????????????????????????¨??????????????????
	 for(i=0;i<shineN;i++){
	  if(shineI[i]==num){break;}
	 }
	 if(i==shineN){	//?????¨???????????£????????????
	  shineU[num]=0;
	  shineI[shineN]=num;
	  shineN++;
	 }
	 shineU[num]+=suryo*tanka;
	}
	//??????
	eliteN=0;
	for(j=0;j<shineN;j++){
	 i=shineI[j];
	 if(ELITE<=shineU[i]){
	  cout<<i+1<<endl;
	  eliteN++;
	 }
	}
	if(eliteN==0){cout<<AHO<<endl;}
}
return 0;
}

C++: #include<stdio.h>
//#include<stdlib.h>
//#include<time.h>

struct staff_data{
	int num,price,volume;
	unsigned long long int total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	/*srand((unsigned)time(NULL));*/
	
	while(scanf("%d",&n)!=0){
	
		if(n==0){
			break;
		}
		
		for(i=0;i<4000;i++){
			dt[i].num=0;
			dt[i].price=0;
			dt[i].total=0;
			dt[i].volume=0;
		}
		
		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			/*num=rand()%4000;
			price=rand()%1000000;
			volume=rand()%100000;
			printf("%5d %5d %5d ||",num,price,volume);*/
			
			for(j=0;j<=i;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					dt[j].num=num;
					dt[j].total=(price)*(volume)+dt[j].total;
					/*printf("num==%5d total==%d\n",dt[j].num,dt[j].total);*/
					break;
				}
				
			}
		}

		hantei=0;

		for(j=0;j<n;j++){
		
			if(dt[j].total>=1000000){
				printf("%d\n",dt[j].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	return 0;
}

C++: #include<map>
#include<iostream>
using namespace std;
int main(){
        map<int,int> total;
        int d,num,item,ko;
        while(cin>>d){
                if(d==0) break;
                for(int i=0;i<d;i++){
                        cin>>num>>item>>ko;
                        item *= ko;
                        //cout<<item<<endl;
                        if(item>=1000000){
                                total.insert(make_pair(num,item));
                        }
                }
                if(total.size()==0) cout<<"NA"<<endl;
                else{
                        map<int,int>::iterator it;
                        for(it=total.begin();it!=total.end();it++){
                                cout<<(*it).first<<endl;
                        }
                        total.clear();
                }
        }
}

C++: #include<map>
#include<iostream>
using namespace std;
int main(){
	map<int,int> total;
	int d,num,item,ko,cont=0;
	while(cin>>d){
		if(d==0) break;
		cin.ignore();
		for(int i=0;i<d;i++){
			cin>>num>>item>>ko;
			item *= ko;
			if(item>=1000000){
				cont++;
				total.insert(make_pair(cont,num));
			}
		}
		if(total.size()){
			map<int,int>::iterator it;
			for(it=total.begin();it!=total.end();it++){
				cout<<(*it).second<<endl;
			}
		}
		else cout<<"MA"<<endl;
		cont=0;
		total.clear();
	}
}

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

int n,num,flag;
long int shine[4000],tannka,kosu;

int main(){
	while(1){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>num>>tannka>>kosu;
			shine[num]+=tannka*kosu;
			if(shine[num]>=1000000){
				cout<<num<<endl;
				flag++;
			}
		}
		if(flag==0){cout<<"NA"<<endl;}
		else{flag=0;}
		for(int i=0;i<4000;i++){
			shine[i]=0;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    unsigned long long a[5000]={0},c=0,p,o,u;
    rep(i,5000)cout<<a[i];
    rep(i,n){
      cin>>p>>o>>u;
      a[p]+=o*u;
      if(a[p]>=1000000){cout<<i<<endl;c++;}
    }
    if(!c)cout<<"NA"<<endl;
  }
}