TnT/CodeNet4Repair huggingface dataset:
Problem:
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.  Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.  For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:    * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.   * For every i, B_i \leq C_i holds.  If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
d = [A[i]-B[i] for i in range(N)]
print(d)
d.sort()
neg = 0
count = 0
for e in d:
    if e < 0:
        neg += e
        count += 1
        continue
    break
for e in d[::-1]:
    if neg >= 0:
        break
    neg += e 
    count += 1
print(count)

Fixed, accepted submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
d = [A[i]-B[i] for i in range(N)]
d.sort()
neg = 0
count = 0
for e in d:
    if e < 0:
        neg += e
        count += 1
        continue
    break
for e in d[::-1]:
    if neg >= 0:
        break
    neg += e 
    count += 1
print(count)
Problem:
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N.  Find the minimum cost incurred before reaching the goal.

Incorrect submission (verdict: Wrong Answer):
n,m,x=map(int,input().split())
a=map(int,input().split())
print(min(len([i for i in a if x<i]),len([i for i in a if x>i])))

Fixed, accepted submission:
n,m,x=map(int,input().split())
a=map(int,input().split())
b,c=[],[]
for i in a:
  if i>x:
  	b.append(i) 
  else:
    c.append(i)
print(min(len(b),len(c)))
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):
string_list = [input() for i in range(3)]

a = int(string_list[0])
b = int(string_list[1])
h = int(string_list[2])

answer = (a+b)*h/2

print(answer)


Fixed, accepted submission:
string_list = [input() for i in range(3)]

a = int(string_list[0])
b = int(string_list[1])
h = int(string_list[2])

answer = (a+b)*h//2

print(answer)
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())
s=S%60
S/=60
m=S%60
h=S/60
print("{}:{}:{}".format(h, m, s))

