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

n = int(input())
l = []
for _ in range(n):
    a = input()
    if a in l:
        l.remove(a)
    else:
        l.append(a)

print(len(l))

### FIXED CODE ###

from collections import defaultdict

n = int(input())
l = defaultdict(int)
for _ in range(n):
    a = input()
    l[a] += 1
ans = 0
for i in l.values():
    if i % 2 == 1:
        ans += 1
    else:
        pass
print(ans)
### BUGGY CODE ###

k = int(input())
i = 1
x = 7 % k
x0 = x
while x != 0:
	x = (10 * x + 7) % k
	i += 1
	if x == x0:
		print(-1)
		break
else:
	print(i)

### FIXED CODE ###

k = int(input())
i = 1
x = 7 % k
seen = {x}
while x != 0:
	x = (10 * x + 7) % k
	i += 1
	if x in seen:
		print(-1)
		break
	seen.add(x)
else:
	print(i)
### BUGGY CODE ###

import heapq

def solve(n, XL):
    blocked = [0] * n
    total = 0
    for i in range(n):
        ax, al = XL[i]
        for j in range(i + 1, n):
            bx, bl = XL[j]
            if ax - al < bx - bl < ax + al or ax - al < bx + bl < ax + al:
                blocked[i] -= 1
                blocked[j] -= 1
                total += 1
    count = 0
    heapq.heapify(blocked)
    while total > 0:
        total += heapq.heappop(blocked)
        count += 1
    return n - count

_n = int(input())
_XL = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _XL))


### FIXED CODE ###

n = int(input())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: lr[1])
count = 1
cur = LR[0][1]
for l, r in LR[1:]:
    if cur <= l:
        count += 1
        cur = r
print(count)
### BUGGY CODE ###

n = int(input())
s = input()#西→東方向でi番目並んだ人が向いている向きSi, E=東, W=西

#i番目をリーダーとするとき
#<i番目はE
#i<番目はW

ans = n - 1
for i in range(n):
    buf = 0
    for j in range(n):
        if j < i:
            if s[j] == 'W':
                buf += 1
        if j > i:
            if s[j] == 'E':
                buf += 1
    ans = min(ans, buf)
    
print(ans)

### FIXED CODE ###

n = int(input())
s = input() + ' '

w = [0] * (n + 1)
e = [0] * (n + 1)
bfW = 0
bfE = 0
for i in range(n+1):
    w[i] = bfW
    e[i] = bfE
    if s[i] == 'W':
        bfW += 1
    elif s[i] == 'E':
        bfE += 1

ans = n - 1
for i in range(n):
    myW = w[i]
    myE = e[n] - e[i + 1]
    ans = min(ans, myE + myW)
    
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
nums = []
for _ in range(N):
    a, b = map(int, input().split())
    nums += [a] * b
nums.sort()
print(nums[K - 1])

### FIXED CODE ###

N, K = map(int, input().split())
nums = []
for _ in range(N):
    a, b = map(int, input().split())
    nums.append([a, b])
cnt = 0
nums.sort()
for num in nums:
    cnt += num[1]
    if cnt >= K:
        print(num[0])
        break
### BUGGY CODE ###



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


N = int(input())
a = make_divisors(N)
b = []
c = []

for j in range(len(a)):
    for k in range(len(a)):
        if a[j] * a[k] == N:
            b.append([a[j],a[k]])

for l in range(len(b)):
    c.append(b[l][0] + b[l][1])

print(min(c) - 2)


### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

N = int(input())
a = make_divisors(N)
b = []
c = []

for j in range(len(a)):
    for k in range(len(a)):
        if a[j] * a[k] == N:
            b.append([a[j],a[k]])

for l in range(len(b)):
    c.append(b[l][0] + b[l][1])

print(min(c) - 2)
### BUGGY CODE ###

from collections import deque

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

A = [[] for i in range(N)]

for i in range(M) :
    l,r,d = map(int,input().split())
    l -= 1
    r -= 1
    
    A[l].append([r,d])
    A[r].append([l,-d])

