TnT/CodeNet4Repair huggingface dataset:
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):
# encoding:utf-8
import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())

N,K = LI()
D = [str(i) for i in input().split()]


def main():
    ans = N
    while True:
        for i in range(K):
            # print(list(str(ans)))
            if D[i] in list(str(ans)):
                print(ans)
                ans += 10**max((len(str(ans))-list(str(ans)).index(D[i])-1),0)
                break
            if i == K - 1:
                return ans

print(main())


Fixed, accepted submission:
# encoding:utf-8
import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())

N,K = LI()
D = [str(i) for i in input().split()]


def main():
    ans = N
    while True:
        for i in range(K):
            # print(list(str(ans)))
            if D[i] in list(str(ans)):
                # print(ans)
                ans += 1
                # ans += 10**max((len(str(ans))-list(str(ans)).index(D[i])-1),0)
                break
            if i == K - 1:
                return ans

print(main())
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())
if B < C:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
A, B, C = map(int, input().split())

if (A < C and B > C) or (A > C and B < C):
    print('Yes')
else:
    print('No')
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
up = int(input())
down = int(input())
height = int(input())

print((up + down)*height/2)

Fixed, accepted submission:
up = int(input())
down = int(input())
height = int(input())

print(int((up + down)*height/2))
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

#n = int(input())
#a = int(input())
a,b = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(input().split())
#string = input()


#m = int(input())

num = str(a) + str(b)
num = int(num)
tmp = pow(num,0.5)
if math.ceil(tmp) == math.floor(tmp):
  print("YES")
  quit()
else:
  print("NO")

Fixed, accepted submission:
import math

#n = int(input())
#a = int(input())
a,b = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
#ls = list(map(int,input().split(" ")))
#a,b = list(input().split())
#string = input()


#m = int(input())

num = str(a) + str(b)
num = int(num)
tmp = pow(num,0.5)
if math.ceil(tmp) == math.floor(tmp):
  print("Yes")
  quit()
else:
  print("No")
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

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

a = [2**i for i in range(7)]

for i in a:
  if i > n:
    a.remove(i)
    
print(max(a))

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

a = [2**i for i in range(7)]
b = []
for i in a:
  if i <= n:
    b.append(i)
    
print(max(b))
Problem:
Write a program which reads two integers a and b, and calculates the following values:    * a ÷ b: d (in integer)   * remainder of a ÷ b: r (in integer)   * a ÷ b: f (in real number)

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split(" "))
d = a // b
r = a % b
f = a / b
print("{0} {1} {2}".format(d, r, f))

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

print(f"{a//b} {a%b} {a/b:.5f}")
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):
#N,M=map(int,input().split())
#T=list(map(int,input().split()))
N=9999 
M=1
#T=[1,3,4,5,6,7,8,9]
T=[]
L=[]
for i in range(10):
    if(not T.count(i)):
        L.append(i)

l=len(str(N))+1
MIN=10**10

def calc(st):
    global MIN
    st=str(st)
    if(len(st)>l):return 0
    for num in L:
        t=calc(st+str(num))
        if(int(t)>=N):
            MIN=min(MIN,int(t))
    if(st!=""):
        if(int(st)>=N):
            MIN=min(int(st),MIN)
    return (MIN)

print(calc(str()))







Fixed, accepted submission:
N,M=map(int,input().split())
T=list(map(int,input().split()))
#N=9999 
#M=1
#T=[1,3,4,5,6,7,8,9]
#T=[]
L=[]
for i in range(10):
    if(not T.count(i)):
        L.append(i)

l=len(str(N))+1
MIN=10**10

def calc(st):
    global MIN
    st=str(st)
    if(len(st)>l):return 0
    for num in L:
        t=calc(st+str(num))
        if(int(t)>=N):
            MIN=min(MIN,int(t))
    if(st!=""):
        if(int(st)>=N):
            MIN=min(int(st),MIN)
    return (MIN)

print(calc(str()))
Problem:
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows:    * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.   * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.  You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.

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

ans = []

for i in range(M):
    ans.append([i+1,2*M-i])

for an in ans:
    print(an[0],an[1])

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

num = list(range(1,N+1))
ans = []


