TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.

Incorrect submission (verdict: Wrong Answer):
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


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


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b, c = inls()

print(a[0] + b[0]+c[0])

Fixed, accepted submission:
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


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


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b, c = inls()

print((a[0] + b[0]+c[0]).upper())
Problem:
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.  Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.

Incorrect submission (verdict: Wrong Answer):
def isprime(n):
    if n < 2: return 0
    elif n == 2: return 1

    if n % 2 == 0: return 0

    for i in range(3, n, 2):
        if n % i == 0 : return 0

    return 1

n = str([isprime(int(i)) for i in input().split()].count(1))
print(n)


Fixed, accepted submission:
def isprime(n):
    if n < 2: return 0
    elif n == 2: return 1

    if n % 2 == 0: return 0

    for i in range(3, n, 2):
        if i > n/i: return 1
        if n % i == 0 : return 0

    return 1

N = int(input())
n = [int(input()) for i in range(N)]

a = [i for i in n if isprime(i)]

print(len(a))
Problem:
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".

Incorrect submission (verdict: Wrong Answer):
a, b, c = [int(i) for i in input().split()]

if a > b:
    if b > c:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Fixed, accepted submission:
a, b, c = [int(i) for i in input().split()]

if a < b:
    if b < c:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Problem:
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.

Incorrect submission (verdict: Wrong Answer):
s = input()
if len(s) == 2:
    s = s[::-1]
print(s)

Fixed, accepted submission:
s = input()
if len(s) == 3:
    s = s[::-1]
print(s)
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()

capacity = 0
f_capacity = 0

for c in s:
    if c == 'a':
        if capacity < a+b:
            capacity += 1
            print('YES')
        else:
            print('NO')
    elif c == 'b':
        if capacity < a+b and f_capacity < b:
            capacity += 1
            f_capacity += 1
            print('YES')
        else:
            print('NO')
    else:
        print('NO')

Fixed, accepted submission:
n, A, B = map(int, input().split())
s = input()

ab = 0
f = 0

for t in s:
    if t == "a":
        if ab < A + B:
            print("Yes")
            ab += 1
        else:
            print("No")
    elif t == "b":
        if ab < A + B and f < B:
            print("Yes")
            ab += 1
            f += 1
        else:
            print("No")
    else:
        print("No")
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):
sum([a for a in range(1,int(input())+1)])

Fixed, accepted submission:
n = int(input())
print(sum([a for a in range(1,n+1)]))
Problem:
There is a game that involves three variables, denoted A, B, and C.  As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other.  After each choice, none of A, B, and C should be negative.  Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.

