TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.   The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.  An edge whose removal disconnects the graph is called a _bridge_.   Find the number of the edges that are bridges among the M edges.

Incorrect submission (verdict: Wrong Answer):

def dfs(x):
    if visited[x]:
        return
    visited[x] = True
    for i in range(N):
        
        if graph[x][i]:
            dfs(i)


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

edge = []
graph = [[False]*N for _ in range(N)]   
visited = [False]*N

for i in range(M):
    a, b = map(int, input().split())
    edge.append((a, b))
    graph[a-1][b-1] = True
    graph[b-1][a-1] = True

ans = 0
for i, e in enumerate(edge):
    
    graph[e[0]-1][e[1]-1] = False
    graph[e[1]-1][e[0]-1] = False

    
    for j in range(N):
        visited[j] = False

    
    dfs(0)

    
    bridge = True
    for j in range(N):
        if visited[j]:
            bridge=False
            break
#     for j in range(N):
#         if not visited[j]:
#             bridge = True
    if bridge:
        ans += 1

    
    graph[e[0]-1][e[1]-1] = True
    graph[e[1]-1][e[0]-1] = True

print(ans)


Fixed, accepted submission:

def dfs(x):
    if visited[x]:
        return
    visited[x] = True
    for i in range(N):
        
        if graph[x][i]:
            dfs(i)


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

edge = []
graph = [[False]*N for _ in range(N)]   
visited = [False]*N

for i in range(M):
    a, b = map(int, input().split())
    edge.append((a, b))
    graph[a-1][b-1] = True
    graph[b-1][a-1] = True

ans = 0
for i, e in enumerate(edge):
    
    graph[e[0]-1][e[1]-1] = False
    graph[e[1]-1][e[0]-1] = False

    
    for j in range(N):
        visited[j] = False

    
    dfs(0)

    
    bridge = False
    for j in range(N):
        #if not visited[j]:
        if not all(visited):
            bridge = True
    if bridge:
        ans += 1

    
    graph[e[0]-1][e[1]-1] = True
    graph[e[1]-1][e[0]-1] = True

print(ans)
Problem:
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(str, input().split())
A = a[0]
B = b[0]
C = c[0]

ans = A.upper() + B.upper() + C.upper()

Fixed, accepted submission:
a, b, c = map(str, input().split())
A = a[0]
B = b[0]
C = c[0]

ans = A.upper() + B.upper() + C.upper()
print(ans)
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):
x = input().split()
xx = int("".join(x))
if xx % 4 == 0:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
x = input().split()
xx = int("".join(x))
if xx % 4 == 0:
    print("YES")
else:
    print("NO")
Problem:
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.  We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells.      Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side):      In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point.  Your task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density.  You may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10\.

Incorrect submission (verdict: Wrong Answer):
import sys

paper = [[0] * 10 for i in range(10)]

for line in sys.stdin:
    x,y,s = map(int,line.split(','))
    for i in range(10):
        for j in range(10):
            if s == 1:
                if abs(i - y) + abs(j - x) <= 1:
                    paper [i] [j] += 1
            if s == 2:
                if abs(i - y) <= 1 and abs(j - x) <= 1:
                    paper [i] [j] += 1
            if s == 3:
                if abs(i - y) + abs(j - x) <= 2:
                    paper [i] [j] += 1

ans = [0,0]
for i in range(10):
    for j in range(10):
        if paper [i] [j] == 0:
            ans [0] += 1
        if paper [i] [j] > ans [1]:
            ans [1] = paper [i] [j]

print(ans [0],ans [1])

Fixed, accepted submission:
paper = [[0] * 10 for i in range(10)]

while True:
    try:
        x,y,s = map(int,input().split(','))
    except:
        break
    if s == 1:
        for i in range(10):
            for j in range(10):
                if abs(x - i) + abs(y - j) <= 1:
                    paper [i] [j] += 1
    elif s == 2:
        for i in range(10):
            for j in range(10):
                if abs(x - i) <= 1 and abs(y - j) <= 1:
                    paper [i] [j] += 1
    else:
        for i in range(10):
            for j in range(10):
                if abs(x - i) + abs(y - j) <= 2:
                    paper [i] [j] += 1

ls = sum(paper,[])
print(ls.count(0))
print(max(ls))
Problem:
M-kun has the following three cards:    * A red card with the integer A.   * A green card with the integer B.   * A blue card with the integer C.  He is a genius magician who can do the following operation at most K times:    * Choose one of the three cards and multiply the written integer by 2.  His magic is successful if both of the following conditions are satisfied after the operations:    * The integer on the green card is **strictly** greater than the integer on the red card.   * The integer on the blue card is **strictly** greater than the integer on the green card.  Determine whether the magic can be successful.

Incorrect submission (verdict: Wrong Answer):
import numpy as np
A = [int(x) for x in input().split()]
src = np.array(A)
K = int(input())
flag = 0

for i in range(K):
  if(src[0] < src[1]):
    if(src[1] < src[2]):
      flag = 1
      break
    else:
      src[2] *= 2
  else:
    src[1] *= 2
   
