Harryxun/stf_run huggingface dataset:
import sys
import numpy as np
 
n = int(input())
lst = [int(i) for i in sys.stdin.readline().split()]
mod = 10 ** 9 + 7
c = []

for i in range(60):
    c1 = sum(lst & 1)
    c.append(c1 * (n - c1))
    lst >>= 1
print(sum([v * 2 ** i for i, v in enumerate(c)]) % mod)

### FIXED CODE ###

import sys
import numpy as np
 
n = int(input())
lst = [int(i) for i in sys.stdin.readline().split()]
arr = np.array(lst, np.int64)

mod = 10 ** 9 + 7
x_sum = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    x_sum += (c1 * (n - c1) * 2 ** i)
    x_sum %= mod
    arr >>= 1
print(x_sum)
w, h, x, y = map(int, input().split())

min_wh = w*h/2
a = 0
if w%x==0 and h%y==0:
    a = 1
print(min_wh, a)

### FIXED CODE ###

w, h, x, y = map(int, input().split())


if x in [0, w] or y in [0, h]:
    print(w * h/2, 0)
else:
    if x * 2 == w and y * 2 == h:
        print(w * h / 2, 1)
    else:
        print(w * h/2, 0)
a, b = (int(i) for i in input().split()) 

list=[]
 
for i in range(a):
    list.append(int(input()))

new_list = sorted(list)

sabun = None

for i in range(len(new_list)-1):

    if i+b == len(new_list):
        break

    bbb = new_list[i+b-1] - new_list[i]

    if sabun == None:
        sabun = bbb
        continue

    if sabun > bbb:
        sabun = bbb
    
print(sabun)

### FIXED CODE ###

n = int(input())

if n == 25:
    print("Christmas")

if n == 24:
    print("Christmas Eve")

if n == 23:
    print("Christmas Eve Eve")

if n == 22:
    print("Christmas Eve Eve Eve")
import numpy as np
N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(N):
 ans.append(abs(X- x[i]))
print(np.gcd.reduce(ans))

### FIXED CODE ###

import math
import fractions
from functools import reduce
N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = []
for i in range(N):
 ans.append(abs(X- x[i]))
ans = tuple(ans)

print(reduce(fractions.gcd, ans))
n, m = input()
A = []
b = []
   
for i in range(0, n):
   A += [map(int, raw_input().split())]
 
for j in range(0, m):
   b += [input()]
    
for i in range(0, n):
   c = 0
   for j in range(0, m):
      c += A[i][j] * b[j]
   print c

### FIXED CODE ###

n, m = map(int, raw_input().split())
A = []
b = []
    
for i in range(0, n):
   A += [map(int, raw_input().split())]
  
for j in range(0, m):
   b += [input()]
     
for i in range(0, n):
   c = 0
   for j in range(0, m):
      c += A[i][j] * b[j]
   print c
#ABC102C
N=int(input())
A=list(map(int, input().split()))
B=[0]*N
b=0
ans=0
for i in range(N):
    B[i]=A[i]-(i+1)
B_sorted=sorted(B)
if N%2==0:
    b=(B_sorted[N/2]+B_sorted[N/2-1])//2
