TnT/CodeNet4Repair huggingface dataset:
Problem:
There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
print(a)
total = 0
for i in range(n):
    if a[a[i] - 1] == i + 1:
        total += 1
print(total // 2)


Fixed, accepted submission:
n = int(input())
a = list(map(int, input().split()))
total = 0
for i in range(n):
    if a[a[i] - 1] == i + 1:
        total += 1
print(total // 2)
Problem:
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.  At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:    * Choose a (connected) rope with a total length of at least L, then untie one of its knots.  Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.

Incorrect submission (verdict: Wrong Answer):
n,l=map(int, input().split())
a=list(map(int, input().split()))
ans=-1
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        ans=i+1
        break
if ans==-1:print('Impossible')
else:
    for i in range(1,n):
        if i!=ans:print(i)
    print(ans)

Fixed, accepted submission:
n,l=map(int, input().split())
a=list(map(int, input().split()))
ans=-1
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        ans=i+1
        break
if ans==-1:print('Impossible')
else:
    print('Possible')
    for i in range(1,ans):print(i)
    for i in range(n-1,i,-1):print(i)
Problem:
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.  Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.  For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:    * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.   * For every i, B_i \leq C_i holds.  If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.

Incorrect submission (verdict: Wrong Answer):


import numpy
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]

diff = [0 for x in range(N)]

for i in range(N):
    diff[i] = A[i] - B[i]

if (sum(diff) < 0):
    print (-1)
else:
    shakkin = 0
    ans = 0
    for d in diff:
        if d < 0:
            shakkin += d
            ans += 1
    for d in sorted(diff, reverse=True):
        if shakkin >= 0:
            break
        print("diff: %s", d)
        ans += 1
        shakkin += d
        if shakkin >= 0:
            break
    print(ans)

Fixed, accepted submission:


import numpy
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]

diff = [0 for x in range(N)]

for i in range(N):
    diff[i] = A[i] - B[i]

if (sum(diff) < 0):
    print (-1)
else:
    point = 0
    ans = 0
    for d in diff:
        if d < 0:
            point += d
            ans += 1
    for d in sorted(diff, reverse=True):
        if point >= 0:
            break
        ans += 1
        point += d
    print(ans)
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):

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

    print((b//x+1) - (a//x+1))

main()

Fixed, accepted submission:
def main():
    a, b, x = map(int,input().split())
    re_b = (b//x)+1
    if a-1 != -1:
        re_a = ((a-1)//x)+1
        print(re_b - re_a)
    else:
        print(re_b)
main()
Problem:
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.  Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s.  Given the name of the contest, print the abbreviation of the name.

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


Fixed, accepted submission:
s = input()
print('A'+s[8]+'C')
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())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

max_x = max(x)
max_y = max(y)
#print(max_x)
#print(max_y)
#print(Y-X)

XY_list = []
xy_list = []
for i in range(X+1, Y+1):
    XY_list.append(i)

if max_x + 1  >= max_y:
    print("War")
    exit()

for i in range(max_x, max_y+1):
    xy_list.append(i)

#print(XY_list)
#print(xy_list)
set_XY = set(XY_list)
set_xy = set(xy_list)

print("No War" if set_XY in set_xy else "War")




Fixed, accepted submission:
N, M , X ,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

max_x = max(x)
max_y = max(y)
min_y = min(y)
#print(max_x)
#print(max_y)
#print(Y-X)

XY_list = []
xy_list = []
for i in range(X+1, Y+1):
    XY_list.append(i)

if max_x   >= min_y:
    print("War")
    exit()

for i in range(max_x +1, min_y+1):
    xy_list.append(i)

#print(XY_list)
#print(xy_list)
set_XY = set(XY_list)
set_xy = set(xy_list)

print("No War" if set_XY & set_xy else "War")
Problem:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
sSorted = sorted(input())

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

  

Fixed, accepted submission:
sSorted = sorted(input())
if ''.join(sSorted) =="abc":
  print("Yes")
else:
  print("No")
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):
#96
A,B,C = map(int,input().split())
ans= ((A+B)>=C)
if ans:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
#96
A,B,C = map(int,input().split())
ans= ((A+B)>=C)
if ans:
    print("Yes")
else:
    print("No")
Problem:
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.  Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.  For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:    * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.   * For every i, B_i \leq C_i holds.  If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.

Incorrect submission (verdict: Wrong Answer):
i = input()
n = int(i)
a = list(map(int, i.split()))
b = list(map(int, i.split()))
if sum(a) < sum(b):
  print(-1)
  exit()
  
c = [x-y for x,y in zip(a,b)]
p = [i for i in c if i > 0]
m = [i for i in c if i < 0]

f = sum(m)
l = len(m)
for k in sorted(p, reverse=True):
  if f >= 0:
    break
  f += k
  l += 1
print(l)

Fixed, accepted submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) < sum(b):
  print(-1)
  exit()
  
c = [x-y for x,y in zip(a,b)]
p = [z for z in c if z > 0]
m = [z for z in c if z < 0]

f = sum(m)
l = len(m)
for k in sorted(p, reverse=True):
  if f >= 0:
    break
  f += k
  l += 1
print(l)
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):
a,b = list(map(int,input().split(" ")))
s = input()
postal_code_len = a+b+1

