TnT/CodeNet4Repair huggingface dataset:
Problem:
You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i.  You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W.  Your objective is to maximize the total value of the selected items.

Incorrect submission (verdict: Wrong Answer):
N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]

w0 = items[0][0]
memo = [{} for i in range(N + 1)]

memo[0] = {0: 0}
for i, (wi, vi) in enumerate(items):
    for w, v in memo[i].items():

        if w + wi <= W:
            memo[i + 1][w + wi] = v + vi

        memo[i + 1][w] = max(memo[i + 1].get(w, 0), memo[i][w])

print(max(memo[N].values()))


Fixed, accepted submission:
import itertools

N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]

minW = items[0][0]
arrVs = [[] for i in range(4)]
for w, v in items:
    arrVs[w - minW].append(v)

acc = [[] for i in range(4)]
for i, arrV in enumerate(arrVs):
    arrV.sort(reverse=True)
    acc[i] = [0] + list(itertools.accumulate(arrV))

num = [range(len(acc[i])) for i in range(4)]

ans = 0
for n in itertools.product(num[0], num[1], num[2], num[3]):
    w = sum([n[i] * (minW + i) for i in range(4)])
    v = sum([acc[i][n[i]] for i in range(4)])
    if w <= W:
        ans = max(ans, v)

print(ans)
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
s = [int(i) for i in input().split(" ")]
count = 0

if s[0] < s[1]:
    for i in range(s[0], s[1]):
        print("1<2 : {}".format(i))
        if i == s[2]:
            print("Yes")
            count = 1
            break

else:
    for i in range(s[1], s[0]):
        print("2<1 : {}".format(i))
        if i == s[2]:
            print("Yes")
            count = 1
            break

if count == 0:
    print("No")

Fixed, accepted submission:
s = [int(i) for i in input().split(" ")]
count = 0

if s[0] < s[1]:
    for i in range(s[0], s[1]):
        if i == s[2]:
            print("Yes")
            count = 1
            break

else:
    for i in range(s[1], s[0]):
        if i == s[2]:
            print("Yes")
            count = 1
            break

if count == 0:
    print("No")
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
x,a,b = map(int, input().split())
print("A" if abs(x-a)>abs(x-b) else "B")

Fixed, accepted submission:
x,a,b = map(int, input().split())
print("A" if abs(x-a)<abs(x-b) else "B")
Problem:
There is a grid with H rows and W columns.  The square at the i-th row and j-th column contains a string S_{i,j} of length 5.  The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet.    Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location.  For example, the square at the 6-th row and 8-th column should be reported as `H6`.

