Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def max_heapify(a, i):
    h = len(a)
    l = 2 * i + 1
    r = 2 * i + 2
    if l < h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r < h and a[r] > a[largest]:
        largest = r

    if largest != i:
        tmp = a[i]
        a[i] = a[largest]
        a[largest] = tmp
        max_heapify(a, largest)


def build_max_heap(a):
    h = len(a)
    for i in range(h // 2 - 1, -1, -1):
        max_heapify(a, i)


heap = []
while True:
    s = input().split()
    if s[0] == "end":
        break
    elif s[0] == "extract":
        build_max_heap(heap)
        print(heap[0])
        heap = heap[1:]
        build_max_heap(heap)
    elif s[0] == "insert":
        heap.append(int(s[1]))


### FIXED CODE ###

import sys


def extract_max(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H:
        v = A[i]
        rv = 0
        lv = 0
        r = (i + 1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]

        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x


def insert(a, n):
    i = len(a)
    a.append(n)
    while i > 0:
        p = int((i + 1) / 2) - 1
        v = a[i]
        pv = a[p]
        if pv < v:
            a[p] = v
            a[i] = pv
            i = p
        else:
            break


def main():
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    S = []
    for cmd in cmds:  # input()
        if cmd[0] == "i":
            insert(S, int(cmd[7:]))

        elif cmd == "extract":
            a = extract_max(S)
            print(a)

        elif cmd == "end":
            break


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000)
s=input().strip()
x,y=map(int,input().split())
sl=[len(i) for i in s.split('T')]
x0,y0=sl[0],0

answers={}
def search(xx,yy,k,isUD):
    if (xx,yy,k) in answers:
        return answers[(xx,yy,k)]
    if k == len(sl):
        ans=(xx,yy)==(x,y)
    else:
        lng=sl[k]
        # D or L
        llr=(lng if not isUD else 0)
        lud=(lng if isUD else 0)
        d_l = search(xx-llr,yy-lud,k+1, not isUD)
        u_r = search(xx+llr,yy+lud,k+1, not isUD)
        ans = d_l or u_r
    answers[(xx,yy,k)]=ans
    return ans
print('Yes' if search(x0,y0,1,True) else 'No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
s=input().strip()
x,y=map(int,input().split())
sl=[len(i) for i in s.split('T')]
x0,y0=sl[0],0
s_x = sl[::2]
s_y = sl[1::2]
s_y=[0]+s_y
dpx=[set() for i in s_x]
dpy=[set() for i in s_y]
dpx[0].add(s_x[0])
dpy[0].add(0)
for i,l in enumerate(s_x):
    if i==0:continue
    ll=dpx[i]
    for xx in dpx[i-1]:
        ll.add(xx-l)
        ll.add(xx+l)
for i,l in enumerate(s_y):
    if i==0:continue
    ll=dpy[i]
    for yy in dpy[i-1]:
        ll.add(yy-l)
        ll.add(yy+l)
print('Yes' if x in dpx[-1] and y in dpy[-1] else 'No')
### BUGGY CODE ###

s = input()
l = len(s)
prev = ''

while s != prev:
    prev = s
    s = s.replace('01', '')
    s = s.replace('10', '')

print(l - len(s))

### FIXED CODE ###

s = input()
c0 = 0
c1 = 0
for si in s:
    if si == '0':
        c0 += 1
    else:
        c1 += 1


print(2*min(c0,c1))
### BUGGY CODE ###

n=int(input())
a=list(map(int, input().split()))
f=1
for i in range(n):
  f*=a[i]
if f>1000000000000000000:
  f=-1
print(f)

### FIXED CODE ###

def solve():
    n=int(input())
    a=list(map(int,input().split()))
    f=1
    if 0 in a:
        f=0
    for i in a:
        f*=i
        if f>1000000000000000000:
            print(-1)
            return 
    print(f)
solve()
### BUGGY CODE ###

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

div=10**9+7
tmp=1
K=min(N,M)
diff=abs(N-M)
for i in range(K):
    tmp*=(i+1)%div
ans=max(0,(2-diff)*tmp*tmp*(1+K*diff))%div
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)
### BUGGY CODE ###

a=int(input())
s=[]
for i in range(1,int(0.5*a+1)):
  if a%i==0:
    s.append(i+a//i)
print(min(s)-2)

### FIXED CODE ###

n = int(input())
s=[]
a=0
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      a=n//i
      s.append(n//i+n//a)
print(min(s)-2)
### BUGGY CODE ###

s = list(input())
ans = 0

for i in range(4, len(s) + 1):
    l = 0
    r = l + i
    while r <= len(s):
        if int(''.join(s[l:r])) % 2019 == 0:
            ans += 1
            l = r - 1
            r = l + i
        else:
            l += 1
            r += 1
print(ans)

### FIXED CODE ###

s = input()[::-1]
sum_of_digits = 0
cnts = [0] * 2019
cnts[0] = 1

d = 1
for c in s:
    sum_of_digits += int(c) * d
    d *= 10
    d %= 2019
    sum_of_digits %= 2019
    cnts[sum_of_digits] += 1

ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)
### BUGGY CODE ###

#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
A = [0]*N
for i in range(N):
  A[i] = I()
  
A.sort()
A2 = A[:]

temp = A.pop(0)
B = [temp]
for i in range(math.ceil((N-1)/2)):
  if i%2==0:
    temp = A.pop(len(A)-1)
    B.insert(0,temp)
    if len(A)>0:
      temp = A.pop(0)
      B.insert(0,temp)
  else:
    temp = A.pop(len(A)-1)
    B.append(temp)
    if len(A)>0:
      temp = A.pop(0)
      B.append(temp)

val1 = 0
val2 = val1
for i in range(N-1):
  val1 += abs(B[i]-B[i+1])

if N%2==1:
  val2 = val1-abs(A2[(N-1)//2]-A2[(N-1)//2+1])+abs(A2[(N-1)//2]-A2[(N-1)//2-1])
print(max(val1,val2))

### FIXED CODE ###

#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

from collections import deque

N = I()
tempA = [0]*N
for i in range(N):
  tempA[i] = I()
  
tempA.sort()
A = deque(maxlen=N)
for i in range(N):
  A.append(tempA[i])
A2 = tempA[:]


temp = A.popleft()
B = deque(maxlen=N)
B.append(temp)
for i in range(math.ceil((N-1)/2)):
  if i%2==0:
    temp = A.pop()
    B.appendleft(temp)
    if len(A)>0:
      temp = A.popleft()
      B.appendleft(temp)
  else:
    temp = A.pop()
    B.append(temp)
    if len(A)>0:
      temp = A.popleft()
      B.append(temp)

val1 = 0
val2 = val1
for i in range(N-1):
  val1 += abs(B[i]-B[i+1])

if N%2==1:
  val2 = val1-abs(A2[(N-1)//2]-A2[(N-1)//2+1])+abs(A2[(N-1)//2]-A2[(N-1)//2-1])
print(max(val1,val2))
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
check = []
check.append(A.count(min(A))+A.count(min(A)+1))

for i in range(min(A)+1, max(A)+1):
    check.append(check[-1]-A.count(i-2)+A.count(i+1))
print(max(check))

### FIXED CODE ###

import collections
N = int(input())
A = sorted(list(map(int, input().split())))
ans = 1

AA = collections.Counter(A)
cc = [0]*(max(A)+1)

for i in AA.keys():
    cc[i] = AA[i]

for i in range(len(cc)):
    ans =  max(ans, sum(cc[i:i+3]))

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, maxint


def max_heapify(a, i, heap_size):
    L = 2*i
    R = 2*i + 1
    if L <= heap_size and a[L] > a[i]:
        largest = L
    else:
        largest = i
    if R <= heap_size and a[R] > a[largest]:
        largest = R
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest, heap_size)


def max_heap_insert(a, key, heap_size):
    heap_size[0] += 1
    a[heap_size[0]] =  -1-maxint
    heap_increase_key(a, key, heap_size[0])


def heap_increase_key(a, key, i):
    if key < a[i]:
        raise ValueError('new key less current key')
    a[i] = key
    while i > 1 and a[i//2] < a[i]:
        a[i], a[i//2] = a[i//2], a[i]
        i = i // 2


def heap_extract_max(a, heap_size):
    if heap_size[0] < 1:
        raise ValueError('heap under flow')
    max = a[1]
    a[1] = a[heap_size[0]]
    heap_size[0] -= 1
    max_heapify(a, 1, heap_size[0])
    return max


heap = [-1-maxint] * 2000001
heap_size = [1]
for cmd in stdin:
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert 0 <= key <= 2000000000
        max_heap_insert(heap, key, heap_size)
    elif cmd.startswith('ex'):
        print(heap_extract_max(heap, heap_size))
    elif cmd.startswith('en'):
        break

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def max_heapify(a, i):
    heap_size = a[0]

    L = 2*i
    R = 2*i + 1
    if L <= heap_size and a[L] > a[i]:
        largest = L
    else:
        largest = i
    if R <= heap_size and a[R] > a[largest]:
        largest = R
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)


def main():
    heap = [-1] * 2000001
    heap[0] = 1
    for cmd in stdin:
        if cmd[0] == 'i':
            heap[0] += 1
            i = heap[0]
            heap[i] = int(cmd[7:])

            half = i // 2
            while i > 1 and heap[half] < heap[i]:
                heap[i], heap[half] = heap[half], heap[i]
                i //= 2
                half = i // 2
        elif cmd[1] == 'x':
            print(heap[1])
            heap[1] = heap[heap[0]]
            heap[0] -= 1
            max_heapify(heap, 1)
        elif cmd[1] == 'n':
            exit(0)


main()
### BUGGY CODE ###

N = int(input())
numbers = []
for i in range(N):
    numbers.append(int(input()))

lis = [-float("inf"),numbers[0]]
for last in numbers[1:]:
    for i, (left, right) in enumerate(zip(lis, lis[1:])):
        if left < last and last < right:
            lis = lis[:i+1] + [last] + lis[i+2:]
            break
    if lis[-1] < last:
        lis.append(last)

print(len(lis)-1)

### FIXED CODE ###

import bisect

N = int(input())
numbers = []
for i in range(N):
    numbers.append(int(input()))

lis = [numbers[0]]
for last in numbers[1:]:
    if lis[-1] < last:
        lis.append(last)
    else:
        pos = bisect.bisect_left(lis, last)
        lis[pos] = last

print(len(lis))
### BUGGY CODE ###

N = int(input())
X = str(input())
X10 = int(X,2)
one_num = X.count("1")

for i in range(N):
    target = int(X[i])
    if target == 0:
        plus = pow(2,N-i-1)
        ones = one_num + 1
    else:
        plus = -pow(2,N-i-1)
        ones = one_num-1
    
    Xnow = X10+plus
    count = 0
    if Xnow == 0:
        print(count)
        continue
    else:
        Xnow = Xnow%ones
        count+=1
        while Xnow > 0:
            Xnow2 = format(Xnow, 'b')
            ones = Xnow2.count("1")
            Xnow = Xnow%ones
            count+=1
        print(count)

### FIXED CODE ###

N = int(input())
x2 = input()
x10 = int(x2, 2)
popc =  x2.count("1")
#print("x10", x10)
#print("popc", popc)
#popc: Nを2進数で表したときの1の個数

#以下で1つフリップさせた時の入力に対する余りを事前に計算
if popc <= 1:
    xp = x10%(popc+1)
    xm = 0
else:
    xp = x10%(popc+1)
    xm = x10%(popc-1)
#print("xp", xp)
#print("xm", xm)

#以下でフリップさせた場所のみを計算
for i in range(N):
    if x2[i] == "1":
        if popc == 1:
            print(0)
            continue
        tmp = (xm - pow(2, N-i-1, popc-1))%(popc-1)
    else:
        tmp = (xp + pow(2, N-i-1, popc+1))%(popc+1)
        
    #print("tmp", tmp)
    ans = 1
    while tmp > 0:
        tmp %= bin(tmp).count("1")
        ans += 1
    print(ans)
### BUGGY CODE ###

import math

n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))
pgcd = True
sgcd = a[n-1]

for i in range(0,n-1):
    sgcd = math.gcd(sgcd, a[i])
    if sgcd==1:
        break
if sgcd!=1:
    print('not coprime')
else:
    for i in range(0,n-1):
        sgcd = math.gcd(sgcd, a[i])    
        for j in range(i+1,n):
            if math.gcd(a[i], a[j]) != 1:
                print('setwise coprime')
                break
        else:
            continue
        break
    else:
        print('pairwise coprime')

### FIXED CODE ###

import math

n = int(input().rstrip())
a = list(map(int,input().rstrip().split()))
NUM = 1_000_005
aa = [0]*NUM
pgcd = True
sgcd = a[n-1]
aa[a[n-1]]+=1
for i in range(0,n-1):
    sgcd = math.gcd(sgcd, a[i])
    aa[a[i]]+=1

for i in range(2,NUM):
    tmp = sum(aa[i::i])
    if tmp >= 2:
        pgcd = False
        break
        
if sgcd!=1:
    print('not coprime')
elif pgcd:
    print('pairwise coprime')
else:
    print('setwise coprime')
### BUGGY CODE ###

import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a, b, c = sorted(a), sorted(b), sorted(c)

ans = 0
for i in b:
    up_index = bisect.bisect_left(a,i)
    down_index = bisect.bisect_right(c,i)
    ans += len(a[:up_index])*len(c[down_index:])

print(ans)


### FIXED CODE ###

import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a, b, c = sorted(a), sorted(b), sorted(c)

ans = 0
for i in b:
    up_index = bisect.bisect_left(a,i)
    down_index = bisect.bisect_right(c,i)
    ans += up_index * (n-down_index)

print(ans)
### BUGGY CODE ###

n = input()
list = list(map(int,input().split()))
count = 0
for i, val in enumerate(list):
  if min(list[0:i+1]) >= val:
    count += 1
print("%d"%(count))

### FIXED CODE ###

n = int(input())
list = list(map(int,input().split()))
count = 0
minimum = list[0]
for i in range(n):
  if minimum >= list[i]:
    count += 1
    minimum = list[i]

print("%d"%(count))
### BUGGY CODE ###

if __name__ == '__main__':
    S = list(input())
    T = list(input())

    letter = []
    for i in range(len(S)):
        letter.append(T[i])                                                                                                                                                     
        if S[i] == T[i]:
            continue
        else:
            if S[i] in letter:
                break
            else:
                s = S[i]
                for j in range(len(S)):
                    if S[j] == s:
                        S[j] = T[i]
                    elif S[j] == T[i]:
                        S[j] = s

    if S == T:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

if __name__ == '__main__':
    S = list(input())
    T = list(input())

    start = [-1 for i in range(26)]
    stop = [-1 for i in range(26)]

    fail = False
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')

        if start[a] != -1 or stop[b] != -1:
            if start[a] != b or stop[b] != a:
                print('No')
                fail = True
                break
        else:
            start[a] = b
            stop[b] = a

    if not fail:
        print('Yes')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import fractions


def tri_gcd(p, q, r):
    tmp_gcd = fractions.gcd(p, q)
    return fractions.gcd(tmp_gcd, r)


k = int(input())
res = 0
for a in range(1, k+1):
    for b in range(a, k+1):
        for c in range(b, k+1):
            tk = tri_gcd(a, b, c)
            if a == b:
                if b == c:
                    res += tk
                else:
                    res += tk * 3
            else:
                if b == c:
                    res += tk*3
                else:
                    res += tk*6

print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import fractions
gcd_map = [[0 for i in range(401)] for i in range(401)]


def mem_gcd(p, q):
    if gcd_map[p][q] == 0:
        gcd_map[p][q] = fractions.gcd(p, q)
    return gcd_map[p][q]


k = int(input())
res = 0
for a in range(1, k+1):
    for b in range(a, k+1):
        tmp_gcd = mem_gcd(a, b)
        for c in range(b, k+1):
            tk = mem_gcd(tmp_gcd, c)
            if a == b:
                if b == c:
                    res += tk
                else:
                    res += tk * 3
            else:
                if b == c:
                    res += tk*3
                else:
                    res += tk*6

print(res)
### BUGGY CODE ###

def main():
  N=int(input())
  n=list(map(int,input().split()))
  
  for i in range(N):
    print(n.count(i+1))
    
main()

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
A=[0]*N
for i in a:
  A[i-1]+=1
for i in A:
  print(i)
### BUGGY CODE ###

n = int(input())

list_s = []
for i in range(n):
    s = input()
    list_s_tmp = []
    for j in s:
        list_s_tmp.append(j)
    
    list_s.append(sorted(list_s_tmp))

result = 0
for i in range(len(list_s)):
    for j in range(i, len(list_s)):
        if list_s[i] == list_s[j]:
            result = result + 1

print((result - n))

### FIXED CODE ###

n = int(input())

d = {}
ans = 0
for i in range(n):
    list_s = sorted(list(input()))

    s = ""
    for j in list_s:
        s = s + j

    if s in d:
        ans = ans + d[s]
        d[s] += 1
    else:
        d[s] = 1

print(ans)
### BUGGY CODE ###

def SME():
    A = [[x,i] for i,x in enumerate(Whole)]
    A.sort()
    i = 1
    while i < len(A) - 1:
        if A[i+1][1]-A[i-1][1] < L :
            if A[i+1][0]==A[i-1][0] :
                del A[i]
                continue
        i += 1
    C = set([i for i in range(N)])
    D = set([])
    parameter = 0.997
    count = 0
    ANS = [None] * N
    for j in range(N) :
        a = A[j]
        for i,x in enumerate(ANS[a[1]:a[1]+L]):
            if x : continue
            else :
                ANS[a[1]+i] = a[0]
                D.add(a[1]+i)
                count += 1
        if count > N * parameter : break
    for i in C.difference(D):
        if i < L : ANS[i] = min(Whole[:i+1])
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
if N != 10 ** 5 :
    ANS = SME()
    for i in ANS[L-1:-1]:print(i, end=" ")
    print(ANS[-1])
else :
    if max(Whole) < 10 ** 5 :
        ANS = SME()
        for i in ANS[L-1:-1]:print(i, end=" ")
        print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

n=int(input())
s=input()
c=0
for i in range(n-2):
  t1=s[i]
  for j in range(i+1,n-1):
    t2=s[j]
    if t1 not in t2:
      for k in range(j+1,n):
        t3=s[k]
        if t3 not in t1+t2 and j-i!=k-j:
          c+=1
print(c)

### FIXED CODE ###

n=int(input())
s=input()
t=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  j=1
  while i+j*2<n:
    if s[i]!=s[i+j] and s[i+j]!=s[i+2*j] and s[i]!=s[i+2*j]:
      t-=1
    j+=1
print(t)
### BUGGY CODE ###

# -*- coding:utf-8 -*-

n, h = map(int, input().split())
a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a.sort()
b.sort()

x = a[-1]

count = 0
while(h > 0):    
    if b[-1] > x:
        h -= b.pop()
        count += 1;
        if not b:
            b.append(-100)
    else:
        if a[-1] == 1:
            count += h
            break
        else:
            h -= a[-1]
            count += 1;

print(count)


### FIXED CODE ###

# -*- coding:utf-8 -*-

n, h = map(int, input().split())
a = []
b = []

for i in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a.sort()
b.sort()

x = a[-1]

count = 0
while(h > 0):    
    if b[-1] > x:
        h -= b.pop()
        count += 1;
        if not b:
            b.append(-100)
    else:
        #h -= a[-1]
        #count += 1;
        count += (h // a[-1])
        h -= a[-1] * (h//a[-1])
        break
if h > 0:
    count += 1
print(count)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    Sum = 0
    for i in range(pi+1):
        Sum += i
    ev.append(Sum / pi)

ans = 0
cost = sum(ev[:k])
for i in range(k, n+1):
    if ans < cost:
        ans = cost
    if i == n:
        continue
    cost -= ev[i-k]
    cost += ev[i]
    # print(i)

print(ans)
# print(ev)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
ev = []
for pi in p:
    ev.append((pi + 1) / 2)

ans = 0
cost = sum(ev[:k])
for i in range(k, n+1):
    if ans < cost:
        ans = cost
    if i == n:
        continue
    cost -= ev[i-k]
    cost += ev[i]
    # print(i)

print(ans)
# print(ev)
### BUGGY CODE ###

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

max_xor = 1 << (len(bin(max(A))) - 2)
ans = N
for l in range(N-1):
    csum = A[l]
    cxor = A[l]
    for r in range(l+1,N):
        if csum >= max_xor:
            break
        csum += A[r]
        cxor ^= A[r]
        if csum == cxor:
            ans += 1
print(ans)


### FIXED CODE ###

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

    if N == 1:
        return 1

    ans = N
    l = 0
    r = 0
    s = A[l]
    while l < N-1:
        if r+1 < N:
            if s & A[r+1] == 0:
                r += 1
                s |= A[r]
                ans += r - l
                continue
        if l == r:
            l += 1
            r += 1
            s = A[l]
        else:
            s &= ~A[l]
            l += 1
    return ans

print(solve())

#  1  2  4  8  1
#  l  r              (1,2)
#  l     r           (1,4)(2,4)
#  l        r        (1,8)(2,8)(4,8)
#     l     r
#     l        r     (2,1)(4,1)(8,1)