TnT/CodeNet4Repair huggingface dataset:
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
def solve():
    A,B = map(int,input().split())
    S = input()
    seq = [str(x) for x in range(10)]
    print(seq)

    for i in range(A+B+1):
        if i== A:
            if S[i] != "-":
                return False
        else:
            if not(S[i] in seq):
                return False
    return True

if __name__ == '__main__':
    cond = solve()
    if cond:
        print("Yes")
    else:
        print("No")

Fixed, accepted submission:
def solve():
    A,B = map(int,input().split())
    S = input()
    seq = [str(x) for x in range(10)]

    for i in range(A+B+1):
        if i== A:
            if S[i] != "-":
                return False
        else:
            if not(S[i] in seq):
                return False
    return True

if __name__ == '__main__':
    cond = solve()
    if cond:
        print("Yes")
    else:
        print("No")
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):
h1, m1, h2, m2, k = map(int, input().split())
print(min(0, (h2*60+m2) - (h1*60+m1) - k))

Fixed, accepted submission:
h1, m1, h2, m2, k = map(int, input().split())
print(max(0, (h2*60+m2) - (h1*60+m1) - k))
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
A = list(map(int,input().split()))
A.sort(reverse = True)

if A[0] == (A[1] + A[2]):
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
A = list(map(int,input().split()))
A.sort(reverse = True)

if A[0] == (A[1] + A[2]):
  print('Yes')
else:
  print('No')
Problem:
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.     

Incorrect submission (verdict: Wrong Answer):
def check(W, H, x, y, r):
    if W - x < r or  H - y < r:
        return "No"
    else:
        return "Yes"

L = list(map(int, input().split()))
check(L[0], L[1], L[2], L[3], L[4])

Fixed, accepted submission:
W, H, x, y, r = [int(x) for x in input().split()]
print("Yes" if (W - x >= r and H - y >= r and x > 0 and y > 0) else "No")
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=[int(i) for i in input().split()]
print("YES" if a<=c<=b else "NO")

Fixed, accepted submission:
a,b,c=[int(i) for i in input().split()]
print("Yes" if a<=c<=b else "No")
Problem:
AtCoder Mart sells 1000000 of each of the six items below:    * Riceballs, priced at 100 yen (the currency of Japan) each   * Sandwiches, priced at 101 yen each   * Cookies, priced at 102 yen each   * Cakes, priced at 103 yen each   * Candies, priced at 104 yen each   * Computers, priced at 105 yen each  Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible.   (Ignore consumption tax.)

Incorrect submission (verdict: Time Limit Exceeded):
X = int(input())
flag = 0
for a in range(0,1001):
  for b in range(0,1001):
    for c in range(0,1001):
      for d in range(0,1001):
        for e in range(0,1001):
          for f in range(0,1001):
            if 100*a+101*b+102*c+103*d+104*e+105*f == X:
              flag += 1
print(flag)

Fixed, accepted submission:
X = int(input())
flag = 0
for C in range(X+1):
  if 100*C <= X and 105*C >= X:
    flag += 1
    break
print(flag)
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: Time Limit Exceeded):
N = int(input())
Astr = input().split()
An = []
for A in Astr:
    An.append(int(A))
count = 0
end = 0
while end == 0:
    for A in An:
        if A%2==1:
            print(count)
            end = 1
            break
        else:
            A /= 2
    count += 1
        

Fixed, accepted submission:
N = int(input())
Astr = input().split()
A = []
for A_i in Astr:
    A.append(int(A_i))

candidate = 0
end = 0
while end == 0:
    for A_i in A:
        if (A_i/2**(candidate))%2 != 0:
            end = 1
            break
    else:
        candidate += 1
print(candidate)
Problem:
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?

Incorrect submission (verdict: Wrong Answer):
suuji = input()
print('input', suuji)
kaisu = 0
for i in suuji:
	if i == "2":
		kaisu += 1
	else:
		pass
print(kaisu)

Fixed, accepted submission:
suuji = input()
kaisu = 0
for i in suuji:
	if i == "2":
		kaisu += 1
	else:
		pass
print(kaisu)
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):
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 

input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))

INF = 1001001001

# ---------------------------------------

def main():
    A = inpl()
    A.sort()
    if A[0]==A[1]==5 and A[2]==7:
        print("Yes")
    else:
        print("No")

main()


Fixed, accepted submission:
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 

input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))

INF = 1001001001

# ---------------------------------------

def main():
    A = inpl()
    A.sort()
    if A[0]==A[1]==5 and A[2]==7:
        print("YES")
    else:
        print("NO")