if(src[0] < src[1]):
	if(src[1] < src[2]):
		print("yes")
else:
	print("no")

Fixed, accepted submission:
import numpy as np
A = [int(x) for x in input().split()]
src = np.array(A)
K = int(input())
flag = 0

for i in range(K):
  if(src[0] < src[1]):
    if(src[1] < src[2]):
      flag = 1
      break
    else:
      src[2] *= 2
  else:
    src[1] *= 2
   
if(src[0] < src[1]):
	if(src[1] < src[2]):
		print("Yes")
	else:
		print("No")
else:
  print("No")
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(d, r, f)

Fixed, accepted submission:
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, "{:.5f}".format(f))
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):
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)


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

calc = int((a+b)*h/2)
print(calc)
Problem:
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes:    * Hit his pocket, which magically increases the number of biscuits by one.   * Exchange A biscuits to 1 yen.   * Exchange 1 yen to B biscuits.  Find the maximum possible number of biscuits in Snuke's pocket after K operations.

Incorrect submission (verdict: Wrong Answer):
K,A,B=map(int,input().split())
if B-A<=2:
  print(K+1)
else:
  print(max(0,K-(A-1)//2))

Fixed, accepted submission:
K,A,B=map(int,input().split())
if K+1>=A and A+2<=B:
  print(((K+1)-A)//2*(B-A)+A+((K+1)-A)%2)
else:
  print(K+1)
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            count = 0
            for dx, dy in (
                (-1,1), (0,1), (1,0),
                (-1,0), (0,0), (0,1),
                (-1,-1),(0,-1),(1,-1)
            ):
                now_x, now_y = i+dx, j+dy
                if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1 and s[now_x][now_y] == "#":
                    count += 1
            s[i][j] = str(count)

for i in range(H):
    print(''.join(s[i]))

Fixed, accepted submission:
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == '.':
            count = 0
            for dx, dy in (
                (-1,1), (0,1), (1,1),
                (-1,0), (0,0), (1,0),
                (-1,-1),(0,-1),(1,-1)
            ):
                now_x, now_y = i+dx, j+dy
                if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1 and s[now_x][now_y] == "#":
                    count += 1
            s[i][j] = str(count)

for i in range(H):
    print(''.join(s[i]))
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
S = input()
sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3])
def minus(a, sumS):
    sS = sumS
    ba = bin(a)
    for ia,aa in enumerate(ba[::-1]):
        if aa == 'b':
            break
        elif aa == '1':
            sS -=  2 * int(S[ia+1:ia+2])
    if sS == 7:
        print(ba)
        T = ['+', '+', '+', '=7']
        for ia,aa in enumerate(ba[::-1]):
            if aa == '1':
                T[ia] = '-'

        result = ''
        for i in range(len(S)):
            result += S[i] + T[i]
        return result
    else:

        return minus(a+1,sumS)
print(minus(0,sumS))

Fixed, accepted submission:
S = input()
sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3])
def minus(a, sumS):
    sS = sumS
    ba = bin(a)
    for ia,aa in enumerate(ba[::-1]):
        if aa == 'b':
            break
        elif aa == '1':
            sS -=  2 * int(S[ia+1:ia+2])
    if sS == 7:
        T = ['+', '+', '+', '=7']
        for ia,aa in enumerate(ba[::-1]):
            if aa == '1':
                T[ia] = '-'

        result = ''
        for i in range(len(S)):
            result += S[i] + T[i]
        return result
    else:

        return minus(a+1,sumS)
print(minus(0,sumS))
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 - N//1000*1000)

Fixed, accepted submission:
N = int(input())
a = (N + 1000 -1)//1000
print(a*1000-N)
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())
test = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

for _ in range(N):
    s = input()
    test[s] += 1

for i, j in test.items():
    print("{} × {}".format(i, j))


Fixed, accepted submission:
N = int(input())
test = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

for _ in range(N):
    s = input()
    test[s] += 1

for i, j in test.items():
    print("{} x {}".format(i, j))
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):
def find(n):
    
    tn = int(n/2)
    s = 2 * tn + 1
    count = 0
    line_list = []
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if i + j != s:
                line_list.append(str(i) + " " + str(j))
                count +=1

    return count, line_list


if __name__ == '__main__':
    n = input()

    count, line_list = find(int(n))
    print(count)
    print("\n".join(line_list))

Fixed, accepted submission:
def find(sequence):
    result_list = []
    for i in range(len(sequence)):
        for j in reversed(list(range(len(sequence)))):
            if sequence[j] == j + 1:
                result_list.append(sequence.pop(j))
                break
    if len(sequence) != 0:
        return [-1]
    return result_list


if __name__ == "__main__":
    n = input()
    sequence = input()
    data = [int(item) for item in sequence.split(" ")]
    print("\n".join(map(str, reversed(find(data)))))
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())

ans = a

if b <= a:
    ans -= 1
print(ans)


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

