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<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		long long y[4000] = { 0 };
		vector<int>l;
		for (int i = 0; i < n; i++){
			int a;
			long long b, c;
			cin >> a >> b >> c;
			y[a] += b * c;
			if (find(l.begin(),l.end(), a) == l.end())l.push_back(a);
		}
		vector<int>ll;
		for (long long i: l) {
			if (y[i] >= 1000000)ll.push_back(i);
		}
		sort (l.begin(), l.end());
		if (ll.size() == 0)cout << "NA" << endl;
		else for (int i:ll){
			cout << i << endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	int number[5000];
	int tanka;
	int ryou;
	long long goukei[5000];
	while(cin>>n&&n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka;
			cin>>ryou;
			goukei[i]=tanka*ryou;
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					if(goukei[i]>=1000000)goukei[i]=1000000;
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include "stdio.h"
#include "string.h"
int N[4001],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,0,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
int main(){
int n;
while(cin>>n,n){
long ta[5000]={0};int x[5000]={0};
int cnt=0,a,b,c;
	for(int i=0;i<n;i++){
	cin>>a>>b>>c;
	ta[a]+=b*c;
	bool f=1;
	for(int j=0;j<i;j++)if(x[j]==a)f=0;
	if(f)x[cnt++]=a;
	}
	bool f=1;
	for(int i=0;i<n;i++){
	//cout<<x[i]<<" "<<ta[x[i]]<<endl;
	if(ta[x[i]]>=1000000){cout<<x[i]<<endl;f=0;}
	}
	if(f)cout<<"NA"<<endl;
}
	return 0;
}

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

int main(){
   int n,i,flag;
   int num[5000],pz[5000],kazu[5000];
   for(;;){
      cin>>n;
      if(n==0) break;
      
      flag=0;
      for(i=0;i<n;i++) cin>>num[i]>>pz[i]>>kazu[i];
      
      for(i=0;i<n;i++){
         if(pz[i]*kazu[i]>=1000000){
            cout<<num[i]<<endl;
            flag=1;
         }
      }
      if(flag!=1)
         cout<<"NA"<<endl;
   }
   return 0;
}

C++: #include<iostream>
using namespace std;
int ans[4000];

int main(){
	int N;
	int e, p, q;
	int x;
	while (1){
		x = 0;
		cin >> N;
		if (N == 0){ break; }
		while (N){
			cin >> e >> p >> q;
			cout << N<<x << endl;
			if (p*q >= 1000000){
				ans[x] = e;
				x++;
			}
			N--;
		}
			for (int i = 0; i < N; i++)
			{
				if (i == 0 && ans[i] == 0)cout << "NA" << endl;
				if (ans[i] == 0){ break; }
				cout << ans[i] << endl;
			}
	}
	return 0;
}

C++: // a.c.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
int main(void){
	int n;
	int ban, tan, suu;
	long long int bango[4001];
	int flg,i;
	while (1){
		for (i = 1; i <= 4000; i++){
			bango[i] = 0;
		}
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &ban, &tan, &suu);
			bango[ban] += tan*suu;
		}
		flg = 0;
		for (i = 1; i <= 4000; i++){
			if (bango[i]>=1000000){
				printf("%d\n", i);
				flg = 1;
			}
		}
		if (!flg){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main() {
	long long n,i,p,q;
	while(cin>>n,n){
		vector<int> ids;
		map<int,long long> m;
		while(n--){
			cin>>i>>p>>q;
			if(!m.count(i))ids.push_back(i);
			m[i]+=p*q;
		}
		int na=1;
		for (int k=0;k<(int)ids.size();++k) {
			if(1000000<=m[ids[k]]){
				cout<<ids[k]<<endl;
				na=0;
			}
		}
		if(na) cout<<"NA\n";
	}
}

C++: #include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;
void shoki();
void henkan(string);
int tansaku(int);
pair<string,long long> num[10000];
int n,ban,tanka,kazu,i,j,memo;
bool dp[10000]={false};
int main(){
	int al=0;
	bool y=false;
	while(1){
		shoki();
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>num[i].first>>tanka>>kazu;
			henkan(num[i].first);
			if(dp[memo]==true){
				num[tansaku(i)].second+=tanka*kazu;
			}
			else{
			num[i].second+=tanka*kazu;
			}
			dp[memo]=true;
			memo=0;
		}
		for(int k=0;k<=i;k++){
			if(num[k].second==0){
				continue;
			}
			if(num[k].second>=1000000){
				y=true;
				cout<<num[k].first<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
		memset(dp,false,sizeof(dp));
	}
	return 0;
}
void shoki(){
	for(int i=0;i<4001;i++){
		num[i].first="0";
		num[i].second=0;
	}
	return;
}
void henkan(string str1){
	long long kake=1;
	for(int i=0;i<str1.size();i++){
		memo+=str1[i]*i;
		i*=10;
	}
	return;
}
int tansaku(int rec){
	int res;
	for(int l=0;l<rec;l++){
		if(num[rec].first==num[l].first){
			return res=l;
		}
	}
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void){
  int i, j, c, num, data;
  int staff[4000], n, value;
  int state[4000], state_n;
  char buf[8];

  while(1){
    num = j = 0;
    while((c = getchar()) != '\n'){
      buf[j++] = c;
      if(j == 1 && c == '0') break;
    }
    buf[j] = '\0';
    num = atoi(buf);
    if(num == 0) break;

    for(i = 0; i < 4000; i++){
      staff[i] = 0;
      state[i] = 0;
    }
    state_n = 0;

    for(i = 0; i < num; i++){
      data = j = 0;
      while((c = getchar()) != '\n'){
        buf[j] = c;
        if(c == ' ' && data == 0){
          buf[j] = '\0';
          n = atoi(buf);
          j = 0;
          data++;
          continue;
        }
        if(c == ' ' && data == 1){
          buf[j] = '\0';
          value = atoi(buf);
          j = 0;
          data++;
          continue;
        }
        j++;
      }
      buf[j] = '\0';
      staff[n-1] += atoi(buf) * value;
      if(staff[n-1] >= 1000000 && state[n-1] == 0){
        state[n-1] = ++state_n;
      }
    }

    if(state_n == 0){
      printf("NA\n");
    }
    for(j = 1; j <= state_n; j++){
      for(i = 0; i < 4000; i++){
        if(state[i] == j){
          printf("%d\n", i+1);
        }
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0)
			break;
		int c[4001]={} , id[100000];
		for (int i=0; i<n; i++){
			int p , q;
			cin >> id[i] >> p >> q;
			c[id[i]] += p*q;
		}
		bool f=1;
		for (int i=0; i<n; i++){
			if (c[id[i]]>=1000000){
				cout << id[i] << endl;
				c[id[i]]=0;
				f=0;
			}
		}
		if (f)
			cout << "NA" << endl;

	}

	return 0;
}