TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Incorrect submission (verdict: Wrong Answer):
ret = input()
count_max = 0
for i in range(1, len(ret)):
  count = 0
  for k in range(97, 123):
    if ((chr(k) in ret[:i]) & (chr(k) in ret[i:])):
      count += 1
  if count > count_max:
    count_max = count
print(count_max)

Fixed, accepted submission:
len = int(input())
ret = input()
count_max = 0
for i in range(1, len):
  count = 0
  for k in range(97, 123):
    if ((chr(k) in ret[:i]) and (chr(k) in ret[i:])):
      count += 1
  if count > count_max:
    count_max = count
print(count_max)
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):
import sys
import numpy as np

A,B,C = list(map(int, input().split()))
K = int(input())


for i in range(K):
    if A > B:
        B = B*2
    elif B > C:
        C = C*2

if A < B and B < C:
    print('yes')
else:
    print('no')


Fixed, accepted submission:
import sys
import numpy as np

A,B,C = list(map(int, input().split()))
K = int(input())


for i in range(K):
    if A >= B:
        B = B*2
    elif B >= C:
        C = C*2

if A < B and B < C:
    print('Yes')
else:
    print('No')
Problem:
An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina".  Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
for i in range(n):
  l = [s for s in input().split()]
  for s in l:
    if s == 'Hoshino':
      l[l.index(s)] = 'Hoshina'
  a = ''
  for s in l:
    a += s
    a += ' '
  a.rstrip()
  print(a)

Fixed, accepted submission:
n = int(input())
for i in range(n):
  a = input()
  a = a.replace('Hoshino','Hoshina')
  print(a)
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):
import bisect

n=int(input())
a=[0]+sorted(list(map(int,input().split())))+[10**9]

ans1=a[-2]

index=bisect.bisect_right(a,(ans1)//2)

b1=a[index-1]
b2=a[index]

if abs((ans1)/2-b1)<abs((ans1)/2-b2):ans2=b1
else:ans2=b2

print(a)
print(b1,b2)
print(index)

print(ans1,ans2,sep=" ")

Fixed, accepted submission:
import bisect

n=int(input())
a=[0]+sorted(list(map(int,input().split())))+[10**9]

ans1=a[-2]

index=bisect.bisect_right(a,(ans1)//2)

b1=a[index-1]
b2=a[index]

if abs((ans1)/2-b1)<=abs((ans1)/2-b2):ans2=b1
else:ans2=b2

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

Incorrect submission (verdict: Wrong Answer):
s = input().replace("eracer", "").replace("erace","").replace("dream","").replace("dreamer","")
if s:
    print("NO")
else:
    print("YES")

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

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

S = S[::-1]

word_list1 = "dream"
word_list2 = "dreamer"
word_list3 = "erase"
word_list4 = "eraser"

s = ""
ans = ""

word_list = [word_list1[::-1],word_list2[::-1],word_list3[::-1],word_list4[::-1]]

for i in S:
    s += i
    if s in word_list:
        ans += s
        s = ""

if S == ans:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
import re

S = input()

if re.match('(dream|dreamer|erase|eraser)+$', S):
    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):
n = int(input())

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

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

for i in range(n):
    b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] = a[i][3]

for i in range(4):
    for j in range(3):
        b[i][j].insert(0, "")
        print(*b[i][j])
    print("####################")
    

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

a = []
for i in range(n):
    a.append(list(map(int, input().split())))

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

for i in range(n):
    b[a[i][0] - 1][a[i][1] - 1][a[i][2] - 1] += a[i][3]

for i in range(4):
    for j in range(3):
        b[i][j].insert(0, "")
        print(*b[i][j])
    if i == 3:
        break
    print("####################")
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Wrong Answer):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
def f(x, y, z):
    return x**2 + y**2 + z **2 + x * y + y * z + z * x

L = [0] * (N + 1)
for x in range(1, N+1):
    for y in range(1, N + 1):
        for z in range(1, N + 1):
            if f(x,y,z) < N:
                L[f(x, y, z)] += 1