num_list = list(map(str, range(0,10)))

flag = True
print([c in num_list for c in list(s[:a]+s[a+1:]) ])
if s[a] == "-" and all([ c in num_list for c in list(s[:a]+s[a+1:]) ]):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b = list(map(int,input().split(" ")))
s = input()
postal_code_len = a+b+1

num_list = list(map(str, range(0,10)))

flag = True
#print([c in num_list for c in list(s[:a]+s[a+1:]) ])
if s[a] == "-" and all([ c in num_list for c in list(s[:a]+s[a+1:]) ]):
    print("Yes")
else:
    print("No")
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):
a,b,c = map(str,input().split())

aa = list(a)
bb = list(b)
cc = list(c)

abc = aa[0] + bb[0] + cc[0]
abc.capitalize()
print(abc)

Fixed, accepted submission:
a,b,c = map(str,input().split())
 
aa = list(a)
bb = list(b)
cc = list(c)
 
abc = aa[0] + bb[0] + cc[0]
abc.upper()
print(abc.upper())
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

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

if a > x:
    print("No")
elif b < x-a:
    print("No")
else:
    print("Yes")


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

if a > x:
    print("NO")
elif b < x-a:
    print("NO")
else:
    print("YES")
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
import math

n, k = map(int, input().split())
if math.ceil(n / 2) >= k:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
import math

n, k = map(int, input().split())
if math.ceil(n / 2) >= k:
    print('YES')
else:
    print('NO')
Problem:
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.  Given an integer N, determine whether it is a Harshad number.

Incorrect submission (verdict: Wrong Answer):
def f(X):
	total = 0
	while X > 0:
		total += X % 10
		X /= 10
	return total

N = int(input())

if N / f(N) == 0:
	print("Yes")
else:
	print("No")


Fixed, accepted submission:
def f(X):
	total = 0
	while X > 0:
		total += X % 10
		X = X // 10
	return total

N = int(input())

if N % f(N) == 0:
	print("Yes")
else:
	print("No")
Problem:
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
s=list(input())
k=int(input())
t=s[k-1]
print(t)
for i in range(len(s)):
    if s[i]!=t:
        s[i]="*"
print("".join(s))

Fixed, accepted submission:
n=int(input())
s=list(input())
k=int(input())
l=s[k-1]
for i in range(n):
  if s[i]!=l:
    s[i]="*"
print("".join(s))
Problem:
Write a program which reads two integers a and b, and calculates the following values:    * a ÷ b: d (in integer)   * remainder of a ÷ b: r (in integer)   * a ÷ b: f (in real number)

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

Fixed, accepted submission:
a,b = map(int, input().split())
print('{0} {1} {2:.5f}'.format(a // b, a % b, a / b))
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):
import copy
a,b = map(int, input().split())
s = list(input())
tmp = copy.copy(s)
tmp.pop(a)
if 1 <= a and b <= 5 and a + b + 1 == len(s) and s[a] == '-' and 'tmp'.join(tmp).isnumeric():
    print('yes')
else:
    print('No')
    
    

Fixed, accepted submission:
a,b = map(int, input().split())
s = input()
print('Yes' if s[a] == '-' and (s[:a] + s[a + 1:]).isdigit() else 'No')
Problem:
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T  T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.

Incorrect submission (verdict: Wrong Answer):
W = input()
print(W)
t=0

while(1):
	char_list = list(x for x in input().split())
	print(char_list)
	if char_list[0] == 'END_OF_TEXT':
		break
	
	for i in range(len(char_list)):
		if W == char_list[i]:
			t += 1

print(t)

Fixed, accepted submission:
W = input().lower()
#print(W)
t=0

while(1):
	char_list = list(x for x in input().split())
	#print(char_list)
	if char_list[0] == 'END_OF_TEXT':
		break
	
	for i in range(len(char_list)):
		if W == char_list[i].lower():
			t += 1

print(t)
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):
n = int(input())
S = input().strip()

