Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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);
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector<long long int> ans;
    vector<long long int> u(4001, 0);
    for(int i=0; i<n; i++){
      long long int e, p, q;
      cin >> e >> p >> q;
      u[e] += p*q;
      // if( p * q >= 1000000 ) ans.push_back(e);
    }
    for(int i=0; i<4001; i++){
      if( u[i] >= 1000000 ) ans.push_back(i);
    }
    if( ans.size() == 0 ) cout << "NA" << endl;
    else for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;
  }

  return 0;
}

// EOF

C++: 
int main(){

	long all[4001] = {};
	long code, a, b, n, i,j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}


		cin >> n;
		if (n == 0){
			break;
		}

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

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

		if (j == 0){
			cout << "NA" << endl;
		}

	}
}

C++: #include<stdio.h>

int main(){
	long kazu,data[4000][3];
	long R[4000];
	long kaunto=0;
	long i,j;
	long number=0;
	
	scanf("%d",&kazu);
	while(kazu!=0){
		for(i=0;i<4000;i++){
			R[i]=0;
		}
		for(i=0;i<4000;i++){
			data[i][0]=i+1;
		}
		for(i=0;i<4000;i++){
			for(j=1;j<3;j++){
				data[i][j]=0;
			}
		}
		
		for(i=0;i<kazu;i++){
			scanf("%d",&number);
			scanf("%d %d",&data[number-1][1],&data[number-1][2]);
		}
		
		for(i=0;i<4000;i++){
			if(data[i][1]*data[i][2]>=1000000){
				R[kaunto]=data[i][0];
				kaunto++;
			}
		}
		
		kaunto=0;
		while(R[kaunto]!='\0'){
			printf("%d\n",R[kaunto]);
			kaunto++;
		}
		if(R[0]=='\0'){
			printf("NA\n");
		}
		
		kaunto=0;
		
		scanf("%d",&kazu);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

int n,a,b,N;
ll s[4000][2];
string d;

int main(){
    while(cin>>N){
	if(N==0)return 0;
	for(int i=0;i<4000;i++){
	    for(int j=0;j<2;j++){
		s[i][j]=0;
	    }
	}
	int m=0;
	for(int i=0;i<N;i++){
	    cin>>n>>a>>b;
	    int flag=0;
	    for(int j=0;j<m;j++)if(s[j][0]==n){s[j][1]+=(ll)a*b;flag=1;}
	    if(flag==0){s[m][0]=n;s[m][1]=a*b;m++;}
	}
	int flag2=0;
	for(int i=0;i<m;i++)if(s[i][1]>999999){cout<<s[i][0]<<endl;flag2=1;}
	if(flag2==0)cout<<"NA"<<endl;
    }
}

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

int main()
{
	int n,a,b,c;
	while(cin >> n, n)
	{
		vector<int>  v;
		map<int,int> m;

		while(n--)
		{
			cin >> a >> b >> c;
			if(m.insert(pair<int,int>(a,b*c)).second)
			{
				v.push_back(a);
			}
			else
			{
				m[a] += b*c;
			}
		}

		bool f=true;
		for(int i=0; i<v.size(); i++)
		{
			if(m[v[i]]>=1000000)
			{
				f=false;
				cout << v[i] << endl;
			}
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

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

int main(){
  int n,i,p,q,f;
  for(;scanf("%d",&n),n;){
    map<int,int>m;
    vector<int>v;
    for(;n--;){
      scanf("%d%d%d",&i,&p,&q);
      if(m.find(i)==m.end())v.push_back(i);
      m[i]+=p*q;
    }
    for(f=i=0;i<v.size();i++){
      if(m[v[i]]>=1000000)printf("%d\n",v[i]),f=1;
    }
    if(!f)puts("NA");
  }
}

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