print(*L, sep="\n")





Fixed, accepted submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
def f(x, y, z):
    return x**2 + y**2 + z **2 + x * y + y * z + z * x

L = [0] * (N + 1)
thre =  ceil(sqrt(N)) + 1
# print(thre)
for x in range(1, thre+1):
    for y in range(1, thre + 1):
        for z in range(1, thre + 1):
            if f(x,y,z) <= N:
                L[f(x, y, z)] += 1
print(*L[1:], sep="\n")
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(0)
    exit()
else:
    print(1000-a)
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
n, l = map(int, input().split())
s_list = sorted([input() for i in range(n)])
mojiretu = ','.join(s_list)
print(mojiretu)

Fixed, accepted submission:
n, l = map(int, input().split())
s_list = sorted([input() for i in range(n)])
mojiretu = ''.join(s_list)
print(mojiretu)
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
s = input()
sr = s[::-1]
w = ["maerd","remaerd","esare","resare"]
for i in range(4):
    sr = sr.replace(w[i],"")
if sr == "":print("Yes")
else:print("No")


Fixed, accepted submission:
s = input()
sr = s[::-1]
w = ["resare","esare","remaerd","maerd"]
for i in range(4):
    sr = sr.replace(w[i],"")
if sr == "":print("YES")
else:print("NO")
Problem:
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.  Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.  Find the inversion number of B, modulo 10^9 + 7.  Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.

Incorrect submission (verdict: Wrong Answer):
def main(n,k,a):

    mod = 10**9 + 7
    t1, t2 = 0, 0
    for i in range(n):
        for j in range(n):
            if a[i] > a[j]:
                t1 += 1
        for j in range(n - i):
            if a[i] > a[j + i]:
                t2 += 1
        count = t1 * k * (k - 1) / 2 % mod
        count += t2 * k % mod

    print(t1, t2)

    print(int(count % mod))


if __name__ == '__main__':
    n,k = map(int, input().split(' '))
    a = list(map(int, input().split(' ')))
    main(n,k,a)


Fixed, accepted submission:
def main(n,k,a):

    mod = 10**9 + 7
    t1, t2 = 0, 0
    for i in range(n):
        for j in range(n):
            if a[i] > a[j]:
                t1 += 1
        for j in range(n - i - 1):
            if a[i] > a[j + i + 1]:
                t2 += 1

    count = (t1 * ((k * (k - 1)) // 2)) % mod
    count += (t2 * k) % mod
    print(int(count % mod))


if __name__ == '__main__':
    n, k = map(int, input().split(' '))
    a = list(map(int, input().split(' ')))
    main(n,k,a)
Problem:
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.  Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.  Find the duration of time when some song was played while Niwango was asleep.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
S=[]
T=[]
for i in range(N):
  s,t=input().split()
  S.append(str(s))
  T.append(int(t))
X=str(input())

triger=0
j=0
A=0
for i in S:
  if i==X:
    triger=1
  if triger==1:
    A+=T[j]
  j+=1
print(A)

Fixed, accepted submission:
N=int(input())
S=[]
T=[]
for i in range(N):
  s,t=input().split()
  S.append(str(s))
  T.append(int(t))
X=str(input())

triger=0
j=0
A=0
for i in S:
  if triger==1:
    A+=T[j]
  if i==X:
    triger=1
  j+=1
print(A)
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):
N,M=map(int,input().split())
AB=[]
for i in range(M):
	a,b=map(int,input().split())
	AB.append([a,b])
AB=list(map(list, set(map(tuple, AB))))

ROOP=[[] for i in range(N+1)]


for i in range(2,N+1):
	for ab in AB:
		if i ==ab[0]:
			ROOP[i].append(ab[1])

		elif i==ab[1]:
			ROOP[i].append(ab[0])
	if 1 in ROOP[i]:
		GOAL_start=i


visited=[-1]*(N+1)
visited[GOAL_start]=1



def bfs(GOAL,GOAL_NEXT):
	if GOAL_NEXT in ROOP[GOAL]:
		ROOP[GOAL].remove(GOAL_NEXT)
	else:
		return 1
	for i in ROOP[GOAL]:
		if visited[i]==-1 or visited[i]>1+visited[GOAL]:
			visited[i]=1+visited[GOAL]
			bfs(i,GOAL)
		else:
			return 1
bfs(GOAL_start,1)

print(AB)
print(visited)
if -1 not in visited[2:]:
	print("Yes")
	for i in visited[2:]:
		print(i)
else:
	print("NO")

Fixed, accepted submission:
from collections import deque

N,M=map(int,input().split())

AB=[]
for i in range(M):
	AB.append(list(map(int,input().split())))

links=[[] for _ in range(N+1)]
results=[-1]*(N+1)

for a, b in AB:
    links[a].append(b)
    links[b].append(a)
q=deque([1])

while q:
	pos=q.popleft()
	for i in links[pos]:
		if results[i]==-1:
			results[i]=pos
			q.append(i)
print('Yes')
print('\n'.join(str(i) for i in results[2:]))
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):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    E = []
    
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if N % 2 == 0 and i+j == N+1:
                continue
            if N % 2 == 1 and i+j == N:
                continue
            E.append((i, j))

    return E


