Harryxun/stf_run huggingface dataset:
s=input();k=[]
for i in range(0,len(s)):
    if s[i]!='B':
        k.append(int(s[i]))
    else:
        del k[-1]
for j in range(0,len(s)):
    print(k[j],end='')
print('')

### FIXED CODE ###

s=input();k=[]
for i in range(0,len(s)):
    if s[i]!='B':
        k.append(int(s[i]))
    else:
        if k!=[]:
            del k[-1]
for j in range(0,len(k)):
    print(k[j],end='')
print('')
import numpy as np
A, B, Q=map(int, input().split())
s=[int(input()) for _ in range(A)]
t=[int(input()) for _ in range(B)]
x=[int(input()) for _ in range(Q)]

def f(nums, a):
  if a<=nums[0]:
    return nums[0]-a
  if nums[-1]<=a:
    return a-nums[-1]
  tmp=np.searchsorted(nums, a, side='left')
  return min(a-nums[tmp-1], nums[tmp]-a)

for i in range(Q):
  out=2*10**10
  if x[i]<=s[0]:
    s2=s[0]
    out=min(out, s2-x[i]+f(t, s2))
  elif s[-1]<=x[i]:
    s1=s[-1]
    out=min(out, x[i]-s1+f(t, s1))
  else:
    tmp=np.searchsorted(s, x[i], side='left')
    s1=s[tmp-1]
    out=min(out, x[i]-s1+f(t, s1))
    s2=s[tmp]
    out=min(out, s2-x[i]+f(t, s2))
    
  if x[i]<=t[0]:
    t2=t[0]
    out=min(out, t2-x[i]+f(s, t2))
  elif t[-1]<=x[i]:
    t1=t[-1]
    out=min(out, x[i]-t1+f(s, t1))
  else:
    tmp=np.searchsorted(t, x[i], side='left')
    t1=t[tmp-1]
    out=min(out, x[i]-t1+f(s, t1))
    t2=t[tmp]
    out=min(out, t2-x[i]+f(s, t2))
    
  print(out)

### FIXED CODE ###

import bisect

A, B, Q=map(int, input().split())
s=[int(input()) for _ in range(A)]
t=[int(input()) for _ in range(B)]
x=[int(input()) for _ in range(Q)]

st=[0]*A
ts=[0]*B

for i in range(A):
  tmp=bisect.bisect_left(t, s[i])
  if tmp==0:
    st[i]=t[0]-s[i]
  elif tmp==B:
    st[i]=s[i]-t[-1]
  else:
    st[i]=min(s[i]-t[tmp-1], t[tmp]-s[i])
    
for i in range(B):
  tmp=bisect.bisect_left(s, t[i])
  if tmp==0:
    ts[i]=s[0]-t[i]
  elif tmp==A:
    ts[i]=t[i]-s[-1]
  else:
    ts[i]=min(t[i]-s[tmp-1], s[tmp]-t[i])

for i in range(Q):
  cand=set()
  tmp=bisect.bisect_left(s, x[i])
  if tmp>0:
    cand.add(x[i]-s[tmp-1]+st[tmp-1])
  if tmp<A:
    cand.add(s[tmp]-x[i]+st[tmp])
    
  tmp=bisect.bisect_left(t, x[i])
  if tmp>0:
    cand.add(x[i]-t[tmp-1]+ts[tmp-1])
  if tmp<B:
    cand.add(t[tmp]-x[i]+ts[tmp])
    
  print(min(cand))
N=int(input())
return N%1000

### FIXED CODE ###

N=int(input())
if N%1000==0:
    print(0)
