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<cstring>
#include<vector>
using namespace std;
long long sales[4010];
#define foreach(r,p,it) for(r::iterator it=p.begin();it!=p.end();++it)

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
        vector<int> shains;
        shains.clear();
    
        memset(sales,0,sizeof(sales));
        long long num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
            int f=0;
            for(int j=0;j<shains.size();j++)
            {
                if(shains[j] == num){f=1;break;}
            }
            if(f==0) shains.push_back(num);
        }
        int na = 0;
        for(int i=0;i<shains.size();i++)
        {
            //cout <<"NUMBER"<<*it <<endl;
            if(sales[shains[i]] >= 1000000){cout<<shains[i]<<endl;na=1;}
        }
        if(na==0)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][2] = {{0}};
        int a,x,y;

        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&a,&x,&y);
            mem[i][0] += x*y;
            mem[i][1] += a;
        }
        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 <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

struct Sales{
	long long int sum;
	int id;
};


int main(){

	int checkTable[4001],index;
	long long int price,amount;
	Sales sales[4001];

	int n,id,count;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 1; i <= 4000; i++){
			sales[i].id = -1;
			sales[i].sum = 0;
			checkTable[i] = -1;	//?????´?????????????????????-1,?????´????????????sales??§?????????????????????
		}

		index = 0;

		for(int i = 1; i <= n; i++){
			scanf("%d %lld %lld",&id,&price,&amount);

			if(checkTable[id] == -1){	//????????´?????´???
				sales[index].id = id;
				sales[index].sum = price*amount;
				checkTable[id] = index;
				index++;
			}else{
				sales[checkTable[id]].sum += price*amount;
			}

		}

		count = 0;

		for(int i = 0; i < index; i++){
			if(sales[i].sum >= 1000000){
				printf("%d\n",sales[i].id);
				count++;
			}
		}
		if(count == 0)printf("NA\n");
	}

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n, a, b, c;
    while(true){
        scanf("%d", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%d%lld%lld", &a, &b, &c);
            if(b*c>=1000000){
                na = false;
                printf("%d\n", &a);
            }
        }
        if(na) puts("NA");
    }
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	int number[4000]={0};
	int tanka;
	int ryou;
	long long goukei[4000]={0};
	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 <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(){
	int n,a,b,c,flag;
	map<int, int> m;
	while (cin >> n, n){
		m.clear();
		flag = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> c;
			m[a] += b * c;
		}
		map<int, int>::iterator it = m.begin();
		while (it != m.end()){
			if ((*it).second >= 1000000){
				flag = 1;
				cout << (*it).first << endl;
			}
			it++;
		}
		if (!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n;
	int number[4000]={0};
	int tanka;
	int ryou;
	long long goukei[4000]={0};
	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 <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int i,j,k,l;
    int n;
    long long id,cost,qty;
    long long data_list[10000];
    int id_list[10000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        fill(data_list,data_list+10000,0);
        k=0;
        for(l=0;l<n;l++){
            data_list[id]+=(cost*qty);
            cin>>id>>cost>>qty;
            id_flag=true;
            for(i=0;i<=k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

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[10];

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