TnT/CodeNet4Repair huggingface dataset:
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):
#!/usr/bin/env python3

import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    a=sys.stdin.readlines()
    #print(a)
    N,X=int(a[0]),a[-1]
    #print(N)
    slept=0
    ans=0
    for i in range(1,1+N):
        t,l=a[i].split()
        #print(t,l)
        
        if slept:ans+=int(l)
        if t==X:slept=1
    print(ans)
#%%submit!
resolve()

Fixed, accepted submission:
#!/usr/bin/env python3

import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    a=sys.stdin.readlines()
    #print(a)
    N,X=int(a[0].rstrip()),a[-1].rstrip()
    #print(N)
    slept=0
    ans=0
    for i in range(1,1+N):
        t,l=a[i].rstrip().split()
        #print(t,l)
        
        if slept:ans+=int(l)
        if t==X:slept=1
    print(ans)
#%%submit!
resolve()
Problem:
Snuke has N dogs and M monkeys. He wants them to line up in a row.  As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.  How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.

Incorrect submission (verdict: Wrong Answer):
N, M = [int(i) for i in input().split()]

L = abs(N - M)

if L >= 2:
    print(0)

Fixed, accepted submission:
import math
N, M = [int(i) for i in input().split()]
r = pow(10, 9) + 7
L = abs(N - M)

if L >= 2:
    print(0)
elif L == 0:
    E = 2*math.factorial(N)*math.factorial(M)
    print(E % r)
else:
    E = math.factorial(N)*math.factorial(M)
    print(E % r)
Problem:
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_.   Here, a correct bracket sequence is defined as follows:    * `()` is a correct bracket sequence.   * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence.   * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence.   * Every correct bracket sequence can be derived from the rules above.  Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
S = input()
T = []
for s in S:
  if s == "(":
    T.append(-1)
  else:
    T.append(1)
c = 0
U = ""
for i in range(N):
  c += T[i]
  if c > 0:
    U += "("
    c -= 1
  if T[i] == -1:
    U += "("
  else:
    U += ")"
print(U + ")"*(-c))

Fixed, accepted submission:
N = int(input())
S = input()
T = []
c = 0
m = 0
for s in S:
  if s == ")":
    c += 1
  else:
    if c > 0:
      m += c 
      c = 0
    c -= 1
  if c > 0:
    m += c 
    c = 0
print("("*m + S + ")"*(-c))
Problem:
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi.  How many ways are there to choose K consecutive integers?

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

print(N-K)

Fixed, accepted submission:
N, K = map(int, input().split())

print(N-K+1)
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

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

change = N%1000
print(change)

Fixed, accepted submission:
N = int(input())
change = ((N+1000-1)//1000)*1000-N

print(change)
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

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



if x ==1 or y ==1:
  print(1)
  exit(0)
if x%2==0 or y%2==0:
  print(x*y/2)
  exit(0)
print((x*y/2+1))


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



if x ==1 or y ==1:
  print(1)
  exit(0)
if x%2==0 or y%2==0:
  print(int(x/2*y))
  exit(0)
a=int(x*y/2)+1
print(a)
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):
from collections import Counter
n = int(input().strip())
L = [input().strip() for _ in range(n)]


cnt=Counter(L)
for x in ["AC", "WA", "TLE", "RE"]:
    print(x+" ×　"+str(cnt[x]))

Fixed, accepted submission:
from collections import Counter
n = int(input().strip())
L = [input().strip() for _ in range(n)]


cnt=Counter(L)
for x in ["AC", "WA", "TLE", "RE"]:
    print(x+" x "+str(cnt[x]))
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):
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 12 16:30:47 2017