Incorrect submission (verdict: Wrong Answer):
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [input() for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "snuke":
      print("{}{}".format(i+1, alpha[j]))

Fixed, accepted submission:
H, W = map(int, input().split())
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
S = [list(map(str, input().split())) for _ in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "snuke":
      print("{}{}".format(alpha[j], i+1))
Problem:
AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition:  (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).  Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.  _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_  With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.  The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn.

Incorrect submission (verdict: Wrong Answer):
s=input()
g=s.count('g')
p=s.count('p')
a=g-p+(g+p)//2
print(a)

Fixed, accepted submission:
s=input()
g=s.count('g')
p=s.count('p')
a=(-p+(g+p)//2)
print(a)
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

Incorrect submission (verdict: Wrong Answer):
x = int(input())
a = int(input())
b = int(input())

x = x -a
count = 0
while x - b < 0:
  x = x - b
  count += 1
  
print(x)
  

Fixed, accepted submission:
x = int(input())
a = int(input())
b = int(input())

x = x - a
while x - b >= 0:
  x = x - b
print(x)
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
x, a, b=map(int, input().split())
if a<=b:
  print('delicious')
else:
  if b-a<x+1:
    print('safe')
  else:
    print('dangerous')

Fixed, accepted submission:
x, a, b=map(int, input().split())
if a>=b:
  print('delicious')
else:
  if b-a<x+1:
    print('safe')
  else:
    print('dangerous')
Problem:
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.  You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0.  However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned.  For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]
b = []

for i in range(n):
  if i == 0:
    b.append(abs(a[i]))
  if i == n - 1:
    b.append(abs(a[i]))
  else:
    b.append(abs(a[i] - a[i - 1]))
  

sd = sum(b)

for j in range(n):
  if j == 0:
    print(sd - b[j] - b[j + 1] + abs(a[j + 1]))
  if j == n - 1:
    print(sd - b[j + 1] - b[j] + abs(a[j]))
  else:
    print(sd - b[j] - b[j + 1] + abs(a[j + 1] - a[j - 1]))
  

Fixed, accepted submission:
n = int(input())
a = [int(x) for x in input().split()]
b = []

for i in range(n + 1):
  if i == 0:
    b.append(abs(a[i]))
  elif i == n:
    b.append(abs(a[i - 1]))
  else:
    b.append(abs(a[i] - a[i - 1]))
  

sd = sum(b)

for j in range(n):
  if j == 0:
    print(sd - b[j] - b[j + 1] + abs(a[j + 1]))
  elif j == n - 1:
    print(sd - b[j] - b[j + 1] + abs(a[j - 1]))
  else:
    print(sd - b[j] - b[j + 1] + abs(a[j + 1] - a[j - 1]))
Problem:
You are given three integers A, B and C.  Determine if there exists an equilateral triangle whose sides have lengths A, B and C.

Incorrect submission (verdict: Wrong Answer):
A,B,C=map(int,input().split())
if A-B==2*C:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
A,B,C=map(int,input().split())
if A==B and A==C:
  print("Yes")
else:
  print("No")
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
a, b = 0, 0
print(l)
for i in range(len(l)):
  if i % 2 == 0:
    a += l[i]
  else:
    b += l[i]

print(abs(a-b))


Fixed, accepted submission:
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
a, b = 0, 0
for i in range(len(l)):
  if i % 2 == 0:
    a += l[i]
  else:
    b += l[i]

print(abs(a-b))
Problem:
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.  Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.  Find the duration of time when some song was played while Niwango was asleep.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
l=[input().split() for i in range(n)]
x=input()

ans=0
sum=0
for i,j in l:
 print(i,j)
 if i!=x:
  ans+=int(j)
 else:
  ans+=int(j)
  break
for i,j in l:
 sum+=int(j)
print(sum-ans)

Fixed, accepted submission:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[input().split() for i in range(n)]
x=input()

ans=0
c=False
for s,t in l:
  if c:
    ans+=int(t)
  if x==s:
    c=True

print(ans)
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
A, B = map(int, input().split())
line = []
for k in range(0,A):
    line.append(k)
line = line[1::2]
if len(line) >= B:
    print("YES")
else:
    print("NO")


Fixed, accepted submission:

A, B = map(int, input().split())
line = []
for k in range(0,A+1):
    line.append(k)
line = line[1::2]

if len(line) >= B:
    print("YES")
else:
    print("NO")
Problem:
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail:                 Counting-Sort(A, B, k) 1    for i = 0 to k 2        do C[i] = 0 3    for j = 1 to length[A] 4        do C[A[j]] = C[A[j]]+1 5    /* C[i] now contains the number of elements equal to i */ 6    for i = 1 to k 7    do C[i] = C[i] + C[i-1] 8    /* C[i] now contains the number of elements less than or equal to i */ 9    for j = length[A] downto 1 10       do B[C[A[j]]] = A[j] 11          C[A[j]] = C[A[j]]-1   Write a program which sorts elements of given array ascending order based on the counting sort.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def counting_sort(A, k):
    B = [0] * k
    C = [0] * k
    for j in range(array_length):
        C[A[j]] += 1
    print('1', C[:array_length])

    for i in range(1, k):
        C[i] += C[i - 1]
    print('2', C[:array_length])

    for m in range(array_length - 1, -1, -1):
        B[C[A[m]]] = A[m]
        C[A[m]] -= 1

    return B[1:array_length + 1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    MAX_ELEM = int(1e4 + 1)
    result = counting_sort(A=array, k=MAX_ELEM)
    print(*result)

Fixed, accepted submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def counting_sort(A, max_occurance):
    result = [0] * array_length
    count_list = [0] * max_occurance

    for j in range(array_length):
        count_list[A[j]] += 1
    # print('step-1', C[:array_length])

    for i in range(1, max_occurance):
        count_list[i] += count_list[i - 1]
    # print('step-2', C[:array_length])

    for m in array[::-1]:
        result[count_list[m] - 1] = m
        count_list[m] -= 1

    return result


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    max_elem = int(1e4)
    result = counting_sort(A=array, max_occurance=max_elem)
    print(*result)
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
print(a - (0 if a < b else 1))

Fixed, accepted submission:
a, b = map(int, input().split())
print(a - (0 if a <= b else 1))
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
print(int(input())%1000)

Fixed, accepted submission:
X = int(input())
lack = X % 1000
if lack == 0:
  print(0)
else:
  print(1000 - lack)
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):

t = []
x = []
y = []

t.append(0)
x.append(0)
y.append(0)

for i in (range(0, 1000000, 1)):
  try:
    c = input()
    if i == 0:
      N = int(c)
    else:
      t.append(int(c.split(" ")[0]))
      x.append(int(c.split(" ")[1]))
      y.append(int(c.split(" ")[2]))
  except:
    break

for i in range(0, len(t) - 1, 1):
  
  con1 = t[i + 1] >= (x[i + 1] + y[i + 1]) 
  dt = t[i+1] - t[i]
  dist = (x[i+1]-x[i]) + (y[i+1] - y[i]) 
  
  print("{0} {1} {2}".format(con1, dist, dt))
  
  if con1 is True and (dt - dist) %2 == 0:
    print("yes")
  else:
    print("No")
    break
  
  
    
  
  
  

Fixed, accepted submission:

t = []
x = []
y = []

t.append(0)
x.append(0)
y.append(0)

for i in (range(0, 1000000, 1)):
  try:
    c = input()
    if i == 0:
      N = int(c)
    else:
      t.append(int(c.split(" ")[0]))
      x.append(int(c.split(" ")[1]))
      y.append(int(c.split(" ")[2]))
  except:
    break

for i in range(0, len(t) - 1, 1):
  
  con1 = t[i + 1] >= (x[i + 1] + y[i + 1]) 
  dt = t[i+1] - t[i]
  dist = (x[i+1]-x[i]) + (y[i+1] - y[i]) 

  if con1 is True and (dt - dist) %2 == 0:
    ans = "Yes"
  else:
    ans = "No"
    break
    
print(ans)
Problem:
You are given two integers A and B as the input. Output the value of A + B.  However, if A + B is 10 or greater, output `error` instead.

Incorrect submission (verdict: Wrong Answer):
s = str(input())
if s == set(s):
    print("yes")
else:
    print("no")

Fixed, accepted submission:
h , w = map(int, input().split())

if(h + w < 10):
    print(h + w)
else:
    print("error")
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
a, b, x = map(int, input().split())
print('Yes' if a <= x and a+b >= x else 'No')

Fixed, accepted submission:
a, b, x = map(int, input().split())
print('YES' if a <= x and a+b >= x else 'NO')
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
import math

n, k = [int(i) for i in input().split()]

if math.ceil(n-1) < k:
    print("No")
else:
    print("Yes")

Fixed, accepted submission:
import math

n, k = [int(i) for i in input().split()]

if math.ceil(n/2) < k:
    print("NO")
else:
    print("YES")
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
N=int(input()) 
pre_t=0
pre_x=0
pre_y=0
for i in range(N):
    now_t,now_x,now_y=list(map(int,input().split()))
    d=abs(pre_x-now_x)+abs(pre_y-now_y)
    t=pre_t-now_t
    if d<=t and t%2==d%2:
        flg=1
    else:
        flg=0
        break
if flg==1:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
N = int(input()) 
pre_t = 0
pre_x = 0
pre_y = 0

for i in range(N):
    now_t,now_x,now_y = list(map(int,input().split()))
    d = abs(now_x - pre_x) + abs(now_y - pre_y)
    t = now_t - pre_t
    if d <= t and t % 2 == d % 2:
        flg = 1
    else:
        flg = 0
        break

if flg == 1:
    print('Yes')
else:
    print('No')
Problem:
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.  Snuke's objective is to permute the element in a so that the following condition is satisfied:    * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.  Determine whether Snuke can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
l = list(map(int,input().split()))

num_odd = 0
num_even = 0
num_four = 0

for i in l:
    if i % 4 == 0:
        num_four += 1
    elif i % 2 == 0:
        num_even += 1
    else:
        num_odd += 1

if num_four <= 2 * num_odd:
    ans = "No"
else:
    ans = "Yes"
print(ans)


Fixed, accepted submission:
N = int(input())
l = list(map(int,input().split()))

num_odd = 0
num_even = 0
num_four = 0

for i in l:
    if i % 2 == 1:
        num_odd += 1
    elif i % 4 == 0:
        num_four += 1
    else:
        num_even += 1

if num_four + 1 > num_odd:
    ans = "Yes"
elif num_four + 1 == num_odd and num_even == 0:
    ans = "Yes"
else:
    ans = "No"
print(ans)
Problem:
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.   According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.   Determine if he is correct.

Incorrect submission (verdict: Wrong Answer):
l=[]
for i in range(3):
  l1=list(map(int,input().split()))
  l.append(l1)
flag=0
for i in range(l[0][0]+1):
  y0=l[0][0]-i
  y1=l[1][0]-i
  y2=l[2][0]-i
  x1=l[0][1]-y1
  x2=l[0][2]-y1
  if l[1][1]==y1+x1 and l[1][2]==y1+x2 and l[2][1]==y2+x1 and l[2][2]==y2+x2:
    flag=1
  else:
    continue
if flag==1:
  print('Yes')
else:
  print('No')


Fixed, accepted submission:
l=[]
for i in range(3):
  l1=list(map(int,input().split()))
  l.append(l1)
flag=0
y0=l[0][0]-0
y1=l[1][0]-0
y2=l[2][0]-0
x1=l[0][1]-y0
x2=l[0][2]-y0
if l[1][1]==y1+x1 and l[1][2]==y1+x2 and l[2][1]==y2+x1 and l[2][2]==y2+x2:
    flag=1
else:
    pass
if flag==1:
  print('Yes')
else:
  print('No')
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
print(-(n//-2))


Fixed, accepted submission:
n=int(input())
print((n-1)//2)
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
num = int(input())
print(num % 1000)

Fixed, accepted submission:
num = int(input())
val = num % 1000
if val == 0: print(0)
else: print(1000 - val)
Problem:
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`.  You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.

Incorrect submission (verdict: Wrong Answer):
s = input()
slen =len(s)
ans = s[0:1]+str(slen)+s[-1:]
print(ans)

Fixed, accepted submission:
s = input()
slen =len(s)
ans = s[0:1]+str(slen-2)+s[-1:]
print(ans)
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

Incorrect submission (verdict: Wrong Answer):
r,g,b,n = [int(i) for i in input().split()]

cnt = 0
for i in range(n//r+1):
  n_r = i*r
  if n_r > n:
    break
  for j in range(n//g+1):
    n_rg = j*g + n_r
    if n_rg > n:
      break
    if n_rg%b == 0:
      cnt += 1
        
print(cnt)

Fixed, accepted submission:
r,g,b,n = [int(i) for i in input().split()]

cnt = 0
for i in range(n//r+1):
  n_r = i*r
  if n_r > n:
    break
  for j in range(n//g+1):
    n_rg = j*g + n_r
    if n_rg > n:
      break
    if (n-n_rg)%b == 0:
      cnt += 1
        
print(cnt)