{"raw_statement":[{"iden":"statement","content":"Bocchi the Builder just finished constructing her latest project: a laneway consisting of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck! She accidentally spilled black paint on some of the tiles. Now, some of the tiles are wet and the other tiles are dry. Bocchi must place warning tape around the perimeters of all wet areas. Can you help her determine how many metres of tape she needs?\n\nThe first triangular tile will point upwards. Each pair of adjacent tiles (that is, tiles that share a common side) will point in opposite directions. Each tile has a side length of $1$ metre."},{"iden":"input","content":"The first line of input will consist of one positive integer $C$, representing the number of columns.\n\nThe next two lines will each consist of $C$ integers separated by spaces. Each integer represents\nthe colour of a tile along the laneway, with `1` indicating that the tile is black (wet) and `0` indicating that the tile is white (dry).\n\nThe following table shows how the available 15 marks are distributed:\n\n| Marks | Description | Bound |\n| :----------: | :---------- | :----------: |\n| 3 | The laneway is not very long, black tiles are never adjacent and the second row is fully white. | $C \\le 2 \\times 10^3$ |\n| 3 | The laneway is not very long, black tiles may be adjacent and the second row is fully white. | $C \\le 2 \\times 10^3$ |\n| 5 | The laneway is not very long, black tiles may be adjacent and may appear in the second row. | $C \\le 2 \\times 10^3$ |\n| 4 | The laneway may be very long, black tiles may be adjacent and may appear in the second row. | $C \\le 2 \\times 10^5$ |\n"},{"iden":"output","content":"Output a single integer representing the length of tape Bocchi needs,in metres."},{"iden":"note","content":"**本题采用捆绑测试**。\n\n- Subtask $1$（$3$ points）：$C \\leq 2 \\times 10^3$，黑色三角形不相邻，第二行全部为白色三角形。\n- Subtask $2$（$3$ points）：$C \\leq 2 \\times 10^3$，黑色三角形可能相邻，第二行全部为白色三角形。\n- Subtask $3$（$5$ points）：$C \\leq 2 \\times 10^3$，黑色三角形可能相邻，第二行可能有黑色三角形。\n- Subtask $4$（$4$ points）：$C \\leq 2 \\times 10^5$，黑色三角形可能相邻，第二行可能有黑色三角形。\n\n样例 $1$ 图解：\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/5tfc7u5b.png)\n\n样例 $2$ 图解：\n\n![](https://cdn.luogu.com.cn/upload/image_hosting/4e22mx61.png)"}],"translated_statement":null,"sample_group":[["5\n1 0 1 0 1\n0 0 0 0 0","9"],["7\n0 0 1 1 0 1 0\n0 0 1 0 1 0 0","11"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}