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>
using namespace std;
int main(){
long long n,a,b,c,f,i,j,k,s[4001],aa[4001];
while(cin>>n){
if(n==0)break;
for(i=0;i<n;i++){s[i]=0;aa[i]=0;}
for(i=0;i<n;i++){
cin>>a>>b>>c;
k=i;
for(j=0;j<i;j++)if(a==aa[j]){k=j;break;}
aa[i]=a;
for(j=0;j<c;j++){
if(s[k]>=1000000)break;
s[k]+=b;
}
}
for(f=0,i=0;i<n;i++)
if(s[i]>=1000000){cout<<aa[i]<<endl;f=1;}
if(f==0)cout<<"NA"<<endl;
}
return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int main(){

 long int n,i,j,cnt=0,tanka,kazu,sum[4002]={0};
  char syain[4000][5],*syokika="GO";

  while(1){

    scanf("%ld",&n);
    if(n==0){
      break;
    }

    for(i=0;i<n;i++){
      scanf("%s",syain[i]);
      scanf("%ld",&tanka);
      scanf("%ld",&kazu);
      sum[i]=tanka*kazu;
    
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(strcmp(syain[i],syain[j])==0 && i!=j){
	  sum[i]=sum[i]+sum[j];
	  sum[j]=0;
	  strcpy(syain[j],syokika);
	}
      }
    }

    for(i=0;i<n;i++){
      if(sum[i]>=1000000){
	cnt=1;
	printf("%s\n",syain[i]);
      }
    }
    if(cnt==0){
      printf("NA\n");
    }

    cnt=0;

  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	while (cin >> n)
	{	bool f = false;
		int e[4000], p[4000], q[4000], t[4000];
		for (int i = 0; i < n; i++)
		{
			cin >> e[i];
			cin >> p[i];
			cin >> q[i];
			t[i] = p[i] * q[i];
		}

		for (int a = 0; a < n; a++)
		{
			if (t[a] >= 1000000)
			{
				cout << e[a] << endl;
				f = true;
			}
		
		
		}
		if (!f)
		{
			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;
    bool f=true;
    rep(i,0,n){
        int num;
        ll a,b;
        scanf("%d %lld %lld",&num,&a,&b);
        if(a*b>=1000000){
            printf("%lld\n",num);
            if(f)f=false;   
        }
    }
    if(f)cout<<"NA"<<endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
using namespace std;
main(){
  //mlÛ¶vÛ¶
  long long a,b,c,n,f;
  //aÔbP¿cÊ
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
			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]]>999999)f=0;cout<<v[i]<<endl;
    if(f)cout<<"NA"<<endl;
  }
}

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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		int buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			if(buf[1] * buf[2] >= 1000000){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

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

int main(){

  int num, v, n, m, len, cnt;
  vector<int> vc[2];

  while(cin >> n){
    if(n == 0) break;
    vc[0].clear();
    vc[1].clear();
    len = 0;

    for(int i=0; i<n; i++){
      cin >> num >> v >> m;
      for(int j=0; j<=len; j++){
        if(j == len){
          vc[0].push_back(num);
          vc[1].push_back(v * m);
          len++;
          break;
        }
        if(vc[0][j] == num){
          vc[1][j] += v * m;
          break;
        }
      }
    }
    
    cnt = 0;
    for(int i=0; i<len; i++){
      if(vc[1][i] >= 1000000){
        cout << vc[0][i] << endl;
        cnt++;
      }
    }
    if(cnt == 0) cout << "NA" << endl;

  }

  return 0;

}

C++: #include <iostream>
using namespace std;
int main(){
    long long bangou,tanka,kosuu;
    long long number; cin >> number;
    long long kuso[number];
    do{
        long long man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            kuso[i]=0;
        }

        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
            kuso[i]=bangou;
        }
        int count =0;
        if(man[kuso[0]-1]>=1000000){
            cout << kuso[0] << endl;
            count++;
        }
        for(int i=1;i<number;i++){
            int tmp =0;
            for(int j=0;j<i;j++){
                if(kuso[i]==kuso[j]){
                    tmp++;
                    break;
                }
            }
            if(tmp==0 && man[kuso[i]-1]>=1000000){
                cout << kuso[i] << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
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;
			w=y*z;
			p[x]+=w;
		}
	
		for(i=0;i<4001;i++) {
			if(p[i]>=1000000) {
				cout<<i<<endl;
				f=1;
			}
		}
		if(f==0) cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int a,hoge;
	bool flag;
	while(1){
		cin >> a;
		if(a == 0) break;
		int number[a];
		int tanka[a];
		int ryo[a];
		int gokei[a];
		flag = false;
		for(int i=0;i<a;i++){
			cin >> number[i] >> tanka[i] >> ryo[i];
			gokei[i] = tanka[i] * ryo[i];
			if(gokei[i] >= 1000000){
				cout << number[i] << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	int n,i,j,b;
	int a,suu;
	long long int syain[4001];
	int zyun[4001];
	int flg=0;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
			zyun[i]=0;
		}
		int cnt=1;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
			if(zyun[a]==0){
				zyun[a]=cnt;
				cnt++;
			}
		}
/*		for(i=1;i<=4000;i++){
			if(zyun[i]!=0){
				printf("%d=%d %d\n",i,zyun[i],syain[i]);
			}
		}
*/		flg=0;
		for(i=1;i<=cnt;i++){
			for(j=1;j<=4000;j++){
				if(zyun[j]==i && syain[j]>=1000000){
					printf("%d\n",j);
					flg=1;
				}
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0; 
}