Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict,deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[(1,1),(-1,1),(1,-1),(-1,-1),(2,0),(-2,0),(0,2),(0,-2),(1,2),(-1,2),(1,-2),(-1,-2),(2,1),(-2,1),(2,-1),(-2,-1),(2,2),(-2,2),(2,-2),(-2,-2)]

visit=defaultdict(lambda: 0) #未訪問:0 訪問済み:1

q=deque()
q.append((0,CH,CW))
visit[(CH,CW)]=1

while q:
    kyori, fro_h, fro_w=q.popleft()
    visit[(fro_h, fro_w)]=1
    if fro_h==DH and fro_w==DW:
        print kyori
        quit()
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
                    q.appendleft((kyori,to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
                    q.append((kyori+1, to_h, to_w))

print -1


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
n=int(input())
A=[]
cnt=0
add=0
for i in range(4471):
    cnt +=i+1
    A.append((cnt,i+1))
for i in range(len(A)-1):
    if A[i][0]<=n<=A[i+1][0]:
        add=(A[i+1][1],A[i+1][0]-n)
        break

for i in range(add[0]):
    if i+1==add[1]:
        continue
    print(i+1)

### FIXED CODE ###

n=int(input())
A=[]
cnt=0
add=0
for i in range(4472):
    cnt +=i+1
    A.append((cnt,i+1))
for i in range(len(A)-1):
    if A[i][0]<=n<=A[i+1][0]:
        add=(A[i+1][1],A[i+1][0]-n)
        break

for i in range(add[0]):
    if i+1==add[1]:
        continue
    print(i+1)
import math

R = int(input())

print R*2*math.pi()

### FIXED CODE ###

import math

R = int(input())

print (float(R*2*math.pi))
n=int(input())
d=[-1]*n
l=deque([])
for i in range(n-1):
    u,v,w=map(int,input().split())
    u,v=min(u,v),max(u,v)
    l.append((u-1,v-1,w))
f=0
while len(l):
    x=l.popleft()
    if f:
        if x[2]%2 and d[x[0]]==0:
            d[x[1]]=1
        elif x[2]%2 and d[x[0]]==1:
            d[x[1]]=0
        elif x[2]%2==0 and d[x[0]]==1:
            d[x[1]]=1
        elif x[2]%2==0 and d[x[0]]==0:
            d[x[1]]=0
        elif x[2]%2 and d[x[1]]==0:
            d[x[0]]=1
        elif x[2]%2 and d[x[1]]==1:
            d[x[0]]=0
        elif x[2]%2==0 and d[x[1]]==1:
            d[x[0]]=1
        elif x[2]%2==0 and d[x[1]]==0:
            d[x[0]]=0
        else:
            l.append(x)
    else:
        f=1
        if x[2]%2:
            d[x[0]]=0
            d[x[1]]=1
        else:
            d[x[0]]=0
            d[x[1]]=0
for i in d:
    print(i)

### FIXED CODE ###

from collections import deque
def sol():
    n=int(input())
    d=[-1]*n
    l=deque([])
    for i in range(n-1):
        u,v,w=map(int,input().split())
        u,v=min(u,v),max(u,v)
        l.append((u-1,v-1,w))
    f=0
    while len(l):
        x=l.popleft()
        if f:
            if x[2]%2 and d[x[0]]==0:
                d[x[1]]=1
            elif x[2]%2 and d[x[0]]==1:
                d[x[1]]=0
            elif x[2]%2==0 and d[x[0]]==1:
                d[x[1]]=1
            elif x[2]%2==0 and d[x[0]]==0:
                d[x[1]]=0
            elif x[2]%2 and d[x[1]]==0:
                d[x[0]]=1
            elif x[2]%2 and d[x[1]]==1:
                d[x[0]]=0
            elif x[2]%2==0 and d[x[1]]==1:
                d[x[0]]=1
            elif x[2]%2==0 and d[x[1]]==0:
                d[x[0]]=0
            else:
                l.append(x)
        else:
            f=1
            if x[2]%2:
                d[x[0]]=0
                d[x[1]]=1
            else:
                d[x[0]]=0
                d[x[1]]=0
    for i in d:
        print(i)

if __name__=="__main__":
    sol()
import math
n, m = map(int, input().split())
s = input()
t = input()
lcm = (n * m) // math.gcd(n, m)
gcd = math.gcd(n, m)
ans = lcm
if gcd > 1:
    for i in range(gcd):
        if s[i * (n // gcd)] != t[i * (m // gcd)]:
            ans = -1
print(ans)

### FIXED CODE ###

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while (b != 0):
        a, b = b, a % b
    return a

n, m = map(int, input().split())
s = input()
t = input()
lcm = (n * m) // gcd(n, m)
gcd = gcd(n, m)
ans = lcm
if gcd > 1:
    for i in range(gcd):
        if s[i * (n // gcd)] != t[i * (m // gcd)]:
            ans = -1
if s[0] != t[0]:
    ans = -1
print(ans)
N = int(input())
arr = str(input())
lst =[]
for i in arr.split():
    lst.append(i)
multi = 1
for i in lst:
    if i > pow(10,18):
        print(-1)
        exit(0)
    else: multi *= int(i)
print(multi)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
def nhan(A):
    multi = 1
    for i in A:
        multi *= i
        if multi > 10**18: return -1
    return multi
print(nhan(A))
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*n
if 1 not in a and 2 not in a:
    dp[0]=1
    dp[1]=2
elif 1 not in a and 2 in a:
    dp[0]=1
    dp[1]=0
elif 1 in a and 2 not in a:
    dp[0]=0
    dp[1]=1
else:
    print(0)
    exit()
for i in range(2,n):
    if i+1 in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%((10**9)+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[None]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
for i in a:
    dp[i]=0
for i in range(2,n+1):
    if dp[i]!=0 :
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))
ins = input()


def foo(s):
    last = s[-1:]
    # is empty
    print(s)
    if not s:
        return "YES"
    else:
        n = 0
        if last == 'r' and s[-6:] == 'eraser':
            n = -6
        elif last == 'r' and s[-7:] == 'dreamer':
            n = -7
        elif (last == 'e' and s[-5:] == 'erase') or (last == 'm' and s[-5:] == 'dream'):
            n = -5

        if n == 0:
            return "NO"
        else:
            return foo(s[:n])


print(foo(ins))


### FIXED CODE ###

s = input()


while len(s) > 0:
    if s[-6:] == 'eraser':
        s=s[:-6]
    elif s[-7:] == 'dreamer':
        s=s[:-7]
    elif s[-5:] == 'erase' or s[-5:] == 'dream':
        s=s[:-5]
    else:
        print('NO')
        exit(0)
print('YES')
from collections import Counter
import random
n,m = map(int,input().split())
grid = [list(input()) for i in range(n)]
def jc(a,b):
  l = len(a)
  used = [0]*l
  for i in range(l):
    if used[i]:
      continue
    for j in range(i,l):
      if used[j]:
        continue
      if a[i] == b[j] and b[i] == a[j]:
        used[i] = 1
        used[j] = 1
        break
  if used.count(1) == l:
    return True
  else:
    return False
def judge(a):
  h = len(a)
  w = len(a[0])
  if h%2 == 0:
    flg = 1
  else:
    flg = 2
  used = [0]*h
  for i in range(h):
    if used[i]:
      continue
    ci = Counter(a[i])
    for j in range(i+1,h):
      if used[j]:
        continue
      cj = Counter(a[j])
      if ci == cj:
        if jc(a[i],a[j]):
          used[i] = 1
          used[j] = 1
          break
  if used.count(0) < flg:
    return True
  else:
    return False
gt = list(zip(*grid))
flgx,flgy = 0,0
for _ in range(10):
  random.shuffle(grid)
  if judge(grid):
    flgx = 1
    break
for _ in range(10):
  random.shuffle(gt)
  if judge(gt):
    flgy = 1
    break
if flgx*flgy:
  print("YES")
else:
  print(2/0)

### FIXED CODE ###

from collections import Counter
n,m = map(int,input().split())
grid = [list(input()) for i in range(n)]
def jc(a,b):
  l = len(a)
  used = [0]*l
  for i in range(l):
    if used[i]:
      continue
    for j in range(i+1,l):
      if used[j]:
        continue
      if a[i] == b[j] and b[i] == a[j]:
        used[i] = 1
        used[j] = 1
        break
  if used.count(0) <= l%2:
    return True
  else:
    return False
def judge(a):
  h = len(a)
  w = len(a[0])
  used = [0]*h
  for i in range(h):
    if used[i]:
      continue
    ci = Counter(a[i])
    for j in range(i+1,h):
      if used[j]:
        continue
      cj = Counter(a[j])
      if ci == cj:
        if jc(a[i],a[j]):
          used[i] = 1
          used[j] = 1
          break
  if used.count(0) <= h%2:
    return True
  else:
    return False
gt = list(zip(*grid))
if judge(grid) & judge(gt):
  print("YES")
else:
  print("NO")
S = input()
N = len(S)
prev = S[0]
ans = 1
i = 1
while i < N:
  ans += 1
  if len(prev) == 2:
    prev = S[i]
    i += 1
    continue
  if prev == S[i] and i < N-1:
    i += 2
    prev = S[i] + S[i+1]
  elif prev == S[i]:
    ans -= 1
    break
  else:
    prev = S[i]
    i += 1
print(ans)

### FIXED CODE ###

S = input()
N = len(S)
prev = S[0]
ans = 1
i = 1
while i < N:
  ans += 1
  if len(prev) == 2:
    prev = S[i]
    i += 1
    continue
  if prev == S[i] and i < N-1:
    prev = S[i] + S[i+1]
    i += 2
  elif prev == S[i]:
    ans -= 1
    break
  else:
    prev = S[i]
    i += 1
print(ans)
import sys
input = sys.stdin.readline

def main():
  n = int(input())
  F = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    F[a].append(b)
    F[b].append(a)
  seenB = [False]*n
  seenW = [False]*n
  seenB[n-1] = True
  seenW[0] = True
  def dfs(v, seen):
    seen[v] = True
    rep = 1
    for nv in F[v]:
      if seen[nv]:
        continue
      rep += dfs(nv, seen)
    return rep
  aplusc = dfs(0, seenB) - 1
  bplusc = dfs(n-1, seenW) - 1
  print(aplusc, bplusc)
  c = aplusc + bplusc + 2 - n
  a = aplusc - c
  b = bplusc - c
  if c%2 == 0:
    if a > b:
      print("Fennec")
    else:
      print("Snuke")
  else:
    if a >= b:
      print("Fennec")
    else:
      print("Snuke")
      
if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def main():
  n = int(input())
  F = [[] for _ in range(n)]
  for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    F[a].append(b)
    F[b].append(a)
  seenB = [False]*n
  seenW = [False]*n
  distB = [0]*n
  distW = [0]*n
  def dfs(v, seen, dist):
    seen[v] = True
    for nv in F[v]:
      if seen[nv]:
        continue
      dist[nv] = dist[v] + 1
      dfs(nv, seen, dist)
  dfs(0, seenB, distB)
  dfs(n-1, seenW, distW)
  b, w = 0, 0
  for i in range(n):
    if distB[i] <= distW[i]:
      b += 1
    else:
      w += 1
  if b > w:
    print("Fennec")
  else:
    print("Snuke")
      
if __name__ == '__main__':
  main()
N = input()

if N % 2 == 0:
    print(0.5)
else:
    print(float((N//2+1)/N))
    

### FIXED CODE ###

N = int(input())

if N % 2 == 0:	
    print((N/2)/N)
else:
    print(((N+1)/2)/N)
N = int(raw_input())
a = []
for i in range(N):
	a.append(raw_input())
#print a
for i in range(N):
	a[i] = int(a[i])
cnt = 0
trn = 0
while trn != 1:
	if trn == -2:
		cnt = -1
		break
	#print a

	hako = trn
	trn = a[trn] - 1
	a[hako] = -1
	cnt += 1
	
print cnt


### FIXED CODE ###

a = raw_input().split()
for i in range(3):
	a[i] = int(a[i])

b = a[1] - a[2]
if b >= 0:
	print "delicious"
else:
	if a[0] + a[1] < a[2]:
		print "dangerous"
	else:
		print "safe"
import numpy as np

N, Q = map(int, input().split())
S = input()
ac_array = np.zeros(N)
ans = []

for i in range(N):
    if S[i] == 'A' and S[i+1] == 'C':
        ac_array[i] += 1
#         ac_array[i+1] += 1
# print(ac_array)
q_list = np.zeros([Q, 2])
for q in range(Q):
    q_list[q, 0], q_list[q, 1] = map(int, input().split())
    ans.append(ac_array[int(q_list[q, 0]-1):int(q_list[q,1]-1)].sum())

for a in range(Q):
    print(int(ans[a]))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)
ans = []

for i in range(N):
    t[i+1] += t[i] + ( 1 if S[i:i+2] == 'AC' else 0) 

for i in range(Q):
    l, r = map(int, input().split())
    ans.append(t[r-1] - t[l-1])
    
for i in range(Q):
    print(ans[i])
N,M = map(int,input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a_, b_ = map(int,input().split())
    # 配列の添字としたいので-1
    a[i] = a_ -1
    b[i] = b_ -1

route = [0]*N  # 通過済
connect=[[0]*M for _ in range(M)]
def dfs(now, depth):
    # print("#"*depth,now, depth)
    # 通過済ならNG
    if route[now]: return 0
    # depth = Nなら達成
    if depth == N: return 1
    
    route[now] = 1
    ans = 0
    for i in range(N):
        if connect[now][i]:
            ans += dfs(i, depth+1)
    route[now] = 0
    return ans

for i in range(M):
    connect[a[i]][b[i]] = connect[b[i]][a[i]] = 1

# for xx in connect:
#     print(xx)
print(dfs(0,1))

### FIXED CODE ###

N,M = map(int,input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a_, b_ = map(int,input().split())
    # 配列の添字としたいので-1
    a[i] = a_ -1
    b[i] = b_ -1

route = [0]*N  # 通過済
connect=[[0]*N for _ in range(N)]
def dfs(now, depth):
    # print("#"*depth,now, depth)
    # 通過済ならNG
    if route[now]: return 0
    # depth = Nなら達成
    if depth == N: return 1
    
    route[now] = 1
    ans = 0
    for i in range(N):
        if connect[now][i]:
            ans += dfs(i, depth+1)
    route[now] = 0
    return ans

for i in range(M):
    connect[a[i]][b[i]] = connect[b[i]][a[i]] = 1

# for xx in connect:
#     print(xx)
print(dfs(0,1))
N = int(input())
c=list(map(int, input().split()))

@jit
def search(N,c):
  count = 0
  for i in range(N):
    b = []
    m = copy.copy(c)
    a = c[i]
    m.pop(i)
    m.sort()
    for j in range(N-1):
      if m[j]>c[i]:
        count+=1
        break
      elif c[i]%m[j]==0:
        break
      elif j == N-2:
        count+=1
      elif c[i]%m[j]!=0:
        continue
      
  return count

print(search(N,c))
      
      
      
     
  
  

### FIXED CODE ###

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

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)
S = input()
 
if (S == 'AAA') or (S=='BBB'):
  print 'No'
else:
  print 'Yes'


### FIXED CODE ###

S = input()
 
if (S == 'AAA') or (S=='BBB'):
  print('No')
else:
  print('Yes')
a,b = map(int,input().split())

A = [1]
for i in range(2,11):
    tmp = A[-1] + i
    A.append(tmp)

dif = b-a
pos = dif - 2

print(A[pos] - a)

### FIXED CODE ###

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

A = [1]
for i in range(2,1000):
    tmp = A[-1] + i
    A.append(tmp)

dif = b-a
pos = dif - 2

print(A[pos] - a)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
from typing import List

def rdp_connect() -> bool:
    global s1, s2
    s1 = input()
    if s1 == '.':
        return False
    s2 = input()
    return True

def rdp_token(s: str) -> List[str]:
    res = []
    while s:
        match = re.match(r'[a-zA-Z0-9;]+', s)
        if match:
            res.append(s[:match.end()])
            s = s[match.end():]
            continue
        match = re.match(r'"[^"]*"', s)
        if match:
            res.append(s[:match.end()-1])
            s = s[match.end():]
            continue
    return res

def rdp_check() -> bool:
    l1 = rdp_token(s1)
    l2 = rdp_token(s2)
    if len(l1) != len(l2):
        return False
    flag = True
    for t1, t2 in zip(l1, l2):
        if t1 == t2:
            continue
        if t1[0] == t2[0] == '"' and flag:
            flag = False
        else:
            return False
    return True

if __name__ == '__main__':
    while rdp_connect():
        if s1 == s2:
            print('IDENTICAL')
        elif rdp_check():
            print('CLOSE')
        else:
            print('DIFFERENT')

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re

def rdp_connect() -> bool:
    global s1, s2
    s1 = input()
    if s1 == '.':
        return False
    s2 = input()
    return True

def rdp_token(s: str):
    res = []
    while s:
        match = re.match(r'[a-zA-Z0-9;]+', s)
        if match:
            res.append(s[:match.end()])
            s = s[match.end():]
            continue
        match = re.match(r'"[^"]*"', s)
        if match:
            res.append(s[:match.end()-1])
            s = s[match.end():]
            continue
        break
    return res

def rdp_check() -> bool:
    l1 = rdp_token(s1)
    l2 = rdp_token(s2)
    if len(l1) != len(l2):
        return False
    flag = True
    for t1, t2 in zip(l1, l2):
        if t1 == t2:
            continue
        if t1[0] == t2[0] == '"' and flag:
            flag = False
        else:
            return False
    return True

if __name__ == '__main__':
    while rdp_connect():
        if s1 == s2:
            print('IDENTICAL')
        elif rdp_check():
            print('CLOSE')
        else:
            print('DIFFERENT')
k = int(input().split('')[1])
sticks = sorted(list(map(int,input().split())),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)

### FIXED CODE ###

k = int(input().split()[1])
sticks = sorted(list(map(int,input().split())),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)
a,b,c =map(input().split())
print(a[0],b[0],c[0],sep="")

### FIXED CODE ###

a,b,c =input().split()
print(a[0].upper(),b[0].upper(),c[0].upper(),sep="")
def main(n, x_u):
    ans = 0
    btc = 380000.0

    for x, u in x_u:
        if u == 'JPY':
            ans += x
        else:
            ans += x * btc

    print(ans)


if __name__ == "__main__":
    n = int(input())
    x_u = [list(map(int, input().split())) for _ in range(n)]

    main(n, x_u)


### FIXED CODE ###

def main(n, x_u):
    ans = 0
    btc = 380000.0

    for x, u in x_u:
        if u == 'JPY':
            ans += int(x)
        else:
            ans += float(x) * btc

    print(ans)


if __name__ == "__main__":
    n = int(input())
    x_u = [input().split() for _ in range(n)]

    main(n, x_u)
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = int(prev * t / gcd(prev, t))
print(prev)


### FIXED CODE ###

def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 1
for i in range(n):
        t = int(input())
        prev = prev * t // gcd(prev, t)
print(prev)
a,b=map(int,input().split())
 
if (a*b) % 2 =0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
 
if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

if k - q > 0:
  res = ['Yes'] * n
else:
  res = ['No'] * n
  ans = [0] * n
  for i in range(len(a)):
    ans[a[i]-1] += 1
  for i in range(len(n)):
    if k - q + ans[i] > 0:
      res[i] = 'Yes'
print('\n'.join(map(str, res)))

### FIXED CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

if k - q > 0:
  res = ['Yes'] * n
else:
  res = ['No'] * n
  ans = [0] * n
  for i in range(len(a)):
    ans[a[i]-1] += 1
  for i in range(n):
    if k - q + ans[i] > 0:
      res[i] = 'Yes'
print('\n'.join(map(str, res)))
N = int(input())
height = map(int, input().split())

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
	if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+(height[n] - height[n-1]), temp2+(height[n] - height[n-2]))
    return minimum_jump[n]
     
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(1001000)

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

minimum_jump = [-1]*N
minimum_jump[0] = 0
minimum_jump[1] = abs(height[0] - height[1])

def frog_jump(n): #n is index of stone
  if minimum_jump[n] != -1:
    return minimum_jump[n]
  else:
    if minimum_jump[n-1] != -1:
      temp1 = minimum_jump[n-1]
    else:
      temp1 = frog_jump(n-1)
    if minimum_jump[n-2] != -1:
      temp2 = minimum_jump[n-2]
    else:
      temp2 = frog_jump(n-2)
    minimum_jump[n] = min(temp1+abs(height[n] - height[n-1]), temp2+abs(height[n] - height[n-2]))
    return minimum_jump[n]
  
print(frog_jump(N-1))
match_num=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int, input().split())
nums=sorted(list(map(int, input().split())),reverse=True)
INF=1000000
#max桁数
dp = [-INF for _ in range(N+1)]
dp[0]=0
usables=[]
for n in nums:
  usables.append(match_num[n])

for i in range(min(usables), N+1):
  tmp=[]
  for u in usables:
    if (i-u)>=0:
      tmp.append(dp[i-u])
  
  dp[i]=max(tmp)+1

remained_maches=N

ans=''  
for i in range(dp[N]):
  for j in range(M):
    if dp[remained_maches]-1==dp[remained_maches-usables[j]]:
      ans+=str(nums[j])
      remained_maches-=usables[j]
      break
        
print(ans)



### FIXED CODE ###

match_num=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int, input().split())
nums=sorted(list(map(int, input().split())),reverse=True)
INF=1000000
#max桁数
dp = [-INF for _ in range(N+1)]
dp[0]=0
usables=[]
for n in nums:
  usables.append(match_num[n])

for i in range(min(usables), N+1):
  tmp=[]
  for u in usables:
    if (i-u)>=0:
      tmp.append(dp[i-u])
  
  dp[i]=max(tmp)+1

remained_maches=N

ans=''  
for i in range(dp[N]):
  for j in range(M):
    if (remained_maches-usables[j])>=0:
      if dp[remained_maches]-1==dp[remained_maches-usables[j]]:
        ans+=str(nums[j])
        remained_maches-=usables[j]
        break
        
print(ans)
def sol():
    n=int(input())
    a=[int(i) for i in input().split()]
    ans=n
    p=0
    q=1
    while p<n-1:
        w=x=a[p]
        chk=0
        p+=1
        while p<n:
            w+=a[q]
            x^=a[q]
            q+=1
            if w!=x: break
            chk+=1
        p=q
        ans+=chk*(chk+1)//2
    print(ans)

if __name__=="__main__":
    sol()

### FIXED CODE ###

def sol():
    n=int(input())+1
    a=[int(i) for i in input().split()]+[2**21-1]
    ans=0
    i=j=w=x=0
    while i<n-1:
        while j<n and w==x:
            w+=a[j]
            x^=a[j]
            j+=1
        ans+=(j-i-1)
        w-=a[i]
        x^=a[i]
        i+=1
    print(ans)

if __name__=="__main__":
    sol()