problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p03665
u114641312
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['# from math import factorial,sqrt,ceil,gcd\n# from itertools import permutations as permus\n# from collections import deque,Counter\n# import re\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\nimport numpy as np\n# import networkx as nx\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n# from scipy.special import comb\n\n\nN,P = map(int,input().split())\n# arrA = list(map(int,input().split()))\narrA = np.array(input().split(),dtype=np.int64)\n\nA = arrA % 2\nif not 1 in A:\n if P == 1:\n print(0)\neven = 1\nodd = 1\nfor i in A:\n if i == 0:\n even *= 2\n odd *= 2\n else:\n even = odd + even\n odd = even + odd\nif P==0:\n print(even)\nelse:\n print(odd)\n\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n', '# from math import factorial,sqrt,ceil,gcd\n# from itertools import permutations as permus\n# from collections import deque,Counter\n# import re\n\n# from decimal import Decimal, getcontext\n\n# # eps = Decimal(10) ** (-100)\n\nimport numpy as np\n# import networkx as nx\n# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson\n# from scipy.sparse import csr_matrix\n# from scipy.special import comb\n\n\nN,P = map(int,input().split())\n# arrA = list(map(int,input().split()))\narrA = np.array(input().split(),dtype=np.int64)\n\nA = arrA % 2\nif not (1 in A):\n if P == 1:\n print(0)\n exit()\n else:\n print(2**N)\n exit()\n\neven = 1\nodd = 1\nfor i in sorted(A)[::-1][1:]:\n if i == 0:\n even *= 2\n odd *= 2\n else:\n even,odd = odd + even , odd + even\nif P==0:\n print(even)\nelse:\n print(odd)\n\n# for row in board:\n\n# print("{:.10f}".format(ans))\n# print("{:0=10d}".format(ans))\n']
['Wrong Answer', 'Accepted']
['s738966284', 's158868473']
[12384.0, 13212.0]
[156.0, 163.0]
[1175, 1248]
p03665
u129836004
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N, P = map(int, input().split())\nAs = list(map(int, input().split()))\neven = 0\nodd = 0\nfor a in As:\n if a % 2 == 0:\n even += 1\n else:\n odd += 1\nprint(even)\nprint(odd)\nE = 2**even\nif P == 0:\n O = 1\n o = 1\n for i in range(2, odd+1, 2):\n o = int(o*(odd+1-i)*(odd+2-i)/i/(i-1))\n O += o\nelse:\n O = odd\n o = odd\n for i in range(3, odd+1, 2):\n o = int(o*(odd+1-i)*(odd+2-i)/i/(i-1))\n O += o\nprint(E*O)', 'N, P = map(int, input().split())\nAs = list(map(int, input().split()))\neven = 0\nodd = 0\nfor a in As:\n if a % 2 == 0:\n even += 1\n else:\n odd += 1\n\nE = 2**even\nif P == 0:\n O = 1\n o = 1\n for i in range(2, odd+1, 2):\n o = int(o*(odd+1-i)*(odd+2-i)/i/(i-1))\n O += o\nelse:\n O = odd\n o = odd\n for i in range(3, odd+1, 2):\n o = int(o*(odd+1-i)*(odd+2-i)/i/(i-1))\n O += o\nprint(E*O)']
['Wrong Answer', 'Accepted']
['s984727866', 's027373790']
[3064.0, 3064.0]
[17.0, 17.0]
[460, 438]
p03665
u131634965
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p=map(int, input().split())\na=list(map(int, input().split()))\ntotal=sum( n%2 for i in a )\n\nif total==0:\n if p==0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))', 'n,p=map(int, input().split())\na=list(map(int, input().split()))\ntotal=sum( n%2 for i in a )\n\nif total=0:\n if p==0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))', 'n,p=map(int, input().split())\na=list(map(int, input().split()))\ntotal=sum( i%2 for i in a )\n\nif total==0:\n if p==0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s800349748', 's925335821', 's616909116']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[191, 190, 191]
p03665
u153147777
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import scipy.misc as scm\n\n\nN, P = map(int, input().split())\nA = [int(s) % 2 == 0 for s in input().split()]\n\nevens = len(list(filter(lambda x: x == True, A)))\nodds = len(A) - evens\n\nif P == 0:\n evens_x = pow(2, evens)\n odds_x = 0\n \n for i in range(0, odds + 1, 2):\n odds_x += scm.comb(odds, i)\n \nelse:\n evens_x = pow(2, evens)\n odds_x = 0\n\n for i in range(1, odds + 1, 2):\n odds_x += scm.comb(odds, i)\n \nprint(int(evens_x * odds_x))\n', 'import itertools\nimport scipy.misc as scm\nimport sys\n\nN, P = map(int, input().split())\nA = [int(s) % 2 == 0 for s in input().split()]\n\nevens = len(list(filter(lambda x: x == True, A)))\nodds = len(A) - evens\n\nif P == 0:\n evens_x = int(pow(2, evens))\n odds_x = 0\n \n for i in range(0, odds + 1, 2):\n odds_x += int(scm.comb(odds, i))\n\n print(evens_x * odds_x)\n \nelse:\n evens_x = int(pow(2, evens))\n odds_x = 0\n\n for i in range(1, odds + 1, 2):\n odds_x += int(scm.comb(odds, i))\n\n print(evens_x * odds_x)\n ', '_, P = map(int, input().split())\nA = [int(s) % 2 == 0 for s in input().split()]\n\nevens = len(list(filter(lambda x: x == True, A)))\nodds = len(A) - evens\n\nevens_x = pow(2, evens)\n\nif odds == 0 and P == 0:\n print(int(evens_x))\nelif odds == 0 and P == 1:\n print(0)\nelse:\n odds_x = pow(2, odds - 1)\n print(int(evens_x * odds_x))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s181780754', 's587439882', 's651154516']
[16828.0, 26120.0, 3064.0]
[1134.0, 373.0, 19.0]
[470, 548, 337]
p03665
u183840468
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p = [int(i) for i in input().split()]\n\nif p % 2 == 0:\n print(2**p)\nelse:\n print(2**(p-1))', 'n,p = [int(i) for i in input().split()]\n \nif p % 2 == 0:\n print(2**n)\nelse:\n print(2**(n-1))', 'a,b = [int(i) for i in input().split()]\n\nl = [int(i) for i in input().split()]\n\nl2 = [i for i in l if i %2 == 1]\n\nif not l2 :\n print(2**a if b % 2 == 0 else 0)\nelse:\n print(2**(a-1))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s008159925', 's632523878', 's611270723']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[93, 94, 188]
p03665
u226191225
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['nCr = {}\ndef cmb(n, r):\n if r == 0 or r == n: return 1\n if r == 1: return n\n if (n,r) in nCr: return nCr[(n,r)]\n nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return nCr[(n,r)]\n\nn,p = map(int,input().split())\nx = [int(i) for i in input().split()]\nodd = 0\nans = 0\nans_tmp = 0\nfor i in x:\n if i%2:\n odd += 1\n\nans += 2**(n-odd)\ntmp = odd//2\nif p:\n if odd:\n for i in range(tmp):\n ans_tmp += cmb(odd,i*2+1)\nelse:\n print(odd)\n if odd:\n tmp += 1\n for i in range(tmp):\n ans_tmp += cmb(odd,(i*2))\n\nans *= ans_tmp\nprint(ans)', 'nCr = {}\ndef cmb(n, r):\n if r == 0 or r == n: return 1\n if r == 1: return n\n if (n,r) in nCr: return nCr[(n,r)]\n nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return nCr[(n,r)]\n\nn,p = map(int,input().split())\nx = [int(i) for i in input().split()]\nodd = 0\nans = 0\nans_tmp = 0\nfor i in x:\n if i%2:\n odd += 1\n\nans += 2**(n-odd)\ntmp = odd//2\nif p:\n if odd:\n for i in range(tmp):\n ans_tmp += cmb(odd,i*2+1)\nelse:\n if odd:\n tmp += 1\n for i in range(tmp):\n ans_tmp += cmb(odd,(i*2))\n else:\n ans_tmp = 1\n\nans *= ans_tmp\nprint(ans)']
['Wrong Answer', 'Accepted']
['s171558381', 's849907786']
[3064.0, 3064.0]
[18.0, 18.0]
[577, 588]
p03665
u227082700
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p=map(int,input().split());a=list(map(int,input().split()));b=[0,0]\nfor i in a:b[i%2]+=1\nprint(2**b[p]-p)', 'n,p=map(int,input().split())\na=list(map(int,input().split()))\nfor i in range(n):a[i]%=2\no=a.count(1)\nz=n-o\nif o==0:\n if p==0:print(2**z)\n else:print(0)\nelse:\n print(2**(n-1))']
['Wrong Answer', 'Accepted']
['s761244682', 's061800089']
[2940.0, 3060.0]
[17.0, 17.0]
[107, 177]
p03665
u228223940
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import scipy.misc\nn,p = map(int,input().split())\nai = [int(i)%2 for i in input().split()]\n\nzero = ai.count(0)\none = ai.count(1)\n\n\ntmp = 2**zero\nans = 0\nfor i in range(one//2+1):\n if p == 0:\n if i*2 > one:\n break\n ans += scipy.misc.comb(one,0+i*2)\n else:\n if i*2+1 > one:\n break\n ans += scipy.misc.comb(one,1+i*2)\nprint(int(ans*tmp))', 'n,p = map(int,input().split())\nai = [int(i)%2 for i in input().split()]\n\nzero = ai.count(0)\none = ai.count(1)\n\n\n\n# import sys\n\nnCr = {}\ndef cmb(n, r):\n if r == 0 or r == n: return 1\n if r == 1: return n\n if (n,r) in nCr: return nCr[(n,r)]\n nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return nCr[(n,r)]\n\ntmp = 2**zero\nans = 0\nfor i in range(one//2+1):\n if p == 0:\n if i*2 > one:\n break\n ans += cmb(one,0+i*2)\n else:\n if i*2+1 > one:\n break\n ans += cmb(one,1+i*2)\nprint(int(ans*tmp))']
['Wrong Answer', 'Accepted']
['s835766621', 's687100219']
[14556.0, 3064.0]
[185.0, 18.0]
[388, 629]
p03665
u241159583
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from math import factorial\nn,p = map(int, input().split())\nA = list(map(int, input().split()))\n\ndef combinations_count(n,r):\n return factorial(n) // (factorial(n-r) * factorial(r))\n\neven = 0\nnot_even = 0\nfor a in A:\n if a % 2 == 0: even += 1\n else: not_even += 1\nprint(even, not_even)\nans = 0\nif p == 0:\n \n if even != 0: a = factorial(even)\n else: a = 0\n \n b = 0 \n n = 2\n while n <= not_even:\n b += combinations_count(not_even, n)\n n += 2\n print(a + b + a * b + 1)\nelse:\n \n if not_even != 0: a = factorial(not_even)\n else: a = 0\n \n b = 0\n n = 3\n while n <= even:\n b += combinations_count(even, n)\n n += 2\n print(a + b + a * b)', 'from scipy.special import comb\nn,p = map(int, input().split())\nA = list(map(int, input().split()))\ncnt = [0,0] \nfor a in A:\n if a%2==0: cnt[0] += 1\n else: cnt[1] += 1\n \nans = 0\nif p==0: \n for i in range(0,cnt[1]+1,2):\n ans += comb(cnt[1],i,exact=True)\n ans *= 2**cnt[0]\nelse: \n for i in range(1,cnt[1]+1,2):\n ans += comb(cnt[1],i,exact=True)\n ans *= 2**cnt[0]\nprint(ans)']
['Wrong Answer', 'Accepted']
['s304022430', 's862107561']
[3064.0, 42104.0]
[17.0, 179.0]
[763, 489]
p03665
u252828980
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\na,b = map(int,input().split())\nL = list(map(int,input().split()))\nLe = [x for x in L if x%2 == 0]\nLo = [x for x in L if x%2 == 1]\n#print(Le,Lo)\ndef nCr(n,r):\n return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))\n \nif b == 0:\n ev = 0\n od = 1\n while ev <= len(Le)//2:\n ev += nCr(len(Le),ev)\n ev += 2\n while od <= len(Lo)+1:\n od += nCr(len(Lo),od)\n od += 2\nelif b == 1:\n ev = 0\n od = 0\n while ev <= len(Le)//2:\n ev += nCr(len(Le),ev)\n ev += 2\n while od <= len(Lo)+1:\n od += nCr(len(Lo),od)\n od += 2\nprint(ev*od)', 'n,p = map(int,input().split())\nL = list(map(int,input().split()))\nLe = [x for x in L if x%2 == 0]\nLo = [x for x in L if x%2 == 1]\n\nif p == 0:\n if len(Lo) == 0:\n print(2**n)\n else:\n print(2**(n-1))\nif p == 1:\n if len(Lo) == 0:\n print(0)\n else:\n print(2**(n-1))']
['Runtime Error', 'Accepted']
['s329674292', 's131528442']
[3064.0, 3064.0]
[17.0, 17.0]
[619, 299]
p03665
u309141201
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\neven = 0\nodd = 0\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nfor i in range(N):\n if A[i] % 2 == 0:\n even += 1\n else:\n odd += 1\n\noddcmb = 0\nif P == 0:\n for i in range(odd)[::2]:\n # print(i)\n oddcmb += comb(odd, i)\n ans = 2**even*oddcmb\n \nelse:\n for i in range(1, odd)[::2]:\n # print(i)\n oddcmb += comb(odd, i)\n ans = 2**even*oddcmb\n\nprint(ans)', 'import math\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\neven = 0\nodd = 0\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nfor i in range(N):\n if A[i] % 2 == 0:\n even += 1\n else:\n odd += 1\n\noddcmb = 0\nif P == 0:\n for i in range(odd+1)[::2]:\n # print(i)\n oddcmb += comb(odd, i)\n ans = 2**even*oddcmb\n \nelse:\n for i in range(1, odd+1)[::2]:\n # print(i)\n oddcmb += comb(odd, i)\n ans = 2**even*oddcmb\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s230282599', 's640798710']
[3064.0, 3064.0]
[18.0, 18.0]
[552, 556]
p03665
u321035578
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n, p = map(int, input().split())\na = list(map(int,input().split()))\n\nodd = []\neven = []\nfor i, aa in enumerate(a):\n if aa % 2 == 0:\n even.append(aa)\n else:\n odd.append(aa)\ne = len(even)\no = len(odd)\nans = 2 ** e\nod_list = [0]\nbunsi = 1\nbunbo = 1\n\nfor i in range(1,o):\n bunsi *= o - i + 1\n bunbo *= i\n od_list.append(bunsi//bunbo)\neven_i = od_list[::2]\nodd_i = od_list[1::2]\nif p == 0:\n print(ans * sum(even_i))\nelse:\n print(ans * sum(odd_i))\n\n\n ', "import sys\nfrom math import factorial\ndef main():\n packages, remainder = receiveInputData()\n\n packages.countOddAndEven()\n\n even_ways = packages.calculateEvenWays()\n odd_ways_remainder0, odd_ways_remainder1 = packages.calculateOddWays()\n\n if remainder.isZero():\n print(even_ways * odd_ways_remainder0)\n return\n\n print(even_ways * odd_ways_remainder1)\n\n\n\n\n\n\nclass Package():\n def __init__(self, packages_list, packages_num):\n if not isinstance(packages_list, list):\n print('Package Class argument error')\n sys.exit(1)\n\n \n if packages_num < 1 or packages_num > 50:\n print('Package Class Restriction error')\n print(packages_num)\n sys.exit(1)\n\n self.packages = packages_list\n self.packages_num = packages_num\n\n \n def countOddAndEven(self):\n self.packages_num_of_odd_biscuits = 0\n self.packages_num_of_even_biscuits = 0\n for pack_i, biscuits_num in enumerate(self.packages):\n if biscuits_num % 2 == 0:\n self.packages_num_of_even_biscuits += 1\n else:\n self.packages_num_of_odd_biscuits += 1\n print(self.packages_num_of_odd_biscuits)\n\n \n \n \n def calculateEvenWays(self):\n return 2 ** self.packages_num_of_even_biscuits\n\n def calculateOddWays(self):\n count_combination_list = self.calculateCombination(self.packages_num_of_odd_biscuits)\n\n \n \n selected_even_odds = sum(count_combination_list[::2])\n\n \n \n selected_odd_odds = sum(count_combination_list[1::2])\n\n return selected_even_odds, selected_odd_odds\n\n def calculateCombination(self,n):\n \n select_ways_of_odd = [1]\n for select_num in range(1,n + 1):\n n_C_i = factorial(n) // (factorial(select_num) * factorial(n - select_num))\n select_ways_of_odd.append(n_C_i)\n return select_ways_of_odd\n\n\n\n\n\n\n\n\n\n\n\nclass Remainder():\n def __init__(self, remainder_0or1):\n if not isinstance(remainder_0or1, int):\n print('Remainder Class argument error')\n sys.exit(1)\n\n \n if remainder_0or1 != 0 and remainder_0or1 != 1:\n print('Remainder Class Restriction error')\n sys.exit(1)\n\n self.remainder = remainder_0or1\n\n\n def isZero(self):\n if self.remainder == 0:\n return True\n return False\n\n\ndef receiveInputData():\n\n N, P = map(int, input().split())\n A = list(map(int,input().split()))\n\n return Package(A, N), Remainder(P)\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom math import factorial\ndef main():\n packages, remainder = receiveInputData()\n\n packages.countOddAndEven()\n\n even_ways = packages.calculateEvenWays()\n odd_ways_remainder0, odd_ways_remainder1 = packages.calculateOddWays()\n\n if remainder.isZero():\n print(even_ways * odd_ways_remainder0)\n return\n\n print(even_ways * odd_ways_remainder1)\n\n\n\n\n\n\nclass Package():\n def __init__(self, packages_list, packages_num):\n if not isinstance(packages_list, list):\n print('Package Class argument error')\n sys.exit(1)\n\n \n if packages_num < 1 or packages_num > 50:\n print('Package Class Restriction error')\n print(packages_num)\n sys.exit(1)\n\n self.packages = packages_list\n self.packages_num = packages_num\n\n \n def countOddAndEven(self):\n self.packages_num_of_odd_biscuits = 0\n self.packages_num_of_even_biscuits = 0\n for pack_i, biscuits_num in enumerate(self.packages):\n if biscuits_num % 2 == 0:\n self.packages_num_of_even_biscuits += 1\n else:\n self.packages_num_of_odd_biscuits += 1\n\n \n \n \n def calculateEvenWays(self):\n return 2 ** self.packages_num_of_even_biscuits\n\n def calculateOddWays(self):\n count_combination_list = self.calculateCombination(self.packages_num_of_odd_biscuits)\n\n \n \n selected_even_odds = sum(count_combination_list[::2])\n\n \n \n selected_odd_odds = sum(count_combination_list[1::2])\n\n return selected_even_odds, selected_odd_odds\n\n def calculateCombination(self,n):\n \n select_ways_of_odd = [1]\n for select_num in range(1,n + 1):\n n_C_i = factorial(n) // (factorial(select_num) * factorial(n - select_num))\n select_ways_of_odd.append(n_C_i)\n return select_ways_of_odd\n\n\n\n\n\n\n\n\n\n\n\nclass Remainder():\n def __init__(self, remainder_0or1):\n if not isinstance(remainder_0or1, int):\n print('Remainder Class argument error')\n sys.exit(1)\n\n \n if remainder_0or1 != 0 and remainder_0or1 != 1:\n print('Remainder Class Restriction error')\n sys.exit(1)\n\n self.remainder = remainder_0or1\n\n\n def isZero(self):\n if self.remainder == 0:\n return True\n return False\n\n\ndef receiveInputData():\n\n N, P = map(int, input().split())\n A = list(map(int,input().split()))\n\n return Package(A, N), Remainder(P)\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s333473370', 's707426684', 's003839388']
[3064.0, 3064.0, 3064.0]
[17.0, 20.0, 18.0]
[483, 3178, 3129]
p03665
u325956328
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from scipy.special import comb\nimport numpy as np\n\nN, P = map(int, input().split())\nA = np.array(list(map(int, input().split())))\n\nA = A % 2 != 0\nodd = np.sum(A)\neven = N - odd\nprint(A, odd, even)\n\nans = 0\nodd_num = 0\neven_num = 0\nif P == 1:\n for i in range(1, odd + 1, 2):\n odd_num += comb(odd, i, exact=True)\n even_num = pow(2, even)\n ans = odd_num * even_num\nelse:\n for i in range(0, odd + 1, 2):\n odd_num += comb(odd, i, exact=True)\n even_num = pow(2, even)\n ans = odd_num * even_num\n # print(odd_num, even_num)\nprint(ans)\n', 'from scipy.special import comb\nimport numpy as np\n\nN, P = map(int, input().split())\nA = np.array(list(map(int, input().split())))\n\nA = A % 2 != 0\nodd = np.sum(A)\neven = N - odd\n\n\nans = 0\nodd_num = 0\neven_num = 0\nif P == 1:\n for i in range(1, odd + 1, 2):\n odd_num += comb(odd, i, exact=True)\n even_num = pow(2, even)\n ans = odd_num * even_num\nelse:\n for i in range(0, odd + 1, 2):\n odd_num += comb(odd, i, exact=True)\n even_num = pow(2, even)\n ans = odd_num * even_num\n # print(odd_num, even_num)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s500797932', 's127360020']
[42468.0, 42524.0]
[183.0, 181.0]
[562, 564]
p03665
u329865314
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['tmp = list(map(int,input().split()))\nAs = list(map(int,input().split()))\nn,p = tmp[0],tmp[1]\no ,e = 0,0\nfor i in range(n):\n if As[i] % 2:\n o += 1\n else:\n e += 1\ndef comb(j,k):\n if k == 1:\n return(j)\n else:\n return comb(j-1,k-1) * j / k\nans = 0\nif p == 0:\n for i in range(o+1):\n if not i % 2:\n ans += int(comb(o,i))\nelse:\n for i in range(o+1):\n if i % 2:\n ans += int(comb(o,i))\nans *= (2 ** e)\nprint(ans)', 'tmp = list(map(int,input().split()))\nAs = list(map(int,input().split()))\nn,p = tmp[0],tmp[1]\no ,e = 0,0\nfor i in range(n):\n if As[i] % 2:\n o += 1\n else:\n e += 1\ndef comb(j,k):\n if k == 0:\n return(1)\n else:\n return comb(j-1,k-1) * j / k\nans = 0\nif p == 0:\n for i in range(o+1):\n if not i % 2:\n ans += int(comb(o,i))\nelse:\n for i in range(o+1):\n if i % 2:\n ans += int(comb(o,i))\nans *= (2 ** e)\nprint(ans)']
['Runtime Error', 'Accepted']
['s976289640', 's486426786']
[3988.0, 3188.0]
[75.0, 19.0]
[438, 438]
p03665
u340010271
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P=map(int,input().split())\na=list(map(int,input().split()))\na=list(map(lambda x:x%2,a))\nif 1 in a:\n print(2**N)\nelse:\n if P%2==0:\n print(2**(N-1))\n else:\n print(0)', 'N,P=map(int,input().split())\na=list(map(int,input().split()))\na=list(map(lambda x:x%2,a))\nif 1 in a:\n print(2**(N-1))\nelse:\n if P%2==0:\n print(2**N)\n else:\n print(0)']
['Wrong Answer', 'Accepted']
['s456625130', 's870456827']
[3060.0, 3316.0]
[17.0, 20.0]
[188, 188]
p03665
u346812984
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\n\nodd = sum([a % 2 for a in A])\neven = len(A) - odd\n\nans = (2 ** even) * (2 ** (odd - 1))\n\n', 'import sys\n\nsys.setrecursionlimit(10 ** 6)\nINF = float("inf")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n N, P = map(int, input().split())\n A = [0] + list(map(int, input().split()))\n dp_odd = [0 for _ in range(N + 1)]\n dp_even = [0 for _ in range(N + 1)]\n dp_even[0] = 1\n\n for i in range(1, N + 1):\n if A[i] % 2 == 0:\n dp_odd[i] = dp_odd[i - 1] * 2\n dp_even[i] = dp_even[i - 1] * 2\n else:\n dp_odd[i] = dp_even[i - 1] + dp_odd[i - 1]\n dp_even[i] = dp_odd[i - 1] + dp_even[i - 1]\n\n if P == 0:\n print(dp_even[-1])\n else:\n print(dp_odd[-1])\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s295809048', 's908612241']
[2940.0, 3064.0]
[17.0, 17.0]
[227, 717]
p03665
u358254559
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P = map(int, input().split())\nA = list(map(int, input().split()))\n\neven_num=0\nodd_num=0\n\nfor a in A:\n if a%2==0:\n even_num+=1\n else:\n odd_num+=1\n\nev_case = 2**even_num\n\n\nfrom math import factorial\n\nres=0\nfor i in range(P,odd_num+1,2): res += factorial(odd_num) / factorial(i) / factorial(odd_num - i)\n\nprint(ev_case*res)', 'N,P = map(int, input().split())\nA = list(map(int, input().split()))\n\neven_num=0\nodd_num=0\n\nfor a in A:\n if a%2==0:\n even_num+=1\n else:\n odd_num+=1\n\nev_case = 2**even_num\n\n\nfrom math import factorial\n\nres=0\nfor i in range(P,odd_num+1,2): res += factorial(odd_num) / factorial(i) / factorial(odd_num - i)\n\nprint(int(ev_case*res))']
['Wrong Answer', 'Accepted']
['s811021180', 's801414756']
[3064.0, 3064.0]
[18.0, 17.0]
[408, 413]
p03665
u367130284
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from math import factorial\ndef cmb(n,r):\n if n-r<0:\n return 0\n else:\n return factorial(n) // factorial(r) // factorial(n - r)\n \n\nn,p,*a=map(int,open(0).read().split())\n\nodd=sum(i%2 for i in a)\neven=n-odd\n\nprint(odd,even)\n\nx=sum(cmb(even,i)for i in range(even+1))\ny=sum(cmb(odd,i)for i in range(p,odd+1,2))\nprint(x*y)\n', 'from math import factorial\ndef cmb(n,r):\n if n-r<0:\n return 0\n else:\n return factorial(n) // factorial(r) // factorial(n - r)\n \n\nn,p,*a=map(int,open(0).read().split())\n\nodd=sum(i%2 for i in a)\neven=n-odd\n\n\nx=sum(cmb(even,i)for i in range(even+1))\ny=sum(cmb(odd,i)for i in range(p,odd+1,2))\nprint(x*y)\n\n']
['Wrong Answer', 'Accepted']
['s446259959', 's624763763']
[3188.0, 3188.0]
[20.0, 18.0]
[344, 329]
p03665
u371385198
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\n \n import sys\ninput = sys.stdin.readline\n\n\ndef readstr():\n return input().strip()\n\n\ndef readint():\n return int(input())\n\n\ndef readnums():\n return map(int, input().split())\n\n\ndef readstrs():\n return input().split()\n\n\nN, P = readnums()\nA = map(lambda x: x % 2, readnums())\n\nif not sum(A):\n print(0)\nelse:\n print(2 ** N // 2)\n', 'import sys\ninput = sys.stdin.readline\n\n\ndef readstr():\n return input().strip()\n\n\ndef readint():\n return int(input())\n\n\ndef readnums():\n return map(int, input().split())\n\n\ndef readstrs():\n return input().split()\n\n\nN, P = readnums()\nA = map(lambda x: x % 2, readnums())\n\nif P:\n if not sum(A):\n print(0)\n else:\n print(2 ** N // 2)\nelse:\n if not sum(A):\n print(2 ** N)\n else:\n print(2 ** N // 2)\n']
['Runtime Error', 'Accepted']
['s203930127', 's106009242']
[2940.0, 3060.0]
[17.0, 17.0]
[344, 444]
p03665
u388415336
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['num_bags, congr_factor = list(map(int, input().split()))\nbags = list(map(int, input().split()))\nodd_bags = len([bag for bag in bags if (bag % 2 == 1]))\n\nif congr_factor == 0 and odd == 0:\n print(2 ** num_bags)\nelif congr_factor == 1 and odd == 0:\n print(0)\nelse:\n print(2 ** (num_bags-1))\n', 'num_bags, congr_factor = list(map(int, input().split()))\nbags = list(map(int, input().split()))\nodd = len([a for a in bags if (a % 2 == 1]))\n\nif congr_factor == 0 and odd == 0:\n print(2 ** num_bags)\nelif congr_factor == 1 and odd == 0:\n print(0)\nelse:\n print(2 ** (num_bags-1))\n', 'num_bags, congr_factor = list(map(int, input().split()))\nbags = list(map(int, input().split()))\nodd_bags = len([bag for bag in bags if (bag % 2 == 1)])\n\nif congr_factor == 0 and odd_bags == 0:\n print(2 ** num_bags)\nelif congr_factor == 1 and odd_bags == 0:\n print(0)\nelse:\n print(2 ** (num_bags-1))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s434600085', 's450527344', 's769011736']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[292, 281, 302]
p03665
u394721319
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P = [int(i) for i in input().split()]\nA = [int(i)%2 for i in input().split()]\n\nk = A.count(1)\nl = A.count(0)\n\nif P == 0:\n if k == 0:\n print(2**l)\n ans = 1\n ans = 2**(k-1+l)\nelse:\n if k == 0:\n print(0)\n exit()\n else:\n ans = 1\n ans = 2**(k-1+l)\n\nprint(A)\n', 'N,P = [int(i) for i in input().split()]\nA = [int(i)%2 for i in input().split()]\n\nk = A.count(1)\nl = A.count(0)\n\nif P == 0:\n if k == 0:\n print(2**l)\n exit()\n ans = 1\n ans = 2**(k-1+l)\nelse:\n if k == 0:\n print(0)\n exit()\n else:\n ans = 1\n ans = 2**(k-1+l)\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s681497367', 's496880507']
[3060.0, 3188.0]
[17.0, 20.0]
[305, 322]
p03665
u411923565
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\nN,P = map(int,input().split())\nA = list(map(int,input().split()))\nA = sorted(A,reverse = False)\n\nm = sum(A) +1\ndp = [0]*(m)\n\ndp[0] = 2\n\n\nv = 0\n\nodd = 0\neven = 1\n\n\n\nfor a in range(N):\n \n for j in range(2):\n n = A[a]*j\n v += n \n \n if dp[v-n]%2 != n%2:\n dp[v] = 1\n odd += 1\n \n else:\n dp[v] = 2\n even += 1\nif P == 0:\n print(even)\nelse:\n print(odd)', '\nN,P = map(int,input().split())\nA = list(map(int,input().split()))\nA = sorted(A,reverse = False)\n\n\ndp = [[0]*2 for _ in range(N+1)]\n\n\ndp[0] = [1,0]\n\nfor v in range(1,N+1):\n \n if A[v-1]%2 == 0:\n dp[v][0] = dp[v-1][0]*2\n dp[v][1] = dp[v-1][1]*2\n \n else:\n \n dp[v][0] = dp[v-1][1] + dp[v-1][0]\n dp[v][1] = dp[v-1][0] + dp[v-1][1]\nprint(dp[N][P])']
['Wrong Answer', 'Accepted']
['s732397997', 's687516063']
[9172.0, 9164.0]
[28.0, 26.0]
[638, 722]
p03665
u414699019
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from operator import mul\nfrom functools import reduce\n\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\nN,P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=len([i for i in A if i%2==1])\neven=len([i for i in A if i%2==0])\n\nif P==0:\n ans=2**even\n ans_odd=1\n if odd!=0:\n for i in range(odd//2+1):\n ans_odd+=cmb(odd,2*i)\nelse:\n ans=2**even\n ans_odd=0\n if odd!=0:\n for i in range(odd//2):\n ans_odd+=cmb(odd,2*i+1)\nprint(ans*ans_odd)', 'from operator import mul\nfrom functools import reduce\n\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\nN,P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=len([i for i in A if i%2==1])\neven=len([i for i in A if i%2==0])\n\nif P==0:\n ans=2**even\n ans_odd=1\n if odd!=0:\n ans_odd=0\n for i in range(odd//2+1):\n ans_odd+=cmb(odd,2*i)\nelse:\n ans=2**even\n ans_odd=0\n if odd!=0:\n for i in range(odd//2):\n ans_odd+=cmb(odd,2*i+1)\nprint(ans*ans_odd)']
['Wrong Answer', 'Accepted']
['s103542970', 's103257654']
[3572.0, 3700.0]
[23.0, 26.0]
[613, 631]
p03665
u427344224
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N, P = map(int, input().split())\na_list = list(map(int, input().split()))\nimport math\ncount = 0\neven_count = 0\nodd_count = 0\nfor a in a_list:\n if a % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n\nif even_count > 0:\n print(2**(N-1))\n\nelse:\n if P == 0:\n print(2**N)\n else:\n print(0)', 'N, P = map(int, input().split())\na_list = list(map(int, input().split()))\na=[i%2 for i in a_list]\nif sum(a)>0:print(2**(N-1))\nelse:\n if P==0:\n print(2**N)\n else:\n print(0)']
['Wrong Answer', 'Accepted']
['s579965788', 's353329849']
[3064.0, 3444.0]
[17.0, 25.0]
[326, 191]
p03665
u432688695
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["# -*- coding: utf-8 -*-\n\nimport sys\nimport os\n\ninput_text_path = __file__.replace('.py', '.txt')\nfd = os.open(input_text_path, os.O_RDONLY)\nos.dup2(fd, sys.stdin.fileno())\n\nN, P = map(int, input().split())\n\nA_temp = list(map(int, input().split()))\nA = []\n\nfor a in A_temp:\n A.append(a % 2)\n\nzero_num = A.count(0)\none_num = A.count(1)\n\ndef Permutation(n, m):\n ret = 1\n for i in range(m):\n ret *= (n - i)\n return ret\n\ndef Combination(n, m):\n #import itertools\n #lst = [1] * n\n #c = list(itertools.combinations(lst, m))\n \n return Permutation(n, m) // Permutation(m, m)\n\ncombination_for_one = 0\nif P == 0:\n for i in range(2, one_num + 1, 2):\n combination_for_one += Combination(one_num, i)\n combination_for_one += 1\nelse:\n for i in range(0, one_num, 2):\n combination_for_one += Combination(one_num, i)\n\nans = combination_for_one * (2 ** zero_num)\n\nprint(ans)", '# -*- coding: utf-8 -*-\n\nimport sys\nimport os\nimport math\n\nN, P = map(int, input().split())\n\nA_temp = list(map(int, input().split()))\nA = []\n\nfor a in A_temp:\n A.append(a % 2)\n\nzero_num = A.count(0)\none_num = A.count(1)\n\ndef Combination(n, m):\n #print(str(n) + "C" + str(m))\n f = math.factorial\n return f(n) // f(m) // f(n - m)\n\ncombination_for_one = 0\nif P == 0:\n for i in range(0, one_num + 1, 2):\n combination_for_one += Combination(one_num, i)\nelse:\n for i in range(1, one_num, 2):\n combination_for_one += Combination(one_num, i)\n\nans = combination_for_one * (2 ** zero_num)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s157778596', 's907338347']
[3064.0, 3064.0]
[18.0, 17.0]
[925, 622]
p03665
u445511055
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['# -*- coding: utf-8 -*-\nimport math\n\ndef main():\n """Function."""\n n, p = map(int, input().split())\n a = list(map(int, input().split()))\n\n e_count, o_count = 0, 0\n for dum in a:\n if dum % 2 == 0:\n e_count += 1\n else:\n o_count += 1\n\n print(e_count)\n print(o_count)\n\n total = 0\n if p == 0:\n dum = 1\n for i in range(o_count // 2):\n n = (i + 1) * 2\n dum += (math.factorial(o_count) // (math.factorial(o_count - n) * math.factorial(n)))\n total += (2 ** e_count) * dum\n\n elif p == 1:\n if o_count == 0:\n pass\n else:\n dum = 0\n for i in range((o_count + 1) // 2):\n n = (i * 2) + 1\n dum += (math.factorial(o_count) // (math.factorial(o_count - n) * math.factorial(n)))\n total += (2 ** e_count) * dum\n\n print(total)\n\n\nif __name__ == "__main__":\n main()\n', '# -*- coding: utf-8 -*-\nimport math\n\ndef main():\n """Function."""\n n, p = map(int, input().split())\n a = list(map(int, input().split()))\n\n e_count, o_count = 0, 0\n for dum in a:\n if dum % 2 == 0:\n e_count += 1\n else:\n o_count += 1\n\n total = 0\n if p == 0:\n dum = 1\n for i in range(o_count // 2):\n n = (i + 1) * 2\n dum += (math.factorial(o_count) // (math.factorial(o_count - n) * math.factorial(n)))\n total += (2 ** e_count) * dum\n\n elif p == 1:\n if o_count == 0:\n pass\n else:\n dum = 0\n for i in range((o_count + 1) // 2):\n n = (i * 2) + 1\n dum += (math.factorial(o_count) // (math.factorial(o_count - n) * math.factorial(n)))\n total += (2 ** e_count) * dum\n\n print(total)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s191023108', 's612781527']
[3064.0, 3064.0]
[18.0, 18.0]
[945, 906]
p03665
u445624660
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\n\nn, p = map(int, input().split())\nodds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))\nevens = n - odds\n\ndef ncr(n, r):\n res = 1\n for i in range(1, r + 1):\n res = res * (n - i + 1) // i\n return res\n\n\nans = 0\nif p == 0:\n for i in range(0, odds, 2):\n ans += ncr(odds, i)\n ans *= max(1, 2 ** evens)\nelse:\n for i in range(1, odds, 2):\n ans += ncr(odds, i)\n ans *= max(1, 2 ** evens)\nprint(ans)\n', '\n\nn, p = map(int, input().split())\nodds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))\nevens = n - odds\n\nprint(evens, odds)\n\n\ndef ncr(n, r):\n res = 1\n for i in range(1, r + 1):\n res = res * (n - i + 1) // i\n return res\n\n\nans = 0\nif p == 0:\n for i in range(0, odds, 2):\n ans += ncr(odds, i)\n ans *= max(1, 2 ** evens)\nelse:\n for i in range(1, odds, 2):\n ans += ncr(odds, i)\n ans *= max(1, 2 ** evens)\nprint(ans)\n', '\n\nn, p = map(int, input().split())\nodds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))\nevens = n - odds\n\n\ndef ncr(n, r):\n res = 1\n for i in range(1, r + 1):\n res = res * (n - i + 1) // i\n return res\n\n\nans = 0\nif p == 0:\n for i in range(0, odds, 2):\n ans += ncr(odds, i)\n if evens > 0:\n ans *= max(1, 2 ** evens)\nelse:\n for i in range(1, odds, 2):\n ans += ncr(odds, i)\n if evens > 0:\n ans *= max(1, 2 ** evens)\nprint(ans)\n', '\n\n\n\nn, p = map(int, input().split())\nodds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))\nevens = n - odds\n\n\ndef ncr(n, r):\n res = 1\n for i in range(1, r + 1):\n res = res * (n - i + 1) // i\n return res\n\n\nans = 0\nif p == 0:\n for i in range(0, odds + 1, 2):\n ans += ncr(odds, i)\n if evens > 0:\n ans *= max(1, 2 ** evens)\nelse:\n if odds > 0:\n for i in range(1, odds + 1, 2):\n ans += ncr(odds, i)\n ans *= max(1, 2 ** evens)\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s017493626', 's319324315', 's711918999', 's928147966']
[3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0, 18.0]
[561, 582, 606, 703]
p03665
u474423089
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["import scipy.misc\nN,P=map(int,input().split(' '))\nA=list(map(int,input().split(' ')))\nodd = 0\neven = 0\nfor i in A:\n if i%2 !=0:\n odd += 1\n else:\n even += 1\n\nans = 0\nif P ==1:\n for i in range(1,odd+1,2):\n ans += scipy.misc.comb(odd,i)\nelse:\n for i in range(0,odd+1,2):\n ans += scipy.misc.comb(odd,i)\nans = ans*(2**even)\nprint(ans)", "import scipy.misc\nN,P=map(int,input().split(' '))\nA=list(map(int,input().split(' ')))\nodd = 0\neven = 0\nfor i in A:\n if i%2 !=0:\n odd += 1\n else:\n even += 1\n\nans = 0\nif P ==1:\n for i in range(1,odd+1,2):\n ans += scipy.misc.comb(odd,i)\nelse:\n for i in range(0,odd+1,2):\n ans += scipy.misc.comb(odd,i)\nans = ans*(2**even)\nprint(int(ans))", "import scipy.misc\nN,P=map(int,input().split(' '))\nA=list(map(int,input().split(' ')))\nodd = 0\neven = 0\nfor i in A:\n if i%2 !=0:\n odd += 1\n else:\n even += 1\n\nans = 0\nif P ==1:\n for i in range(1,odd+1,2):\n ans += scipy.misc.comb(odd,i)\nelse:\n for i in range(0,odd+1,2):\n ans += scipy.misc.comb(odd,i)\nans = ans*(2**even)\nprint(int(-(-1*ans//1)))\n", "N,P=map(int,input().split(' '))\nA=list(map(int,input().split(' ')))\nfor i in A:\n if i%2 != 0:\n print(2**(N-1))\n exit()\nif P ==0:\n print(2**N)\nelse:\n print(0)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s248843589', 's495894935', 's778585134', 's157577145']
[13484.0, 13492.0, 13520.0, 3060.0]
[164.0, 163.0, 161.0, 17.0]
[369, 374, 384, 180]
p03665
u482969053
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\n\ndef combination(n, r):\n return math.factorial(n)/math.factorial(r)/math.factorial(n-r)\n\nn, p = map(int, input().split())\na_list = list(map(int, input().split()))\nsurplus0 = 0\nsurplus1 = 0\nfor i in a_list:\n if i % 2 == 0:\n surplus0 += 1\n else:\n surplus1 += 1\n\nif p == 0:\n \n s0 = 0\n for i in range(surplus0+1):\n s0 = math.factorial(surplus0)\n \n s1 = 0\n if surplus1 == 0:\n s1 = 1\n elif surplus1 % 2 == 1:\n for i in range(surplus1//2 + 1):\n s1 += combination(surplus1, i*2)\n else:\n for i in range(surplus1//2):\n s1 += combination(surplus1, i*2)\n ans = s0 * s1\nelse:\n \n s0 = 0\n for i in range(surplus0+1):\n s0 += combination(surplus0, i)\n \n s1 = 0\n if surplus1 == 0:\n s1 = 0\n elif surplus1 % 2 == 1:\n for i in range(surplus1//2 + 1):\n s1 += combination(surplus1, i*2+1)\n else:\n for i in range(surplus1//2):\n s1 += combination(surplus1, i*2+1)\n ans = s0 * s1\n\nprint(int(ans))\n', 'import math\n\ndef combination(n, r):\n return math.factorial(n)/math.factorial(r)/math.factorial(n-r)\n\nn, p = map(int, input().split())\na_list = list(map(int, input().split()))\nsurplus0 = 0\nsurplus1 = 0\nfor i in a_list:\n if i % 2 == 0:\n surplus0 += 1\n else:\n surplus1 += 1\n\nif p == 0:\n \n s0 = 0\n for i in range(surplus0+1):\n s0 = math.factorial(surplus0)\n \n s1 = 0\n if surplus1 % 2 == 1:\n for i in range(surplus1//2 + 1):\n s1 += combination(surplus1, i*2)\n else:\n for i in range(surplus1//2):\n s1 += combination(surplus1, i*2)\n ans = s0 * s1\nelse:\n \n s0 = 0\n for i in range(surplus0+1):\n s0 += combination(surplus0, i)\n \n s1 = 0\n if surplus1 == 0:\n s1 = 0\n elif surplus1 % 2 == 1:\n for i in range(surplus1//2 + 1):\n s1 += combination(surplus1, i*2+1)\n else:\n for i in range(surplus1//2):\n s1 += combination(surplus1, i*2+1)\n ans = s0 * s1\n\nprint(int(ans))\n', 'def solve():\n N, P = list(map(int, input().split()))\n A = list(map(int, input().split()))\n if all([x % 2 == 0 for x in A]):\n if P == 0:\n print(2 ** N)\n else:\n print(0)\n else:\n print(2 ** (N-1))\n\nsolve()\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s056334331', 's283622606', 's591676280']
[3064.0, 3064.0, 3316.0]
[19.0, 21.0, 20.0]
[1212, 1173, 258]
p03665
u511630329
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N, P = map(int, input().split())\nA = [int(a) for a in input().split()]\ndp=[[0,0] for _ in range(N)]\ndp[0]=[2,0]\nfor i in range(1,N):\n if A[i]%2 ==0:\n dp[i][0]=dp[i-1][0]*2\n dp[i][1]=dp[i-1][1]*2\n else:\n dp[i][0]=dp[i-1][0]*2\n dp[i][1]+=dp[i-1][0]\n print(dp[i])\nprint(dp[N-1][P])', 'N, P = map(int, input().split())\nA = [int(a) for a in input().split()]\ndp=[[0,0] for _ in range(N)]\ndp[0]=[2,0]\nfor i in range(1,N):\n if A[i]%2 ==0:\n dp[i][0]=dp[i-1][0]*2\n dp[i][1]=dp[i-1][1]*2\n else:\n dp[i][0]=dp[i-1][0]*2\n dp[i][1]+=dp[i-1][0]\n print(dp[i])\nprint(dp[N-1][A[N-1]%2])', 'N, P = map(int, input().split())\nA = [int(a) for a in input().split()]\ndp=[[0,0] for _ in range(N)]\ndp[0]=[2,0]\nfor i in range(1,N):\n if A[i-1]%2 ==0:\n dp[i][0]=dp[i-1][0]*2\n dp[i][1]=dp[i-1][1]*2\n else:\n dp[i][0]=dp[i-1][0]*2\n dp[i][1]+=dp[i-1][0]\n P=1\nprint(dp[N-1][P])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s971115530', 's995637453', 's427542397']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 17.0]
[320, 327, 313]
p03665
u513434790
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from math import factorial\n\ndef c(n,k):\n return factorial(n)/(factorial(n-k) * factorial(k))\n\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\n\no = 0\ne = 0\n\nfor i in A:\n if i % 2 == 0:\n e += 1\n else:\n o += 1\non = o // 2\n\na = []\nb = []\nans = 0\n\nif P == 0:\n for i in range(e+1):\n a.append(c(e,i))\n for i in range(on+1):\n b.append(c(o,i*2)) \n for i in a:\n for j in b:\n ans += i * j\nelse:\n for i in range(e+1):\n a.append(c(e,i))\n for i in range(1,o+1)[::2]:\n b.append(c(o,i)) \n for i in a:\n for j in b:\n ans += i * j\n \nprint(ans)', 'from math import factorial\n\ndef c(n,k):\n return factorial(n)/(factorial(n-k) * factorial(k))\n\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\n\no = 0\ne = 0\n\nfor i in A:\n if i % 2 == 0:\n e += 1\n else:\n o += 1\non = o // 2\n\na = []\nb = []\nans = 0\n\nif P == 0:\n for i in range(e+1):\n a.append(c(e,i))\n for i in range(on+1):\n b.append(c(o,i*2)) \n for i in a:\n for j in b:\n ans += i * j\nelse:\n for i in range(e+1):\n a.append(c(e,i))\n for i in range(1,o+1)[::2]:\n b.append(c(o,i)) \n for i in a:\n for j in b:\n ans += i * j\n\nans = int(ans)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s026345576', 's418680139']
[3064.0, 3064.0]
[17.0, 17.0]
[671, 678]
p03665
u535171899
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from math import factorial\n\nn,p = map(int,input().split())\na_input = list(map(int,input().split()))\n\n\n\ndef calc_comb(n,r):\n return factorial(n) / factorial(r) / factorial(n - r)\n\nodd_len = 0\neven_len = 0\nfor i in range(n):\n if a_input[i]%2==0:\n even_len+=1\n else:\n odd_len+=1\n\nans=0\neven_comb = 2**even_len\nif p==0:\n if odd_len%2==0:\n for i in range(0,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\n print(i)\n if odd_len%2==1:\n for i in range(1,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\nelse:\n if odd_len%2==0:\n for i in range(1,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\n if odd_len%2==1:\n for i in range(0,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\nprint(int(ans))\n', 'from math import factorial\n\nn,p = map(int,input().split())\na_input = list(map(int,input().split()))\n\n\n\ndef calc_comb(n,r):\n return factorial(n) / factorial(r) / factorial(n - r)\n\nodd_len = 0\neven_len = 0\nfor i in range(n):\n if a_input[i]%2==0:\n even_len+=1\n else:\n odd_len+=1\n\nans=0\neven_comb = 2**even_len\nif p==0:\n if odd_len%2==0:\n for i in range(0,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\n if odd_len%2==1:\n for i in range(1,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\nelse:\n if odd_len%2==0:\n for i in range(1,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\n if odd_len%2==1:\n for i in range(0,odd_len+1,2):\n ans+=calc_comb(odd_len,i)*even_comb\nprint(int(ans))\n']
['Wrong Answer', 'Accepted']
['s724674131', 's533376293']
[3188.0, 3064.0]
[20.0, 18.0]
[910, 889]
p03665
u537782349
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['a, b = map(int, input().split())\nc = list(map(int, input().split()))\ne_odd = False\nfor i in c:\n if i % 2 == 1:\n e_odd = not e_odd\n break\nif not e_odd:\n if b == 1:\n print(0)', 'a, b = map(int, input().split())\nc = list(map(int, input().split()))\nd = 0\ne = 0\nfor i in c:\n if i % 2 == 0:\n d += 1\n else:\n e += 1\nif e == 0:\n if b == 0:\n print(2 ** a)\n else:\n print(0)\nelse:\n print(2 ** (a - 1))\n']
['Wrong Answer', 'Accepted']
['s430165016', 's118648782']
[3064.0, 2940.0]
[19.0, 18.0]
[199, 257]
p03665
u537963083
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from collections import Counter\nimport itertools\nimport math\n\nn, p = map(int, input().split())\nalist = map(int, input().split())\n\nd = Counter()\nfor a in alist:\n d[a % 2] += 1\n\n# print(d)\n\nzeros = 2 ** d[0]\n\n\nones = 0\nif p == 0:\n for i in range(d[1]):\n if i % 2 == 0:\n ones += math.factorial(d[1]) // (math.factorial(d[1] - i) * math.factorial(i))\n # print(i)\n \nelse:\n for i in range(d[1]):\n if i % 2 == 1:\n ones += math.factorial(d[1]) // (math.factorial(d[1] - i) * math.factorial(i))\n # print(i)\n \n\n\n\n\nprint(zeros * ones)\n', 'from collections import Counter\nimport itertools\nimport math\n\nn, p = map(int, input().split())\nalist = map(int, input().split())\n\nd = Counter()\nfor a in alist:\n d[a % 2] += 1\n\n# print(d)\n\nzeros = 2 ** d[0]\n\n\nones = 0\nif p == 0:\n for i in range(d[1]+1):\n if i % 2 == 0:\n ones += math.factorial(d[1]) // (math.factorial(d[1] - i) * math.factorial(i))\n # print(i)\n \nelse:\n for i in range(d[1]+1):\n if i % 2 == 1:\n ones += math.factorial(d[1]) // (math.factorial(d[1] - i) * math.factorial(i))\n # print(i)\n \n\n\n\n\nprint(zeros * ones)\n']
['Wrong Answer', 'Accepted']
['s652598425', 's024252474']
[3316.0, 3316.0]
[21.0, 21.0]
[650, 654]
p03665
u540761833
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\nN,P = map(int,input().split())\nA = [i%2 for i in list(map(int,input().split()))]\nodd,even = A.count(1),A.count(0)\nsumo = 0\nfor i in range(0,odd+1,P+1):\n sumo += int(math.factorial(odd)//(math.factorial(odd-i)*math.factorial(i)))\nprint(sumo*(2**even))', 'import math\nN,P = map(int,input().split())\nA = [i%2 for i in list(map(int,input().split()))]\nodd,even = A.count(1),A.count(0)\nsumo = 0\nfor i in range(P,odd+1,2):\n sumo += int(math.factorial(odd)//(math.factorial(odd-i)*math.factorial(i)))\nprint(sumo*(2**even))']
['Wrong Answer', 'Accepted']
['s995539034', 's496611471']
[3060.0, 3064.0]
[17.0, 17.0]
[265, 263]
p03665
u541318412
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from operator import mul\nfrom functools import reduce\n\n\nn,p = map(int,input().split())\nL = list(map(int,input().split()))\n\nLLeven = map(lambda x: x % 2, L)\nLLodd = map(lambda x: x % 2, L)\n\neven = list(LLeven).count(0)\nodd = list(LLodd).count(1)\n\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\n\ndef pattern(x):\n (choose_even,choose_odd) = (0,0)\n for i in range(x):\n if i%2 == 0:\n choose_even += cmb(x,i)\n else:\n choose_odd += cmb(x,i)\n return(choose_even,choose_odd)\n\nif p == 0:\n print(2**even * pattern(odd)[0])\nelse:\n print(2**even * pattern(odd)[1])', 'from operator import mul\nfrom functools import reduce\n\n\nn,p = map(int,input().split())\nL = list(map(int,input().split()))\n\nLLeven = map(lambda x: x % 2, L)\nLLodd = map(lambda x: x % 2, L)\n\neven = list(LLeven).count(0)\nodd = list(LLodd).count(1)\n\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\n\ndef pattern(x):\n (choose_even,choose_odd) = (0,0)\n for i in range(x+1):\n if i%2 == 0:\n choose_even += cmb(x,i)\n else:\n choose_odd += cmb(x,i)\n return(choose_even,choose_odd)\n\nif p == 0:\n print(2**even * pattern(odd)[0])\nelse:\n print(2**even * pattern(odd)[1])']
['Wrong Answer', 'Accepted']
['s141753655', 's874556737']
[3700.0, 3572.0]
[23.0, 22.0]
[722, 724]
p03665
u543954314
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\n\ndef cc(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn, p = map(int, input().split())\na = list(map(int, input().split()))\no = 0\ne = 0\ns = 0\nfor i in a:\n if i%2:\n o += 1\n else:\n e += 1\nif p:\n for j in range(1,o,2):\n s += cc(o, j)\nelse:\n for k in range(0,o,2):\n s += cc(o, k)\nprint(s*2**e)\n ', 'import math\n\ndef cc(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn, p = map(int, input().split())\na = list(map(int, input().split()))\no = 0\ne = 0\ns = 0\nfor i in a:\n if i%2:\n o += 1\n else:\n e += 1\nif p:\n for j in range(1,o+1,2):\n s += cc(o, j)\nelse:\n for k in range(0,o+1,2):\n s += cc(o, k)\nprint(s*2**e)\n \n']
['Wrong Answer', 'Accepted']
['s040511941', 's344823507']
[3064.0, 3064.0]
[18.0, 18.0]
[357, 362]
p03665
u559823804
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p=map(int,input().split())\na=list(map(int,input().split()))\nprint(2**(N-1))', 'n, p = map(int, input().split())\na = list(map(lambda x: x % 2, map(int, input().split())))\ne=a.count(0)\n\nans=2**(n-1)\nif p==1 and e==n:\n ans=0\nif p==0 and e==0:\n ans=2**n\nprint(ans)', 'n,p=map(int,input().split())\na=list(map(lambda x: x%2, map(int,input().split())))\ne=a.count(0)\n\nans=2**(n-1)\nif p==1 and e==n:\n ans=0\nif p==0 and e==n:\n ans=2**n\nprint(ans)\n\n \n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s059539776', 's654104297', 's888258122']
[2940.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0]
[77, 187, 185]
p03665
u572012241
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n, p = map(int, input().split())\na = list(map(int, input().split()))\n\nodd = 0\neven = 0\n\nfor i in a:\n if a %2 ==0:\n even +=1\n else:\n odd+=1\nif even == n:\n if p == 0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))', 'n, p = map(int, input().split())\na = list(map(int, input().split())\n\nodd = 0\neven = 0\n\nfor i in a:\n if a %2 ==0:\n even +=1\n else:\n odd+=1\nif even == n:\n if p == 0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))', 'n, p = map(int, input().split())\na = list(map(int, input().split()))\n\nodd = 0\neven = 0\n\nfor i in a:\n if i %2 ==0:\n even +=1\n else:\n odd+=1\nif even == n:\n if p == 0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s667976258', 's815927719', 's730190551']
[3064.0, 2940.0, 3060.0]
[18.0, 17.0, 19.0]
[260, 259, 260]
p03665
u576917603
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\ndef ncr(n, r):\n return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))\nn,p=map(int,input().split())\na=list(map(int,input().split()))\nodd=0\neven=0\n\nfor i in a:\n if i%2==0:\n even+=1\n else:\n odd+=1\n\nif p==1:\n ans=2**even\n odd_choice=0\n for i in range(1,odd+1,2):\n odd_choice+=ncr(odd,i)\n print(ans*odd_choice if even!=0 else odd_choice)\n\nelse:\n ans=2**even\n if even==0:\n ans=0\n odd_choice=0\n for i in range(0,odd+1,2):\n odd_choice+=ncr(odd,i)\n print(ans*odd_choice)', 'import math\ndef ncr(n, r):\n return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))\nn,p=map(int,input().split())\na=list(map(int,input().split()))\nodd=0\neven=0\n\nfor i in a:\n if i%2==0:\n even+=1\n else:\n odd+=1\n\nif p==1:\n ans=2**even\n odd_choice=0\n for i in range(1,odd+1,2):\n odd_choice+=ncr(odd,i)\n print(ans*odd_choice if even!=0 else odd_choice)\n\nelse:\n ans=2**even\n if even==0:\n ans=0\n odd_choice=0\n for i in range(0,odd+1,2):\n odd_choice+=ncr(odd,i)\n print(ans*odd_choice if even!=0 else odd_choice)']
['Wrong Answer', 'Accepted']
['s679765303', 's563445460']
[3064.0, 3064.0]
[17.0, 20.0]
[556, 583]
p03665
u587589241
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['def comb(n,k):\n nCk = 1\n MOD = 10**9+7\n\n for i in range(n-k+1, n+1):\n nCk *= i\n nCk %= MOD\n\n for i in range(1,k+1):\n nCk *= pow(i,MOD-2,MOD)\n nCk %= MOD\n return nCk\nn,p=map(int,input().split())\na=list(map(lambda x:int(x)%2,input().split()))\non=a.count(1)\nze=a.count(0)\nprint(on,ze)\nans=0\nif on==0:\n if p==0:\n print(2**n)\n exit()\n if p==1:\n print(0)\n exit()\n \nprint(2**(n-1))', 'n,p=map(int,input().split())\na=list(map(lambda x:int(x)%2,input().split()))\non=a.count(1)\nze=a.count(0)\nans=0\nif on==0:\n if p==0:\n print(2**n)\n exit()\n if p==1:\n print(0)\n exit()\n \nprint(2**(n-1))']
['Wrong Answer', 'Accepted']
['s586913979', 's397545774']
[9140.0, 9176.0]
[29.0, 25.0]
[454, 233]
p03665
u589087860
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n, p = map(int, input().split())\n\na = list(input())\n\nif p == 1:\n print(0)\n\nelif p == 0:\n print(2 ** n)\n\nelse:\n print(2 ** (n - 1))\n', 'n, p = map(int, input().split())\n\na = list(input())\n\nfor i in len(a):\n if i % 2 == 1:\n print(2 ** (n - 1))\n exit(0)\n\nif p == 0:\n print(2 ** n)\n\nelse:\n print(0)\n', 'n, p = map(int, input().split())\n\na = list(input())\n\nfor i in a:\n if i % 2 == 1:\n print(2 ** (n - 1))\n exit(0)\n\nif p == 0:\n print(2 ** n)\n\nelse:\n print(0)\n', 'n, p = map(int, input().split())\n\na = list(map(int, input().split()))\n\n#print(a)\n\nfor i in a:\n if i % 2 == 1:\n print(2 ** (n - 1))\n exit(0)\n\nif p == 0:\n print(2 ** n)\n\nelse:\n print(0)\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s216643785', 's316576757', 's728004385', 's553267610']
[2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 18.0]
[140, 183, 178, 207]
p03665
u593567568
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P = map(int,input().split())\nA = list(map(int,input().split()))\n\nA = [a % 2 for a in A]\n\nacc = [1] * 60\nfor i in range(60):\n if i == 0:\n continue\n acc[i] = acc[i-1] * i\n\nodd = sum(A)\neven = N - odd\n\nans = 0\nif P == 0:\n \n j = 0\n for i in range(0,odd,2):\n j += acc[odd] // (acc[odd-i] * acc[i])\n \nelse:\n \n j = 0\n for i in range(1,odd,2):\n j += acc[odd] // (acc[odd-i] * acc[i])\n \nans = 0\nfor i in range(even):\n k = acc[even] // (acc[even-i] * acc[i])\n ans += k * j\n \nprint(ans)\n ', 'N,P = map(int,input().split())\nA = list(map(int,input().split()))\n\nA = [a % 2 for a in A]\n\nacc = [1] * 60\nfor i in range(60):\n if i == 0:\n continue\n acc[i] = acc[i-1] * i\n\nodd = sum(A)\neven = N - odd\n\nans = 0\nif P == 0:\n \n j = 0\n for i in range(0,odd+1,2):\n j += acc[odd] // (acc[odd-i] * acc[i])\n \nelse:\n \n j = 0\n for i in range(1,odd+1,2):\n j += acc[odd] // (acc[odd-i] * acc[i])\n \nans = 0\nfor i in range(even):\n k = acc[even] // (acc[even-i] * acc[i])\n ans += k * j\n \nprint(ans)\n \n', 'N,P = map(int,input().split())\nA = list(map(int,input().split()))\n\nA = [a % 2 for a in A]\n\nacc = [1] * 60\nfor i in range(60):\n if i == 0:\n continue\n acc[i] = acc[i-1] * i\n\nodd = sum(A)\neven = N - odd\n\nans = 0\nif P == 0:\n \n j = 0\n for i in range(0,odd+1,2):\n j += acc[odd] // (acc[odd-i] * acc[i])\n\nelse:\n \n j = 0\n for i in range(1,odd+1,2):\n j += acc[odd] // (acc[odd-i] * acc[i])\n \nans = 0\nfor i in range(even+1):\n k = acc[even] // (acc[even-i] * acc[i])\n ans += k * j\n \nprint(ans)\n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s007000013', 's247796978', 's293921941']
[3064.0, 3064.0, 3064.0]
[18.0, 18.0, 17.0]
[570, 575, 575]
p03665
u614181788
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p = map(int,input().split())\na = list(map(int,input().split()))\n\ns = [0]*n\nfor i in range(n):\n if a[i]%2 == 0:\n s[i] = 0\n else:\n s[i] = 1\nimport collections\nc = collections.Counter(s)\nodd = c[1]\neven = c[0]\nx = 0\ni = 0\nwhile 2*i+p <= even:\n x += comb(even, i, exact=True)\n i += 1\nfrom scipy.special import comb\nans = 0\ni = 0\nwhile 2*i+p <= odd:\n ans += comb(odd, 2*i+p, exact=True)*x\n i += 1\nif p == 0:\n print(ans)\nelse:\n print(ans*2)', 'import math\ndef comb(n, r): #comb(int, int)\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\nn,p = map(int,input().split())\na = list(map(int,input().split()))\na_even = 0\na_odd = 0\nfor i in range(n):\n if a[i]%2 == 0:\n a_even += 1\n else:\n a_odd += 1\nans = 0\nif p%2 == 0:\n k = 0\n for i in range(10**10):\n if 2*i > a_odd:\n break\n k += comb(a_odd, 2*i)\n print(k*2**a_even)\nelse:\n k = 0\n for i in range(10**10):\n if 2*i+1 > a_odd:\n break\n k += comb(a_odd, 2*i+1)\n print(k*2**a_even)']
['Runtime Error', 'Accepted']
['s228408664', 's181014270']
[3316.0, 9168.0]
[21.0, 30.0]
[477, 591]
p03665
u619819312
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,r=map(int,input().split())\nc=[i%2for i in list(map(int,input().split()))]\np=sum(c)\nprint((2**(n-1))if p==0 else(0if r!=1else 2**n))', 'n,r=map(int,input().split())\nc=[i%2for i in list(map(int,input().split()))]\np=sum(c)\nprint(0if p==0 and r!=0else(2**n if p==0 and r!=1else (2**(n-1))))']
['Wrong Answer', 'Accepted']
['s009966845', 's199096436']
[3060.0, 3064.0]
[18.0, 21.0]
[133, 151]
p03665
u630088114
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import sys\n\ndef biscuit(N, P, As):\n n_even = 0\n n_odd = 0\n for a in As:\n if int(a) % 2 == 0:\n n_even += 1\n else:\n n_odd +=1\n v = 2**n_even\n print(n_even, n_odd)\n if n_odd == 0:\n v *= (0 if int(P) == 1 else 1)\n else:\n v *= 2**(n_odd -1)\n return v\n\nN, P = sys.stdin.readline().strip().split()\nAs = sys.stdin.readline().strip().split()\nprint(biscuit(N, P, As))', 'import sys\n\ndef biscuit(N, P, As):\n n_even = 0\n n_odd = 0\n for a in As:\n if int(a) % 2 == 0:\n n_even += 1\n else:\n n_odd +=1\n v = 2**n_even\n \n if n_odd == 0:\n v *= (0 if int(P) == 1 else 1)\n else:\n v *= 2**(n_odd -1)\n return v\n\nN, P = sys.stdin.readline().strip().split()\nAs = sys.stdin.readline().strip().split()\nprint(biscuit(N, P, As))\n']
['Wrong Answer', 'Accepted']
['s175489223', 's801027770']
[3064.0, 3064.0]
[17.0, 17.0]
[415, 417]
p03665
u636387751
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from scipy.misc import comb\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\nodd = 0\neven = 0\nfor i in range(N):\n if A[i]%2 == 0:\n even += 1\n else:\n odd += 1\nm = 0\nif P == 0:\n for i in range(0,odd+1,2):\n m += int(comb(odd,i))\nelse:\n for i in range(1,odd+1,2):\n m += int(comb(odd,i))\n\nprint(m*(2**even))\n', 'from scipy.misc import comb\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\nodd = 0\neven = 0\nfor i in range(N):\n if A[i]%2 == 0:\n even += 1\n else:\n odd += 1\nm = 0\nif P == 0:\n for i in range(0,odd+1,2):\n m += int(comb(odd,i))\nelse:\n for i in range(1,odd+1,2):\n m += int(comb(odd,i))\n\nprint(m*(2**even))\n', 'N, P = map(int, input().split())\nA = list(map(int, input().split()))\nodd = 0\neven = 0\nfor i in range(N):\n if A[i]%2 == 0:\n even += 1\n else:\n odd += 1\n\nC = {(0,0):1}\ndef comb(n,k):\n if n == 0 or k == 0 or k == n:\n return 1\n else:\n if (n,k) in C:\n return C[(n,k)]\n else:\n C[(n,k)] = comb(n-1,k) + comb(n-1,k-1)\n return C[(n,k)]\nm = 0\nif P == 0:\n for i in range(0,odd+1,2):\n m += int(comb(odd,i))\nelse:\n for i in range(1,odd+1,2):\n m += int(comb(odd,i))\nprint(m*(2**even))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s697805782', 's986126847', 's530950088']
[26208.0, 14768.0, 3188.0]
[414.0, 1459.0, 20.0]
[363, 363, 570]
p03665
u644907318
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P = map(int,input().split())\nA = list(map(int,input().strip()))\ncnt = 0\nfor i in range(N):\n cnt += A[i]%2\nprint(2**(N-1))', 'N,P = map(int,input().split())\nA = list(map(int,input().split()))\ncnt = 0\nfor i in range(N):\n cnt += A[i]%2\nif cnt>0:\n print(2**(N-1))\nelif P==1:\n print(0)\nelse:\n print(2**N)']
['Runtime Error', 'Accepted']
['s646012447', 's960607541']
[3064.0, 3060.0]
[17.0, 17.0]
[126, 186]
p03665
u645250356
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush,heapify\nimport sys,bisect,math,itertools,fractions\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\ndef conb(n,r): \n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn,m = inpl()\na = inpl()\nodd = even = 0\nfor x in a:\n if x%2: odd += 1\n else: even += 1\nres = pow(2,even)\nores = eres = 0\nfor i in range(odd):\n if i%2 == 0:\n eres += conb(odd,i)\n else:\n ores += conb(odd,i)\nif m:\n print(ores*res)\nelse:\n print(eres*res)", "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush,heapify\nimport sys,bisect,math,itertools,fractions\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\ndef conb(n,r): \n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn,m = inpl()\na = inpl()\nodd = even = 0\nfor x in a:\n if x%2: odd += 1\n else: even += 1\nres = pow(2,even)\nores = eres = 0\nfor i in range(odd+1):\n if i%2 == 0:\n eres += conb(odd,i)\n else:\n ores += conb(odd,i)\nif m:\n print(ores*res)\nelse:\n print(eres*res)"]
['Wrong Answer', 'Accepted']
['s589721266', 's426151264']
[5040.0, 5084.0]
[35.0, 37.0]
[681, 683]
p03665
u653807637
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["# encoding:utf-8\nimport math\n\ndef main():\n\tN, P = list(map(int, input().split()))\n\tbiscuits = list(map(int, input().split()))\n\n\tn_odd = sum([x % 2 for x in biscuits])\n\tn_even = N - n_odd\n\n\tprint(n_odd)\n\tprint(calcNPtrn_odd(n_odd, P))\n\tprint(calcNPtrn_even(n_even))\n\n\tout = calcNPtrn_odd(n_odd, P) * calcNPtrn_even(n_even)\n\tprint(out)\n\t\ndef calcComb(n, m):\n\treturn(math.factorial(n)/math.factorial(m)/math.factorial(n-m))\n\ndef calcNPtrn_odd(n, is_odd):\n\tif n == 0:\n\t\tif is_odd == 1:\n\t\t\treturn(0)\n\t\telse:\n\t\t\treturn(1)\n\n\tcount = 0\n\tif is_odd == 1:\n\t\tfor i in range(1, n + 1, 2):\n\t\t\tcount += calcComb(n, i)\n\t\t\tprint(count)\n\telse:\n\t\tcount = 0\n\t\tfor i in range(0, n + 1, 2):\n\t\t\tcount += calcComb(n, i)\n\n\treturn(int(count))\n\ndef calcNPtrn_even(n):\n\tif n == 0:\n\t\treturn(1)\n\n\tcount = 0\n\tfor i in range(0, n + 1):\n\t\tcount += calcComb(n, i)\n\treturn(int(count))\n\nif __name__ == '__main__':\n\tmain()", "# encoding:utf-8\nimport math\n\ndef main():\n\tN, P = list(map(int, input().split()))\n\tbiscuits = list(map(int, input().split()))\n\n\tn_odd = sum([x % 2 for x in biscuits])\n\tn_even = N - n_odd\n\n\tout = calcNPtrn_odd(n_odd, P) * calcNPtrn_even(n_even)\n\tprint(out)\n\t\ndef calcComb(n, m):\n\treturn(math.factorial(n)/math.factorial(m)/math.factorial(n-m))\n\ndef calcNPtrn_odd(n, is_odd):\n\tif n == 0:\n\t\tif is_odd == 1:\n\t\t\treturn(0)\n\t\telse:\n\t\t\treturn(1)\n\n\tcount = 0\n\tif is_odd == 1:\n\t\tfor i in range(1, n + 1, 2):\n\t\t\tcount += calcComb(n, i)\n\telse:\n\t\tfor i in range(0, n + 1, 2):\n\t\t\tcount += calcComb(n, i)\n\n\treturn(int(count))\n\ndef calcNPtrn_even(n):\n\tif n == 0:\n\t\treturn(1)\n\n\tcount = 1\n\tfor i in range(1, n + 1):\n\t\tcount += calcComb(n, i)\n\treturn(int(count))\n\nif __name__ == '__main__':\n\tmain()"]
['Wrong Answer', 'Accepted']
['s430725068', 's687547305']
[3064.0, 3064.0]
[19.0, 17.0]
[885, 779]
p03665
u655663334
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import itertools\nimport math\nfrom math import factorial\n\nN,P = list(map(int, input().split()))\nAs = list(map(int, input().split()))\n\n\nodd = 0\neven = 0\n\nfor A in As:\n if(A % 2 == 0):\n even += 1\n else:\n odd += 1\n\n\n\neven_combi = 0\n\nfor i in range(even+1):\n even_combi += math.factorial(even) // math.factorial(i) // math.factorial(even-i)\n\nprint(even_combi)\n\n\n\n\n\nodd_combi = 0\n\nif(P == 0):\n for i in range(0,odd + 1,2):\n odd_combi += math.factorial(odd) // math.factorial(i) // math.factorial(odd-i)\n\nelse:\n for i in range(1, odd + 1 , 2):\n odd_combi += math.factorial(odd) // math.factorial(i) // math.factorial(odd-(i))\n\nprint(odd_combi*even_combi)', 'import itertools\nimport math\nfrom math import factorial\n\nN,P = list(map(int, input().split()))\nAs = list(map(int, input().split()))\n\n\nodd = 0\neven = 0\n\nfor A in As:\n if(A % 2 == 0):\n even += 1\n else:\n odd += 1\n\n\n\neven_combi = 0\n\nfor i in range(even+1):\n even_combi += math.factorial(even) // math.factorial(i) // math.factorial(even-i)\n\n#print(even_combi)\n\n\n\n\n\nodd_combi = 0\n\nif(P == 0):\n for i in range(0,odd + 1,2):\n odd_combi += math.factorial(odd) // math.factorial(i) // math.factorial(odd-i)\n\nelse:\n for i in range(1, odd + 1 , 2):\n odd_combi += math.factorial(odd) // math.factorial(i) // math.factorial(odd-(i))\n\nprint(odd_combi*even_combi)']
['Wrong Answer', 'Accepted']
['s427205736', 's489133150']
[9212.0, 9192.0]
[30.0, 28.0]
[972, 973]
p03665
u667084803
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=0\nfor i in range(N):\n if A[i]%2==1: odd+=1\n break\nif odd==0:\n if P==1: print(0)\n else: print(2**N)\nelse:\n print(2**(N-1))', 'import math\ndef comb(n,r):\n return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))\n\nN,P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=0\neven=0\ntotal=0\nfor i in range(N):\n total+=A[i]\n if A[i]%2==0:\n even+=1\n else: \n odd+=1\ntotal=total%2\nevens=2**even\n\nans=0\nif total==even%2:\n for i in range(int((odd+1)/2)): \n ans+=comb(odd,2*i)\nelse:\n for i in range(int((odd+1)/2)):\n ans+=comb(odd,2*i+1)\nprint(ans*evens)', 'import math\ndef comb(n,r):\n return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))\n\nN,P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=0\neven=0\ntotal=0\nfor i in range(N):\n total+=A[i]\n if A[i]%2==0:\n even+=1\n else: \n odd+=1\ntotal=total%2\nevens=2**even\n\nans=0\nif total==even%2:\n for i in range(int((odd+1)/2)): \n ans+=comb(odd,2*i)\n print(comb(odd,2*i))\nelse:\n for i in range(int((odd+1)/2)):\n ans+=comb(odd,2*i+1)\n print(comb(odd,2*i+1))\nprint(ans*evens)', ',P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=0\nfor i in range(N):\n if A[i]%2==1: odd+=1\nif odd==0:\n if P==1: print(0)\n else: print(2**N)\nelse:\n print(2**(N-1))', 'N,P=map(int,input().split())\nA=list(map(int,input().split()))\nodd=0\nfor i in range(N):\n if A[i]%2==1: odd+=1\nif odd==0:\n if P==1: print(0)\n else: print(2**N)\nelse:\n print(2**(N-1))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s024091909', 's100646793', 's565383348', 's894214756', 's111045969']
[2940.0, 3064.0, 3064.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0, 17.0, 17.0]
[194, 456, 508, 183, 184]
p03665
u670180528
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['print(2**int(input()[:2]))', 'i=int(input()[:2])-1;print((2**i,0)[i%2])', 'n,p,*a=map(int,open(0).read().split());print(2**~-n*(any(x%2for x in a)or(1^p)*2))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s278217423', 's517904198', 's846131740']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[26, 41, 82]
p03665
u691018832
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn, p, *a = map(int, read().split())\ncnt_1 = 0\ncnt_2 = 0\nfor i in a:\n if a[i] % 2 == 1:\n cnt_1 += 1\n else:\n cnt_2 += 1\nans = 2 ** max(0, cnt_1 - 1) * 2 ** cnt_2\nif p == 1 and cnt_1 == 0:\n ans = 0\nprint(ans)\n', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import defaultdict\nfrom operator import mul\nfrom functools import reduce\n\n\ndef nCr(n, r):\n if n < r:\n return 0\n r = min(n - r, r)\n if r == 0:\n return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1, r + 1))\n return over // under\n\n\nn, p = map(int, readline().split())\na = list(map(lambda x: int(x) % 2, readline().split()))\ndict = defaultdict(int)\nfor aa in a:\n dict[aa] += 1\nmemo = 2 ** dict[0]\nans = 0\nif p == 0:\n ans += memo\n m = 2\nelse:\n m = 1\nfor i in range(m, dict[1] + 1, 2):\n ans += nCr(dict[1], i) * memo\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s611436438', 's389541337']
[3060.0, 3808.0]
[18.0, 29.0]
[377, 760]
p03665
u693953100
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['def check(a):\n for i in a:\n if i%2:\n return True\n return False\n\nn,p = map(int, input().split())\na = list(map(int,input().split()))\nif check():\n print(2**(n-1))\nelif p==0:\n print(2**n)\nelse:\n print(0)', 'def check(a):\n for i in a:\n if i%2:\n return True\n return False\n\nn,p = map(int, input().split())\na = list(map(int,input().split()))\nif check(a):\n print(2**(n-1))\nelif p==0:\n print(2**n)\nelse:\n print(0)']
['Runtime Error', 'Accepted']
['s541815454', 's519654597']
[3060.0, 3064.0]
[17.0, 21.0]
[232, 233]
p03665
u694649864
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\nimport itertools\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\n\nodd = []\neven = []\nc = 0\nfor i in A:\n if i % 2 == 0:\n even.append(i)\n else:\n odd.append(i)\n\n\nif P == 1:\n \n for i in range(1, len(odd)+1, 2):\n c += combinations_count(len(odd), i)\nif P == 0:\n \n for i in range(0, len(odd)+1, 2):\n c += combinations_count(len(odd), i)\n \nprint(2 ** len(even) * c) ', '\nimport itertools\nimport math\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\n\nodd = []\neven = []\nc = 0\nfor i in A:\n if i % 2 == 0:\n even.append(i)\n else:\n odd.append(i)\n\n\nif P == 1:\n \n for i in range(1, len(odd)+1, 2):\n c += combinations_count(len(odd), i)\nif P == 0:\n \n for i in range(0, len(odd)+1, 2):\n c += combinations_count(len(odd), i)\n \nprint(2 ** len(even) * c) ']
['Runtime Error', 'Accepted']
['s341197832', 's846318482']
[3064.0, 3064.0]
[18.0, 18.0]
[939, 951]
p03665
u758815106
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N,P= map(int, input().split())\nA= list(map(int, input().split()))\nA = [A[i] % 2 for i in range(N)] \neven = A.count(0)\nodd = A.count(1)\n\nanseven = 1\nansodd = 0\n\ndic = {0:1}\nfor i in range(1, 51):\n dic[i] = dic[i - 1] * i\n\n\nfor i in range(1, even + 1):\n anseven += dic[even] // dic[even - i] // dic[i]\n\nif P == 0:\n \n for i in range(2, odd + 1, 2):\n ansodd += dic[odd] // dic[odd - i] // dic[i]\n\nelse:\n if odd == 0:\n print(0)\n exit()\n \n for i in range(1, odd + 1, 2):\n ansodd += dic[odd] // dic[odd - i] // dic[i]\n\nprint(anseven * ansodd)', 'N,P= map(int, input().split())\nA= list(map(int, input().split()))\nA = [A[i] % 2 for i in range(N)] \neven = A.count(0)\nodd = A.count(1)\n\nanseven = 1\nansodd = 1\n\ndic = {0:1}\nfor i in range(1, 51):\n dic[i] = dic[i - 1] * i\n\n\nfor i in range(1, even + 1):\n anseven += dic[even] // dic[even - i] // dic[i]\n\nif P == 0:\n \n for i in range(2, odd + 1, 2):\n ansodd += dic[odd] // dic[odd - i] // dic[i]\n\nelse:\n if odd == 0:\n print(0)\n exit()\n ansodd = 0\n \n for i in range(1, odd + 1, 2):\n ansodd += dic[odd] // dic[odd - i] // dic[i]\n\nprint(anseven * ansodd)']
['Wrong Answer', 'Accepted']
['s963862993', 's536910521']
[9104.0, 9128.0]
[28.0, 29.0]
[641, 656]
p03665
u761989513
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n, p = map(int, input().split())\na = list(map(int, input().split()))\nodd = 0\nfor i in a:\n if i % 2:\n print(2 ** (n - 1))\nif p:\n print(0)\nelse:\n print(2 ** n)', 'n, p = map(int, input().split())\na = list(map(int, input().split()))\nodd = 0\nfor i in a:\n if i % 2:\n print(2 ** (n - 1))\n exit()\nif p:\n print(0)\nelse:\n print(2 ** n)']
['Wrong Answer', 'Accepted']
['s419765387', 's338123652']
[2940.0, 2940.0]
[20.0, 18.0]
[173, 188]
p03665
u767664985
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N, P = map(int, input().split())\nA = [i%2 for i in list(map(int, input().split))]\nzero = A.count(0)\none = A.count(1)\n\nprint( (2**zero) * (2**(max(0, one-1))) )\n', 'N, P = map(int, input().split())\nA = list(map(int, input().split()))\na = [i%2 for i in A]\nzero = a.count(0)\none = a.count(1)\n\nif one == 0 and P == 1:\n print(0)\nelse:\n print( (2**zero) * (2**(max(0, one-1))) )\n']
['Runtime Error', 'Accepted']
['s726782843', 's935044560']
[2940.0, 2940.0]
[17.0, 17.0]
[160, 215]
p03665
u771007149
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['#AGC017-A\nfrom math import factorial\ndef nCr(n,r):\n return factorial(n) / factorial(r) / factorial(n - r)\nn,p = map(int,input().split())\na = list(map(int,input().split()))\neven = 0\nodd = 0\nfor i in a:\n if i % 2 == 0:\n even += 1\n else:\n odd += 1\n\n\nif p == 0:\n temp = 0\n for i in range(0,odd+1,2):\n print(i)\n temp += nCr(odd,i)\n print(int(2**even * temp))\n\nelse:\n temp = 0\n for i in range(1,odd+1,2):\n temp += nCr(odd,i)\n print(int(2**even * temp))', '#AGC017-A\nfrom math import factorial\ndef nCr(n,r):\n return factorial(n) / factorial(r) / factorial(n - r)\nn,p = map(int,input().split())\na = list(map(int,input().split()))\neven = 0\nodd = 0\nfor i in a:\n if i % 2 == 0:\n even += 1\n else:\n odd += 1\n\n\nif p == 0:\n temp = 0\n for i in range(0,odd+1,2):\n temp += nCr(odd,i)\n print(int(2**even * temp))\n\nelse:\n temp = 0\n for i in range(1,odd+1,2):\n temp += nCr(odd,i)\n print(int(2**even * temp))']
['Wrong Answer', 'Accepted']
['s970574954', 's860372009']
[9220.0, 9212.0]
[29.0, 24.0]
[522, 505]
p03665
u781262926
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from scipy.special import comb\nn, p, *A = map(int, open(0).read().split())\nodd = sum(a%2 for a in A)\neven = n - odd\n\nif p:\n s = 0\n for i in range(1, odd, 2):\n s += comb(odd, i, exact=True)\n s *= pow(2, even)\n print(s)\nelse:\n s = 0\n for i in range(0, odd, 2):\n s += comb(odd, i, exact=True)\n s *= pow(2, even)\n print(s)', 'from scipy.special import comb\nn, p, *A = map(int, open(0).read().split())\no = sum(a%2 for a in A)\ne = n - o\n\ns = 0\nfor i in range(p, o+1, 2):\n s += comb(o, i, exact=True)\ns *= pow(2, e)\nprint(s)']
['Wrong Answer', 'Accepted']
['s163179615', 's871683123']
[42452.0, 42360.0]
[190.0, 186.0]
[332, 196]
p03665
u807772568
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import sys,collections as cl,bisect as bs\nsys.setrecursionlimit(100000)\ninput = sys.stdin.readline\nmod = 10**9+7\nMax = sys.maxsize\ndef l(): \n return list(map(int,input().split()))\ndef m(): \n return map(int,input().split())\ndef onem(): \n return int(input())\ndef s(x): \n a = []\n if len(x) == 0:\n return []\n aa = x[0]\n su = 1\n for i in range(len(x)-1):\n if aa != x[i+1]:\n a.append([aa,su])\n aa = x[i+1]\n su = 1\n else:\n su += 1\n a.append([aa,su])\n return a\ndef jo(x): \n return " ".join(map(str,x))\ndef max2(x): \n return max(map(max,x))\ndef In(x,a): \n k = bs.bisect_left(a,x)\n if k != len(a) and a[k] == x:\n return True\n else:\n return False\n\ndef pow_k(x, n):\n ans = 1\n while n:\n if n % 2:\n ans *= x\n x *= x\n n >>= 1\n return ans\n\n\n\nmod = 10**9+7 \nN = 10**5\ndef cmb(n, r):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\ndef p(n,r):\n if ( r<0 or r>n ):\n return 0\n return g1[n] * g2[n-r] % mod\n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n# a = cmb(n,r)\n\nn,p = m()\n\na = l()\n\non= 0\n\nsu = 0\n\nfor i in range(n):\n a[i] %= 2\n if a[i] == 1:\n on += 1\nno = n - on\n\nif p % 2 == 0:\n if on % 2 == 0:\n for i in range(0,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n else:\n for i in range(1,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n\nelse:\n if on % 2 == 0:\n for i in range(1,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n\n else:\n for i in range(0,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n\nprint(su)\n\n', 'import sys,collections as cl,bisect as bs\nsys.setrecursionlimit(100000)\ninput = sys.stdin.readline\nmod = 10**9+7\nMax = sys.maxsize\ndef l(): \n return list(map(int,input().split()))\ndef m(): \n return map(int,input().split())\ndef onem(): \n return int(input())\ndef s(x): \n a = []\n if len(x) == 0:\n return []\n aa = x[0]\n su = 1\n for i in range(len(x)-1):\n if aa != x[i+1]:\n a.append([aa,su])\n aa = x[i+1]\n su = 1\n else:\n su += 1\n a.append([aa,su])\n return a\ndef jo(x): \n return " ".join(map(str,x))\ndef max2(x): \n return max(map(max,x))\ndef In(x,a): \n k = bs.bisect_left(a,x)\n if k != len(a) and a[k] == x:\n return True\n else:\n return False\n\ndef pow_k(x, n):\n ans = 1\n while n:\n if n % 2:\n ans *= x\n x *= x\n n >>= 1\n return ans\n\n\nnCr = {}\ndef cmb(n, r):\n if r == 0 or r == n: return 1\n if r == 1: return n\n if (n,r) in nCr: return nCr[(n,r)]\n nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return nCr[(n,r)]\nn,p = m()\n\na = l()\n\non= 0\n\nsu = 0\n\nfor i in range(n):\n a[i] %= 2\n if a[i] == 1:\n on += 1\nno = n - on\n\nif p % 2 == 0:\n if on % 2 == 0:\n for i in range(0,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n else:\n for i in range(1,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n\nelse:\n if on % 2 == 0:\n for i in range(1,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n\n else:\n for i in range(0,on+1,2):\n su += cmb(on,i)\n suu = 0\n for i in range(no+1):\n suu += cmb(no,i)\n su *= suu\n\nprint(su)\n\n']
['Wrong Answer', 'Accepted']
['s720224287', 's071053031']
[15716.0, 3556.0]
[135.0, 22.0]
[2631, 2263]
p03665
u813098295
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['def nCr(n, r):\n ret = 1\n for i in range(1, n+1):\n ret *= i\n for i in range(1, r+1):\n ret //= i\n for i in range(1, n-r+1):\n ret //= i\n return ret\n\nn, p = map(int, input().split())\na = map(int, input().split())\neven, odd = 0, 0\n\nfor i in a:\n if i & 1:\n odd += 1\n else:\n even += 1\n\nc_even = 2**even\nc_odd = 0\n\nstart = 1 if p else 0\n\nwhile start <= odd:\n c_odd += nCr(odd, start)\n start += 2\nprint(c_even, c_odd)\nprint(c_even * c_odd)\n', 'def nCr(n, r):\n ret = 1\n for i in range(1, n+1):\n ret *= i\n for i in range(1, r+1):\n ret //= i\n for i in range(1, n-r+1):\n ret //= i\n return ret\n\nn, p = map(int, input().split())\na = map(int, input().split())\neven, odd = 0, 0\n\nfor i in a:\n if i & 1:\n odd += 1\n else:\n even += 1\n\nc_even = 2**even\nc_odd = 0\n\nstart = 1 if p else 0\n\nwhile start <= odd:\n c_odd += nCr(odd, start)\n start += 2\n\nprint(c_even * c_odd)']
['Wrong Answer', 'Accepted']
['s085421901', 's983339799']
[3064.0, 3064.0]
[17.0, 17.0]
[481, 460]
p03665
u814986259
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from math import factorial\nN,P=map(int,input().split())\na=list(map(int,input().split()))\nodd=0\neven=0\nfor i in range(N):\n if a[i]%2==0:\n even+=1\n else:\n odd+=1\nans=2**even\nk=0\nif P==0:\n k=0\nelse:\n k=1\ntmp=0\nfor i in range(k,odd,2):\n tmp+=factorial(odd)//factorial(odd-i)//factorial(i)\n\nprint(ans*tmp)\n', 'from math import factorial\nN,P=map(int,input().split())\na=list(map(int,input().split()))\nodd=0\neven=0\nfor i in range(N):\n if a[i]%2==0:\n even+=1\n else:\n odd+=1\nans=2**even\nk=0\nif P==0:\n k=odd//2 +1\nelse:\n k=(odd+1)//2\ntmp=0\nfor i in range(1,k+1):\n tmp+=factorial(odd)//factorial(odd-i)//factorial(i)\n\nprint(ans*tmp)', 'from math import factorial\nN,P=map(int,input().split())\na=list(map(int,input().split()))\nodd=0\neven=0\nfor i in range(N):\n if a[i]%2==0:\n even+=1\n else:\n odd+=1\nans=2**even\nk=0\nif P==0:\n k=0\nelse:\n k=1\ntmp=0\nfor i in range(k,odd+1,2):\n tmp+=factorial(odd)//factorial(odd-i)//factorial(i)\n\nprint(ans*tmp)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s073868002', 's553824593', 's725167091']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[312, 326, 314]
p03665
u821262411
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['for i in a:\n if i%2==0:\n k +=1\nm=n-k\n\nans_x=ans_y=0\n\ndef cbn(b,c):\n z=1\n for i in range(2,b+1):\n z *= i\n for i in range(2,c+1):\n z //= i\n for i in range(2,b-c+1):\n z //= i\n return(z)\n\n\nif p==0:\n\n for i in range(k+1):\n ans_x += cbn(k,i)\n for i in range(0,m+1,2):\n ans_y += cbn(m,i)\n\n print(ans_x * ans_y)\n\nelse:\n\n for i in range(k+1):\n ans_x += cbn(k,i)\n for i in range(1,m+1,2):\n ans_y += cbn(m,i)\n\n print(ans_x * ans_y) ', 'n,p=map(int,input().split())\na=list(map(int,input().split()))\nk=m=0\nfor i in a:\n if i%2==0:\n k +=1\nm=n-k\n\nans_x=ans_y=0\n\ndef cbn(b,c):\n z=1\n for i in range(2,b+1):\n z *= i\n for i in range(2,c+1):\n z //= i\n for i in range(2,b-c+1):\n z //= i\n return(z)\n\n\nif p==0:\n\n for i in range(k+1):\n ans_x += cbn(k,i)\n for i in range(0,m+1,2):\n ans_y += cbn(m,i)\n\n print(ans_x * ans_y)\n\nelse:\n\n for i in range(k+1):\n ans_x += cbn(k,i)\n for i in range(1,m+1,2):\n ans_y += cbn(m,i)\n\n print(ans_x * ans_y) \n']
['Runtime Error', 'Accepted']
['s335881078', 's123968644']
[3064.0, 3064.0]
[18.0, 18.0]
[513, 585]
p03665
u835482198
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\nN, P = map(int, input().split())\nA = map(int, input().split())\n\nn_even = len(filter(lambda x: x % 2 == 0, A))\nn_odd = N - n_even\nans = 2 ** max(0, n_odd - 1) * 2 ** n_even\nif P == 0 and n_odd == 0:\n print(0)\nelse:\n print(ans)\n', 'N, P = map(int, input().split())\nA = map(int, input().split())\n\nif all(filter(lambda x: x % 2 == 0, A)):\n if P == 0:\n print(0)\n else:\n print(2 ** N)\nelse:\n n_even = sum(filter(lambda x: x % 2 == 0, A))\n n_odd = N - n_even\n print(2 ** max(0, n_odd - 1) * 2 ** n_even)\n', 'N, P = map(int, input().split())\nA = map(int, input().split())\n\nn_even = len(list(filter(lambda x: x % 2 == 0, A)))\nn_odd = N - n_even\nans = (2 ** max(0, n_odd - 1)) * (2 ** n_even)\nif P == 1 and n_odd == 0:\n print(0)\nelse:\n print(ans)\n\n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s537821740', 's553436990', 's767136380']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0]
[233, 296, 244]
p03665
u843175622
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\nn, p, *a = map(int, open(0).read().split())\n\n\ndef c(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nmemo = [0, 0]\nfor i in range(n):\n memo[a[i] % 2] += 1\n# p == 0\n\n\nans = 0\nif p == 0:\n for i in range(0, memo[1], 2):\n ans += c(memo[1], i) * pow(2, memo[0])\nelse:\n for i in range(1, memo[1], 2):\n ans += c(memo[1], i) * pow(2, memo[0])\n# p == 1\nprint(ans)\n', 'import math\nn, p, *a = map(int, open(0).read().split())\n\n\ndef c(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nmemo = [0, 0]\nfor i in range(n):\n memo[a[i] % 2] += 1\n# p == 0\n\n\nans = 0\nif p == 0:\n for i in range(0, memo[1] + 1, 2):\n ans += c(memo[1], i) * pow(2, memo[0])\nelse:\n for i in range(1, memo[1] + 1, 2):\n ans += c(memo[1], i) * pow(2, memo[0])\n# p == 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s289978283', 's993759321']
[9232.0, 9136.0]
[30.0, 28.0]
[426, 434]
p03665
u846552659
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N, P = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nodd = [ tmp for tmp in a if tmp%2 != 0]\neven = [ tmp for tmp in a if tmp%2 == 0]\nif P == 0:\n ans += 1\n b = sum([ len(list(itertools.combinations(odd,tmp))) for tmp in range(2, len(odd)+1, 2) ])\nelse:\n b = sum([ len(list(itertools.combinations(odd,tmp))) for tmp in range(1, len(odd)+1, 2) ])\nc = [ len(list(itertools.combinations(even, tmp))) for tmp in range(1, len(even)+1) ]\nfactor = 0\nfor tmp in c:\n ans += tmp*b\n factor += tmp\nelse:\n if P == 0:\n ans += b+factor\n else:\n ans += b\nprint(ans)', '# -*- coding:utf-8 -*-\nimport itertools, math\nN, P = map(int, input().split())\na = list(map(int, input().split()))\nans = 0\nodd = [ tmp for tmp in a if tmp%2 != 0]\neven = [ tmp for tmp in a if tmp%2 == 0]\nd = math.factorial(len(odd))\ne = math.factorial(len(even))\nif P == 0:\n ans += 1\n b = sum([ (d//math.factorial(len(odd)-tmp))//math.factorial(tmp) for tmp in range(2, len(odd)+1, 2) ])\nelse:\n b = sum([ (d//math.factorial(len(odd)-tmp))//math.factorial(tmp) for tmp in range(1, len(odd)+1, 2) ])\nc = [ (e//math.factorial(len(even)-tmp))//math.factorial(tmp) for tmp in range(1, len(even)+1) ]\nfor tmp in c:\n ans += tmp*b\nelse:\n if P == 0:\n ans += b+sum(c)\n else:\n ans += b\nprint(ans)']
['Runtime Error', 'Accepted']
['s505423385', 's646652654']
[3064.0, 3064.0]
[18.0, 18.0]
[606, 717]
p03665
u846694620
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["import math\n\n\ndef comb(n, r):\n return math.factorial(n) / math.factorial(r) / math.factorial(n - r)\n\n\ndef main():\n n, p = map(int, input().split())\n a = tuple(map(lambda x: int(x) % 2 == 0, input().split()))\n\n if n == 1 and a[0] == bool(p):\n print(0)\n return 0\n\n t = len(tuple(filter(lambda x: x, a)))\n f = n - t\n\n f_comb = 0\n for j in range(f + 1):\n f_comb += comb(f, j)\n\n t_comb = 0\n if p != 0:\n for i in range(t + 1):\n if i % 2 == 0:\n t_comb += comb(t, i)\n else:\n for i in range(t + 1):\n if i % 2 == 1:\n t_comb += comb(t, i)\n\n print(int(t_comb * f_comb))\n\n return 0\n\n\nif __name__ == '__main__':\n main()\n", "import math\n\n\ndef comb(n, r):\n return math.factorial(n) / math.factorial(r) / math.factorial(n - r)\n\n\ndef main():\n n, p = map(int, input().split())\n a = tuple(map(lambda x: int(x) % 2 == 0, input().split()))\n\n if n == 1 and a[0] == bool(p):\n print(0)\n return 0\n\n t = len(tuple(filter(lambda x: x, a)))\n f = n - t\n\n f_comb = 0\n for j in range(f + 1):\n f_comb += comb(f, j)\n\n t_comb = 0\n if p == 0:\n for i in range(t + 1):\n if i % 2 == 0:\n t_comb += comb(t, i)\n else:\n for i in range(t + 1):\n if i % 2 == 1:\n t_comb += comb(t, i)\n\n print(int(t_comb * f_comb))\n\n return 0\n\n\nif __name__ == '__main__':\n main()\n", "import math\n \n \ndef comb(n, r):\n return math.factorial(n) / math.factorial(r) / math.factorial(n - r)\n \n \ndef main():\n n, p = map(int, input().split())\n a = tuple(map(lambda x: int(x) % 2, input().split()))\n \n if n == 1 and a[0] % 2 != p:\n print(0)\n return 0\n \n t = len(tuple(filter(lambda x: x == 1, a)))\n f = n - t\n \n f_comb = 0\n for j in range(f + 1):\n f_comb += comb(f, j)\n \n t_comb = 0\n if p == 0:\n for i in range(t + 1):\n if i % 2 == 0:\n t_comb += comb(t, i)\n else:\n for i in range(t + 1):\n if i % 2 == 1:\n t_comb += comb(t, i)\n \n print(int(t_comb * f_comb))\n \n return 0\n \n \nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s519736357', 's891258355', 's701582505']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 17.0]
[735, 735, 744]
p03665
u855200003
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\nimport itertools\n\nN,P = [int(i) for i in input().split(" ")]\nA = [int(i) for i in input().split(" ")]\nk = 0\nfor i in range(N):\n if int(A[i] % 2) == P:\n k += 1\n\nif k == 0:\n if P == 0:\n tmp = 0\n i = 0\n while i < N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(tmp)\n elif P == 1:\n print(0)\nelse:\n tmp = 0\n i = 0\n while i < N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(pow(2,k)*tmp)', 'import math\nimport itertools\n\nN,P = [int(i) for i in input().split(" ")]\nA = [int(i) for i in input().split(" ")]\nk = 0\nfor i in range(N):\n if int(A[i] % 2) == P:\n k += 1\n\nif k == 0:\n if P == 0:\n tmp = 0\n i = 0\n while i < N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(tmp)\n elif P == 1:\n print(0)\nelse:\n tmp = 0\n i = 0\n while i <= N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(pow(2,k)*tmp)', 'import math\nimport itertools\n\nN,P = [int(i) for i in input().split(" ")]\nA = [int(i) for i in input().split(" ")]\nk = 0\nfor i in range(N):\n if int(A[i] % 2) == P:\n k += 1\n\nif k == 0:\n if P == 0:\n tmp = 0\n i = 0\n while i < N-k:\n tmp += int(math.factorial(N)/(math.factorial(N-i)*math.factorial(i)))\n i += 2\n print(tmp)\n elif P == 1:\n print(0)\nelse:\n tmp = 0\n i = 0\n while i < N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(pow(2,k)*tmp)\n', 'import math\nimport itertools\n\nN,P = [int(i) for i in input().split(" ")]\nA = [int(i) for i in input().split(" ")]\nk = 0\nfor i in range(N):\n if int(A[i] % 2) == P:\n k += 1\n\nif k == 0:\n if P == 0:\n tmp = 0\n i = 0\n while i <= N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(tmp)\n elif P == 1:\n print(0)\nelse:\n tmp = 0\n i = 0\n while i <= N-k:\n tmp += int(math.factorial(N-k)/(math.factorial(N-k-i)*math.factorial(i)))\n i += 2\n print(pow(2,k)*tmp)\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s163002333', 's635059123', 's887711523', 's363599027']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 18.0, 17.0, 19.0]
[586, 587, 583, 589]
p03665
u859897687
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p=map(int,input().split())\nl=list(map(lambda x:int(x)%2,input().split()))\na=l.count(0)\nb=l.count(1)\nans1=1\nfor i in range(0,a+1,2):\n ans11=1\n for j in range(a,a-i,-1):\n ans11*=j\n for j in range(1,1+i):\n ans11//=j\n ans1+=ans11\nans2=1\nfor i in range(p,b+1,2):\n ans21=1\n for j in range(b,b-i,-1):\n ans21*=j\n for j in range(1,1+i):\n ans21//=j\n ans2+=ans21\nprint(ans1*ans2)', 'n,p=map(int,input().split())\nl=list(map(lambda x:int(x)%2,input().split()))\na=l.count(0)\nb=l.count(1)\nans1=1\nif not a==0:\n for i in range(0,a+1,2):\n ans11=1\n for j in range(a,a-i-1,-1):\n ans11*=j\n for j in range(1,1+i):\n ans11//=j\n ans1+=ans11\nans2=1\nif not b==0:\n for i in range(p,b+1,2):\n ans21=1\n for j in range(b,b-i-1,-1):\n ans21*=j\n for j in range(1,1+i):\n ans21//=j\n ans2+=ans21\nprint(ans1*ans2)', 'n,p=map(int,input().split())\nl=list(map(lambda x:int(x)%2,input().split()))\na=l.count(0)\nb=l.count(1)\nans1=1\nfor i in range(0,a+1,2):\n ans11=1\n for j in range(a,a-i,-1):\n ans11*=j\n for j in range(1,1+i):\n ans11//=j\n ans1+=ans11\nans2=1\nfor i in range(p,b+1,2):\n ans21=1\n for j in range(b,b-i,-1):\n ans21*=j\n for j in range(1,1+i):\n ans21//=j\n ans2+=ans21\nprint(ans1+ans2)', 'n,p=map(int,input().split())\nl=list(map(lambda x:int(x)%2,input().split()))\na,b=0,0\nfor i in l:\n if l%2>0:\n a+=1\n else:\n b+=1\nif a==0:\n if p==0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))', 'n,p=map(int,input().split())\nl=list(map(lambda x:int(x)%2,input().split()))\na,b=0,0\nfor i in l:\n if i>0:\n a+=1\n else:\n b+=1\nif a==0:\n if p==0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s004790420', 's235349999', 's911692849', 's938698873', 's326627425']
[3064.0, 3064.0, 3064.0, 3060.0, 3064.0]
[20.0, 17.0, 18.0, 18.0, 18.0]
[390, 448, 390, 214, 212]
p03665
u860002137
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from collections import deque\n\nnCr = {}\n\n\ndef cmb(n, r):\n if r == 0 or r == n:\n return 1\n if r == 1:\n return n\n if (n, r) in nCr:\n return nCr[(n, r)]\n nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)\n return nCr[(n, r)]\n\n\nN, P = map(int, input().split())\nA = np.array(list(map(int, input().split())))\n\nli = list(np.mod(A, 2))\nzero = li.count(0)\none = li.count(1)\n\nif P == 0:\n combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]\nif P == 1:\n combi = [1] + [2 * x + 1 for x in range(1, (one + 1) // 2)]\n\nq = deque(combi)\n\nright = 0\nwhile q:\n c = q.popleft()\n tmp = cmb(one, c)\n right += tmp\n\nprint(2**zero * right)', 'from scipy.special import comb\nfrom collections import deque\n\nN, P = map(int, input().split())\nA = np.array(list(map(int, input().split())))\n\nli = list(np.mod(A, 2))\nzero = li.count(0)\none = li.count(1)\n\nif P == 0:\n combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]\nif P == 1:\n combi = [1] + [2 * x + 1 for x in range(1, (one + 1) // 2)]\n\nq = deque(combi)\n\nright = 0\nwhile q:\n c = q.popleft()\n tmp = comb(one, c, exact=True)\n right += tmp\n\nprint(2**zero * right)', 'from collections import deque\nfrom functools import lru_cache\n\nnCr = {}\n\n\n@lru_cache(maxsize=None)\ndef cmb(n, r):\n if r == 0 or r == n:\n return 1\n if r == 1:\n return n\n if (n, r) in nCr:\n return nCr[(n, r)]\n nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)\n return nCr[(n, r)]\n\n\nN, P = map(int, input().split())\nA = np.array(list(map(int, input().split())))\n\nli = list(np.mod(A, 2))\nzero = li.count(0)\none = li.count(1)\n\nif P == 0:\n combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]\nif P == 1:\n combi = [1] + [2 * x + 1 for x in range(1, (one + 1) // 2)]\n\nq = deque(combi)\n\nright = 0\nwhile q:\n c = q.popleft()\n tmp = cmb(one, c)\n right += tmp\n\nprint(2**zero * right)', 'n, p = map(int, input().split())\narr = list(map(int, input().split()))\n\na = sum([x % 2 == 1 for x in arr])\nb = n - a\n\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\n\nMOD = 10**18 + 7\nN = 10**6\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % MOD)\n inv.append((-inv[MOD % i] * (MOD // i)) % MOD)\n factinv.append((factinv[-1] * inv[-1]) % MOD)\n\nstart = p\n\n\nans = 0\nfor i in range(p, a + 1, 2):\n for j in range(b + 1):\n ans += cmb(a, i, MOD) * cmb(b, j, MOD)\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s008214833', 's507996956', 's923376791', 's300999571']
[3316.0, 14512.0, 3564.0, 127756.0]
[21.0, 189.0, 23.0, 1358.0]
[659, 483, 716, 665]
p03665
u860972915
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['def odd(n):\n return n % 2 == 1\n \ndef even(n):\n return n % 2 == 0\n\nfrom math import factorial as fact\ndef c(n, r):\n if n < r:\n return 0\n if n == 0:\n return 0\n if r == 0:\n return 1\n return fact(n) // (fact(n-r) * fact(r))\n\nn, p = map(int, input().split())\na = list(map(int, input().split()))\no = [i for i in a if odd(i)]\ne = [i for i in a if even(i)]\nx = len(o)\ny = len(e)\nyc = 0\nfor i in range(y):\n yc += c(y, i + 1)\nans = 0\nif p == 0:\n ans += yc\ni = 2 - p\nwhile True:\n if i > x:\n break\n ans += c(x, i)\n ans += c(x, i) * yc\n i += 2\nprint(ans)', 'def odd(n):\n return n % 2 == 1\n \ndef even(n):\n return n % 2 == 0\n\nfrom math import factorial as fact\ndef c(n, r):\n if n < r:\n return 0\n if n == 0:\n return 0\n if r == 0:\n return 1\n return fact(n) // (fact(n-r) * fact(r))\n\nn, p = map(int, input().split())\na = list(map(int, input().split()))\no = [i for i in a if odd(i)]\ne = [i for i in a if even(i)]\nx = len(o)\ny = len(e)\nyc = 0\nfor i in range(y):\n yc += c(y, i + 1)\nans = 0\nif p == 0:\n ans += 1\ni = 2 - p\nwhile True:\n if i > x:\n break\n ans += c(x, i)\n ans += c(x, i) * yc\n i += 2\nif p == 0:\n ans += yc\nprint(ans)']
['Wrong Answer', 'Accepted']
['s126179821', 's305955308']
[3064.0, 3064.0]
[19.0, 17.0]
[608, 632]
p03665
u871841829
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['N, P = map(int, input().split())\nA = map(int, input().split())\n\nodds, evens = 0, 0\n\nfor i in A:\n if i & 1:\n odds += 1\n \n else:\n evens += 1\n\nfrom math import factorial\n\nif P == 0:\n ans = 0\n fo = factorial(odds)\n for r in range(2, odds + 1, 2):\n # ncr\n ans += fo // (factorial(odds - r) * factorial(r))\n ans *= 2**evens\n\nelse:\n ans = 0\n fo = factorial(odds)\n for r in range(1, odds + 1, 2):\n # ncr\n ans += fo // (factorial(odds - r) * factorial(r))\n\n ans *= 2**evens\nprint(ans)\n', 'N, P = map(int, input().split())\nA = map(int, input().split())\n\nodds, evens = 0, 0\n\nfor i in A:\n if i & 1:\n odds += 1\n \n else:\n evens += 1\n\nfrom math import factorial\n\nif P == 0:\n ans = 0\n fo = factorial(odds)\n for r in range(0, odds + 1, 2):\n ans += fo // (factorial(odds - r) * factorial(r))\n ans *= 2**evens\n\nelse:\n ans = 0\n fo = factorial(odds)\n for r in range(1, odds + 1, 2):\n ans += fo // (factorial(odds - r) * factorial(r))\n\n ans *= 2**evens\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s333554308', 's906678893']
[3064.0, 3064.0]
[18.0, 18.0]
[555, 527]
p03665
u875361824
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["def main():\n N, P = map(int, input().split())\n *A, = map(int, input().split())\n\n editorial(N, P, A)\n\ndef editorial(N, P, A):\n odds = [a for a in A if a % 2 == 1]\n odd = len(odds)\n even = N - odd\n\n if odd == 0:\n if P = 1:\n print(0)\n else:\n print(2 ** N)\n return\n \n \n ans = 2 ** (N - 1)\n \n \n \n \n \n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n N, P = map(int, input().split())\n *A, = map(int, input().split())\n\n editorial(N, P, A)\n\ndef editorial(N, P, A):\n odds = [a for a in A if a % 2 == 1]\n odd = len(odds)\n even = N - odd\n\n if odd == 0:\n if P == 1:\n print(0)\n else:\n print(2 ** N)\n return\n \n \n ans = 2 ** (N - 1)\n \n \n \n \n \n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s922150993', 's304194974']
[2940.0, 3064.0]
[17.0, 18.0]
[808, 809]
p03665
u921773161
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import numpy as np\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\nA = np.array(A)\nA = A % 2\nA = list(A)\ncount0 = A.count(0)\ncount1 = A.count(1)\n\nprint(count0, count1, P)\n\nif P == 0 and count1 % 2 == 0:\n tmp = 2**(count1-1) * 2**count0\n\nelif P == 0 and count1 % 2 == 1:\n tmp = 2**(count1-1) * 2**count0\n\nelif P == 1 and count1 % 2 == 0:\n tmp = 2**(count1-1) * 2**count0\n\nelif P == 1 and count1 % 2 == 1:\n tmp = 2**(count1-1) * 2**count0 \n\nprint(round(tmp))', 'import numpy as np\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\nA = np.array(A)\nA = A % 2\nA = list(A)\ncount0 = A.count(0)\ncount1 = A.count(1)\n\n#print(count0, count1, P)\n\nif P == 0 and count1 % 2 == 0:\n tmp = max(1, 2**(count1-1)) * 2**count0\n\nelif P == 0 and count1 % 2 == 1:\n tmp = max(1, 2**(count1-1)) * 2**count0\n\nelif P == 1 and count1 % 2 == 0:\n tmp = max(1, 2**(count1-1))* 2**count0\n\nelif P == 1 and count1 % 2 == 1:\n tmp = max(1, 2**(count1-1)) * 2**count0 \n\nif count1 == 0 and P ==1:\n tmp = 0\n\nprint(round(tmp))']
['Wrong Answer', 'Accepted']
['s233456252', 's527270211']
[12484.0, 12488.0]
[151.0, 150.0]
[489, 560]
p03665
u941047297
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
["def main():\n from operator import mul\n from functools import reduce\n def combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n n, p = list(map(int, input().split()))\n A = list(map(int, input().split()))\n odd = sum([a % 2 == 1 for a in A])\n even = n - odd\n if p == 0:\n odd_sum = 0\n for i in range(0, odd + 1, 2):\n odd_sum += combinations_count(odd, i)\n else:\n if odd == 0:\n print(0)\n exit()\n else:\n odd_sum = 0\n for i in range(1, odd + 1, 2):\n odd_sum += combinations_count(odd, i)\n if even == 0:\n even_sum = 0\n else:\n even_sum = pow(2, even)\n print(even_sum * odd_sum)\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n from operator import mul\n from functools import reduce\n def combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n n, p = list(map(int, input().split()))\n A = list(map(int, input().split()))\n odd = sum([a % 2 == 1 for a in A])\n even = n - odd\n if p == 0:\n odd_sum = 0\n for i in range(0, odd + 1, 2):\n odd_sum += combinations_count(odd, i)\n else:\n if odd == 0:\n print(0)\n exit()\n else:\n odd_sum = 0\n for i in range(1, odd + 1, 2):\n odd_sum += combinations_count(odd, i)\n if even == 0:\n even_sum = 0\n print(odd_sum)\n else:\n even_sum = pow(2, even)\n print(even_sum * odd_sum)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s630339466', 's044438538']
[9428.0, 9564.0]
[27.0, 33.0]
[886, 913]
p03665
u941438707
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p=map(int,input().split())\na=[int(i) for i in input().split()]\nb=[i%2 for i in a]\nans=(2**b.count(0))*(2**(b.count(1)-1))\nprint((p+1)%2 if p not in b else ans)', 'from math import factorial as f\nn,p,*a=map(int,open(0).read().split())\nx=len([i for i in a if i%2])\ny=n-x\n\nxx=0\nfor i in range(p,x,2):\n xx+=f(x)//f(i)//f(x-i)\n\nyy=0\nfor i in range(0,y):\n yy+=f(y)//f(i)//f(y-i)\n\nprint(xx*yy+xx*(p^0)+yy*(p^1))', 'from math import factorial as f\nn,p,*a=map(int,open(0).read().split())\nx=len([i for i in a if i%2])\ny=n-x\n\nxx=0\nfor i in range(p,x,2):\n xx+=f(x)//f(i)//f(x-i)\n\nyy=0\nfor i in range(0,y):\n yy+=f(y)//f(i)//f(y-i)\n\nif x>0 and y>0:\n print(xx*yy+xx*(p^0)+yy*(p^1))\nelif x==0:\n print(yy(p^1))\nelse:\n print(xx)', 'n,p=map(int,input().split())\na=[int(i) for i in input().split()]\nb=[i%2 for i in a]\nans=(2**b.count(0))*(2**(b.count(1)-1))\nprint(0 if p not in b else ans)', 'from math import factorial as f\nn,p,*a=map(int,open(0).read().split())\nx=len([i for i in a if i%2])\ny=n-x\n\nxx=0\nfor i in range(p,x,2):\n xx+=f(x)//f(i)//f(x-i)\n\nyy=0\nfor i in range(0,y):\n yy+=f(y)//f(i)//f(y-i)\n\nprint(xx*yy+xx)', 'n,p,*a=map(int,open(0).read().split())\nif len([i for i in a if i%2])==0:\n print(2**n*(p^1))\nelse:\n print(2**(n-1))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s349547432', 's546954400', 's609740587', 's704266780', 's735276633', 's589560421']
[3060.0, 3064.0, 3064.0, 3188.0, 3064.0, 2940.0]
[17.0, 17.0, 18.0, 19.0, 17.0, 17.0]
[161, 247, 317, 155, 232, 120]
p03665
u945418216
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['import math\nn,p = map(int, input().split())\naa = list(map(int, input().split()))\n\naa = list(map(lambda x:x%2, aa))\nodd = aa.count(1)\neven = aa.count(0)\nans = 2**even\n# if p==1:\n# ans*=odd\n\n\npattern = 0\nfor i in range(p, odd+1, 2):\n print(even, odd, i, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))\n pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))\nprint(ans*pattern)', 'import math\nn,p = map(int, input().split())\naa = list(map(int, input().split()))\n\naa = list(map(lambda x:x%2, aa))\nodd = aa.count(1)\neven = aa.count(0)\nans = 2**even\n# if p==1:\n# ans*=odd\n\n\npattern = 0\nfor i in range(p, odd+1, 2):\n \n pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))\nprint(ans*pattern)']
['Wrong Answer', 'Accepted']
['s533372578', 's261500429']
[3064.0, 3064.0]
[17.0, 17.0]
[458, 460]
p03665
u948522631
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['def cmb(n, r):\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return result\n\n\nn, p = map(int,input().split())\na = list(map(int,input().split()))\n\neven=0\nodd=0\nfor i in a:\n if i%2 == 0:\n even+=1\n else:\n odd+=1\nans = 0\nif p == 0:\n print(1<<n)\n\nelse:\n evens = 0\n i = 1\n while(i <= even):\n evens += cmb(even, i)\n\n i+=1\n\n i = 1\n while(i <= odd):\n ans += cmb(odd, i) + cmb(odd, i)*evens\n\n i+=2\n print(ans)', 'def cmb(n, r):\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return result\n\n\nn, p = map(int,input().split())\na = list(map(int,input().split()))\n\neven=0\nodd=0\nfor i in a:\n if i%2 == 0:\n even+=1\n else:\n odd+=1\nans = 0\nif p == 0:\n evens = 0\n i = 1\n while(i <= even):\n evens += cmb(even, i)\n\n i+=1\n\n ans += 1<<even\n i = 2\n while(i <= odd):\n ans += cmb(odd, i) + cmb(odd, i)*evens\n i+=2\n\n print(ans)\n\nelse:\n evens = 0\n i = 1\n while(i <= even):\n evens += cmb(even, i)\n\n i+=1\n\n i = 1\n while(i <= odd):\n ans += cmb(odd, i) + cmb(odd, i)*evens\n\n i+=2\n print(ans)']
['Wrong Answer', 'Accepted']
['s094761989', 's646024204']
[3064.0, 3064.0]
[18.0, 19.0]
[947, 1148]
p03665
u977193988
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['n,p=map(int,input().split())\nA=list(map(int,input().split()))\n\nfor i in range(n):\n A[i]%=2\none=A.count(1)\nif one==n:\n print(2**n)\nelse:\n print(2**(n-1))', 'n,p=map(int,input().split())\nA=list(map(int,input().split()))\n\nfor i in range(n):\n A[i]%=2\none=A.count(1)\nif one==n and p==0:\n print(2**n)\nelif one==n and p==1:\n print(0)\nelse:\n print(2**(n-1))', 'n,p=map(int,input().split())\nA=list(map(int,input().split()))\n\nfor i in range(n):\n A[i]%=2\nzero=A.count(0)\nif zero==n and p==0:\n print(2**n)\nelif zero==n and p==1:\n print(0)\nelse:\n print(2**(n-1))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s165786883', 's658461283', 's611200013']
[3060.0, 3060.0, 3064.0]
[19.0, 17.0, 19.0]
[161, 205, 208]
p03665
u980205854
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\n\nN, P = map(int, input().split())\nprint(2**N)', '\nimport numpy as np\n\nN, P = map(int, input().split())\nA = list(map(int, input().split()))\nodd = len([i for i in A if i%2!=0])\nif odd==0 and P==0:\n ans = 2**N\nelif odd==0 and P==1:\n ans = 0\nelse:\n ans = 2**(N-1)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s783944653', 's351832561']
[2940.0, 21048.0]
[17.0, 318.0]
[60, 244]
p03665
u987164499
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['from sys import stdin\nfrom math import factorial\n\nn,p = [int(x) for x in stdin.readline().rstrip().split()]\nli = list(map(int,stdin.readline().rstrip().split()))\n\ndef combinations_count(n, r):\n return factorial(n) // (factorial(n - r) * factorial(r))\n\nguusu = 0\nkisuu = 0\n\nfor i in li:\n if i%2 == 0:\n guusu += 1\n else:\n kisuu += 1\n\npoint = 0\n\nif p == 0:\n for i in range(guusu//2+1):\n point += combinations_count(guusu,i*2)\n for j in range(kisuu//2+1):\n point += combinations_count(kisuu,j*2)\nif p == 1:\n for i in range(guusu+1):\n for j in range(kisuu//2 if kisuu%2 == 0 else kisuu//2+1):\n point += combinations_count(guusu,i)*combinations_count(kisuu,j*2+1)\n\nprint(point)', 'from sys import stdin\nfrom math import factorial\n\nn,p = [int(x) for x in stdin.readline().rstrip().split()]\nli = list(map(int,stdin.readline().rstrip().split()))\n\ndef combinations_count(n, r):\n return factorial(n) // (factorial(n - r) * factorial(r))\n\nguusu = 0\nkisuu = 0\n\nfor i in li:\n if i%2 == 0:\n guusu += 1\n else:\n kisuu += 1\n\npoint = 0\n\nif p == 0:\n for i in range(guusu//2+1):\n point += combinations_count(guusu,i*2)\n for j in range(kisuu//2+1):\n point += combinations_count(kisuu,i*2)\nif p == 1:\n for i in range(guusu+1):\n for j in range(kisuu//2 if kisuu%2 == 0 else kisuu//2+1):\n point += combinations_count(guusu,i)*combinations_count(kisuu,j*2+1)\n\nprint(point)', 'from sys import stdin\n\nn,p = [int(x) for x in stdin.readline().rstrip().split()]\nli = list(map(int,stdin.readline().rstrip().split()))\n\nif all(i%2 == 0 for i in li):\n if p == 0:\n print(2**n)\n else:\n print(0)\nelse:\n print(2**(n-1))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s136811249', 's343168182', 's945119930']
[3064.0, 3064.0, 3060.0]
[18.0, 18.0, 17.0]
[735, 735, 253]
p03665
u996749146
2,000
262,144
There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2. How many such ways to select bags there are?
['\n\n\n\n\nimport math\n\nN, P = map(int,input().strip().split(" "))\nA = list(map(int,input().strip().split(" ")))\n\neven = 0\nodd = 0\nfor a in A:\n if a % 2 == 0:\n even += 1\n else:\n odd += 1\n\neven_combi = 2 ** even\n\nodd_combi = 0\nm = int(odd/2)\n#print("m:", m)\nfor i in range(m+1):\n if P == 0:\n odd_combi += math.factorial(odd) / (math.factorial(i*2) * math.factorial(odd-i*2))\n else:\n if odd-(i*2+1) > 0:\n odd_combi += math.factorial(odd) / (math.factorial(i*2+1) * math.factorial(odd-(i*2+1)))\n\n\nprint(even_combi*odd_combi)\n', '\n\n\n\n\nimport math\n\nN, P = map(int,input().strip().split(" "))\nA = list(map(int,input().strip().split(" ")))\n\neven = 0\nodd = 0\nfor a in A:\n if a % 2 == 0:\n even += 1\n else:\n odd += 1\n\neven_combi = 2 ** even\n\nodd_combi = 0\nm = int(odd/2)\n#print("m:", m)\nfor i in range(m+1):\n if P == 0:\n odd_combi += math.factorial(odd) / (math.factorial(i*2) * math.factorial(odd-i*2))\n else:\n if odd-(i*2+1) > 0:\n odd_combi += math.factorial(odd) / (math.factorial(i*2+1) * math.factorial(odd-(i*2+1)))\n\n\nprint(int(even_combi*odd_combi))\n']
['Wrong Answer', 'Accepted']
['s340846104', 's339030119']
[3064.0, 3188.0]
[18.0, 17.0]
[681, 686]
p03666
u101225820
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['N,A,B,C,D=map(int,input().split())\nfor i in range(0,N-1):\n l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))\n\nfor _ in l:\n if B-A in _:\n print("YES")\n break\nelse:\n print("NO")', 'N,A,B,C,D=map(int,input().split())\nN=N-2\nfor i in range(0,N+1):\n l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))\n\nfor _ in l:\n if B-A in _:\n print("YES")\n break\nelse:\n print("NO")\n', 'N,A,B,C,D=map(int,input().split())\nN=N-1\nl=[]\nfor i in range(0,N+1):\n l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))\n\nfor _ in l:\n if B-A in _:\n print("YES")\n break\nelse:\n print("NO")']
['Runtime Error', 'Runtime Error', 'Accepted']
['s042968674', 's278162718', 's987908542']
[3060.0, 3060.0, 80408.0]
[18.0, 18.0, 530.0]
[191, 198, 202]
p03666
u334712262
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
["# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, A, B, C, D):\n\n B -= A\n A = 0\n M = N - 1\n for i in range(N):\n u = i * D - (M-i) * C\n l = i * C - (M-i) * D\n if l <= A <= u:\n return 'Yes'\n\n return 'No'\n\n\ndef main():\n N, A, B, C, D = read_int_n()\n print(slv(N, A, B, C, D))\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(10000)\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, A, B, C, D):\n\n B -= A\n A = 0\n M = N - 1\n for i in range(N):\n u = i * D - (M-i) * C\n l = i * C - (M-i) * D\n if l <= B <= u:\n return 'YES'\n\n return 'NO'\n\n\ndef main():\n N, A, B, C, D = read_int_n()\n print(slv(N, A, B, C, D))\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s573572099', 's263211846']
[5728.0, 7648.0]
[189.0, 189.0]
[1323, 1323]
p03666
u340781749
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
["def solve(n, a, b, c, d):\n return d == 0\n if d == 0:\n return a == b\n t = n - 1\n return (b - a - c * t) % (c + d) <= (d - c) * t\n\n\nprint('YES' if solve(*map(int, input().split())) else 'NO')\n", "def solve(n, a, b, c, d):\n if d == 0:\n return a == b\n t = n - 1\n ab = abs(a - b)\n if ab > d * t:\n return False\n return (ab - c * t) % (c + d) <= (d - c) * t\n\n\nprint('YES' if solve(*map(int, input().split())) else 'NO')\n"]
['Wrong Answer', 'Accepted']
['s104881194', 's919077044']
[3188.0, 2940.0]
[18.0, 18.0]
[209, 248]
p03666
u354638986
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['def main():\n n, a, b, c, d = map(int, input().split())\n\n for i in range(n):\n if c * (n-1-i) - d * i <= b - a <= -c * i + d * (n-1-i):\n print("Yes")\n break\n else:\n print("No")\n\n\nif __name__ == \'__main__\':\n main()\n', 'def main():\n n, a, b, c, d = map(int, input().split())\n\n for i in range(n):\n if c * (n-1-i) - d * i <= b - a <= -c * i + d * (n-1-i):\n print("YES")\n break\n else:\n print("NO")\n\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Accepted']
['s523604048', 's960140537']
[2940.0, 2940.0]
[175.0, 175.0]
[260, 260]
p03666
u572142121
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
["N,a,b,c,d=map(int, input().split())\nN-=1\na,b=0,abs(b-a)\n\nif d*N<b:\n print('No')\n exit()\n \nfor i in range(N//2+1):\n e=b-(N-i*2)*d\n f=b-(N-i*2)*c\n if e<=(d-c)*i and (c-d)*i<=f:\n print('Yes')\n exit()\nprint('No')", "N,a,b,c,d=map(int, input().split())\nN-=1\na,b=0,abs(b-a)\n\n\nfor i in range(N//2+1):\n e=b-(N-i*2)*d\n f=b-(N-i*2)*c\n if e<=(d-c)*i and (c-d)*i<=f:\n print('YES')\n exit()\nprint('NO')"]
['Wrong Answer', 'Accepted']
['s551496474', 's298886727']
[9196.0, 9140.0]
[148.0, 147.0]
[259, 224]
p03666
u608297208
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['N,A,B,C,D = map(int,input().split())\nif N > 30 and D > 1:\n\tflag = 10 **9\nelse:\n\tflag = pow(D,N -1)\nB -= A\nif N % 2 == 1:\n\tif (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")\nelse:\n\tif ((B - (D + C) / 2) % (C + D) <= (N - 1) * (D - C) / 2 : #and B <= flag and B >= -flagor (B + (D + C) / 2) % (C + D) <= (N - 1) * (D - C) / 2)\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")', 'N,A,B,C,D = map(int,input().split())\nif N > 18 and D > 1:\n\tflag = 10 **9\nelse:\n\tflag = pow(D,N)\nB -= A\nif N % 2 == 1:\n\tif (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")\nelse:\n\tif (abs(B % (C + D) - (D - C) / 2) <= (N - 1) * (D - C) / 2 or (B % (C + D) + (D - C) / 2) mod (C + D) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")', 'N,A,B,C,D = map(int,input().split())\nflag = D * (N - 1)\nB -= A\nif D - C == 0:\n\tif A == B:\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")\nelif N % 2 == 1:\n\tif (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")\nelse:\n\tif abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:\n\t\tprint("YES")\n\telse:\n\t\tprint("NO")']
['Runtime Error', 'Runtime Error', 'Accepted']
['s459506392', 's823767461', 's736564459']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[473, 483, 438]
p03666
u624475441
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
["N, A, B, C, D = map(int, input().split())\nlb, ub = A, A\nfor _ in range(1, N):\n if (lb + ub) / 2 < B:\n lb, ub = lb + C, ub + D\n else:\n lb, ub = lb - D, ub - C\nif lb <= B <= ub:\n print('Yes')\nelse:\n print('No')", "N, A, B, C, D = map(int, input().split())\nfor m in range(N):\n if C * (N - 1 - m) - D * m <= B - A <= D * (N - 1 - m) - C * m:\n print('YES')\n break\nelse:\n print('NO')"]
['Wrong Answer', 'Accepted']
['s779718109', 's331003260']
[3060.0, 3060.0]
[227.0, 221.0]
[234, 185]
p03666
u630088114
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['import sys\n\ndef diff(N,A,B,C,D):\n mini = (B+(N-1)*D-A)/(C+D)\n for i in xrange(mini, N-1):\n lower_bound = A + i*C - (N-i-1)*D\n upper_bound = A + i*D - (N-i-1)*C\n print(lower_bound, upper_bound)\n if lower_bound <= B and B <= upper_bound:\n return True\n elif B < lower_bound:\n return False\n\nstr = sys.stdin.readline().strip() #"491995 412925347 825318103 59999126 59999339"\nN,A,B,C,D = map(int,str.strip().split(" "))\nprint("YES" if diff(N,A,B,C,D) else "NO")\n', 'import sys\n\ndef diff(N,A,B,C,D):\n mini = (B+(N-1)*D-A)/(C+D)\n for i in range(int(mini), N-1):\n lower_bound = A + i*C - (N-i-1)*D\n upper_bound = A + i*D - (N-i-1)*C\n #print(lower_bound, upper_bound)\n if lower_bound <= B and B <= upper_bound:\n return True\n elif B < lower_bound:\n return False\n\nstr = sys.stdin.readline().strip() #"491995 412925347 825318103 59999126 59999339"\nN,A,B,C,D = map(int,str.strip().split(" "))\nprint("YES" if diff(N,A,B,C,D) else "NO")']
['Runtime Error', 'Accepted']
['s583244847', 's345511913']
[3064.0, 3064.0]
[19.0, 19.0]
[519, 523]
p03666
u653807637
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['# encoding:utf-8\nimport math\n\ndef main():\n\tN, A, B, C, D = list(map(int, input().split()))\n\tcur_list = [(A, A)]\n\n\tfor i in range(N - 1):\n\t\tcur_list = calcNextList(cur_list, C, D)\n\t\tcur_list =[x for x in cur_list if x[0] >= 0 and x[1] <= 10 ** 9]\n\t\tcur_list = merge(cur_list)\n\n\tprint(cur_list)\n\tfor x in cur_list:\n\t\tif x[0] <= B <= x[1]:\n\t\t\tprint("YES")\n\t\t\tbreak\n\telse:\n\t\tprint("NO")\n\n\n\n# \treturn((input_taple[0] - D, input_taple[1] + D))\n\ndef Duplicate(input_taple, C, D):\n\tfirst_tuple = (input_taple[0] + C, input_taple[1] + D)\n\tsecond_tuple = (input_taple[0] - D, input_taple[1] - C)\n\treturn([first_tuple, second_tuple])\n\ndef calcNextList(cur_list, C, D):\n\tnext_list = []\n\tfor x in cur_list:\n\t\tnext_list.extend(Duplicate(x, C, D))\n\treturn(next_list)\n\ndef merge(cur_list):\n\tcur_list.sort()\n\n\tnext_list = [cur_list[0]]\n\n\tfor i in range(len(cur_list) - 1):\n\t\tif next_list[-1][1] >= cur_list[i+1][0]:\n\t\t\tmerged = (next_list[-1][0], max(next_list[-1][1], cur_list[i+1][1]))\n\t\t\tnext_list.pop()\n\t\t\tnext_list.append(merged)\n\t\telse:\n\t\t\tnext_list.append(cur_list[i+1])\n\n\treturn(next_list)\n\nif __name__ == \'__main__\':\n\tmain()', '# encoding:utf-8\nimport math\n\ndef main():\n\tN, A, B, C, D = list(map(int, input().split()))\n\n\tfor i in range(N):\n\t\tplus_band = calcBand(i, C, D)\n\t\tminus_band = calcBand(N - i - 1, C, D)\n\t\ttotal_band = (plus_band[0] - minus_band[1], plus_band[1] - minus_band[0])\n\n\t\tif total_band[0] <= B - A <= total_band[1]:\n\t\t\tprint("YES")\n\t\t\tbreak\n\telse:\n\t\tprint("NO")\n\ndef calcBand(n_band, C, D):\n\treturn((C * n_band, D * n_band))\n\nif __name__ == \'__main__\':\n\tmain()']
['Runtime Error', 'Accepted']
['s999266343', 's835893117']
[3692.0, 3064.0]
[2107.0, 437.0]
[1146, 452]
p03666
u729133443
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
["n,a,b,c,d=map(int,input().split())\nf=0\nfor i in range(n):f^=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c\nprint('NYOE S'[f::2])", "n,a,b,c,d=map(int,input().split());print('NYOE S'[any(i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*cfor i in range(n))::2])", "n,a,b,c,d=map(int,input().split());print('NYOE S'[any(c*i-d*(~i+n)<=b-a<=d*i-c*(~i+n)for i in range(n))::2])"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s374749538', 's700391074', 's731206844']
[3060.0, 2940.0, 3060.0]
[278.0, 17.0, 205.0]
[113, 108, 108]
p03666
u754022296
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['N, A, B, C, D = map(int, input().split())\nE = B - A\nfor m in range(N):\n if C*(N-1-m) - D*m <= E <= -C*m + (N-1-m)*D:\n print("YES")\n break\nelse\nprint("NO")', 'N, A, B, C, D = map(int, input().split())\nE = B - A\nfor m in range(N):\n if C*(N-1-m) - D*m <= E <= -C*m + (N-1-m)*D:\n print("YES")\n break\nelse:\n print("NO")\n']
['Runtime Error', 'Accepted']
['s440424079', 's192970256']
[2940.0, 2940.0]
[17.0, 211.0]
[161, 165]
p03666
u814986259
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['N,A,B,C,D=map(int,input().split())\nif A> B:\n A,B=B,A\nif C>D:\n C,B=B,C\n\nflag=False\ndiff=B-A\nd=0\nfor i in range(0,N,2):\n d+=D-C\n j= N-1 - i\n if j==0:\n if diff==d:\n flag=True\n break\n k=abs(diff - d) / j\n if k>=C and k<=D:\n flag=True\n break\n \nif flag:\n print("YES")\nelse:\n print("NO")\n', 'N, A, B, C, D = map(int, input().split())\nif A > B:\n A, B = B, A\n\nflag = False\ndiff = B-A\nd = 0\nfor i in range(0, N, 2):\n if i > 0:\n d += D-C\n j = N-1 - i\n if diff == d and j % 2 == 0:\n flag == True\n break\n if j == 0:\n break\n\n k = abs(diff - d) / j\n if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):\n flag = True\n break\n k = abs(diff + d) / j\n if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):\n flag = True\n break\n\nif flag:\n print("YES")\nelse:\n print("NO")\n\n']
['Wrong Answer', 'Accepted']
['s960539431', 's729097812']
[3064.0, 3188.0]
[168.0, 378.0]
[310, 601]
p03666
u918935103
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['N,a,b,c,d = map(int,input().split())\nn = N - 1\nans = "No"\nfor i in range(n+1):\n m1 = i*d - (n-i)*c\n m2 = -1*(n-i)*d + i*c\n if m1 <= m2:\n if a + m1 <= b and b <= a+ m2:\n ans = "Yes"\n #print(m1,m2)\n break\n else:\n if a + m2 <= b and b <= a + m1:\n ans = "Yes"\n #print(m1,m2)\n break\nprint(ans)', 'N,a,b,c,d = map(int,input().split())\nn = N - 1\nans = "NO"\nfor i in range(n+1):\n m1 = i*d - (n-i)*c\n m2 = -1*(n-i)*d + i*c\n if m1 <= m2:\n if a + m1 <= b and b <= a+ m2:\n ans = "YES"\n #print(m1,m2)\n break\n else:\n if a + m2 <= b and b <= a + m1:\n ans = "YES"\n #print(m1,m2)\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s857885791', 's090925837']
[3188.0, 3064.0]
[394.0, 416.0]
[380, 380]
p03666
u994988729
2,000
262,144
There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty. Aohashi would like to fill the empty squares with integers so that the following condition is satisfied: * For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive). As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.
['N, A, B, C, D = map(int, input().split())\nB -= A\n\nans = "NO"\nfor i in range(N):\n high = i * D - (N - i - 1) * C\n low = i * C - (N - i - 1) * D\n print(i, N-i-1, low, high)\n if low <= B <= high:\n ans = "YES"\nprint(ans)', 'N, A, B, C, D = map(int, input().split())\n\ndif = B - A\n\nans = "NO"\nfor i in range(N):\n pos = i\n neg = N - i - 1\n high = D * pos - C * neg\n low = C * pos - D * neg\n if low <= dif <= high:\n ans = "YES"\n break\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s691782832', 's931847147']
[25444.0, 3188.0]
[1289.0, 331.0]
[235, 247]
p03667
u340781749
2,000
262,144
There are N balls in a row. Initially, the i-th ball from the left has the integer A_i written on it. When Snuke cast a spell, the following happens: * Let the current number of balls be k. All the balls with k written on them disappear at the same time. Snuke's objective is to vanish all the balls by casting the spell some number of times. This may not be possible as it is. If that is the case, he would like to modify the integers on the minimum number of balls to make his objective achievable. By the way, the integers on these balls sometimes change by themselves. There will be M such changes. In the j-th change, the integer on the X_j-th ball from the left will change into Y_j. After each change, find the minimum number of modifications of integers on the balls Snuke needs to make if he wishes to achieve his objective before the next change occurs. We will assume that he is quick enough in modifying integers. Here, note that he does not actually perform those necessary modifications and leaves them as they are.
['from collections import Counter, defaultdict\n\nn, m = map(int, input().split())\nan = list(map(int, input().split()))\nac = defaultdict(int, Counter(an))\nad = [0] * (n * 2)\nfor a, c in ac.items():\n for i in range(a - c, a):\n ad[i] += 1\nans = ad[:n].count(0)\n\nfor _ in range(m):\n x, y = map(int, input().split())\n ax = an[x - 1]\n xdi = ax - ac[ax]\n ad[xdi] -= 1\n ac[ax] -= 1\n ac[y] += 1\n ydi = y - ac[y]\n ad[ydi] += 1\n an[x - 1] = y\n if ad[xdi] == 0:\n ans += 1\n if ad[ydi] == 1:\n ans -= 1\n print(ans)\n', "from collections import Counter\n\nn, m = map(int, input().split())\nan = list(map(int, input().split()))\nac_ = Counter(an)\nac = {i: ac_[i] if i in ac_ else 0 for i in range(1, n + 1)}\nad = [0] * n\nfor a, c in ac.items():\n for i in range(max(0, a - c), a):\n ad[i] += 1\nans = ad.count(0)\nanss = []\n\nfor x, y in (map(int, input().split()) for _ in range(m)):\n ax = an[x - 1]\n xdi = ax - ac[ax]\n if xdi >= 0:\n ad[xdi] -= 1\n if ad[xdi] == 0:\n ans += 1\n ac[ax] -= 1\n ac[y] += 1\n ydi = y - ac[y]\n if ydi >= 0:\n ad[ydi] += 1\n if ad[ydi] == 1:\n ans -= 1\n an[x - 1] = y\n anss.append(ans)\nprint('\\n'.join(map(str, anss)))\n"]
['Wrong Answer', 'Accepted']
['s628719500', 's869739371']
[41060.0, 74716.0]
[2105.0, 1491.0]
[557, 696]
p03675
u035336908
2,000
262,144
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
['N = int(input())\na = input().split()\nb = []\nfor i in range(len(a)):\n\tif i % 2 == 1:\n\t\tb.insert(0, a[i])\n\telse:\n\t\tb.append(a[i])\nif N % 2 == 1:\n\tb = b.reverse()\nprint(b)\nline = " ".join(b)\nprint(line)', 'N = int(input())\na = input().split()\nb = [""] * N\nb1 = [a[i] for i in range(len(a)) if i % 2 == 1][::-1]\nb2 = [a[i] for i in range(len(a)) if i % 2 == 0]\nb = b1 + b2\nif N % 2 == 1:\n\tb = b[::-1]\nline = " ".join(b)\nprint(line)']
['Runtime Error', 'Accepted']
['s927733953', 's575395376']
[20184.0, 28148.0]
[2105.0, 90.0]
[199, 224]