Problem:


Score : 200 points

Problem Statement

We have a grid with N rows and M columns of squares. Initially, all the squares are white.

There is a button attached to each row and each column.
When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.
When a button attached to a column is pressed, the colors of all the squares in that column are inverted.

Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.

Constraints

1 \leq N,M \leq 1000

0 \leq K \leq NM

Input

Input is given from Standard Input in the following format:

N M K

Output

If Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.

Sample Input 1

2 2 2

Sample Output 1

Yes

Press the buttons in the order of the first row, the first column.

Sample Input 2

2 2 1

Sample Output 2

No

Sample Input 3

3 5 8

Sample Output 3

Yes

Press the buttons in the order of the first column, third column, second row, fifth column.

Sample Input 4

7 9 20

Sample Output 4

No



Sample input:
2 2 2


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m < m):
        push_count_m += 1
        current += m
    #elif (current < k and push_count_n < n):
    #    push_count_n += 1
    #    current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current += n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_n += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m/m > push_count_n/n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N, M, K = list(map(int, input().split()))

if (K % N == 0) or (K % M == 0):
    print('Yes')
    sys.exit()

for i in range(1,N):
    for j in range(1,M):
        c = i*M + j*N - max(i,j)
        if c == K:
            print('Yes')
            sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m < m):
        push_count_m += 1
        current += m
    #elif (current < k and push_count_n < n):
    #    push_count_n += 1
    #    current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current += n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_n += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m/m > push_count_n/n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m < m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n < n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current += n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_n += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m/m > push_count_n/n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m < m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n < n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_n += 1
                current += n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_m += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m < m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n < n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current += n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_n += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current += n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_n += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(2)

        if strategy == 2:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current += n - 2 * push_count_n
        elif (strategy == 0):
            if (push_count_m >= m/2):
                push_count_n += 1
                current += m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 1000000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(2)

        if strategy == 2:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current -= n - 2 * push_count_n
        elif (strategy == 0):
            if (push_count_m >= m/2):
                push_count_n += 1
                current -= m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(2)

        if strategy == 0:
            if (push_count_n >= n/2 ):
                push_count_m += 1
                current -= n - 2 * push_count_n
        elif (strategy == 1):
            if (push_count_m >= m/2):
                push_count_n += 1
                current -= m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(2)

        if (push_count_n >= n/2 and strategy == 0):
            push_count_m += 1
            current -= n - 2 * push_count_n
        elif (push_count_m >= m/2 and strategy == 1):
            push_count_n += 1
            current -= m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(3)

        if (push_count_n > n/2 and strategy == 0):
            push_count_m += 1
            current -= n - 2 * push_count_n
        elif (push_count_m > m/2 and strategy == 1):
            push_count_n += 1
            current -= m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
import random

n, m, k = map(int,input().split(" "))

push_count_n = 0
push_count_m = 0

count = 10000

current = 0

for i in range(count,0,-1):
    if (current == k):
        print("Yes")
        break
    if (current < k and push_count_m <= m):
        push_count_m += 1
        current += m
    elif (current < k and push_count_n <= n):
        push_count_n += 1
        current += n
    else:
        pass


    if (current > k):
        gap = current - k

        strategy = random.randrange(2)

        if (push_count_n > n/2 and strategy == 0):
            push_count_m += 1
            current -= n - 2 * push_count_n
        elif (push_count_m > m/2 and strategy == 1):
            push_count_n += 1
            current -= m - 2 * push_count_m
        else:
            if push_count_m > push_count_n:
                push_count_m -= 1
                current += n - 2 * push_count_n
            else:
                push_count_n -= 1
                current += m - 2 * push_count_m

    if (i == 1):
        print("No")

Submission status: Wrong Answer

Solution code:
N,M,K= map(int, raw_input().split())
flag=0

for x in range(N):
    for y in range(M):
        if M*x+N*y-2*x*y == K:
            print 'Yes'
            flag=1
            break
        else:
            continue
    if flag==1:
        break
if flag==0:
    print 'No'

Submission status: Wrong Answer

Solution code:
N, M, K = map(int, input().split())

flag = False

for i in range(N):
    if flag:
        break
    for j in range(M):
        if flag:
            break
        if M*i+N*j-i*j*2==K:
            flag = True

if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M, K = map(int, input().split())

flag = False

for i in range(N):
    if flag:
        break
    for j in range(M):
        if flag:
            break
        if M*i+N*j-i*j==K:
            flag = True

if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

