Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        map<int, long long> info;
        map<int, long long>::iterator it;
        rep(i,n){
            int a, b, c;
            cin >> a >> b >> c;
            info[a] += b * c;
        }
        bool c = true;
        for(it = info.begin(); it != info.end(); it++){
            if(it->second >= 1000000){
                cout << it->first << endl;
                c = false;
            }
        }
        if(c) cout << "NA" << endl;
    }
}

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

class meb{
public:
	int num;
	unsigned long long tanka;
	unsigned long long count;
	unsigned long long sum;
};

int main(){
	int n;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int n;
ll need = 1000000;

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		
		map<ll, ll> sum;
		set<ll> ids;
		for (int i = 0; i < n; i++) {
			ll id, p, q; cin >> id >> p >> q;
			ids.insert(id);
			sum[id] += (p * q);
		}
		
		bool na = true;
		set<ll>::iterator it;
		for (it = ids.begin(); it != ids.end(); it++) {
			if (sum[(*it)] >= need) {
				cout << (*it) << endl;
				na = false;
			}
		}
		
		if (na) cout << "NA" << endl;
	}
	
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define ll long long

int main()
{
    while (1)
    {
	int n,id,f=0;
	ll price,num;
	cin >> n;
	if (n==0)break;
	rep(i,n)
	{
	    cin >> id >> price >> num;
	    if (price*num >= 1000000)
	    {
		cout << id << endl;
		f=1;
	    }
	}
	if (f==0)cout << "NA" << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,e,p,q,x[4001],X[1001],cnt,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		cnt=0;
		for(i=0;i<=4000;i++) x[i]=0;
		for(i=0;i<n;i++){
			scanf("%d%d%d",&e,&p,&q);
			if(x[e]>=1000000) x[e]=-1;
			if(x[e]!=-1){
				x[e]+=p*q;
			}
			if(x[e]>=1000000){
				cnt++;
				X[cnt]=e;
			}
		}
		if(cnt>0){
			for(i=1;i<=cnt;i++){
				printf("%d\n",X[i]);
			}
		}
		else printf("NA\n");
	}
	return 0;
}

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

using namespace std;

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

        vector<int> bangoulist;
        map<int,long> alldata;
        alldata.clear();
        for(int i=0;i<n;i++){
                int bangou,tanka,num;
                scanf(" %d %d %d",&bangou,&tanka,&num);
                if(alldata[bangou]!=0){
                        alldata[bangou]+=tanka*num;
                }else{
                        bangoulist.push_back(bangou);
                        alldata[bangou]=tanka*num;
                }
        }
        bool flag=true;
        for(int i=0;i<(int)bangoulist.size();i++){
                if(alldata[bangoulist[i]]>=1000000){
                        cout<<bangoulist[i]<<"\n";
                        flag=false;
                }
        }
        if(flag)cout<<"NA\n";
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    long long bangou,tanka,kosuu;
    long long number; cin >> number;
    long long kuso[number];
    do{
        long long man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            kuso[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
            kuso[i]=bangou;
        }
        int count =0;
        if(man[kuso[0]-1]>=1000000){
            cout << kuso[0] << endl;
            count++;
        }
        for(int i=1;i<number;i++){
            int tmp =0;
            for(int j=0;j<i;j++){
                if(kuso[i]!=kuso[j]){
                    tmp++;
                    break;
                }
            }
            if(tmp==0 && man[kuso[i]-1]>=1000000){
                cout << kuso[i] << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

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

int main()
{
	int em[40000];
	int num,i,id,p,q,flag;
	cin>>num;

	while(num!=0){
    flag =0;

	for(i=0;i<40000;i++){
		em[i]=0;
	}

	for(i=0;i<=num-1;i++){
	    cin>>id >>p >>q;
		em[id]+=p*q;
	}

	for(i=0;i<40000;i++){
		if(em[i]>=1000000){
			cout<<i<<"\n";
		    flag =1;
		}
	}
	if(flag!=1)
		cout<<"NA\n";
	cin >>num;

	}
	return 0;
		
}

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

typedef pair<int,int> P; //社員番号、売上

int main(void)
{
	int n;

	while(cin >> n,n){
		vector<P> d;
	
		int no,m,k;
		bool f = false;

		for(int i = 0; i < n; i++){
			cin >> no >> m >> k;
			
			int j;
			for(j = 0; j < d.size(); j++){
				if(d[j].first == no){
					d[j].second += m*k;
				}
			}

			if(j == d.size()){
				d.push_back(P(no,m*k));
			}
		}
		int j;
		for(j = 0; j < d.size(); j++)
			if(d[j].second >= 1000000){
				f = true;
				break;
			}
		if(!f)
			cout << "NA" << endl;

		else{
			for(j = 0; j < d.size(); j++)
				if(d[j].second >= 1000000){
					cout << d[j].first << 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>0){
			cin >> e >> p >> q;
			if (p*q > 1000000){
				ans[x] = e;
				x++;
			}
			N--;
		}
		if (ans[0] == 0){ cout << "NA" << endl; }
		else for (int i = 0; i < N; i++)
		{
			if (ans[i] == 0)break;
			cout << ans[i] << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

int main(void) {

  int n;

  int id,unit,amount;

  int i,flag;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    flag=0;

    for(i=0;i<n;i++) {

      scanf("%d %d %d",&id,&unit,&amount);

      if(unit*amount>=1000000) {

	printf("%d\n",id);

	flag=1;

      }

    }

    if(flag==0) printf("NA\n");

  }

  return 0;

}