TnT/CodeNet4Repair huggingface dataset:
Problem:
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.  However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells.  Find the number of ways she can travel to the bottom-right cell.  Since this number can be extremely large, print the number modulo 10^9+7.

Incorrect submission (verdict: Wrong Answer):
def main():
    h,w,a,b=map(int,input().split(' '))
    mod = 10**9+7
    mx=max(h,w)
    fac=[1]*(h+w+1)
    for i in range(1,h+w+1):
        fac[i]=fac[i-1]*i%mod
    rev=[1]*(mx+1)
    rev[-1]=pow(fac[mx],mod-2,mod)
    for i in range(mx-1,-1,-1):
        rev[i+1]=rev[i+1]*(i+1)%mod
    const=rev[h-a-1]*rev[a-1]%mod
    ans = sum(fac[h - a + i - 1] * rev[i] * fac[a + w - 2 - i] * rev[w - i - 1] % mod for i in range(b, w))
    print(ans * const % mod)



if __name__ == '__main__':
    main()


Fixed, accepted submission:
def main():
    h,w,a,b=map(int,input().split(' '))
    mod = 10**9+7
    mx=max(h,w)
    fac=[1]*(h+w+1)
    for i in range(1,h+w+1):
        fac[i]=fac[i-1]*i%mod
    rev=[1]*(mx+1)
    rev[-1]=pow(fac[mx],mod-2,mod)
    for i in range(mx-1,-1,-1):
        rev[i]=rev[i+1]*(i+1)%mod
    const=rev[h-a-1]*rev[a-1]%mod
    ans = sum(fac[h - a + i - 1] * rev[i] * fac[a + w - 2 - i] * rev[w - i - 1] % mod for i in range(b, w))
    print(ans * const % mod)



if __name__ == '__main__':
    main()
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
def insertionSort(A,N):
    for i in range(1,len(A)):
        v = A[i]
        j=i-1
        while(j>=0 and A[j] > v):
            A[j+1] = A[j]
            j-=1
        A[j+1]=v
        print(*A)

def main():
    print("??°????????\???")
    A = list(map(int,input().split()))
    N = len(A)
    insertionSort(A,N)

if __name__ == '__main__':
    main()

Fixed, accepted submission:
N = int(input())
A = list(map(int,input().split()))
print( *A )
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A [j] > v :
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print( *A )
Problem:
For an integer n not less than 0, let us define f(n) as follows:    * f(n) = 1 (if n < 2)   * f(n) = n f(n-2) (if n \geq 2)  Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Incorrect submission (verdict: Wrong Answer):
n=int(input())
ans=0
if n % 2==1:
    for i in range(1,19):
        waru = 2*5**i
        if n < waru:
            break
        else:
            tmp = n/waru
            ans += int(tmp)
print(str(ans))

Fixed, accepted submission:
n=int(input())
ans=0
if n % 2==0:
    for i in range(1,10000):
        waru = 2*5**i
        if n < waru:
            break
        else:
            tmp = n//waru
            ans += tmp
print(str(ans))
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
print(N*800-200*N//15)

Fixed, accepted submission:
N = int(input())
print(N*800-200*(N//15))
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 = list(map(int, input().split()))

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

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

if b-a==c-b:
	print('YES')
else:
	print('NO')
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

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

ans = 0
for i in range(R):
  cntR = N - i
  for j in range(min(cntR, G)):
    cntG = cntR - j
    if cntG <= B:
      ans += 1
print(ans)


Fixed, accepted submission:
R, G, B, N = map(int, input().split())

ans = 0
for i in range(N//R+1):
  cntR = N - i * R
  for j in range(cntR//G+1):
    cntG = cntR - j * G
    if cntG % B == 0:
      ans += 1
print(ans)
Problem:
Write a program which finds a pattern $p$ in a ring shaped text $s$.     

Incorrect submission (verdict: Wrong Answer):
s = str(input())
p = str(input())
case = s + s
if p in case == True:
	print('yes')
else:
	print('no')


Fixed, accepted submission:
s = str(input())
p = str(input())
case = s + s
if p in case:
	print('Yes')
else:
	print('No')
Problem:
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}.  Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())
c = []
for _ in range(h):
    c.append(list(input()))

for i in range(h):
    print(*c[i])
    print(*c[i])

Fixed, accepted submission:
h,w = map(int,input().split())
c = []
for _ in range(h):
    c.append(list(input()))

for i in range(h):
    print("".join(c[i]))
    print("".join(c[i]))
Problem:
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball.  He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls.  Find the minimum number of balls that Takahashi needs to rewrite the integers on them.

Incorrect submission (verdict: Wrong Answer):
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
counter_list = []
for i in range(N):
    if a_list.count(i) > 0:
        counter_list.append(a_list.count(i))

counter_list.sort()

count = 0
for i in range(len(counter_list) - K):
    count += i

print(count)

Fixed, accepted submission:
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
counter_list = [0]*N
for i in a_list:
    counter_list[i-1] += 1

counter_list.sort(reverse=True)

ans = N - sum(counter_list[:K])    

print(ans)
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())
a = N%1000
if(a==0):
  print(a)
else:
  print(1000-a)
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):
N = int(input())
A = list(map(int, input().split()))

count = 0
flag = False
while True:
  for n in range(N):
    if A[n] % 2 == 0: 
      A[n] = A[n] / 2
    else: 
      flag = True
      break 
  count += 1
  if flag: break

Fixed, accepted submission:
N = int(input())
A = list(map(int, input().split()))
 
count = 0
flag = False
while True:
  for n in range(N):
    if A[n] % 2 != 0:
      flag = True
      break
  if flag: break
  
  for n in range(N):
    A[n] //= 2
  count += 1

print(count)
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):
import numpy as np

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

