Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())

a = []
aindex = 0
for _ in range(M):
    a.append(int(input()))

before1 = 1
before2 = 0
if len(a)>0:
    ai = a[aindex]

for i in range(1, N+1):
    if i == ai:
        before2 = before1
        before1 = 0
        if aindex < len(a)-1:
            aindex += 1
            ai = a[aindex]
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current


print(before1)


Fixed submission:
from collections import deque
 
N, M = map(int, input().split())
 
a = []
aindex = 0
for _ in range(M):
    a.append(int(input()))
 
before1 = 1
before2 = 0
ai=0
if len(a)>0:
    ai = a[aindex]
 
for i in range(1, N+1):
    if i == ai:
        before2 = before1
        before1 = 0
        if aindex < len(a)-1:
            aindex += 1
            ai = a[aindex]
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current
 
 
print(before1)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())

a = deque()
for _ in range(M):
    a.append(int(input()))

before1 = 1
before2 = 0
if len(a)>0:
    ai = a.popleft()

for i in range(N):
    if i == (ai-1):
        before2 = before1
        before1 = 0
        if len(a)>0:
            ai = a.popleft()
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current


print(before1)


Fixed submission:
from collections import deque
 
N, M = map(int, input().split())
 
a = []
aindex = 0
for _ in range(M):
    a.append(int(input()))
 
before1 = 1
before2 = 0
ai=0
if len(a)>0:
    ai = a[aindex]
 
for i in range(1, N+1):
    if i == ai:
        before2 = before1
        before1 = 0
        if aindex < len(a)-1:
            aindex += 1
            ai = a[aindex]
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current
 
 
print(before1)

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())

a = deque()
for _ in range(M):
    a.append(int(input()))

before1 = 1
before2 = 0
ai = a.popleft()
for i in range(N):
    if i == (ai-1):
        before2 = before1
        before1 = 0
        if len(a)>0:
            ai = a.popleft()
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current
    
print(before1)


Fixed submission:
from collections import deque
 
N, M = map(int, input().split())
 
a = []
aindex = 0
for _ in range(M):
    a.append(int(input()))
 
before1 = 1
before2 = 0
ai=0
if len(a)>0:
    ai = a[aindex]
 
for i in range(1, N+1):
    if i == ai:
        before2 = before1
        before1 = 0
        if aindex < len(a)-1:
            aindex += 1
            ai = a[aindex]
    else:
        current = divmod(before1 + before2, 10**9+7)[1]
        before2 = before1
        before1 = current
 
 
print(before1)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

cnt = 0

for r in range(3001):
    if r*R > N:
        break
    for g in range(3001):
        if r*R + g*G > N:
            break
        diff = N - (r*R + g*G)
        if divmod(diff, B)[1] == 0:
            cnt += 1

print(cnt)


Fixed submission:
R, G, B, N = map(int, input().split())

cnt = 0
r, g, b = 0, 0, 0

while r*R <= N:
    tank = N - r*R
    while True:
        if divmod(tank, B)[1] == 0:
            cnt += 1
        tank -= G
        if tank < 0:
            break
    r += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
