Question: 
Write a function to find the largest possible value of k such that k modulo x is y.


Model's Code:
def find_max_val(n, x, y):
    k = n - (n % x) + y
    if k > n:
        k -= x
    return k if k >= 0 else -1



Sample Correct Code:
import sys 
def find_max_val(n, x, y): 
	ans = -sys.maxsize 
	for k in range(n + 1): 
		if (k % x == y): 
			ans = max(ans, k) 
	return (ans if (ans >= 0 and
					ans <= n) else -1) 


Asserts:
assert find_max_val(15, 10, 5) == 15
assert find_max_val(187, 10, 5) == 185
assert find_max_val(16, 11, 1) == 12


Tests:
Test 1 of 3: PASS
Test 2 of 3: PASS
Test 3 of 3: PASS

Test 663 of 974: 496/663 (74.81146304675717%): success