TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:    * The graph is simple and connected.   * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.  It can be proved that at least one such graph exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):

N = int(input())

matrix = [[1 for i in range(N)] for i in range(N)]
for i in range(N):
    matrix[i][i] = 0

if N%2==0:
    for i in range(N):
        matrix[i][N-i-1] = 0
else:
    for i in range(N-1):
        matrix[i][N-i-2] = 0

for i in range(N):
    for j in range(i+1,N):
        if matrix[i][j] == 1:
            print(i+1,"",j+1)


Fixed, accepted submission:

N = int(input())

matrix = [[1 for i in range(N)] for i in range(N)]
for i in range(N):
    matrix[i][i] = 0

if N%2==0:
    for i in range(N):
        matrix[i][N-i-1] = 0
else:
    for i in range(N-1):
        matrix[i][N-i-2] = 0

print(int((N*(N-1)/2)-int(N/2)))
for i in range(N):
    for j in range(i+1,N):
        if matrix[i][j] == 1:
            print(i+1,j+1)
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())

a = []

for i in range(h):
    a.append(input())

print(a)

ans = []

for i in range(h + 2):
    if i == 0 or i == h + 1:
        s = ""
        for j in range(w + 2):
            s = s + "#"

        ans.append(s)

    else:
        s = "#" + a[i - 1] + "#"
        ans.append(s)

#print(ans)

print('\n'.join(ans))


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

a = []

for i in range(h):
    a.append(input())

#print(a)

ans = []

for i in range(h + 2):
    if i == 0 or i == h + 1:
        s = ""
        for j in range(w + 2):
            s = s + "#"

        ans.append(s)

    else:
        s = "#" + a[i - 1] + "#"
        ans.append(s)

#print(ans)

print('\n'.join(ans))
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):
W = input()

import collections

switch = 0
W_list = list(W)
W_dic = collections.Counter(W_list)
for num in W_dic.values():
    if num%2 != 0:
        switch = 1
        break

print(switch)
if switch == 0:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
W = input()

import collections

switch = 0
W_list = list(W)
W_dic = collections.Counter(W_list)
for num in W_dic.values():
    if num%2 != 0:
        switch = 1
        break

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

Incorrect submission (verdict: Wrong Answer):
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"
found = [i for i in alphabet if i not in S]
found.sort()
if len(found) == 0:
  print('None')
else:
  print(found[0])

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

X, A, B = [i for i in place]

X_A = abs(X - A)
X_B = abs(X - B)

if X_A <= X_B:
  print('A')
else:
  print('B')
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())

A = x - a
B = x - b

print(min(A,B))

Fixed, accepted submission:
x,a,b = map(int,input().split())
if abs(x-a) < abs(x-b):
  print("A")
else:
  print("B")
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
def devide_counter(num):
    devide_count = 0
    while num%2==0:
        num /= 2
        devide_count += 1
    return devide_count

#N = int(input())
A = list(map(int, input().split()))

devide_count_list=[]
for a in A:
    devide_count_list.append(devide_counter(a))
    
print(min(devide_count_list))

Fixed, accepted submission:
def devide_counter(num):
    devide_count = 0
    while num%2==0:
        num /= 2
        devide_count += 1
    return devide_count

N = int(input())
A = list(map(int, input().split()))

devide_count_list=[]
for a in A:
    devide_count_list.append(devide_counter(a))
    
print(min(devide_count_list))
Problem:
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.  Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.

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


def Diff(H, W):
    
    H_min = int(H / 3)
    H_max = int(H / 3) + 1
    
    W_short = int(W / 2)
    W_long = W - W_short
    S_1_1 = [H_min * W, (H - H_min) * W_short, (H - H_min) * W_long]
    S_1_2 = [H_max * W, (H - H_max) * W_short, (H - H_max) * W_long]
    D_1_1 = max(S_1_1) - min(S_1_1)
    D_1_2 = max(S_1_2) - min(S_1_2)
    return min(D_1_1, D_1_2)
R = []
R.append(H)
R.append(W)
R.append(Diff(H, W))
R.append(Diff(W, H))
print(min(R))


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



def Diff(H, W):
    
    H_min = int(H / 3)
    H_max = int(H / 3) + 1
    
    W_short = int(W / 2)
    W_long = W - W_short
    S_1_1 = [H_min * W, (H - H_min) * W_short, (H - H_min) * W_long]
    S_1_2 = [H_max * W, (H - H_max) * W_short, (H - H_max) * W_long]
    D_1_1 = max(S_1_1) - min(S_1_1)
    D_1_2 = max(S_1_2) - min(S_1_2)
    return min(D_1_1, D_1_2)