a=input()
p=list(map(int,input().split()))
q=list(map(int,input().split()))
cost=0
for i in range(a):
    if p[i] - q[[i] > 0:
        cost += (p[i]-q[i])   
print(n)

Fixed submission:
a=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
cost=0
for i in range(a):
    if p[i] - q[i] > 0:
        cost += (p[i]-q[i])   
print(cost)
Buggy python submission (verdict: Runtime Error):
#ATCGを小文字へ置き換え、小文字を抽出する作戦
S=input().replace("A","a").replace("T","t").replace("C","c").replace("G","g")

#小文字の列を取得
import re
list=re.findall(r"[a-z]+",S)

#各列の文字列の長さをリストに
list2=[]
for i in range(len(list)):
  list2.append(len(list[i]))

print(max(list2))

Fixed submission:
#ATCGを小文字へ置き換え、小文字を抽出する作戦
S=input().replace("A","a").replace("T","t").replace("C","c").replace("G","g")

#小文字の列を取得
import re
list=re.findall(r"[a-z]+",S)

#各列の文字列の長さをリストに
list2=[]
for i in range(len(list)):
  list2.append(len(list[i]))
  
#リストが空の場合との場合分け
if list2 ==[]:
  print(0)
else:
  print(max(list2))
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
list=[]

for i in range(1,min(a,b)):
  if a % i == 0 and b % i == 0:
    list.append(i)
  else:
    pass
print(list[-k])

Fixed submission:
a,b,k=map(int,input().split())
list=[]

for i in range(1,min(a,b)+1):
  if a % i == 0 and b % i == 0:
    list.append(i)
  else:
    pass
print(list[-k])

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
list=[]

for i in range(1,min(a,b)):
  if a % i == 0 and b % i == 0:
    list.append(i)
  else:
    pass
print(list[k-1])

Fixed submission:
a,b,k=map(int,input().split())
list=[]

for i in range(1,min(a,b)+1):
  if a % i == 0 and b % i == 0:
    list.append(i)
  else:
    pass
print(list[-k])
Buggy python submission (verdict: Runtime Error):
n,t=map(int,input().split())
clis=[]
tlis=[]
for i in range(n):
  a,b=map(int,input().split())
  clis.append(a)
  tlis.append(b)
lis2=[]
for i in range(n):
  if tlis[i] > t:
    pass
  else:
    lis2.append(clis[i])
if len(lis2)==0:
  print(TLE)
else:
  print(min(lis2))

Fixed submission:
n,t=map(int,input().split())
clis=[]
tlis=[]
for i in range(n):
  a,b=map(int,input().split())
  clis.append(a)
  tlis.append(b)
lis2=[]
for i in range(n):
  if tlis[i] > t:
    pass
  else:
    lis2.append(clis[i])
if len(lis2)==0:
  print("TLE")
else:
  print(min(lis2))
Buggy python submission (verdict: Runtime Error):
N=int(input())
D=int(input())
maximum=2*D+1
if N%maximum==0:
    print(int(N/maximum))
else:
    print(int(N/maximum+1))

Fixed submission:
inputing=input()
N=int(inputing.split()[0])
D=int(inputing.split()[1])

maximum=2*D+1
if N%maximum==0:
    print(int(N/maximum))
else:
    print(int(N/maximum+1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
columns = [int(input()) for i in range(n)]
for order_element in range(0,len(columns)):
    copied=columns.copy()
    copied.pop(order_element)
    print(sorted(copied)[-1])

Fixed submission:
n = int(input())
lister = [int(input()) for i in range(n)]
ordered=sorted(lister,reverse=True)

for element in lister:
  if ordered[0]!=element:
    print(ordered[0])
  else:
    print(ordered[1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
columns = [int(input()) for i in range(n)]
maximum_keeper=[]
for order_element in range(0,len(columns)):
    copied=columns.copy()
    copied.pop(order_element)
    print(max(copied))

Fixed submission:
n = int(input())
lister = [int(input()) for i in range(n)]
ordered=sorted(lister,reverse=True)

for element in lister:
  if ordered[0]!=element:
    print(ordered[0])
  else:
    print(ordered[1])
Buggy python submission (verdict: Runtime Error):
N2 = N
sum = 0
while True:
    sum += N % 10
    N = N // 10
    if N == 0:
        break
if N2 % sum == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
# coding: utf-8
# Your code here!
N = int(input())
N2 = N
sum = 0
while True:
    sum += N % 10
    N = N // 10
    if N == 0:
        break
if N2 % sum == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input)
for i in range(n):
    std_in = input().split()
    dat.append([std_in[0], int(std_in[1])])

for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  # 点数を降順ソートするために点数をマイナスにする。
    e.append(i)  # ソート前の順序
 
    sorted_list = sorted(dat)  # 都市名と点数のマイナス値で昇順ソート
 
for i, s in enumerate(sorted_list):
    # 順序を出力
    print(sorted_list[i][2])


Fixed submission:
n = int(input())
dat = []
for i in range(n):
    std_in = input().split()
    dat.append([std_in[0], int(std_in[1])])
     
for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  # 点数を降順ソートするために点数をマイナスにする。
    e.append(i)  # ソート前の順序
     
sorted_list = sorted(dat)  # 都市名と点数のマイナス値で昇順ソート
     
for i, s in enumerate(sorted_list):
    # 順序を出力
    print(sorted_list[i][2])

Buggy python submission (verdict: Runtime Error):
n = int(input)
for i in range(n):
    std_in = input.split()
    dat.append([std_in[0], int(std_in[1])])

for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  # 点数を降順ソートするために点数をマイナスにする。
    e.append(i)  # ソート前の順序

    sorted_list = sorted(dat)  # 都市名と点数のマイナス値で昇順ソート

for i, s in enumerate(sorted_list):
    # 順序を出力
    print(sorted_list[i][2])


Fixed submission:
n = int(input())
dat = []
for i in range(n):
    std_in = input().split()
    dat.append([std_in[0], int(std_in[1])])
     
for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  # 点数を降順ソートするために点数をマイナスにする。
    e.append(i)  # ソート前の順序
     
sorted_list = sorted(dat)  # 都市名と点数のマイナス値で昇順ソート
     
for i, s in enumerate(sorted_list):
    # 順序を出力
    print(sorted_list[i][2])
Buggy python submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split())
KA = [[int(x) for x in l] for l in [input().split() for i in range(N)]]
[x.pop(0) for x in KA]
x = []
for s in KA:
  x.extend(s)
c = 0
for i in range(1, M + 1):
  c = c + (1 if x.count(i) == N else 0)
print(c)

Fixed submission:
A, B = (int(x) for x in input().split())
if B % A == 0:
  print(A + B)
else:
  print(B - A)

Buggy python submission (verdict: Runtime Error):
A, B = (int(x) for x in input().split())
if B % A == 0:
  return A + B
else:
  return B - A

Fixed submission:
A, B = (int(x) for x in input().split())
if B % A == 0:
  print(A + B)
else:
  print(B - A)
Buggy python submission (verdict: Runtime Error):
T / X

Fixed submission:
s = input().split()
T = int(s[0])
X = int(s[1])
print(T / X)

Buggy python submission (verdict: Runtime Error):
X / T

Fixed submission:
s = input().split()
T = int(s[0])
X = int(s[1])
print(T / X)
Buggy python submission (verdict: Runtime Error):
s = [input() for i in range(2)]
N = int(s[0])
L = map(int, s[1].split())
print(if('Yes', max(L) < sum(L) - max(L), 'No'))

Fixed submission:
s = [input() for i in range(2)]
N = int(s[0])
L = list(map(int, s[1].split()))
print('Yes' if max(L) < sum(L) - max(L) else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
a,b= map(int,input().split())
List=[j for j in range(a,b+1)]
np.asarray(List)
if np.prod(List)>0:
    print("Positive")
elif np.prod(List)<0:
    print("Negative")
else:
    print("Zero")

Fixed submission:
a,b= map(int,input().split())
if a*b<0:
    print("Zero")
elif a>0 or (b-a+1)%2==0 :
    print("Positive")
else:
    print("Negative")
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

cnts = []
for q in range(Q):
	l, r = map(int, input().split())
	cnt = S[l-1:r].count('AC')
	cnts.append(cnt)

for c in cnts:
	print(c)
	

Fixed submission:
# GET AX
N, Q = map(int, input().split())
S = str(input())
lr = [list(map(int, input().split())) for _ in range(Q)]
#N, Q = 8, 3
#S = 'ACACTACG'
#lr = [[3,7],[2,3],[1,8]]

a = [0]*len(S)
ac_num = 0
for i in range(N-1):
	a[i] = ac_num
	if S[i] == 'A' and S[i+1] == 'C':
		ac_num += 1
a[-1] = ac_num

for q in range(Q):
	l, r = lr[q]
	nl = a[l-1]
	nr = a[r-1]
	print(nr - nl)

Buggy python submission (verdict: Time Limit Exceeded):
# GET AX
N, Q = map(int, input().split())
S = str(input())
lr = [list(map(int, input().split())) for _ in range(Q)]

for l, r in lr:
	s = S[l-1:r]
	print(s.count('AC'))

Fixed submission:
# GET AX
N, Q = map(int, input().split())
S = str(input())
lr = [list(map(int, input().split())) for _ in range(Q)]
#N, Q = 8, 3
#S = 'ACACTACG'
#lr = [[3,7],[2,3],[1,8]]

a = [0]*len(S)
ac_num = 0
for i in range(N-1):
	a[i] = ac_num
	if S[i] == 'A' and S[i+1] == 'C':
		ac_num += 1
a[-1] = ac_num

for q in range(Q):
	l, r = lr[q]
	nl = a[l-1]
	nr = a[r-1]
	print(nr - nl)
Buggy python submission (verdict: Time Limit Exceeded):
#Energy Drink Collector
N, M = map(int, input().strip().split())
A = []
B = []
for n in range(N):
	a, b = map(int, input().strip().split())
	A.append(a)
	B.append(b)
total   = 0
collect = 0
while True:
	min_i = A.index(min(A))
	if collect + B[min_i] < M:
		total += A[min_i]*B[min_i]
		collect += B[min_i]
		del A[min_i]
		del B[min_i]
	else:
		total += A[min_i]*(M - collect)
		collect = M
		break
print(total)	

Fixed submission:
#Energy Drink Collector
N, M = map(int, input().strip().split())

list = [list(map(int, input().strip().split())) for i in range(N)]	
list.sort(key = lambda x : x[0])
sum = 0
cnt = 0
for a, b in list:
	if cnt + b < M:
		sum += a*b
		cnt += b
	else:
		sum += a*(M - cnt)
		break

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
# Unification
S = list(map(int, input()))

cnt = 0
idx = 1
prv = S[0]
while idx < len(S):
	if S[idx] != prv:
		cnt += 2
		del S[idx]
		del S[idx-1]
		if len(S) > 0:
			idx = 1
			prv = S[0]
		else:
			break
	else:
		prv = S[idx]
		idx += 1
		
print(cnt)

Fixed submission:
S = input()
ans = 2*min(S.count('0'), S.count('1'))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))

def solve_range(h, start):
	ans = 0
	for i in range(start, len(h)):
		if h[i] > 0:
			h[i] -= 1
		else:
			break
	start = min((i for i in range(len(h)) if h[i] >0), default = -1)
	if start == -1:
		return ans+1
	else:
		ans += solve_range(h, start) + 1
		return ans

start = min((i for i in range(len(h)) if h[i] > 0), default = -1)
a=solve_range(h,start)
print(a)

Fixed submission:
# Grand Garden
N = int(input().strip())
h = list(map(int, input().strip().split()))

def mizu(h, s):
	for k in range(s, len(h)):
		if h[k] > 0:
			h[k] -= 1
		else:
			break
	return h
	
def find_start(h):
	s = 0
	for k in range(len(h)):
		if h[k] > 0:
			s = k
			break
	return s

def is_finish(h):
	if sum(h) == 0:
		return True
	else:
		return False

count = 0
while True:
	if is_finish(h):
		break
	s = find_start(h)
	h = mizu(h, s)
	count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())

A = []
for n in range(N):
    a = int(input())
    A.append(a)

for n in range(N):
    temp = copy.deepcopy(A)
    del temp[n]
    print(max(temp))


Fixed submission:
import copy

N = int(input())

A = []
for n in range(N):
    a = int(input())
    A.append(a)

m = max(A)
flag = 1
for n in range(N):
    if flag == 1 and A[n] == m:
        t = copy.deepcopy(A)
        del t[n]
        print(max(t))
        flag = 0
        continue

    print(m)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
n1 = N-K
mod = 10**9+7
def comb(n, k):
    ans = 1
    for i in range(1, k+1):
        ans = ans*(n+1-i)//i
    return ans

for i in range(1, K+1):
    ans = comb(n1+1, i)
    ans %= mod
    ans *= comb(K-1, i-1)
    ans %= mod
    print(ans)
    

Fixed submission:
N, K = map(int, input().split())
n1 = N-K
mod = 10**9+7
def comb(n, k):
    ans = 1
    for i in range(1, k+1):
        ans = ans*(n+1-i)//i
    return ans

for i in range(1, K+1):
    ans = comb(n1+1, i)
    ans %= mod
    ans *= comb(K-1, i-1)
    ans %= mod
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
As = [int(input()) for _ in range(M)]
mod = 10**9 +7
dp = [0]*(N+1)
dp[0] = 1
if As[0] != 1:
    dp[1] = 1
for i in range(2, N+1):
    if i in As:
        continue
    dp[i] = (dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)



Fixed submission:
N, M = map(int, input().split())
As = [int(input()) for _ in range(M)]+[0]
mod = 10**9 +7
dp = [0]*(N+1)
dp[0] = 1
j = 0
if As[j] != 1:
    dp[1] = 1
else:
    j += 1
for i in range(2, N+1):
    if i == As[j]:
        j += 1
        continue
    dp[i] = (dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
Ss = [input() for _ in range(H)]
L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
D = [[0]*H for _ in range(W)]
U = [[0]*H for _ in range(W)]
for i in range(H):
    for j in range(W):
        if Ss[i][j] == '.':
            if j == 0:
                L[i][0] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        if Ss[i][-j-1] == '.':
            if j == 0:
                R[i][-1] = 1
            else:
                R[i][-j-1] = R[i][-j] + 1
                
for j in range(W):
    for i in range(H):
        if Ss[i][j] == '.':
            if i == 0:
                U[j][0] = 1
            else:
                U[j][i] = U[j][i-1]+1
        if Ss[-i-1][j] == '.':
            if i == 0:
                D[j][-1] = 1
            else:
                D[j][-i-1] = D[j][-i] + 1

ans = 0
for i in range(H):
    for j in range(W):
        x = L[i][j] + R[i][j] + D[j][i] + U[j][i] - 3
        if ans < x:
            ans = x
print(ans)

Fixed submission:
H, W = map(int, input().split())
Ss = [input() for _ in range(H)]
L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
D = [[0]*H for _ in range(W)]
U = [[0]*H for _ in range(W)]
for i in range(H):
    for j in range(W):
        if Ss[i][j] == '.':
            if j == 0:
                L[i][0] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        if Ss[i][-j-1] == '.':
            if j == 0:
                R[i][-1] = 1
            else:
                R[i][-j-1] = R[i][-j] + 1
                
for j in range(W):
    for i in range(H):
        if Ss[i][j] == '.':
            if i == 0:
                U[j][0] = 1
            else:
                U[j][i] = U[j][i-1]+1
        if Ss[-i-1][j] == '.':
            if i == 0:
                D[j][-1] = 1
            else:
                D[j][-i-1] = D[j][-i] + 1

ans = 0
for i in range(H):
    for j in range(W):
        x = L[i][j] + R[i][j] + D[j][i] + U[j][i] - 3
        if ans < x:
            ans = x
print(ans)
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
 
    def root(self, i):
        if self.parent[i] == i:
            return i
        else:
            self.parent[i] = self.root(self.parent[i])
            return self.parent[i]
    
    def find(self, x, y):
        return self.root(x) == self.root(y)
 
    def union(self, i, j):
        i = self.root(i)
        j = self.root(j)
        self.parent[j] = i
N, M = map(int, input().split())
tree = UnionFind(N)
for _ in range(M):
    x, y, z = map(int, input().split())
    tree.union(x-1, y-1)
for i in range(N):
    tree.root(i)
print(len(set(tree.parent)))

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
 
    def root(self, i):
        if self.parent[i] == i:
            return i
        else:
            self.parent[i] = self.root(self.parent[i])
            return self.parent[i]
    
    def find(self, x, y):
        return self.root(x) == self.root(y)
 
    def union(self, i, j):
        i = self.root(i)
        j = self.root(j)
        self.parent[j] = i
N, M = map(int, input().split())
tree = UnionFind(N)
for _ in range(M):
    x, y, z = map(int, input().split())
    tree.union(x-1, y-1)
for i in range(N):
    tree.root(i)
print(len(set(tree.parent)))
Buggy python submission (verdict: Runtime Error):
M, K =map(int, input().split())
if K >= 2**M:
    ans = -1
elif M == 0:
    ans = [0, 0]
elif M == 1:
    if K == 0:
        ans = [0, 1, 1, 0]
    else:
        ans = [0, 0, 1, 1]
else:
    ans = list(range(K-1)) + list(range(K+1, 2**M)) +[K] + list(range(2**M-1, K, -1))+list(range(K-1, -1, -1)) +[K]
print(*ans)

Fixed submission:
M, K =map(int, input().split())
if K >= 2**M:
    ans = [-1]
elif M == 0:
    ans = [0, 0]
elif M == 1:
    if K == 1:
        ans = [-1]
    else:
        ans = [0, 0, 1, 1]
else:
    ans = list(range(K)) + list(range(K+1, 2**M)) +[K] + list(range(2**M-1, K, -1))+list(range(K-1, -1, -1)) +[K]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
R, G , B, N = map(int, input().split())
cnt = 0
for i in range(3001):
    if i*R > N:
        break
    for j in range(3001):
        if i*R + j*G > N:
            break
        if i*R+j*G <= N and (N-i*R-j*G) % B == 0:
            cnt += 1
print(cnt)

Fixed submission:
R, G , B, N = map(int, input().split())
cnt = 0
for i in range(3001):
    for j in range(3001):
        if i*R+j*G <= N and (N-i*R-j*G) % B == 0:
            cnt += 1
print(cnt)

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

Fixed submission:
R, G , B, N = map(int, input().split())
cnt = 0
for i in range(3001):
    for j in range(3001):
        if i*R+j*G <= N and (N-i*R-j*G) % B == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import collections
n, k = map(int, input().split())
s = [int(i) for i in input()]
c = []
prv = 1
cnt = 0
for i in s:
    if prv != i:
        c.append(cnt)
        cnt = 1
        prv = i
    else:
        cnt += 1
if cnt > 0:
    c.append(cnt)
if prv == 0:
    c.append(0)
que = collections.deque(c[0])
res =c[0]
ans = c[0]
m = len(c) // 2
for i in range(m):
    if len(que) == 2*k + 1:
        res -= que.popleft() + que.popleft()
    que.append(c[2*i +1])
    que.append(c[2*i +2])
    res += c[2*i+1] + c[2*i+2]
    ans = max(res, ans)
print(ans)
        

Fixed submission:
import collections
n, k = map(int, input().split())
s = input()
zero =[]
cnt = 0
d = collections.deque()
for i, j in enumerate(s):
    if j == '0':
        cnt += 1
    if j == '1' and i > 0:
        if cnt > 0:
            zero.append((cnt, i-1))
            cnt = 0
if cnt > 0:
    zero.append((cnt, n-1))
idx = n-1
one= []
while zero:
    d.append(zero.pop())
    if len(d) < k:
        continue
    if zero:    
        i, j = zero[-1]
        one.append(idx-j)
    else:
        one.append(idx +1)
    k, l = d.popleft()
    idx = l-k
if one == []:
    one.append(n)
print(max(one))

Buggy python submission (verdict: Runtime Error):
import collections
n, k = map(int, input().split())
s = input()
nums = collections.deque()
anss = collections.deque(maxlen = 2*k +1)
ans = []
c_zero = 0
c_one = 0
if s[1] == '0':
    nums.append(0)
for i in s:
    if i == '0':
        c_zero += 1
        if c_one > 0:
            nums.append(c_one)
            c_one = 0
    elif i == '1':
        c_one += 1
        if c_zero > 0:
            nums.append(c_zero)
            c_zero = 0
if s[-1] == '1':
    nums.append(c_one)
elif s[-1] == '0':
    nums.append(c_zero)
while len(anss) < 2*k +1:
    if len(nums) == 0:
        print(n)
        break
    anss.append(nums.popleft())
if len(nums) == 0:
    print(n)
while nums:
    ans.append(sum(anss))
    if len(nums) == 0:
        break
    anss.append(nums.popleft())
    if len(nums) == 0:
        break
    anss.append(nums.popleft())
    if len(nums) == 0:
        ans.append(sum(anss))
if ans:
    print(max(ans))

Fixed submission:
import collections
n, k = map(int, input().split())
s = input()
zero =[]
cnt = 0
d = collections.deque()
for i, j in enumerate(s):
    if j == '0':
        cnt += 1
    if j == '1' and i > 0:
        if cnt > 0:
            zero.append((cnt, i-1))
            cnt = 0
if cnt > 0:
    zero.append((cnt, n-1))
idx = n-1
one= []
while zero:
    d.append(zero.pop())
    if len(d) < k:
        continue
    if zero:    
        i, j = zero[-1]
        one.append(idx-j)
    else:
        one.append(idx +1)
    k, l = d.popleft()
    idx = l-k
if one == []:
    one.append(n)
print(max(one))