else:
    b=(B_sorted[N//2])
for i in range(N):
    ans+=abs(A[i]-(b+i+1))
print(int(ans))


### FIXED CODE ###

#ABC102C
N=int(input())
A=list(map(int, input().split()))
B=[0]*N
b=0
ans=0
for i in range(N):
    B[i]=A[i]-(i+1)
B_sorted=sorted(B)
if N%2==0:
    b=(B_sorted[int(N/2)]+B_sorted[int(N/2-1)])//2
else:
    b=(B_sorted[N//2])
for i in range(N):
    ans+=abs(A[i]-(b+i+1))
print(int(ans))
while True:
    n=int(input())
    if n==0:break
    b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
    mem=[[1145141919 for i in range(n)]for j in range(2)]
    que=[[0,0,0],[1,0,0]]
    count=1145141919
    while len(que)!=0:
        d=que.pop(0)
        state=b[d[0]][d[1]]
        if state!=2 and d[1]==n-1 and d[2]<count:
            count=d[2]
        mem[d[0]][d[1]]=d[2]
        case=-1
        if state==0:case=0
        elif state==1:
            if b[d[0]][d[1]+1]==1:case=1
            else:case=0
        elif state==2:case=2

        if case==0:
            for i in range(3):
                if d[1]+i>=n:break
                if d[0]==0 and mem[1][d[1]+i]>d[2]+1:que.append([1,d[1]+i,d[2]+1])
                elif d[0]==1 and mem[0][d[1]+i]>d[2]+1:que.append([0,d[1]+i,d[2]+1])
        elif case==1:
            if mem[d[0]][d[1]+1]>d[2]:que.append([d[0],d[1]+1,d[2]])
        elif case==2:
            if mem[d[0]][d[1]-1]>d[2]:que.append([d[0],d[1]-1,d[2]])
    print(str(count)if count!=1145141919 else "NA")

### FIXED CODE ###

def bfs(b):
    mem=[[False for i in range(n)]for j in range(2)]
    st=[0,0]
    for i in range(2):
        if b[i][0]!=1:continue
        while st[i]<n-1 and b[i][st[i]+1]==1:
            st[i]+=1
        if st[i]==n-1:return 0
    mem[0][st[0]]=True
    mem[1][st[1]]=True
    que=[[0,st[0],0],[1,st[1],0]]
    while len(que)!=0:
        d=que.pop(0)
        des=(d[0]+1)%2
        cst=d[2]+1
        for i in range(3):
            fl=d[1]+i
            if fl>=n:break
            state=b[des][fl]
            if state!=2 and fl==n-1:
                return cst
            if state==0:
                if mem[des][fl]==False:
                    que.append([des,fl,cst])
                    mem[des][fl]=True
            elif state==1:
                k=1
                while True:
                    if fl+k>=n:return cst
                    if b[des][fl+k]!=1:
                        if mem[des][fl+k-1]==False:
                            que.append([des,fl+k-1,cst])
                            mem[des][fl+k-1]=True
                        break
                    else: k+=1

            elif state==2:
                k=1
                while True:
                    if b[des][fl-k]!=2:
                        if mem[des][fl-k]==False:
                            que.append([des,fl-k,cst])
                            mem[des][fl-k]=True
                        break
                    else:k+=1  
    return -1
while True:
    n=int(input())
    if n==0:break
    b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
    count=bfs(b)
    print(str(count)if count>=0 else "NA")
N = int(input())
h = list(map(int,input().split()))

lmin = [] #極小値のリスト
lmax = [] #極大値のリスト

for i in range(i,N-1):
    if (h[i] >= h[i-1]) and (h[i] > h[i+1]):
        lmax.append(h[i])
    
for k in range(i,N-1):
    if (h[i] <= h[i-1]) and (h[i] < h[i+1]):
        lmin.append(h[i])

ans = sum(lmax) - sum(lmin)

print(ans)


### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
if max(h) == min(h):
    ans = h[0]

else:
    same = []
    for i in range(N-1):
        if h[i] == h[i+1]:
            same.append(i)
    
    if len(same) >= 1:
        for k in range (len(same))[::-1]:
            del h[same[k]]
    
    N = len(h)

    lmin = [] #極小値のリスト
    lmax = [] #極大値のリスト

    if N >=3:
        for i in range(1,N-1):
            if (h[i] > h[i-1]) and (h[i] > h[i+1]):
                lmax.append(h[i])
        
        for k in range(1,N-1):
            if (h[k] < h[k-1]) and (h[k] < h[k+1]):
                lmin.append(h[k])

        if h[0] > h[1]:
            lmax.append(h[0])
            
        if h[N-1] > h[N -2]:
            lmax.append(h[N-1])
                
        if (len(lmax) == 1) :
            ans = max(h)

        else:
            ans = sum(lmax) - sum(lmin)
    
    if N == 2:
        ans = max(h)

    if N == 1:
        ans = h[0]

#print(lmax)
#print(lmin)
print(ans)
import copy

def main():
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)

    def lcm(a, b):
        return int(a / gcd(a, b)) * b

    n, m = map(int, input().split())
    # これだと72がREになる
    A = set([int(x) for x in input().split()])
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    A_ = copy.deepcopy(A)
    a_lcm = A.pop()
    # Aの要素が複数ならlcmを計算する
    if len(A) >= 1:
        for a in A:
            a_lcm = lcm(a_lcm, a)
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    for i in A_:
        if (a_lcm / 2) % i != 0:
            continue
        else:
            print(0)
            exit()
    # mがlcmの半分よりも小さかったら0
    if a_lcm / 2 > m:
        print(0)
    else:
        # あとは定数倍の数調べて終わり
        ans = int((m - (a_lcm / 2))) // a_lcm + 1
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
# from math import gcd


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
n = int(input())
x = input()
cnt1 = x.count('1')
x10 = int(x,2)

if cnt1 > 1:
  x10mod_m = x10 % (cnt1-1)
  x10mod_p = x10 % (cnt1+1)
else:
  x10mod_m = 0
  x10mod_p = 0

ans = []
for i in range(n):
  add_val = add_val >> 1
  if x[i] == '1':
    if cnt1 == 1:
      print(0)
      continue
    cntx = cnt1-1
    mod = ( x10mod_m - pow(1,n-1-i,cntx) ) % cntx
  else:
    cntx = cnt1+1
    mod = ( x10mod_p + pow(1,n-1-i,cntx) ) % cntx
    
  cnt = 1
  mod = format(mod, 'b')
  
  while True:
    if mod == '0':
      break
    mod = format( int(mod,2) % mod.count('1'), 'b')
    cnt += 1
  print(cnt)

### FIXED CODE ###

n = int(input())
x = input()
cnt1 = x.count('1')
x10 = int(x,2)

if cnt1 > 1:
  x10mod_m = x10 % (cnt1-1)
  x10mod_p = x10 % (cnt1+1)
else:
  x10mod_m = 0
  x10mod_p = 0

ans = []
for i in range(n):
  if x[i] == '1':
    if cnt1 == 1:
      print(0)
      continue
    cntx = cnt1-1
    mod = ( x10mod_m - pow(2,n-1-i,cntx) ) % cntx
  else:
    cntx = cnt1+1
    mod = ( x10mod_p + pow(2,n-1-i,cntx) ) % cntx
    
  cnt = 1
  mod = format(mod, 'b')
  
  while True:
    if mod == '0':
      break
    mod = format( int(mod,2) % mod.count('1'), 'b')
    cnt += 1
  print(cnt)
N = int(input())
print(a+a**2+a**3)

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
print(c_b)
print(c_r)

for k_b in c_b.keys():
    if c_r.has_key(k_b):
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
        else:
            if res < c_b[k_b]:
                res = c_b[k_b]

print(res)


### FIXED CODE ###

from collections import Counter

arr_b = []
N = int(input())
for i in range(N):
    arr_b.append(str(input()))
arr_r = []
N = int(input())
for i in range(N):
    arr_r.append(str(input()))

c_b = Counter(arr_b)
c_r = Counter(arr_r)

res = 0
for k_b in c_b.keys():
    if k_b in c_r :
        if res < c_b[k_b] - c_r[k_b]:
            res = c_b[k_b] - c_r[k_b]
    else:
        if res < c_b[k_b]:
            res = c_b[k_b]

print(res)
N,W = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  for j in range(W+1):
    if j < li[i][0]: continue
    
    dp[i+1][j] = max(dp[i+1][j], dp[i][j-li[i][0]] + li[i+1][1])
    
print(dp[-1][-1])

### FIXED CODE ###

import numpy as np

N,W = map(int,input().split())

item = [list(map(int,input().split())) for _ in range(N)]

val = np.zeros(W+1,dtype = int)

for i in range(N):
  item_weight = item[i][0]
  val[item_weight :] = np.maximum(val[item_weight :], val[:-item_weight] + item[i][1])
  
print(max(val))
X = int(input(7))
A = int(input(4))
 
if X < A:
 print(0)
else:
 print(10)

### FIXED CODE ###

X, A = map(int, input().split())
 
if X < A:
 print(0)
else:
 print(10)
import collections

N=int(input())
S=input()

lenR=S.count("R")
lenG=S.count("G")
lenB=S.count("B")

count=0
for i in range(N-2):
    for j in range(i,N-1):
        if 2*j-i>N:
            continue
        if (S[i] != S[j]) and (S[i]!=S[2*j-i]) and (S[j]!=S[2*j-i]):
                    count+=1
    
print(lenR*lenG*lenB-count)

### FIXED CODE ###

import collections

N=int(input())
S=input()

lenR=S.count("R")
lenG=S.count("G")
lenB=S.count("B")

count=0
for i in range(N-2):
    for j in range(i,N-1):
        k=2*j-i
        if k>=N:
            continue
        else:
            if (S[i] != S[j]) and (S[i]!=S[k]) and (S[j]!=S[k]):
                count+=1
    
print(lenR*lenG*lenB-count)
n = int(input())
li =list(input().split())
for i in range(n):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))

### FIXED CODE ###

n = int(input())
li =list(input())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)
a=input()
s=[(int(a[0])*10)+int(a[1]),(int(a[2])*10)+int(a[3])]