if M % 2 == 0:
    for i in range(M // 2):
        ans.append([i+1,M+1-i])
    for i in range(M // 2):
        ans.append([i+2+M,2*M+1-i])


if M % 2 != 0:
    for i in range(M // 2):
        ans.append([i+1,M-i])
    for i in range(M - M//2):
        ans.append([i+1+M,2*M+1-i])


for an in ans:
    print(an[0],an[1])
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):
l = input().split().sort()
if l == [5,7,7]:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
l = list(map(int, input().split()))
l.sort()
if l == [5,5,7]:
    print("YES")
else:
    print("NO")
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
from collections import deque

def main():
    N,M = map(int, input().split())
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        r[a-1].append(b-1)
        r[b-1].append(a-1)
    print(r)

    p=[-1]*N
    q=deque([0])
    while q:
        i=q.popleft()
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print('Yes')
    for i in range(1,N):
        print(p[i]+1)

main()

Fixed, accepted submission:
from collections import deque

def main():
    N,M = map(int, input().split())
    r = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        r[a-1].append(b-1)
        r[b-1].append(a-1)

    p=[-1]*N
    q=deque([0])
    while q:
        i=q.popleft()
        for j in r[i]:
            if p[j] == -1:
                p[j] = i
                q.append(j)
    print('Yes')
    for i in range(1,N):
        print(p[i]+1)

main()
Problem:
You have an integer variable x. Initially, x=0.  Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`.  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

Incorrect submission (verdict: Wrong Answer):
n=input()
s=list(input())
x=0
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
print(x)

Fixed, accepted submission:
x=int(input())
s=input()
x=0
l=[0]
for i in s:
  if i=='I':
    x+=1
    l.append(x)
  elif i=='D':
    x-=1
    l.append(x)
print(max(l))
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
x, y = map(int, input().split())
for i in range(0, 10001):
    if x > y:
        temp = int(x)
        x = y
        y = temp
    print(f'{x} {y}')



Fixed, accepted submission:
for i in range(0, 10001):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break
    if x > y:
        temp = int(x)
        x = y
        y = temp
    print(f'{x} {y}')
Problem:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

Incorrect submission (verdict: Wrong Answer):
m,d = map(int, input().split())
count = 0
for i in range(m):
  for j in range(d):
    i += 1
    j += 1
    if j//10 * j%10 == i:
      count += 1
      
print(count)

Fixed, accepted submission:
m,d = map(int, input().split())
count = 0
for i in range(m):
  i += 1
  for j in range(d):
    j += 1
    j = str(j)
    if len(j) == 2:
      ten = int(j[0])
      one = int(j[1])
      if ten >= 2 and one >= 2 and int(j[0])*int(j[1]) == i:
        count += 1
      
print(count)
Problem:
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once.  You are given the sequence _A_ and _q_ questions where each question contains _M i_.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
A = [int(i) for i in input().split()]
input()
M = [int(i) for i in input().split()]

def solve(i, m):
    if i >= n:
        res = False
    elif m == 0:
        res = True
    else:
        res = solve(i+1, m) or solve(i+1, m-A[i])
    return res

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')


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

def solve(i, m):
    if m == 0:
        return True
    if i >= n or m < 0:
        return False
    res = solve(i+1, m) or solve(i+1, m-A[i])
    return res

for m in M:
    if sum(A) < m:
        print("no")
    elif solve(0, m):
        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())
src = list(map(int,input().split()))
odd = two = four = 0
for a in src:
    if a%2: odd += 1
    elif a%4==0: four += 1
    else: two += 1
if two < 2:
    odd += 1
print('No' if odd > four else 'Yes')

Fixed, accepted submission:
N = int(input())
src = list(map(int,input().split()))
x4 = odd = 0
for a in src:
    if a%4 == 0:
        x4 += 1
    elif a%2:
        odd += 1

if odd <= x4:
    print('Yes')
elif odd == x4+1:
    print('Yes' if x4+odd == N else 'No')
else:
    print('No')
Problem:
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.

Incorrect submission (verdict: Wrong Answer):
words = input().split(" ")
for word in words:
    for w in word:
        if w.isupper():
            w.lower()
        else:
            w.upper()
print(",".join(words))

    

Fixed, accepted submission:
print(input().swapcase())
Problem:
There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.  You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.  Your objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?

Incorrect submission (verdict: Wrong Answer):
class Union():
    def __init__(self, n):
        self.para = [-1] * n
    
    def find(self, n):
        if self.para[n] < 0:
            return n
        
        else:
            self.para[n] = self.find(self.para[n])
            return self.para[n]
    
    def union(self, n, m):
        n = self.find(n)
        m = self.find(m)
        if n == m:
            return False
        else:
            if self.para[n] > self.para[m]:
                n, m = m, n
            
            self.para[n] += self.para[m]
            self.para[m] = n
    
    def same(self, n, m):
        return self.find(n) == self.find(m)

N = int(input()) 
X, Y = [], [] 
for i in range(N): 
    x,y = map(int,input().split()) 
    X.append((x,i)) 
    Y.append((y,i))
X.sort()
Y.sort()
ALL = []
for i in range(len(X)-1):
    ALL.append((X[i+1][0]-X[i][0], X[i][1], X[i+1][1]))
    ALL.append((Y[i+1][0]-Y[i][0], Y[i][1], Y[i+1][1]))
ALL.sort()
ut = Union(N)
cnt = 0
for a in ALL:
    n = a[1]
    m = a[2]
    if not ut.same(n,m):
        ut.union(n,m)
        cnt += a[0]

Fixed, accepted submission:
class Union():
    def __init__(self, n):
        self.para = [-1] * n
    
    def find(self, n):
        if self.para[n] < 0:
            return n
        
        else:
            self.para[n] = self.find(self.para[n])
            return self.para[n]
    
    def union(self, n, m):
        n = self.find(n)
        m = self.find(m)
        if n == m:
            return False
        else:
            if self.para[n] > self.para[m]:
                n, m = m, n
            
            self.para[n] += self.para[m]
            self.para[m] = n
    
    def same(self, n, m):
        return self.find(n) == self.find(m)

N = int(input()) 
X, Y = [], [] 
for i in range(N): 
    x,y = map(int,input().split()) 
    X.append((x,i)) 
    Y.append((y,i))
X.sort()
Y.sort()
ALL = []
for i in range(len(X)-1):
    ALL.append((X[i+1][0]-X[i][0], X[i][1], X[i+1][1]))
    ALL.append((Y[i+1][0]-Y[i][0], Y[i][1], Y[i+1][1]))
ALL.sort()
ut = Union(N)
cnt = 0
for a in ALL:
    n = a[1]
    m = a[2]
    if not ut.same(n,m):
        ut.union(n,m)
        cnt += a[0]
print(cnt)
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):
A=int(input())
B=int(input())
C=int(input())
print(A-B-C)

Fixed, accepted submission:
A=int(input())
B=int(input())
C=int(input())
print((A-B)%C)
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
s_str = input()

check_list = ['a', 'b', 'c']

result_list = [[s == check for check in check_list] for s in s_str]
result = all([s1 or s2 or s3 for s1, s2, s3 in result_list])
print(result)

Fixed, accepted submission:
s_str = input()

check_list = ['a', 'b', 'c']
result_list = [[s == check for check in check_list] for s in s_str]
r1, r2, r3 = result_list
result = all([s1 or s2 or s3 for s1, s2, s3 in zip(r1, r2, r3)])

if result:
    print('Yes')
else:
    print('No')
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 = str(input())
separated = list(s)
count = 0
for char in separated:
    print(char)
    if char == "1":
        count += 1
print(count)

Fixed, accepted submission:
s = str(input())
separated = list(s)
count = 0
for char in separated:
    if char == "1":
        count += 1
print(count)
Problem:
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.  He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.  So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`.  Find the minimum number of iterations for the rewrite operation.

Incorrect submission (verdict: Wrong Answer):
S = input()
A = 'C0DEFESTIVAL2O16'
ans = 0
for i in range(len(S)):
  if S[i] == A[i]:
    ans += 1

print(ans)

Fixed, accepted submission:
S = input()
A = 'CODEFESTIVAL2016'
ans = 0
for i in range(len(S)):
  if S[i] != A[i]:
    ans += 1

print(ans)
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
if __name__ == '__main__':
    y, m, d = map(int, input().split('/'))
    if y == 2017:
        y = 2018
    print('/'.join(map(str, [y, m, d])))

Fixed, accepted submission:
if __name__ == '__main__':
    y, m, d = map(str, input().split('/'))
    if int(y) == 2017:
        y = str(2018)
    print('/'.join([y, m, d]))
Problem:
Write a program which reads five numbers and sorts them in descending order.

Incorrect submission (verdict: Wrong Answer):
s = input().split()
arr = [int(s[i]) for i in range(5)]
arr.sort(reverse=True)
print(arr)

Fixed, accepted submission:
s = input().split()
arr = [int(s[i]) for i in range(5)]
arr.sort(reverse=True)
for i in range(len(arr)):
    if i != len(arr)-1:
        print(arr[i], end=" ")
    else:
        print(arr[i])
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
N, M, X, Y = map(int, input().split())
xmax = max(list(map(int, input().split())))
ymin = min(list(map(int, input().split())))
r = "war"
for z in range(X, Y):
    if xmax < z and ymin >= z and xmax != Y and ymin != X:
        r = "No war"
        break

print(r)

Fixed, accepted submission:
N, M, X, Y = map(int, input().split())
xmax = max(map(int, input().split() + [X]))
ymin = min(map(int, input().split() + [Y]))
 
if xmax < ymin:
    print("No War")
else:
    print("War")