dist = [False for i in range(N)]

ans = "Yes"

flg1 = 0
flg2 = 0

for i in range(N) :
    if flg1 :
        break
    
    if dist[i] :
        continue
    
    dist[i] = 0
    
    q = deque([i])
    
    while q :
        if flg2 :
            break
        
        now = q.pop()
        for to,d in A[now] :
            if not dist[to] :
                dist[to] = dist[now] + d
                q.append(to)
            
            elif dist[to] == dist[now] + d :
                continue
            
            else :
                ans = "No"
                flg1 = 1
                flg2 = 1
                break

print(ans)


### FIXED CODE ###

N,M = map(int,input().split())
A = [[] for i in range(N+1)]

for i in range(M) :
    l,r,d = map(int,input().split())
    
    l -= 1
    r -= 1
    
    A[l].append([r,d])
    A[r].append([l,-d])

distance = ["#" for i in range(N)]

ans = "Yes"

flg = 0

for i in range(N) :
    if flg == 1 :
        break
    
    if distance[i] != "#" :
        continue
    
    distance[i] = 0
    stack = [i]
    
    while stack :
        v = stack.pop()
        
        for to,d in A[v] :
            if distance[to] == "#" :
                distance[to] = distance[v] + d
                stack.append(to)
            
            elif distance[to] != distance[v] + d :
                ans = "No"
                stack = []
                flg = 1
                break
                

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

n = int(input())
li = list(map(int,input().split()))
m =1
for i in range(n):
    m = m*li[i]
if m > 10**18:
    print(-1)
else:
    print(m)

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
m =1
if 0 in li:
    print(0)
    exit()
for i in range(n):
    m *= li[i]
    if m > 10**18:
        print(-1)
        exit()
else:
    print(m)
### BUGGY CODE ###

n=int(input())
s=[]
for i in range(n):
    a=input()
    s.append(a)
d={}
t=0
for i in range(n):
    if s[i] not in d:
        d[s[i]]=1
        if t==0:
            t=1
    else:
        d[s[i]]+=1
        if t<d[s[i]]:
            t=d[s[i]]
b=[]
for i in range(n):
    if d[s[i]]==t and (s[i] not in b):
        b.append(s[i])
b.sort()
for i in range(len(b)):
    print(b[i])

### FIXED CODE ###

n=int(input())
s=[]
for i in range(n):
    s.append(input())
s.sort()
t=1
m=0
a=s[0]
for i in range(n-1):
    if s[i+1]==a:
        t+=1
    else:
        a=s[i+1]
        m=max(t,m)
        t=1
m=max(t,m)
t=1
x=[]
a=s[0]
for i in range(n-1):
    if s[i+1]==a:
        t+=1
    else:
        a=s[i+1]
        if t==m:
            x.append(s[i])
        t=1
if  t==m:
    x.append(s[len(s)-1])
for i in range(len(x)):
    print(x[i])
### BUGGY CODE ###

from collections import deque

n,k = map(int,input().split())

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

#ループを探す？

checked_list = [1]
que = deque([a[0]])


counter = 0
while True:
    counter += 1
    x = que.popleft()
    if counter == k:
        print(x)
        exit()
    if x in checked_list:
        startflg = checked_list.index(x)
        loop_length = counter - startflg
        loop_list = checked_list[startflg:counter]
        amari = (k-startflg) % loop_length
        print(loop_list[amari])
        exit()
    else:
        que.append(a[x-1])
        checked_list.append(x)



### FIXED CODE ###

from collections import deque
import sys

def main():
    input = sys.stdin.readline
    n,k = map(int,input().split())

    a = [int(x) for x in input().split()]

    #ループを探す？

    checked_dict = {1:0}
    que = deque([a[0]])

    counter = 0


    while True:
        counter += 1
        x = que.popleft()
        if counter == k:
            print(x)
            exit()
        if x in checked_dict:
            startflg = checked_dict[x]
            loop_length = counter - startflg

            inverse_dict = {v:k for k,v in checked_dict.items()}

            loop_list = [inverse_dict[i] for i in range(startflg,startflg+loop_length)]
            amari = (k-startflg) % loop_length
            print(loop_list[amari])
            exit()
        else:
            que.append(a[x-1])
            checked_dict[x] = counter

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

