Problem:


Score : 300 points

Problem Statement

There are N integers written on a blackboard. The i-th integer is A_i.

Takahashi will repeatedly perform the following operation on these numbers:

Select a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.

Then, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.

Determine whether it is possible to have only one integer on the blackboard.

Constraints

2 ≦ N ≦ 10^5

1 ≦ A_i ≦ 10^9

A_i is an integer.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 … A_N

Output

If it is possible to have only one integer on the blackboard, print YES. Otherwise, print NO.

Sample Input 1

3
1 2 3

Sample Output 1

YES

It is possible to have only one integer on the blackboard, as follows:

Erase 1 and 3 from the blackboard, then write 4. Now, there are two integers on the blackboard: 2 and 4.

Erase 2 and 4 from the blackboard, then write 6. Now, there is only one integer on the blackboard: 6.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

NO



Sample input:
3
1 2 3


Sample output:
YES

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
Even = []
Odd = []
A.sort()
for a in A:
    if a % 2 == 0:
        a.append(Even)
    if a % 2 == 1:
        a.append(Odd)
if len(Odd) % 2 == 1:
    print('NO')
else:
    print('YES')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
odd = 0
for i in range(n):
    if a[i]%2==1:
        odd+=1
if odd%2==0:
    print('YES')
else:
    pritn('NO')

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
odd = [a for a in A if a%2]

if odd%2:
  print('NO')
else:
  print('YES')

Submission status: Runtime Error

Solution code:
if __name__ == "__main__"
    if (input() % 2) == 0
        print ("NO")
    else
        print("YES")

Submission status: Runtime Error

Solution code:
if (input() % 2) == 0
    print ("NO")
else
    print("YES")

Submission status: Runtime Error

Solution code:
import sys
sys.stdin.readline()
count = 0
a_list = list(map(int, sys.stdin.readline().split()))
for a in x_list:
  count += a%2

print("YES") if count%2==0 else print("NO")

Submission status: Runtime Error

Solution code:
import sys
input_ = sys.stdin.readline
input_()
x_list = list(map(int, input_().split()))
for x in x_list:
  if x%2==0:
    a += 1

if a%2==0:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
odd=0
for x in a:
    if a%2==1:
        odd+=1
if odd%2==1:
    print('NO')
else:
    print('YES')

Submission status: Runtime Error

Solution code:
a = int(input())
x= list(map(int, input().split()))

for i in x:
    if i%2!=0:
        s+=1
if s%2==0:
    print("YES")
else:print("NO")

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

odd = len(list(filter(lambda x: x % 2 != 0, A)))
even = N - odd

ans = "YES"


if odd == 1 and even == 0:
    odd = odd
elif odd % 2 == 1:
    ans = "NO"
else:
    even += odd//2
    while True:
        if even == 1:
        if even % 2 == 1:
            ans = "NO"
            break
        even //= 2
print(ans)

Submission status: Runtime Error

Solution code:
f=lambda x:int(x)%2
n=int(input())
a=list(map(f,input().split())).count(1)
print([YNEOS][n>1 and a%2>0::2])

Submission status: Runtime Error

Solution code:
f=lambda x:int(x)%2
n=int(input())
a=list(map(f,input().split())).count(1)
print([YNEOS][n>1 and a%2>0::2]

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int, input().split()))
a=[i%2 for i in a]
b=a.count(1)
anb,b=a.count(0)+b//2,b+b//2
if an%2+b%2==1:print('YES')
else:print('NO')

Submission status: Runtime Error

Solution code:
s=input().split()
i=0
count=0
while i<n:
  if int(s[i])%2!=0:
    count+=1
  i+=1
if count%2==0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

cnt = 0 
for x in A:
  if A%2 == 1:
    cnt += 1
    
if cnt % 2 == 0:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
input();print('YNEOS'[eval(input().replace(' ','^'))&1::2])

Submission status: Runtime Error

Solution code:
input();print('YNEOS'[eval(input().replace(' ','^'))::2])

Submission status: Runtime Error

