TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
print((a+b+1)/2)

Fixed, accepted submission:
a, b = map(int, input().split())
print(int((a+b+1)/2))
Problem:
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.  Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.  Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
R=[[] for i in range(N)]
C=[[] for i in range(N)]
a=[]
b=[]
L=[]

for i in range(N-1):
    ai,bi=map(int,input().split())
    a.append(ai-1)
    b.append(bi-1)
    R[a[i]].append(b[i])
    L.append(len(R[a[i]]))

K=max(L)

if len(R[0])!=K:
    K+=1
print(K)

for i in range(N-1):
    for k in range(1,K+1):
        if not k in C[a[i]]:
            print(k)
            C[a[i]].append(k)
            C[b[i]].append(k)
            break
        else:continue



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

for i in range(N-1):
    ai,bi=map(int,input().split())
    a.append(ai-1)
    b.append(bi-1)
    G[ai-1].append(bi-1)
    G[bi-1].append(ai-1)

k=[0]*N

from collections import deque

q=deque([0])
visited=[0]*N
ans={}
p=[-1]*N

kmx=0
while q:
    x=q.popleft()
    visited[x]=1
    cnt=1
    for i in G[x]:
        if visited[i]!=0:continue
        if p[x]==cnt:
            cnt+=1
        ans[(x,i)]=cnt
        ans[(i,x)]=cnt

        p[i] = cnt
        cnt += 1
        kmx=max(kmx,cnt-1)
        q.append(i)

print(kmx)
for i in range(N-1):
    print(ans[(a[i],b[i])])
Problem:
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.  The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.  How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
H = int(input())
W = int(input())
print((N-H+1)+(N-W+1))


Fixed, accepted submission:
N = int(input())
H = int(input())
W = int(input())
print((N-H+1)*(N-W+1))
Problem:
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.  Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.

Incorrect submission (verdict: Wrong Answer):
a=input()
b=input()
if a==b[::-1]:
    print('Yes')
else:print('No')

Fixed, accepted submission:
a=input()
b=input()
if a==b[::-1]:
    print('YES')
else:print('NO')
Problem:
Write a program which reads three integers, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int,input().split())
if a > b:
    x = a
    a = b
    b = a
elif b > c:
    x = b
    b = c
    c = x
elif a > b:
    x = a
    a = b
    b = x

print(a,b,c,end = " ")
    
    
    
    



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

print(a,b,c,sep = " ")
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

Incorrect submission (verdict: Wrong Answer):
s = str(input())
Alst = []
Zlst = []
for i in range(len(s)):
    if s[i]=='A':
        Alst.append(i)
    elif s[i]=='Z':
        Zlst.append(i)
print(max(Zlst)-min(Alst))

Fixed, accepted submission:
s = str(input())
Alst = []
Zlst = []
for i in range(len(s)):
    if s[i]=='A':
        Alst.append(i)
    elif s[i]=='Z':
        Zlst.append(i)
print(max(Zlst)-min(Alst)+1)
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 = map(int,input().split())

if b-a == c-b :
    print("Yes")
else:
    print("No")


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

if b-a == c-b :
    print("YES")
else:
    print("NO")
Problem:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

Incorrect submission (verdict: Wrong Answer):
m,d=map(int,input().split())
month = [i for i in range(1,m+1)]
ct=0
if d<10:
  print(0)
  exit()
for i in range(11,d+1):
  a=int(str(i)[0])
  b=int(str(i)[1])
  if a*b in month:
    ct+=1
print(ct)

Fixed, accepted submission:
m,d=map(int,input().split())
month = [i for i in range(1,m+1)]
ct=0
if d<10:
  print(0)
  exit()
for i in range(11,d+1):
  a=int(str(i)[0])
  b=int(str(i)[1])
  if a*b in month and a>=2 and b>=2:
    ct+=1
print(ct)
Problem:
Rng is preparing a problem set for a qualification round of CODEFESTIVAL.  He has N candidates of problems. The difficulty of the i-th candidate is D_i.  There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems.  Determine whether Rng can complete the problem set without creating new candidates of problems.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
for i in range(n):
	for k in range(len(d)):
		print(len(d))
		if len(t) == 0:
			print('YES')
			break
		elif t[0] == d[k]:
			del d[k]
			del t[0]
			break
if len(t) == 0:
	print('YES')
else:
	print('NO')

Fixed, accepted submission:
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')
Problem:
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally).  Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate.  Out of the N materials, how many can produce an H \times W plate if properly cut?

Incorrect submission (verdict: Wrong Answer):
N,H,W = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*N]
print(sum(a<=H and b<=W for a,b in AB))

Fixed, accepted submission:
N,H,W = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*N]
print(sum(a>=H and b>=W for a,b in AB))
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):
import sys
n = int(input())
txy = []
for i in range(n):
  txy.append(list(map(int, input().split())))
