We need to parse the problem: It says "if two slimes of the same color are adjacent, they will start to combine themselves." So we want to avoid any adjacent pair of same color. We can change the color of any slime to any of 10000 colors. Goal: minimum number of changes so that the resulting sequence has no two adjacent equal.
We have N up to 100, colors given a_i are between 1 and N (since constraints: 1 <= a_i <= N, though there are 10000 colors available). So essentially we have a sequence of length N, we want to change some positions to new colors (any colors) to ensure adjacent equality is eliminated.
But note: we can choose any colors from the huge palette, so we can always assign a new distinct color to a changed position as needed to avoid conflicts with neighbors. However, if we change a position, we also want to minimize number of changes. This is essentially a problem: given a string (or sequence) of colors, we need to make it such that no two adjacent are equal. Each change can turn a character into any other (from huge set). This is reminiscent of "minimum edits to make a string with no two adjacent equal". Since we can change to any color, the optimal strategy is to leave as many positions unchanged as possible while ensuring the sequence after changes has no adjacent equals. This is like we need to find a maximum size subset of indices that we keep unchanged, such that among those kept positions, no two consecutive in the original order (adjacent in the sequence) have the same color, and also they are not adjacent? Actually if we keep two adjacent positions unchanged, they must have different colors, because otherwise they'd be equal adjacent and cause combination. So we need to choose a subset of positions to keep unchanged (the rest we will change) such that if i and i+1 are both kept, then a_i != a_{i+1}. Also, we can change any other positions to any colors, so we can always fix the neighbors appropriately. But note: if we change some positions, we can assign them colors that avoid conflicts with both neighbors. Since we have many colors, we can always assign a color that is different from both neighbors (if they are kept or changed). But careful: changed positions themselves might create new adjacent equal pairs if we assign same color to two adjacent changed positions. But we can assign them arbitrarily to avoid that. So the only constraints are the ones we enforce by keeping some positions unchanged: those must not conflict with each other. So the problem reduces to: find the largest subset of indices we can keep unchanged such that no two kept adjacent indices have the same color. Then answer = N - size of that subset.
But is that always correct? Consider that we can also potentially keep some positions unchanged but modify others to something that may cause conflict with kept ones? But we can choose the colors for changed positions arbitrarily, so we can always avoid creating new conflicts: For each changed position, we can assign a color that is different from its left neighbor (if any) and different from its right neighbor (if any). Since there are 10000 colors available, we can always pick a color not equal to the left neighbor's color (which may be original or assigned) and not equal to the right neighbor's color. However, we need to consider the possibility that the left neighbor is also changed, and we might assign colors to both changed neighbors that could conflict with each other, but we can assign them sequentially to avoid conflict. As long as we have enough colors, we can always assign distinct colors to each changed position that differ from both neighbors. Actually we need to guarantee existence of an assignment after choosing which positions to keep unchanged. This is essentially a graph coloring problem on a path where some vertices have fixed colors, others are free. The path graph: vertices 1..N, edges between i and i+1 require colors different. Some vertices have predetermined colors (the ones we keep unchanged). For the free vertices, we need to assign colors from a large set such that all edges have different colors at endpoints. Since the path is bipartite? Actually it's just a path. This is always possible as long as for any edge where both endpoints are fixed, they are different (that's our constraint). For edges where at least one endpoint is free, we can always assign a color to the free endpoint to be different from the neighbor. However, if both endpoints are free, we need to assign them different colors, but we can do so because we can assign them arbitrarily. With a large enough palette, it's trivial: assign each free vertex a color distinct from its neighbors; you can just assign colors 1,2,3,... in order ensuring each edge has different colors, because you have unlimited colors. The only potential issue is if we have constraints that propagate? For a path, we can color greedily from left to right: for each vertex, if it's fixed, keep it; else assign any color different from left neighbor (and maybe also different from right neighbor? But we can't see right neighbor yet). But when we get to the next vertex, it might conflict because we assigned a color to the current free vertex that is same as the right neighbor if that right neighbor is fixed. But we can handle it: for a free vertex, we need to choose a color that is different from both neighbors? Actually edge constraints: for each edge (i,i+1), we need c_i != c_{i+1}. So for a free vertex i, it needs to be different from i-1 and i+1. But when we assign colors sequentially, we don't yet know c_{i+1} if it is free. But we can assign a color to i such that it's different from c_{i-1}. Then when we get to i+1, if it's free, we assign it a color different from c_i. So that ensures c_i != c_{i+1}. But does it guarantee that c_{i+1} is different from c_{i+2}? That will be handled later. However, we must also ensure that if i+1 is fixed, then we need c_i != c_{i+1}. Since we can choose c_i after knowing c_{i+1} if it's fixed? But if we process from left to right, we know c_{i+1} only if it's fixed; if it's fixed, we know its value. So we can choose c_i such that it's different from both c_{i-1} and c_{i+1} (if known). But if we are processing left to right and i+1 is fixed, we can see that. So we can assign c_i accordingly. Since we have many colors, we can always pick a color not equal to those constraints (at most 2 constraints). So feasible if we have at least 3 colors? But we have 10000, so it's fine. What if both neighbors are fixed and are the same? Then the edge constraints require c_i != left and c_i != right, but if left and right are same, then we need a color different from that value. That's possible as long as there exists at least one other color, which there is. So if a vertex is free, it's always possible to assign a color to satisfy its incident edges, as long as we have at least 2 colors? Wait: what if both neighbors are fixed and they are different? Then we need c_i != left and c_i != right. That requires a third color if left and right are different. Since we have many colors, it's possible. So any free vertex can be colored as long as we have at least 3 colors? But we have 10000, so it's fine.
Therefore, the problem reduces to: find a maximum set of indices to keep unchanged such that for any two adjacent indices both kept, their original colors are different. That's a classic problem: given a sequence, we want to select a subset of positions to keep (cannot have adjacent equal if both kept). Equivalent to: we need to delete some positions (change them) to break any adjacent equal pairs among the kept positions. But also note: if we have three consecutive positions where the first and third are same color, but the middle is different or same? Actually if we keep the first and third, they are not adjacent, so no problem. So constraints are only on adjacent kept positions. So we want to keep as many as possible, but we cannot keep two adjacent positions if they have the same original color. However, we could keep two adjacent positions if they have different colors. So it's allowed. So the problem is: given a sequence, we want to pick a subset of indices to retain, maximizing size, with the condition that for any i, if both i and i+1 are selected, then a_i != a_{i+1}. This is similar to a maximum independent set on a graph where edges exist between i and i+1 if a_i == a_{i+1}? Actually constraint only prohibits selecting both endpoints of an edge if the colors are equal. So it's like a graph with edges connecting i and i+1, each edge has a condition: if a_i == a_{i+1}, then we cannot select both; if a_i != a_{i+1}, then it's allowed to select both. So the constraint is only for equal-adjacent pairs. So we can think: we must break all adjacent equal pairs: for any i where a_i == a_{i+1}, at least one of them must be changed. So it's like covering constraints: for each i with a_i == a_{i+1}, we need to select at least one of i, i+1 to be changed. Then we want to minimize the number of changes. That's a classic minimum vertex cover on a set of edges, but here the edges are only those where a_i == a_{i+1}, and we want to select minimum number of vertices to "break" all those edges (i.e., ensure that each such edge has at least one endpoint changed). However, is that exactly the problem? Let's test: If we change at least one in each adjacent equal pair, then after changes we can assign colors to changed positions to ensure no adjacent equals. But is it sufficient? Suppose we have a pattern: colors 1, 2, 1. There are no adjacent equal pairs, so we don't need to change any, and answer is 0. The vertex cover approach would have no edges, so minimum changes=0. OK.
Consider: 1,1,2. There is one edge (1,2) equal. If we change either position 1 or 2, then the remaining sequence after changes (but we have to assign new colors to changed ones appropriately) can be made conflict-free. For example, change position 1 to 3, we get 3,1,2 -> no adjacent equals. Or change position 2 to 3: 1,3,2. So answer is 1. Minimum vertex cover on a single edge is 1. Good.
Consider: 1,1,1. There are edges (1,2) and (2,3) both equal. Minimum vertex cover on a path of three vertices with edges both present: we need to select vertices such that each edge covered. The minimum is 1? Actually can we cover both edges by selecting vertex 2? That covers both edges. So vertex cover suggests 1 change. But is it possible to only change vertex 2 and achieve no adjacent equal? If we change vertex 2 to some color X, then we have colors: 1, X, 1. Adjacent pairs: (1, X) are different if X != 1; (X,1) are different if X != 1. So yes, if we set X not equal to 1, we have no adjacent equal. So answer would be 1. But the example given in problem: Input 5: 1 1 1 1 1 output is 2. Wait, check: For N=5 all ones, the answer is 2. That suggests that minimum changes is 2, not 1. Let's examine: For N=5 all ones, can we change only one slime to break all adjacent equalities? Suppose we change position 3 to color 2. Then sequence: 1,1,2,1,1. Adjacent pairs: (1,1) at positions 1-2 are still equal -> they combine. So we have an adjacent equal pair (positions 1 and 2). So that's not allowed. Changing only one cannot break all pairs because the pairs are not all incident to a single vertex. The edges: (1,2), (2,3), (3,4), (4,5). Minimum vertex cover on a path of 5 vertices with all edges present. The minimum vertex cover size for a path of length 5 (5 vertices) is floor(N/2) = 2? Actually for a path graph, the size of minimum vertex cover is ceil(N/2)?? Wait, standard: For a path graph with n vertices, maximum matching size is floor(n/2). Minimum vertex cover size equals maximum matching size (by Kőnig's theorem for bipartite graphs). For a path of 5 vertices, maximum matching size is 2 (e.g., edges (1,2) and (3,4) or (2,3) and (4,5)), so min vertex cover = 2. So that matches example output 2. So indeed, the problem reduces to minimum vertex cover on the graph where vertices are positions and edges connect i and i+1 if a_i == a_{i+1}. Because we need to change at least one endpoint of each such edge to ensure that after changes, no two adjacent are same. But is that condition sufficient? Let's reason.
We have a sequence. We decide which positions to change (set C) and which to keep (set K). After changes, we assign new colors to changed positions arbitrarily. We want the final sequence to have no adjacent equal. This is possible iff there is an assignment of colors to changed positions that satisfies all adjacent inequality constraints. As argued, if we have a set K of kept positions with original colors, the constraints are: for each i, final c_i must be different from c_{i+1}. If both i and i+1 are kept, then we need a_i != a_{i+1}. So for any adjacent pair both in K, we must have a_i != a_{i+1}. That's a necessary condition. If we have an adjacent pair where at least one is changed, we can assign colors to changed positions to satisfy inequality, as we have many colors. However, is it always possible to assign colors to changed positions such that all edges are satisfied, given that kept positions have fixed colors? We need to check if there can be a situation where it's impossible even though each kept-kept edge has different colors. For a path, it's always possible to assign colors to the free vertices given a sufficiently large palette, because it's a 2-SAT? Actually it's like list coloring: each free vertex can be any color except possibly some constraints from neighbors. Since the graph is a path, we can do greedy: process from left to right, assign each free vertex a color that is different from its left neighbor (which might be fixed or already assigned) and also different from its right neighbor if that neighbor is fixed (we can look ahead). But if we assign greedily only based on left neighbor, we might cause conflict with a fixed right neighbor if the left neighbor's assignment equals that fixed color? Wait: Suppose we have a pattern: K (kept) at position i, unknown at i+1 (changed), K at i+2 (kept). Suppose kept colors: at i, color 1; at i+2, color 1 as well. If we assign i+1 a color that is not equal to left (1) and not equal to right (1). So we need a color different from 1. That's possible. In greedy left-to-right, when we reach i+1, we know left color (already assigned or kept) and we know right color if it's kept (since it's fixed). So we can pick a color not equal to both. If right is not kept, we don't know its assignment yet, but we only need to avoid conflict with left. When we later assign i+2, we will ensure it is different from i+1. Since i+2 is kept (color 1), we must have i+1 != 1. So we must ensure i+1 != 1. So when we assign i+1, we can choose any color != left, but also we need to consider that the right neighbor is kept with color 1, so we need i+1 != 1. So we need to know that. Since we can see ahead (i+2 is kept), we can incorporate that constraint. So as long as we have at least 2 colors if only left constraint, or 3 colors if both left and right are kept and have two distinct colors? Actually we need at least one color that is not equal to the left color and not equal to the right color. That requires at most 2 forbidden colors. Since we have 10000, it's possible as long as we have at least 1 available color. If left and right are both the same color (say 1), we need a color != 1, which is possible (9999 choices). If they are different, say left=1, right=2, we need a color different from 1 and 2, which is also possible (9998 choices). So always possible. For cases where both neighbors are changed and we haven't assigned them yet, we can assign later to avoid conflict. So indeed, any selection K that satisfies that no two adjacent kept positions have equal original colors can be extended to a full assignment.
Thus, the problem is to find the minimum number of changes, i.e., the minimum size of C such that for every i where a_i == a_{i+1}, at least one of i, i+1 is in C. That is exactly a vertex cover problem on the graph G where edges are defined for each adjacent equal pair. Because we need to "break" each such edge by changing at least one endpoint.
But wait: is it necessary that we must change at least one endpoint of every equal adjacent pair? If we keep both endpoints unchanged, then they are adjacent and equal, which violates condition. So yes, for each i with a_i == a_{i+1}, at least one must be changed. So condition necessary.
Thus the answer is the size of a minimum vertex cover in this graph, which is a set of edges that forms a collection of disjoint intervals? Actually the edges are only between consecutive indices, and they exist only where a_i == a_{i+1}. The graph is a subgraph of a path; it's a union of paths (maybe isolated vertices). Since the edges only exist where equality holds, the graph might consist of several connected components: each maximal run of consecutive equal elements creates a path (a chain) of length equal to the number of elements in the run, with edges between consecutive positions in that run. Actually if we have a run of k equal numbers, then there are (k-1) edges connecting them (i to i+1, i+1 to i+2, ...). So the graph is a set of disjoint paths (each path being a run of equal elements). However, note that these runs are separate: between runs, the colors are different, so no edge. So the vertex cover problem decomposes over each run. For each run of equal numbers of length L (L >= 1), we have a path graph of L vertices, with edges connecting consecutive vertices (L-1 edges). We need to select a minimum vertex cover for that path. Minimum vertex cover for a path of L vertices is floor(L/2). Actually check: For a path of length L (vertices), minimum vertex cover size = floor(L/2). Because maximum matching size is floor(L/2). For a path of L vertices, matching can take edges (1,2), (3,4), ... So maximum matching size = floor(L/2). So min vertex cover = floor(L/2). But is that always optimal? Let's test: L=1: no edges, min cover = 0. L=2: one edge, min cover = 1 (floor(2/2)=1). L=3: edges: (1,2),(2,3) -> min cover=1 (floor(3/2)=1) as we saw. L=4: min cover=2 (floor(4/2)=2). L=5: min cover=2? floor(5/2)=2, but is it possible to cover all edges with 2 vertices? For path 1-2-3-4-5 with edges 1-2,2-3,3-4,4-5. Selecting vertices 2 and 4 covers edges: 1-2 (2), 2-3 (2), 3-4 (4), 4-5 (4). Yes. So floor(L/2) works. So the answer would be sum over runs of floor(L_i/2). But let's test with examples:
Example 1: 5 numbers: 1 1 2 2 2 => runs: [1,1] length 2 -> floor(2/2)=1, [2,2,2] length 3 -> floor(3/2)=1, total=2. Output is 2. Correct.
Example 2: 3 numbers: 1 2 1 => runs: each length 1, sum=0. Output 0. Correct.
Example 3: 5 all ones: run length 5 -> floor(5/2)=2. Output 2. Correct.
Example 4: 14 numbers: 1 2 2 3 3 3 4 4 4 4 1 2 3 4. Let's identify runs: a1=1 (diff from next 2) => run length1 for 1. Then 2,2 -> run length2 (positions 2-3?) Actually a2=2, a3=2 => run length2. Then 3,3,3 => run length3. Then 4,4,4,4 => run length4. Then 1 (position 11) is alone? Check: after the four 4's, a11=1, a12=2, so 1 alone => length1. Then a12=2, a13=3? Actually a12=2, a13=3, so 2 alone => length1. a13=3, a14=4, so 3 alone => length1. a14=4 alone => length1. So runs: lengths: 1,2,3,4,1,1,1,1. floor: 0,1,1,2,0,0,0,0 sum=4. Output=4. Correct.
So the answer appears to be sum over maximal consecutive equal runs: floor(length/2). This is a simple O(N) solution.
But wait, is there any nuance? Could there be a scenario where we change a position and affect multiple runs? Since runs are separated by different colors, edges only within runs. So indeed the problem decomposes. And the minimum number of changes to break all adjacent equal pairs is exactly the sum of floor(run_length/2). But is this always optimal? Let's think if there's any cross-run interaction that could allow fewer changes? For example, consider two runs separated by a different color. If we change a position in one run, it might affect the boundary between runs? But the boundary is between different colors originally, so there is no edge there. Changing a boundary element could potentially create a new adjacent equal pair with the neighbor from the other run? However, we are allowed to assign new colors to changed positions. If we change a boundary element, we could assign it any color, and we can choose it to avoid equality with the neighbor. So changing a boundary element does not create a problem, but could it help reduce changes needed within a run? Perhaps we could change a position that is at the end of a run, thereby breaking multiple edges within the run? But the vertex cover approach already accounts for covering edges within runs. Changing an endpoint of a run can cover edges incident to it. In a path, the min vertex cover is floor(L/2). That's the optimal. So cross-run doesn't help because edges are independent.
But one more nuance: We are allowed to change colors to any of 10000 colors. However, after changes, the final sequence might have new adjacent equalities if we assign colors carelessly. But we can assign them appropriately, as argued. So the minimal changes is indeed the min vertex cover size.
But is there any scenario where it's beneficial to change a position that is not in the vertex cover? For example, if we change extra positions, maybe we can cover edges with fewer? No, vertex cover is exactly set of changed positions. If we change a position, it's in C. The condition is that for every edge (i,i+1) with a_i==a_{i+1}, at least one of i,i+1 is in C. So C must be a vertex cover of the graph defined by equal-adjacent edges. Conversely, any vertex cover yields a set of changes that satisfy the condition (since we can assign colors to changed vertices to avoid conflicts). So the minimum number of changes equals the minimum vertex cover size.
Thus the solution: compute runs of consecutive equal elements, sum floor(len/2).
But is there a possibility that after changing some vertices, we might create new equal-adjacent pairs due to the new colors? Since we can choose colors arbitrarily, we can avoid that. So yes.
Thus answer = sum over runs of (len // 2).
But wait, the sample 4 gave answer 4, which matches.
Thus the problem is trivial: just iterate and count.
However, let's double-check with more complex cases: N=2, a=[1,1] => run length 2 -> floor(2/2)=1, answer 1. Indeed we need to change one.
N=2, a=[1,2] => runs both length1 => sum=0, answer 0.
N=3, a=[1,1,1] => length 3 -> floor(3/2)=1, answer 1. But is it possible with 1 change? Change middle to 2: [1,2,1] no adjacent equals. Change leftmost: [2,1,1] gives last two equal, so not good. So must change the middle. So yes 1.
N=4, all ones -> length 4 -> floor(4/2)=2. Can we do with 2 changes? Yes: change positions 2 and 4? But then [1, X,1,X] might have X same? But we can choose distinct if needed. Actually change positions 2 and 4: we need to ensure after changes, no adjacent equal: Let positions: 1=1, 2=c2, 3=1, 4=c4. Conditions: c2 != 1, and 1 != c2? Already. Also 3=1 != c4, and c4 != 1? Actually edges: (1,2): 1 != c2; (2,3): c2 != 1; (3,4): 1 != c4. So as long as c2 != 1 and c4 != 1, it's fine. So yes. Could we do with 1 change? If we change position 2 only: [1,c2,1,1] then (3,4) are both 1 -> equal. So not. Change position 3 only: [1,1,c3,1] then (1,2) both 1 -> equal. So need at least 2. So correct.
Thus answer formula holds.
Now, given N up to 100, it's easy.
But let's think if there is any twist: The problem statement says "If two slimes of the same color are adjacent, they will start to combine themselves." And "Takahashi can change the color of one slime to any of the 10000 colors by one spell. How many spells are required so that no slimes will start to combine themselves?" So we want to avoid any adjacent equal colors. So indeed.
Thus solution: count consecutive equal groups; for each group, add floor(count/2). Print that sum.
Now, we must confirm if there is any scenario where changing a slime might cause new adjacency issues that cannot be resolved because of the limited palette? But palette size is 10000, which is > N, so definitely enough.
Edge cases: If there is a run of length 1, floor(1/2)=0. So only runs of length >= 2 contribute.
Implementation: read N, read list a. Iterate i from 0 to N-1, keep current run length start. Or simply count while a[i]==a[i-1] and accumulate.
Pseudo:
count = 1
ans = 0
for i in range(1, N):
if a[i] == a[i-1]:
count += 1
else:
ans += count // 2
count = 1
ans += count // 2 # last run
print(ans)
That's it.
But wait, let's verify with sample 4:
a = [1,2,2,3,3,3,4,4,4,4,1,2,3,4]
i=1: 2 !=1 -> run length 1 -> ans+=0, count=1
i=2: 2==2 -> count=2
i=3: 3 !=2 -> ans+=2//2=1 -> count=1
i=4: 3==3 -> count=2
i=5: 3==3 -> count=3
i=6: 4 !=3 -> ans+=3//2=1 -> count=1
i=7: 4==4 -> count=2
i=8: 4==4 -> count=3
i=9: 4==4 -> count=4
i=10: 1 !=4 -> ans+=4//2=2 -> count=1
i=11: 2 !=1 -> ans+=1//2=0 -> count=1
i=12: 3 !=2 -> ans+=1//2=0 -> count=1
i=13: 4 !=3 -> ans+=1//2=0 -> count=1
end: ans+=1//2=0 -> total = 1+1+2 =4. correct.
Thus answer.
But is there any scenario where we might achieve fewer changes by not strictly following the vertex cover? For instance, consider runs of equal colors that are separated by a color that appears elsewhere, but if we change that separating color to something else, we might merge runs? But that would only add constraints, not reduce. No.
What if we change a slime not in a run to break runs indirectly? For example, suppose we have sequence: 1,1,2,2. Runs: [1,1] length2 -> floor=1, [2,2] length2 -> floor=1, total 2 changes. But could we do with 1 change? Maybe change the middle element (position 2 or 3) to something else. Let's try: original: 1,1,2,2. If we change position 2 (the second 1) to 3: becomes 1,3,2,2. Adjacent pairs: (1,3) ok; (3,2) ok; (2,2) equal -> not allowed. If we change position 3 (first 2) to 3: 1,1,3,2 -> (1,1) equal -> not allowed. If we change position 2 to 2: 1,2,2,2 -> (2,2) and (2,2) still problems. So indeed need at least 2 changes. So sum floor works.
Consider more complex: 1,1,1,2,2,2,2. Runs: len3 and len4 -> floor=1+2=3. Could we do with 2 changes? Possibly by changing a position to merge runs? Actually if we change position 3 (the third 1) to 2, we get 1,1,2,2,2,2,2? Wait original: indices:1:1,2:1,3:1,4:2,5:2,6:2,7:2. If we change index 3 to 2: we get 1,1,2,2,2,2,2. Now runs: [1,1] length2, [2,2,2,2,2] length5. Then floors: 1 + 2 = 3? floor(5/2)=2, so total 3. Actually we still have 1 change, but we might need more. After change, we still have adjacent equal pairs: (1,2) both 1 -> problem. So we need to change at least one of 1 or 2. So additional changes needed. Could we change index 2 to something else? That would be second change. Let's try: change index 3 to 2, and also change index 1 to something else? But then total changes = 2? Let's attempt: Change index 1 to 3, and index 3 to 2. Sequence: 3,1,2,2,2,2,2. Now check: (3,1) ok, (1,2) ok, (2,2) equal at (3,4)?? Actually positions: 3->2, 4->2 (original 2). So index3 and index4 both 2 -> adjacent equal. So still problem. Could change index4 as well? That would be 3 changes. So it seems at least 3 changes required. So sum floor is correct.
Thus solution is simple.
But before finalizing, think if there is any hidden condition: "If two slimes of the same color are adjacent, they will start to combine themselves." It might be that after combining, they become one slime? The problem statement: "If two slimes of the same color are adjacent, they will start to combine themselves." It doesn't say they combine immediately and change the configuration; it just says they start to combine, which we want to avoid. So we just need to avoid any adjacent equal colors.
Thus answer is sum_{runs} floor(length/2).
But is there any situation where a run length is even and floor(length/2) might be achieved by selecting every other vertex? That yields a vertex cover of size floor(L/2). Yes.
Thus implement.
Now, the problem constraints: N <= 100, a_i <= N (not necessarily <= 10000). But we don't need to use the 10000 colors except conceptually.
Thus final answer: compute runs and sum half lengths integer division.
Edge case: N up to 100, but runs may be as large as 100, so integer arithmetic fine.
One more thought: Could there be an alternative where we change a slime to a color that is the same as its other neighbor but not its immediate neighbor? That wouldn't help. So fine.
Therefore, we can just output sum(len_i//2).
Now, confirm with more random tests: Suppose N=6: 1,2,2,2,2,1. Runs: [1] len1, [2,2,2,2] len4, [1] len1. Sum floors: 0+2+0=2. Can we do with 2 changes? Possibly change positions 2 and 5? Let's try: change pos2 to 3, pos5 to 3? But then we need to ensure no adjacent equals. Original: 1,2,2,2,2,1. Change pos2 to 3, pos5 to 3: becomes 1,3,2,2,3,1. Check pairs: (1,3) ok, (3,2) ok, (2,2) equal -> positions 3 and 4 both 2 -> problem. So need to break the inner run of 2's. The run of four 2's: indices 2? Actually original run of 2's: indices 2,3,4,5 (since after changes, we changed index2 and index5, but index3 and index4 remain 2). Now indices 3 and 4 are adjacent 2 and 2. So we need to change at least one of them. So total changes at least 3? But our formula gave 2. So maybe there is a better selection: Instead of changing index2 and index5, we could change index3 and index4? That would be 2 changes: change both middle 2's to something else. For instance: change index3 to 3, index4 to 3? But then we might have 3 and 3 adjacent? Actually after changes: indices:1=1,2=2,3=3,4=3,5=2,6=1. Check: (1,2) 1-2 ok, (2,3) 2-3 ok, (3,4) 3-3 equal -> problem. So we cannot change both to the same color if they become adjacent. But we can change them to different colors: change index3 to 3, index4 to 4. Then sequence: 1,2,3,4,2,1. Check: (2,3) ok, (3,4) ok, (4,2) ok. So that works. So 2 changes (positions 3 and 4) indeed break all equal adjacent pairs. So our formula 2 works.
But what about the earlier attempt: changing pos2 and pos5 failed because we left indices 3-4 as 2-2. So the vertex cover must cover each edge. In the run of four 2's (indices 2,3,4,5), the edges are (2-3),(3-4),(4-5). Minimum vertex cover is size 2, e.g., {3,4} covers edges (2-3),(3-4),(4-5). Or {2,4} or {3,5} also. Our selection {2,5} does not cover edge (3-4) because neither 3 nor 4 is changed. So indeed not a vertex cover. So the vertex cover approach is correct.
Thus answer is indeed sum over runs of floor(length/2).
Now, is there any subtlety about the fact we can change colors to any of 10000, but we might have to ensure that the changed colors do not accidentally create new equalities with other changed colors? But as argued, we can assign them appropriately. So it's fine.
Thus we have a very simple solution.
Given the problem statement, it's a typical AtCoder ABC problem? Possibly AtCoder ABC 064 B? Actually I recall a problem: "Colorful Slimes" or something? But anyway.
Now, the output format: just print integer.
I think that's all.
But let me consider if there is any scenario where a vertex cover of size floor(L/2) might not be sufficient because of the assignment of colors after changes might be impossible? Let's test with a run of length 3: vertices 1,2,3 all same color. Minimum vertex cover size = 1, e.g., change vertex 2. Then we have colors: v1 = original color C, v2 = new color X, v3 = C. We can choose X != C. Then no adjacent equal, ok.
Run length 4: vertices 1,2,3,4. Minimum vertex cover size 2. Choose to change vertices 2 and 4. Then colors: v1=C, v2=X, v3=C, v4=Y. Conditions: v1!=v2 => C != X; v2!=v3 => X != C; v3!=v4 => C != Y; v4 (none right). So need X != C and Y != C. We can choose X and Y distinct? Actually they just need to be != C. They could be same or different, but if X=Y, then v2 and v3? v2 = X, v3 = C, so no conflict. v4? Actually v3 and v4: C and Y, need C != Y. So we can set X=2, Y=2, both != C, then check: v1=1, v2=2 -> ok; v2=2, v3=1 -> ok; v3=1, v4=2 -> ok. So works.
Run length 5: vertices 1-5. Minimum cover size 2, e.g., change 2 and 4. Then colors: v1=C, v2=X, v3=C, v4=Y, v5=C. Conditions: v1!=v2: C != X; v2!=v3: X != C; v3!=v4: C != Y; v4!=v5: Y != C. So need X != C and Y != C, which is possible. Also note that v2 and v4 might be adjacent? They are not adjacent. So fine.
Thus always feasible.
Therefore, answer is sum floor(length_i/2).
Now, implement in Python.
Given N up to 100, we could also solve using DP, but runs method is simpler.
But is it always true that the graph edges are exactly those adjacent equal pairs? Yes. And since runs are disjoint, min vertex cover is sum over each run's min vertex cover. However, careful: If runs are separated by a single element of a different color, the vertex cover problem on the whole graph is not exactly independent because a vertex could belong to two edges from two different runs? Actually each vertex belongs to at most two edges, but those edges are within its run. Since runs are maximal segments of equal colors, the graph edges only exist within runs, and there are no edges between runs. So the graph is a disjoint union of paths (each run). Therefore the minimum vertex cover of the whole graph is sum of minimum vertex covers of each component. So our approach is correct.
Thus solution: compute runs.
Edge Cases: N=2, both equal -> answer 1. N=2, different -> 0. N=1? Constraint says N>=2, so ignore.
Now, we need to output the number.
Given the simplicity, we should produce code accordingly.
But wait, the problem statement says "Takahashi can change the color of one slime to any of the 10000 colors by one spell." So it's one spell per slime.
Thus answer is as above.
Now, maybe we should consider if there is any alternative approach that yields smaller number? For instance, sometimes we could change a slime to a color that matches a neighbor's color but break other equalities? But that would create a new adjacency equal? The goal is to have no adjacent equal. So changing to match a neighbor would be bad unless that neighbor is also changed. But maybe we could change two slimes to the same new color, but then they become adjacent? If they are not adjacent, it's fine. But the vertex cover approach only ensures that for each original equal-adjacent pair, at least one is changed. Changing both might be necessary in some assignments? But we can always assign colors to changed vertices appropriately, as argued. So minimum vertex cover is sufficient.
Double-check with a tricky case: sequence: 1,1,2,2,1,1. Runs: [1,1] len2 ->1, [2,2] len2 ->1, [1,1] len2 ->1, total=3. Could we achieve with 2 changes? Let's try: maybe change positions 2 and 5? Positions: 1, X,2,2,Y,1. Need to assign X and Y not causing issues. After changes: 1,X,2,2,Y,1. Conditions: 1 != X; X != 2; 2 != 2 (positions 3-4) -> equal! So still have equal at 3-4. So need to break that run. So we need to change at least one of 3 or 4. So total 3 changes. That matches sum.
Could we change 3 and something else? For run of 2's, we need at least 1 change. So total at least 2 (for the two runs of 1's?) Actually there are two runs of 1's, each require at least 1 change? Not exactly: each run of equal adjacent requires covering edges. For run of length 2, one edge, so at least one vertex from that run must be changed. So for each run of length L, minimum vertices to change from that run to cover its edges is floor(L/2). But sometimes a vertex could be part of two runs? Not possible because runs are separated by at least one element of different color, so vertices in a run only have edges within that run. So a vertex change can only cover edges in its run. So sum of minima per run is necessary. And it's also sufficient because we can pick exactly floor(L/2) from each run (e.g., every second vertex starting from the second? Actually typical min cover for a path of length L vertices: pick vertices 2,4,6,... up to floor(L/2)*2? For L=2, pick vertex 2; for L=3, pick vertex 2; for L=4, pick vertices 2 and 4; for L=5, pick vertices 2 and 4; etc.) That selection ensures each edge is incident to at least one selected vertex. Then after changes, we can assign new colors appropriately. So total changes = sum floor(L/2). So answer is correct.
Thus code is straightforward.
But wait, what about runs of length 0? Not applicable.
Thus final answer.
Now, I will produce final solution in Python.
But the problem might be from AtCoder ABC 064 B? Actually it's "Colorful Slimes"? No, it's maybe from "ABC 046 B" or something? I recall a problem "AtCoder Beginner Contest 064 B - Traveling AtCoDeer Problem"? Not that. Anyway.
We'll implement.
Potential pitfalls: reading input: N and then list of ints.
Implementation:
def solve():
import sys
input = sys.stdin.readline
N = int(input().strip())
a = list(map(int, input().split()))
ans = 0
cnt = 1
for i in range(1, N):
if a[i] == a[i-1]:
cnt += 1
else:
ans += cnt // 2
cnt = 1
ans += cnt // 2
print(ans)
Test with examples.
Example1: N=5, a=1 1 2 2 2 => runs: cnt starts 1; i=1: a[1]==a[0] => cnt=2; i=2: a[2]!=a[1] => ans+=2//2=1, cnt=1; i=3: a[3]==a[2] => cnt=2; i=4: a[4]==a[3] => cnt=3; end ans+=3//2=1 => total 2. OK.
Example2: 1 2 1 => cnt: i=1: 2!=1 => ans+=1//2=0, cnt=1; i=2:1!=2 => ans+=1//2=0, cnt=1; end ans+=1//2=0 => 0.
Example3: 1 1 1 1 1 => cnt: i=1: eq cnt=2; i=2: eq cnt=3; i=3: eq cnt=4; i=4: eq cnt=5; end ans+=5//2=2 => 2.
Example4: as computed 4.
So it's correct.
Thus answer.
Now produce final answer in appropriate format.
But wait, check constraint: a_i are between 1 and N, but we don't need that.
Thus final.
But I want to double-check that the graph is indeed just runs. Consider a scenario where the original colors are not only consecutive equalities; what about non-consecutive edges? Only adjacent edges matter. So yes.
Thus solution is final.
Now produce final answer.
The problem reduces to covering each pair of adjacent equal colors by changing at least one of them.
For each maximal consecutive block of equal colors of length (L), at least (\lfloor L/2 \rfloor) slimes must be changed (minimum vertex cover of a path of length (L)).
Summing over all blocks gives the answer.
import sys
def main() -> None:
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 1 # length of the current block
for i in range(1, N):
if a[i] == a[i-1]:
cnt += 1
else:
ans += cnt // 2
cnt = 1
ans += cnt // 2 # last block
print(ans)
if __name__ == "__main__":
main()