Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

def solve():
    N = int(input())

    L0 = 2
    L1 = 1
    i = 2
    while True:
        ans = L0 + L1

        if i == N:
            break
        
        L0 = L1
        L1 = ans
        i += 1

    print(ans)

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    N = int(input())

    if N == 1:
        print(1)
        return

    L0 = 2
    L1 = 1
    i = 2
    while True:
        ans = L0 + L1

        if i == N:
            break
        
        L0 = L1
        L1 = ans
        i += 1

    print(ans)

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

def solve():
    N = int(input())

    L0 = 2
    L1 = 1
    i = 2
    while True:
        ans = L0 + L1

        if i == N:
            break
        
        L0 = L1
        L1 = ans

    print(ans)
    
if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    N = int(input())

    if N == 1:
        print(1)
        return

    L0 = 2
    L1 = 1
    i = 2
    while True:
        ans = L0 + L1

        if i == N:
            break
        
        L0 = L1
        L1 = ans
        i += 1

    print(ans)

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    toN := Nに行ける島番号のリスト
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1, toN = [], []
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            toN.append(a)
    
    for b in from1:
        if b in toN:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    """
    from1 := 1から行ける島番号のリスト
    canN[i] := 島iがNに行くことができるか否か
    from1とtoNの両方に同じ島番号が存在するとき、POSSIBLE
    """
    from1 = []
    canN = [False] * (N+1)
    for i in range(M):
        a, b = list(map(int, input().split()))
        if a == 1:
            from1.append(b)
        elif b == N:
            canN[a] = True
    
    for b in from1:
        if canN[b]:
            print("POSSIBLE")
            return
    print("IMPOSSIBLE")
        

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def determine_color(rate):
    if rate >= 1 and rate <= 399:
        return 0
    elif rate >= 400 and rate <= 799:
        return 1
    elif rate >= 800 and rate <= 1199:
        return 2
    elif rate >= 1200 and rate <= 1599:
        return 3
    elif rate >= 1600 and rate <= 1999:
        return 4
    elif rate >= 2000 and rate <= 2399:
        return 5
    elif rate >= 2400 and rate <= 2799:
        return 6
    elif rate >= 2800 and rate <= 3199:
        return 7
    else:
        return 8


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    """方針
    色が8のとき、何色にもなれる。

    先に0~7の色を埋める(Trueにして)。これが最小の数。
    
    その後、色が8の数だけ他の色を埋めていく。それが最大の数。

    """
    min_colors = [False] * 8
    max_colors = [False] * 8
    color8_cnt = 0
    for i, a in enumerate(A):
        color = determine_color(a)
        if color == 8:
            color8_cnt += 1
            continue
        min_colors[color] = True
        max_colors[color] = True

    k = 0
    for i in range(color8_cnt):
        if k == len(max_colors)-1:
            break

        for j in range(k, len(max_colors)):
            k = j
            if not max_colors[j]:
                max_colors[j] = True
                break
    
    min_ans = 0
    for i, c in enumerate(min_colors):
        if c:
            min_ans += 1

    max_ans = 0
    for i, c in enumerate(max_colors):
        if c:
            max_ans += 1

    print(f"{min_ans} {max_ans}")



if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def determine_color(rate):
    if rate >= 1 and rate <= 399:
        return 0
    elif rate >= 400 and rate <= 799:
        return 1
    elif rate >= 800 and rate <= 1199:
        return 2
    elif rate >= 1200 and rate <= 1599:
        return 3
    elif rate >= 1600 and rate <= 1999:
        return 4
    elif rate >= 2000 and rate <= 2399:
        return 5
    elif rate >= 2400 and rate <= 2799:
        return 6
    elif rate >= 2800 and rate <= 3199:
        return 7
    else:
        return 8


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    """方針
    色が8のとき、何色にもなれる。

    先に0~7の色を埋める(Trueにして)。これが最小の数。
    
    その後、最小の数に、色が8の数を足す。それが最大の数。

    問題文に書かれている色以外にもなれることに注意。黒色とか。
    """
    min_colors = [False] * 8
    color8_cnt = 0
    for i, a in enumerate(A):
        color = determine_color(a)
        if color == 8:
            color8_cnt += 1
            continue
        min_colors[color] = True
    
    min_ans = 0
    for i, c in enumerate(min_colors):
        if c:
            min_ans += 1
    
    max_ans = min_ans
    max_ans += color8_cnt

    if min_ans == 0 and color8_cnt != 0:
        min_ans = 1

    print("{} {}".format(min_ans, max_ans))



