TnT/CodeNet4Repair huggingface dataset:
Problem:
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。                 ■■■■□□□□■■■■ ■■■□□□□□■■■■ ■■□□□□□□■■■■ ■□□□□□□□■■■■ □□□■□□□■□□□□ □□□□□□■■■□□□ □□□□□■■■■■□□ ■□□□■■■■■■■□ ■■□□□■■■■■□□ ■■■□□□■■■□□□ ■■■■□□□■□□□□ □□□□□□□□□□□□   マスのデータを読み込んで、島の数を出力するプログラムを作成してください。

Incorrect submission (verdict: Wrong Answer):
# AOJ 0067 The Number of Island
# Python3 2018.6.16 bal4u

# UNION-FIND library
MAX = 12*12

id, size = [0]*MAX, [0]*MAX

def init(n):
	for i in range(n): id[i], size[i] = i, 1
	
def root(i):
	while i != id[i]:
		id[i] = id[id[i]]
		i = id[i]
	return i
	
def connected(p, q):
	return root(p) == root(q)
	
def unite(p, q):
	i, j = root(p), root(q)
	if i == j: return
	if size[i] < size[j]:
		id[i] = j
		size[j] += size[i]
	else:
		id[j] = i
		size[i] += size[j]
# UNION-FIND library

arr = [[0 for r in range(12)] for c in range(12)]
dr = [-1,0,1, 0 ]
dc = [ 0,1,0,-1 ]

while True:
	init(12*12)
	for r in range(12): arr[r] = list(map(int, input()))

	for r in range(12): print('r=', arr[r])

	for r in range(12):
		for c in range(12):
			if arr[r][c] == 0: continue
			for i in range(4):
				nr, nc = r + dr[i], c + dc[i]
				if nr >= 0 and nr < 12 and nc >= 0 and nc < 12:
					if arr[nr][nc] == 1:
						unite(r*12+c, nr*12+nc)
	
	ans = 0
	for r in range(12):
		for c in range(12):
			if arr[r][c] == 1 and root(r*12+c) == r*12+c: ans += 1

	print(ans)
	try: input()
	except: break


Fixed, accepted submission:
# AOJ 0067 The Number of Island
# Python3 2018.6.16 bal4u

# UNION-FIND library
MAX = 12*12

id, size = [0]*MAX, [0]*MAX

def init(n):
	for i in range(n): id[i], size[i] = i, 1
	
def root(i):
	while i != id[i]:
		id[i] = id[id[i]]
		i = id[i]
	return i
	
def connected(p, q):
	return root(p) == root(q)
	
def unite(p, q):
	i, j = root(p), root(q)
	if i == j: return
	if size[i] < size[j]:
		id[i] = j
		size[j] += size[i]
	else:
		id[j] = i
		size[i] += size[j]
# UNION-FIND library

arr = [[0 for r in range(12)] for c in range(12)]
dr = [-1, 0, 1, 0]
dc = [ 0, 1, 0,-1]

while True:
	init(12*12)
	for r in range(12): arr[r] = list(map(int, input()))

	for r in range(12):
		for c in range(12):
			if arr[r][c] == 0: continue
			for i in range(4):
				nr, nc = r + dr[i], c + dc[i]
				if nr >= 0 and nr < 12 and nc >= 0 and nc < 12:
					if arr[nr][nc] == 1:
						unite(r*12+c, nr*12+nc)
	
	ans = 0
	for r in range(12):
		for c in range(12):
			if arr[r][c] == 1 and root(r*12+c) == r*12+c: ans += 1

	print(ans)
	try: input()
	except: break
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Incorrect submission (verdict: Wrong Answer):
s = list(input())
for i in range(1,len(s),2):
    print(s[i],end="")
print()

Fixed, accepted submission:
s = list(input())
for i in range(0,len(s),2):
    print(s[i],end="")
print()
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):


import itertools
N, K = input().split()
P = input().split()


a= sorted(set([str(i) for i in range(10)])-set(P))

b1 = itertools.product(a, repeat=len(N))

b2 = itertools.product(a, repeat=len(N)+1)
ans=str()
cnt=0
for i in b1:
  #print(type(i))
  ans = "".join(i)
  if N <= ans:
    print(ans)
    cnt=1
    break
if cnt==1:
  for i in b2:
    ans = "".join(i)
    if N <= ans:
      print(ans)
      break