if s[1]==0: and s[0]>=13:
  print("NA")
elif s[0]>=13 and s[1]>=13:
  print("NA")
elif 1<=s[0]<=12 and 1<=s[1]<=12:
  print("AMBIGUOUS")
elif s[0]==0 or  s[0]>=13 and 1<=s[1]<=12:
  print("YYMM")
elif 1<=s[0]<=12 and s[1]==0 or s[1]>=13:
  print("MMYY")

### FIXED CODE ###

a=input()
s=[(int(a[0])*10)+int(a[1]),(int(a[2])*10)+int(a[3])]

if s[0]>=13 and s[1]==0:
  print("NA")
elif s[0]==0 and s[1]==0:
  print("NA")
elif s[0]>=13 and s[1]>=13:
  print("NA")
elif 1<=s[0]<=12 and 1<=s[1]<=12:
  print("AMBIGUOUS")
elif s[0]>=13 and 1<=s[1]<=12:  
  print("YYMM")
elif s[0]==0 and 1<=s[1]<=12:
  print("YYMM")
elif 1<=s[0]<=12 and s[1]==0:
  print("MMYY")
elif 1<=s[0]<=12 and s[1]>=13:
  print("MMYY")
line = input()
data = line.split()
 
height = int(data[0])
wei = int(data[1])
 