R = []
R.append(H)
R.append(W)
R.append(Diff(H, W))
R.append(Diff(W, H))
if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    print(min(R))
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):
if __name__=="main":
    i=int(input())
    print((int(i**0.5))**2)

Fixed, accepted submission:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, = I()
print(int(n ** 0.5) ** 2)
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):
numbers = [int(s) for s in input().split()] 
K = int(input())
for i in range(K):
    if(numbers[2] < numbers[0]):
        numbers[2] *= 2
        
    elif(numbers[1] < numbers[0]):
        numbers[1] *= 2
        
    elif(numbers[2] < numbers[1]):
        numbers[2] *= 2
        
    else:
        break
print(numbers)
if(numbers[1] > numbers[0] and numbers[2] > numbers[1]):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
numbers = [int(s) for s in input().split()] 
K = int(input())
for i in range(K):
    if(numbers[2] <= numbers[0]):
        numbers[2] *= 2
    elif(numbers[1] <= numbers[0]):
        numbers[1] *= 2
    elif(numbers[2] <= numbers[1]):
        numbers[2] *= 2
    else:
        break
if(numbers[1] > numbers[0] and numbers[2] > numbers[1]):
    print("Yes")
else:
    print("No")
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):
w = list(map(str,input()))

w_ord = []

for i in range(len(w)):
    w_ord.append(ord(w[i]))

w_ord.sort()

j = 1

if len(w) % 2 == 1:
    print("NO")
else:
    for i in range((len(w)+1)//2):
        if not w_ord[2*i] == w_ord[2*i + 1]:
            print("NO")
            break
        else:
            if i == (len(w)+1)//2 -1:
                print("YES")

Fixed, accepted submission:
w = input()
W = []
for i in range(len(w)):
    W.append(w[i])

W.sort()

if len(w) % 2 == 1:
    print("No")
    exit()

for i in range(len(w)//2):
    if not W[2*i] == W[2*i+1]:
        print("No")
        exit()
print("Yes")
Problem:
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 SelectionSort(A) 1 for i = 0 to A.length-1 2     mini = i 3     for j = i to A.length-1 4         if A[j] < A[mini] 5             mini = j 6     swap A[i] and A[mini]   Note that, indices for array elements are based on 0-origin.  Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.

Incorrect submission (verdict: Wrong Answer):
def selectionSort(a, n):
  count = 0
  for i in range(0, n):
    minj = i
    for j in range(i, n):
      if a[j] < a[minj]:
        minj = j
    w = a[i]
    a[i] = a[minj]
    a[minj] = w
    count += 1
  print(' '.join(map(str, a)))
  print(count)

n = int(input())
a = list(map(int, input().split()))
selectionSort(a, n)


Fixed, accepted submission:
def selectionSort(a, n):
  count = 0
  for i in range(0, n):
    minj = i
    for j in range(i, n):
      if a[j] < a[minj]:
        minj = j
    if i != minj:
      w = a[i]
      a[i] = a[minj]
      a[minj] = w
      count += 1
  print(' '.join(map(str, a)))
  print(count)

n = int(input())
a = list(map(int, input().split()))
selectionSort(a, n)
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

Incorrect submission (verdict: Wrong Answer):
A=input()
print('NYOE S'[(A[1]==A[2]) and 
(A[0]==A[1] or A[1]==A[3])
::2])

Fixed, accepted submission:
A=input()
print('NYoe s'[(A[1]==A[2]) and 
(A[0]==A[1] or A[1]==A[3])
::2])
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())

if x - a < 0:
    print("No")

else:
    if b < x - a:
        print("No")

    else:
        print("Yes")


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

if x - a < 0:
    print("NO")

else:
    if b < x - a:
        print("NO")

    else:
        print("YES")
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 sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
XU=[list(SR().split()) for _ in range(N)]
print(XU)
ans = 0

for xu in XU:
    if xu[1] == 'JPY':
        ans += int(xu[0])
    else:
        ans += float(xu[0])*380000
print(ans)

Fixed, accepted submission:
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce


def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
XU=[list(SR().split()) for _ in range(N)]
ans = 0

for xu in XU:
    if xu[1] == 'JPY':
        ans += int(xu[0])
    else:
        ans += float(xu[0])*380000
print(ans)
Problem:
You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds.  Note that a+b=15 and a\times b=15 do not hold at the same time.

Incorrect submission (verdict: Wrong Answer):
print("a")

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

if a+b == 15:
    print("+")
elif a*b == 15:
    print("*")
else:
    print("x")
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
import sys
import math
import numpy as np
import copy

def main():
    s = input()

    a, b, c, d = "dream", "dreamer", "erase", "eraser"
    ra, rb, rc, rd = a[::-1], b[::-1], c[::-1], d[::-1]
    rs = s[::-1]

    while rs:
        flag = False
        for ele in [ra, rb, rc, rd]:
            if rs.startswith(ele):
                rs = rs.replace(ele, "", 1)
                flag = True
        if not flag:
            print("No")
            return 0
    
    print("Yes")
    return 0

if __name__ == '__main__':
    sys.exit(main())

Fixed, accepted submission:
import sys
import math
import numpy as np
import copy

def main():
    s = input()

    a, b, c, d = "dream", "dreamer", "erase", "eraser"
    ra, rb, rc, rd = a[::-1], b[::-1], c[::-1], d[::-1]
    rs = s[::-1]

    while rs:
        flag = False
        for ele in [ra, rb, rc, rd]:
            if rs.startswith(ele):
                rs = rs.replace(ele, "", 1)
                flag = True
        if not flag:
            print("NO")
            return 0
    
    print("YES")
    return 0

if __name__ == '__main__':
    sys.exit(main())
Problem:
Snuke is giving cookies to his three goats.  He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).  Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

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