Incorrect submission (verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
S = [input().strip("\n").replace("A", "0").replace("B", "1").replace("C", "2") for _ in range(N)]
Ans = [None] * N

def search(i, num):
    if i == N - 1:
        if num[int(S[N-1][0])] > 0: 
            Ans[N-1] = S[N-1][0]
            return True
        elif num[int(S[N-1][1])] > 0: 
            Ans[N-1] = S[N-1][1]
            return True
        else: return False
    f = S[i][0]
    s = S[i][1]
    num[int(f)] += 1
    num[int(s)] -= 1
    if num[int(s)] >= 0:
        if search(i+1, num):
            Ans[i] = f
            return True
    num[int(f)] -= 2
    num[int(s)] += 2
    if num[int(f)] >= 0:
        if search(i+1, num):
            Ans[i] = s
            return True
    num[int(f)] += 1
    num[int(s)] -= 1
    return False

def solve():
    if search(0, [A, B, C]):
        print("Yes")
        for i, a in enumerate(Ans):
            if a == 0: print("A")
            elif a == 1: print("B")
            else: print("C")
    else: print("No")

    return 0

if __name__ == "__main__":
    solve()

Fixed, accepted submission:
import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
S = [input().strip("\n").replace("A", "0").replace("B", "1").replace("C", "2") for _ in range(N)]
Ans = [None] * N

def search(i, num):
    if i == N:
        if min(num) >= 0: return True
        else: return False
    if min(num) < 0: return False
    L = [num[0], num[1], num[2]]
    f = S[i][0]
    s = S[i][1]
    L[int(f)] += 1
    L[int(s)] -= 1
    if search(i+1, L):
        Ans[i] = f
        return True
    L[int(f)] -= 2
    L[int(s)] += 2
    if search(i+1, L):
        Ans[i] = s
        return True
    return False

def solve():
    if search(0, [A, B, C]):
        print("Yes")
        for i, a in enumerate(Ans):
            if a == "0": print("A")
            elif a == "1": print("B")
            else: print("C")
    else: print("No")
    #print(Ans)

    return 0

if __name__ == "__main__":
    solve()
Problem:
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?

Incorrect submission (verdict: Wrong Answer):
#!/user/bin/env python3
# -*- conding: utf-8 -*-


def ans(a, b, c):
    aa = a * a
    bb = b * b
    cc = c * c

    if aa + bb < cc:
        return 'Yes'
    else:
        return 'No'


def main():
    a, b, c = map(int, input().split())

    print(ans(a, b, c))


if __name__ == '__main__':
    main()

Fixed, accepted submission:
#!/user/bin/env python3
# -*- conding: utf-8 -*-

import math

def ans(a, b, c):
    rab = math.sqrt(a * b)
    

    if c - a - b <= 0:
        return 'No'
    elif (c - a - b) ** 2 > 4 * a * b:
        return 'Yes'
    else:
        return 'No'


def main():
    a, b, c = map(int, input().split())

    print(ans(a, b, c))


if __name__ == '__main__':
    main()
Problem:
取引先の顧客番号と取引日を月ごとに記録したデータがあります。今月のデータと先月のデータを読み込んで、先月から２ヶ月連続で取引のある会社の顧客番号と取引のあった回数を出力するプログラムを作成してください。ただし、月々の取引先数は 1,000 社以内です。

Incorrect submission (verdict: Wrong Answer):
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

table = [[False for i in range(32)] for j in range(1001)]
table2 = [[False for i in range(32)] for j in range(1001)]
C = [False for i in range(1001)]
C2 = [False for i in range(1001)]

while True:
    N = input()
    if len(N) <= 1:
        break
    c,d = [int(i) for i in N.split(",")]
    table[c][d] = True
    print(c,d)
    C[c] = True

M = list(get_input())
for l in range(len(M)):
    c,d = [int(i) for i in M[l].split(",")]
    table2[c][d] = True
    print(c,d)
    C2[c] = True

for i in range(1001):
    if C[i] and C2[i]:
        cnt = 0
        for j in range(32):
            if table[i][j]:
                cnt += 1
            if table2[i][j]:
                cnt += 1
        print(i,cnt)



Fixed, accepted submission:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break


table = [[False for i in range(32)] for j in range(1001)]
table2 = [[False for i in range(32)] for j in range(1001)]
C = [False for i in range(1001)]
C2 = [False for i in range(1001)]

while True:
    N = input()
    if len(N) <= 1:
        break
    c, d = [int(i) for i in N.split(",")]
    table[c][d] = True
    C[c] = True

M = list(get_input())
for l in range(len(M)):
    c, d = [int(i) for i in M[l].split(",")]
    table2[c][d] = True
    C2[c] = True

for i in range(1001):
    if C[i] and C2[i]:
        cnt = 0
        for j in range(32):
            if table[i][j]:
                cnt += 1
            if table2[i][j]:
                cnt += 1
        print(i, cnt)
Problem:
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors.  Find the number of the possible ways to paint the balls.

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

Fixed, accepted submission:
a, b = map(int, input().split())
print(b*(b-1)**(a-1))
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):
from decimal import *
a,b,x = map(int,input().split())
print((Decimal(b//x)-Decimal((a-1)/x)))

Fixed, accepted submission:
a,b,x = map(int,input().split())
print((int(b//x)-int((a-1)//x)))
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())
count = list()
for b in range(4):
    count.append(list())
    for f in range(3):
        count[b].append(list())
        for r in range(10):
            count[b][f].append(0)
            # count[b][f][r] = 0

read = 0
while read < n:
    b,f,r,v = [int(x) for x in input().split(" ")]
    count[b-1][f-1][r-1] = v
    read += 1

for b in range(4):
    for f in range(3):
        for r in range(10):
            print("", count[b][f][r], end="")
        print()
    print("####################")
    

Fixed, accepted submission:
n = int(input())
count = list()
for b in range(4):
    count.append(list())
    for f in range(3):
        count[b].append(list())
        for r in range(10):
            count[b][f].append(0)

read = 0
while read < n:
    b,f,r,v = [int(x) for x in input().split(" ")]
    count[b-1][f-1][r-1] += v
    read += 1

for b in range(len(count)):
    for f in range(len(count[b])):
        for r in range(len(count[b][f])):
            print("", count[b][f][r], end="")
        print()
    if b < len(count) - 1:
        print("####################")
Problem:
Given is a positive integer L. Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.

Incorrect submission (verdict: Wrong Answer):
L=int(input())
ans=0
if L%3==0:
    print((L/3)**3)
else:
    print(((L-1)/2)**2)


Fixed, accepted submission:
L=int(input())
print("{:.12f}".format(L**3/27))
Problem:
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`.  Consider doing the following operation:    * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.  You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Incorrect submission (verdict: Wrong Answer):
import itertools
import numpy as np

H,W,K=map(int,input().split())
m=[]
for i in range(H):
    m.append(list(input()))
print(m)
ans=0
for i in range(2**H):
     for j in range(2**W):
            i_s=format(i, "0{0}b".format(H))
            j_s=format(j, "0{0}b".format(W))
            M=[[[] for _ in range(W)] for _ in range(H)]
            for h in range(H):
                for w in range(W):
                    if i_s[h]=="1" or j_s[w]=="1":
                        M[h][w]="$"
                    else:
                        M[h][w]=m[h][w]
            M_1=list(itertools.chain.from_iterable(M))
            if M_1.count("#")==K:
                ans+=1
            
print(ans)

Fixed, accepted submission:
import itertools
import numpy as np

H,W,K=map(int,input().split())
m=[]
for i in range(H):
    m.append(list(input()))

ans=0
for i in range(2**H):
     for j in range(2**W):
            i_s=format(i, "0{0}b".format(H))
            j_s=format(j, "0{0}b".format(W))
            M=[[[] for _ in range(W)] for _ in range(H)]
            for h in range(H):
                for w in range(W):
                    if i_s[h]=="1" or j_s[w]=="1":
                        M[h][w]="$"
                    else:
                        M[h][w]=m[h][w]
            M_1=list(itertools.chain.from_iterable(M))
            if M_1.count("#")==K:
                ans+=1
            
print(ans)
Problem:
Snuke is giving cookies to his three goats.  He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).  Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('possible')
else:
    print('Impossible')

Fixed, accepted submission:
a, b = map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')
Problem:
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Incorrect submission (verdict: Wrong Answer):
#many medians
n=int(input())
B=list(map(int,input().split()))
C=B.copy()
B=sorted(B)
median1=B[n//2]
median2=B[n//2-1]
if median1==median2:
    for _ in range(n):
        print(median1)
elif median1<median2:
    for i in range(n):
        if i>=n//2:
            print(median1)
        elif i<n//2:
            print(median2)


Fixed, accepted submission:
#many medians
n=int(input())
B=list(map(int,input().split()))
C=B.copy()
B=sorted(B)
median1=B[n//2]
median2=B[n//2-1]
if median1==median2:
    for _ in range(n):
        print(median1)
elif median1>median2:
    for i in range(n):
        if C[i]>=median1:
            print(median2)
        else:
            print(median1)
Problem:
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`.  You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing.  The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.

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

L = {}
L[0] = -1 if S[0] == "W" else -1
for i in range(1,N):
    L[i] = L[i-1] - 1 if S[i] == "W" else L[i-1] + 1

R = {}
R[N-1] = -1 if S[N-1] == "W" else -1
for i in range(N-2, -1 , -1):
    R[i] = R[i+1] -1 if S[i] == "W" else R[i+1] + 1   

#print(L)
#print(R)

ans_key = 0
for i in range(N-1):
    if L[i] - R[i + 1] >= ans_key:
        ans_key = i
if L[N-1] > ans_key:
    ans_key = L[N-1]
elif R[0] > ans_key:
    ans_key = R[0]

ans = 0
l_num = (ans_key - (-1 * L[ans_key-1]) if L[i-1] < 0 else 0) //2 + (-1 * L[ans_key-1]) if L[i-1] < 0 else 0
r_num = ((N - ans_key -1 +  R[ans_key + 1] if  R[ans_key + 1] > 0 else 0 )) // 2  + R[ans_key + 1] if  R[ans_key + 1] > 0 else 0 

#print(ans_key)
print(l_num + r_num)


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

L_count = {}
L_count[0] = 0
for i in range(1,N):
    if S[i-1] == "W":
        L_count[i] = L_count[i-1] + 1
    else:
        L_count[i] = L_count[i-1]

R_count = {}
R_count[N-1] = 0
for i in range(N-2,-1,-1):
    if S[i+1] == "E":
        R_count[i] = R_count[i+1] + 1
    else:
        R_count[i] = R_count[i+1]

leader_i = 0
turn_num = N+1

for i in range(N):
    #print(L_count[i] + R_count[i],"i is",i,"leader_i is",leader_i)
    if L_count[i] + R_count[i] < turn_num:
        leader_i = i
        turn_num = L_count[i] + R_count[i]


R_sort = sorted(R_count.items(), key=lambda x: x[0])
#print(L_count)
#print(R_sort)
#print(leader_i)
print(L_count[leader_i] + R_count[leader_i])
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

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

chk = [0]*N
print(N, A)

A.reverse()
for i, a in enumerate(A):
    print('i', i)
    sum_chk = sum(chk[N-i-1::N-i])
    if sum_chk == a-1:
        chk[N-i-1] = 1
        continue
    elif sum_chk == a:
        continue
    else:
        print(-1)
        exit()

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Fixed, accepted submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if i+1 <= N//2:
        if a:
            chk[N-i-1] = 1
    else:
        sum_chk = sum(chk[N-i-1::N-i])
        s2 = sum_chk%2
        if a:
            if s2 == 0:
                chk[N-i-1] = 1
        else:
            if s2 == 1:
                chk[N-i-1] = 1

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)
Problem:
There is a hotel with the following accommodation fee:    * X yen (the currency of Japan) per night, for the first K nights   * Y yen per night, for the (K+1)-th and subsequent nights  Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.

Incorrect submission (verdict: Wrong Answer):
n, k, x, y = map(int, open(0).read().split())
ans = 0
while n < 0:
    if n <= k:
        ans += x
    else:
        ans += y
    n -= 1
else:
    print(ans)

Fixed, accepted submission:
n, k, x, y = [int(input()) for _ in range(4)]
ans = 0
while n:
    if n <= k:
        ans += x
    else:
        ans += y
    n -= 1
else:
    print(ans)