Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
A, B = map(int, input().split())
max_n = fractions.gcd(A,B)
ans = 1
first = 2
while True:
    for i in range(first,max_n+1):
        if max_n % i == 0:
            while True:
                max_n //= i
                if max_n % i != 0:
                    break
            ans += 1
            first = i
            break
    if max_n == 1:
        break
print(ans)

Fixed submission:
import fractions
import math

def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a


A, B = map(int, input().split())
max_n = fractions.gcd(A,B)

ans = set(trial_division(max_n))
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
A, B = map(int, input().split())
max_n = fractions.gcd(A,B)
ans = 1
first = 2
while max_n != 1:
    for i in range(first,max_n+1):
        if max_n % i == 0:
            while max_n % i == 0:
                max_n //= i
            ans += 1
            first = i
            break
print(ans)

Fixed submission:
import fractions
import math

def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a


A, B = map(int, input().split())
max_n = fractions.gcd(A,B)

ans = set(trial_division(max_n))
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
A, B = map(int, input().split())
max_n = fractions.gcd(A,B)
ans = 1
while max_n != 1:
    for i in range(2,max_n+1):
        if max_n % i == 0:
            while max_n % i == 0:
                max_n //= i
            ans += 1
            break
print(ans)

Fixed submission:
import fractions
import math

def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a


A, B = map(int, input().split())
max_n = fractions.gcd(A,B)

ans = set(trial_division(max_n))
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
ans=1
flag = True
first = 2
while flag:
    flag = False
    for i in range(first,min(A,B)):
        if A % i == 0 and B % i ==0:
            ans += 1
            A //= i
            B //= i
            flag = True
            first = i
print(ans)

Fixed submission:
import fractions
import math

def trial_division(n):
    a = [1]
    for i in range(2,int(math.sqrt(n)) + 1):
        while n % i == 0:
            n //= i
            a.append(i)
    a.append(n)
    return a


A, B = map(int, input().split())
max_n = fractions.gcd(A,B)

ans = set(trial_division(max_n))
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
items = list(map(int, input().split()))
for _ in range(M):
	items[items.index(max(items))] //= 2
print(sum(items))

Fixed submission:
import heapq
N, M = map(int, input().split())
items = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(items)
for _ in range(M):
	tmp = heapq.heappop(items)
	heapq.heappush(items, int(tmp/2))
print(-sum(items))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
items = list(map(int, input().split()))
items.sort(reverse=True)
for _ in range(M):
	items[0] //= 2
	items.sort(reverse=True)
print(sum(items))

Fixed submission:
import heapq
N, M = map(int, input().split())
items = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(items)
for _ in range(M):
	tmp = heapq.heappop(items)
	heapq.heappush(items, int(tmp/2))
print(-sum(items))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
items = list(map(int, input().split()))
for _ in range(M):
	items[items.index(max(items))] //= 2
print(sum(items))


Fixed submission:
import heapq
N, M = map(int, input().split())
items = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(items)
for _ in range(M):
	tmp = heapq.heappop(items)
	heapq.heappush(items, int(tmp/2))
print(-sum(items))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
items = list(map(int, input().split()))
items.sort(reverse=True)
for _ in range(M):
	items[0] //= 2
	items.sort(reverse=True)
print(sum(items))


Fixed submission:
import heapq
N, M = map(int, input().split())
items = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(items)
for _ in range(M):
	tmp = heapq.heappop(items)
	heapq.heappush(items, int(tmp/2))
print(-sum(items))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
summ = 0
for i in range(N):
    for j in range(N-i+1,N):
        if (j % i) == 0:
            summ += ans_list[j]
    if (summ % 2) != arr[i]:
        ans_list[i] = 1
        ans.append(arr[i])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")

Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i
    while j < N:
        j = j + N - i
        if j - 1 < N:
            summ += ans_list[j-1]
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

ans.sort()
print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
summ = 0
for i in range(N):
    for j in range(N-i+1,N):
        if (j % i) == 0:
            summ += ans_list[j]
    if (summ % 2) != arr[i]:
        ans_list[i] = 1
        ans.append(arr[i])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")

Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i
    while j < N:
        j = j + N - i
        if j - 1 < N:
            summ += ans_list[j-1]
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

ans.sort()
print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))
count_1 = arr.count(1)
ans_list = [0] * (N)
ans = []
summ = 0
if count_1 == 0:
    print(0)
    exit()
for i in range(N):
    for j in range(N-i+1,N):
        if (j % i) == 0:
            summ += ans_list[j]
    if (summ % 2) != arr[i]:
        ans_list[i] = 1
        ans.append(arr[i])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")






Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i
    while j < N:
        j = j + N - i
        if j - 1 < N:
            summ += ans_list[j-1]
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

