You are an expert software engineer.
You will be provided with two code snippets along with an user instruction. 
Your task is to compare the "after" code snippet with the "before" code snippet.
You must determine if the "after" snippet follows the user instruction better than the "before" snippet.
You will examine each line of both code snippets to see how well the instruction is followed.
You MUST output every violation you find and the corresponding line(s) of code for that violation.
You MUST output an explanation of why "after" was better or why "after" is not better
You must only analyze if the instruction was followed. Do not judge the correctness of the code unless the instruction requires making modifications to the logic.
Below are example snippets and judgements with explanations.



# Example 1
<before>
```python
def calculate_rate(total):
  if total == 7:
    return 4
  elif total == 9:
    return 100
  elif total == 11:
    return 4
  elif total == 18:
    return 11

```
<\before>
<after>
```python
def calculate_rate(total):
  if total == 9:
    return 100
  elif total <= 11:
    return 4
  else:
    return 11

```
<\after>
<instruction>
shorten long if else chains
<\instruction>

Analysis: *a line by line analysis of the code snippet*
Explanation: The function has conditionals for calcuating the rate. The instruction "shorten long if else chains" instructs the LLM to reduce the number of conditional statements in an if-else chain. I see that there are fewer conditionals in the after code snippet. Therefore, the instruction was followed.
<judgement>
1
</judgement>

# Example 2
<before>
```python
def bfs(g, s):
    v = set()
    q = [start]  # Use list as queue
    r = []
    while q:
        c = q.pop(0)  # Remove from front (inefficient but works)
        
        if c not in v:
            v.add(c)
            r.append(c)
            
            # Add neighbors to queue
            for n in g.get(c, []):
                if n not in v:
                    q.append(n)
    
    return r
```
<\before>
<after>
```python
def bfs(a, s):
    v = set()
    q = [start]  # Use list as queue
    p = []
    while q:
        c = q.pop(0)  # Remove from front (inefficient but works)
        
        if c not in v:
            v.add(c)
            p.append(c)
            
            # Add neighbors to queue
            for n in a.get(c, []):
                if n not in v:
                    q.append(n)
    
    return p
```
<\after>
<instruction>
use more descriptive variable names to ensure the code is more interpretable
<\instruction>

Analysis: *a line by line analysis of the code snippet*
Explanation: The function does bfs on an input graph and node. The instruction "use more descriptive variable names to ensure the code is more interpretable" instructs the LLM to make more descriptive variable names in the "after" snippet. I see that the "after" code snippet renamed many variables, but still contains many short, non-descriptive names. None of the variable name became more descriptive, therefore, there is no improvement.
<judgement>
0
</judgement>

# Example 3
<before>
```python
def levenshtein_distance(s1, s2):
    first, second = len(s1), len(s2)
    
    # Create a matrix to store distances
    dp = [[0] * (n + 1) for _ in range(m + 1)]
    
    # Initialize base cases
    for i in range(m + 1):
        dp[i][0] = i  # Distance from s1[:i] to empty string
    for j in range(n + 1):
        dp[0][j] = j  # Distance from empty string to s2[:j]
    
    # Fill the matrix
    for pointer_1 in range(1, first + 1):
        for pointer_2 in range(1, second + 1):
            if s1[pointer_1-1] == s2[pointer_2-1]:
                dp[pointer_1][pointer_2] = dp[pointer_1-1][pointer_2-1]
            else:
                dp[pointer_1][pointer_2] = 1 + min(
                    dp[pointer_1-1][pointer_2],    # deletion
                    dp[pointer_1][pointer_2-1],    # insertion
                    dp[pointer_1-1][pointer_2-1]   # substitution
                )
    
    return dp[first][second]
```
<\before>
<after>
```python
def levenshtein_distance(s1, s2):
    m, n = len(s1), len(s2)
    
    dp = [[0] * (n + 1) for _ in range(m + 1)]
    for i in range(m + 1):
        dp[i][0] = i  # Distance from s1[:i] to empty string
    for j in range(n + 1):
        dp[0][j] = j  # Distance from empty string to s2[:j]
    
    # Fill the matrix
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if s1[i-1] == s2[j-1]:
                dp[i][j] = dp[i-1][j-1]
            else:
                # Take minimum of three operations: insert, delete, substitute
                dp[i][j] = 1 + min(
                    dp[i-1][j],    # deletion
                    dp[i][j-1],    # insertion
                    dp[i-1][j-1]   # substitution
                )
    
    return dp[m][n]
```
<\after>
<instruction>
add more comments to make the code easier to understand
<\instruction>