if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def solve():
    A, B = list(map(int, input().split()))
    if A > B:
        print("GREATER")
    elif A < B:
        print("LESS")
    else:
        print("EQUAL")
        

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    A = int(input())
    B = int(input())
    if A > B:
        print("GREATER")
    elif A < B:
        print("LESS")
    else:
        print("EQUAL")


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    A = []
    B = []

    for i in range(N):
        A.append(list(input()))
    for i in range(M):
        B.append(list(input()))
    
    # 左上から順に走査する
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == B[0][0]:
                is_contained = True
                for k in range(i, i+M):
                    for l in range(j, j+M):
                        if A[k][l] != B[k][l]:
                            is_contained = False
                            break
                    if not is_contained: break
                if is_contained:
                    print("Yes")
                    return
    print("No")


if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    A = []
    B = []

    for i in range(N):
        A.append(list(input()))
    for i in range(M):
        B.append(list(input()))
    
    # 左上から順に走査する
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == B[0][0]:
                is_contained = True
                for k in range(0, M):
                    for l in range(0, M):
                        if A[i+k][j+l] != B[k][l]:
                            is_contained = False
                            break
                    if not is_contained: break
                if is_contained:
                    print("Yes")
                    return
    print("No")


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
"""考え方
   i:    0 1   2 3   4
------------------  
A[i]:  100 2 100 2 100

iが奇数のときのA[i]をまず減らす戦略が有効。

その後、まだ条件を満たさないなら、iが偶数のときのA[i]を減らす。

"""
def solve():
    N, x = list(map(int, input().split()))
    A = list(map(int, input().split()))

    ans = 0
    for i in range(1, N, 2):

        # iが奇数のときの数字を減らす。
        if A[i-1]+A[i] > x:
            diff = (A[i-1]+A[i]) - x
            if A[i] <= diff:
                A[i] -= diff
                ans += diff
    
    for i in range(0, N, 2):
        if i == N-1:
            if A[i]+A[i-1] > x:
                diff = (A[i]+A[i-1]) - x
                A[i] -= diff
                ans += diff

        # iが偶数のときの数字を減らす
        if A[i]+A[i+1] > x:
            diff = (A[i]+A[i+1]) - x
            A[i] -= diff
            ans += diff
    
    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-
"""貪欲法
"""
def solve():
    N, x = list(map(int, input().split()))
    A = list(map(int, input().split()))

    ans = 0

    total = A[1] + A[0]
    if total > x:
        diff = min(total-x, A[1])
        A[1] -= diff
        ans += diff

    total = A[1] + A[0]
    if total > x:
        diff = total - x
        A[0] -= diff
        ans += diff

    for i in range(2, N):
        total = A[i] + A[i-1]

        if total > x:
            diff = total - x
            A[i] -= diff
            ans += diff
    
    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def solve():
    a, b, c = list(map(int, input.split()))

    if a+b == c or b+c==a or c+a==b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    a, b, c = list(map(int, input().split()))

    if a+b == c or b+c==a or c+a==b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