Fixed, accepted submission:
S=int(input())
print("{}:{}:{}".format(S//3600, (S//60)%60, S%60))
Problem:
Compute A \times B, truncate its fractional part, and print the result as an integer.

Incorrect submission (verdict: Wrong Answer):
import math
a,b=map(float,input().split())
z=int(math.ceil(a*b))
print(z)


Fixed, accepted submission:
import math
x,y=input().split()
a=int(x)
y=y.replace('.','')
b=int(y)
z=(a*b)//100
print(z)
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 abs(a-b)> c:
  print("yes")
else:
  print("no")

Fixed, accepted submission:
a,b,c=map(int, input().split()) 
if a > c > b:
  print("Yes")
elif a < c < b:
  print("Yes")
else:
  print("No")
Problem:
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.  We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person.  At most how many people can sit on the seat?

Incorrect submission (verdict: Wrong Answer):
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
print((a-c)//b)

Fixed, accepted submission:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
print((a-c)//(b+c))
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

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

can = True
for i in range(N):
    t, x, y = list(map(int, input().split()))
    
    if not t%2 == (x+y)%2 or (x+y) > t:
        can = False
        break
print(can)

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

can = True
for i in range(N):
    t, x, y = list(map(int, input().split()))
    
    if not t%2 == (x+y)%2 or (x+y) > t:
        can = False
        break
        
if can:
    s = "Yes"
else:
    s = "No"
print(s)
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-


n, y = map(int, input().split())
judge = "no value"

for i in range(n+1):
    if judge == "Found it!":
        break
    for j in range(n+1):
        value = i * 1000 + j * 5000 + (n - i - j) *10000
        if value == y:
            print(i, j, n - i - j)
            judge = "Found it!"
            break

if judge == "no value":
    print(-1, -1, -1)

            
            
                
                

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

for i in range(n+1):
    for j in range(n+1):
        z = n - i - j
        value = z * 10000 + i * 5000 + j *1000
        if value == y and z >= 0:
            print(z, i , j)
            break
        
    else:
        continue
    
    break

else:
    print(-1, -1, -1)
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):
a, b, c = map(int, input().split())
k = int(input())
c = c * 2 ** k

i = 1
if a < b:
  if b < c:
    print("Yes")
  else:
    print("No")
else:
  while i <= k:
    if a < i * b and i * b < c:
      print("Yes")
      break
    else:
      b = b * 2
      i += 1
  if i > k:
    print("No")

print(a, b, c, i)

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

i = 1
if a < b:
  if b < c:
    print("Yes")
  else:
    print("No")
else:
  while i <= k:
    if a < b and b < c:
      print("Yes")
      break
    else:
      b = b * 2
      c = int(c / 2)
      i += 1
  if i > k:
    print("No")
Problem:
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.  The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.  How many different PIN codes can he set this way?  Both the lucky number and the PIN code may begin with a 0.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = input()
print(s)
cnt = 0
for s1 in range(10):
    s1_ind = s.find(str(s1))
    if s1_ind == -1 or s1_ind >= len(s)-2 : continue
    for s2 in range(10):
        s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
        if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
        for s3 in range(10):
            s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
            if s3_ind > s2_ind: 
                cnt+=1

print(cnt)



Fixed, accepted submission:
n = int(input())
s = input()
cnt = 0
for s1 in range(10):
    s1_ind = s.find(str(s1))
    if s1_ind == -1 or s1_ind >= len(s)-2 : continue
    for s2 in range(10):
        s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
        if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
        for s3 in range(10):
            s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
            if s3_ind > s2_ind: 
                cnt+=1

print(cnt)
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())
A = [input() for i in range(N)]

print('AC × {}'.format(A.count('AC')))
print('WA × {}'.format(A.count('WA')))
print('TLE × {}'.format(A.count('TLE')))
print('RE × {}'.format(A.count('RE')))


Fixed, accepted submission:
N = int(input())
A = [input() for i in range(N)]

print('AC x', A.count('AC'))
print('WA x', A.count('WA'))
print('TLE x', A.count('TLE'))
print('RE x', A.count('RE'))
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
from bisect import bisect_left, bisect_right
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a = [int(i) for i in input().split()]
a.sort()
lim = len(a)//2
ans = []
for i, x in enumerate(a[::-1]):
    if i == lim:
        break
    if x != bisect_left(a, x//2):
        ans.append(combinations_count(x, bisect_left(a, x//2)))
    if x != bisect_right(a, x//2):
        ans.append(combinations_count(x, bisect_right(a, x//2)))
print(max(ans))

Fixed, accepted submission:
from itertools import combinations
n = int(input())
a = [int(i) for i in input().split()]
a.sort()

ai = a[-1]
aj = -1
for i in range(n-1):
    if abs(a[i] - ai/2) <= abs(aj - ai/2):
        aj = a[i]
print(ai, aj)
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

kyori = abs(a - b)
sokudo = abs(v-w)

if (a > b and v < w) and (a < b and v > w) and kyori < t * sokudo:
  print('YES')
else:
  print('NO')


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

kyori = abs(a - b)
sokudo = v-w

if kyori<=t*sokudo:
  print('YES')
else:
  print('NO')
Problem:
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.  Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:    * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter.  What is the minimum number of operations required to achieve the objective?

Incorrect submission (verdict: Wrong Answer):
n=open(0).read()
p=int(n[0])
ans=0
for i in range(p):
  ans+=len({n[i],n[p+i],n[p*2+i]})-1
print(ans)

Fixed, accepted submission:
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
  if a[i] == b[i] == c[i]:
    continue
  if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
    ans += 1
  else:
    ans += 2
print(ans)
Problem:
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1.  Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode:                 BubbleSort(C) 1 for i = 0 to C.length-1 2     for j = C.length-1 downto i+1 3         if C[j].value < C[j-1].value 4             swap C[j] and C[j-1]                 SelectionSort(C) 1 for i = 0 to C.length-1 2     mini = i 3     for j = i to C.length-1 4         if C[j].value < C[mini].value 5             mini = j 6     swap C[i] and C[mini]   Note that, indices for array elements are based on 0-origin.  For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A1 = list(map(str,input().split()))
A2 = A1[:]

def bubbleSort(A, N):
 flag = 0
 i = 0
 while flag == 0:
  flag = 1
  for j in range(N-1, i, -1):
   if A[j][1] < A[j-1][1]:
    A[j], A[j-1] = A[j-1], A[j]
    flag = 0
  i += 1
 return A

def selectSort(A, N):
 for i in range(N):
  minj = i
  for j in range(i, N):
   if A[j][1] < A[minj][1]:
    minj = j
  if A[i][1] != A[minj][1]:
   A[i], A[minj] = A[minj], A[i]
 return A

def stable(Ab, As, N):
 for i in range(N):
  if Ab[i] != As[i]:
   return False
 return True

bubbleSort(A1, N)
selectSort(A2, N)
print(" ".join(map(str, A1)))
print("Stable")
print(" ".join(map(str, A2)))
if stable(A1, A2, N):
 print("Stable")
else:
 print("Not Stable")

Fixed, accepted submission:
N = int(input())
A1 = list(map(str,input().split()))
A2 = A1[:]

def bubbleSort(A, N):
 flag = 0
 i = 0
 while flag == 0:
  flag = 1
  for j in range(N-1, i, -1):
   if A[j][1] < A[j-1][1]:
    A[j], A[j-1] = A[j-1], A[j]
    flag = 0
  i += 1
 return A

def selectSort(A, N):
 for i in range(N):
  minj = i
  for j in range(i, N):
   if A[j][1] < A[minj][1]:
    minj = j
  if A[i][1] != A[minj][1]:
   A[i], A[minj] = A[minj], A[i]
 return A

def stable(Ab, As, N):
 for i in range(N):
  if Ab[i] != As[i]:
   return False
 return True

bubbleSort(A1, N)
selectSort(A2, N)
print(" ".join(map(str, A1)))
print("Stable")
print(" ".join(map(str, A2)))
if stable(A1, A2, N):
 print("Stable")
else:
 print("Not stable")
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 = input()

if S == "abc":
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
S = list(input())
S.sort()
if S == ['a', 'b', 'c']:
    print("Yes")
else:
    print("No")
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):
str = input()
ans = '2018'+str[4:7]
print(ans)

Fixed, accepted submission:
str = input()
ans = '2018'+str[4:10]
print(ans)
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())
n_apperances = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(n):
    s = input()
    n_apperances[s] += 1

for key in n_apperances:
    print('{} × {}'.format(key, n_apperances[key]))


Fixed, accepted submission:
n = int(input())
n_apperances = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(n):
    s = input()
    n_apperances[s] += 1

for key in n_apperances:
    print('{} x {}'.format(key, n_apperances[key]))
Problem:
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Incorrect submission (verdict: Wrong Answer):
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n + 1)]
q = deque([])
visited = set()
dist = [None] * (n + 1)

for i in range(m):
    a, b, k = map(int, input().split())
    g[a].append((b, k))
    g[b].append((a, -k))

def dfs(u):
    q.append(u)
    while q:
        v = q.pop()
        visited.add(v)
        for x, d in g[v]:
            if x not in visited:
                if dist[x] is None:
                    dist[x] = dist[v] + d
                elif dist[x] != dist[v] + d:
                    return False
                q.append(x)
    return True

for i in range(1, n + 1):
    if i not in visited:
        print(len(visited))
        dist[i] = 1
        if not dfs(i):
            print("No")
            exit()
print("Yes")


Fixed, accepted submission:
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n + 1)]
q = deque([])
visited = set()
dist = [None] * (n + 1)

for i in range(m):
    a, b, k = map(int, input().split())
    g[a].append((b, k))
    g[b].append((a, -k))

def dfs(u):
    q.append(u)
    while q:
        v = q.pop()
        visited.add(v)
        for x, d in g[v]:
            if x not in visited:
                if dist[x] is None:
                    dist[x] = dist[v] + d
                elif dist[x] != dist[v] + d:
                    return False
                q.append(x)
    return True

for i in range(1, n + 1):
    if i not in visited:
        dist[i] = 1
        if not dfs(i):
            print("No")
            exit()
print("Yes")
Problem:
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.  For example, if K = 3, print `ACLACLACL`.

Incorrect submission (verdict: Wrong Answer):
"ACL"*int(input())

Fixed, accepted submission:
print("ACL"*int(input()))
Problem:
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.  Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:    * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.  At least how many explosions do you need to cause in order to vanish all the monsters?

Incorrect submission (verdict: Wrong Answer):
import math

import numpy as np


N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))


def enough(T):
    h2 = list(map(lambda x: x - B * T, h))
    print(h2)
    return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T


def solver(mi, ma):
    print(mi, ma)
    mid = (mi + ma) // 2
    if mi == ma:
        return mid
    elif enough(mid):
        return solver(mi, mid)
    else:
        return solver(mid + 1, ma)


t = max(h) // B

print(solver(0, t))


Fixed, accepted submission:
import math

N, A, B = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))


