##### Canadian Computing Olympiad: 2023 Day 2, Problem 3

Alice has a collection of sticks. Initially, she has sticks of length for each .

Alice would like to use her sticks to make some isosceles triangles. An isosceles triangle is made of two sticks of the same length, say , and a third stick with a length between and inclusive. Note that the triangles must strictly obey the triangle inequality, and equilateral triangles are okay. Each stick may be used in at most one triangle. Alice would like to know the maximum number of isosceles triangles she can make with her sticks.

There are events that change the collection of sticks she has. The -th event consists of two integers and , representing that the number of sticks of length changes by . Note that may be positive, negative, or even , but Alice will never have a negative number or more than sticks of each length.

Your task is to determine the maximum number of isosceles triangles Alice can make after each event if she uses her sticks optimally.

#### Input Specification

The first line of input contains two space-separated integers and .

The second line of input contains space-separated integers , representing Alice's initial collection.

The next lines of input each contain two space-separated integers and , representing an event.

Initially and after each event, the number of sticks of length is between and for all .

Marks Awarded | Bounds on | Additional Constraints |
---|---|---|

marks | There are at most sticks in total initially and after each event | |

marks | No additional constraints. | |

marks | The number of sticks of each length is either , , or initially and after each event. | |

marks | For each event, | |

marks | No additional constraints. |

#### Output Specification

Output lines each containing a single integer, the answer after each event.

#### Sample Input

```
4 3
3 1 4 1
3 -3
1 6
2 1
```

#### Output for Sample Input

```
1
3
4
```

#### Explanation of Output for Sample Input

After the first event, Alice can make a single triangle with sticks of lengths .

After the second event, Alice can make triangles with sticks of lengths .

After the third event, Alice can make triangles with sticks of lengths and a triangle with sticks of lengths .

## Comments