TnT/CodeNet4Repair huggingface dataset:
Problem:
English text is not available in this practice contest.  ケン・マリンブルーは，宇宙ヤシガニを求めて全銀河を旅するスペースハンターである．宇宙ヤシガニは，宇宙最大とされる甲殻類であり，成長後の体長は 400 メートル以上，足を広げれば 1,000 メートル以上にもなると言われている．既に多数の人々が宇宙ヤシガニを目撃しているが，誰一人として捕らえることに成功していない．  ケンは，長期間の調査によって，宇宙ヤシガニの生態に関する重要な事実を解明した．宇宙ヤシガニは，驚くべきことに，相転移航法と呼ばれる最新のワープ技術と同等のことを行い，通常空間と超空間の間を往来しながら生きていた．さらに，宇宙ヤシガニが超空間から通常空間にワープアウトするまでには長い時間がかかり，またワープアウトしてからしばらくは超空間に移動できないことも突き止めた．  そこで，ケンはついに宇宙ヤシガニの捕獲に乗り出すことにした．戦略は次のとおりである．はじめに，宇宙ヤシガニが通常空間から超空間に突入する際のエネルギーを観測する．このエネルギーを _e_ とするとき，宇宙ヤシガニが超空間からワープアウトする座標 ( _x_ , _y_ , _z_ ) は以下の条件を満たすことがわかっている．    * _x_ , _y_ , _z_ はいずれも非負の整数である．   * _x_ \+ _y_ 2 \+ _z_ 3 = _e_ である．   * 上記の条件の下で _x_ \+ _y_ \+ _z_ の値を最小にする．  これらの条件だけでは座標が一意に決まるとは限らないが， _x_ \+ _y_ \+ _z_ の最小値を _m_ としたときに，ワープアウトする座標が平面 _x_ \+ _y_ \+ _z_ = _m_ 上にあることは確かである．そこで，この平面上に十分な大きさのバリアを張る．すると，宇宙ヤシガニはバリアの張られたところにワープアウトすることになる．バリアの影響を受けた宇宙ヤシガニは身動きがとれなくなる．そこをケンの操作する最新鋭宇宙船であるウェポン・ブレーカー号で捕獲しようという段取りである．  バリアは一度しか張ることができないため，失敗するわけにはいかない．そこでケンは，任務の遂行にあたって計算機の助けを借りることにした．あなたの仕事は，宇宙ヤシガニが超空間に突入する際のエネルギーが与えられたときに，バリアを張るべき平面 _x_ \+ _y_ \+ _z_ = _m_ を求めるプログラムを書くことである．用意されたテストケースの全てに対して正しい結果を出力したとき，あなたのプログラムは受け入れられるであろう．

Incorrect submission (verdict: Wrong Answer):
cubics = [ x * x * x for x in range(0, 100)]
squares = [ x * x for x in range(0, 1000) if x * x < 100 ** 3 - 99 ** 3]
while True:
    x, y, z = 0, 0, 0
    e = int(input())
    if e == 0: break
    for i in range(len(cubics)):
        if e - cubics[i] < 0:
            e -= cubics[i - 1]
            z = i - 1
            break
    for i in range(len(squares)):
        if e - squares[i] < 0:
            e -= squares[i -1]
            y = i - 1
            break
    x = e
    print(x + y + z)

Fixed, accepted submission:
from math import floor, sqrt

cubics = [ x * x * x for x in range(101)]
squares = [ x * x for x in range(1000)]
while True:
    m = 1000000
    e = int(input())
    if e == 0: break
    for z in range(len(cubics)):
        if e < cubics[z]: break
        tmp = e - cubics[z]
        y = floor(sqrt(tmp))
        x = tmp - y ** 2
        m = min(m, x + y + z)
    print(m)
Problem:
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.  He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.  To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.  How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

Incorrect submission (verdict: Wrong Answer):
import bisect
n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    b = B[i]
    a = bisect.bisect_left(A, b)
    c = n-bisect.bisect_right(C, b)
    print(a, b, c)
    ans += a*c
