diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -11,6 +11,6 @@
             y = -inf
             break
         elif b[i] > 0:
-            y = min((q[i] - x * a[i]) // b[i], x)
+            y = min((q[i] - x * a[i]) // b[i], y)
     ans = max(ans, x + y)
 print(ans)