odd=np.count_nonzero(A%2!=0)
four=np.count_nonzero(A%4==0)

if odd+four==N:
  if odd-1<=four:
    print('Yes')
  else:
    print('No')
else:
  if odd==2 and four==2:
    print('Yes')
  elif odd+1<=four:
    print('Yes')
  else:
    print('No')


Fixed, accepted submission:
import numpy as np
 
N=int(input())
A=np.array(list(map(int,input().split())))
 
odd=np.count_nonzero(A%2!=0)
four=np.count_nonzero(A%4==0)
ans='No'

if odd==1 and four>=1:
  ans='Yes'
elif odd==2 and four>=2:
  ans='Yes'
else:
  if odd+four==N and odd-1<=four:
    ans='Yes'
  elif odd<=four:
    ans='Yes'
print(ans)
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Incorrect submission (verdict: Wrong Answer):
x=int(input())
for t in range(1,10**5+1):
  if t*(t-1)//2>x:
    print(t-1)
    exit()

Fixed, accepted submission:
x=int(input())
for t in range(1,10**5+1):
  if t*(t-1)//2>=x:
    print(t-1)
    exit()
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):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = list(input())

print(a)

if a[0] == a[1] and a[1] == a[2]:
    print("Yes")

elif a[0] == a[1] and a[1] == a[3]:
    print("Yes")

elif a[0] == a[2] and a[2] == a[3]:
    print("Yes")

elif a[2] == a[1] and a[1] == a[3]:
    print("Yes")

else:
    print("No")

Fixed, accepted submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = list(input())


if (a[0] == a[1]) and (a[1] == a[2]):
    print("Yes")


elif (a[2] == a[1]) and (a[1] == a[3]):
    print("Yes")

else:
    print("No")
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):
sharpNum = 20
roomNum = 10
height = 15
dataNum = int(input())
#building = [[0]*sharpNum] * height
building = [[0] * sharpNum for i in range(height)]
actRoom = 0
for data in range(dataNum):
    b,f,r,v = map(int, input().split())
    for floor in range(height):
        if floor%4 == 3:
            for room in range(sharpNum):
                #print("#floor: %d" %floor)
                #print("#room: %d" %room)
                building[floor][room] = "#"
                #print("buiding: &s" %building[floor][room])
        else:
            for room in range(sharpNum):
                if room%2 == 0:
                    building[floor][room] = " "
                else:
                    actRoom = actRoom + 1
                    #print("#room: %d" %room)
                    #print("#actRoom: %d" %actRoom)
                    if floor == f-1 and actRoom == r:
                        building[floor][room] = building[floor][room] + v

for floor in range(height):      
    for i in range(len(building[0])):
        print(building[floor][i],end="")


Fixed, accepted submission:
sharpNum = 20
roomNum = 10
height = 15
dataNum = int(input())
#building = [[0]*sharpNum] * height
building = [[0] * sharpNum for i in range(height)]

for data in range(dataNum):
    actBuilding = 1
    actRoom = 0
    actFloor = 0
    b,f,r,v = map(int, input().split())
    for floor in range(height):
        actRoom = 0
        if floor%4 == 3:
            actFloor = 0
            actBuilding = actBuilding + 1
            for room in range(sharpNum):
                building[floor][room] = "#"
        else:
            actFloor = actFloor + 1
            
            for room in range(sharpNum):
                if room%2 == 0:
                    building[floor][room] = " "
                else:
                    actRoom = actRoom + 1 
                    if actBuilding == b and actFloor== f and actRoom == r:
                        building[floor][room] = building[floor][room] + v

for floor in range(height):      
    for i in range(len(building[0])):
        print(building[floor][i],end="")
    print("")
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] == ".":
            c = 0
            for x in range(-1, 2):
                for y in range(-1, 2):
                    if x == 0 and y == 0:
                        break
                    else:
                        if 0 <= i+y and 0 <= j+x and i+y < h and j+x < w:
                            if s[i+y][j+x] == "#":
                                c += 1
            s[i][j] = str(c)