N, M, K = (int(i) for i in input().split())
ans = False
for s in range(1, N + 1):
  for t in range(1, M + 1):
    if(s * M + t * N - s * t * 2 == K):
      ans = True
      break
  if(ans):
    break
if(ans):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N, M, K = map(int, input().split())

for r in range(N):
    for c in range(M):
        if (N - r) * c + r * (M - c) == K:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
def calc(a,b,c,d):
    return a*b + c*d
N, M, K = map(int, sys.stdin.readline().strip().split())
if N*M / 2 < K:
    K = N*M -K
for n in xrange(N+1):
    for m in xrange(M+1):
        if calc(n,m,N-n,M-m) == K:
            print n, m
            print 'Yes'
            exit(0)
print 'No'

Submission status: Wrong Answer

Solution code:
import sys
M,N,K = map(int,input().split())
if N > M:
    tmp = M
    M = N
    N = tmp
for i in range(N+1):
    for j in range(M+1):
        if M*i + M*j - 2*i*j == K:
            print('Yes')
            sys.exit()
 
print('No')

Submission status: Wrong Answer

Solution code:
N, M, K = list(map(int, input().split()))
flag = 0
for n in range(N):
    for m in range(M):
        if flag == 0 and n * M + m * N - 2 * n * m == K:
            print("Yes")
            flag = 1
            break
if flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M, K = list(map(int, input().split()))
flag = 0
for n in range(N):
    for m in range(M):
        if n * M + m * N - 2 * n * m == K:
            print("Yes")
            flag = 1
            break
if flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M, K = list(map(int, input().split()))
flag = 0
for n in range(N):
    for m in range(M):
        if n * M + m * N - n * m == K:
            print("Yes")
            flag = 1
            break
if flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M, K = list(map(int, input().split()))
flag = 0
for n in range(N):
    for m in range(M):
        if n * M + m * N - abs(n - m) == K:
            print("Yes")
            flag = 1
            break
if flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
#! /bin/python
# coding:utf-8

import itertools

N = raw_input()

if (N.find('9') == -1):
    print "No"
else:
    print "Yes"

Submission status: Wrong Answer

Solution code:
def k_judge(n, m, k):
    for i in range(1, n+1):
        for j in range(1, m+1):
            if i*(m-j)+j*(n-i) == k:
                return True
    return False


def main():
    n, m, k = map(int, input().split())
    if k_judge(n, m, k):
        print("Yes")
    else:
        print("No")
        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python                                                                                          
#-*- coding: utf-8 -*-                                                                                         

import numpy as np
from itertools import product

if __name__ == "__main__":
    N, M, K = map(int, raw_input().split())
    success = False
    for n, m in product(range(N+1), range(M+1)):
        rows = np.zeros((N, M))
        rows[:, 0:n] = 1
        cols = np.zeros((N, M))
        cols[0:m, :] = 1
        board = rows + cols
        board = np.where(board % 2 == 1, 1, 0)
        if np.sum(board) == K:
            success = True
            break
    if success:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python                                                                                          
#-*- coding: utf-8 -*-                                                                                         

from itertools import product

if __name__ == "__main__":
    N, M, K = map(int, raw_input().split())
    success = False
    for	n, m in	product(range(N), range(M)):
        if n*M + m*N - 2*n*m == K:
            success = True
            break
    if success:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python                                                                                           
#-*- coding: utf-8 -*-                                                                                          

import numpy as np

if __name__ == "__main__":
    N, M, K = map(int, raw_input().split())
    success = False
    for i in range(N * M):
        n = i / N
        m = i % N
        rows = np.zeros((N, M))
        rows[:, 0:n] = 1
        cols = np.zeros((N, M))
        cols[0:m, :] = 1
        board = rows + cols
        board = np.where(board % 2 == 1, 1, 0)
        if np.sum(board) == K:
            success = True
            break
    if success:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
N, M, K = map(int, input().split())


def solve(N, M, K):
    for i in range(N):
        for j in range(M):
            blackNum = i*M + j*N - 2*i*j
            if K == blackNum:
                return "Yes"
    return "No"

print(solve(N, M, K))

Submission status: Wrong Answer

Solution code:
n, m, k = [int(x) for x in input().split()]

flag = False

for i in range(1,n+1):
    for j in range(1,m+1):
        if (n - i) * (m - j) + i * j == k:
            flag = True
            break       
        else:
            continue
        break

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
ans = "No"
for a in range(n):
	for b in range(m):
		area = a * (m-b) + (n-a) * b
		if area == k:
			ans = "Yes"
			break
		elif area < k:
			break
	if ans == "Yes":
		break