print(max(len(set(S[i+1:]) & set(S[:i])) for i in range(n)))

Fixed, accepted submission:
n = int(input())
S = input().strip()
print(max(len(set(S[:i+1]) & set(S[i+1:])) for i in range(n-1)))
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):
s = list(map(str,input().split()))
print(s[0][0]+s[1][0]+s[2][0])

Fixed, accepted submission:
s = list(map(str,input().split()))
print((s[0][0]+s[1][0]+s[2][0]).upper())
Problem:
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up.  We will perform the following operation once for each square contains a card:    * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.  It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.

Incorrect submission (verdict: Wrong Answer):
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M > 1:
    print(M-2)
elif M == 1 and N > 1:
    print(N-2)
elif N > 1 and M > 2:
    print((N-2)*(M-2))

Fixed, accepted submission:
N,M= map(int,input().split())
print(abs((N-2)*(M-2)))
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
abc = [int(i) for i in input().split()]
if abc[0] == abc[1]:
    print(abc[0])
else:
    print((set(abc[:2]) & set([abc[2]])).pop())

Fixed, accepted submission:
abc = [int(i) for i in input().split()]
if abc[0] == abc[1]:
    print(abc[2])
else:
    print((set(abc[:2]) - (set(abc[:2]) & set([abc[2]]))).pop())
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

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

print("voewl" if c in ["a", "b", "c", "d", "e"] else "consonant")

Fixed, accepted submission:
c = input()

print("vowel" if c in ["a", "i", "u", "e", "o"] else "consonant")
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

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

ss = "".join(sorted(s))
tt = "".join(sorted(t))

if ss<tt:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
s = list(input())
t = list(input())

ss = "".join(sorted(s))
tt = "".join(sorted(t, reverse=True))

if ss<tt:
    print("Yes")
else:
    print("No")
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
xab = list(map(int, input().split()))
if xab[2] <= xab[1]:
    print('delicious')
elif xab[1] < xab[2] <= xab[0]:
    print('safe')
else:
    print('dangerou')

Fixed, accepted submission:
xab = list(map(int, input().split()))
if xab[2] <= xab[1]:
    print('delicious')
elif xab[1] < xab[2] <= xab[0]+xab[1]:
    print('safe')
else:
    print('dangerous')
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 = int(input())
k = int(input())
x = int(input())
y = int(input())
print(min(n,k)*x + min(n-k,0)*y)

Fixed, accepted submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(min(n,k)*x + max(n-k,0)*y)
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):
a, b, x = map(int, input().split())

if x == a:
    print((b - a + 1) // x + 1)
else:
    print((b - a + 1) // x)


Fixed, accepted submission:
a, b, x = map(int, input().split())
print(b//x - (a - 1)//x)
Problem:
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up.  We will perform the following operation once for each square contains a card:    * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.  It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.

Incorrect submission (verdict: Wrong Answer):
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    print(max(1, N-2) * max(1, M-2))


if __name__ == '__main__':
    main()


Fixed, accepted submission:
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    if N == 2 or M == 2:
        print(0)
    else:
        print(max(1, N-2) * max(1, M-2))


if __name__ == '__main__':
    main()
Problem:
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

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

s=0

for i in range(n):
    x,u=map(str,input().split())
    if u == "JPY":
        s+=int(x)
    elif u == "BTC":
        s+=380000*float(x)
    else:
        s+=0
print(int(s))


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

s=0

for i in range(n):
    x,u=map(str,input().split())
    if u == "JPY":
        s+=int(x)
    elif u == "BTC":
        s+=380000*float(x)
    else:
        s+=0
print(s)
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):
# -*- coding: utf-8 -*-
a,b,c = list(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<=c and b>=c:
    print("Yes")
else:
    print("No")
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

Incorrect submission (verdict: Wrong Answer):
n, a = [int(input(i)) for i in range(2)]
if n % 500 <= a:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
n = int(input())
a = int(input())
if n % 500 <= a:
    print('Yes')
else:
    print('No')