Fixed, accepted submission:


import itertools
N, K = input().split()
P = input().split()


a= sorted(set([str(i) for i in range(10)])-set(P))

b1 = itertools.product(a, repeat=len(N))

b2 = itertools.product(a, repeat=len(N)+1)
ans=str()
cnt=0
for i in b1:
  #print(type(i))
  ans = "".join(i)
  if N <= ans:
    print(ans)
    cnt=1
    break
if cnt==0:
  for i in b2:
    ans = "".join(i)
    #print(ans)
    if "0"+N <= ans:
      print(ans)
      break
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = int(input())
if N <= A:
    print("Yes")
elif N - 500 <= A:
    print ("Yes")
else:
    print("No")
    

Fixed, accepted submission:
N = int(input())
A = int(input())
r = N%500
if A >= r:
    print("Yes")
else:
    print("No")
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):
a,b,c=map(int,input().split())
print("YES" if a<c<b or b<c<a else "NO")

Fixed, accepted submission:
a,b,c=map(int,input().split())
print("Yes" if a<c<b or b<c<a else "No")
Problem:
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.  The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it.  Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.  Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
a=[int(input())for i in range(N)]
p=1
ok=False
ans=0
for i in range(N):
    ans+=1
    if p==2:
        ok=True
        break
    p=a[p-1]
print(ans if ok else -1)

Fixed, accepted submission:
N=int(input())
a=[int(input())for i in range(N)]
p=1
ok=False
ans=0
for i in range(N):
    if p==2:
        ok=True
        break
    p=a[p-1]
    ans+=1
print(ans if ok else -1)
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
a = list(map(int,input().split()))
print(sum(a)-sum(list(set(a))))

Fixed, accepted submission:
a = list(map(int,input().split()))
if a[0]!=a[1]and a[0]!=a[2]:
  print(a[0])

elif a[1]!=a[0]and a[1]!=a[2]:
  print(a[1])

else:
  print(a[2])
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
S = input()
count = 0
for i in range(3):
    if S[i] == 1:
        count += 1
print(count)

Fixed, accepted submission:
S = input()
count = 0
for i in range(3):
    if S[i] == "1":
        count += 1
print(count)
Problem:
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied:    * Each lowercase letter of the English alphabet occurs even number of times in w.  You are given the string w. Determine if w is beautiful.

Incorrect submission (verdict: Wrong Answer):
from collections import Counter
W = input()

Ans = "YES"

C = Counter(W).items()
for c in C:
    _x,cnt = c
    if cnt%2 != 0:
        Ans = "NO"
        break

print(Ans)



Fixed, accepted submission:
# python 3.4.3
import sys
input = sys.stdin.readline
# import numpy as np
from collections import Counter

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
W = input().rstrip()

C = Counter(W).most_common()

ans = "Yes"
for _,cnt in C:
    if cnt%2 == 1:
        ans = "No"
        break

print(ans)
Problem:
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.  Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.  Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.                 void call(int n){   int i = 1;  CHECK_NUM:   int x = i;   if ( x % 3 == 0 ){     cout << " " << i;     goto END_CHECK_NUM;   }  INCLUDE3:   if ( x % 10 == 3 ){     cout << " " << i;     goto END_CHECK_NUM;   }   x /= 10;   if ( x ) goto INCLUDE3;  END_CHECK_NUM:   if ( ++i <= n ) goto CHECK_NUM;    cout << endl; }

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

n = int(input())
i = 1

while True:
    if i % 3 == 0 | i % 10 == 3:
        print(' {0}'.format(i))

    i += 1
    if i > n:
        break



Fixed, accepted submission:
# -*- coding: utf-8 -*-
from functools import reduce

n = int(input())
i = 1

while True:

    a = [int(x) for x in list(str(i))]

    if 3 in a:
        print(" {0}".format(int(reduce(lambda x, y: x + y, [str(x) for x in a]))), end='')
    elif sum(a) % 3 == 0:
        print(" {0}".format(int(reduce(lambda x, y: x + y, [str(x) for x in a]))), end='')

    i += 1
    if i > n:
        print()
        break
Problem:
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())

numbers_list = [i for i in range(a,b+1) if i%c==0]

print(len(numbers_list))

Fixed, accepted submission:
a, b, c = map(int, input().split())