print(ans)

Submission status: Wrong Answer

Solution code:
n, m, k = map(int, input().split())
ans = "No"
for a in range(n):
	for b in range(m):
		area = (n-a) * (m-b) + a * b
		if area == k:
			ans = "Yes"
			break
		elif area < k:
			break
	if ans == "Yes":
		break
print(ans)

Submission status: Wrong Answer

Solution code:
N, M, K = map(int, input().split())

colored = 0
flag = 0

for i in range(N + 1):
    for j in range(M + 1):
        colored = i * M + j * N - i * j
        if colored == K:
            flag = 1
            break
        else:
            pass

if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

res = 'No'

for i in range(N):
    for j in range(M):
        if i*(M-j) + j*(N-i) == K:
            res = 'Yes'
            break

print(res)

Submission status: Wrong Answer

Solution code:
def solve():
    N, M, K = list(map(int, input().split(" ")))

    for n in range(N):
        for m in range(M):
            if (M - m) * n + (N - n) * m == K:
                print("Yes")
                return

    print("No")


solve()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N, M, K = map(int, raw_input().split() )
    ans = 0

    for a in xrange(N+1):
        for b in xrange(N+1):
            if (((N-a) * b + a * (M - b)) == K):
                ans = 1

    if ans:
        print "Yes"
    else:
        print "No"

Submission status: Wrong Answer

Solution code:
N,M,K = map(int,input().strip().split())
def judge(N,M,K):
    if K > N * M or K < 0:
        return False
    for n in range(0, N + 1):
        for m in range(0, M + 1):
            if n * M + m * N - m * n == K:
                return True
    return False
if judge(N, M, K):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
nums = [int(x) for x in input().split()]
N,M,K = nums[0],nums[1],nums[2]

for k in range(N):
	for l in range(M):
		if k * (M - l) + l * (N-k) == K:
			print("Yes")
			exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
N,M,K = map(int,input().strip().split())
def judge(N,M,K):
    if K > N * M or K < 0:
        return False
    for n in range(1, N + 1):
        for m in range(1, M + 1):
            if n * M + m * N - m * n == K:
                return True
    return False
if judge(N, M, K):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for m in range(M):
    for n in range(N):
        l = (M - m) * n + (N - n) * m
        if l == K:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
n,m,k = map(int,input().split())
flg = False
for i in range(n + 1):
    for j in range(m + 1):
        if i * (n - j) + j * (m - i) == k:
            flg = True
            break
        else:
            pass
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,m,k = map(int,input().split())
flg = False
for i in range(n + 1):
    for j in range(m + 1):
        if i * (n - j) + j * (m - i) == k:
            flg = True
            break
        else:
            pass
print(flg)
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
M,N,K = map(int,input().split())
if N > M:
    tmp = M
    M = N
    N = tmp
for i in range(N):
    for j in range(M):
        if M*i + M*j - 2*i*j == K:
            print('Yes')
            sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
n,m,k = map(int,input().split())
flg = False
for i in range(n):
    for j in range(m):
        if i * (n - j) + j * (m - i) == k:
            flg = True
            break
        else:
            pass
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M,K= (int(i) for i in input().split())  
ok=0

for j in range(M):
 for i in range(N):
  if j*N+i*M-2*i*j==K :

       ok=1

if ok==0:
 print("No")
else:
 print("Yes")

Submission status: Wrong Answer

Solution code:
N,M,K= (int(i) for i in input().split())  
ok=0

for j in range(M):
 for i in range(N):
  if j*N+i*M-i*j==K :

       ok=1

if ok==0:
 print("No")
else:
 print("Yes")

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys

all=input()
all_list=all.split(" ")
n=int(all_list[0])
m=int(all_list[1])
k=int(all_list[2])

for i_n in range(n):
        for i_m in range(m):
                now_k=(i_n*m+i_m*n)-2*i_n*i_m
                if k==now_k:
                        print("Yes")
                        sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,m,k = list(map(int,input().split()))
if k == 0:
    print('Yes')
    exit()
ma = max(n,m)
mini = min(n,m)
if n == 1 or m == 1:
    print('Yes')
    exit()
if k%m ==0 or k%n == 0 or k%(n+m):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=input().split()
import numpy as np
a=np.zeros((int(s[0]),int(s[1])))

