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 <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		long long a,b,c;
		int f=0;
		map<int,long long> s;
			vector<int> d;
		
		for(int i=0;i<n;i++){
		
			cin>>a>>b>>c;
			if(!s[a])d.push_back(a);
			s[a]+=b*c;
		}
		for(int i=0;i<d.size();i++){
			if(s[d[i]]>=1000000){
				cout<<d[i]<<endl;
				f=1;
			}
			
		}
		if(f!=1)
			cout<<"NA"<<endl;
	
	}
	
}

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

struct Saler
{
	int Number;
	int Saled;
};

int main(){
	struct Saler* sl;
	int n, a, b, c, i;
	bool isFound;
	
loop:
	scanf("%d", &n);		// データ個数
	if(n == 0) goto end_scope;
	sl = (struct Saler*)malloc(sizeof(struct Saler) * (n + 1));
	memset(sl, 0, sizeof(struct Saler)*n);
	for(int j = 0; j < n; j++)
	{
		scanf("%d %d %d", &a, &b, &c);
		for(i = 0; i < n; i++)
		{
			if(sl[i].Number == 0)
			{
				sl[i].Number = a;
				sl[i].Saled = b * c;
				break;
			}
			else if(sl[i].Number == a)
			{
				sl[i].Saled += b * c;
				break;
			}
		}
	}
	isFound = false;
	for(int j = 0; j < n; j++)
	{
		cout << "Saled " << j << ":" << sl[j].Saled << endl;
		if(sl[j].Saled >= 1000000)
		{
			cout << sl[j].Number << endl;
			isFound = true;
		}
	}
	!isFound && (cout << "NA" << endl);
	free(sl);
	goto loop;
end_scope:
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){

	int i;

	while(true){
		int n;
		int j = 0;

		cin >> n;

		if(n == 0){
			break;
		}
		else if(n < 0 || 4000 < n){
			continue;
		}
		int* a = new int[n];
		int* b = new int[n];
		int* c = new int[n];

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

		for(i = 0; i < n; i++){
			if(b[i] * c[i] >= 1000000){
				cout << a[i] << endl;
				j++;
			}
		}
		if(j == 0){
			cout << "NA" << endl;
		}


	}
}

C++: //AOJ0100
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define __int64 long long 
int main(){
	int n;
	while(cin>>n,n!=0){
vector< pair<int,__int64> >ta;
ta.clear();
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
bool f=0;
int index=0;
for(int j=0;j<ta.size();j++)if(ta[j].first==a)f=1,index=j;
__int64 bc=b*c;
if(f==0)ta.push_back(pair<int,__int64>(a,bc));
else ta[index].second+=b*c;
}

bool f=0;
//cout<<"size "<<ta.size()<<endl;
for(int i=0;i<ta.size();i++){
	//cout<<ta[i].first<<"   "<<ta[i].second<<endl;
	if(ta[i].second>=1000000){cout<<ta[i].first<<endl;f=1;}
}
	if(!f)cout<<"NA"<<endl;
}
	return 0;
}

C++: #include<stdio.h>
int n,i,j,b;
int a,suu;
long long int syain[4001];
int zyun[4001];
int flg=0;
int main(void){
	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]);
		}
	*/	int aa=1;
		for(i=1;i<=cnt;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++: #include<cstdio>

using namespace std;
const int target = 1000000;
int company[4000] = { 0 };

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		int num, sell, cnt;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			company[num - 1] += sell*cnt;
		}
		for (int i = 0; i < 4000; i++)
		{
			if (company[i] >= target)
			{
				printf("%d\n", i + 1);
				hero = true;
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[3][4000],n,i,f;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0;i<n;i++)
      cin>>data[0][i]>>data[1][i]>>data[2][i];
    for(i=0,f=0;i<n;i++)
      if(data[1][i]*data[2][i]>999999)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

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

long long member[4000];
bool ached[4000];
vector<int> ach;

int main(void){
  int n;
  while(true){
    cin >> n;
    if(n == 0)  break;
    fill(member, member + 4000, 0);
    fill(ached, ached + 4000, false);
    ach.clear();
    for(int i = 0; i < n; i++){
      long long id, tanka, suryo;
      cin >> id >> tanka >> suryo;
      member[id] += tanka * suryo;
      if(member[id] >= 1000000 && ached[id] == false){
        ach.push_back(id);
        ached[id] = true;
      }
    }

    if(ach.empty()){
      cout << "NA" << endl;
    }else{
      for(int i = 0; i < ach.size(); i++){
        cout << ach[i] << endl;
      }
    }
  }
  return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        map<int,long long int>M;
        while(n--){
            int a,b,c;
            cin>>a>>b>>c;

            M[a]+=(long long)b*c;
        }

        bool flag=true;
        for(map<int,long long int>::iterator ite=M.begin();ite!=M.end();ite++){
            if(ite->second>=1000000){
                cout<<ite->first<<endl;
                flag=false;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

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

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        long long int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        int t,cost;
        int num;
        for(int i = 0 ; i < n ; i++){
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
        
       for(int i = 0 ; i < n ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(gs[i]==gs[j]&&i < j){
                    gs[j] = 4001;
                }
            }
        }
        
        for(int i = 0 ; i < n ; i++){
            if(s[gs[i]] >= 1000000){
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if(!cnt) cout << "NA" << endl;
    }
    
    return 0;
}