main()
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())
print("Yes" if a < b < c else "No")

Fixed, accepted submission:
l = map(int, input().split())
print(' '.join(map(str, sorted(l))))
Problem:
An elementary school student Takahashi has come to a variety store.  He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?  Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Incorrect submission (verdict: Wrong Answer):
A, B, C = map(int,input().split())
if A+B>C:
    print('yes')
else:
    print('no')

Fixed, accepted submission:
A, B, C = map(int,input().split())
if A+B>=C:
    print('Yes')
else:
    print('No')
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())

x = N*800
y = int(N//15)

print(x-y)

Fixed, accepted submission:
N = int(input())
     
x = N*800
y = int(N//15) * 200
     
print(x-y)
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

Incorrect submission (verdict: Wrong Answer):
n,m=map(int,input().split())
sa=set()
sb=set()
for i in range(m):
  a,b=map(int,input().split())
  if a==1:sb.add(b)
  if b==1:sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")

Fixed, accepted submission:
n,m=map(int,input().split())
L1=set()
Ln=set()
for i in range(m):
  a,b=map(int,input().split())
  if a==1 or b==1:
    L1.add(a if b==1 else b)
  if a==n or b==n:
    Ln.add(a if b==n else b)
print('POSSIBLE' if len(L1&Ln)!=0 else 'IMPOSSIBLE')
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())
lis = [0 for i in range(4)]
mo = ["AC","WA","TLE","RE"]
for ii in range(n):
    i = input()
    if i=="AC":
        lis[0]+=1
    elif i=="WA":
        lis[1]+=1
    elif i=="TLE":
        lis[2]+=1
    elif i == "RE":
        lis[3]+=1

for i in range(4):
    print(str(mo[i])+" × "+str(lis[i]))


Fixed, accepted submission:
n = int(input())
lis = [0 for i in range(4)]
mo = ["AC","WA","TLE","RE"]
for ii in range(n):
    i = input()
    if i=="AC":
        lis[0]+=1
    elif i=="WA":
        lis[1]+=1
    elif i=="TLE":
        lis[2]+=1
    elif i == "RE":
        lis[3]+=1

for i in range(4):
    tmp = "{0} x {1}".format(mo[i],lis[i])
    print(tmp)
Problem:
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Incorrect submission (verdict: Wrong Answer):
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp


def binary_search(list_1, list_2):
    count = 0

    for b in list_2:
        left_index = 0
        right_index = len(list_1)
        
        while left_index < right_index:
            center = int((left_index + right_index) / 2)
            if list_1[center] == b:
                count += 1
                break
            elif b < list_1[center]:
                right_index = center
            elif b > list_1[center]:
                left_index = center + 1
                
    return count

if __name__ == "__main__":
    n_listA = int(input())
    a = list(set([n for n in input().split()]))
    n_listB = int(input())
    b = list(set([n for n in input().split()]))
    print(binary_search(a,b))

Fixed, accepted submission:
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp


def binary_search(list_1, list_2):
    count = 0

    for b in list_2:
        left_index = 0
        right_index = len(list_1)
        
        while left_index < right_index:
            center = int((left_index + right_index) / 2)
            if list_1[center] == b:
                count += 1
                break
            elif b < list_1[center]:
                right_index = center
            elif b > list_1[center]:
                left_index = center + 1
                
    return count

if __name__ == "__main__":
    n_listA = int(input())
    a = sorted(set([n for n in input().split()]))
    n_listB = int(input())
    b = set([n for n in input().split()])
    print(binary_search(a,b))
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
n, m, x, y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = max(a)+1
d = min(b)
e = 0

if c > d:
    print("War")
else:
    for i in range(c,d+1):
        if x < i and i <= y:
            print("No War")
            print(i)
            e = 1
            break
    if e == 0:
        print("War")

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

c = max(a)+1
d = min(b)
e = 0

if c > d:
    print("War")
else:
    for i in range(c,d+1):
        if x < i and i <= y:
            print("No War")
            e = 1
            break
    if e == 0:
        print("War")
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())
atoz=[]
for i in range(len(s)):
	if(s[i]=="A"):
		a=i
		break
#print(a)


for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)
#print(s_l)

r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	#print(i)
	if(i!="Z"):
		s_l.pop()
#		print(s_l)
	else:
		break
#	r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
print(str_s_l)

Fixed, accepted submission:

s=str(input())
atoz=[]
for i in range(len(s)):
	if(s[i]=="A"):
		a=i
		break
#print(a)