def solve():
    a, b, h = list(map(int, input().split()))
    print(int((a+b)*h//2))

if __name__ == "__main__":
    solve()


Fixed submission:
# -*- coding:utf-8 -*-

def solve():
    a = int(input())
    b = int(input())
    h = int(input())
    print(int((a+b)*h//2))

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt

def SieveOfEratosthenes(n):
    prime = [True for i in range(n + 1)] 
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * 2, n + 1, p): 
                prime[i] = False
        p += 1
    prime[0]= False
    prime[1]= False
    return(prime)
def f(n):
    ans = 0
    for i in range(1, int(sqrt(n)+1)):
        if n%i == 0:
            if i**2 == n:ans+=1
            else:ans += 2
    return(ans)
prime = SieveOfEratosthenes(10**6)
n = int(input())
ans = 0
for i in range(1, n):
    tem = n-i
    if not prime[tem]:
        ans += f(tem)
    else:
        ans += 2
#     print(tem ,ans)
print(ans)

Fixed submission:
from math import *
MAX = 1000001; 
factor = [0]*(MAX + 1); 
  
def generatePrimeFactors(): 
    factor[1] = 1; 
   
    for i in range(2,MAX): 
        factor[i] = i; 
  
    for i in range(4,MAX,2): 
        factor[i] = 2; 
    i = 3; 
    while(i * i < MAX): 
        if (factor[i] == i): 
            j = i * i; 
            while(j < MAX):  
                if (factor[j] == j): 
                    factor[j] = i; 
                j += i; 
        i+=1
  
def calculateNoOFactors(n): 
    if (n == 1): 
        return 1; 
    ans = 1; 
    dup = factor[n]; 
    c = 1; 
    j = int(n / factor[n]); 
    while (j > 1): 
        if (factor[j] == dup): 
            c += 1; 
        else: 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        j = int(j / factor[j]); 
    ans = ans * (c + 1); 
  
    return ans;
generatePrimeFactors()
# n = int(input())
# print(calculateNoOFactors(n))

n = int(input())
ans = 0
for i in range(1, n):
    tem = n-i
    ans += calculateNoOFactors(i)
#     print(tem ,ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# MOD = 10**9 + 7
def main():
	MAXN = 1000001
	spf = [0 for i in range(MAXN)] 
	sett = set()
	def sieve(): 
		spf[1] = 1
		for i in range(2, MAXN):  
			spf[i] = i 

		for i in range(4, MAXN, 2): 
			spf[i] = 2

		for i in range(3, ceil(sqrt(MAXN))): 
			
			if (spf[i] == i): 
				
				for j in range(i * i, MAXN, i): 
					
					if (spf[j] == j): 
						spf[j] = i
	sieve()
	
	# def getFactorization(x): 
	# 	ret = set() 
	# 	# print("This is for ",x)
	# 	flag = 1
	# 	while (x != 1):
	# 		# print("\t", x, spf[x], sett)
	# 		if spf[x] in sett:
	# 			flag = 0
	# 		ret.add(spf[x]) 
	# 		x = x // spf[x]
	# 	sett = sett.union(ret)
	# 	return flag


	n = int(input()); arr = read()
	gcd_ = arr[0]
	f1 = 0; f2 = 1
	for i in arr:
		gcd_ = gcd(gcd_, i)
		# res = getFactorization(i)
		x = i
		ret = set() 
		# print("This is for ",x)
		flag = 1
		while (i != 1):
			# print("\t", i, spf[x], sett)
			if spf[i] in sett:
				flag = 0
			ret.add(spf[i]) 
			i = i // spf[i]
		sett = sett.union(ret)
		# print(x, flag)
		f1 += flag; f2 &= flag

	# print(sett)

	if f2:print("pairwise coprime")
	elif gcd_ == 1:print("setwise coprime")
	else:print("not coprime")



	



if __name__ == "__main__":
	main()

# import math as mt 




# # def getFactorization(x): 
# # 	ret = list() 
# # 	while (x != 1): 
# # 		ret.append(spf[x]) 
# # 		x = x // spf[x] 

# # 	return ret 
# sieve()
# # print(spf[:100])


Fixed submission:
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# MOD = 10**9 + 7
def main():
	MAXN = 1000001
	spf = [0 for i in range(MAXN)] 
	# sett = set()
	def sieve(): 
		spf[1] = 1
		for i in range(2, MAXN):  
			spf[i] = i 

		for i in range(4, MAXN, 2): 
			spf[i] = 2

		for i in range(3, ceil(sqrt(MAXN))): 
			
			if (spf[i] == i): 
				
				for j in range(i * i, MAXN, i): 
					
					if (spf[j] == j): 
						spf[j] = i
	sieve()
	n = int(input()); arr = read()
	gcd_ = arr[0]
	check = [0]*(10**6 +1)
	f1 = 0; f2 = 1
	for i in arr:
		gcd_ = gcd(gcd_, i)
		# x = i
		ret = []
		flag = 1
		while (i != 1):
			if check[spf[i]]:# in sett:
				flag = 0
			ret.append(spf[i]) 
			i = i // spf[i]
		for j in ret:check[j] = 1
		# sett = sett.union(ret)
		# print(x, flag)
		f1 += flag; f2 &= flag

	# print(sett)

	if f2:print("pairwise coprime")
	elif gcd_ == 1:print("setwise coprime")
	else:print("not coprime")



	



if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

MOD = 10**9 + 7


def main():
	# ans_ = []
	# ans_.append(ans)
	# print(("\n").join(map(str, ans_)))
	n = int(input())
	s = 0
	while n:
		s += n%10
		s %= 9
		n //= 10
	print("YNeos"[s!=0::2])






if __name__ == "__main__":
	main()

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

MOD = 10**9 + 7


def main():
	# ans_ = []
	# ans_.append(ans)
	# print(("\n").join(map(str, ans_)))
	n = input().strip()#10**200000 - 1#int(input())
	i = 0
	s = 0
	while i < len(n):
		# print(n)
		s += int(n[i])
		s %= 9
		i += 1
	print("YNeos"[s!=0::2])






if __name__ == "__main__":
	main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

MOD = 10**9 + 7


def main():
	# ans_ = []
	# ans_.append(ans)
	# print(("\n").join(map(str, ans_)))
	n = int(input())
	s = 0
	while n:
		s += n%10
		s %= 9
		n //= 10
	print("YNeos"[s!=0::2])






if __name__ == "__main__":
	main()

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

MOD = 10**9 + 7


def main():
	# ans_ = []
	# ans_.append(ans)
	# print(("\n").join(map(str, ans_)))
	n = input().strip()#10**200000 - 1#int(input())
	i = 0
	s = 0
	while i < len(n):
		# print(n)
		s += int(n[i])
		s %= 9
		i += 1
	print("YNeos"[s!=0::2])






if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	n, k = read(); arr = read()
	arr2 = [i for i in arr]
	for i in range(k-1):
		arr2[k-1] *= arr[i]
	# print(arr)
	for i in range(k, n):
		arr2[i] *= (arr2[i-1]//arr[i-k])
	# print(arr)
	# print(arr2)
	for i in range(k, n):
		print("YNeos"[arr2[i] <= arr2[i-1]::2])






if __name__ == "__main__":
	main()

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	n, k = read(); arr = read()
	for i in range(k, n):
		print("YNeos"[arr[i] <= arr[i-k]::2])






if __name__ == "__main__":
	main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	n, k = read(); arr = read()
	arr2 = [i for i in arr]
	for i in range(k-1):
		arr2[k-1] *= arr[i]
	# print(arr)
	for i in range(k, n):
		arr2[i] *= (arr2[i-1]//arr[i-k])
	# print(arr)
	# print(arr2)
	for i in range(k, n):
		print("YNeos"[arr2[i] <= arr2[i-1]::2])






if __name__ == "__main__":
	main()

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	n, k = read(); arr = read()
	for i in range(k, n):
		print("YNeos"[arr[i] <= arr[i-k]::2])






if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	n = int(input()); arr = read()
	stocks = 0; money = 1000
	j = n-1
	while arr[j] <= arr[j-1]:
		j -= 1
	for i in range(j):
		if arr[i] < arr[i+1] and stocks == 0:
			stocks += money//arr[i]
			money = money%arr[i]
		elif arr[i] > arr[i+1] and stocks:
			money += stocks*arr[i]
			stocks = 0

	# print(j)
	if stocks:
		money += arr[j]*stocks

	print(money)







if __name__ == "__main__":
	main()

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	n = int(input()); arr = read()
	stocks = 0; money = 1000
	j = n-1
	while j > 0 and arr[j] <= arr[j-1]:
		j -= 1
	for i in range(j):
		if arr[i] < arr[i+1] and stocks == 0:
			stocks += money//arr[i]
			money = money%arr[i]
		elif arr[i] > arr[i+1] and stocks:
			money += stocks*arr[i]
			stocks = 0

	# print(j)
	if stocks:
		money += arr[j]*stocks

	print(money)







if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int, input().split(" ")))
if 0 in arr:
    print(0)
    exit()
for i in arr:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Fixed submission:
n = int(input())
arr = list(map(int, input().split(" ")))
ans = 1
if 0 in arr:
    print(0)
    exit()
for i in arr:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().split(" "))
print(["safe", "unsafe"][s <= w])

Fixed submission:
s, w = map(int, input().split(" "))
print(["safe", "unsafe"][s <= w])

Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().strip().split(" "))
print(["safe", "unsafe"][s < w])

Fixed submission:
s, w = map(int, input().split(" "))
print(["safe", "unsafe"][s <= w])
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split(" "))
i = 0
while a > 0 or c > 0:
  if i%2 == 0:
    c -= b
    else:
      a -= d
  i += 1