n=int(input())
a=[list(map(int,input().split()))for i in range(n)]
b=[list(map(int,input().split()))for i in range(n)]
a.sort(key=lambda x:x[0])
b.sort(key=lambda x:x[1],reverse=1)
ans=0
i,j=0,0
while i<n and j<n:
  if a[i][0]>b[j][0]:
    j+=1
    continue
  elif a[i][1]>b[j][1]:
    i+=1
  else:
    ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
a=[list(map(int,input().split()))for i in range(n)]
b=[list(map(int,input().split()))for i in range(n)]
a.sort(key=lambda x:x[1],reverse=1)
b.sort(key=lambda x:x[0])
ans=0
for i in a:
  for j in b:
    if i[0]<j[0] and i[1]<j[1]:
      b.remove(j)
      ans+=1
      break
print(ans)
### BUGGY CODE ###

from collections import deque
n, k = map(int, input().split())
a = list(map(int, input().split()))

prev = 1
for i in range(k):
    prev *= a[i]

a_old = deque(a)
s = [prev]
for i in range(k, n):
    old = a_old.popleft()
    score = prev*a[i] / old
    s.append(score)
    prev = score

for i in range(1, n-k+1):
    if s[i] > s[i-1]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

for i in range(n-k):
    if a[i+k] <= a[i]:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def f(m):
    ans = 0
    r_m = math.sqrt(m)
    for i in range(1, int(r_m) + 1):
        for j in range(1, int(r_m) + 1):
            for k in range(1, int(r_m) + 1):
                if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i == m:
                    ans += 1
    return ans


n = I()
for i in range(1, n + 1):
    print(f(i))


### FIXED CODE ###

import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def f(m):
    res = 0
    r_m = math.sqrt(m)
    for i in range(1, int(r_m) + 1):
        for j in range(1, int(r_m) + 1):
            for k in range(1, int(r_m) + 1):
                if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i == m:
                    print(f'{(m, i, j, k)=}')
                    res += 1
    return res


n = I()
cnt = [0] * 10001
r_n = int(math.sqrt(n)) + 1
for x in range(1, r_n):
    for y in range(1, r_n):
        for z in range(1, r_n):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v <= n:
                cnt[v] += 1

