Problem:
What Color Is The Universe?    On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,        "There are many stars in the space. What color is the universe if I look up it from outside?"  Until he found the answer to this question, he couldn't sleep. After a moment's thought, he proposed a hypothesis,  "When I observe the stars in the sky, if more than half of the stars have the same color, that is the color of the universe."  He has collected data of stars in the universe after consistently observing them. However, when he try to count the number of star, he was in bed sick with a cold. You decided to help him by developing a program to identify the color of the universe.  You are given an array A . Let | A | be the number of element in A , and let N m be the number of m in A . For example, if A = {3, 1, 2, 3, 3, 1, 5, 3}, | A | = 8, N 3 = 4, N 1 = 2, N 5 = 1. Your program have to find m such that:    N m > (| A | / 2 )   If there is no such m , you also have to report the fact. There is no
such m for the above example, but for a array A = {5, 2, 5, 3, 4, 5, 5}, 5 is the answer.  Input  There are several test cases. For each test case, in the first line | A | is given. In the next line, there will be | A | integers. The integers are less than 2 31 and | A | < 1,000,000. The input terminate with a line which contains single 0.  Output  For each test case, output m in a line. If there is no answer, output "NO COLOR" in a line.  Sample Input  8
3 1 2 3 3 1 5 3
7
5 2 5 3 4 5 5
0  Output for the Sample Input  NO COLOR
5

Solution (Python):
import bisect

while(1):
    n=int(raw_input())
    m=n/2+1
    if n==0:
        break
    else:
        S=sorted([int(x) for x in raw_input().split()])
        i=0
        while(i<n):
            s=S[i]
            num=bisect.bisect(S,s)-bisect.bisect_left(S,s)
            if num>=m:
                print s
                break
            else:
                i=bisect.bisect(S,s)
        else:
            print 'NO COLOR'

Solution (Python):
from collections import defaultdict

while True:
    n = int(input())
    if not n:
        break
    stars = defaultdict(int)
    for s in map(int, input().split()):
        stars[s] += 1
    half_n = n // 2
    for i, s in stars.items():
        if s > half_n:
            print(i)
            break
    else:
        print('NO COLOR')

Solution (Python):
while True:
    num=int(input())
    if num==0:
        break
    stars=sorted(input().split())
    if stars.count(stars[num//2]) > num/2 :
        print(stars[num//2])
    else:
        print("NO COLOR")

Solution (Python):
while 1:
    n=int(input())
    if n==0:break
    s=sorted(input().split())
    print(s[n//2] if s.count(s[n//2])>n/2 else 'NO COLOR')

Solution (Python):
while 1:
    nums = int(input())
    if nums != 0:
        d = {}
        stars = list(map(int,input().split()))
        for x in stars:
            if x not in d:
                d[x] = 1
            else:
                d[x] += 1

        key = list(d.keys())
        val = list(d.values())
        m = int(max(val))
        if m > nums/2:
            res = key[val.index(m)]
            print(res)
        else:
            print("NO COLOR")
    else:break

Solution (Python):
while 1:
    nums = int(input())
    if nums != 0:
        d = {}
        stars = list(map(int,input().split()))
        for x in stars:
            if x not in d:
                d[x] = 1
            else:
                d[x] += 1

        key = list(d.keys())
        val = list(d.values())
        m = int(max(val))
        if m > nums/2:
            res = key[val.index(m)]
            print(res)
        else:
            print("NO COLOR")
    else:break

Solution (Python):
while 1:
    nums = int(input())
    if nums != 0:
        d = {}
        stars = list(map(int,input().split()))
        for x in stars:
            if x not in d:
                d[x] = 1
            else:
                d[x] += 1

        key = list(d.keys())
        val = list(d.values())
        m = int(max(val))
        if m > nums/2:
            res = key[val.index(m)]
            print(res)
        else:
            print("NO COLOR")
    else:break

Solution (Python):
while True:
    N = int(input())
    if N == 0:
        break
    A = list(map(int, input().split()))
    A.sort()
    m = 0
    flag = True
    for i in range(N):
        m += 1
        if i == N - 1 or A[i] != A[i + 1]:
            if 2 * m > N:
                print(A[i])
                flag = False
                break
            m = 0
    if flag:
        print("NO COLOR")

Solution (Python):



import sys
from sys import stdin
input = stdin.readline
 	
from collections import Counter
while True:
	n = int(input())
	if n == 0: break
	a = tuple(map(int, input().split()))
	x, w = Counter(a).most_common()[0]
	print(x if w>(n>>1) else "NO COLOR")

Solution (Python):
while True:
    n=input()
    if n==0:break
    A=map(int,raw_input().split())
    A.sort()
    cnt=0
    pre=A[0]
    for c in A:
        if c==pre:
            cnt+=1
            if cnt>n/2:
                print c
                break
        else:
            cnt=1
            pre=c
    else:
        print "NO COLOR"

Solution (Python):
while 1:
	n = input()
	if n == 0: break
	A = sorted(map(int,raw_input().split()))
	c,l = A[0],1
	for i in range(1,n):
		if A[i] == c:
			l += 1
			if l > n/2:
				print c
				break
		else:
			c = A[i]
			l = 1
	else:
		print c if l > n/2 else "NO COLOR"

Solution (Python):
while 1:
    n = input()
    if n == 0: break
    A = sorted(map(int,raw_input().split()))
    c,l = A[0],0
    for i in A:
        if i == c:
            l += 1
            if l > n/2:
                print c
                break
        else:
            c = i
            l = 1
    else:
        print "NO COLOR"

Solution (Python):
while 1:
    n = input()
    if n == 0: break
    A = map(int,raw_input().split())
    A.sort()
    c,l = A[0],0
    for i in A:
        if i == c:
            l += 1
            if l > n/2:
                print c
                break
        else:
            c = i
            l = 1
    else:
        print "NO COLOR"

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    A = map(int, raw_input().split())
    m = {}
    for i in A:
        if i in m:
            m[i] += 1
        else:
            m[i] = 1
    ans = [key for key in m if m[key] * 2 > len(A)]
    print ans[0] if len(ans) > 0 else "NO COLOR"

Solution (Python):
from collections import Counter
while 1:
    N = int(input())
    if N == 0:
        break
    ct = Counter(map(int, input().split()))
    (a, b), *c = ct.most_common()
    if b*2 > N:
        print(a)
    else:
        print("NO COLOR")