Solution code:
def main10():
    buf = int(input(""));
    strbuf = input("");
    strbufs = strbuf.split();
    buf2 = [];
    for i in range(buf):
        buf2.append(int(strbufs[i]));
    if len(buf2) == 1:
        return("YES");
    else:
        ki = 0;
        for i in range(buf):
            if buf2 % 2 == 1:
                ki += 1;
        if ki % 2 == 0:
            print("YES");
        else:
            print("NO");



if __name__ == '__main__':
    main10()

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
even_cnt=0
odd_cnt=0
for i in a:
    if i%2==0:
        even_cnt+=1
    else:
        odd_cnt+=1
if 1<=odd_cnt:
    even_cnt+=odd_cnt//2　#奇数から偶数になったもの数
    odd_cnt=odd_cnt%2 
    even_cnt=even_cnt%2
    if even_cnt==1 and odd_cnt==1:
        print("NO")
    else:
        print("YES")
else:
    print("YES")

#考察
#奇数の和も偶数の和も偶数なので、奇数の数を減らせばよい。

Submission status: Runtime Error

Solution code:
n = int(input().strip())
a = [int(x) for x in input().strip().split()]
flg = [-1 for i in range(n)]
b = []
l = [[] for i in range(n)]
for i in range(n - 1):
  b.append([int(x) - 1 for x in input().strip().split()])
for x in b:
  l[x[0]].append(x[1])
  l[x[1]].append(x[0])
 
while True:
  minimum = a[0]
  idx = []
  for i, x in enumerate(a):
    if flg[i] != -1 or x > minimum:
      continue
    if x < minimum:
      minimum = x
      idx =[i]
    else:
      idx.append(i)
  while True:
    w = []
    for i in idx:
      flg[i] = 0
      for x in l[i]:
        if flg[x] == -1 and a[x] != a[i]:
          flg[x] = 1
          w.append(x)
    idx = []
    for i in w:
      for x in l[i]:
        if flg[x] == -1:
          flg[x] = 0
          for y in l[x]:
            if flg[y] == -1 and a[x] > a[y]:
              flg[x] = -1
              break
          if flg[x] == 0:
            idx.append(x)
    if len(idx) == 0:
      break
  if -1 not in flg:
    break

sep = ''
s = ''
for i, x in enumerate(flg):
  if x == 1:
    s += sep + str(i + 1)
    sep = ' '

print(s)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)


def main():
    # 入力処理
    L1 = input()
    L2 = input()
    N = int(L1)
    As = [int(x) for x in L2.split()]

    print("N={}, As={}".format(N, As),
          file=sys.stderr)

    # アルゴリズム本体
    even = [A % 2 == 0 for A in As]
    N_even = sum(even)
    N_odd = N - N_even

    print("N_even:{}, N_odd:{}".format(N_even, N_odd),
          file=sys.stderr)

    results = list(explore(N_even, N_odd))
    print(results,
          file=sys.stderr)

    # 出力
    if any(results):
        print('YES')
    else:
        print('NO')


def explore(N_even, N_odd):
    # 再帰終了
    if N_even in (0, 1) and N_odd in (0, 1):
        if N_even == 0:
            raise Exception("Unbelievable!!")
        else:
            if N_odd == 0:
                yield True
            else:
                yield False

    # もう１段潜る
    else:
        if N_even >= 2:
            yield from explore(*process(N_even, N_odd, 'even'))
        if N_odd >= 2:
            yield from explore(*process(N_even, N_odd, 'odd'))


def process(N_even, N_odd, target):
    # １ターン分の処理
    if target == 'even':
        return N_even - 1, N_odd
    elif target == 'odd':
        return N_even + 1, N_odd - 2


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys


def main():
    # 入力処理
    L1 = input()
    L2 = input()
    N = int(L1)
    As = [int(x) for x in L2.split()]

    print("N={}, As={}".format(N, As),
          file=sys.stderr)

    # アルゴリズム本体
    even = [A % 2 == 0 for A in As]
    N_even = sum(even)
    N_odd = N - N_even

    print("N_even:{}, N_odd:{}".format(N_even, N_odd),
          file=sys.stderr)

    results = list(explore(N_even, N_odd))
    print(results,
          file=sys.stderr)

    # 出力
    if any(results):
        print('YES')
    else:
        print('NO')