pt = 0
py = 0
px = 0
for t, x, y in txy:
  dt = t - pt
  dx = x - px
  dy = y - py
  ax = abs(dx) % 2
  ay = abs(dy) % 2
  a = ax + ay % 2
  if abs(dx) + abs(dy) > dt or a != dt % 2:
    print("No")
    sys.exit()
print("Yes")

Fixed, accepted submission:
import sys
n = int(input())
txy = []
for i in range(n):
  txy.append(list(map(int, input().split())))
pt = 0
py = 0
px = 0
for t, x, y in txy:
  dt = t - pt
  dx = x - px
  dy = y - py
  ax = abs(dx) % 2
  ay = abs(dy) % 2
  a = (ax + ay) % 2
  if abs(dx) + abs(dy) > dt or a != dt % 2:
    print("No")
    sys.exit()
print("Yes")
Problem:
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.  The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.  How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?

Incorrect submission (verdict: Wrong Answer):
N=int(input())
H=int(input())
W=int(input())
H+=1-N
W+=1-N
print(H*W)

Fixed, accepted submission:
N=int(input())
H=int(input())
W=int(input())
print((N-H+1)*(N-W+1))
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(1000-(n//1000))

Fixed, accepted submission:
n = int(input())
print((1000-(n%1000))%1000)
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(800*(min(n, 15)) + 600*(max(0, n-15)))

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

Incorrect submission (verdict: Wrong Answer):
import queue
from collections import defaultdict
n,m = map(int,input().split())
g = defaultdict(set)
ans = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].add(b)
    g[b].add(a)

visited = [False]*n
visited[0] = True
q = queue.Queue()
q.put(0)
while not q.empty():
    v = q.get()
    for p in g[v]:
        if not visited[p]:
            ans[p] = v
            q.put(p)
            visited[p] = True
for x in ans[1:]:
    print(x+1)

Fixed, accepted submission:
import queue
from collections import defaultdict
n,m = map(int,input().split())
g = defaultdict(set)
ans = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].add(b)
    g[b].add(a)

visited = [False]*n
visited[0] = True
q = queue.Queue()
q.put(0)
while not q.empty():
    v = q.get()
    for p in g[v]:
        if not visited[p]:
            ans[p] = v
            q.put(p)
            visited[p] = True
print('Yes')
for x in ans[1:]:
    print(x+1)
Problem:
We have a grid with H rows and W columns. At first, all cells were painted white.  Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.  Compute the following:    * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?

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

def main():
	H, W, N = map(int, input().split(" "))
	AB = []
	for _ in range(N):
		a, b = map(int, input().split(" "))
		AB.append((a, b))

	ans = {}
	for i, val in enumerate(AB):
		a, b = val
		a, b = a-1, b-1
		for ba in range(max(0, a-2), min(H-2, a+1)):
			for bb in range(max(0, b-2), min(W-2, b+1)):
				if (ba, bb) in ans.keys():
					ans[(ba, bb)] += 1
				else:
					ans[(ba, bb)] = 1
				if bb == 3:
					print("{} {}".format(a+1, b+1))

	ans2 = [0] * 10
	total = (H-2) * (W-2)
	t = 0
	print(ans)
	for i in ans.values():
		ans2[i] += 1
		t += 1
	ans2[0] = total - t
	for i in range(10):
		print(ans2[i])

if __name__ == "__main__":
	main()


Fixed, accepted submission:
# -*- coding: utf-8 -*-
import sys

def main():
	H, W, N = map(int, input().split(" "))
	AB = []
	for _ in range(N):
		a, b = map(int, input().split(" "))
		AB.append((a, b))

	ans = {}
	for i, val in enumerate(AB):
		a, b = val
		a, b = a-1, b-1
		for ba in range(max(0, a-2), min(H-2, a+1)):
			for bb in range(max(0, b-2), min(W-2, b+1)):
				if (ba, bb) in ans.keys():
					ans[(ba, bb)] += 1
				else:
					ans[(ba, bb)] = 1

	ans2 = [0] * 10
	total = (H-2) * (W-2)
	t = 0
	for i in ans.values():
		ans2[i] += 1
		t += 1
	ans2[0] = total - t
	for i in range(10):
		print(ans2[i])

if __name__ == "__main__":
	main()
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

Incorrect submission (verdict: Wrong Answer):
n= int(input())
l= list(map(int,input().split()))
s= 0
for i in range(n-1):
	if(l[i+1]<l[0]):
		l[0],l[i+1]= l[i+1],l[0]
for j in range(n-1):
	if(l[n-1]<l[j]):
		l[n-1],l[j]= l[j],l[n-1]
for k in range(n-1):
	s+= l[i]
print(l[0],l[n-1],s)

Fixed, accepted submission:
n= int(input())
l= list(map(int,input().split()))
s= 0
for i in range(n):
	if(l[i]<l[0]):
		l[0],l[i]= l[i],l[0]