for i in range(a,len(s)):
	atoz.append(s[i])

s_l=list(atoz)
#print(s_l)

r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
	#print(i)
	if(i!="Z"):
		s_l.pop()
#		print(s_l)
	else:
		break
#	r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
#print(str_s_l)
print(len(str_s_l))
Problem:
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.  The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).  Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer.  If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.

Incorrect submission (verdict: Wrong Answer):
import math
n=int(input())
if (n+1)//1.08-n//1.08>0:
  print(n//1.08)
else:
  print(':(')

Fixed, accepted submission:
n=int(input())
for i in range(n+1):
  if int(1.08*i)==n:
    print(i)
    exit()
print(':(')
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())
if n%2==0:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j!=n+1:
                print(i,j)
else:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j!=n:
                print(i,j)


Fixed, accepted submission:
n=int(input())
ans=[]
if n%2==0:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j!=n+1:
                ans.append([i,j])
else:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j!=n:
                ans.append([i,j])
print(len(ans))
for i,j in ans:
    print(i,j)
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):
def create_List():
	re_list = [[],[],[],[]]
	for i in range(4):
		for j in range(3):
			re_list[i].append([0 for k in range(10)])
	return re_list


num = create_List()
for _ in range(int(input())):
	data = list(map(int,input().split()))
	num[data[0]-1][data[1]-1][data[2]-1] = data[3]

# ????????????
for i in range(4):
	for j in range(3):
		print(' '.join(map(str,num[i][j])))
	print('#'*20)

Fixed, accepted submission:
def create_List():
	re_list = [[],[],[],[]]
	for i in range(4):
		for j in range(3):
			re_list[i].append([0 for k in range(10)])
	return re_list


num = create_List()
for _ in range(int(input())):
	data = list(map(int,input().split()))
	num[data[0]-1][data[1]-1][data[2]-1] += data[3]

# ????????????
for i in range(4):
	for j in range(3):
		print(' ' + ' '.join(map(str,num[i][j])))
	if i == 3:
		break
	print('#'*20)
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())
for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y) > n or (x + y + t) % 2:
        print("NO")
        exit()
print("YES")

Fixed, accepted submission:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y) > t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")
Problem:
There are N people numbered 1 to N. Each person wears a red hat or a blue hat.  You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.  Determine if there are more people wearing a red hat than people wearing a blue hat.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
s=input()
count=0
for i in s:
  if i=='B':
    count+=1
if count>(n-count):
  print('Yes')
else:
  print('No')

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

Incorrect submission (verdict: Wrong Answer):
s = input()

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

one = -1
flg = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			if a + b*one**i + c*one**j + d*one**k == 7:
				print(i,j,k)
				flg = True
				break
		if flg:
			break
	if flg:
		break
                
if i == 0 :
	i_flg = "+"
else:
	i_flg = "-"

if j == 0 :
	j_flg = "+"
else:
	j_flg = "-"

if k == 0 :
	k_flg = "+"
else:
	k_flg = "-"

print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')

Fixed, accepted submission:
s = input()

a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

one = -1
flg = False

for i in range(2):
	for j in range(2):
		for k in range(2):
			if a + b*one**i + c*one**j + d*one**k == 7:
				flg = True
				break
		if flg:
			break
	if flg:
		break
                
if i == 0 :
	i_flg = "+"
else:
	i_flg = "-"

if j == 0 :
	j_flg = "+"
else:
	j_flg = "-"

if k == 0 :
	k_flg = "+"
else:
	k_flg = "-"

print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')
Problem:
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).  Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems.  A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
origin,ans = [],[]

for i in range(m):
	p,x = map(int,input().split())
	origin.append(t[p-1])
	t[p-1] = x
	ans.append(sum(t))
	t[p-1] = origin[0]
	origin = []
	
print(ans)

Fixed, accepted submission:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
origin,ans = [],[]

for _ in range(m):
	p,x = map(int,input().split())
	origin.append(t[p-1])
	t[p-1] = x
	ans.append(sum(t))
	t[p-1] = origin[0]
	origin = []

for i in range(m):
	print(ans[i])
Problem:
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?

Incorrect submission (verdict: Wrong Answer):
n, m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m) :
    a[i], b[i] = map(int, input().split())
loute = a + b
for i in range(n) :
    print(loute.count(i))

Fixed, accepted submission:
n, m = map(int, input().split())
a = [0] * m
b = [0] * m
for i in range(m) :
    a[i], b[i] = map(int, input().split())
loute = a + b
for i in range(n) :
    print(loute.count(i + 1))