s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s195771594 | p03846 | u444856278 | 1518368116 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14820 | 539 | from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
po = Counter(A)
ans = -1
mod = 10**9 + 7
if N % 2 == 0:
if po[0] != 0:
ans = 0
else:
for i in range(1,N,2):
if po[i] != 2:
ans = 0
if ans != 0:
ans = int(2**(N/2)) % mod
else:
if po[0] != 1:
ans = 0
else:
for i in range(2,N,2):
if po[i] != 2:
ans = 0
if ans != 0:
ans = int(2**((N-1)/2)) % mod
print(ans) |
s754214987 | p03846 | u444856278 | 1518246920 | Python | Python (3.4.3) | py | Runtime Error | 75 | 14948 | 526 | from collections import Counter
f = lambda :[int(i) for i in input().split()]
N = int(input())
A = f()
po = Counter(A)
ans = -1
if N % 2 == 0:
if po[0] != 0:
ans = 0
else:
for i in range(1,N,2):
if po[i] != 2:
ans = 0
if ans != 0:
ans = int(2**(N/2))
else:
if po[0] != 1:
ans = 0
else:
for i in range(2,N,2):
if po[i] != 2:
ans = 0
if ans != 0:
ans = int(2**((N-1)/2))
print(ans) |
s720777274 | p03846 | u075012704 | 1515728034 | Python | Python (3.4.3) | py | Runtime Error | 66 | 16352 | 674 | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
div = 10**9 + 7
if N % 2 == 0:
if A.count(0) != 0:
print(0)
else:
A = dict(Counter(A))
val = A.values()
val = list(filter(lambda x: x == 2, val))
if len(val) * 2 == N:
print(int(2**(N/2) % div))
else:
print(0)
else:
if A.count(0) != 1:
print(0)
else:
A.remove(0)
A = dict(Counter(A))
val = A.values()
val = list(filter(lambda x: x == 2, val))
if len(val) * 2 == (N-1):
print(int(2 ** ((N-1) / 2) % div))
else:
print(0)
|
s939337059 | p03846 | u075012704 | 1515727497 | Python | Python (3.4.3) | py | Runtime Error | 69 | 16352 | 594 | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
div = 10**9+7
if N % 2 == 0:
A = dict(Counter(A))
val = A.values()
val = list(filter(lambda x: x == 2, val))
if len(val) * 2 == N:
print(int(2**(N/2) % div))
else:
print(0)
else:
if A.count(0) != 1:
print(0)
else:
A.remove(0)
A = dict(Counter(A))
val = A.values()
val = list(filter(lambda x: x == 2, val))
if len(val) * 2 == (N-1):
print(int(2 ** ((N-1) / 2) % div))
else:
print(0)
|
s505521402 | p03846 | u136090046 | 1512532946 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 13880 | 643 | num =int(input())
val = [int(x) for x in input().split()]
_len = len(val)
sort_val = sorted(val)
set_val = set(sort_val)
res = True
if len(sort_val) %2 != 0 and sort_val[1] == 0:
res = False
elif len(sort_val) %2 != 0 and sort_val[1] != 0:
sort_val = sort_val[1:]
set_val.remove(0)
if res:
for i in set_val:
if len(sort_val) == 2 and sort_val[0] == sort_val[1]:
break
if sort_val[2] == i:
res = False
break
else:
sort_val = sort_val[2:]
cnt = 1
if res:
for i in range(0, _len//2):
cnt = cnt*2 % 1000000007
print(0 if not res else cnt)
|
s188125841 | p03846 | u190405389 | 1507171274 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 560 | n = int(input())
a = list(map(int, input().split()))
ans = 1
b = [0] * ((n + 1) // 2)
if n % 2 == 0:
for x in a:
if x % 2 == 0:
print(0)
exit()
b[x // 2] += 1
for y in b:
if y != 2:
print(0)
exit()
else:
for x in a:
if x % 2 != 0:
print(0)
exit()
b[x // 2] += 1
for y in b[1:]:
if y != 2:
print(0)
exit()
if b[0] != 1:
print(0)
exit()
print((2 ** (n//2)%(10**9+7))
|
s400454309 | p03846 | u665415433 | 1506696346 | Python | Python (3.4.3) | py | Runtime Error | 81 | 13880 | 760 | N = int(input())
A = [int(i) for i in input().split()]
A.sort()
old, check = 0, 0
if len(A) % 2 is 1:
if A[0] is not 0 or A[1] is not 2:
print(0)
exit()
else:
for i in range(1, N):
if old is A[i] and check <= 1:
check += 1
elif old + 2 is A[i] and check <= 1:
old = A[i]
check = 0
else:
print(0)
exit()
print(2 ** ((N - 1) // 2))
else:
old = -1
for i in range(N):
if old is A[i] and check <= 1:
check += 1
elif old + 2 is A[i] and check <= 1:
old = A[i]
check = 0
else:
print(0)
exit()
print(2 ** (N // 2))
|
s691727594 | p03846 | u052746401 | 1491110372 | Python | Python (3.4.3) | py | Runtime Error | 97 | 14324 | 530 | import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = True
if n % 2 == 1:
if a[0] != 0:
print(0)
else:
ans = [i for i in range(2, n, 2) for j in range(2)]
ans.insert(0, 0)
if ans != a:
print(0)
flag = False
if flag:
print((2**((n - 1) // 2)) % (1e9 + 7))
else:
ans = [i for i in range(1, n, 2) for j in range(2)]
if ans != a:
print(0)
flag = False
if flag:
print((2**(n // 2)) % (1e9 + 7))
|
s794217917 | p03846 | u052746401 | 1491109874 | Python | Python (3.4.3) | py | Runtime Error | 96 | 14324 | 540 | import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = True
if n % 2 == 1:
if a[0] != 0:
print(0)
else:
ans = [i for i in range(2, n, 2) for j in range(2)]
ans.insert(0, 0)
if ans != a:
print(0)
flag = False
if flag:
print(int((2**((n - 1) // 2)) % (1e9 + 7)))
else:
ans = [i for i in range(1, n, 2) for j in range(2)]
if ans != a:
print(0)
flag = False
if flag:
print(int((2**(n // 2)) % (1e9 + 7)))
|
s016175301 | p03846 | u052746401 | 1491109202 | Python | Python (3.4.3) | py | Runtime Error | 92 | 14324 | 562 | import copy
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = True
if n % 2 == 1:
if a[0] != 0:
print(0)
else:
for i in range(2, n, 2):
if not(a[i - 1] == i and a[i] == i):
print(0)
flag = False
break
if flag:
print(int((2**((n-1)//2))%(1e9+7)))
else:
for i in range(1, n, 2):
if not(a[i - 1] == i and a[i] == i):
print(0)
flag = False
break
if flag:
print(int((2**(n//2))%(1e9+7)))
|
s439594095 | p03846 | u010110540 | 1486755725 | Python | Python (3.4.3) | py | Runtime Error | 101 | 14008 | 329 | N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
l = list(range(1, N, 2)) * 2
else:
l = [0] + list(range(2, N, 2)) * 2
flag = True
if sorted(A) != sorted(l):
flag = False
if flag == False:
print(0)
else:
if N % 2 == 0:
print(int(2**(N/2)) % 1000000007)
else:
print(int(2**((N-1)/2)) % 1000000007)
|
s117089694 | p03846 | u010110540 | 1486755373 | Python | Python (3.4.3) | py | Runtime Error | 90 | 19040 | 389 | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
l = list(range(1, N, 2)) * 2
else:
l = [0] + list(range(2, N, 2)) * 2
flag = True
cntA = Counter(A)
cntl = Counter(l)
if cntA != cntl:
flag = False
if flag == False:
print(0)
else:
if N % 2 == 0:
print(int(2**(N/2)) % 1000000007)
else:
print(int(2**((N-1)/2)) % 1000000007) |
s235262120 | p03846 | u010110540 | 1486754675 | Python | Python (3.4.3) | py | Runtime Error | 59 | 14008 | 361 | N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
l = list(range(1, N, 2)) * 2
else:
l = [0] + list(range(2, N, 2)) * 2
flag = True
for i in range(N):
if sorted(T)[i] != sorted(A):
flag = False
break
if flag == False:
print(0)
else:
if N % 2 == 0:
print(int(2**(N/2)) % 1000000007)
else:
print(int(2**((N-1)/2)) % 1000000007) |
s290810656 | p03846 | u010110540 | 1486754639 | Python | Python (3.4.3) | py | Runtime Error | 60 | 14008 | 361 | N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
l = list(range(1, N, 2)) * 2
else:
l = [0] + list(range(2, N, 2)) * 2
flag = True
for i in range(N):
if sorted(T)[i] != sorted(A):
flag = Flase
break
if flag == False:
print(0)
else:
if N % 2 == 0:
print(int(2**(N/2)) % 1000000007)
else:
print(int(2**((N-1)/2)) % 1000000007) |
s281189732 | p03846 | u010110540 | 1486754264 | Python | Python (3.4.3) | py | Runtime Error | 64 | 14008 | 356 | N = int(input())
A = list(map(int, input().split()))
if N % 2 == 0:
l = list(range(1, N, 2)) * 2
else:
l = [0] + list(range(2, N, 2)) * 2
flag = True
if sum(A) != sum(l):
flag = False
if A.count(0) > 1:
flag = False
if flag == False:
print(0)
else:
if N % 2 == 0:
print(int(2**(N/2)) % 1000000007)
else:
print(int(2**((N-1)/2)) % 1000000007) |
s606327716 | p03846 | u348405655 | 1485412832 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 405 | N = int(input())
A = list(map(int,input().split()))
Nc = 1
if A.count(0) >= 2:
Nc *= 0
else:
for i in range(N):
if (N-A[i]-1) >= 0:
if A.count(i+1) == 2:
Nc = Nc*2
elif A.count(i+1) == 0:
else:
Nc *= 0
break
else:
Nc *= 0
break
print(Nc%1000000007) |
s176078742 | p03846 | u348405655 | 1485411627 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 430 | N = int(input())
A = list(map(int,input().split()))
Nc = 1
if A.count(0) >= 2:
Nc *= 0
else:
for i in range(N):
if (N-A[i]) >=1
if A.count(i+1) == 2:
Nc = Nc*2%1000000007
elif A.count(i+1) == 0:
Nc *= 1
else:
Nc *= 0
break
else:
Nc *= 0
break
print(Nc)
|
s972340692 | p03846 | u455505352 | 1483418995 | Python | Python (3.4.3) | py | Runtime Error | 140 | 14008 | 542 | N = int(input())
A = list(map(lambda x:int(x), input().split()))
fail=False
count_list = [0]*(int((N-1)/2)+1)
for i in range(N):
if A[i]%2==N%2:
print(0)
fail=True
break
count_list[int(A[i]/2)] = count_list[int(A[i]/2)]+1
if not fail:
if N%2==0:
for c in count_list:
if c!=2:
print(0)
break
else:
print(int(2**(N/2)%(10**9+7)))
if N%2==1:
if count_list[0]!=1:
print(0)
else:
count_list.pop(0)
for c in count_list:
if c!=2:
print(0)
break
else:
print(int(2**((N-1)/2)%(10**9+7)))
|
s150328344 | p03846 | u353638740 | 1483141372 | Python | Python (3.4.3) | py | Runtime Error | 177 | 14008 | 778 | N = int(input())
As = map(int,input().split())
As = list(As)
divider = pow(10,9)+7
def checkTrueReport(array):
if len(array) != N:
return False
sorted_array = sorted(array)
correct_array = list()
if N % 2 == 0:
for i in range(0,N):
element = i
if i %2==0:
element +=1
correct_array.append(element)
else:
for i in range(0,N):
element = i
if i %2!=0:
element +=1
correct_array.append(element)
return correct_array == sorted_array
checkTrueReport(As)
if checkTrueReport(As):
if N % 2 == 0:
answer = pow(2,N/2)%divider
else:
answer = pow(2,(N-1)/2)%divider
print(int(answer))
else:
print(0) |
s496669288 | p03846 | u386131832 | 1482418602 | Python | Python (3.4.3) | py | Runtime Error | 110 | 13812 | 290 | n=int(input())
list=[int(i) for i in input().split()]
list.sort()
if n%2==0:
count=0
else: count=1
while count<n and list[count]==list[count+1]:
count+=2
if count>=len(list):
if n%2==0:
print(int(2**(n/2)))
else:
print(int(2**((n-1)/2)))
else:
print(0) |
s459668112 | p03846 | u095015466 | 1482186142 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 469 | def pow(base, nod):
MOD = 10**9+7
ans = 1
tmp = 2
while base>0:
if base%2==1: ans=ans*tmp%MOD
tmp = tmp**2%MOD
base /= 2
return ans
n=int(raw_input())
a=map(int,raw_input().split())
d={}
for i in xrange(n):
if a[i] not in d: d[a[i]]=0
d[a[i]]+=1
isValid=True
if n%2==0:
for k,v in d:
if k%2!=1 or v!=2:
isValid=False
else:
for k,v in d:
if k%2!=0 or (k==0 and v!=1) or (k!=0 and v!=2):
isValid=False
if isValid:
print pow(2, n/2)
else:
print 0 |
s253868293 | p03846 | u379559362 | 1482156458 | Python | Python (3.4.3) | py | Runtime Error | 87 | 14820 | 368 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = n//2
ca = Counter(a)
if n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
ans = (2 ** m) % (1e9 + 7)
print(int(ans))
elif n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
ans = (2 ** m) % (1e9 + 7)
print(int(ans))
else:
print(0)
|
s104302684 | p03846 | u379559362 | 1482156203 | Python | Python (3.4.3) | py | Runtime Error | 91 | 14948 | 364 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = n//2
ca = Counter(a)
if n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
ans = 2 ** m % (1e9 + 7)
print(int(ans))
elif n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
ans = 2 ** m % (1e9 + 7)
print(int(ans))
else:
print(0)
|
s841312301 | p03846 | u379559362 | 1482156030 | Python | Python (3.4.3) | py | Runtime Error | 86 | 14820 | 349 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
m = n//2
ca = Counter(a)
if n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
ans = 2 ** m % (1e9 + 7)
print(int(ans))
elif n % 2 == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
ans = 2 ** m % (1e9 + 7)
print(int(ans))
else:
print(0)
|
s411228976 | p03846 | u270343876 | 1482124619 | Python | Python (2.7.6) | py | Runtime Error | 65 | 11304 | 508 | N = int(raw_input())
line = map(int,raw_input().split(' '))
if N%2 == 0:
for i in range(1,N-1,2):
if line.count(i) != 2:
print 0
exit(0)
line.remove(i)
line,remove(i)
print 2**(N/2) %(10**9+7)
else:
if line.count(0) != 1:
print 0
exit(0)
line.remove(0)
for i in range(2,N-1,2):
if line.count(i) != 2:
print 0
exit(0)
line.remove(i)
line,remove(i)
print 2**(N/2)%(10**9+7)
|
s910230122 | p03846 | u270343876 | 1482123728 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 373 | N = int(raw_input())
line = map(int,raw_input().split(' '))
if N%2 == 0:
for i in range(1,N-1,2):
if line.count(i) != 2:
print 0
exit(0)
print 2**(N/2)
else:
if line.count(0) != 1:
print 0
break
for i in range(2,N-1,2):
if line.count(i) != 2:
print 0
exit(0)
print 2**(N/2) |
s789752761 | p03846 | u627417051 | 1482118801 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3068 | 550 | N = int(input())
L = input().split()
if N % 2 == 0:
sc = 0
for i in range(0, N):
n = L.count(str(i))
if n ¥= 2:
sc += 1
break
else:
pass
if sc ==0:
ss = 2 * (N / 2)
print(ss)
else:
n = L.count("0")
if n % 2 ¥= 0:
print(0)
else:
for i in range(0, N):
n = L.count(str(i))
if n ¥= 2:
sc += 1
break
else:
pass
if sc ==0:
ss = 2 * (N / 2)
print(ss)
|
s341848716 | p03846 | u781758937 | 1482118430 | Python | Python (3.4.3) | py | Runtime Error | 57 | 14008 | 449 | import sys
sys.setrecursionlimit(10000)
N = int(input())
A = list(map(int,input().split()))
error = 0
if N%2 == 1:
if A.count(0) != 1:
print(0)
elif sum(A) != (N+1)*(N-1)/2:
print(0)
else:
print(int((2**((N-1)/2))%(10**9+7)))
else:
if A.count(0) != 0:
print(0)
elif sum(A) != N**2/2:
print(0)
else:
print(int((2**(N/2))%(10**9+7)))
|
s766972455 | p03846 | u069170167 | 1482117843 | Python | Python (3.4.3) | py | Runtime Error | 1343 | 23536 | 393 | import numpy as np
import math
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
print(int(math.fmod(math.pow(2, N//2), (math.pow(10, 9) + 7))))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
print(int(math.fmod(math.pow(2, N//2), (math.pow(10, 9) + 7))))
else:
print(0) |
s892843953 | p03846 | u069170167 | 1482117709 | Python | Python (3.4.3) | py | Runtime Error | 1741 | 23508 | 409 | import numpy as np
import math
N = int(input())
A = list(map(int, input().split()))
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
print(np.int64(np.remainder(math.pow(2, N//2), (math.pow(10, 9) + 7))))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
print(np.int64(np.remainder(math.pow(2, N//2), (math.pow(10, 9) + 7))))
else:
print(0) |
s304940294 | p03846 | u781758937 | 1482117080 | Python | Python (3.4.3) | py | Runtime Error | 56 | 14008 | 409 | N = int(input())
A = list(map(int,input().split()))
error = 0
if N%2 == 1:
if A.count(0) != 1:
print(0)
elif sum(A) != (N+1)*(N-1)/2:
print(0)
else:
print(int((2**((N-1)/2))%(10**9+7)))
else:
if A.count(0) != 0:
print(0)
elif sum(A) != N**2/2:
print(0)
else:
print(int((2**(N/2))%(10**9+7)))
|
s970177722 | p03846 | u442810826 | 1482116972 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2696 | 1014 | N = int(raw_input())
A=map(int, raw_input().split(' '))
A.sort()
flug = 0
if N % 2 == 0:
for i in range(N):
if not A[i] == 2*(i/2)+1:
N = int(raw_input())
A=map(int, raw_input().split(' '))
A.sort()
flug = 0
if N % 2 == 0:
for i in range(N):
if not A[i] == 2*(i/2)+1:
print 0
flug = 1
break
else:
for i in range(N):
if i % 2 == 0:
if not A[i] == i:
print 0
flug =1
break
else:
if not A[i] == i+1:
print 0
flug = 1
break
if flug == 0:
print(pow(2, N/2))
flug = 1
break
else:
for i in range(N):
if i % 2 == 0:
if not A[i] == i:
flug =1
break
else:
if not A[i] == i+1:
flug = 1
break
if flug == 0:
print(pow(2, N/2))
else:
print 0 |
s151053199 | p03846 | u752513456 | 1482116455 | Python | Python (3.4.3) | py | Runtime Error | 96 | 10548 | 503 | N = int(input())
A = input().split().sort()
dic = dict()
for a in A:
a = int(a)
dic[a] = dic.get(a, 0) + 1
keys = list(dic.keys())
values = list(dic.values())
if N % 2 == 0:
if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
print(2**(N//2) % (10**9 + 7))
else:
print(0)
else:
if keys == [2*i for i in range(N//2)] and values == [1] + [2 for i in range(N//2 - 1)]:
print(2**(N//2) % (10**9 + 7))
else:
print(0)
|
s931748574 | p03846 | u522322096 | 1482115806 | Python | Python (3.4.3) | py | Runtime Error | 102 | 14692 | 287 | import sys
n = int(input())
a_lst = [int(x) for x in input().split()]
dic = {}
for i in range(1, n + 1, 2):
j = n - i
dic[j] = 1 if j == 0 else 2
for i in a_lst:
dic[i] -= 1
if dic[i] < 0:
print(0)
sys.exit()
print(pow(2, n // 2) % (pow(10, 9) + 7)) |
s443833637 | p03846 | u553070003 | 1482115763 | Python | Python (3.4.3) | py | Runtime Error | 78 | 14008 | 509 | n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
res = 1
for i in a:
b[i] += 1
if n % 2 == 1:
if b[0] != 1:
print(0)
exit(2)
else:
for i in range(2, n, 2):
if b[i] != 2:
print(0)
exit(3)
#print(res)
res = res * 2 % (10**9 + 7)
else:
for i in range(1, n, 2):
if b[i] != 2:
print(0)
exit(4)
res = res * 2 % (10 ** 9 + 7)
print(res) |
s838486469 | p03847 | u786020649 | 1594917426 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9236 | 408 | import sys
p=10**9+7
dthbit=lambda d,n: (n>>d)&1
def main(n):
dp=[[0 for _ in range(3)] for _ in range(64)]
dp[63][0]=1
for d in range(62,-1,-1):
b=dthbit(d,n)
s=dp[d+1][:]
dp[d][0]=dp[d+1][0]+(1^b)*dp[d+1][1] % p
dp[d][1]=b*dp[d+1][0]+dp[d+1][1] % p
dp[d][2]=(1+b)*dp[d+1][1]+3*dp[d+1][2] % p
return sum(dp[0][:] % p)
n=int(input())
print(main(n))
|
s421810909 | p03847 | u292978925 | 1586832623 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 372 | import sys
in1 = sys.stdin.readlines()
N = in1[0]
#N = 10 ** 18
#N = 2
"""
0 + 0 = 0
0 x 0 = 0
1 + 0 = 1
1 x 0 = 1
2 + 0 = 2
2 x 0 = 2
1 + 1 = 2
1 x 1 = 0
3 + 0 = 3
3 x 0 = 3
2 + 1 = 3
2 x 1 = 3
"""
p = 10 ** 9 + 7
def f(n):
if n in d:
return d[n]
d[n] = f(n // 2) + f((n - 1) // 2) + f((n - 2) // 2)
return d[n]
d = {0: 1, 1: 2}
print(f(N) % p)
|
s607029356 | p03847 | u213143275 | 1586390329 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1291 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7
def read_values():
return map(int, input().split())
def read_index():
return map(lambda x: int(x) - 1, input().split())
def read_list():
return list(read_values())
def read_lists(N):
return [read_list() for n in range(N)]
class V:
def __init__(self, f, v=None):
self.f = f
self.v = v
def __str__(self):
return str(self.v)
def ud(self, n):
if n is None:
return
if self.v is None:
self.v = n
return
self.v = self.f(self.v, n)
def get(self, init=None):
if self.v is None:
return init
else:
return self.v
def main():
N = format(int(input()), "b")
D = len(str(N))+1
dp = [[0 for _ in range(3)] for __ in range(D + 1)]
dp[0][0] = 1
print(N)
for d in range(D):
for k in range(3):
for s in range(3):
sd = 2 * s + int(N[d]) - k
if sd > 2:
sd = 2
if sd < 0:
continue
dp[d + 1][sd] += dp[d][s]
dp[d + 1][sd] %= mod
print(sum(dp[D]))
if __name__ == "__main__":
main()
|
s845820172 | p03847 | u976365284 | 1575862843 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 196 | n = int(input())
m = 10 ** 9 + 7
l = 2 ** 32
xs = [int(x) for x in input().split()]
r = 0
for i in range(0, n - 1):
for j in range(i + 1, n):
r = (r + ((xs[i] ^ xs[j]) % l)) % m
print(r)
|
s288141345 | p03847 | u976365284 | 1575862813 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 196 | n = int(input())
m = 10 ** 9 + 7
l = 2 ** 32
xs = [int(x) for x in input().split()]
r = 0
for i in range(0, n - 1):
for j in range(i + 1, n):
r = (r + ((xs[i] ^ xs[j])) % l) % m
print(r)
|
s219049360 | p03847 | u675757825 | 1569471673 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 773 | #include<cstdio>
const long A = 1e9 + 7;
long n;
int dp[2][3];
int main() {
scanf("%ld", &n);
dp[0][0] = 1;
for (int i = 59; i >= 0; i--) {
if ((n >> i) & 1) {
dp[i & 1][2] = (static_cast<long>(dp[(i + 1) & 1][2]) * 3 + dp[(i + 1) & 1][1] * 2) % A;
dp[i & 1][1] = (dp[(i + 1) & 1][1] + dp[(i + 1) & 1][0]) % A;
dp[i & 1][0] = dp[(i + 1) & 1][0];
}
else {
dp[i & 1][2] = (static_cast<long>(dp[(i + 1) & 1][2]) * 3 + dp[(i + 1) & 1][1]) % A;
dp[i & 1][1] = dp[(i + 1) & 1][1];
dp[i & 1][0] = (dp[(i + 1) & 1][1] + dp[(i + 1) & 1][0]) % A;
}
}
int ans = 0;
for (int i = 0; i <= 2; i++) ans = (ans + dp[0][i]) % A;
printf("%d\n", ans);
}
|
s022167846 | p03847 | u736729525 | 1566493939 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 758 | import heapq
def dijkstra(m, s, t):
INF = 1e10
D = [INF] * N
D[s] = 0
Q = [(0 if s == v else INF, v) for v in range(N)]
heapq.heapify(Q)
while Q:
c, u = heapq.heappop(Q)
if D[u] < c:
continue
for v, w in m[u]:
if D[v] > D[u] + w:
D[v] = D[u] + w
heapq.heappush(Q, (D[u]+w, v))
return D[t]
N, M = map(int, input().split())
# N < 100
m = [[] for i in range(N)]
E = [0] * M
for i in range(M):
a, b, w = map(int, input().split())
E[i] = a-1, b-1, w
m[a-1].append((b-1,w))
m[b-1].append((a-1,w))
count = 0
for a, b, w in E:
d = dijkstra(m, a, b)
#print((a+1, b+1), d, "w=%d"%w)
if d < w:
count += 1
print(count)
|
s303372584 | p03847 | u310678820 | 1562357384 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 1482 | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def unite(self, x, y):
x = self.find(x)
y = self.find(y)
if self.rank[x] < self.rank[y]:
self.par[x] = y
else:
self.par[y] = x
if self.rank[x] == self.rank[y]:
self.rank[x] += 1
# 同じ集合に属するか判定
def same_check(self, x, y):
return self.find(x) == self.find(y)
N, K, L = map(int, input().split())
mark = 0
U1 = UnionFind(N)
U2 = UnionFind(N)
for i in range(K):
p, q = map(int, input().split())
U1.unite(p-1, q-1)
for i in range(L):
r, s = map(int, input().split())
U2.unite(r-1, s-1)
List=[]
for i in range(N):
List.append((U1.par[i], U2.par[i], i))
List = sorted(List)
cnt = 0
member = []
ans = [0]*N
for i in range(N-1):
if List[i][0]==List[i+1][0] and List[i][1]==List[i+1][1]:
cnt+=1
if member:
member.append(List[i+1][2])
else:
member.append(List[i][2])
member.append(List[i+1][2])
else:
for j in member:
ans[j]=cnt
cnt = 0
member = []
for j in member:
ans[j]=cnt
for i in range(N):
print(ans[i]+1) |
s648484240 | p03847 | u655834330 | 1558202950 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38640 | 775 | import numpy as np
def read_input():
n = int(input())
return n
def mymod(x):
return x % (10**9 + 7)
def submit():
N = read_input()
N = list(map(int, list(bin(N)[2:])))
dp = np.zeros((len(N) + 1, 3))
dp[len(N)][0] = 1
for i in range(len(N) - 1, -1, -1):
for s in range(3):
for k in range(3):
new_s = 2 * s + N[len(N) - i - 1] - k
if new_s < 0:
continue
if new_s > 2:
new_s = 2
dp[i][new_s] += mymod(dp[i + 1][s])
dp[i][0] = mymod(dp[i][0])
dp[i][1] = mymod(dp[i][1])
dp[i][2] = mymod(dp[i][2])
print(int(sum(dp[0])) % (10**9 + 7))
if __name__ == '__main__':
submit() |
s204293712 | p03847 | u736228006 | 1529515165 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 280 | MOD = 10**9+7
N = int(input())
dp = [1,0,0]
for i in range(64,-1,-1):
ndp = [0,0,0]
for d in range(3):
nd = d*2 + (n>>>i&1)
ndp[min(2,nd)] += dp[d]
if nd >= 1: ndp[min(2,nd-1)] += dp[d]
if nd >= 2: ndp[min(2,nd-2)] += dp[d]
dp = ndp
print(sum(dp) % MOD) |
s531392066 | p03847 | u736228006 | 1529515083 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 285 | MOD = int(1e9) + 7
N = int(input())
dp = [1,0,0]
for i in range(64,-1,-1):
ndp = [0,0,0]
for d in range(3):
nd = d*2 + (n>>>i&1)
ndp[min(2,nd)] += dp[d]
if nd >= 1: ndp[min(2,nd-1)] += dp[d]
if nd >= 2: ndp[min(2,nd-2)] += dp[d]
dp = ndp
print(sum(dp) % MOD) |
s987735766 | p03847 | u736228006 | 1529514891 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 285 | MOD = int(1e9) + 7
N = int(input())
dp = [1,0,0]
for i in range(64,-1,-1):
ndp = [0,0,0]
for d in range(3):
nd = d*2 + (N>>>i&1)
ndp[min(2,nd)] += dp[d]
if nd >= 1: ndp[min(2,nd-1)] += dp[d]
if nd >= 2: ndp[min(2,nd-2)] += dp[d]
dp = ndp
print(sum(dp) % MOD) |
s648507151 | p03847 | u736228006 | 1529514549 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 284 | MOD = int(10**9)+7
N = int(input())
dp[0][0] = 1
for i in range(64,-1,-1):
ndp = [0,0,0]
for d in range(3):
nd = d*2 + (N>>>i&1)
ndp[min(2,nd)] += dp[d]
if nd >= 1: ndp[min(2,nd-1)] += dp[d]
if nd >= 2: ndp[min(2,nd-2)] += dp[d]
dp = ndp
print(sum(dp) % MOD) |
s758801126 | p03847 | u736228006 | 1529514179 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 280 | MOD = int(1e9) + 7
N = int(input())
dp[0][0] = 1
for i in range(64,-1,-1):
ndp[0][0] = 0
for d in range(3):
nd = d*2 + (N>>>i&1)
ndp[min(2,nd)] += dp[d]
if nd >= 1: ndp[min(2,nd-1)] += dp[d]
if nd >= 2: ndp[min(2,nd-2)] += dp[d]
dp = ndp
print(sum(dp) % MOD) |
s426924495 | p03847 | u348405655 | 1485414608 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3064 | 469 | N = int(input())
A = list(map(int,input().split()))
Nc = 1
e = 0
for i in range(N):
if (N-A[i]-1) < 0:
e = 1
Nc = 0
break
if e ==0:
if A.count(0) >= 2:
Nc *= 0
else:
for i in range(N-1):
if A.count(i+1) == 2:
Nc *= 2
elif A.count(i+1) ==0:
Nc *= 1
else:
Nc *= 0
break
print(Nc%1000000007) |
s840826139 | p03847 | u280667879 | 1482236961 | Python | Python (3.4.3) | py | Runtime Error | 29 | 3700 | 125 | from functools import*
@lru_cache
def d(n):x=n//2;return n+1 if n<2 else d(x)+d(~-x)+d(n+~x)
print(d(int(input()))%(10**9+7)) |
s786362403 | p03848 | u917872021 | 1599233737 | Python | Python (3.8.2) | py | Runtime Error | 97 | 20532 | 543 | n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
a_counter = {}
for a in a_list:
if a in a_counter.keys():
a_counter[a] += 1
else:
a_counter[a] = 1
data_error = False
if n % 2 == 0:
for i in range(1, n, 2):
if a_counter[i] != 2:
data_error = True
else:
for i in range(0, n, 2):
if a_counter[i] != 2:
if i == 0 and a_counter[0] == 1:
continue
data_error = True
if data_error:
print(0)
else:
print(2**(int(n/2)))
|
s732066428 | p03848 | u266014018 | 1595830111 | Python | Python (3.8.2) | py | Runtime Error | 35 | 17092 | 370 | def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n = int(input())
a = map(int, input().split())
mod = 10**9 + 7
a.sort()
check = [i+1 - (i+n)%2 for i in range(n)]
if a != check:
print(0)
return
else:
ans = pow(2, n//2, mod)
print(ans)
if __name__ == '__main__':
main() |
s513585353 | p03848 | u266014018 | 1595830083 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9104 | 336 | def main():
import sys
def input(): return sys.stdin.readline().rstrip()
n = int(input())
mod = 10**9 + 7
a.sort()
check = [i+1 - (i+n)%2 for i in range(n)]
if a != check:
print(0)
return
else:
ans = pow(2, n//2, mod)
print(ans)
if __name__ == '__main__':
main() |
s013684493 | p03848 | u644907318 | 1593259265 | Python | PyPy3 (7.3.0) | py | Runtime Error | 119 | 93836 | 720 | N = int(input())
A = list(map(int,input().split()))
if N==1:
if A[0]==0:
print(1)
else:
print(0)
else:
C = {}
for i in range(N):
a = A[i]
if a not in C:
C[a]=0
C[a] += 1
flag = 0
if N%2==0:
for i in range(1,N,2):
if C[i]==2:continue
flag=1
break
else:
for i in range(2,N,2):
if C[i]==2:continue
flag = 1
break
if C[0]!=1:
flag = 1
if flag==1:
print(0)
else:
p = 10**9+7
k = N//2
ans = 1
cnt = 1
while cnt<=k:
ans = (ans*2)%p
cnt += 1
print(ans) |
s301503893 | p03848 | u919025034 | 1592872689 | Python | PyPy3 (7.3.0) | py | Runtime Error | 121 | 94716 | 442 | import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))
if N%2==0:
for i in range(0,N,2):
if i%2==0 and A[i]==0:
pass
elif i%2==a and A[i]==2:
pass
else:
print(0);exit(0)
else:
for i in range(N):
if i==0 and A[i]==1:
continue
if i%2==0 and A[i]==2:
pass
elif i%2==1 and A[i]==0:
pass
else:
print(0);exit(0)
print(pow(2,N//2,10**9+7 )) |
s450891694 | p03848 | u919025034 | 1592872566 | Python | PyPy3 (7.3.0) | py | Runtime Error | 120 | 95016 | 440 | import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))
if N%2==0:
for i in range(0,N,2):
if i%2==0 and A[i]==0:
pass
elif i%2==a and A[i]==2:
pass
else:
print(0);exit()
else:
for i in range(N):
if i==0 and A[i]==1:
continue
if i%2==0 and A[i]==2:
pass
elif i%2==1 and A[i]==0:
pass
else:
print(0);exit()
print(pow(2,N//2,10**9+7 )) |
s543670604 | p03848 | u919025034 | 1592872338 | Python | PyPy3 (7.3.0) | py | Runtime Error | 113 | 94796 | 467 | import collections
N=int(input())
A=collections.Counter(list(map(int,input().split())))
if N%2==0:
for i in range(0,N,2):
if i%2==0 and A[i]==0:
pass
elif i%2==a and A[i]==2:
pass
else:
print(0);exit()
print(2**(N//2))
else:
for i in range(N):
if i==0:
if A[i]!=1:
print(0);exit()
elif i%2==0 and A[i]==2:
pass
elif i%2==1 and A[i]==0:
pass
else:
print(0);exit()
print(2**(N//2)) |
s884405394 | p03848 | u212328220 | 1592518397 | Python | Python (3.8.2) | py | Runtime Error | 96 | 24984 | 506 | from collections import Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
print(c_al)
mod = int(10**9 + 7)
if n % 2 == 0:
for k,v in c_al.items():
if v != 2:
print(0)
exit()
print((2 ** (n / 2)) % mod)
elif n % 2 != 0:
for k, v in c_al.items():
if k == 0:
if v != 1:
print(0)
exit()
elif v != 2:
print(0)
exit()
print((2 ** (n // 2)) % mod) |
s533600342 | p03848 | u212328220 | 1592517240 | Python | Python (3.8.2) | py | Runtime Error | 65 | 20580 | 499 | from collections import Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
mod = 10**9 + 7
if n % 2 == 0:
for k,v in c_al.items():
if v != 2:
print(0)
exit()
print(int((2 ** (n / 2)) % mod))
elif n % 2 != 0:
for k, v in c_al.items():
if k == 0:
if v != 1:
print(0)
exit()
elif v != 2:
print(0)
exit()
print(int((2 ** (n // 2)) % mod)) |
s341452382 | p03848 | u212328220 | 1592514267 | Python | Python (3.8.2) | py | Runtime Error | 62 | 20724 | 307 | from collections import defaultdict, Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
mod = 10**9 + 7
if n % 2 == 0 and 0 not in c_al.values():
print(int((2 ** (n / 2)) % mod))
elif n % 2 != 0 and c_al[0] == 1:
print(int((2 ** (n // 2)) % mod))
else:
print(0)
|
s646352357 | p03848 | u212328220 | 1592514197 | Python | Python (3.4.3) | py | Runtime Error | 57 | 14820 | 297 | from collections import defaultdict, Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
mod = 10**9 + 7
if n % 2 == 0 and 0 not in c_al.values():
print((2 ** (n / 2)) % mod)
elif n % 2 != 0 and c_al[0] == 1:
print((2 ** (n // 2)) % mod)
else:
print(0)
|
s951331228 | p03848 | u212328220 | 1592513968 | Python | Python (3.4.3) | py | Runtime Error | 57 | 14820 | 297 | from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
if n % 2 == 0 and 0 not in c_al.values():
print(int(2**(n/2))%((10**9) + 7))
elif n % 2 != 0 and c_al[0] == 1:
print(int(2 ** (n // 2))%((10**9) + 7))
else:
print(0) |
s139494480 | p03848 | u212328220 | 1592513936 | Python | Python (3.4.3) | py | Runtime Error | 57 | 14820 | 293 | from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
if n % 2 == 0 and 0 not in c_al.values():
print(int(2**(n/2))%(10**9) + 7)
elif n % 2 != 0 and c_al[0] == 1:
print(int(2 ** (n // 2))%(10**9) + 7)
else:
print(0) |
s769559851 | p03848 | u212328220 | 1592513842 | Python | Python (3.4.3) | py | Runtime Error | 56 | 14820 | 269 | from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
if n % 2 == 0 and 0 not in c_al.values():
print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
print(int(2 ** (n // 2)))
else:
print(0) |
s905619018 | p03848 | u212328220 | 1592513706 | Python | Python (3.4.3) | py | Runtime Error | 56 | 14820 | 271 | from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
if n % 2 == 0 and 0 not in c_al.values():
print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
print(int(2 ** ((n // 2))))
else:
print(0) |
s563087168 | p03848 | u212328220 | 1592513647 | Python | Python (3.4.3) | py | Runtime Error | 56 | 14812 | 252 | from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))
c_al = Counter(al)
if n % 2 == 0 and 0 not in c_al.values():
print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
print(int(2 ** ((n // 2)))) |
s581399910 | p03848 | u212328220 | 1592449514 | Python | Python (3.4.3) | py | Runtime Error | 178 | 14196 | 1242 | from collections import Counter, defaultdict, deque
n = int(input())
# n,a,b = map(int,input().split())
# al = list(map(int,input().split()))
al = list(map(int, input().split()))
if n == 1 and al[0] == 0:
print(1)
elif n == 2:
if 0 not in al:
print(2)
else:
print(0)
if n % 2 == 0:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
# print(n-x-1,x)
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
# print(lst)
if 0 not in lst:
print(int(2 ** (n / 2)) % ((10 ** 9) + 7))
else:
print(0)
else:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
# print(n - x - 1, x)
if x == y:
lst[int(x)] += 1
else:
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
# print(lst)
if 0 not in lst:
print(int(2 ** ((n - 1) / 2)) % ((10 ** 9) + 7))
else:
print(0)
|
s452148508 | p03848 | u212328220 | 1592448304 | Python | Python (3.4.3) | py | Runtime Error | 184 | 14196 | 1172 | from collections import Counter, defaultdict, deque
n = int(input())
# n,a,b = map(int,input().split())
# al = list(map(int,input().split()))
al = list(map(int, input().split()))
if n == 1 and al[0] == 0:
print(1)
elif n == 2:
if 0 not in al:
print(2)
else:
print(0)
if n % 2 == 0:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
# print(n-x-1,x)
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
# print(lst)
if 0 not in lst:
print(int(2 ** (n / 2)) % ((10 ** 9) + 7))
else:
print(0)
else:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
# print(n - x - 1, x)
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
# print(lst)
if 0 not in lst:
print(int(2 ** ((n - 1) / 2)) % ((10 ** 9) + 7))
else:
print(0)
|
s151567389 | p03848 | u212328220 | 1592447954 | Python | Python (3.4.3) | py | Runtime Error | 183 | 14196 | 1054 | from collections import Counter, defaultdict, deque
n = int(input())
# n,a,b = map(int,input().split())
# al = list(map(int,input().split()))
al = list(map(int, input().split()))
if n % 2 == 0:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
# print(n-x-1,x)
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
# print(lst)
if 0 not in lst:
print(int(2 ** (n / 2)) % ((10 ** 9) + 7))
else:
print(0)
else:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
# print(n - x - 1, x)
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
# print(lst)
if 0 not in lst:
print(int(2 ** ((n - 1) / 2)) % ((10 ** 9) + 7))
else:
print(0)
|
s750980237 | p03848 | u212328220 | 1592447765 | Python | Python (3.4.3) | py | Runtime Error | 194 | 14196 | 1011 | from collections import Counter, defaultdict, deque
n = int(input())
#n,a,b = map(int,input().split())
# al = list(map(int,input().split()))
al = list(map(int,input().split()))
if n % 2 == 0:
lst = [0]*n
for i in range(1,n):
x = (al[i-1]+n-1)/2
y = x -al[i-1]
#print(x,y)
#print(n-x-1,x)
lst[int(n-x-1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
#print(lst)
if not 0 in lst:
print(int(2**(n/2))%((10**9)+7))
else:
print(0)
else:
lst = [0] * n
for i in range(1, n):
x = (al[i - 1] + n - 1) / 2
y = x - al[i - 1]
# print(x,y)
#print(n - x - 1, x)
lst[int(n - x - 1)] += 1
lst[int(x)] += 1
if (lst[int(n - x - 1)] or lst[int(x)]) >= 3:
print(0)
exit()
#print(lst)
if not 0 in lst:
print(int(2 ** ((n-1) / 2))%((10**9)+7))
else:
print(0)
|
s267123474 | p03848 | u674343825 | 1592355676 | Python | Python (3.4.3) | py | Runtime Error | 66 | 14008 | 436 | n = int(input())
a = list(map(int,input().split()))
count = [0]*n
for i in a:
count[i] += 1
ans = 0
if n%2 == 0:
if all(count[2*f]==0 for f in range(n//2)) and all(count[2*k-1]==2 for k in range(1,n//2)):
ans = (2**(n//2)) % (1e+9 + 7)
else:
if count[0] == 1 and all(count[2*f]==2 for f in range(1,n//2)) and all(count[2*k-1]==0 for k in range(1,n//2)):
ans = (2**(n//2)) % (1e+9 + 7)
print(int(ans)) |
s088981727 | p03848 | u860002137 | 1591154849 | Python | Python (3.4.3) | py | Runtime Error | 64 | 14820 | 408 | import sys
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
if arr.count(0) > 1:
print(0)
sys.exit()
if len(arr) % 2 == 0 and arr.count(0) > 0:
print(0)
sys.exit()
cnt = Counter(arr)
li = list(cnt.values())
if li.count(2) != n // 2:
print(0)
sys.exit()
if not all([x <= 2 for x in li]):
print(0)
sys.exit(0)
print(reduce(mul, li)) |
s692610192 | p03848 | u979552932 | 1588453050 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 516 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
h[x] += 1
f = True
for k, v in h..most_common():
if n % 2 == 1 and k == 0:
if v != 1:
f = False
break
elif v != 2:
f = False
break
MOD = 1000000007
def mpow(n, p, mod):
r = 1
while p > 0:
if p & 1 == 1:
r = r * n % mod
n = n * n % mod
p >>= 1
return r
print(mpow(2, int(n / 2), MOD) if f else 0) |
s799796173 | p03848 | u979552932 | 1588452916 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 512 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
h[x] += 1
f = True
for k, v in h.items():
if n % 2 == 1 and k == 0:
if v != 1:
f = False
break
elif v != 2:
f = False
break
MOD = 1_000_000_007
def mpow(n, p, mod):
r = 1
while p > 0:
if p & 1 == 1:
r = r * n % mod
n = n * n % mod
p >>= 1
return r
print(mpow(2, int(n / 2), MOD) if f else 0) |
s928380912 | p03848 | u979552932 | 1588452848 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 518 | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
h[x] += 1
f = True
for k, v in h.most_common():
if n % 2 == 1 and k == 0:
if v != 1:
f = False
break
elif v != 2:
f = False
break
MOD = 1_000_000_007
def mpow(n, p, mod):
r = 1
while p > 0:
if p & 1 == 1:
r = r * n % mod
n = n * n % mod
p >>= 1
return r
print(mpow(2, int(n / 2), MOD) if f else 0) |
s902229737 | p03848 | u979552932 | 1588452648 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 512 | from collections import Counter
n = int(input())
a = map(int, input().split())
h = Counter()
for x in a:
h[x] += 1
f = True
for k, v in h.most_common():
if n % 2 == 1 and k == 0:
if v != 1:
f = False
break
elif v != 2:
f = False
break
MOD = 1_000_000_007
def mpow(n, p, mod):
r = 1
while p > 0:
if p & 1 == 1:
r = r * n % mod
n = n * n % mod
p >>= 1
return r
print(mpow(2, int(n / 2), MOD) if f else 0) |
s167648925 | p03848 | u169138653 | 1586035965 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 510 | n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
d=dict()
for i in range(n):
if a[i] not in d:
d[a[i]]=1
else:
d[a[i]]+=1
d=sorted(list(d.items()))
if n%2:
for i in range(len(d)):
if i==0:
if d[i][0]!=0 or d[i][1]!=1:
print(0)
exit()
else:
if d[i][0]!=i*2 or d[i][1]!=2:
print(0)
exit()
print(pow(2,len(d)-1,mod)
else:
for i in range(len(d)):
if d[i][0]!=2*i+1 or d[i][1]!=2:
print(0)
exit()
print(2,len(d),mod) |
s564101422 | p03848 | u202570162 | 1585941778 | Python | Python (3.4.3) | py | Runtime Error | 85 | 14692 | 658 | #ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
ans=0
flag=True
if N%2==0:
for k in range(1,N,2):
cnt[k]=0
for a in A:
cnt[a]+=1
for k in range(1,N,2):
if cnt[k]!=2:
flag=False
break
if flag: ans=pow(2,N//2,const)
else:
for k in range(0,N,2):
cnt[k]=0
for a in A:
cnt[a]+=1
for k in range(0,N,2):
if k==0:
if cnt[0]!=1:
flag=False
break
else:
if cnt[k]!=2:
flag=False
break
if flag: ans=pow(2,(N-1)//2,const)
print(ans)
|
s006871332 | p03848 | u202570162 | 1585941489 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14692 | 549 | #ARC066-C
N=int(input())
A=[int(i) for i in input().split()]
const=10**9+7
cnt={}
if N%2==0:
for k in range(1,N,2):
cnt[k]=0
for a in A:
cnt[a]+=1
for k in range(1,N,2):
if cnt[k]!=2:
print(0)
exit()
print(pow(2,N//2,const))
else:
for k in range(0,N,2):
cnt[k]=0
for a in A:
cnt[a]+=1
if cnt[0]!=1:
print(0)
exit()
for k in range(2,N,2):
if cnt[k]!=2:
print(0)
exit()
print(pow(2,(N-1)//2,const))
|
s074685992 | p03848 | u832152513 | 1583469872 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38512 | 220 | n = int(input())
a = sorted(list(map(int, input().split())))
x = n%2 + 1
for i in range(n)[n%2+2::2]:
if a[i] != a[i+1] or a[i] - x != 2:
print(0)
exit()
x = a[i]
print(2**(n//2) % (10**9+7) |
s035654106 | p03848 | u305366205 | 1582383872 | Python | Python (3.4.3) | py | Runtime Error | 78 | 13880 | 411 | n = int(input())
a = sorted(list(map(int, input().split())))
if n % 2 == 1:
for i in range(0, n, 2):
if i == 0 and a[i] != 0:
print(0)
exit()
elif a[i] != a[i + 1] or a[i] != 2 * i:
print(0)
exit()
else:
for i in range(0, n, 2):
if a[i] != a[i + 1] or a[i] != 2 * i + 1:
print(0)
exit()
print(2 ** (n // 2)) |
s692676437 | p03848 | u527993431 | 1582378187 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 273 | N=int(input())
A=list(map(int,input().split()))
if N%2==0:
for i in range (N):
A[i]%2!=1:
print(0)
exit()
print((2**N)%(10**9+7))
else:
for i in range (N):
A[i]%2!=0:
print(0)
exit()
if min(A)!=0:
print(0)
exit()
else:
print((2**(N-1))%(10**9+7)) |
s416939892 | p03848 | u459419927 | 1576364069 | Python | Python (3.4.3) | py | Runtime Error | 212 | 23392 | 403 | import numpy as np
import collections
while(1):
N=int(input())
A = np.array(list(map(int, input().split())))
if np.count_nonzero(A ==0)>=2:
print("0")
break
dict=collections.Counter(A)
key = [k for k, v in dict.items() if int(v) <= 2]
if len(key)==0:
print("0")
break
else:
ans=2**len(key)
ans =ans%(10**9+7)
print(ans) |
s438207495 | p03848 | u948524308 | 1576173284 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 327 | N,M=map(int,input().split())
mod=10**9+7
a=[]
for i in range(M):
a.append(int(input()))
DP=[1]*(N+1)
if 1 in a:
DP[1]=0
for i in range(2,N+1):
if i in a:
DP[i]=0
if DP[i-1]==0:
print(0)
exit()
else:
DP[i]=DP[i-1]+DP[i-2]
DP[i]=DP[i]%mod
print(DP[N])
|
s459730730 | p03848 | u708255304 | 1575681318 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2696 | 677 | from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0: # 奇数の場合
count = Counter(A)
now_key = 2
for k, v in count.items():
if k == 0:
if v != 1:
print(0)
exit()
else:
if k != now_key or v != 2:
print(0)
exit()
now_key += 2
print(2**(N//2) % mod)
else: # 偶数の場合
count = Counter(A)
now_key = 1
for k, v in count.items():
if k != now_key or v != 2:
print(0)
exit()
now_key += 2
print(2**(N//2) % mod)
|
s174926434 | p03848 | u413165887 | 1570142621 | Python | Python (3.4.3) | py | Runtime Error | 104 | 14008 | 917 | import sys
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
if n%2 == 0:
for i in range(n-1):
if i%2 == 0:
if a[i] == a[i+1]:
continue
else:
print(0)
sys.exit()
else:
if a[i]+2 == a[i+1]:
continue
else:
print(0)
sys.exit()
print((2 ** (n//2)) % (10**9+7))
else:
if a[0] == 0:
for i in range(1, n-1):
if i%2 == 1:
if a[i] == a[i+1]:
continue
else:
print(0)
sys.exit()
else:
if a[i]+2 == a[i+1]:
continue
else:
print(0)
sys.exit()
print(2**((n-1)/2)%(10**9+7))
else:
print(0)
sys.exit() |
s478124330 | p03848 | u413165887 | 1570142444 | Python | Python (3.4.3) | py | Runtime Error | 102 | 14008 | 924 | import sys
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
if n%2 == 0:
for i in range(n-1):
if i%2 == 0:
if a[i] == a[i+1]:
continue
else:
print(0)
sys.exit()
else:
if a[i]+2 == a[i+1]:
continue
else:
print(0)
sys.exit()
print(int(2**(n/2)%(10**9+7)))
else:
if a[0] == 0:
for i in range(1, n-1):
if i%2 == 1:
if a[i] == a[i+1]:
continue
else:
print(0)
sys.exit()
else:
if a[i]+2 == a[i+1]:
continue
else:
print(0)
sys.exit()
print(int(2**((n-1)/2)%(10**9+7)))
else:
print(0)
sys.exit() |
s172764712 | p03848 | u413165887 | 1570142274 | Python | Python (3.4.3) | py | Runtime Error | 105 | 14008 | 904 | import sys
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
if n%2 == 0:
for i in range(n-1):
if i%2 == 0:
if a[i] == a[i+1]:
continue
else:
print(0)
sys.exit()
else:
if a[i]+2 == a[i+1]:
continue
else:
print(0)
sys.exit()
print(int(2**(n/2)))
else:
if a[0] == 0:
for i in range(1, n-1):
if i%2 == 1:
if a[i] == a[i+1]:
continue
else:
print(0)
sys.exit()
else:
if a[i]+2 == a[i+1]:
continue
else:
print(0)
sys.exit()
print(int(2**((n-1)/2)))
else:
print(0)
sys.exit() |
s998077076 | p03848 | u413165887 | 1570110189 | Python | Python (3.4.3) | py | Runtime Error | 128 | 13812 | 817 | import sys
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
a.append(-1)
counter = 0
b = []
for i in range(n+1):
if a[counter] == a[i]:
continue
else:
b.append([a[counter], i-counter])
counter = i
odd = 0
if n%2 == 1:
if b[0][0] == 0 and b[0][1] == 1:
b[0][1] += 1
n += 1
odd = 1
else:
print(0)
sys.exit()
if odd:
for i in range(int(n//2)):
if b[i][0] == i*2 and b[i][1] == 2:
continue
else:
print(0)
sys.exit()
else:
for i in range(int(n//2)):
if b[i][0] == i*2+1 and b[i][1] == 2:
continue
else:
print(0)
sys.exit()
if odd:
print(int(2**(n/2 -1)%(10**9 + 7)))
else:
print(int(2**(n/2)%(10**9 + 7))) |
s134550029 | p03848 | u413165887 | 1570109805 | Python | Python (3.4.3) | py | Runtime Error | 128 | 14008 | 793 | import sys
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
a.append(-1)
counter = 0
b = []
for i in range(n+1):
if a[counter] == a[i]:
continue
else:
b.append([a[counter], i-counter])
counter = i
odd = 0
if n%2 == 1:
if b[0][0] == 0 and b[0][1] == 1:
b[0][1] += 1
n += 1
odd = 1
else:
print(0)
sys.exit()
if odd:
for i in range(int(n//2)):
if b[i][0] == i*2 and b[i][1] == 2:
continue
else:
print(0)
sys.exit()
else:
for i in range(int(n//2)):
if b[i][0] == i*2+1 and b[i][1] == 2:
continue
else:
print(0)
sys.exit()
if odd:
print(int(2**(n/2 -1)))
else:
print(int(2**(n/2))) |
s606768624 | p03848 | u948524308 | 1569518987 | Python | Python (3.4.3) | py | Runtime Error | 67 | 14820 | 480 | import collections
N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7
A=collections.Counter(A_data)
if N%2==1:
if not A[0]==1:
ans=0
else:
for i in range(2,N,2):
if not A[i]==2:
ans=0
break
if ans!=0:
ans=2**((N-1)//2)%mod
elif N%2==0:
for i in range(1,N,2):
if not A[i]==2:
ans=0
break
if ans!=0:
ans=2**(N//2)%mod
print(ans) |
s109995089 | p03848 | u378328623 | 1569042873 | Python | Python (3.4.3) | py | Runtime Error | 217 | 23472 | 421 | import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
flag = True
else:
print(0)
else:
if np.all(L-np.arange(N)-np.array([1,0]*(N/2))==0):
flag = True
else:
print(0)
if flag:
a=1
for i in range(N//2):
a = (a*2)%(10**9+7)
print(a) |
s326923746 | p03848 | u378328623 | 1569042839 | Python | Python (3.4.3) | py | Runtime Error | 219 | 23444 | 413 | import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
flag = True
else:
print(0)
else:
if np.all(L-np.arange(N)-np.array([1,0]*(N/2))==0):
flag = True
else:print(0)
if flag:
a=1
for i in range(N//2):
a = (a*2)%(10**9+7)
print(a) |
s496167825 | p03848 | u378328623 | 1569042776 | Python | Python (3.4.3) | py | Runtime Error | 217 | 23444 | 413 | import numpy as np
N = int(input())
l = list(map(int, input().split()))
l.sort()
L = np.array(l)
flag = False
if N%2==1:
if np.all(L-np.arange(N)-np.array([0]+[1,0]*(N//2))==0):
flag = True
else:
print(0)
else:
if np.all(L-np.arange(N)+np.array([1,0]*(N/2))==0):
flag = True
else:print(0)
if flag:
a=1
for i in range(N//2):
a = (a*2)%(10**9+7)
print(a) |
s367773034 | p03848 | u010090035 | 1566439231 | Python | Python (3.4.3) | py | Runtime Error | 102 | 14008 | 540 | import sys
MOD = 1000000007
N = int(input())
a = list(map(int,input().split()))
if(N%2 == 0):
a.sort()
for i in range(N//2):
n = 2*i + 1
if(a[2*i] != n or a[2*i + 1] != n):
print(0)
sys.exit()
print((2 ** (N//2)) % MOD)
else:
a.sort()
if(a[0] != 0 or a[1] == 0 ):
print(0)
sys.exit()
for i in range((N-1)//2):
n = 2*i + 2
if(a[2*i + 1] != n or a[2*i + 2] != n):
print(0)
sys.exit()
print((2 ** ((N-1)//2)) % MOD)
|
s777034264 | p03848 | u623349537 | 1565578648 | Python | Python (3.4.3) | py | Runtime Error | 57 | 14436 | 679 | N = int(input())
A = list(map(int, input().split()))
def is_valid(A):
counts = {}
for a in A:
if a in counts:
counts[a] += 1
else:
counts[a] = 1
if len(A) % 2 == 1:
if counts[0] != 1:
return False
for i in range(1, len(A) // 2 + 1):
if 2 * i not in counts or counts[2 * i] != 2:
return False
return True
else:
for i in range(1, len(A) // 2 + 1):
if 2 * i not in counts or counts[2 * i - 1] != 2:
return False
return True
return True
if is_valid(A):
print(2 ** (N // 2))
else:
print(0) |
s440913214 | p03848 | u623349537 | 1565578528 | Python | Python (3.4.3) | py | Runtime Error | 68 | 14436 | 633 | N = int(input())
A = list(map(int, input().split()))
def is_valid(A):
counts = {}
for a in A:
if a in counts:
counts[a] += 1
else:
counts[a] = 1
if len(A) % 2 == 1:
if counts[0] != 1:
return False
for i in range(1, len(A) // 2 + 1):
if counts[2 * i] != 2:
return False
return True
else:
for i in range(1, len(A) // 2 + 1):
if counts[2 * i - 1] != 2:
return False
return True
return True
if is_valid(A):
print(2 ** (N // 2))
else:
print(0) |
s788164991 | p03848 | u923712635 | 1561564962 | Python | PyPy3 (2.4.0) | py | Runtime Error | 234 | 55788 | 502 | N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
if(N==1):
if(A[0]==0):
print(1)
else:
print(0)
else:
for i in A:
if(i not in di):
di[i]=1
else:
di[i]+=1
for i in range(N//2):
if(i+c==0):
flag &= (di[i]==1)
else:
flag &= (di[i*2+c]==2)
if(not flag):
print(0)
break
else:
print((2<<(N//2-1))%mod)
|
s584682112 | p03848 | u923712635 | 1561564881 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38256 | 525 | N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
if(N==1):
if(A[0]==0):
print(1)
else:
print(0)
else:
for i in A:
if(i not in di):
di[i]=1
else:
di[i]+=1
for i in range(N//2):
if(i+c==0):
flag &= (di[i]==1)
else:
flag &= (di[i*2+c]==2)
if(not flag):
else:
print(0)
break
else:
print((2<<(N//2-1))%mod)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.