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")
		}
	}
}

Python: from collections import OrderedDict

while True :
    n = int(input())
    if n == 0 : break
    
    box = OrderedDict()
    for _ in ([None]*n) :
        e, p, q = map(int, input().split())
        if e in box : box[e] += p * q
        else        : box[e]  = p * q
    
    check = 0
    for _ in box :
        if box[_] >= (10**6) :
            print(_)
            check = 1
    if check == 0 : print('NA')

Python: while True:
    n=int(input())
    if n==0:break
    res=[0 for i in range(4000)]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
    flag=False
    for i in range(4000):
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")

Python: e=[]
while 1:
  l=[list(map(int,input().split())) for i in range(int(input()))]
  if not l:break
  d={}
  for i in l:
    if i[0] not in d:
      d[i[0]]=i[1]*i[2]
    else:
      d[i[0]]+=i[1]*i[2]
  e.append(d)
f=0
for i in e:
  f=0
  for j in i.items():
    if j[1]>=1000000:
      print(j[0])
      f=1
  if not f:
    print("NA")

Python: num=int(input())
emp=[]
cnt=0
for i in range(num):
    emp.append(num)
    emp[i]=[int(k) for k in input().split()]
for i in range(num):
    for q in range(i+1,num):
        if emp[i][0]==emp[q][0]:
            emp[i][1]=emp[i][1]+emp[q][1]
            emp[i][2]=emp[i][2]+emp[q][2]
            emp[q][1],emp[q][2]=0,0
    if emp[i][1]*emp[i][2]>=1000000:
        print(emp[i][0])
        cnt+=1
if cnt==0:
    print('NA')

Python: num=int(input())
emp=[]
cnt=0
for i in range(num):
    emp.append(num)
    emp[i]=[int(k) for k in input().split()]
for i in range(num):
    for q in range(i+1,num):
        if emp[i][0]==emp[q][0]:
            emp[i][1]=emp[i][1]+emp[q][1]
            emp[i][2]=emp[i][2]+emp[q][2]
            emp[q][1],emp[q][2]=0,0
    if emp[i][1]*emp[i][2]>=1000000:
        print(emp[i][0])
        cnt+=1
if cnt==0:
    print('NA')

Python: list = []

while (True):
    n = int(input())
    if (n == 0):
        break

    isNA = True

    for i in range(n):
        ds = input().split()
        e = ds[0]
        p = int(ds[1])
        q = int(ds[2])

        sales = p * q

        if (1000000 <= sales):
            list.append(e)
            isNA = False

    if isNA:
        list.append("NA")

for l in list:
    print("%s" % l)

Python: while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    sep = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        if i in d:
            d[i] += p*q
        else:
            d[i] = p*q
            sep.append(i)
    tmp = list(filter(lambda x: x[1] >= 1000000, d.items()))
    if len(tmp):
        for s in sep:
            if s in tmp:
                print(s)
    else:
        print("NA")

Python: while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(int, input().split()))
        ID = ipq[0]
        pq = ipq[1] * ipq[2]
        if ID in sales:
            sales[ID][1] += pq
        else:
            sales[ID] = [ID, pq]
    t = -1
    for k, v in sales.items():
        if v[1] >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Python: while True:

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(0,data_num,1):
        print("datanum = {0}".format(data_num))

        a,b,c = map(int,input().split())

        Earnings = b * c
        
        if Earnings >= 1000000:
            print(a)
            nice_syatiku += 1

    if nice_syatiku == 0:
        print("NA")

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        vector<int> ord;
        map<int, int> total;
        int m, x, y;
        LOOP(n){
            cin >> m >> x >> y;
            if(!EXIST(ord, m)) ord.PB(m);
            total[m] += x*y;
        }
        bool f=true;
        EACH(ord, it)if(total[*it]>=1000000){
            f = false;
            cout << *it << endl;
        }
        if(f)cout << "NA" << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void){
    int n,i,j,k=0,l=0,x,y,z;
    int a[4001]={0};
    long long b[4001]={0};
    int c[4001]={0};
    int flag[4001]={0};
    int flag2[4001]={0};
    for(;;){
        k=0;
        for(j=0;j<n;j++){
            a[j]=0;
            b[j]=0;
            flag[j]=0;
            x=0;
            c[j]=0;
            }
        scanf("%d",&n);
        if(n==0)break;
        k=1;
        for(i=0;i<n;i++){
            scanf("%d",&x);
            scanf("%d",&y);
            scanf("%d",&z);

            if(flag[x]==1)i--;
            else {
                b[x]=b[x]+y*z;
                a[i] = x;
                flag2[i]=1;


                }
            }
            if(b[x]>=1000000){

                flag[x]=1;

                k++;
            }



        if(k!=1){
            for(l=0;l<n;l++){
                if(flag2[l]==1&&flag[a[l]]==1){
                    printf("%d\n",a[l]);
                }
            }
        }
        else if(k==1){
                printf("NA\n");

            }
        }

return 0;
}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        int id, p, q;
        bool flag = false;
        long long workers[4000] = {0};
        for (int i = 0; i < n; i++) {
            cin >> id >> p >> q;
            workers[id] += p * q;
        }

        for (int i = 0; i < 4000; i++) {
            if (workers[i] >= 1000000) {
                cout << i << endl;
                flag = true;
            }
        }
        if (!flag)
            cout << "NA" << endl;
    }

    return 0;
}