ans.sort()
print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = 1
tmp = A[0]
for i in range(N):
    if A[i] > tmp:
        tmp = A[i]
        cnt += 1
cnt2 = 1
tmp = A[N-1]
for i in range(N):
    if A[N-1-i] > tmp:
        tmp = A[N-1-i]
        cnt += 1
if cnt2 >= cnt:
    A = A[::-1]
ans = 0
while True:
    tmp = -1
    for i in range(N):
        if A[i] > tmp:
            tmp = A[i]
            A[i] = -1
    if tmp == -1:
        break
    ans += 1
print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)][::-1]
def LIS(L):
  from bisect import bisect
  seq=[]
  for i in L:
    pos=bisect(seq,i)
    if len(seq)<=pos:
      seq.append(i)
    else:
      seq[pos]=i
  return len(seq)
print(LIS(A))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
while True:
    tmp = -1
    for i in range(N):
        if A[i] > tmp:
            tmp = A[i]
            A[i] = -1
    if tmp == -1:
        break
    ans += 1
print(ans)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)][::-1]
def LIS(L):
  from bisect import bisect
  seq=[]
  for i in L:
    pos=bisect(seq,i)
    if len(seq)<=pos:
      seq.append(i)
    else:
      seq[pos]=i
  return len(seq)
print(LIS(A))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
arr = list(map(int, input().split()))
for i in itertools.permutations(arr):
    flg = True
    for k in range(N):
        if i[k-2] ^ i[k] != i[k-1]:
            flg = False
            break
    if flg:
        print('Yes')
        exit()
print('No')

Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
cnt = arr.count(0)
if cnt == N:
    print('Yes')
    exit()
if N % 3 != 0:
    print('No')
    exit()
if cnt == N//3 and len(set(arr)) == 2:
    print('Yes')
    exit()
from collections import defaultdict
d = defaultdict(int)
for i in arr:
    d[i] += 1
if len(d) != 3:
    print('No')
    exit()
check = []
for key in d.keys():
    check.append(key)
if d[check[0]] == d[check[1]] and d[check[1]] == d[check[2]] and d[check[2]] == d[check[0]] and check[0]^check[1]^check[2] == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

cd = lcm(c, d)