def main():
    N = read_int()
    for e in slv(N):
        print('%d %d' % e)


if __name__ == '__main__':
    main()


Fixed, accepted submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    se = N+1 if N % 2 == 0 else N
    return list(filter(lambda x: x[0]+x[1]!=se, combinations(range(1, N+1), 2)))


def main():
    N = read_int()
    E = slv(N)
    print(len(E))
    for e in E:
        print('%d %d' % e)


if __name__ == '__main__':
    main()
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
a,b,c,x = map(int,[input() for i in range(4)])
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if(100*a + 10*b + c == x):
                count += 1
print(count)

Fixed, accepted submission:
a,b,c,x = map(int,[input() for i in range(4)])
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if(500*i + 100*j + 50*k == x):
                count += 1
print(count)
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 = int(input())
A = input()
B = input()
C = input()
ans = 0

for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        continue
    elif A[i] != B[i] and B[i] != C[i]:
        ans += 2
    else:
        ans += 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] and B[i] == C[i]:
        continue
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        ans += 2
    else:
        ans += 1

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

Incorrect submission (verdict: Wrong Answer):
x,a,b=map(int, input().split())
if abs(x-a)>abs(x-b):
  print('A')
else:
  print('B')

Fixed, accepted submission:
x,a,b=map(int, input().split())
if abs(x-a)<abs(x-b):
  print('A')
else:
  print('B')
Problem:
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Incorrect submission (verdict: Wrong Answer):
x,y,d=map(int,input().split())
ans=y//d-x//d
if x==0:
  ans+=1
print(ans)

Fixed, accepted submission:
x,y,d=map(int,input().split())
ans=y//d-(x-1)//d
print(ans)
Problem:
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.

Incorrect submission (verdict: Wrong Answer):
S = input()
S.upper()


Fixed, accepted submission:
S = input()
S.swapcase()
print(S.swapcase())
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
print(sum([i for i in range(int(input()))]))

Fixed, accepted submission:
print(sum([i for i in range(int(input())+1)]))
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())
a, b = 1, 2
for i in range(n - 1):
    a, b = a + b, a
print(a)

Fixed, accepted submission:

a, b, c, d = map(int, tuple(input()))
print('Yes' if a == b == c or b == c == d else 'No')
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  l = [0]
  for j in range(n-1):
    if i << j & 2**(n-2):
      l.append(j+1)
  l.append(n)
  print(l)
  for j in range(len(l)-1):
    ans += int(s[l[j]:l[j+1]])
print(ans)

Fixed, accepted submission:
s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
  l = [0]
  for j in range(n-1):
    if i >> j & 1:
      l.append(j+1)
  l.append(n)
  for j in range(len(l)-1):
    ans += int(s[l[j]:l[j+1]])
print(ans)