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 <cstring>
using namespace std;

int main(){
  int n;//データ数
  while(cin >> n){
    long long arr[4003];//社員番号
    int selling[n];//販売単科
    int sales[n];//売り上げ数量
    int num;
    int check=0;
    //社員は4000人未満
    memset(arr,0,sizeof(arr));
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin >> num >> selling[i] >> sales[i];
      arr[num]+=selling[i]*sales[i];
    }
    for(int i=0;i<=4000;i++){
      if(arr[i]>=1000000){
        cout << i << endl;
        check++;
      }
    }
    if(check==0)
       cout << "NA" << endl;
    check=0;
  }
}

C++: #include<stdio.h>

int main(){

	int n=1, i, x[3][4000] = {},  y=0;

	for (n = 1; n > 0;n++){
		
		scanf("%d", &n);
		
		if (n == 0){ break; }

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[0][i],&x[1][i],&x[2][i]);
		}

		for (i = 0; i < n; i++){
			
			if (x[1][i] * x[2][i] > 999999){
				printf("%d\n", x[0][i],y++);
			}	
		}
		if (y == 0){ printf("NA\n"); y = 0; };
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
	map<int,long long int> mp;
	vector<int> vec;
	int n,now,a;
	long long int b,c;
	while(cin>>n,n){
		now=0;
		mp.clear();
		vec.clear();
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(!mp[a]){
				vec.push_back(a);
			}
			mp[a]+=b*c;
		}
		for(int i=0;i<vec.size();i++)
			if(mp[vec[i]]>=1000000){
			cout<<vec[i]<<endl;
				now++;
			}
		if(now==0)
		cout<<"NA"<<endl;
	}
	return 0;
}

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

C++: #include<stdio.h>

int main(){

	int n=1, i, x[3][4000] = {},  y=0;

	while (n > 0){
		scanf("%d", &n);

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[0][i],&x[1][i],&x[2][i]);
		}

		for (i = 0; i < n; i++){
			
			if (x[1][i] * x[2][i] > 999999){
				printf("%d\n", x[0][i],y++);
			}	
		}
		if (y == 0){ printf("NA\n"); } (y = 0);
	}
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<string.h>

int main()
{
	int n;
	long long v[4001];
	std::vector<int> vec;
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
		
		memset( v, 0, sizeof( v ) );
		vec.clear();
		
		while( n-- ){
			int num;
			long long a, b;
		 	std::cin >> num >> a >> b;
			
			v[num] += a * b;
			vec.push_back( num );
		}
		
		bool f = true;
		bool used[4001];
		
		memset( used, false, sizeof( used ) );
		
		for( std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++ ){
			if( v[*it] >= 1000000 && !used[*it] ){
			 	std::cout << *it << std::endl;
				f = false;
				used[*it] = true;
			}
		}
		
		if( f ){
			std::cout << "NA" << std::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 <iostream>
using namespace std;
int main (int argc, const char * argv[])
{

    int n=1,num,tanka,suryo;
    int sum[4001]={0};
    bool na=true;
    while(true){
        cin>>n;
        if(n==0){
            return 0;
        }
        for(int i=0;i<n;i++){//ツ禿シツ療債つウツづェツつスツ値ツづーツ各ツ配ツ療ア(ツ偲青暗オツ氾板債づ可格ツ納)
            cin>>num>>tanka>>suryo;
            sum[num]+=tanka*suryo;
        }
        for(int i=1;i<=4000;i++){
            if(sum[i]>=1000000){cout<<i<<endl;na=false;}
            sum[i]=0;//ツ篠淞づ可使ツつ、ツづヲツつ、ツづ可渉可甘コツ可サツづーツつオツづつィツつュ
        }
        if(na)cout<<"NA"<<endl;
        na=true;
    }
}

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

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int id, price, amount;
		vector<int> v;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> amount;
			if(price * amount >= 10000){
				auto itr = find(v.begin(), v.end(), id);
				if(itr == v.end()){
					v.push_back(id);
				}
			}
		}
		if(v.empty()){
			cout << "NA" << endl;
		}
		else{
			for(int i = 0; i < v.size(); i++){
				cout << v[i] << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  while( cin >> n,n ){
    ll ma[4001] = {0};
    vector<ll>ve;
    ve.clear();
    for(int k = 0 ; k < n ; k++ ){
      int a,b,c;
      cin >> a >> b >> c;
      if(ma[a] == 0)ve.push_back(a);
      ma[a] += b*c;
    }
    int f = 1;
    for(vector<ll>::iterator it = ve.begin() ; it != ve.end() ; it++ ){
      if(ma[(*it)] >= 1000000 ){
	cout << (*it) << endl;
	f = 0;
      }
    }
    if(f)cout << "NA" << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int n; cin >> n;
    do {
        int e[n], p[n], q[n];
        int tmp[4010] = {};
        int flag = 0;
        rep(i, n) cin >> e[i] >> p[i] >> q[i];
        for (int i = 0; i < n; i++) {
            tmp[e[i]] += p[i] * q[i];
        }
        for (int i = 0; i < 4010; i++) {
            if (tmp[i] >= 1000000) {
                cout << i << endl;
                flag = 1;
            }
        }
        if (flag == 0) cout << "NA" << endl;
        cin >> n;
    } while(n != 0);

    return 0;
}