for a in range(h):
    print("".join(s[a]))

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] == ".":
            c = 0
            for x in range(-1, 2):
                for y in range(-1, 2):
                    if x == 0 and y == 0:
                        continue
                    else:
                        if 0 <= i+y and 0 <= j+x and i+y < h and j+x < w:
                            if s[i+y][j+x] == "#":
                                c += 1
            s[i][j] = str(c)
for a in range(h):
    print("".join(s[a]))
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
s = int(input())
m = 0
h = 0

if s >= 60:
    m = int(s / 60)
    s = s % 60

if m >= 60:
    h = int(m / 60)
    m = m % 60

print(h,m,s)


Fixed, accepted submission:
s = int(input())
m = 0
h = 0

if s >= 60:
    m = int(s / 60)
    s = s % 60

if m >= 60:
    h = int(m / 60)
    m = m % 60

print(h,end = ":")
print(m,end = ":")
print(s)
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

Incorrect submission (verdict: Wrong Answer):
komoji = input()
if komoji in "aeiou" == True:
    print("vowel")
else:
    print("consonant")

Fixed, accepted submission:
s = input()
if s in "aeiou":
    print("vowel")
else:
    print("consonant")
Problem:
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c).  Takahashi and Aoki will play a game, where each player has a string of length N. Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: `L`, `R`, `U` and `D`.  The game consists of N steps. The i-th step proceeds as follows:    * First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece.   * Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece.  Here, to move the piece in the direction of `L`, `R`, `U` and `D`, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done.  Takahashi wants to remove the piece from the grid in one of the N steps. Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid. Determine if the piece will remain on the grid at the end of the game when both players play optimally.

Incorrect submission (verdict: Wrong Answer):
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
  print(hidari,migi,ue,shita)
  if S[i] == 'L':
    hidari -= 1
  if S[i] == 'R':
    migi += 1
  if S[i] == 'U':
    ue -= 1
  if S[i] == 'D':
    shita += 1
  if hidari == 0 or migi == W+1 or ue == H+1 or shita == 0:
    flag = 1
  
  print(hidari,migi,ue,shita)
  if T[i] == 'R' and hidari != W:
    hidari += 1
  if T[i] == 'L' and migi != 0:
    migi -= 1
  if T[i] == 'D' and ue != 0:
    ue += 1
  if T[i] == 'U' and shita != H:
    shita -= 1

if flag :
  print("NO")
else :
  print("YES")
  

Fixed, accepted submission:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
  if S[i] == 'L':
    hidari -= 1
  if S[i] == 'R':
    migi += 1
  if S[i] == 'U':
    ue -= 1
  if S[i] == 'D':
    shita += 1
  if hidari == 0 or migi == W+1 or ue == 0 or shita == H+1 :
    flag = 1
  
  if T[i] == 'R' and hidari != W:
    hidari += 1
  if T[i] == 'L' and migi != 1:
    migi -= 1
  if T[i] == 'D' and ue != H:
    ue += 1
  if T[i] == 'U' and shita != 1:
    shita -= 1

if flag :
  print("NO")
else :
  print("YES")
Problem:
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.  Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Incorrect submission (verdict: Wrong Answer):
for i in range(3):
    print(input()[i],sep='')

Fixed, accepted submission:
s=''
for i in range(3):
    s+=input()[i]
print(s)
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
n, k = map(int, input().split())
sum = 0
for i in range (1, n-1):
    sum = sum + i
    print(sum)
if k >= sum:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
n, k = map(int, input().split())
num = n/2+ 0.5
if num >= k:
    print("YES")
else:
    print("NO")
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()))

if sorted(ABC) == [5,5,7]:
    print("Yes")
else:
    print("No")

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

if sorted(ABC) == [5,5,7]:
    print("YES")
else:
    print("NO")
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):
def time(x):
    return 48-int(x)
time(input())

Fixed, accepted submission:
a = input()
x = int(a)
print(48-x)
Problem:
Takahashi is a user of a site that hosts programming contests.   When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows:    * Let the current rating of the user be a.   * Suppose that the performance of the user in the contest is b.   * Then, the new rating of the user will be the avarage of a and b.  For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.  Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.   Find the performance required to achieve it.

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

Fixed, accepted submission:
a = int(input())
b = int(input())
print(2*b-a)
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
s = input()
n = int(s)**3
print('x =', s,'x^3=', n)


Fixed, accepted submission:
x = int(input())
print(x*x*x)
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):
a, b = map(int, input().split())
if a + b % 3 == 0:
  print('Possible')
  exit()
elif a % 3 == 0:
  print('Possible')
  exit()
elif b % 3 == 0:
  print('Possible')
  exit()
print('Impossible')

Fixed, accepted submission:
a, b = map(int, input().split())
if (a + b) % 3 == 0:
  print('Possible')
  exit()
elif a % 3 == 0:
  print('Possible')
  exit()
elif b % 3 == 0:
  print('Possible')
  exit()
print('Impossible')