print(ans)


Fixed, accepted submission:
import bisect
n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    b = B[i]
    a = bisect.bisect_left(A, b)
    c = n-bisect.bisect_right(C, b)
    ans += a*c
print(ans)
Problem:
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b.  Determine whether the arrangement of the poles is beautiful.

Incorrect submission (verdict: Wrong Answer):

a,b,c = map(int,input().split())


if b - a == b - c:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:

a,b,c = map(int,input().split())


if b - a == c - b:
    print("YES")
else:
    print("NO")
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n = int(input())

s = []
for _ in range(n):
  s1 = input()
  s.append(s1)

print('AC × ' + str(s.count('AC')))
print('WA × ' + str(s.count('WA')))
print('TLE × ' + str(s.count('TLE')))
print('RE × ' + str(s.count('RE')))

Fixed, accepted submission:
n = int(input())

s = []
for _ in range(n):
  s1 = input()
  s.append(s1)

print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))
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("YNEOS"[a+b<=x])

Fixed, accepted submission:
a,b,x=map(int,input().split());print("YNEOS"[a+b<x or a>x::2])
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
lst=[]
all=["AC","WA","TLE","RE"]
for _ in range(n):
    a=input()
    lst.append(a)
for i in all:
    print(i,"×",lst.count(i))

Fixed, accepted submission:
N = int(input())
lst = [input() for _ in range(N)]
V=["AC","WA","TLE","RE"]
for v in V:
    print("{} x {}".format(v, lst.count(v)))
Problem:
Snuke loves working out. He is now exercising N times.  Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i.  Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
ans=1
for i in range(n):
  ans*=i
  ans%=10**9+7
print(ans)

Fixed, accepted submission:
n=int(input())
ans=1
for i in range(1,n+1):
  ans*=i
  ans%=10**9+7
print(ans)
Problem:
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

Incorrect submission (verdict: Wrong Answer):
a = input()
b = int(a) + 24
print(b)


Fixed, accepted submission:
a = input()
b = 24 - int(a)
c = 24 + b  
print(c)
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

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

if a >= b :
    print(c*a)
else :
    print((a-b)*c + b*d)

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
 
if a <= b :
    print(c*a)
else :
    print(b*c + (a-b)*d)
Problem:
Snuke has an empty sequence a.  He will perform N operations on this sequence.  In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1).  You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.

Incorrect submission (verdict: Wrong Answer):
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(n):
    if i+1 >= li[i]:
        lin.append(li[i])
    else:
        print(-1)
        exit()
for i in lin:
    print(i)

Fixed, accepted submission:
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = []

while li:
    now = 10**10
    for i,j in enumerate(li,1):
        if i == j:
            now = i
    if now == 10**10:
        print(-1)
        exit()
    lin.append(now)
    li.pop(now-1)

for i in lin[::-1]:
    print(i)
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(min(abs(a-x),abs(b-x)))

Fixed, accepted submission:
x,a,b = map(int,input().split())
if abs(a-x)<abs(b-x):
    print("A")
else:
    print("B")
Problem:
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.  Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s.  Given the name of the contest, print the abbreviation of the name.

Incorrect submission (verdict: Wrong Answer):
# A
s = input()
print("A", s[8], "C")

Fixed, accepted submission:
# A
s = input()
print("A"+ s[8]+ "C")
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
r,g,b = map(int,input().split())
num = 100*r + 10*g + b
if num % 4 == 0:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
r,g,b = map(int,input().split())
num = 100*r + 10*g + b
if num % 4 == 0:
  print("YES")
else:
  print("NO")
Problem:
An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina".  Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.

Incorrect submission (verdict: Wrong Answer):
n = int(input())