def explore(N_even, N_odd):
    # 再帰終了
    if N_even in (0, 1) and N_odd in (0, 1):
        if N_even == 0:
            raise Exception("Unbelievable!!")
        else:
            if N_odd == 0:
                yield True
            else:
                yield False

    # もう１段潜る
    else:
        if N_even >= 2:
            yield from explore(*process(N_even, N_odd, 'even'))
        if N_odd >= 2:
            yield from explore(*process(N_even, N_odd, 'odd'))


def process(N_even, N_odd, target):
    # １ターン分の処理
    if target == 'even':
        return N_even - 1, N_odd
    elif target == 'odd':
        return N_even + 1, N_odd - 2


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys

L1 = '3'
L2 = '1 2 3'

L1 = '5'
L2 = '1 2 3 4 5'

# L1, L2 = input()

def main():
    N = int(L1)
    As = map(int, L2.split())

    even = [A % 2 == 0 for A in As]
    N_even = sum(even)
    N_odd = N - N_even

    printerr("N={} (even:{}, odd:{})".format(N, N_even, N_odd))

    results = list(explore(N_even, N_odd))
    print(list(results))

    if any(results):
        print('YES')
    else:
        print('NO')


def explore(N_even, N_odd):
    # 再帰終了
    if N_even in (0, 1) and N_odd in (0, 1):
        if N_even == 0:
            raise Exception("Unbelievable!!")
        else:
            if N_odd == 0:
                yield True
            else:
                yield False

    # もう１段潜る
    else:
        if N_even >= 2:
            yield from explore(*proc(N_even, N_odd, 'even'))
        if N_odd >= 2:
            yield from explore(*proc(N_even, N_odd, 'odd'))


def proc(N_even, N_odd, target):
    if target == 'even':
        return N_even - 1, N_odd
    elif target == 'odd':
        return N_even + 1, N_odd - 2


def printerr(*args, **kwargs):
    print(*args, **kwargs, file=sys.stderr)



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(i) for i in input().split()]

count=0
for i in A:
	if i%2==1:
		count+=1
if count%2==0:
	print("YES")
else:
	print("NO)

Submission status: Runtime Error

Solution code:
n = int(input())
arg_list = int(input())

k = 0
for item in arg_list:
    if item % 2 == 1 :
        k +=1
if k == 1:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
numInput = int(input())

amount = numInput
numOdd = int(numInput / 2) + (numInput % 2)
numEven 0 int(numInput / 2)

while True:

    if amount >= 2:
        if numOdd >= 2:
            numOdd -= 2
            numEven += 1
            amount -= 1
        else:
            numEven -= 1
            amount -= 1
    else:
        break

if amount == 1:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
n = int(raw_input().split())

a = list(map(int, raw_input().split()))

p = map(lambda x : x % 2, a)
if p.count(1)%2 == 0 :
    print "YES"
else :
    print "NO"

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(n) for n in input().split()]

cnt = 0
for in range(N):
    if A[i] % 2 == 1:
        cnt += 1

if cnt % 2 == 0:
    print ('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(raw_input())
n = np.array(map(int, raw_input().split()))

Nsum = np.sum(n)

if not Nsum % np.cumsum(np.arange(N)):
    print 'NO'
    return
    
sa = n[1:-1] - n
for s in sa:
    if s % n != Nsum / np.cumsum(np.arange(N)):
        print 'NO'
        return
print 'YES'
return

Submission status: Runtime Error

Solution code:
N = input()
if len([a for a in input().rstrip().split() if a % 2]) % 2:
    print('NO')
else:
    print('YES')

Submission status: Runtime Error

Solution code:
def even(num):
    if num & 1:
        return('uneven')
    else:
        return('even')

N = int(input())
A = list(map(int, input().split()))

n = 0
for a in A:
    if even(a) == 'uneven':
        n += 1

if even(n) =a= 'even':
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
od=[i for i in a if a%2]
print('YES' if len(od)%2==0 else 'NO')

Submission status: Runtime Error

Solution code:
import sys

n = list(map(int, next(sys.stdin).split()))

if len(ns) == 1:
    print('YES')
    exit()

if sum(1 for n in ns if n % 2 == 1) % 2 == 0:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
import sys

if sum(for n in map(int, next(sys.stdin).split()) if n % 2 == 1) % 2 == 0:
    print('YES')
else:
    print('NO')