if height %2 ==0:
  if wei %2 ==0:
    print(int(height/2)*wei)
else:
  if wei %2 ==0:
    print(int(height/2)* wei + int(wei/2))
  else:
    print(wei* int(height/2) + int(wei/2)+1)
line = input()
data = line.split()

height = int(data[0])
wei = int(data[1])

if height %2 ==0:
  if wei %2 ==0:
    print(int(height/2)*wei)
  else:
    print(int(height/2)*wei)
else:
  if wei %2 ==0:
    print(int(height/2)* wei + int(wei/2))
  else:
    print(wei* int(height/2) + int(wei/2)+1)
提出情報

### FIXED CODE ###

line = input()
data = line.split()
 
height = int(data[0])
wei = int(data[1])

if height !=1 and wei !=1: 
  if height %2 ==0:
    if wei %2 ==0:
      print(int(wei/2)*height)
    else:
      print(int(wei/2)*height+int(height/2))
  else:
    if wei %2 ==0:
      print(int(height/2)* wei + int(wei/2))
    else:
      print(wei* int(height/2) + int(wei/2)+1)
else:
  print(1)
f = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n, m = map(int, input().split())
a = list(map(int, input().split()))

memo = [-1]*10100


def dp(i):
    # i本のマッチを使って作れる最大の整数
    if i < 0:
        return - 10 ** 100000
    if not (0 <= i and i < 10100):
        print(-1)
        exit()
    if memo[i] != -1:
        return memo[i]
    if i == 0:
        return 0
    ret = -10**100000
    for x in a:
        ret = max(ret, 10 * dp(i - f[x]) + x)
    memo[i] = ret
    return ret


print(dp(n))


### FIXED CODE ###

import resource
import sys
sys.setrecursionlimit(20000)
f = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
n, m = map(int, input().split())
a = list(map(int, input().split()))

memo = ["-1"] * 10100


def MAX(x, y):
    if y[0] != '#' and (x == "#" or len(x) < len(y) or (len(x) == len(y) and x < y)):
        return y
    else:
        return x


def dp(i):
    # i本のマッチを使って作れる最大の整数
    if i < 0:
        return "#"

    if memo[i] != "-1":
        return memo[i]

    if i == 0:
        return ""

    ret = "#"
    for x in a:
        ret = MAX(ret, dp(i - f[x]) + str(x))
    memo[i] = ret
    return ret


print(dp(n))
s = list(input())
K = int(input())
l = []
l2 = []
l3 = []
l4 = []

for i in range(len(s)):
    s[i] = str(ord(s[i])-ord("a")+11)

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        l.append(tmp)

for i in range(len(l)):
    while True:
        if len(l[i]) == len(s)*2: break
        l[i] += '0'

for i in l:
    is_multi = 0
    i = int(i)
    for j in l2:
        if i == j:
            is_multi = 1
    if is_multi == 0:
        l2.append(i)