for j in range(n):
	if(l[n-1]<l[j]):
		l[n-1],l[j]= l[j],l[n-1]
for k in range(n):
	s+= l[k]
print(l[0],l[n-1],s)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):
a,b,k = map(int,input().split())
lia,lib = [],[]

for i in range(a,min(a+k,b)):
    lia.append(i)
for i in range(max(a,b-k+1),b+1):
    lib.append(i)

lia.extend(lib)
for i in set(lia):
    print(i)

Fixed, accepted submission:
a,b,k = map(int,input().split())
lia,lib = [],[]

for i in range(a,min(a+k,b)):
    lia.append(i)
for i in range(max(a,b-k+1),b+1):
    lib.append(i)

lia = list(set(lia+lib))
lia.sort()
for i in lia:
    print(i)
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())
if b<=a and a<=c:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
def yaya(boo):
  if boo:
    print("Yes")
  else:
    print("No")
a,b,c=map(int,input().split())
yaya(a<=c and c<=b)
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

Incorrect submission (verdict: Wrong Answer):
n,a,b = map(int,input().split())
S = input()
passed = 0
f_passed = 0
for s in S:
  if s == "a":
    if passed <= a + b:
      print("Yes")
      passed += 1
    else:
      print("No")
  elif s == "b":
    if passed <= a + b and f_passed <= b:
      print("Yes")
      passed += 1
      f_passed += 1
    else:
      print("No")
  else:
    print("No")

Fixed, accepted submission:
n,a,b = map(int,input().split())
S = input()
passed = 0
f_passed = 0
for s in S:
  if s == "a":
    if passed < a + b:
      print("Yes")
      passed += 1
    else:
      print("No")
  elif s == "b":
    if passed < a + b and f_passed + 1 <= b:
      print("Yes")
      passed += 1
      f_passed += 1
    else:
      print("No")
  else:
    print("No")
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
num = list(map(int,input().split()))
for m in num:
  t = m % 2
  if t == 0:
    print("Even")
  else:
    print("Odd")

Fixed, accepted submission:
num = list(map(int,input().split()))
a = num[0]
b = num[1]
c = (a * b) % 2
if c == 0:
  print("Even")
else:
  print("Odd")
Problem:
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.  He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.  Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.

Incorrect submission (verdict: Wrong Answer):
def Main():
  n = int(input())
  A = list(map(int, input().split()))
  s = set(A)
  print(len(s))
if __name__ == '__main__':
  Main()

Fixed, accepted submission:
def Main():
  n = int(input())
  A = list(map(int, input().split()))
  s = set(A)

  if len(s)%2 == 0:
    print(len(s) - 1)
  else:
    print(len(s))

if __name__ == '__main__':
  Main()
Problem:
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally).  Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate.  Out of the N materials, how many can produce an H \times W plate if properly cut?

Incorrect submission (verdict: Wrong Answer):
from math import floor
N, H, W = map(int, input().split())
ans = 0

for i in range(N):
  A, B = map(int, input().split())
  ans += (A//H) * (B//W)
  
print(ans)

Fixed, accepted submission:
from math import floor
N, H, W = map(int, input().split())
ans = 0
 
for i in range(N):
  A, B = map(int, input().split())
  if (A//H) * (B//W) > 0:
    ans += 1
  
print(ans)
Problem:
In this problem, we use the 24-hour clock.  Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?

Incorrect submission (verdict: Wrong Answer):
T = input()
t = T.count("?")
num =[]
for i in range(0,t+1):
    st = T.replace("?" , "D", i)
    for n in range(0,t+1):
        ste = st.replace("?","P",n)
        for q in range(0,t+1):
            stes = ste.replace("?","D",q)
            num.append(stes)
            print(num)
s = stes.count("DD")
f = stes.count("PD")
ans = s + f
print(ans)

Fixed, accepted submission:
h,m,H,M,k = map(int,input().split())

t1 = 60*h + m
t2 = 60*H + M

ans = t2 - t1 - k
print(ans)
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
A,B,C = input().split()
if A[0] == B[-1] and B[0] == C[0]:
    print ("YES")
else:
    print  ("NO")


Fixed, accepted submission:
A,B,C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print ("YES")
else:
    print  ("NO")
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 = tuple(int(c) for c in input().split(' '))
B, W = tuple(int(c) for c in input().split(' '))
T = int(input())

delta = V - W

if A == B:
  print('YES')
  exit()
elif delta <= 0:
  print('NO')
  exit()
else:
  d = abs(A-B)
  time = d // delta + 1
  print(time)
  

Fixed, accepted submission:
A, V = tuple(int(c) for c in input().split(' '))
B, W = tuple(int(c) for c in input().split(' '))
T = int(input())

delta = V - W

if A == B:
  print('YES')
  exit()
elif delta <= 0:
  print('NO')
  exit()
else:
  d = abs(A-B)
  time = d / delta
  if time <= T:
    print('YES')
  else:
    print('NO')