Repository: evalplus/evalplus
Issue: 🐛 [Bug] sanitizer cannot handle additional statements
Root cause: Algorithmic Error

Ideally, the sanitizer should remove additional statements outside the function to complete in HumanEval. However, it has some unexpected behaviors. The [`sanitize`](https://github.com/evalplus/evalplus/blob/437e6936d3fad9487e891c24e4509b9561b95e3a/evalplus/sanitize.py#L124) function needs to be fixed.

## Case 1

Before sanitization:

```python
def get_max_triples(n):
    """
    You are given a positive integer n. You have to create an integer array a of length n.
        For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
        Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, 
    and a[i] + a[j] + a[k] is a multiple of 3.

    Example :
        Input: n = 5
        Output: 1
        Explanation: 
        a = [1, 3, 7, 13, 21]
        The only valid triple is (1, 7, 13).
    """

    a = [i * i - i + 1 for i in range(1, n + 1)]
    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if (a[i] + a[j] + a[k]) % 3 == 0:
                    count += 1
    return count

# Test the function with the provided example
n = 5
print(get_max_triples(n))  # Output: 1
```

After sanitization:

```python
def get_max_triples(n):
    """
    You are given a positive integer n. You have to create an integer array a of length n.
        For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
        Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, 
    and a[i] + a[j] + a[k] is a multiple of 3.

    Example :
        Input: n = 5
        Output: 1
        Explanation: 
        a = [1, 3, 7, 13, 21]
        The only valid triple is (1, 7, 13).
    """

    a = [i * i - i + 1 for i in range(1, n + 1)]
    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if (a[i] + a[j] + a[k]) % 3 == 0:
                    count += 1
    return count

# 
5
pri
```

## Case 2

Before & after sanitization (no change):

```python
def decode_cyclic(s: str):
    """
    takes as input string encoded with encode_cyclic function. Returns decoded string.
    """

    # split string to groups. Each of length 3.
    # groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
    # cycle elements in each group. Unless group has fewer elements than 3.
    groups = [(group[-1] + group[:-1]) if len(group) == 3 else group for group in groups]
    return "".join(groups)
original_string = "abcdefghijklmnopqrstuvwxyz"
encoded_string = encode_cyclic(original_string)
decoded_string = decode_cyclic(encoded_string)
```

However, the last three lines should be removed. Otherwise, the second one calls `encode_cyclic` which does not exist in the solution code but in the prompt of HumanEval/38, which leads to exception when trying to declare the function [here](https://github.com/evalplus/evalplus/blob/437e6936d3fad9487e891c24e4509b9561b95e3a/evalplus/eval/__init__.py#L134).



The first case can be fixed by [this commit](https://github.com/evalplus/evalplus/pull/189/commits/63df57ca8d124ef44aa2db28a8931d000ee82e2f).