ans = a

if b < a:
    ans -= 1
print(ans)
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
import sys

x = input()

A = int(x[0])
B = int(x[1])
C = int(x[2])
D = int(x[3])

work = A
op1,op2,op3 = "","",""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 1:
                op1 = "+"
                work += B
            else:
                op1 = "-"
                work -= B
            if j == 1:
                op2 = "+"
                work += C
            else:
                op2 = "-"
                work -= C
            if k == 1:
                op3 = "+"
                work += D
            else:
                op3 = "-"
                work -= D
            if work ==7:
                print(x[0]+op1+x[1]+op2+x[2]+op3+x[3])
                sys.exit()
            else:
                work = A

Fixed, accepted submission:
import sys

x = input()

A = int(x[0])
B = int(x[1])
C = int(x[2])
D = int(x[3])

work = A
op1,op2,op3 = "","",""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 1:
                op1 = "+"
                work += B
            else:
                op1 = "-"
                work -= B
            if j == 1:
                op2 = "+"
                work += C
            else:
                op2 = "-"
                work -= C
            if k == 1:
                op3 = "+"
                work += D
            else:
                op3 = "-"
                work -= D
            if work ==7:
                print(x[0]+op1+x[1]+op2+x[2]+op3+x[3]+"=7")
                sys.exit()
            else:
                work = A
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 a<=b and b<=c:
  print("Yes")
elif a>=b and b>=c:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
a,b,c=map(int,input().split())
if a<=c and c<=b:
  print("Yes")
elif a>=c and c>=b:
  print("Yes")
else:
  print("No")
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
i = 0
while True:
    v = input()
    if v == '0':
        break
    print('Case %d: %s' % (i, v))
    i += 1

Fixed, accepted submission:
i = 0
while True:
    i += 1
    v = input()
    if v == '0':
        break
    print('Case %d: %s' % (i, v))
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
nums = input().split()
a = int(nums[0])
b = int(nums[0])
c = int(nums[0])

if a < b < c:
    print(a, b, c)

elif a < c < b:
    print(a, c, b)

elif b < a < c:
    print(b, a, c)

elif b < c < a:
    print(b, c, a)

elif c < a < b:
    print(c, a, b)

else:
    print(c, b, a)

Fixed, accepted submission:
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])

if a <= b <= c:
    print(a, b, c)

elif a <= c <= b:
    print(a, c, b)

elif b <= a <= c:
    print(b, a, c)

elif b <= c <= a:
    print(b, c, a)

elif c <= a <= b:
    print(c, a, b)

else:
    print(c, b, a)
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

Incorrect submission (verdict: Wrong Answer):
import math
a,b=map(int,input().split())
c=a*b
if c%2==0:
    d = c/2
else:
    d = math.floor(c/2) + 1
print(d)


Fixed, accepted submission:
import math
H,W=map(int, input().split())

if H==1 or W==1:
    print(1)
else:
    print(math.ceil(H*W/2))
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):
f=input().split()
(n,m,x,y)=(int(f[0]),int(f[1]),int(f[2]),int(f[3]))
ax=[int(i) for i in input().split()]
ay=[int(i) for i in input().split()]
ax.sort()
ay.sort()
b=ay[0]-ax[-1]
if b>1:
    print("No War")
else:
    print("War")

Fixed, accepted submission:
f=input().split()
(n,m,x,y)=(int(f[0]),int(f[1]),int(f[2]),int(f[3]))
ax=[int(i) for i in input().split()]
ay=[int(i) for i in input().split()]
ax.sort()
ay.sort()
b=ay[0]-ax[-1]
c=0
if x<ax[-1] and y>ax[-1]:
    c=1
elif x>ax[-1] and x<ay[0] and y<ay[0]:
    c=1
elif x>ax[-1] and y>ay[0] and x<ay[0]:
    c=1
if b>0 and c==1:
    print("No War")
else:
    print("War")
Problem:
Given are positive integers N and K.  Determine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples.    * For every integer i from 1 to N, a_i + b_i \leq c_i holds.  If the answer is yes, construct one such partition.

Incorrect submission (verdict: Wrong Answer):
n, k = map(int, input().split())
if 2 * k > n + 1:
    exit(print(-1))
else:
    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=" ")
            else:
                print(i // 2 + n // 2 + k, i // 2 + n + k, i + n * 2 + k, end=" ")
    else:
        for i in range(n):
            if i % 2 == 0:
                print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=" ")
            else:
                print(i // 2 + n // 2 + k + 1, i // 2 + n + k, i + n * 2 + k, end=" ")

Fixed, accepted submission:
n, k = map(int, input().split())
if 2 * k > n + 1:
    exit(print(-1))
else:
    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2)
            else:
                print(k + i // 2 + n // 2, k + i // 2 + n, k + i + n * 2)
    else:
        for i in range(n):
            if i % 2 == 0:
                print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2)
            else:
                print(k + i // 2 + n // 2 + 1, k + i // 2 + n, k + i + n * 2)