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: 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 sorted(sales.items(), key=lambda x: x[1][0]):
        if v[1] >= 1000000:
            print(k)
            t = 1
    if t == -1:
        print("NA")

Python: import sys

while True:
    n=int(input())
    score={}
    if n==0:
        sys.exit()
    for _ in range(n):
        e,p,q=[int(i) for i in input().split(" ")]
        score[e]=score.get(e,0)+p*q

    employee=[]
    for e in score:
        if score[e]>=1000000:
            employee.append(e)

    if len(employee)==0:
        print("NA")
    else:
        for e in employee:
            print(e)

Python: while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:
      print(a)
      f=0
  if f:print('NA')

Python: while True:
    n = int(input())
    if n == 0:
        break
    data = [0] * 4001
    for _ in range(n):
        e, p, q = map(int, input().split())
        data[e] += p*q
        
    for i in range(1, 4001):
        if data[i] >= 1000000:
            print(i)

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

    rs = {}
    for i in range(n):
        arr = [int(x) for x in input().split(' ')]
        s = arr[1] * arr[2]
        rs[arr[0]] = (rs.get(arr[0]) or 0) + s

    top = [k for k, v in rs.items() if v > 1000000 ]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)

Python: import sys
from collections import OrderedDict
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    while True:
        n = int(sys.stdin.readline())
        if n==0 :
            break
        emps = OrderedDict()
        for i in range(n):
            no,price,amount = map(int,sys.stdin.readline().split(' '))
            emps[no]=emps.get(no,0)+price*amount
        results = [k for k,v in emps.items() if v>=1000000]
        if len(results) > 0:
            [print(emp) for emp in results]
        else:
            print("NA")
solve()

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

    rs = {}
    for i in range(n):
        cid, p, q = map(int, input().strip().split(' '))
        rs[cid] = (rs.get(cid, None) or 0) + p * q

    top = [k for k, v in rs.items() if v >= 1000000]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)

Python: #!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []
    for s in shain:
        if not(s[0] in slist):slist.append(s[0])
    newslist = [[x, 0] for x in slist]
    score = []
    for s in shain:
        newslist[slist.index(s[0])][1] += s[1]
    
    flag = False
    for n in newslist:
        if n[1] >= 1000000:
            print(n[0])
            flag = True
    if not flag:print('NA')

Python: while True:
    n = int(input())
    if n == 0:
        break
    data = [0] * 4001
    for _ in range(n):
        e, p, q = map(int, input().split())
        data[e] += p*q

    flag = True
    for i in range(1, 4001):
        if data[i] >= 1000000:
            print(i)
            flag = False
    if flag:
        print("NA")

Python: while 1:
 a={};b=1
 n=int(input())
 if n==0:break
 for _ in[0]*n:
  e,p,q=map(int,input().split())
  a.setdefault(e,0);a[e]+=p*q
 for e in a:
  if a[e]>=1e6:print(e);b=0
 if b:print('NA')

Python: while(True):
    n = int(input())
    if n==0: break
    d = {}
    c = 0
    l = list()
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] += p*q
        else:
            d[id_] = p*q
            l.append(id_)
    for i in l:
        if d[i] >= 1000000:
            print(i)
            c += 1
    if c == 0:
        print('NA')

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys


def solve(data):
    result = []
    total_sales = [0 for _ in range(4000+1)]
    for id, unit_price, quantity in data:
        total_sales[id] += unit_price * quantity
    for i, sales in enumerate(total_sales):
        if sales >= 1000000:
            result.append(i)
    return result


def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])

    while True:
        num = int(input().strip())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().strip().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while(True):
    n = int(input())
    if n==0: break
    d = {}
    c = 0
    l = list()
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] += p*q
        else:
            d[id_] = p*q
            l.append(id_)
    for i in d:
        if d[i] >= 1000000:
            print(i)
            c += 1
    if c == 0:
        print('NA')

Python: while True:
    num=int(input())
    if num==0:
        break
    else:
        d={}
        for i in range (num):
            info=list(map(int,input().split()))
            try:
                d[info[0]]+=info[1]*info[2]
            except:
                d[info[0]]=info[1]*info[2]
    answer=[]
    for i in d.keys():
        if d[i] >=1000000:
            answer.append(i)
    answer=sorted(answer)
    if answer==[]:
        print("NA")
    else:
        for i in answer:
            print(i)

Python: while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    d=int(b)*int(c)
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:
      print(a)
      f=0
  if f:print('NA')