if l[0] % 3 == 0:
    print("Possible")
elif l[1] % 3 == 0:
    print("Possible")
elif l[0]+l[1] % 3 == 0:
    print("Possible")
else:
    print("Impossible")


Fixed, accepted submission:
l = list(map(int, input().split()))
a = l[0]+l[1]

if l[0] % 3 == 0:
    print("Possible")
elif l[1] % 3 == 0:
    print("Possible")
elif a % 3 == 0:
    print("Possible")
else:
    print("Impossible")
Problem:
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).  The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

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

cards = OrderedDict()
cards['S'] = set()
cards['H'] = set()
cards['D'] = set()
cards['C'] = set()

n = int(input())
for _ in range(n):
    suit, num = input().split()
    num = int(num)
    cards[suit].add(num)

for suit, nums in cards.items():
    for num in range(1,14):
        if num not in nums:
            print(suit, num)

Fixed, accepted submission:
n = int(input())
deck = []
for i in range(n):
    deck.append(input())

for suit in 'SHCD':
    for i in range(1, 14):
        card = f'{suit} {i}'
        if card not in deck:
            print(card)
Problem:
M-kun is a competitor in AtCoder, whose highest rating is X.   In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:    * From 400 through 599: 8-kyu   * From 600 through 799: 7-kyu   * From 800 through 999: 6-kyu   * From 1000 through 1199: 5-kyu   * From 1200 through 1399: 4-kyu   * From 1400 through 1599: 3-kyu   * From 1600 through 1799: 2-kyu   * From 1800 through 1999: 1-kyu  What kyu does M-kun have?

Incorrect submission (verdict: Wrong Answer):
x=float(input("m?"))
for i in range(8):
  if 400+200*i<=x<400+200*(i+1):
    print(8-i)

Fixed, accepted submission:
x=float(input())
for i in range(8):
  if 400+200*i<=x<400+200*(i+1):
    print(8-i)
Problem:
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room.  For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left.  Assume that initially no person lives in the building.

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

S = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    S[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(S[i][j][k]), end = "")
        print("")
    if i == 4:
        break
    print("####################")

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

S = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    b, f, r, v = map(int, input().split())
    S[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(S[i][j][k]), end = "")
        print("")
    if i == 3:
        break
    print("####################")
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):
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n = Ii()
print(n%1000)

Fixed, accepted submission:
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n = Ii()
if n%1000 == 0:
  print(0)
else:
  print(1000-n%1000)
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):
import datetime
import string
import re
import math

N = int(input())
while N > 1000:
    N -= 1000

print(N)


Fixed, accepted submission:
import datetime
import string
import re
import math

N = int(input())
while N > 1000:
    N -= 1000

print(1000 - N)
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):
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    x = int(input())

    ans = 0
    for a in range(1, A+1):
        for b in range(1, B+1):
            for c in range(1, C+1):
                if 500*a+50*b+10*c == x:
                    ans += 1
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Fixed, accepted submission:
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    x = int(input())

    ans = 0
    for a in range(0, A+1):
        for b in range(0, B+1):
            for c in range(0, C+1):
                if 500*a+100*b+50*c == x:
                    ans += 1
    print(ans)

input = lambda: stdin.readline().rstrip()
main()