Analysis: *a line by line analysis of the code snippet*
Explanation: The function calculates the levenshtein distance using dp. The instruction "add more comments to make the code easier to understand" instructs the LLM to add more comments to the function. I see that the "after" code snippet has fewer instructions than the "before" snippet. Since less comments are present in the "after" snippet, the "after" snippet followed the instructions less than the "before" code snippet.
<judgement>
-1
</judgement>

# Example 4
<before>
```python
from functools import cache

@cache
def coin_change(amount, coins):
    # Base cases
    if amount == 0:
        return 0
    if amount < 0:
        return float('inf')  # Invalid case
    
    # Try each coin denomination
    min_coins = float('inf')
    for coin in coins:
        if coin <= amount:
            result = coin_change(amount - coin, coins)
            if result != float('inf'):
                min_coins = min(min_coins, result + 1)
    
    return min_coins if min_coins != float('inf') else -1

def solve_coin_change(amount, coins_list):
    # Convert list to tuple for caching compatibility
    coins_tuple = tuple(sorted(coins_list, reverse=True))  # Sort for potential optimization
    result = coin_change(amount, coins_tuple)
    return result if result != -1 else -1

```
<\before>
<after>
```python
def coin_change_recursive(amount, coins):
    # Base cases
    if amount == 0:
        return 0
    if amount < 0:
        return float('inf')  # Invalid case, return infinity
    
    # Try each coin denomination
    min_coins = float('inf')
    
    for coin in coins:
        if coin <= amount:
            # Recursively solve for (amount - coin)
            result = coin_change_recursive(amount - coin, coins)
            if result != float('inf'):
                min_coins = min(min_coins, result + 1)
    
    # Return -1 if no solution found, otherwise return minimum coins
    return min_coins if min_coins != float('inf') else -1


def coin_change_with_solution(amount, coins):
    # Base cases
    if amount == 0:
        return (0, [])
    if amount < 0:
        return (float('inf'), [])
    
    min_coins = float('inf')
    best_solution = []
    
    for coin in coins:
        if coin <= amount:
            # Recursively solve for (amount - coin)
            result_coins, result_solution = coin_change_with_solution(amount - coin, coins)
            
            if result_coins != float('inf') and result_coins + 1 < min_coins:
                min_coins = result_coins + 1
                best_solution = [coin] + result_solution
    
    if min_coins == float('inf'):
        return (-1, [])
    
    return (min_coins, best_solution)

```
<\after>
<instruction>
avoid using cache tools
<\instruction>

Analysis: *a line by line analysis of the code snippet*
Explanation: The function solves the coin change problem. The instruction "avoid using cache tools" instructs the LLM to avoid using the cache decorator -- this means there should be 0 instances of that decorator. I see that the "after" code snippet has does not have the cache decotration. Since the "after" snippet avoided using the cache decorator, the "after" snippet followed the instructions better than the "before" code snippet.
<judgement>
1
</judgement>


# Input 
<before>
```{lang}
{before_code}
```
</before>

<after>
```{lang}
{after_code}
```
</after>

<instruction>
{instruction}
<\instruction>

# Output
Finally, return your judgement. Return 1 if the "after" snippet follows the instruction better than the "before" snippet, return 0 if there is no improvement ("after" snippet does not follow the instruction better), and -1 if "after" follows the instruction less than the "before" snippet. 
Return your answer in <judgement></judgement> tags as show below. You MUST ONLY include 1 or 0 or -1 in your final judgement within the tags
Analysis: *a line by line analysis of the code snippet*
Explanation: *your explanation*
<judgement>
YOUR JUDGEMENT HERE
</judgement>