for i in range(1, n + 1):
    print(cnt[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
h_list = input().split()
h_list = [int(h) for h in h_list]

count = 0

for i in range(n):
    a_height = h_list[i]
    for k in range(i + 1, n):
        b_height = h_list[k]
        if k - i == a_height + b_height:
            count += 1

print(count)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
h_list = input().split()
h_list = [int(h) for h in h_list]

count = 0
result_dict = {}

for i in range(n):
    key = (i+1) + h_list[i]
    value = result_dict.get(key, 0)
    result_dict[key] = value + 1

for j in range(n):
    key = (j+1) - h_list[j]
    count += result_dict.get(key, 0)

print(count)
### BUGGY CODE ###

from collections import deque
import sys
s=input()
a,b =map(int,input().split())
o=[0,0,0]#x,y,向き
X=[1,0,-1,0]
Y=[0,1,0,-1]
q = deque()
q.append([0,0,0,0])
while q:
    x,y,z,k= q.popleft()
    if x==a and y==b and k==len(s):
        print('Yes')
        sys.exit()
    if k==len(s):
        continue
    if s[k]=='F':
        q.append([x+X[z],y+Y[z],z,k+1])
    else:
        q.append([x,y,(z+1)%4,k+1])
        q.append([x,y,(z-1)%4,k+1])
print('No')

### FIXED CODE ###

import sys
s=input()
A,B =map(int,input().split())
table=[[] for i in range(2)]#0が横1が縦
t = 0
k=0
for i in range(len(s)):
    if s[i]=='F':
        k+=1
    else:
        table[t].append(k)
        t=(t+1)%2
        k=0
table[t].append(k)
L=len(s)
Lx=[set() for i in range(len(table[0]) +1)]
Ly=[set() for i in range(len(table[1]) +1)]
Lx[0].add(0)
Ly[0].add(0)
for i in range(len(table[0])):
    x = table[0][i]
    if i==0:
        Lx[1].add(x)
        continue
    for a in Lx[i]:
        if -L<=a+x<=L:
            Lx[i+1].add(a+x)
        if -L<=a-x<=L:
            Lx[i+1].add(a-x) 
flag=True
for a in Lx[len(table[0])]:
    if a==A:
        flag =False
if flag:
    print('No')
    sys.exit()
    
for i in range(len(table[1])):
    x = table[1][i]
    for a in Ly[i]:
        if -L<=a+x<=L:
            Ly[i+1].add(a+x)
        if -L<=a-x<=L:
            Ly[i+1].add(a-x)
flag=True
for a in Ly[len(table[1])]:
    if a==B:
        flag =False
if flag:
    print('No')
    sys.exit()
    
print('Yes')
### BUGGY CODE ###

from itertools import product
n, k = map(int, input().split())
dots = [list(map(int, input().split())) for _ in range(n)]

ans = float("inf")
for a, b, c, d in product(dots, repeat=4):
	upper = max(a[1], b[1], c[1], d[1])
	lower = min(a[1], b[1], c[1], d[1])
	left = min(a[0], b[0], c[0], d[0])
	right = max(a[0], b[0], c[0], d[0])

	area = (upper - lower) * (right - left)
	num = 0
	for dot in dots:
		if left <= dot[0] <= right and lower <= dot[1] <= upper:
			num += 1
	if num >= k and 0 < area < ans:
		ans = area

print(ans)

### FIXED CODE ###

from itertools import combinations
n, k = map(int, input().split())
dots = sorted([list(map(int, input().split())) for _ in range(n)])

ans = float("inf")
for x1, x2 in combinations(range(n), 2):
	wid = dots[x2][0] - dots[x1][0]
	dots_cand = sorted(dots[x1: x2 + 1], key=lambda x: x[1])
	for y1, y2 in combinations(range(x2 + 1 - x1), 2):
		if y2 - y1 + 1 >= k:
			area = (dots_cand[y2][1] - dots_cand[y1][1]) * wid
			if area < ans:
				ans = area

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

from numpy import*;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;a%=h;i,j=searchsorted(sort(hstack((b%h-h,b%h))),(l-a,h-a));c+=sum(j-i)%2*l
print(c)

### FIXED CODE ###

from numpy import*;B,I=searchsorted,lambda:int32(input().split());input();a,b=I(),I();c=0
for k in range(29):l=2**k;h=l*2;x,y=a%h,sort(b%h);y=hstack((y-h,y));c+=sum(B(y,h-x)-B(y,l-x))%2*l
print(c)
### BUGGY CODE ###

from bisect import*
def main():
    root=[[],[]]
    def search_higher(key):
        ptr=root
        ret=None
        while ptr[1]:
            i=bisect(ptr[0],key)
            if i!=len(ptr[0]):ret=ptr[0][i]
            ptr=ptr[1][i]
        i=bisect(ptr[0],key)
        if i!=len(ptr[0]):ret=ptr[0][i]
        return ret
    def search_lower(key):
        ptr=root
        ret=None
        while ptr[1]:
            i=bisect_left(ptr[0],key)
            if i!=0:ret=ptr[0][i-1]
            ptr=ptr[1][i]
        i=bisect_left(ptr[0],key)
        if i!=0:ret=ptr[0][i-1]
        return ret
    def insert_rec(ptr,key):
        b_size=700
        if not ptr[1]:
            insort(ptr[0],key)
            if len(ptr[0])==b_size*2-1:
                ret=[ptr[0][:b_size],[]]
                ptr[0]=ptr[0][b_size:]
                return ret
        else:
            i=bisect(ptr[0],key)
            tmp=insert_rec(ptr[1][i],key)
            if tmp:
                ptr[0].insert(i,tmp[0].pop())
                ptr[1].insert(i,tmp)
                if len(ptr[1])==b_size*2:
                    ret=[ptr[0][:b_size],ptr[1][:b_size]]
                    ptr[0],ptr[1]=ptr[0][b_size:],ptr[1][b_size:]
                    return ret
    def insert(key):
        tmp=insert_rec(root,key)
        if tmp:root[0],root[1]=[tmp[0].pop()],[tmp,root]
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    insert(0)
    insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(search_higher(v)-v)*(v-search_lower(v))*i
        insert(v)
    print(c)
main()

### FIXED CODE ###

root=lambda x:x if par[x]==x else root(par[x])
same=lambda x,y:root(x)==root(y)
def unite(*z):
  x,y=map(root,z)
  if x!=y:
    if rank[x]<rank[y]:
      par[x]=y
      size[y]+=size[x]
    else:
      par[y]=x
      size[x]+=size[y]
      if rank[x]==rank[y]:rank[x]+=1
n,*a=map(int,open(0).read().split())
*par,=range(n)
rank=[1]*n
size=[1]*n
b=[0]*n
for i,t in enumerate(a):b[t-1]=i
c=0
for k in b[::-1]:
  l=r=1
  if k>0 and a[k-1]>a[k]:
    l+=size[root(k-1)]
    unite(k-1,k)
  if k+1<n and a[k+1]>a[k]:
    r+=size[root(k+1)]
    unite(k+1,k)
  c+=l*r*a[k]
print(c)
### BUGGY CODE ###

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

  num_ones = [0 for x in range(60)]
  powers_of_two = [1]
  for i in range(1,60):
    powers_of_two.append((powers_of_two[-1] * 2) % 1000000007)
  
  ans = 0
  for i in range(N-1,-1,-1):
    for j in range(60):
      if A[i] & 1 == 0:
        ans = (ans + powers_of_two[j] * num_ones[j]) % 1000000007
      else:
        ans = (ans + powers_of_two[j] * (N - i - 1 - num_ones[j])) % 1000000007
        num_ones[j] += 1
      A[i] >>= 1
  print(ans)
        
d()


### FIXED CODE ###

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

ans = 0
for i in range(60):
  p = 1 << i
  num_one = len([1 for x in A if x & p])
  ans = ans + p * num_one * (N - num_one)
print(ans % 1000000007)
### BUGGY CODE ###

import numpy as np
n, k = tuple(map(int, input().split()))

ans = 0
if k == 0:
    print(n*n)
    exit()
for a in range(max(1,k), n+1):
    ans += n-a
    b = np.arange(k+1, a+1)
    ans += np.sum((a%b)>=k)
print(ans)

### FIXED CODE ###

n, k = tuple(map(int, input().split()))

ans = 0
for b in range(max(1, k), n+1):
    ans += (b-k)*(n//b)
    if n%b >= k and k>0:
        ans += n%b-k+1
    elif n%b >= k:
        ans += n%b
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def bfs(v, graph, seen, next_v, rank):
    for x in graph[v]:
        if x in seen:
            continue
        next_v.append(x)
        rank.append(rank[0]+1)
        seen.append(x)


next_v = [0]
rank = [0]
seen = [0]
#bfs
while True:
    if len(next_v) == 0 or rank[0] == 3:
        ans = "IMPOSSIBLE"
        break
    if next_v[0] == N-1:
        ans = "POSSIBLE"
        break
    bfs(next_v[0], graph, seen, next_v, rank)
    next_v.pop(0)
    rank.pop(0)
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
graph = [[] for _ in range(N)] 
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def bfs(goal, graph, seen, next_v):
    for x in graph[next_v[0][0]]:
        if x == goal:
            return True
        if x in seen:
            continue
        next_v.append((x,next_v[0][1]+1))
        seen.add(x)
    return False


next_v = [(0,0)]
seen = {0}
#bfs
while True:
    if len(next_v) == 0 or next_v[0][1] == 2:
        ans = "IMPOSSIBLE"
        break
    if bfs(N-1, graph, seen, next_v):
        ans = "POSSIBLE"
        break
    next_v.pop(0)
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
ans = set(range(1,n+1))
for i in range(m):
  l,r=map(int,input().split())
  ans &= set(range(l,r+1))
print(len(ans))  

### FIXED CODE ###

n,m=map(int,input().split())
ansl = 1
ansr = n
for i in range(m):
  l,r=map(int,input().split())
  ansl = max(ansl,l)
  ansr = min(ansr,r)
print(max(0,ansr-ansl+1))
### BUGGY CODE ###

h, n = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
dp = [0] * (h + 1)
for i in range(1, h + 1):
    dp[i] = min(b if i - a < 0 else dp[i - a] + b for a, b in ab)
print(dp[h])

### FIXED CODE ###

h, n = (int(x) for x in input().split())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
max_a = max(a for a, _ in ab)
dp = [0] * (h + max_a)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in ab)
print(dp[h])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1114112)

n = int(input())
a,b,c = [],[],[]
for i in range(n):
    line = input()
    line = line.strip("\n").split(" ")
    a.append(int(line[0]))
    b.append(int(line[1]))
    c.append(int(line[2]))

def helper(i, prev=None, memo={}):
    if (i,prev) in memo: return memo[(i,prev)]

    if i >= n: return 0

    happ1 = 0 if prev == 'a' else a[i] + helper(i+1, 'a', memo)
    happ2 = 0 if prev == 'b' else b[i] + helper(i+1, 'b', memo)
    happ3 = 0 if prev == 'c' else c[i] + helper(i+1, 'c', memo)

    memo[(i,prev)] = max(happ1, happ2, happ3)
    return memo[(i, prev)]

print(helper(0))

### FIXED CODE ###

n = int(input())
a,b,c = [],[],[]
for i in range(n):
    line = input()
    line = line.strip("\n").split(" ")
    a.append(int(line[0]))
    b.append(int(line[1]))
    c.append(int(line[2]))

def bottomup(a, b, c):
    dp = [[0 for _ in range(3)] for _ in range(n)]
    
    dp[(n-1)] = [a[n-1], b[n-1], c[n-1]]

    for i in range(n-2,-1,-1):
        dp[i][0] = a[i] + max(dp[i+1][1:])
        dp[i][1] = b[i] + max(dp[i+1][0], dp[i+1][2])
        dp[i][2] = c[i] + max(dp[i+1][:2])
    
    return max(dp[0])
    
print(bottomup(a,b,c))
### BUGGY CODE ###

s = input() + 'R'


t = []
b = 0
for i in range(1, len(s)):
    if s[i - 1] + s[i] == 'LR':
        t.append(s[b:i])
        b = i

ans = []


for ss in t:
    nR = ss.find('L')
    nL = len(ss) - nR

    R = nR // 2 + (nR % 2) + nL // 2
    L = nL // 2 + (nL % 2) + nR // 2
    ans = ans + [0 for _ in range(nR - 1)]+[R] + \
        [L] + [0 for _ in range(nL - 1)]

for i in range(len(ans)):
    if i != 0:
        print(' ', end='')
    print(ans[i],end='')

### FIXED CODE ###

s = input() + 'R'


t = []
b = 0
for i in range(1, len(s)):
    if s[i - 1] + s[i] == 'LR':
        t.append(s[b:i])
        b = i

ans = []


for ss in t:
    nR = ss.find('L')
    nL = len(ss) - nR

    R = nR // 2 + (nR % 2) + nL // 2
    L = nL // 2 + (nL % 2) + nR // 2

    ans += [0 for _ in range(nR - 1)]+[R, L] + [0 for _ in range(nL - 1)]

for i in range(len(ans)):
    if i != 0:
        print(' ', end='')
    print(ans[i],end='')