for __ in range(n):
    sentence = input()
    length = 0
    after = ""

    while True:
        try:
            sentence[length]
            length += 1
        except:
            break
    
    for i in range(length-6):
        if sentence[i] == "H":
            if sentence[i+1] == "o":
                if sentence[i+2] == "s":
                    if sentence[i+3] == "h":
                        if sentence[i+4] == "i":
                            if sentence[i+5] == "n":
                                if sentence[i+6] == "o":
                                    for j in range(i+6):
                                        after += sentence[j]
                                    after += "a"
                                    for j in range(i+7,length):
                                        after += sentence[j]
                                        
    print(after)


Fixed, accepted submission:
def get_length(sentence):
    length = 0

    while True:
        try:
            if sentence[length] is not None:
                length += 1
        except:
            break

    return length


n = int(input())
target = "Hoshino"
target_right = "Hoshina"
length_target = get_length(target)

for __ in range(n):
    sentence = input()
    length = get_length(sentence)
    
    for i in range(length - length_target +1):
        correct = True
        for j in range(length_target):
            if sentence[i+j] != target[j]:
                correct = False
                break
        if correct:
            after = ""
            for j in range(i):
                after += sentence[j]
            after += target_right
            for j in range(i+length_target, length):
                after += sentence[j]
            sentence = after

    print(sentence)
Problem:
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Incorrect submission (verdict: Wrong Answer):
import re
otoshidama = 0

N = int(input())

for i in range(0,N):
  ni = re.split('\s+', input())
  if(ni[1] == 'BTC'):
    ni[0] = float(ni[0]) * 38000
  otoshidama += float(ni[0])
  
print(otoshidama)


Fixed, accepted submission:
import re
otoshidama = 0

N = int(input())

for i in range(0,N):
  ni = re.split('\s+', input())
  if(ni[1] == 'BTC'):
    otoshidama += (float(ni[0]) * 380000.00)
  else:
    otoshidama += int(ni[0])
  
print(otoshidama)
Problem:
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Incorrect submission (verdict: Wrong Answer):
import math
i = int(input())

print(math.ceil(i / 11))

Fixed, accepted submission:
i = int(input())
x = i // 11
a = x * 2
b = i % 11
if b == 0:
    pass
elif b <= 6:
    a += 1
else:
    a += 2
print(a)
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):

a,b = map(int,input().split())


c = a * b % 2
if (c == 0):
    print("even")
else:
    print("odd")

Fixed, accepted submission:

a,b = map(int,input().split())


c = a * b % 2
if (c == 0):
    print("Even")
else:
    print("Odd")
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
import math

a,b = map(int,input().split())
num = int(a+b)
if math.sqrt(num) % 1 == 0:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
import math

a,b = input().split()
num = int(a+b)
if math.sqrt(num) % 1 == 0:
  print('Yes')
else:
  print('No')
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
IN = [input() for i in range(1)]
N = int(IN[0])
INP = [input() for i in range(int(N))]
AC = 0
WA = 0
TLE = 0
RE = 0
i = 0

while i < N:
  if INP[i] == "AC":
    AC = AC + 1
    i = i + 1
  elif INP[i] == "WA":
    WA = WA + 1
    i = i + 1
  elif INP[i] == "TLE":
    TLE = TLE + 1
    i = i + 1
  elif INP[i] == "RE":
    RE = RE + 1
    i = i + 1
  else:
    i = i + 1

print("AC × " + str(AC))
print("WA × " + str(WA))
print("TLE × " + str(TLE))
print("RE × " + str(RE))
	

Fixed, accepted submission:
IN = [input() for i in range(1)]
N = int(IN[0])
INP = [input() for i in range(int(N))]
AC = 0
WA = 0
TLE = 0
RE = 0
i = 0

while i < N:
  if INP[i] == "AC":
    AC = AC + 1
    i = i + 1
  elif INP[i] == "WA":
    WA = WA + 1
    i = i + 1
  elif INP[i] == "TLE":
    TLE = TLE + 1
    i = i + 1
  elif INP[i] == "RE":
    RE = RE + 1
    i = i + 1
  else:
    i = i + 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))
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):
a = int(input())
b = int(input())
c = int(input())
total = int(input())