ca = (a // c)
cb = (b // c)
tmp_c = cb - ca

da = (a // d)
db = (b // d)
tmp_d = db - da

cda = (a // cd)
cdb = (b // cd)
tmp_cd = cdb - cda
ans = b - a - (tmp_c + tmp_d - tmp_cd) + 1

print(ans)


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

cd = lcm(c, d)

# cの倍数とdの倍数の個数を数える
# cの倍数dの倍数の個数を引く
ca = ((a-1) // c)
# print(ca)
cb = (b // c)
# print(cb)
tmp_c = cb - ca

da = (a // d)
# print(da)
db = (b // d)
# print(db)
tmp_d = db - da

cda = (a // cd)
# print(cda)
cdb = (b // cd)
# print(cdb)
tmp_cd = cdb - cda
ans = b - a + 1 - (tmp_c + tmp_d - tmp_cd)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

cd = lcm(c, d)

# cの倍数とdの倍数の個数を数える
ca = a // c
# print(ca)
cb = b // c
# print(cb)
tmp_c = cb - ca

da = a // d
# print(da)
db = b // d
# print(db)
tmp_d = db - da

cda = a // cd
# print(cda)
cdb = b // cd
# print(cdb)
tmp_cd = cdb - cda
ans = b - a - (tmp_c + tmp_d - tmp_cd) + 1

print(ans)


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

cd = lcm(c, d)

# cの倍数とdの倍数の個数を数える
# cの倍数dの倍数の個数を引く
ca = ((a-1) // c)
# print(ca)
cb = (b // c)
# print(cb)
tmp_c = cb - ca

da = (a // d)
# print(da)
db = (b // d)
# print(db)
tmp_d = db - da

cda = (a // cd)
# print(cda)
cdb = (b // cd)
# print(cdb)
tmp_cd = cdb - cda
ans = b - a + 1 - (tmp_c + tmp_d - tmp_cd)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

cd = lcm(c, d)

# cの倍数とdの倍数の個数を数える
ca = a // c
# print(ca)
cb = b // c
# print(cb)
tmp_c = cb - ca

da = a // d
# print(da)
db = b // d
# print(db)
tmp_d = db - da

cda = a // cd
# print(cda)
cdb = b // cd
# print(cdb)
tmp_cd = cdb - cda
ans = b - a - (tmp_c + tmp_d - tmp_cd) + 1

print(ans)


Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

cd = lcm(c, d)

# cの倍数とdの倍数の個数を数える
# cの倍数dの倍数の個数を引く
ca = ((a-1) // c)
# print(ca)
cb = (b // c)
# print(cb)
tmp_c = cb - ca

da = (a // d)
# print(da)
db = (b // d)
# print(db)
tmp_d = db - da

cda = (a // cd)
# print(cda)
cdb = (b // cd)
# print(cdb)
tmp_cd = cdb - cda
ans = b - a + 1 - (tmp_c + tmp_d - tmp_cd)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ary = []
d2 = []
max = 0
sin_max = 0
for _ in range(N):
    ball = list(map(int, input().split()))
    ary.append(ball)


for i in range(N):
    for j in range(N):
        x = ary[i][0] - ary[j][0]
        y = ary[i][1] - ary[j][1]
        tmp = str(x) + str(y)
        d2.append(tmp)
        max = d2.count(d2[0])
        for i in range(1,N-1):
            if max < d2.count(d2[i]):
                max = d2.count(d2[i])
        sin_max = max
    d2 = []
    max = 0
    sin_max = 0

print(N - sin_max)


Fixed submission:
n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[i][0]-xy[j][0]
		q = xy[i][1]-xy[j][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Buggy python submission (verdict: Runtime Error):
N = int(input())
ary = []
d2 = []
max = 0
sin_max = 0
for _ in range(N):
  ball = list(map(int, input().split()))
  ary.append(ball)
for i in range(N):
    for j in range(N):
        x = ary[i][0] - ary[j][0]
        y = ary[i][1] - ary[j][1]
        tmp = str(x) + str(y)
        d2.append(tmp)
        max = d2.count(d2[0])
        for i in range(1,N-1):
            if max < d2.count(d2[i]):
                max = d2.count(d2[i])
        sin_max = max
    d2 = []
    max = 0
    sin_max = 0

print(N - sin_max)


Fixed submission:
n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[i][0]-xy[j][0]
		q = xy[i][1]-xy[j][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Buggy python submission (verdict: Runtime Error):
N = int(input())
ary = []
# d = []
d2 = []
for _ in range(N):
  ball = list(map(int, input().split()))
  ary.append(ball)

for i in range(N-1):
    x = ary[i][0] - ary[i+1][0]
    y = ary[i][1] - ary[i+1][1]
    # d.append(x)
    # d.append(y)
    tmp = str(x) + str(y)
    d2.append(tmp)
    # d = []
# print(ary)
# print(d2)

max = d2.count(d2[0])
for i in range(1,N-1):
    if max < d2.count(d2[i]):
        max = d2.count(d2[i])

print(len(d2) - max + 1)


Fixed submission:
n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[i][0]-xy[j][0]
		q = xy[i][1]-xy[j][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))
Buggy python submission (verdict: Time Limit Exceeded):
H, W  = map(int, input().split())
grid = [input() for _ in range(H)]
ans = [[0] * W for _ in range(H)]
for i in range(H):
    tmp = 0
    for k in range(W):
        if grid[i][k] == '.':
            tmp += 1
        else:
            ans[i][k] = 0
            for t in range(k-tmp,k):
                ans[i][t] = tmp
            tmp = 0
    for t in range(W-tmp,W):
        ans[i][t] = tmp
a = 0
for i in range(W):
    tmp = 0
    for k in range(H):
        if grid[k][i] == '.':
            tmp += 1
        else:
            for t in range(k-tmp,k):
                a = max(ans[t][i]+tmp-1,a)
            tmp = 0
    for t in range(H-tmp,H):
        a = max(ans[t][i]+tmp-1,a)
print(a)

Fixed submission:
H, W  = map(int, input().split())
grid = [input() for _ in range(H)]
ans = [[0] * W for _ in range(H)]
for i in range(H):
    tmp = 0
    for k in range(W):
        if grid[i][k] == '.':
            tmp += 1
        else:
            ans[i][k] = 0
            for t in range(k-tmp,k):
                ans[i][t] = tmp
            tmp = 0
    for t in range(W-tmp,W):
        ans[i][t] = tmp
a = 0
for i in range(W):
    tmp = 0
    for k in range(H):
        if grid[k][i] == '.':
            tmp += 1
        else:
            for t in range(k-tmp,k):
                a = max(ans[t][i]+tmp-1,a)
            tmp = 0
    for t in range(H-tmp,H):
        a = max(ans[t][i]+tmp-1,a)
print(a)
Buggy python submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S:
    print('No')
    exit()
if D < C:
    for i in range(B-1,D):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
    print('No')
    exit()
else:
    print('Yes')
    exit()

Fixed submission:
N, A, B, C, D = map(int, input().split())
S = input()
for i in range(A-1,max(C,D)-1):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()
if D < C:
    for i in range(B-2,N-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
        if i+1 == D-1:
            break
    print('No')
    exit()
else:
    print('Yes')
    exit()
Buggy python submission (verdict: Runtime Error):
# ABC128-B
# ソートが大事な問題
import itemgetter
a = int(input())
book = []
for i in range(a):
    array = input().split()
    book.append((array[0], int(array[1]) * -1, i))

ans = sorted(book, key=itemgetter(0, 1))

for i in range(a):
    print(ans[i][2] + 1)


Fixed submission:
from operator import itemgetter

# a, b = map(int, input().split())
a = int(input())
array2 = {}
array99 = []
for i in range(a):
    array = input().split()
    array99.append((array[0], int(array[1]) * -1, i))

# print(array99)

b = sorted(array99, key=itemgetter(0, 1))

# print(b)

for i in range(a):
    print(b[i][2] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
ans = 0
card = [1] * N
for _ in range(M):
	L, R = map(int, input().split())
	for i in range(N):
		if i < L-1 or R-1 < i:
			card[i] = 0

print(card.count(1))

Fixed submission:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
max_L = 1
min_R = 100000
for _ in range(M):
	L, R = map(int, input().split())
	if max_L < L:
		max_L = L
	if R < min_R:
		min_R = R
if min_R - max_L + 1 < 0:
	print(0)
else:
	print(min_R - max_L + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
arr = list(map(int, input().split()))
heapq.heapify(arr)
for i in range(M):
    B, C = map(int, input().split())
    count = 0
    while True:
        a = heapq.heappop(arr)
        if a >= C or B <= count:
            heapq.heappush(arr,a)
            break
        else:
            count += 1
            heapq.heappush(arr,C)
print(sum(arr))

Fixed submission:
import heapq
N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(M)]
heapq.heapify(a)
bc = sorted(bc, reverse=True, key=lambda x: x[1])
for i in range(M):
    count = 0
    while True:
        t = heapq.heappop(a)
        if t >= bc[i][1] or bc[i][0] <= count:
            heapq.heappush(a,t)
            break
        else:
            count += 1
            heapq.heappush(a,bc[i][1])
print(sum(a))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
sum = 0
coin_count = 0


for i in range(n):
    k = coin(i, k)
    sum += (1/n) * ((0.5) ** k)

print(sum)


def coin(j,k):
    point = j
    count = 0
    while k <= point:
        point = point * 2
        count += 1
    return count


Fixed submission:
import sys
input = sys.stdin.readline
N,K = map(int, input().split())
ans = 0
for i in range(1,N+1):
	coin = 0
	point = i
	if K <= i:
		ans += 1/N
	else:
		while point < K:
			point *= 2
			coin += 1
		ans += (1/N) * (0.5)**coin

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = 0

for i range(1, a+1):
    if i + b < a:
        ans = ans +1

print(ans)


Fixed submission:
a, b = map(int, input().split())
ans = 0

for i in range(1, a+1):
    if i + b - 1 <= a:
        ans = ans + 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if (N - r*R - g*G) % B == 0 and (N - r*R - g*G) >= 0:
            ans += 1
print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if r*R + g*G <= N and (N - r*R - g*G) % B == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if r*R + g*G <= N and (N - r*R - g*G) % B == 0:
            ans += 1
print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if r*R + g*G <= N and (N - r*R - g*G) % B == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d= map(int, input().split())
ans = 0

a2 = d//a
b2 = d//b
c2 = d//c

for i in range(a2 + 1):
    for j in range(b2 + 1):
        for k in range(c2 + 1):
            sum = a * i + b * j + c * k
            if sum == d:
                ans += 1

print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if r*R + g*G <= N and (N - r*R - g*G) % B == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d= map(int, input().split())
ans = 0

a2 = d//a
b2 = d//b
c2 = d//c

for i in range(a2 + 1):
    for j in range(b2 + 1):
        for k in range(c2 + 1):
            sum = a * i + b * j + c * k
            if sum == d:
                ans += 1

print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if r*R + g*G <= N and (N - r*R - g*G) % B == 0:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d= map(int, input().split())
ans = 0

for i in range(d + 1):
    for j in range(d + 1):
        for k in range(d + 1):
            sum = a * i + b * j + c * k
            if sum == d:
                ans += 1

print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        if r*R + g*G <= N and (N - r*R - g*G) % B == 0:
            ans += 1
print(ans)