TnT/CodeNet4Repair huggingface dataset:
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):
a = list(map(int,input().split()))
#b = list(map(int,input().split()))
b=int(input())
for i in range(b):
    a[a.index(min(a))]= 2*(a[a.index(min(a))])
print(a)
if a[0]<a[1]<a[2]:
    print("Yes")
else:
    print("No")

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

for i in range(b):
    if a[2]<=a[1]:
        a[2]=2*a[2]
    elif a[1]<=a[0]:
        a[1]=2*a[1]
if a[0]<a[1]<a[2]:
    print("Yes")
else:
    print("No")
Problem:
In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

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

X = 0

for i in range(N-1):
    X += min((t[i+1]-t[i]), T) 
    
print(X+7)


Fixed, accepted submission:
N, T = map(int,input().split())
t = list(map(int,input().split()))

X = 0

for i in range(N-1):
    X += min((t[i+1]-t[i]), T) 
    
print(X+T)
Problem:
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`.  You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.

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

print(len(s[1:-1]))

Fixed, accepted submission:
s = input()

print(s[0] + str(len(s[1:-1])) + s[-1])
Problem:
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.   Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.   Here, both the x\- and y-coordinates before and after each movement must be integers.   He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).   Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).   Under this condition, find a shortest path for him.

Incorrect submission (verdict: Wrong Answer):
sx, sy, tx, ty = map(int, input().split())

visited = set([(sx, sy)])

steps = abs(sx - tx) + abs(sy - ty)
ans = ""
pos = (sx, sy)
for i in range(steps):
    if pos[1] == ty:
        ans += "R"
        pos = (pos[0]+1, pos[1])
    else:
        ans += "U"
        pos = (pos[0], pos[1]+1)
    visited.add(pos)

visited.remove((sx, sy))
for i in range(steps):
    next_pos = (pos[0]-1, pos[1])
    if pos[1] == sy and next_pos not in visited:
        ans += "L"
        pos = (pos[0]-1, pos[1])
    else:
        ans += "D"
        pos = (pos[0], pos[1]-1)
    visited.add(pos)
    
ans += "L"
pos = (pos[0]-1, pos[1])
visited.add(pos)

visited.remove((tx, ty))
for i in range(steps*2): 
    next_pos = (pos[0]+1, pos[1])
    if pos == (tx, ty+1):
        ans += "D"
        pos = (pos[0], pos[1]-1)
        break
    else:
        if next_pos not in visited:
            ans += "R"
            pos = (pos[0]+1, pos[1])
        else:
            ans += "U"
            pos = (pos[0], pos[1]+1)
    visited.add(pos)
    
    
ans += "R"
pos = (pos[0]+1, pos[1])
visited.add(pos)

visited.remove((sx, sy))
for i in range(steps*2): 
    next_pos = (pos[0]-1, pos[1])
    if pos == (sx, sy-1):
        ans += "U"
        pos = (pos[0], pos[1]+1)
        break
    else:
        if next_pos not in visited:
            ans += "L"
            pos = (pos[0]-1, pos[1])
        else:
            ans += "D"
            pos = (pos[0], pos[1]-1)
    visited.add(pos)
    
print(ans)
# print(visited)

Fixed, accepted submission:
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = ''
# s to t
ans += 'U' * dy
ans += 'R' * dx
# t to s
ans += 'D' * dy
ans += 'L' * (dx+1)
# s tp t part2
ans += 'U' * (dy+1)
ans += 'R' * (dx+1)
ans += 'D'
# t to s part2
ans += 'R' 
ans += 'D' * (dy+1)
ans += 'L' * (dx+1)
ans += 'U'

print(ans)
Problem:
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.  According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.

Incorrect submission (verdict: Wrong Answer):
def main():
    l = list(map(int,input().split(" ")))
    N = l[0]
    Y = l[1]
    c1 = 0
    c2 = 0
    c3 = 0
    if Y>=N*10000 or Y<=N*1000:
        print(-1,-1,-1)
    while c1<=N:
        tar1 = Y-N*10000
        while c2<=N-c1:
            tar2 = tar1-c2*5000
            while c3<=N-c1-c2:
                tar3 = tar2-c3*1000
                if tar3==0:
                    print(c1,c2,c3)
                c3+=1
            c2+=1
        c1+=1
    print(-1,-1,-1)

if __name__=="__main__":
    main()

Fixed, accepted submission:
def main():
    l = list(map(int,input().split(" ")))
    N = l[0]
    Y = l[1]
    c1 = N
    c2 = 0
    c3 = 0
    if Y>N*10000 or Y<N*1000:
        print(-1,-1,-1)
        exit()
    while c1>=0:
        tar1 = Y-c1*10000
        c2 = N-c1
        while c2>=0:
            tar2 = tar1-c2*5000
            c3 = N-c2-c1
            tar3 = tar2-c3*1000
            if tar3==0:
                print(c1,c2,c3)
                exit()
            c2-=1
        c1-=1
    print(-1,-1,-1)

if __name__=="__main__":
    main()
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):
date = input('')
sub_date = date[4:-1]
print('2018/{0}'.format(sub_date))

Fixed, accepted submission:
date = input('')
sub_date = date[4:]
print('2018{0}'.format(sub_date))
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):
# -*- coding: utf-8 -*-
import sys

N = input()
S = input()

res = ''
lit = S.split(')(')
for i, l in enumerate(lit):
    kakko = l + ')' if i % 2 == 0 else '(' + l
    right, left = 0, 0
    for k in kakko:
        if k == '(':
            left += 1
        else:
            right += 1
    part = '('*(right-left) + kakko if right > left else kakko + ')'*(left-right)
    res += part
print(res)


Fixed, accepted submission:
# -*- coding: utf-8 -*-
import sys, re

N = input()
S = input()
sentence = ''
left, right = 0, 0
for s in S:
    sentence += s
    if s == '(':
        left += 1
    else:
        right += 1
    if left - right < 0:
        sentence = '(' + sentence
        left += 1
if left - right > 0:
    sentence = sentence + ')' * (left - right)
print(sentence)
Problem:
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N.  Find the minimum cost incurred before reaching the goal.

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

A = list(map(int, input().split()))

l = A[:X]
r = A[X+1:]

ans = []

ans.append(len(l)-1)
ans.append(len(r)-1)

print(min(ans))

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

A = list(map(int, input().split()))

ans = []

c = 0

for i in range(N):
  if i == X:
    ans.append(c)
    c = 0
    continue
  if i in A:
    c += 1
  if i == N-1:
    ans.append(c)
print(min(ans))
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=str(input())
ans=S[1:].count('E')
cnt=ans
for i in range(1,N):
    if S[i-1]=='W':
        cnt+=1
    if S[i]=='E':
        cnt-=1
        
print(min(ans,cnt))

Fixed, accepted submission:
N=int(input())
S=input()
ans=S[1:].count('E')
cnt=ans
for i in range(1,N):
    if S[i-1]=='W':
        cnt+=1
    if S[i]=='E':
        cnt-=1
    ans=min(ans,cnt)
    
print(ans)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
def main():
    N = int(input())
    num = list(map(int, input().split()))
    counter = [0] * N
    for j in range(N):
        while num[j]%2==0:
            num[j] = num[j]/2
            counter[j] += 1
    print(min(counter))

Fixed, accepted submission:
def main():
    N = int(input())
    num = list(map(int, input().split()))
    counter = [0] * N
    for j in range(N):
        while num[j]%2==0:
            num[j] = num[j]/2
            counter[j] += 1
    print(min(counter))

main()
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a, b, h = map(int, open(0).read().split())
print((a+b)*h/2)

Fixed, accepted submission:
a, b, h = map(int, open(0).read().split())
print((a+b)*h//2)
Problem:
In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:                 this is a pen   is would become:                 uijt jt b qfo   Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".

Incorrect submission (verdict: Wrong Answer):
import string
import sys

str = input()
alpha = string.ascii_lowercase

for str in sys.stdin:
    for i in range(len(alpha)):
        cipher_str = ""
        for s in str:
            if s in alpha:
                cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]
            else:
                cipher_str += s

        if ("the" or "this" or "that") in cipher_str:
            print(cipher_str)
            break

Fixed, accepted submission:
import string
import sys

alpha = string.ascii_lowercase

for line in sys.stdin:
    for i in range(len(alpha)):
        cipher_str = ""
        for s in line:
            if s in alpha:
                cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]
            else:
                cipher_str += s

        if "the" in cipher_str or "this" in cipher_str or "that" in cipher_str:
            print(cipher_str, end="")
            break
    else:
        print(line, end="")
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):
x = int(input())

a = 100
i = 1/100

print(x/(a**1/100))

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

a = 100
i = 0

while a < x:
  i += 1
  a += a // 100
  
  
print(i)
Problem:
Sitting in a station waiting room, Joisino is gazing at her train ticket.  The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).  In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds.  The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Incorrect submission (verdict: Wrong Answer):
nums = input()
n = 4


def calc(i, f, sum):
    if i == n-1:
        print(f+'=7')
        exit()
        return sum == 7

    else:
        calc(i+1, f + '-' + nums[i+1], sum - int(nums[i+1]))

        calc(i+1,  f + '+' + nums[i+1], sum + int(nums[i]))



calc(0, nums[0], int(nums[0]))

Fixed, accepted submission:
nums = input()
n = 4


def calc(i, f, sum):
    if i == n-1:
        if sum == 7:
            print(f+'=7')
            exit()

    else:
        calc(i+1, f + '-' + nums[i+1], sum - int(nums[i+1]))
        calc(i+1, f + '+' + nums[i+1], sum + int(nums[i+1]))


calc(0, nums[0], int(nums[0]))
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):
def main():
    n,k = map(int,input().split())
    D = list(map(int,input().split()))

    num = [x for x in range(10) if x not in D]
    ans = []
    while n > 0:
        x = n%10
        n //= 10
        flag = True
        for i in range(len(num)):
            if x <= num[i]:
                flag = False
                ans.append(num[i])
                break
        
        if flag:
            ans.append(num[0])
    
    print("".join(map(str,ans[::-1])))

Fixed, accepted submission:
import io,sys
sys.setrecursionlimit(10**6)

def main():
    n,k = map(int,input().split())
    D = list(map(int,input().split()))

    while True:
        temp = n
        num = []
        while temp > 0:
            num.append(temp%10)
            temp//=10
        
        flag = True
        for i in num:
            if i in D:
                flag = False
                break
        if flag:
            print(n)
            sys.exit()
        else:
            n+=1
main()
Problem:
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:    * The graph is simple and connected.   * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.  It can be proved that at least one such graph exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):
N = int( input())
if N == 3:
    print(1,3)
    print(2,3)
else:
    s = N%2
    N = N//2*2
    print(1, N-1)
    print(1,2)
    print(2,N)
    print(N-1,N)
    for i in range(2,N//2):
        for j in range(1,i+1):
            print(j, i+1)
            print(j, N-i)
            print(N+1-j, i+1)
            print(N+1-j, N-i)
    if s == 1 and N != 2:
        for i in range(1,N+1):
            print(i, N+1)

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

if N == 3:
    print(2)
    print(1,3)
    print(2,3)
else:
    s = N%2
    N = N//2*2
    ans = 0
    for i in range(2,N//2+1):
        ans += 4*i - 4
    if s == 0:
        print(ans)
    else:
        print(ans+N)
    print(1, N-1)
    print(1,2)
    print(2,N)
    print(N-1,N)
    for i in range(2,N//2):
        for j in range(1,i+1):
            print(j, i+1)
            print(j, N-i)
            print(N+1-j, i+1)
            print(N+1-j, N-i)
    if s == 1 and N != 2:
        for i in range(1,N+1):
            print(i, N+1)
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
h = int(input())
ans = (a + b) * h / 2
print(ans)


Fixed, accepted submission:
import math
a = int(input())
b = int(input())
h = int(input())
ans = (a + b) * h / 2
print(math.ceil(ans))
Problem:
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.  They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.  Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.

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

A = list(map(int, input().split()))

rui = [0] * N

rui[0] = A[0]
for it in range(1, N):
    rui[it] = rui[it - 1] + A[it]

ans = 1145141919810
for i in range(1, N):
    ans = min(rui[i], rui[N - 1] - rui[i])
    
print(ans)


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

A = list(map(int, input().split()))

rui = [0] * N

rui[0] = A[0]
for it in range(1, N):
    rui[it] = rui[it - 1] + A[it]

ans = 1145141919810
for i in range(0, N - 1):
    ans = min(abs(rui[i] - rui[N - 1] + rui[i]), ans)

print(ans)
Problem:
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.  He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.  To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.  How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
n = int(input())
k = [list(map(int,input().split())) for _ in range(3)]
cnt = [[0] * n for _ in range(2)] 

a = sorted(k[0])
b = sorted(k[1])
c = sorted(k[2])
for i in range(n):
    l = -1
    r = n 
    while r-l > 1:
        
        k = (l+r)//2
        if b[i] > a[k]: l = k
        else: r = k
    cnt[0][i] = l+1
    l = -1
    r = n 
    while r-l > 1:
        
        k = (l+r)//2
        if b[i] < c[k]: r = k
        else: l = k
    cnt[1][i] = n-r
print(cnt)

ans = 0
for i in range(n):
    ans += cnt[0][i]*cnt[1][i]
print(ans) 

Fixed, accepted submission:
#!/usr/bin/env python3
n = int(input())
k = [list(map(int,input().split())) for _ in range(3)]
cnt = [[0] * n for _ in range(2)] 

a = sorted(k[0])
b = sorted(k[1])
c = sorted(k[2])
for i in range(n):
    l = -1
    r = n 
    while r-l > 1:
        
        k = (l+r)//2
        if b[i] > a[k]: l = k
        else: r = k
    cnt[0][i] = l+1
    l = -1
    r = n 
    while r-l > 1:
        
        k = (l+r)//2
        if b[i] < c[k]: r = k
        else: l = k
    cnt[1][i] = n-r


ans = 0
for i in range(n):
    ans += cnt[0][i]*cnt[1][i]
print(ans)
Problem:
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Incorrect submission (verdict: Wrong Answer):
A, B, C, X, Y = map(int, input().split(" "))
p1 = A * X + B * Y
p2 = C * min(X, Y)
p3 = p2
if X > Y:
    p3 += (X - Y) * A
else:
    p3 += (Y - X) * B
print(min(p1, p2, p3))

Fixed, accepted submission:
A, B, C, X, Y = map(int, input().split(" "))
p1 = A * X + B * Y
p2 = C * min(X, Y) * 2
if X > Y:
    p2 += (X - Y) * A
else:
    p2 += (Y - X) * B
p3 = C * max(X, Y) * 2
print(min(p1, p2, p3))
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):

def findSomeofDigits(x):
	s = 0
	while x > 0:
		s = s + x % 10
		x = x // 10
	return s

N,A,B = map(int,input().split())
c = 0
for i in range(N):
	s = findSomeofDigits(i+1)
	if A <= s and s <= B:
		print(i + 1)
		c = c + i + 1
print(c)

Fixed, accepted submission:

def findSomeofDigits(x):
	s = 0
	while x > 0:
		s = s + x % 10
		x = x // 10
	return s

N,A,B = map(int,input().split())
c = 0
for i in range(N):
	s = findSomeofDigits(i+1)
	if A <= s and s <= B:
		c = c + i + 1
print(c)