numbers_list = [i for i in range(a,b+1) if c % i == 0]

print(len(numbers_list))
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
a, b, c = input().split()

if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')


Fixed, accepted submission:
a, b, c = map(int, input().split())

if a <= c and c <= b:
    print('Yes')
else:
    print('No')
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
S = int(input())
h = int(S/360)
m = int((S - h*360)/60)
s = int(S - h*360 -m*60)
print(h, ':', m, ':', s)


Fixed, accepted submission:
S = int(input())
h = int(S/3600)
m = int((S - h*3600)/60)
s = int(S - h*3600 - m*60)
print(h, ':', m, ':', s, sep='')
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

Incorrect submission (verdict: Wrong Answer):
s = input()
print(s)
count = 0
if s[0] == '1':
  count+=1 
if s[1] == '1':
  count+=1
if s[2] == '1':
  count+=1
  
print(count)

Fixed, accepted submission:
s = input()
count = 0
if s[0] == '1':
  count+=1 
if s[1] == '1':
  count+=1
if s[2] == '1':
  count+=1
  
print(count)
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
from math import sqrt, floor

n = int(input())
print((floor(sqrt(n)))^2)

Fixed, accepted submission:
from math import sqrt, floor

n = int(input())
rt = floor(sqrt(n))
print(rt**2)
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-1)

Fixed, accepted submission:
n=int(input())
if n%2==0:
  print(n//2-1)
else:
  print(n//2)
Problem:
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.

Incorrect submission (verdict: Wrong Answer):
D = int(input())#D=365
c = list(map(int, input().split()))#0<=c<=100
s = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [int(input()) for _ in range(D)]


v = []
last = [0] * 26
value = 0
for d in range(D):
    for i in range(26):
        value += s[d][i]
        value += c[i] * (d - last[i])
    v.append(value)

for i in range(D):
    print(v[i])


Fixed, accepted submission:
D = int(input())#D=365
c = list(map(int, input().split()))#0<=c<=100
s = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [int(input()) for _ in range(D)]


v = []
last = [0] * 26
value = 0
for d in range(D):
    type = t[d]
    value += s[d][type - 1]
    last[type - 1] = d + 1
    for i in range(26):
        value -= c[i] * (d + 1 - last[i])
    v.append(value)

for i in range(D):
    print(v[i])
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Incorrect submission (verdict: Wrong Answer):
X = int(input())
listx = []

for i in range(40):
    for j in range(2,11):
        if i**j<=X:
            listx.append(i**j)
print(max(listx))
print(listx)

Fixed, accepted submission:
X = int(input())
listx = []

for i in range(40):
    for j in range(2,11):
        if i**j<=X:
            listx.append(i**j)
print(max(listx))
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())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(0,n,2):
  ans+=i
for i in range(1,n,2):
  ans-=i
print(ans)

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(0,n,2):
  ans+=a[i]
for i in range(1,n,2):
  ans-=a[i]
print(ans)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):
import random
s = list(input())
s_ = str(random.shuffle(s))
t = list(input())
t_ = str(random.shuffle(t))
print('Yes' if s_< t_ else 'No')

Fixed, accepted submission:
s = list(input())
s_ = sorted(s)
t = list(input())
t_ = sorted(t,reverse=True)
print('Yes' if s_< t_ else 'No')
Problem:
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.  You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.

Incorrect submission (verdict: Wrong Answer):
s = "".join(list(reversed(input())))
n = len(s)

