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 <map>
#include <vector>

using namespace std;

int main(void){
  int n, a, b, c;
  map<int, long> m;
  vector<int> v;

  while(cin >> n, n){
    v.clear();  m.clear();

    for(int i=0; i<n; i++){
      cin >> a >> b >> c;

      if(m.find(a) != m.end()){
        m[a] += b * c;
      } else {
        v.push_back(a);
        m[a] = b * c;
      }
    }

    bool flag = false;
    for(int i=0; i<v.size(); i++){
      if(m[v[i]] >= 1000000){
        flag = true;
        cout << v[i] << endl;
      }
    }

    if(flag == false){
      cout << "NA" << endl;
    }
  }


  return 0;
}

C++: #include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,i,j,c=0;
    long long p,n;
    scanf("%d",&i);
    while(i!=0){
        c=0;
	memset(N,0,sizeof(N));
	memset(f,0,sizeof(f));
        for(j=0;j<i;j++){
            scanf("%d%lld%lld",&x,&n,&p);
            if(N[x]>=0&&(N[x]+=n*p)>=1000000L){
                f[c]=x;
                c++;
                N[x]=-100L;
            }
        }
        if(c<1){
            printf("NA\n");
        }else{
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        }
        scanf("%d",&i);
    }
    return 0;
}

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

int main() {
	int num;						//1???????????????????????\????????°
	int data_set = 0;				//???????????????????????°
	bool do_continue = true;		//??????????????°
	std::vector<string> result;		//??????

	while (do_continue) {
		cin >> num;		//???????????°??\???
		if ((num == 0) || (data_set > 50)) {
			do_continue = false;
		}
		else {
			bool na_flg = true;				//NA????????°
			data_set++;						//?????????????????????
			std::map<int, int> e;			//??????
			std::vector<int> employee;
			int fst, snd, thd;

			for (int i = 0; i < num; i++) {
				cin >> fst >> snd >> thd;
				employee.push_back(fst);
				//????????????????????´???
				if (e.count(employee[i])) {
					e[employee[i]] += snd * thd;
				}
				//??°???????????????
				else {
					e[employee[i]] = snd * thd;
				}
			}

			//1000000??\???????????????????´?
			for (unsigned int j = 0; j < employee.size(); j++) {
				if (e[employee[j]] >= 1000000) {
					na_flg = false;
					result.push_back(std::to_string(employee[j]));
				}
			}

			//NA??????
			if (na_flg) {
				result.push_back("NA");
			}
		}
	}

	for (unsigned int i = 0; i < result.size()-1; i++) {
		cout << result[i] << endl;
	}

	//while (1);

	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
	int N;
	
	while(cin>>N,N){
		map<int,int> mp,mp2;
		vector <int> vi;
		queue<int >pq;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			mp[num]+=tanka*suuryo;
			vi.push_back(num);
			if(mp[num]>=1000000){
				mp2[num]++;
			}
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
			if(mp2[*it]>=2){
				mp2[*it]--;
			}
			else if(mp2[*it]==1){
				pq.push(*it);
				mp2[*it]--;
			}
		}
		if(pq.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=pq.size();
			for(int i=0;i<len;i++){
				cout<<pq.front()<<endl;
				pq.pop();
			}
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
#define inf 1000000
using namespace std;
long long int p[114514],x,y,z,w;
int main(void)
{
	int i,j,k,f,n,cnt;
	while(1) {
		cin>>n;
		f=0,cnt=0;
		if(!n)break;
		for(i=0;i<4001;i++) p[i]=0;
		for(i=0;i<n;i++) {
			cin>>x>>y>>z;
			if(y>=inf) y=w;
			else w=y*z;
			if(p[x]>=inf) {}
			else p[x]+=w;
		}
		for(i=0;i<4001;i++) {
			if(p[i]>=inf) {
				cout<<i<<endl;
				f=1;
			}
		}
		if(f==0) cout<<"NA"<<endl;
	}
	return 0;
}

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;
}