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;
long long sum[4000][10000];
bool used[4000][5000];
int main(){
    int a[10000];
    long long int n, b, c;
    for(int m=0; ; m++){
        scanf("%lld", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%d%lld%lld", &a[i], &b, &c);
            sum[m][a[i]] += b*c;
            /*if(b*c>=1000000){
                na = false;
                printf("%lld\n", a);
            }*/
        }
        for(int i = 0; i < n; i++){
            if(used[m][a[i]]==false&&sum[m][a[i]] >= 1000000){
                na = false;
              used[m][a[i]]=true;
                printf("%d\n", a[i]);
            }
        }
        
        if(na) puts("NA");
    }
}

C++: #include<stdio.h>
int n,i,b;
int a,suu;
long long int syain[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;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
		}
		flg=0;
		for(i=1;i<=4000;i++){
			if(syain[i]>=1000000){
				printf("%.4d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    vector<int> num;
    set<int> used;
    map<int, long long> sales;
    int a, b, c;
    for(int i = 0;i < n;i++){
      cin >> a >> b >> c;
      num.push_back(a);
      sales[a] += b * c;
    }
    bool ok = false;
    for(int i = 0;i < n;i++){
      int p = num[i];
      if(used.count(p))continue;
      used.insert(p);
      if(sales[p] >= 1000000){
	cout << p << endl;
	ok = true;
      }
    }
    if(!ok)cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		long long no;
		long long price;
		long long deal;

		vector <long long> V;
		map <long long, long long> P;

		bool f = true;
		for ( int i = 0; i < n; i++ )
		{
			cin >> no >> price >> deal;

			if ( find( V.begin(), V.end(), no ) == V.end() )
				V.push_back( no );

			P[no] = max( P[no], price * deal );

			if ( P[no] >= 1000000 )
			{
				f = false;
			}
		}

		if ( f )
		{
			cout << "NA" << endl;
		}
		else
		{
			for ( vector <long long>::iterator it = V.begin(); it != V.end(); it++ )
			{
				if ( P[*it] >= 1000000 )
				{
					cout << *it << endl;
				}
			}
		}

	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void) {
  int n, flag=0;
  int man[4000], num, sale, good[4000];
  
  while(1) {
    flag = 0;
    for(int i = 0 ; i < 4000 ; i++) {
      man[i] = 0;
      good[i] = 0;
    }
    cin >> n;
    if(n == 0) break;
    for(int i = 0 ; i < n ; i++) {
      cin >> man[i] >> num >> sale;
      if(num * sale >= 1000000) { good[i] = man[i]; flag = 1; }
    }
    if(flag == 1) {
      for(int i = 0 ; i < n ; i++) {
	if(good[i] > 0) cout << good[i] << endl;
      }
    }
    else cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <map>

int main()
{
  int n;
  while (std::cin >> n) {
    if (n == 0) break;
    
    bool na = true;
    std::map<int, long long> id_sales_map;

    for (int i = 0; i < n; ++i) {
      int ID;
      long long price, number;
      std::cin >> ID >> price >> number;

      if (id_sales_map[ID] < 1000000) {
        id_sales_map[ID] += price * number;
        if (id_sales_map[ID] >= 1000000) {
          std::cout << ID << std::endl;
          na = false;
        }
      }
    }

    if (na) {
      std::cout << "NA" << std::endl;
    }
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int bangou,tanka,kosuu;
    int number; cin >> number;
    do{
        int man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
        }
        int count =0;
        for(int i=0;i<4000;i++){
            if(man[i]>=1000000){
                cout << i+1 << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

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

int main(){
 int id,price,num,count;
 bool isBe=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   if(price*num>=100000){
    cout<<id<<'\n';
    isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
 }
 return 0;
}

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

int main()
{
	int em[4000];
	int num,i,id,p,q,flag;
	cin>>num;

	while(num!=0){
    flag =0;

	for(i=0;i<4000;i++){
		em[i]=0;
	}

	for(i=0;i<=num-1;i++){
	    cin>>id >>p >>q;
		em[id]+=p*q;
	}

	for(i=0;i<4000;i++){
		if(em[i]>=1000000){
			cout<<i<<"\n";
		    flag =1;
		}
	}
	if(flag!=1)
		cout<<"NA\n";
	cin >>num;

	}
	return 0;
		
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll sums[4000];
bool used[4000];
int main()
{
	int n;
	while(cin>>n,n) 
	{
		bool f=false;
		int num;
		int a,b;
		fill(sums,sums+4000,0);
		fill(used,used+4000,0);
		for(int i = 0; i < n; ++i)
		{
			cin>>num>>a>>b;
			sums[num-1]+=a*b;
			used[num-1]=true;
		}
		for(int i = 0; i < 4000; ++i)
		{
			if(used[i]&&sums[i]>=1000000)
			{
				cout<<i+1<<endl;
				f=true;
			}
		}
		if(!f) cout<<"NA"<<endl;
	}
  return 0;
}

C++: #include<stdio.h>

int main(){
  while(1){
    int i, n;
    int a, b, c;
    scanf("%d", &n);
    if(n!=0){
      int e[4000] ={};
      int flag = 0;
      for(i=0;i<n;i++){
	scanf("%d %d %d", &a, &b, &c);
	if(e[a]+b*c<=2147483647)
	  e[a]+=b*c;
	else
	  e[a]=2147483647;
      }
      for(i=0;i<4000;i++){
	if(e[i]>=1000000){
	  printf("%d\n", i);
	  flag++;
	}
      }
      if(flag==0)
	printf("NA\n");
    }
    else{
      break;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
int main(){
  int n,inindex;
  long long num,val;
  vector<int> Index;
  map<int,long long> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    List.clear();
    Index.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(!List[inindex]){
	Index.push_back(inindex);
      }
      List[inindex]+=val*num;
    }
    bool NAf=true;
    for(int i=0;i<Index.size();i++){
      if(List[Index[i]] >= 1000000){
	printf("%d\n",Index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}