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

C++: #include <iostream>
#define FOR(i,a,b) for(int i=(a); i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

int main(){
  int n;//入力するデータ
  int check;
  while(cin >> n){
    if(n==0) break;
    check=0;
    ll num[4001]={0};//社員の売り上げ金額
    bool bl[4001]={false};
    ll t[4001]={0};//社員番号
    ll emp,cost,count;
    int k=0;
    REP(i,n){
      cin >> emp >> cost >> count;
      if(bl[emp]==false){
        bl[emp]=true;
        t[k++]=emp;
        num[emp] = cost*count;
      }
      else{
      num[emp] += cost * count;
      }
    }
    REP(i,n){
      if(num[t[i]] >= 1000000){
        cout << t[i] << endl;
        check++;
  }
    }
    if(check==0)
      cout << "NA" << endl;
  }
}

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("%d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint lin(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	list<int> staffList;
	map<int, lint> saleResult;
	int n;
	int staffNum;
	lint unitPrice;
	lint quantity;
	while( 1 )
	{
		n = in();
		if( n == 0 )break;

		staffList.clear();
		saleResult.clear();
		loop(i, 0, n)
		{
			staffNum = in();
			unitPrice = lin();
			quantity = lin();
			staffList.push_back(staffNum);
			saleResult[staffNum] += unitPrice * quantity;
		}
		bool flag = false;
		for(list<int>::iterator it = staffList.begin(); it != staffList.end(); it++)
		{
			if( saleResult[*it] >= 1000000 )
			{
				printf("%d\n", *it);
				saleResult[*it] = 0;
				flag = true;
			}
		}
		if( !flag )
		{
			cout << "NA" << endl;
		}
	}
	return (0);
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	int a,b,c,d;
	int num[4001],tan[4001],data[4001];
	bool flag=false;
	while(1){
		for(a=0;a<=4000;a++){
			data[a]=0;
			num[a]=0;
			tan[a]=0;
		}
		flag=false;
		cin >> n;
		if(n==0)break;
		for(a=1;a<=n;a++){
			cin >> b >> c >> d;
			if(num[b]>0)data[a]=b,num[a]=c,tan[a]=d;
		}
		for(a=1;a<=n;a++){
			if(num[a]*tan[a]>=1000000)printf("%d\n",data[a]),flag=true;
		}
		if(flag==false)printf("NA\n");
	}
	return 0;
}

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

using namespace std;

vector<int> erase_equal(vector<int> v) {
	vector<int> result;
	map<int, bool> mp;
	for (int i = 0; i < v.size(); i++) {
		auto itr = mp.find(v[i]);
		if (itr == mp.end()) {
			mp[v[i]] = true;
			result.push_back(v[i]);
		}
	}
	return result;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		map<int, int> sales;
		vector<int> ids(n);
		for (int i = 0; i < n; i++) {
			int id;
			int sale_val;
			int sale_num;
			cin >> id;
			cin >> sale_val;
			cin >> sale_num;

			ids.push_back(id);
			auto itr = sales.find(id);
			if (itr != sales.end()) {
				sales[id] += sale_val * sale_num;
			} else {
				sales[id] = sale_val * sale_num;
			}
		}

		vector<int> v = erase_equal(ids);
		bool na_flag = true;
		for (int i = 0; i < v.size(); i++) {
			if (sales[v[i]] >= 1000000) {
				cout << v[i] << endl;
				na_flag = false;
			}
		}
		if (na_flag) {
			cout << "NA" << endl;
		}
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n, sum;
	
	while(1)
	{
		sum = 0;
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++)
		{
			int no, x, y;
			cin >> no >> x >> y;
			if(x * y >= 1000000)
			{
				cout << no << endl;
				sum++;
			}
		}
		if(sum == 0) cout << "NA" << endl;
	}
}

C++: #include<cstdio>

int main(){
int a,i,fl;
unsigned long int b,c;
while(1){
scanf("%d",&i);
fl=0;
for(int j=0;j<i;j++){


 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%d",&b);
 scanf("%d",&c);
if(a*c>=1000000) {
 fl=1;
 printf("%d\n",a);
}
if(fl==false) pritnf("NA\n");
}
}
}

C++: #include <stdio.h>

int output[49000];
int count=0;

void input(int);
int main(void){
	int n,i;
	while(true){
		scanf("%d",&n);
		if(n>0){
			input(n);
		}else{
			break;
		}
	}
	for(i=0;i<count;i++){
		if(output[i]!=0){
			printf("%d\n",output[i]);
		}else{
			printf("NA\n");
		}
	}
}
void input(int n){
	int nb = n;
	
	int e[n];
	int p[n];
	int q[n];
	int c[n];
	
	int i;
	
	for(i=0;i<n;i++){
		scanf("%d",&e[i]);
		scanf("%d",&p[i]);
		scanf("%d",&q[i]);
		c[i] = p[i]*q[i];
	}
	
	int j;
	
	for(i=0;i<n-1;i++){
		for(j=1;j<n;j++){
			if(e[i]==e[j]){
				c[i]=c[i]+c[j];
				c[j]=0;
			}
		}
	}
	int ch = 0;
	
	for(i=0;i<n-1;i++){
		if(c[i]>=1000000){
			output[count]=e[i];
			count++;
			ch = 1;
		}
	}
	if(ch == 0){
		output[count]=0;
		count++;
	}
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
long int shineU[SHINE_MAX];	//?£??????????

int num,tanka,suryo;
int i;

int main(){
	white(1){
	 cin>>shineN;
	 if(shineN==0){break;}
	 for(i=0;i<SHINE_MAX;i++){shineU[i]=0;}
	 for(i=0;i<shineN;i++){
	  cin>>num,tanka,suryo;
	  shineU[num-1]+=tanka*suryo;
	 }
	 //??¨?????????????????¨
	 eliteN=0;
	 for(i=0;i<SHINE_MAX && eliteN<shineN;i++){
	  if(ELITE<=shineU[i]){
	   cout<<i<<endl;
	   eliteN++;
	  }
	 }
	 if(eliteN==0){cout<<AHO<<endl;}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int employees[4001];
bool checked[4001];

int main()
{
	int n;
	while (cin >> n, n) {
		for (int i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<int> ans;

		for (int i = 0; i < n; ++i) {
			int num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

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