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 <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int n;
    while(cin>>n, n!=0) {
        int memo[4000] = {0};
        bool F[4000] = {false};
        bool f = true;
        for(int i=0; i<n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            memo[a] += (b*c);
            if(memo[a]>=1000000 && !F[a]) {
                f = false;
                F[a] = true;
                cout << a << endl;
            }
        }
        if(f) cout << "NA" << endl;
    }
    return 0;
}

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

int main(){

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

  while(1){

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

    for(i=0;i<n;i++){
      scanf("%s",syain[i]);
      scanf("%d",&tanka);
      scanf("%d",&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>
#include <fstream>
#include <stdlib.h>
#include <map>
using namespace std;
ifstream fin("D:\\txt.txt");
#define for0(i,n) for (i=0;i<n;i++)

typedef struct employees
{
	int ID;
	int Sales;
}employees;
map<int,int> data;
#define MV(a,b) map<int,int>::value_type(a,b) 
// int main()
// {
// 	data[0]=123;
// 	data[1]=456;
// 	data[1]=789;
// 	int a=data.size();
// 	a=data[1];
// 	map<int,int>::iterator it=data.begin();
// 	a=it->first;
// 	a=it->second;
// 	it++;
// 	a=it->first;
// 	a=it->second;
// }
int main()
{
	int n,a,b,c,i,j;
	while(fin>>n)
	{
		if(!n)break;
		for0(i,n)
		{
			fin>>a>>b>>c;
			c*=b;
			if (data.find(a)==data.end())
			{
				data.insert(MV(a,c));
			}
			else
			{
				data[a]+=c;
			}
		}
	}
	map<int,int>::iterator it=data.begin();

	while(it!=data.end())
	{
		if (1000000<=it->second)
		{
			cout<<it->first<<endl;
		}
		else
		{
			cout<<"NA"<<endl;
		}
		it++;
	}
	return 0;
}//*/

C++: /*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	int n;
	int num[4000];
	bool appear[4001];
	int howmany;
	int number;
	long int in_price;
	long int in_sales;
	long int price[4000];
	long int sales[4000];
	/*****処理部*****/
	while(1){
		memset(appear,false,sizeof(appear));
		memset(price,0,sizeof(price));
		memset(sales,0,sizeof(sales));
		memset(num,0,sizeof(num));
		howmany = 0;
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> number;
			cin >> in_price;
			cin >> in_sales;
			price[number] += in_price;
			sales[number] += in_sales;
			if(!appear[number])	num[i] = number;
			appear[number] = true;
		}
		for(int i=0;i<n;i++){
			if(num[i] != 0){
				if(price[num[i]] * sales[num[i]] >= 1000000){
					cout << num[i] << endl;
					howmany++;
				}
				//cout << i << " " << price[num[i]] << " " << sales[num[i]] << endl;
			}
		}
		if(howmany == 0)	cout << "NA" << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

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

int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        long long a[5000] = {0};
        long long int number;
        long long int jun[5000] = {0};
        long long tanka,kazu;
        for(int i = 1; i <= n; i++){
            cin >> number >> tanka >> kazu;
            a[number] += tanka * kazu;
            jun[i] = number;
        }
        for(int i = 0; i < 4000; i++){
            for(int j = i+1; j <= 4000; j++){
                if(jun[i] == jun[j]) jun[j] = 0;
            }
        }
        
        bool flg = 0;
        for(int i = 1; i 4000; i++){
            if(a[jun[i]] >= 1000000){
                cout << jun[i] << endl;
                flg = 1;
            }
        }


        if(!flg) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
typedef struct result{
  int nam;
  int mon;
  int cont;
  int sum;
}P;
int main(){
  P a[4000];
  int n,nacount;
  while(1){
    cin >> n;
    if(n==0){break;}
    nacount=0;
    for(int i=0;i<n;i++){
      cin>>a[i].nam>>a[i].mon>>a[i].cont;
      a[i].sum=a[i].mon*a[i].cont;
    }
    for(int i=0;i<n;i++){
      for(int j=n-1;j>i;j--){
	if(a[i].nam==a[j].nam){
	  a[i].sum+=a[j].sum;
	}
      }
    }
    for(int i=0;i<n;i++){
      if(a[i].sum>=1000000){
	cout<<a[i].nam<<endl;
	nacount++;
      }
    }if(nacount==0){
      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, 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>
int main(void){
	int n,i,j,b;
	int a,suu;
	long long int syain[4001];
	int zyun[4001];
	int flg=0;
	int aa=1;
	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++;
			}
		}
		flg=0;
	/*	for(i=1000;i<=1005;i++){
			printf("%d=%d %d\n",i,zyun[i],syain[i]);
		}
	*/	aa=1;
		for(i=0;i<4000;i++){
			for(j=1;j<=4000;j++){
				if(zyun[j]==aa && syain[j]>=1000000){
					printf("%d\n",j);
					flg=1;
				}
			}
			aa++;
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

C++: /*
AizuOnline A0100
Sale Result
*/
#include <stdio.h>

long long int uriage[4000];

main()
{
  int i,cnt;
  int code;
  long int tannka,suuryou;
  int flag;
  
  while(EOF != scanf(" %d",&cnt) && cnt > 0)
    {
    for(i=0;i<4000;i++)
      uriage[i]=0;
      
    for(i=0;i<cnt;i++)
      {scanf("%d %ld %ld",&code,&tannka,&suuryou);
       uriage[code] += tannka * suuryou;
      }
    flag = 0;
    for(i=0;i<4000;i++)
      if(uriage[i] >= 1000000)
        {  flag = 1;
          printf("%d\n",i);
        }
    if(flag == 0)
      printf("NA\n");
    }

return(0);
}