@author: gedyra
"""

a,b = list(map(int, input().split()))

d = int(a/b)
r = a%b
f = float(a/b)

print(d, r, f)

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

d = a//b
r = a%b
f = ('{:.5f}'.format(a/b))

print(d, r, f)
Problem:
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`.  After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.

Incorrect submission (verdict: Wrong Answer):
print(input().replace("2018","2017"))

Fixed, accepted submission:
print(input().replace("2017","2018"))
Problem:
You are visiting a large electronics store to buy a refrigerator and a microwave.  The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen.  You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.  You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.

Incorrect submission (verdict: Wrong Answer):
A, B, M = [int(i) for i in input().split(" ")]

a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
C = []

for i in range(M):
  c = [int(i) for i in input().split(" ")]
  C.append(c)

print(a)

m = 1000000

for i in a:
  for j in b:
    cost = i + j
    if m >= cost:
      m = cost

for c in C:
  cost = a[c[0] - 1] + b[c[1] - 1] - c[2]
  if m >= cost:
    m = cost

print(m)

Fixed, accepted submission:
A, B, M = [int(i) for i in input().split(" ")]

a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
C = []

for i in range(M):
  c = [int(i) for i in input().split(" ")]
  C.append(c)

m = min(a) + min(b)

for c in C:
  cost = a[c[0] - 1] + b[c[1] - 1] - c[2]
  if m >= cost:
    m = cost

print(m)
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 = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        tmp = i * 500 + j * 100
        if (X - tmp) % 50 == 0 and tmp <= X:
            print(i, j)
            ans += 1
print(ans)


Fixed, accepted submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            ans += 1 * ((i * 500 + j * 100 + k * 50) == X)
print(ans)
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().rstrip())

print(n%1000)

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

print((1000-n)%1000)
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
a=input();print(int(a[0])-(a[0]>a[1]))

Fixed, accepted submission:
a,b=map(int,input().split())
print(a-(a>b))
Problem:
We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:    * Choose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.  Find the maximum possible number of i such that p_i = i after operations.

Incorrect submission (verdict: Wrong Answer):
n,m=map(int,input().split())
P=list(map(int,input().split()))
edges=[list(map(int,input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n+1)]
        self.rank=[0]*(n+1)

    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1
    def same_check(self,x,y):
        return self.find(x)==self.find(y)

uf=UnionFind(n)
ans=0
for i,j in edges:
    uf.union(i,j)
for i in range(n):
    if uf.same_check(i,P[i]):
        ans+=1
print(ans)

Fixed, accepted submission:
#ARC097-D
n,m=map(int,input().split())
P=list(map(int,input().split()))
edges=[list(map(int,input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n+1)]
        self.rank=[0]*(n+1)

    def find(self,x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def union(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1
    def same_check(self,x,y):
        return self.find(x)==self.find(y)

uf=UnionFind(n)
ans=0
for i,j in edges:
    uf.union(i,j)
for i in range(n):
    if uf.same_check(i+1,P[i]):
        ans+=1
print(ans)
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):
# coding: utf-8
# Your code here!
M=int(input())
B=list(map(int,input().split()))
l=[0]*M

for i in range(1,-int(-M**0.5//1)+1):
    print(i)
        
    
    

Fixed, accepted submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

count=0
ans=[]
hako=[0]*N
for i in range(N)[::-1]:
    all=0
    for j in range(i,N)[::i+1]:
        if i==j:
            continue
        all^=hako[j]
    if all==1:
        if A[i]==1:
            continue
        else:
            hako[i]=1
            count+=1
            ans.append(i+1)
    else:
        if A[i]==1:
            hako[i]=1
            count+=1
            ans.append(i+1)
        else:
            continue
ans.sort()
print(count)
print(*ans)
#print(hako)
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):
n = int(input())
ans = [0] * (n + 1)
for x in range(1, n):
    for y in range(1, n):
        for z in range(1, n):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
print(*ans, sep='\n')

Fixed, accepted submission:
n = int(input())
ans = [0] * (n + 1)
a = [1, 3, 6]
for x in range(1, int(n**0.5) + 1):
    for y in range(x, int(n**0.5) + 1):
        for z in range(y, int(n**0.5) + 1):
            v = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if v <= n:
                ans[v] += a[len(set([x, y, z])) - 1]
print(*ans[1:], sep='\n')
Problem:
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank.  The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.)  Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?

Incorrect submission (verdict: Wrong Answer):
import math

n = int(input())

cash = 100
count = 0

while n >= cash:
    cash = cash + math.floor(cash * 0.01)
    count += 1

print(count)


Fixed, accepted submission:
import math

n = int(input())

cash = 100
count = 0

while n > cash:
    cash = cash + math.floor(cash * 0.01)
    count += 1

print(count)
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):
n = int(input())
sum = 0
for _ in range(n):
    a = int(input())
    if a == 2:
        continue
    for i in range(a):
        x = i + 2
        if a%x == 0:
            sum += 1
            print(a)
            break
        if x > a ** 0.5:
            break
print(n - sum)


Fixed, accepted submission:
n = int(input())
sum = 0
for _ in range(n):
    a = int(input())
    if a == 2:
        continue
    for i in range(a):
        x = i + 2
        if a%x == 0:
            sum += 1
            break
        if x > a ** 0.5:
            break
print(n - sum)
Problem:
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b.  Determine whether the arrangement of the poles is beautiful.

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

Fixed, accepted submission:
a,b,c = map(int, input().split())
if (b - a == c - b):
    print("YES")
else:
    print("NO")
Problem:
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=list(input())
a_id=S.index("A")
z_id=list(reversed(S)).index("Z")
print(z_id - a_id +1)

Fixed, accepted submission:
S=list(input())
l =len(S)
a_id=S.index("A")
z_id=list(reversed(S)).index("Z")
print(l-z_id - a_id)
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):
ans = []
A, B, C = map(int, input().split())
ans.append(A)
ans.append(B)
ans.append(C)
if ans.count(5) == 2 and ans.count(7) == 1:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:
ans = []
A, B, C = map(int, input().split())
ans.append(A)
ans.append(B)
ans.append(C)
if ans.count(5) == 2 and ans.count(7) == 1:
    print('YES')
else:
    print('NO')
Problem:
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i.  You are now at town 1, and you want to visit all the other towns. You have two ways to travel:    * Walk on the line. Your _fatigue level_ increases by A each time you travel a distance of 1, regardless of direction.    * Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered.  Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.

Incorrect submission (verdict: Wrong Answer):
#coding: UTF-8
N, A, B=map(int, input().split())
lis=list(map(int,input().split()))
#print(lis)
out=0
for i in range(0,N-1):
    d=lis[i+1]-lis[i]
    if d < (B-A):
        out=out+d
    else:
        out=out+B
print(out)

Fixed, accepted submission:
#coding: UTF-8
N, A, B=map(int, input().split())
lis=list(map(int,input().split()))
#print(lis)
out=0
for i in range(0,N-1):
    d=(lis[i+1]-lis[i])*A
    if d < B:
        out=out+d
    else:
        out=out+B
print(out)
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())

bs = [input().split() for _ in range(n)]

ans = 0
for b in bs:
	if b[1] == "BTC":
		ans += float(b[0]) * 380000
	else:
		ans += int(b[0])
print(int(ans))

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

bs = [input().split() for _ in range(n)]

ans = 0
for b in bs:
	if b[1] == "BTC":
		ans += float(b[0]) * 380000.0
	else:
		ans += float(b[0])
print(ans)
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

Incorrect submission (verdict: Wrong Answer):
print(2/10)

Fixed, accepted submission:
N,A,B=map(int,input().split())
ans=[]
for i in range(1,N+1):
  j=i//10000+(i%10000)//1000+(i%1000)//100+(i%100)//10+(i%10)//1
  if A<=j<=B:
    ans.append(i)
  
print(sum(ans))
Problem:
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:    * Red boxes, each containing R red balls   * Green boxes, each containing G green balls   * Blue boxes, each containing B blue balls  Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?

Incorrect submission (verdict: Wrong Answer):
R,G,B,N = map(int,input().split())
x = N//R
ans = 0
for i in range(x+1):
  M = N - i*R
  for j in range((M+1)//G):
    L = M - j*G
    if L%B == 0:
      ans += 1
print(ans)

Fixed, accepted submission:
R,G,B,N = map(int,input().split())
x = N//R
ans = 0
for i in range(x+1):
  M = N - i*R
  for j in range((M//G)+1):
    L = M - j*G
    if L%B == 0:
      ans += 1
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):
a,b,x = [int(i) for i in input().split()]

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

Fixed, accepted submission:
a,b,c = [int(i) for i in input().split()]
 
print(b//c - (a-1)//c if a > 0 else b//c + 1)
Problem:
Write a program which replace all the lower-case letters of a given text with the corresponding captital letters.

Incorrect submission (verdict: Wrong Answer):
print(input().capitalize())

Fixed, accepted submission:
from functools import reduce
from operator import add
print(reduce(add, map(str.capitalize, input()[:]), ''))