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 <stdio.h>

int output[50000];
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");
		}
	}
	
	return 0;
}
void input(int ns){
	int e[4000];
	int p[1000000];
	int q[100000];
	int c[ns];
	
	int i;
	
	for(i=0;i<ns;i++){
		scanf("%d %d %d",&e[i],&p[i],&q[i]);
		c[i] = p[i]*q[i];
	}
	
	int j;
	
	for(i=0;i<ns-1;i++){
		for(j=1;j<ns;j++){
			if(e[i]==e[j]){
				c[i]=c[i]+c[j];
				c[j]=0;
			}
		}
	}
	int ch = 0;
	
	for(i=0;i<ns-1;i++){
		if(c[i]>=1000000){
			output[count]=e[i];
			count++;
			ch = 1;
		}
	}
	if(ch == 0){
		output[count]=0;
		count++;
	}
}

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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int main()
{
    int n; ll en, price, qty, check[4001]={0}; qi que;
    while(cin >> n && n) {
        if (n == 0) break;

        for(int i=0; i < n; ++i) {
            cin >> en >> price >> qty;

            if (check[en] >= 0) {
                check[en] += price*qty;
            }

            if (check[en] >= lim) {
                que.push(en);
                check[en]=-1;
            }
        }

        if (que.empty()) {
            cout << "NA" << endl;
        } else {
            for(int i=0,len=que.size(); i < len; ++i) {
                cout << que.front() << endl;
                que.pop();
            }
        }
    }

    return 0;
}

C++: #include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i!=0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-10000000000000;
                }
        }
        if(c==0)
            printf("NA\n");
        else 
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        memset(N,0L,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#define N 4001
using namespace std;
int main(){

  int n;
  int a,num[N],tanka,uriage,jun[N];
  bool judge;

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

    judge = true;
    for(int i=0;i<N;i++){
      num[i] = 0;
    }

    for(int i=0;i<n;i++){
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
      jun[i] = a;
    }

    for(int i=1;i<N;i++){
      if(num[jun[i]]>=1000000){
	cout << jun[i] << endl;
	judge = false;
      }
    }
    if(judge)
      cout << "NA" << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define vint vector<int>


int main(){
    int n;
    while(1){
        cin>>n;
        if(n==0) break;

        bool f = false;
        rep(i,n) {
            int a,b,c; cin>>a>>b>>c;
            if(b*c >= (int)1e6){
                cout<<a<<endl;
                f = true;
            }
        }
        if(!f) cout<<"NA"<<endl;
    }

    return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){

        long long int mem[4500][3] = {{0}};
        long long int a,x,y;
        long long int cnt = 0;

        for(long long int i = 0;i < n; i++){
            scanf("%lld%lld%lld",&a,&x,&y);
            for(long long int j = 0;j < i; j++){
                if(mem[j][1] != a){
                   cnt++;
                }
                else {
                    mem[j][0] += x*y;
                    break;
                }
            }
            if(cnt == i){
                mem[i][0] += x*y;
                mem[i][1] = a;
                cnt = 0;
            }
        }

        bool flg = 0;
        for(int i = 0;i < n; i++){
            if(mem[i][0] >= 1000000){
                printf("%lld\n",mem[i][1]);
                flg = 1;
            }
        }
        if(flg == 0)printf("NA\n");
    }
    return 0;
}

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

int main(){
  int n;//データ数
  while(cin >> n){
    long long arr[4001];//社員番号
    int selling[n];//販売単科
    int sales[n];//売り上げ数量
    int num;
    int check=0;
    //社員は4000人未満
    memset(arr,0,sizeof(arr));
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin >> num >> selling[i] >> sales[i];
      arr[num]+=selling[i]*sales[i];
    }
    for(int i=0;i<=4000;i++){
      if(arr[i]>=1000000){
        cout << i << endl;
        check++;
      }
    }
    if(check==0)
       cout << "NA" << endl;
    check=0;
  }
}

C++: #include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i!=0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            if(N[x]!=-1){
                N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-1;
                }
            }
        }
        if(c==0)
            printf("NA\n");
        else 
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        memset(N,0L,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
    return 0;
}

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

template<typename itr, typename func>
func for_each_withindex(itr fi, itr l, func f){
	unsigned i{};
	for(; fi!=l; ++fi,++i){
		f(*fi,i);
	}
	return f;
}

int main(int argc, char const* argv[])
{
	unsigned n{};
	while (std::cin >> n,n != 0) {
		unsigned long e{}, p{}, q{};
		bool isna{true};
		std::array<unsigned long,4001> es{};
		for (unsigned i = 0; i < n; i++) {
			std::cin >> e >> p >> q;
				es.at(e) += p * q;
		}
		for_each_withindex(es.begin(), es.end(), [&isna](auto sell,auto e){ 
				if (sell>=1e6) {
				std::cout << e << std::endl;
				isna = false;
				}});
		if (isna) {
			std::cout << "NA" << std::endl;
		}

	}
	return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[4000+5]={0};
 
 int main()
 {
   int n;
   while(cin>>n&&n)
   {
     int count=0;
     map<int,long long int> mm;
     bool flag=false;
     for(int i=0;i<n;i++)
     {
       int id,p,q;
       cin>>id>>p>>q;
       mm[id]+=(p*q);
       if(i==0) arr[count++]=id;
       int j;
       for(j=0;j<count;j++)     
       {
         if(arr[j]==id) break;        
       }   
       if(j==count) arr[count++]=id;
     }           
     for(int i=0;i<count;i++)
     {
       int kk=arr[i];
       if(mm[kk]>=1000000)
       { 
         cout<<arr[i]<<endl;
         flag=true;
       }        
     }
     if(!flag) cout<<"NA"<<endl;
   }
   //while(1);
   return 0;
 }