else:
    print((N//1000+1)*1000-N)
N = int(input())
a_list = [int(x) for x in input().split()]
b_list = [0] * N
for i in range(len(a_list), 0, -1):
    if (a_list[i-1] != b_list[i-1]):
        b_list[i-1] ^= 1
        if (i >= 2):
            b_list[0] ^= 1
            for j in range(2, int(math.sqrt(i)+1)):
                if i % j == 0:
                    b_list[j-1] ^= 1
                    b_list[i//j-1] ^= 1
ans = []
cnt = 0
for i, b in enumerate(b_list):
    if (b):
        cnt += 1
        ans.append(str(b))
print(cnt)
if (cnt):
    print(" ".split(ans))


### FIXED CODE ###

N = int(input())
a_list = [int(x) for x in input().split()]
cnt = 0
b_list = set()
for i in range(len(a_list), 0, -1):
    tmp = 0
    for j in range(i*2, N+1, i):
        tmp ^= (j in b_list)
    if (tmp != a_list[i-1]):
        b_list.add(i)
M = len(b_list)
print(M)
if (M>0):
    print(" ".join([str(b) for b in b_list]))
mod = 998244353
rng = 2100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
def homo(n,k):
  if n<0 or k<=0:
    return 0
  else:
    return cmb(n+k-1,k-1)
k,n = map(int,input().split())
if k%2 == 0:
  flg = 0
else:
  flg = 1
ans = []
for i in range(3,k+2,2):
  ic = (i-1)//2
  anstmp = 0
  for j in range(ic+1):
    t = homo(n-j,(k-ic*2+j))*cmb(ic,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
  ans.append(anstmp)
if flg:
  anstmp = 0
  for j in range(1,k//2+1):
    t = (homo(n-j,j)*homo(n-j-1,j+1))*cmb(k//2,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
ans2 = ans[:-1]
ans2 = ans2[::-1]
print(*ans,*ans2,sep="\n")

### FIXED CODE ###

mod = 998244353
rng = 4100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
def homo(n,k):
  if n<0 or k<=0:
    return 0
  else:
    return cmb(n+k-1,k-1)
k,n = map(int,input().split())
if k%2 == 0:
  flg = 0
else:
  flg = 1
ans = []
for i in range(3,k+2,2):
  ic = (i-1)//2
  anstmp = 0
  for j in range(ic+1):
    t = homo(n-j,(k-ic*2+j))*cmb(ic,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
  ans.append(anstmp)
if flg:
  anstmp = 0
  for j in range(1,k//2+1):
    t = (homo(n-j,j)+homo(n-j-1,j))*cmb(k//2,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
ans2 = ans[:-1]
ans2 = ans2[::-1]
print(*ans,sep="\n")
print(*ans2,sep="\n")
s = input()

def func(ac,s,op):
  next = s[0]
  if len(s) ==1:
    if ac + next == 7:
      print(str+'+'+s[0]+'=7')
      exit(0)
    if ac - next == 7:
      print(str+'-'+s[0]+'=7')
      exit(0)
  else:
    func(ac+next,s[1:],op+'+'+str(next))
    func(ac-next,s[1:],op+'-'+str(next))
  
func(int(s[0]),s[1:],s[0])

### FIXED CODE ###

s = input()
n = []
op = []

def calc(lst,n,op):
  if lst:
    op.append('+')
    p = calc(lst[:-1],n+lst[-1],op)
    if p:
      return p
    op.pop()
    op.append('-')
    n = calc(lst[:-1],n-lst[-1],op)
    if n:
      return n
    op.pop()
  else:
    if n == 7:
      return op
    else:
      return None
  
    

for i in range(3):
  n.append(int(s[3-i]))
op = calc(n,int(s[0]),op)
print('{}{}{}{}{}{}{}=7'.format(s[0],op[0],s[1],op[1],s[2],op[2],s[3]))
A,B,C = (int(i) for i in input().split())

Aaddition = A+B+C
if Addition != 17:
  haiku = False
else:
  if ((A==5 or A==7) and (B==5 or B==7) and (C==5 or C==7)):
    haiku = True
  else:
    haiku = False
    
if haiku:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

A,B,C = (int(i) for i in input().split())

Addition = A+B+C
if Addition != 17:
    haiku = False
else:
    if ((A==5 or A==7) and (B==5 or B==7) and (C==5 or C==7)):
        haiku = True
    else:
        haiku = False
    
if haiku:
    print("YES")
else:
    print("NO")
import collections

n, p = map(int,input().split())
D = input()
s = [0] * n
mod = 0
out = 0
if 10 % p == 0:
    for i, d in enumerate(D):
        if int(d) % p == 0:
            out += i + 1
else:
    M = [(int(d) * 10 ** i) % p for i, d in enumerate(D)]
    s[0] = M[0]
    for i in range(1, n):
        s[i] = (s[i - 1] + M[i]) % p
    C = collections.Counter(s)
    out += C[0]
    for c in C.values():
        out += (int(c) * (int(c) - 1)) / 2
print(int(out)

### FIXED CODE ###

n, p = map(int,input().split())
D = input()
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)
while 1:
    try:
        n=int(raw_input())
    except EOFError:
        break
    print len(=[1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if i+j+k+l==n]

### FIXED CODE ###

import itertools
import sys
s=range(0,10)
chk=list(itertools.product(s,repeat=4))
for j in sys.stdin:
    ans=0
    for k in chk:
        if sum(k)==int(j):
            ans+=1
    print ans
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou=>0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x,y = map(int,input().split())
if x % y ==0:
  print(-1)
else:
  print(x)
from math import ceil
s=list(input())
n=len(s)
l=[]
m=[]
buf=[]
for i in range(n):
    if s[i]!="x":
        l.append(s[i])
m=l[::-1]
#print(l,m)
left=[]
right=[]
ans=0
if m==l:
    flag=1
    for i in range(ceil(len(l)/2)):
        buf.append(s[i])
    piv=0
    cnt=0
    for i in range(n):
        if piv==len(buf):
            break
        if s[i]==buf[piv]:
            left.append(cnt)
            cnt=0
            piv=piv+1
        else:
            cnt=cnt+1
    piv=0
    cnt=0
    for i in range(n-1,-1,-1):
        if piv==len(buf):
            break
        if s[i]==buf[piv]:
            right.append(cnt)
            cnt=0
            piv=piv+1
        else:
            cnt=cnt+1
    #print(left,right)
    for i in range(len(left)):
        ans=ans+abs(left[i]-right[i])
    print(ans)
else:
    print("-1")


### FIXED CODE ###

from math import ceil
s=list(input())
n=len(s)
l=[]
m=[]
buf=[]
for i in range(n):
    if s[i]!="x":
        l.append(s[i])
m=l[::-1]
#print(l,m)
left=[]
right=[]
ans=0
if m==l:
    flag=1
    for i in range(ceil(len(l)/2)):
        buf.append(l[i])
    piv=0
    cnt=0
    #print(buf)
    for i in range(n):
        if piv==len(buf):
            break
        if s[i]==buf[piv]:
            left.append(cnt)
            cnt=0
            piv=piv+1
        else:
            cnt=cnt+1
    piv=0
    cnt=0
    for i in range(n-1,-1,-1):
        if piv==len(buf):
            break
        if s[i]==buf[piv]:
            right.append(cnt)
            cnt=0
            piv=piv+1
        else:
            cnt=cnt+1
    #print(left,right)
    for i in range(len(left)):
        ans=ans+abs(left[i]-right[i])
    print(ans)
else:
    print("-1")
import math

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

answer = 0

for i in range(1, K+1):
    answer = combinations_count(K-1, i-1)
    answer *= combinations_count(N-K+1, i)
    answer %= 10**(9) + 7
    print(answer)

### FIXED CODE ###

import math

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

answer = 0

for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
        continue
    answer = combinations_count(K-1, i-1)
    answer *= combinations_count(N-K+1, i)
    answer %= 10**(9) + 7
    print(answer)
a,b = map(int,input().split())

if (a%500) <= b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = int(input())
b = int(input())

if (a%500) <= b:
  print("Yes")
else:
  print("No")
def boolean(a,b):
    if(abs(a[0] - b[0]) == abs(a[1] - b[1]) + abs(a[2] - b[2])):
        return 0
    else:
        return 1

N = int(input())
lists=[0 for i in range(n+1)]
lists[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    lists[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

### FIXED CODE ###

def boolean(a,b):
    D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2])
    if(D >= 0 and D %2 == 0):
        return 0
    else:
        return 1

N = int(input())
txy=[0 for i in range(N+1)]
txy[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    txy[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)
dic = {}
while True:
    try:
        word, pgn = input().split()
    except ValueError:
        break

    if word in dic.keys():
        dic[word].append(int(pgn))
    else:
        dic[word] = [int(pgn)]
for k, v in dic.items():
    print(k)
    print(' '.join(map(str, sorted(v))))

### FIXED CODE ###

d = {}
while True:
    try:
        data = input().split()
    except:
        break
    word = data[0]
    number = int(data[1])
    if word in d:
        d[word].append(number)
    else:
        d[word] = [number]

for k, v in sorted(d.items(), key=lambda x: x[0]):
    print(k)
    print(*sorted(v))
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [-1 for i in range(n + 1)]
        
    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if x != y:
            if self.par[x] < self.par[y]:  # par<0の小さい方に合わせる
                self.par[y] += self.par[x]
                self.par[x] = y
            else:
                self.par[x] += self.par[y]
                self.par[y] = x

    def size(self, x):
        return -self.par[self.find(x)]
    
    
u = UnionFind(N)
for i in range(M):
    u.union(A[i], B[i])
    
ans = 1
for i in range(1, N+1):
    ans = max(ans, u.size(i))
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
u = UnionFind(N)
for i in range(M):
    u.union(A[i], B[i])
    
ans = 1
for i in range(1, N+1):
    ans = max(ans, u.size(i))
print(ans)
import random

x=int(input())

while True:
    a=random.randint(-1000000000,1000000000)
    b=random.randint(-1000000000,1000000000)
    if x == a*a*a*a*a-b*b*b*b*b:
        print(a,b)
        break

### FIXED CODE ###

s = input()

if s == "ABC":
    print("ARC")
else:
    print("ABC")
a = int(input())
b = int(input())
c = int(input())
d = int(input())

s1 = a*b
s2 = c*d

if s1>=s2:
    print(s1)
else:
    print(s2)


### FIXED CODE ###

a,b,c,d = (int(x) for x in input().split())

s1 = a*b
s2 = c*d

if s1>=s2:
    print(s1)
else:
    print(s2)
S=input()
S_=list(S)
Q=int(input())
F1=[]
F2=[]
Q_=[]
for i in range(4):
  Q_.append(list(input().split()))
count=0  
for i in range(len(Q_)):
  if Q_[i]==['1']:
    count+=1
  elif Q_[i][0:2]==['2','1']:
    if count%2==0:
      F1.append(Q_[i][2])
    else:
      F2.append(Q_[i][2])
  else:
    if count%2==0:
      F2.append(Q_[i][2])
    else:
      F1.append(Q_[i][2])
SS=F1[::-1]+S_+F2                
if count%2==0:
  print(''.join(SS))
else:
  print(''.join(SS[::-1]))
    

### FIXED CODE ###

S=input()
S_=list(S)
Q=int(input())
F1=[]
F2=[]
Q_=[]
for i in range(Q):
  Q_.append(list(input().split()))
count=0  
for i in range(len(Q_)):
  if Q_[i]==['1']:
    count+=1
  elif Q_[i][0:2]==['2','1']:
    if count%2==0:
      F1.append(Q_[i][2])
    else:
      F2.append(Q_[i][2])
  else:
    if count%2==0:
      F2.append(Q_[i][2])
    else:
      F1.append(Q_[i][2])
SS=F1[::-1]+S_+F2                
if count%2==0:
  print(''.join(SS))
else:
  print(''.join(SS[::-1]))
n = int(input())
h = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(n-1):
   if h[i] >= h[i+1]:
      cnt += 1
      move_cnt.append(cnt)
   else:
      cnt = 0
      move_cnt.append(cnt)
print(max(move_cnt))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(n-1):
   if h[i] >= h[i+1]:
      cnt += 1
      ans = max(ans, cnt)
   else:
      cnt = 0
print(ans)
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

branch = [[] for _ in range(N)]
for i in range(N-1):
    branch[ab[i][0]-1].append(ab[i][1]-1)
    branch[ab[i][1]-1].append(ab[i][0]-1)

counters = [0 for _ in range(N)]
for i in range(Q):
    counters[px[i][0]-1] += px[i][1]

results = [0 for _ in range(N)]

def repeat(node, counter, pre_node):
    candidates = branch[node]
    counter += counters[node]
    
    for candidate in candidates:
        if candidate == pre_node:
            continue
        else:
            repeat(candidate, counter, node)
    results[node] = counter
    return
    
repeat(0, 0, 0)

print((" ").join([str(i) for i in results]))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]

branch = [[] for _ in range(N)]
for i in range(N-1):
    branch[ab[i][0]-1].append(ab[i][1]-1)
    branch[ab[i][1]-1].append(ab[i][0]-1)

counters = [0 for _ in range(N)]
for i in range(Q):
    counters[px[i][0]-1] += px[i][1]
results = [0 for _ in range(N)]

seen = [False for _ in range(N)]
from collections import deque
seen[0] = True
todo = deque([0])
results[0] = counters[0]

while len(todo)>0:
    checking = todo.pop()
    candidates = branch[checking]
    for candidate in candidates:
        if seen[candidate] == False:
            todo.append(candidate)
            seen[candidate] = True
            results[candidate] = results[checking]+counters[candidate]


print((" ").join([str(i) for i in results]))
N, M = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
cnt = 0
for a in A:
  if a >= S / (4*M):
	cnt += 1
if cnt >= M:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
asum = sum(a)
r = 0
for i in range(n):
  if a[i] >= asum/(4*m):
    r += 1
print("Yes" if r >= m else "No")
#abc133c

l,r=map(int,raw_input().split())
if r-l>3000:
 print 0
 sys.exit()
res=-1
for i in xrange(l,r):
 for j in xrange(i+1,r+1):
  res=min(res,(i*j)%2019)
print res


### FIXED CODE ###

#abc133c

l,r=map(int,raw_input().split())
r=min(r,l+673)
res=2018
for i in  xrange(l,r+1):
 for j in xrange(i+1,r+1):
  res=min(res,i*j%2019)
print res
n = list(input())
if n % 1000 == 0:
    print("0")
else:
    print((10 - int(n[-3])) * 100)


### FIXED CODE ###

n = int(input())
if n % 1000 == 0:
    print("0")
else:
    print(((n // 1000) + 1) * 1000 - n)
N = int(input())
M = int(input())
if N==M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N, M = map(int, input().split())
if N==M:
    print("Yes")
else:
    print("No")
def main():
    [N, M] = [int(i) for i in input().split()]

    E = []

    for i in range(M):
        E.append([int(i) for i in input().split()])

    dist = [-1*10**100 for i in range(N)]
    dist[0] = 0

    for i in range(N):
        for [a, b, c] in E:
            newLen = dist[a-1] + c
            if newLen > dist[b-1]:
                dist[b-1] = newLen

    dist2 = dist.copy()

    for i in range(N):
        for [a, b, c] in E:
            newLen = dist[a-1] + c
            if newLen > dist[b-1]:
                dist2[b-1] = newLen

    if dist != dist2:
        print('inf')
    else:
        print(dist[N-1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    [N, M] = [int(i) for i in input().split()]
    edge = [[10**100] * N for _ in range(N)]

    E = []

    for i in range(M):
        E.append([int(i) for i in input().split()])

    dist = [-1*10**100 for i in range(N)]
    dist[0] = 0

    flag = False

    for i in range(N):
        for [a, b, c] in E:
            newLen = dist[a-1] + c
            if newLen > dist[b-1]:
                dist[b-1] = newLen
        if i == N-1 and dist[N-1] > predist:
            flag = True
        predist = dist[N-1]

    if flag:
        print('inf')
    else:
        print(dist[N-1])


if __name__ == '__main__':
    main()
n=int(input())
a=list(map(int,input().split()))

ll=0
rr=0
llrr=0

result=0

for ll in range(n):

    while rr<n and a[rr]&llrr==0:
        rr+=1
        b+=a[rr]
    result+=r-list
    b=b^a[ll]

print(result)



    

### FIXED CODE ###

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

ll=0
rr=0
llrr=0

result=0

for ll in range(n):

    while rr<n and a[rr]&llrr==0:
        llrr+=a[rr]
        rr+=1
    result+=rr-ll
    llrr=llrr^a[ll]

print(result)
def inv(a,p):
    if a==1:
        return 1
    elif a==0:
        return 0
    return p-(inv(p%a,p)*(p//a))%p
x,y=map(int,input().split())
if (x+y)%3!=0:
    print("0")
    exit()
n=(x+y)//3
r=(2*x-y)//3
p=10**9+7
def fact(n,p):
    a=[[] for _ in range(n+1)]
    a[0]=1
    for i in range(n):
        a[i+1]=(a[i]*(i+1))%p
    return a
f=fact(n,p)
if len(f)=<r:
    print("0")
    exit()
c=f[-1]
d=f[r]
e=f[n-r]
dd=inv(d,p)
ee=inv(e,p)
ans=(c*dd*ee)%p
print(ans)

### FIXED CODE ###

r=int(input())
print(r**2)
n, a, b = map(int, input().split())
ans = 0
for i in range(n):
    if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += 1
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
import itertools
import sys
 
N,A,B=map(int,input().split())
ans=set()
 
if A>B:
  print(0)
  sys.exit()
elif N==1:
  if A==B:
    print(1)
    sys.exit()
  else:
    print(0)
    sys.exit()
elif N==2:
  print(1)
  sys.exit()
else:
  for x in itertools.combinations_with_replacement(range(A,B+1),N-2):
    if x in ans:
      continue
    ans.add(sum(x))
 
print(len(ans))

### FIXED CODE ###

N,A,B=map(int,input().split())
 
if N==1:
  if A==B:
    print(1)
  else:
    print(0)
elif A==B:
  print(1)
elif A>B:
  print(0)
else:
  print(B*(N-2)-A*(N-2)+1)
a

### FIXED CODE ###

weather=list(input())
r= weather. count("R")
if r==2 and weather[1]=="S":
   print(1)
else:
   print(r)
N = input()
a = list(map(input().split())
i = 0
for x,a in enumerate a:
	if x%2!=0 and a%2!=0:
    	i+=1
     
    print(i)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
i=0
for x,y in enumerate (a):
    b=x+1
    if b%2!=0 and y%2!=0:
        i+=1
print(i)
https://atcoder.jp/contests/abc160/tasks/abc160_a

### FIXED CODE ###

S = input()
 
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
n = int(input())
a = list(map(int, input().split()))
s = [0 for _ in range(n)]

score = 0
for i in range(n):
    l = s.index(0)
    r = n - 1 -s[::-1].index(0)
    #right
    score_r, score_l = score, score
    sr, sl = s.copy(), s.copy()
    if r >= i:
        sr[r] = a[i]
        score_r += a[i] * (r - i)
        while r < n-1 and sr[r] > sr[r+1]:
            score_r += sr[r] - sr[r+1]
            sr[r], sr[r+1] = sr[r+1], sr[r]
            r += 1

    if l <= i:
        sl[l] = a[i]
        score_l += a[i] * (i - l)
        while l > 0 and sl[l-1] < sl[l]:
            score_l += sl[l] - sl[l-1]
            sl[l-1], sl[l] = sl[l], sl[l-1]
            l += 1

    if score_r >= score_l:
        score = score_r
        s = sr

    else:
        score = score_l
        s = sl


print(score)
#print(s)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a = [(a[i], i) for i in range(n)]
a.sort(key=lambda x: -x[0])
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

for x in range(n+1):
    for y in range(n+1):
        if x + y > n:
            break
        active, idx = a[x+y-1]
        if x > 0:
            dp[x][y] = max(dp[x][y],
                           dp[x-1][y] + active * abs(idx - (x-1)))

        if y > 0:
            dp[x][y] = max(dp[x][y],
                           dp[x][y-1] + active * abs(idx - (n-y)))

ans = 0
for x in range(n+1):
    ans = max(ans, dp[x][n-x])

print(ans)
from math import degrees, atan

a, b, x = map(int, input().split())

vol = a * a * b

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if 2 * x > vol:
    x -= vol / 2
    tmp = A(a, a, vol / 2 - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)


### FIXED CODE ###

from math import degrees, atan

a, b, x = map(int, input().split())

vol = a * a * b

def A(a, b, x):
    return degrees(atan((a * b * b) / (2 * x)))

if vol == x:
    result = 0
elif 2 * x > vol:
    x -= vol / 2
    tmp = A(a, a, vol / 2 - x)
    result = 90 - tmp
else:
    result = A(a, b, x)

print(result)