max_a = total // 500
max_b = total // 100
max_c = total // 50
ans = 0
for i in range(0, max_a):
  for j in range(0, max_b):
    for k in range(0, max_c):
      sum = 500 * i + 100 * j + 50 * k
      if (sum == total) :
        ans += 1
print(ans)

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

max_a = a if total // 500 > a else total // 500
max_b = b if total // 100 > b else total // 100
max_c = c if total // 50 > c else total // 50
ans = 0
for i in range(0, max_a + 1):
  for j in range(0, max_b + 1):
    for k in range(0, max_c + 1):
      sum = 500 * i + 100 * j + 50 * k
      if (sum == total) :
        ans += 1
print(ans)
Problem:
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.  Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
D = list(map(int, input().split()))
D.sort(reverse=True)
ans = 0
pre_d = float('inf')
for d in D:
  if d < pre_d:
    ans += 1
    pre_d = d

print(ans)

Fixed, accepted submission:
N = int(input())
D = [int(input()) for i in range(N)]
D.sort(reverse=True)
ans = 0
pre_d = float('inf')
for d in D:
  if d < pre_d:
    ans += 1
    pre_d = d

print(ans)
Problem:
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.

Incorrect submission (verdict: Wrong Answer):
S = list(map(str,input()))
S_new = sorted(S)
a = []
index = 0
print(S_new)
for i in range(0, len(S_new) - 1):
	if ord(S_new[i + 1]) - ord(S_new[i]) > 1:
		index = i
		break

if index == 0:
	print('None')
else:
	ans = ord(S_new[index]) + 1
	print(chr(ans))

Fixed, accepted submission:
def cal_word(n):
	return n - 97

def cal_word_rev(n):
	return n + 97

S = list(map(str,input()))
S_new = sorted(S)
index = -1
S_ans = []

for i in range(0, 26):
	S_ans.append('false')

for i in range(0, len(S)):
	S_ans[cal_word(ord(S[i]))] = 'true'

for i in range(0, 26):
	if S_ans[i] == 'false':
		index = i
		break
if index == -1:
	print('None')
else:
	print(chr(cal_word_rev(index)))
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

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

print('Yes' if ABC[0] * ABC[1] * ABC[2] == 175 else 'No')

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

print('YES' if ABC[0] * ABC[1] * ABC[2] == 175 else 'NO')
Problem:
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of   AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.

Incorrect submission (verdict: Wrong Answer):
W, a, b = map(int, input().split())
if b > a + W:print(b - a + W)
elif b + W > a:print(b+W-a)
else:print(0)

Fixed, accepted submission:
W, a, b = map(int, input().split())
if b > a + W:print(b - a - W)
elif b + W < a:print(a-b-W)
else:print(0)
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

Incorrect submission (verdict: Wrong Answer):
from queue import Queue
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def bfs():
    queue = Queue()
    queue.put((1, 0))
    visited = [False]*(n+1)
    while not queue.empty():
        u, step = queue.get()
        for a in adj[u]:
            if a == n:
                print ("Possible")
                return
            
            if step + 1 < 2 and not visited[a]:
                queue.put((a, step+1))
    print ("IMPOSSIBLE")
    return
bfs()

Fixed, accepted submission:
from queue import Queue
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
def bfs():
    queue = Queue()
    queue.put(1)
    distance = [10**6]*(n+1)
    distance[1] = 0
    while not queue.empty():
        u = queue.get()
        if u == n and distance[u] == 2:
            print ("POSSIBLE")
            return
        for a in adj[u]:
            if distance[u] + 1 <= 2 and distance[a] > distance[u] + 1:
                distance[a] = distance[u] + 1
                queue.put(a)
    print ("IMPOSSIBLE")
    return
bfs()
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):
n = int(input())
print(n % 1000)

Fixed, accepted submission:
n = int(input())
print(-n % 1000)