l2.sort()

l2 = list(str(l2[K-1]))

tmp = ''
for i in range(len(l2)):
    if l2[i] != '0':
        tmp += l2[i]

l3 = list(tmp)
if len(l3) % 2 == 1:
    l3.append('0')

i = 0
while i < len(l3):
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    l4.append(tmp)
    i += 2

ans =''
for i in range(len(l4)):
    ans += l4[i]


print(ans)


### FIXED CODE ###

s = list(input())
K = int(input())

l =[]

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        if j > i + 4: break
        tmp += s[j]
        l.append(tmp)
l.sort()

l2 = []
for x in l:
    if len(l2) > 6:
        break
    if x not in l2:
        l2.append(x)


ans = l2[K - 1]

print(ans)
import sys

while 1:
  str = sys.stdin.readline().strip()
  if str=="0 0":
    break
  print(int(str.split(" ")).sort)

### FIXED CODE ###

import sys

while 1:
  a , b = sys.stdin.readline().split()
  if a == b == "0":
    break
  elif int(a) > int(b) :
    print(b,a)
  else :
    print(a,b)
n, k = map(int, input().split())
As = list(map(int, input().split()))


def change(arr):
  newAs = [0] * n
  for i, a in enumerate(arr):
    for t in range(max(i - a, 0), min(i + a + 1, n)):
      newAs[t] += 1
  return newAs


for temp in min(range(k),10**4)):
  As = change(As)
print(' '.join(map(str, As)))

### FIXED CODE ###