print("YNeos"[i%2::2])

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	a, b, c, d = map(int, input().split(" "))
	i = 0
	while a > 0 or c > 0:
		if i%2 == 0:
			c -= b
		else:
			a -= d
		i += 1
	print("YNeos"[i%2::2])



if __name__ == "__main__":
	solve()

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split(" "))
i = 0
while a > 0 or c > 0:
  if i%2 == 0:
    c -= b
  else:
    a -= d
    i += 1
print("YNeos"[i%2::2])

Fixed submission:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	a, b, c, d = map(int, input().split(" "))
	i = 0
	while a > 0 or c > 0:
		if i%2 == 0:
			c -= b
		else:
			a -= d
		i += 1
	print("YNeos"[i%2::2])



if __name__ == "__main__":
	solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
	n, w = read(); 
	dp = [[0 for i in range(w+1)] for j in range(n)]
	w_v_list = [read() for i in range(n)]
	# for i in dp:print(*i)
	# print("\n")
	# print(w_v_list)
	for i in range(n):
		for j in range(w+1):
			elem_w, elem_v = w_v_list[i]
			if elem_w <= j:
				dp[i][j] = max(elem_v + dp[i-1][j - elem_w], dp[i][j-1], dp[i-1][j])
				# w_v_list[i][1] = 0
			else:
				dp[i][j] = max(dp[i][j-1], dp[i-1][j])
	# for i in dp:print(*i)
	print(dp[n-1][w])




if __name__ == "__main__":
	solve()

Fixed submission:
import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
	n, w = read(); 
	dp = [[0 for i in range(w+1)] for j in range(n)]
	w_v_list = [read() for i in range(n)]
	# for i in dp:print(*i)
	# print("\n")
	# print(w_v_list)
	for i in range(n):
		for j in range(w+1):
			elem_w, elem_v = w_v_list[i]
			if elem_w <= j:
				dp[i][j] = max(elem_v + dp[i-1][j - elem_w], dp[i][j-1], dp[i-1][j])
				# w_v_list[i][1] = 0
			else:
				dp[i][j] = max(dp[i][j-1], dp[i-1][j])
	# for i in dp:print(*i)
	print(dp[n-1][w])




if __name__ == "__main__":
	solve()