def enough(T):
    h2 = list(map(lambda x: x - B * T, h))
    return sum(map(lambda x: max(0, math.ceil(x / (A - B))), h2)) <= T


def solver(inf, sup):
    mid = (inf + sup) // 2
    if inf == sup:
        return mid
    elif enough(mid):
        return solver(inf, mid)
    else:
        return solver(mid + 1, sup)


t = 10 ** 9

print(solver(0, t))
Problem:
Rng is going to a festival.  The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer.  Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.

Incorrect submission (verdict: Wrong Answer):
s= input()
print(s[:-6])

Fixed, accepted submission:
s= input()
print(s[:-8])
Problem:
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:    * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.  Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.

Incorrect submission (verdict: Wrong Answer):
a,b,k = map(int,input().split())
for i in range(k):
  if i%2 == 0:
    if a%2 != 0 :
      a -=1
    a /= 2
    b += a
  else :
    if b%2 != 0:
      b -= 1
    b /= 2
    a += b
print(a,b)

Fixed, accepted submission:
a,b,k = map(int,input().split())
for i in range(k):
  if i%2 == 0:
    if a%2 != 0 :
      a -=1
    a /= 2
    b += a
  else :
    if b%2 != 0:
      b -= 1
    b /= 2
    a += b
print(int(a),int(b))