ans = 0
for i in range(n):
    if (n - i) % 2 == 0:
        now = s[i:]
        if now[(n-i)//2:] == now[:(n-i)//2]:
            ans = n - i
            break
print(ans)


Fixed, accepted submission:
s = "".join(list(reversed(input())))
n = len(s)

ans = 0
for i in range(1, n):
    if (n - i) % 2 == 0:
        now = s[i:]
        if now[(n-i)//2:] == now[:(n-i)//2]:
            ans = n - i
            break
print(ans)
Problem:
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.  We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.  Find the maximum number of robots that we can keep.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
x=[]
l=[]
w=[]
max=-(10**10)
num=0
for i in range(n):
    X,L=map(int,input().split())
    x.append(X)
    l.append(L)
    w.append(X-L)
    w.append(X+L)
for i in range(len(w)):
    if (w[i]<max) and i%2==0:
        num+=1
    elif (w[i]<max) and i%2==1:
        num+=0
    else:
        max=w[i]
print(len(w)-num)


Fixed, accepted submission:
n=int(input())
w=[]
for i in range(n):
    x,l=map(int,input().split())
    w.append([x-l,x+l])
w.sort(key=lambda x: x[1])
val=-(10**10)
ans=0
for i in range(n):
    if val<=w[i][0]:
        ans+=1
        val=w[i][1]
print(ans)
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
ans = np.array(a)
k = 2
for i in reversed(range(1, n+1)):
    if n/k < i:
        for x in range(2, k):
            ans[i-1] += ans[x * i - 1]
        ans[i-1] = ans[i-1] % 2
    else:
        k += 1
        for x in range(2, k):
            ans[i-1] += ans[x * i - 1]
        ans[i-1] = ans[i-1] % 2

print(np.sum(ans))
for p in np.ndarray.flatten(np.argwhere(ans) + 1):
    print(p, end=' ')

Fixed, accepted submission:
n = int(input())
a = list(map(int,input().split()))
ans = []
k = 2
for i in range(n, 0, -1):
    if n/k < i:
        for x in range(2, k):
            a[i-1] += a[x * i - 1]
        a[i-1] = a[i-1] % 2
    else:
        while n/k >= i:
            k += 1
        else:
            for x in range(2, k):
                a[i-1] += a[x * i - 1]
            a[i-1] = a[i-1] % 2
    if a[i-1] == 1:
        ans.append(i)
print(len(ans))
print(*ans)
Problem:
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.  Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut:    * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).   * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.  Find the minimum amount of money needed before cutting the bar into two parts with the same length.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
su=0
mi=2000000
for i in range(n):
  su+=a[i]
  left=n-su
  mi=min(mi,max((su-left),(left-su)))

print(mi)

Fixed, accepted submission:
n=int(input())
a=list(map(int,input().split()))
su=0
mi=20000000000000000000
for i in range(n):
  su+=a[i]
  
c=0  
for i in range(n):
  c+=a[i]
  left=su-c
  mi=min(mi,max((c-left),(left-c)))

print(mi)
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
H,W=map(int, input().split())
str_ = ""
for i in range(W):
  str_ = str_ + "#"
print(str_)
for i in range(H):
  S=str(input())
  print("#"+S+"#")
print(str_)

Fixed, accepted submission:
H,W=map(int, input().split())
str_ = ""
for i in range(W+2):
  str_ = str_ + "#"
print(str_)
for i in range(H):
  S=str(input())
  print("#"+S+"#")
print(str_)
Problem:
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode:                 BubbleSort(A) 1 for i = 0 to A.length-1 2     for j = A.length-1 downto i+1 3         if A[j] < A[j-1] 4             swap A[j] and A[j-1]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 4 of the pseudocode.

Incorrect submission (verdict: Wrong Answer):
# selection sort
N = int(input())
A = [int(i) for i in input().split()]

cnt = 0

for i in range(0, N):
    min_i = i
    for j in range(i+1, N)[::-1]:
        if A[j] < A[min_i]:
            min_i = j
    if i != min_i:
        A[i], A[min_i] = A[min_i], A[i]
        cnt = cnt + 1

print(' '.join([str(i) for i in A]))
print(cnt)

Fixed, accepted submission:
N = int(input())
A = [int(i) for i in input().split()]

cnt = 0

for i in range(0, N):
    for j in range(i+1, N)[::-1]:
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            cnt = cnt + 1

print(' '.join([str(item) for item in A]))
print(cnt)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
coins = []
for i in range(0, 4):
  coins.append(int(input()))

count = 0

for i in range(1, coins[0] + 1):
  for j in range(1, coins[1] + 1):
    for k in range(1, coins[2] + 1):
      ans = 500*i + 100*j + 50*k
      if ans == coins[3]:
        count += 1
print(count)




Fixed, accepted submission:
url = "https://atcoder.jp/contests/abc087/tasks/abc087_b"

def main():
    coins = [int(input()) for v in range(3)]
    che = int(input())
    count = 0
    for i in range(0, coins[0] + 1):
        for j in range(0, coins[1] + 1):
            for k in range(0, coins[2] + 1):
                if che == (500 * i) + (100 * j) + (50 * k):
                    count += 1
    print(count)


if __name__ == '__main__':
    main()