import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
for i in range(min(41, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join([str(A) for A in As]))
array = map(int,input().split())
array.sort()
if array[0] != array[2] and (array[0] == array[1] or array[1] == array[2]):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

array = list(map(int,input().split()))
array.sort()
if array[0] != array[2] and (array[0] == array[1] or array[1] == array[2]):
  print('Yes')
else:
  print('No')
import sys
sys.setrecursionlimit(2147483647)


n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

if ans%2==1:
    print(0)
    exit()

ans=ans//2

print((((m//ans)*(-1))//2)*(-1))





### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

cnt=1
while (a[0]%(2**cnt))==0:
    cnt+=1

cnt-=1
for item in a[1:]:
    if item%(2**cnt)!=0:
        print(0)
        exit()
    if (item//(2**cnt))%2==0:
        print(0)
        exit()


import fractions
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //fractions.gcd(ans, a[i])

if ans%2==1:
    print(0)
    exit()

if ans//2>m:
    print(0)
    exit()

ans=ans//2

print((((m//ans)*(-1))//2)*(-1))
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if i.count(a[i])>=2:
    res="NO"
print(res)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")
import math
a,b=map(int,input().split())
print((a*b)//math.gcd(a,b))

### FIXED CODE ###

import fractions
a,b=map(int,input().split())
print((a*b)//fractions.gcd(a,b))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

N = int(A[0])
K = int(A[1])

a = int(N-1)
b = 0
d = 0
for i in B:
  c = B[b]
  if K <= c:
    d = d+1
  b = b+1
print(d)

### FIXED CODE ###

N = input()

s = int(N)%2

if s == 0:
  print(0.5)
else:
  a = (int(N)+1)/(2*int(N))
  print(a)
N = int(input())
a_list = list(map(int, input().split()))
LARGE = 10**9 + 7

bins = [0] * 20

zeros = 0
v_dict = dict()
v_dict[0] = dict()
v_all_dict = dict()

for i in range(N):
    a = a_list[i]
    b = 0
    for k in range(20):
        r = (a // (2**k)) % 2
        bins[k] = (bins[k] + r) % 2
        b += bins[k]*(2**k)
    if b == 0:
        for v in v_dict[zeros].keys():
            if v not in v_all_dict.keys():
                v_all_dict[v] = [zeros, v_dict[zeros][v] % LARGE, 1]
            else:
                z, c1, c2 = v_all_dict[v]
                v_all_dict[v][2] = (v_all_dict[v][2] + v_all_dict[v][1] * (zeros - z)) % LARGE
                v_all_dict[v][1] = (v_all_dict[v][1] + v_all_dict[v][2] * v_dict[zeros][v]) % LARGE
        zeros += 1
        v_dict[zeros] = dict()
    else:
        if b in v_dict[zeros].keys():
            v_dict[zeros][b] += 1
        else:
            v_dict[zeros][b] = 1

if b == 0:
    res = 0
    for v in v_all_dict.keys():
        res += v_all_dict[v][1] + v_all_dict[v][2] - 1
    res += 1
else:
    z, c1, c2 = v_all_dict[b]
    res = (v_all_dict[b][2] + v_all_dict[b][1] * (zeros - z)) % LARGE
    
print(res)


### FIXED CODE ###

N = int(input())
a_list = list(map(int, input().split()))
LARGE = 10**9 + 7


# cumsum
b_list = [0] * N
b = 0

for i in range(N):
    a = a_list[i]
    b = a ^ b
    b_list[i] = b

v_all_dict = dict()
for b in b_list:
    v_all_dict[b] = [0, 0, 1]

zeros = 0



for i in range(N):

    b = b_list[i]

    t = v_all_dict[b][0]

    # new b
    if t < zeros:
        v_all_dict[b][2] = (v_all_dict[b][2] + v_all_dict[b][1] * (zeros - t)) % LARGE
        v_all_dict[b][0] = zeros

    # up
    v_all_dict[b][1] = (v_all_dict[b][1] + v_all_dict[b][2]) % LARGE

    # zeros
    if b == 0:
        zeros += 1

# res
if b_list[-1] == 0:
    res = 0
    for v in v_all_dict.keys():
        if v != 0:
            res = (res + v_all_dict[v][1]) % LARGE
        else:
            res = (res + 2 ** (zeros - 1) - 1) % LARGE
    res += 1

else:
    v = b_list[-1]
    res = v_all_dict[v][2]

print(res % LARGE)
import sys
input=lambda: sys.stdin.readline().rstrip()
A=input()
B=input()
C=input()

a,b,c=len(A),len(B),len(C)

def f(X,Y):
  XY=[True]*(10**4)
  x,y=len(X),len(Y)
  for i in range(5000-y+1,5000+x):
    ret=True
    if i<=5000:
      for j in range(min(x,y+i-5000)):
        if X[j]=="?" or Y[j-i+5000]=="?" or X[j]==Y[j-i+5000]:
          continue
        else:
          ret=False
    else:
      for j in range(min(y,x-i+5000)):
        if Y[j]=="?" or X[j+i-5000]=="?" or Y[j]==X[j+i-5000]:
          continue
        else:
          ret=False
    XY[i]=ret
  return XY
AB=f(A,B)
BC=f(B,C)
AC=f(A,C)
ans=a+b+c
for i in range(5000-b-c,5000+a+c):
  if AB[i]:
    for j in range(5000-b-c,5000+a+b):
      if -4000<=j-i<=4000:
        if AC[j] and BC[j-i+5000]:
          l=min(5000,i,j)
         r=max(i+b,j+c,5000+a)
          ans=min(ans,r-l)
      else:
        if AC[j]:
          l=min(5000,i,j)
          r=max(i+b,j+c,5000+a)
          ans=min(ans,r-l)
print(ans)


### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
A=input()
B=input()
C=input()

a,b,c=len(A),len(B),len(C)

def f(X,Y):
  XY=[True]*(10**4)
  x,y=len(X),len(Y)
  for i in range(5000-y+1,5000+x):
    ret=True
    if i<=5000:
      for j in range(min(x,y+i-5000)):
        if X[j]=="?" or Y[j-i+5000]=="?" or X[j]==Y[j-i+5000]:
          continue
        else:
          ret=False
    else:
      for j in range(min(y,x-i+5000)):
        if Y[j]=="?" or X[j+i-5000]=="?" or Y[j]==X[j+i-5000]:
          continue
        else:
          ret=False
    XY[i]=ret
  return XY
AB=f(A,B)
BC=f(B,C)
AC=f(A,C)
ans=a+b+c
for i in range(5000-b-c,5000+a+c):
  for j in range(5000-b-c,5000+a+b):
    if -4000<=j-i<=4000:
      if AB[i] and AC[j] and BC[j-i+5000]:
        l=min(5000,i,j)
        r=max(i+b,j+c,5000+a)
        ans=min(ans,r-l)
    else:
      if AB[i] and AC[j]:
        l=min(5000,i,j)
        r=max(i+b,j+c,5000+a)
        ans=min(ans,r-l)
print(ans)
S = input()
T = input()

if s + T[-1] == T: 
	print("Yes")
else:
	print("No")

### FIXED CODE ###

S = input(); T = input()

if S + T[-1] == T:
  print("Yes")
else:
  print("No")