b=int(int(s[0])/2)
c=int(int(s[1])/2)
x=[]
for i in range(b):
    a[i,:]=1
    x.append(np.count_nonzero(a))
for j in range(c):
    a[:,j]=1-a[:,j]
    x.append(np.count_nonzero(a))
if int(s[2]) in x:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,m,k = map(int,input().split())
arr = [[] for _ in range(n)]
ans = []
flg = True
for i in range(n):
    for j in range(m):
        arr[i].append(0)

def check(a,b=[]):
    b = []
    for i in range(len(a)):
        b.extend(a[i])
    num = b.count(1)
    return num

def add_one(arr,num):
    arr[num] = list(map(lambda x: (x+1)%2, arr[num]))
    return arr

for i in range(n):
    # add_one(arr,i,j)
    # num = check(arr)
    # ans.append(num)
    if flg:
        for j in range(m):
            if flg:
                arr = add_one(arr,i)
                num = check(arr)
                if num == k:
                    flg = False
                    break
                ans.append(num)

if k in ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, M, K = list(map(int, input().split(' ')))


def run():
    if is_0() or is_all():
        result_ok()
        return 0
    if is_duble():
        result_ok()
        return 0
    # if is_M_ok() or is_N_ok():
    #     result_ok()
    #     return 0
    if is_ok():
        result_ok()
        return 0
    result_no()


def is_0():
    return K == 0


def is_all():
    return K == N * M


def is_duble():
    return K % N == 0 or K % M == 0


def is_N_ok():
    if N % 2 == 0:
        return K == N * M / 2
    else:
        a = N * M / 2
        return K >= a and K <= a + M


def is_M_ok():
    if M % 2 == 0:
        return K == N * M / 2
    else:
        a = N * M / 2
        return K >= a and K <= a + N


def is_ok():
    for i in range(0, N):
        for j in range(0, M):
            # print('i: ', end='')
            # print(i)
            # print('j: ', end='')
            # print(j)
            # print('N * i + M * j - i * j: ', end='')
            # print(N * i + M * j - i * j)
            # print('===============================')
            if N * i + M * j - i * j == K:
                return True
    return False


def result_ok():
    print("Yes")


def result_no():
    print("No")


if __name__ == '__main__':
    run()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, M, K = list(map(int, input().split(' ')))


def run():
    if is_0() or is_all():
        result_ok()
        return 0
    if is_duble():
        result_ok()
        return 0
    if is_M_ok() or is_N_ok():
        result_ok()
        return 0
    if is_ok():
        result_ok()
        return 0
    result_no()


def is_0():
    return K == 0


def is_all():
    return K == N * M


def is_duble():
    return K % N == 0 or K % M == 0


def is_N_ok():
    if N % 2 == 0:
        return K == N * M / 2
    else:
        a = N * M / 2
        return K >= a and K <= a + M


def is_M_ok():
    if M % 2 == 0:
        return K == N * M / 2
    else:
        a = N * M / 2
        return K >= a and K <= a + N


def is_ok():
    for i in range(0, N):
        for j in range(0, M):
            # print('i: ', end='')
            # print(i)
            # print('j: ', end='')
            # print(j)
            # print('N * i + M * j - i * j: ', end='')
            # print(N * i + M * j - i * j)
            # print('===============================')
            if N * i + M * j - i * j == K:
                return True
    return False


def result_ok():
    print("Yes")


def result_no():
    print("No")


if __name__ == '__main__':
    run()

Submission status: Wrong Answer

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

inlist = input().split()
n = int(inlist[0])
m = int(inlist[1])
k = int(inlist[2])
mat = [[1 for i in range(m)] for j in range(n)]
print(mat)

def initialize(i, j, matrix):
    for k in range(i):
        for l in range(j):
            matrix[k][l] = 1
    return matrix

def sum_mat(i, j, matrix):
    sum = 0
    for k in range(i):
        for l in range(j):
            sum = sum + matrix[k][l]
    return sum

escape = False

for l in range(n + 1): #l = 0 -> n
    mat = initialize(n, m, mat)
    for i in range(l):
        for j in range(m):
            mat[i][j] = -mat[i][j]
    mat_save = mat
    for p in range(m + 1): # p = 0 -> m
        mat = mat_save
        for j in range(p):
            for i in range(n):
                mat[i][j] = -mat[i][j]
        sum = sum_mat(n, m, mat)
        if(sum == n * m - 2 * k):
            print("Yes")
            escape = True
            break;
        elif(l == n and p == m):
            print("No")
    if(escape):
        break;