TnT/CodeNet4Repair huggingface dataset:
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())
E = [0]*(N+1)
W = [0]*(N+1)
ans = 10000*10000
for i in range(N-1):
    if S[i] == 'E':
        E[i+1] += E[i] + 1
    else:
        W[i+1] += W[i] + 1
        
for i in range(N):
    ans = min(ans,E[i]+W[i]) 
    print(ans)

Fixed, accepted submission:
N = int(input())
S = list(input())
E = [0]*N
W = [0]*N
ans = 10000*10000
for i in range(N-1):
    if S[i] == 'W':
        W[i+1] += W[i] + 1
    else:
        W[i+1] = W[i]
for i in range(N)[:0:-1]:
    if S[i] == 'E':
        E[i-1] += E[i] + 1
    else:
        E[i-1] = E[i]
for i in range(N):
    ans = min(ans,E[i]+W[i])
print(ans)
Problem:
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i.  Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row:    * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.  Find the intensity of each bulb after the K operations.

Incorrect submission (verdict: Wrong Answer):
import numpy as np
Debug = False
# Calculate intensity
N, K = [int(v) for v in input().split(" ")]
A_arr = [int(v) for v in input().split(" ")]
def Luminate(A_arr, i):
  step = np.arange(len(A_arr))
  distance = abs(step - i)
  isLuminated = distance < np.array(A_arr)+1
  if Debug:
    print(step, distance,isLuminated)
  return isLuminated
def get_Intensity(A_arr):
  return [np.sum(Luminate(A_arr, i)) for i in range(len(A_arr))]
Intensity = A_arr
for i in range(K):
  Intensity = get_Intensity(Intensity)
print(Intensity)

Fixed, accepted submission:
import numpy as np
 
N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
indexes = np.arange(0, N)
 
dp = np.zeros(shape=N + 1, dtype=np.int64)
 
for k in range(K):
    np.add.at(dp, np.maximum(0, indexes - A), 1)
    np.add.at(dp, np.minimum(N, indexes + A + 1), -1)
    A = dp.cumsum()[:-1]
    if np.all(A == N):
        break
    dp *= 0
 
print(' '.join(map(str, A)))
Problem:
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.  You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.

Incorrect submission (verdict: Wrong Answer):
s = input()
num = len(s)
A = s.find("A")
Z = s.rfind("Z")
ans = Z - A
print(Z)


Fixed, accepted submission:
score = int(input())
if (score < 1200):
   print("ABC")
else:
   print("ARC")
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
a, v = list(map(int, input().strip().split()))
b, w = list(map(int, input().strip().split()))
t = int(input().strip())

if abs(a-b) <= (v-w)*t:
    print('Yes')
else:
    print('No')

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

if abs(a-b) <= (v-w)*t:
    print('YES')
else:
    print('NO')
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):
n = int(input())
a_list = list(map(int, input().split()))

min_a = min(a_list)
count = 0
while min_a % 2 == 0:
    min_a /= 2
    count += 1
#print(count)
while True:
    for i in range(n):
        if a_list[i] / 2 ** count % 2 !=0:
            break
    else:
        count += 1    
        continue
    break

print(count)

Fixed, accepted submission:
import numpy as np

input()
A = np.array(list(map(int, input().split())))
count = 0
while all(A%2==0):
    count += 1
    A //= 2
print(count)
Problem:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.  Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence.  Here, the distance between two points s and t on a number line is represented by |s-t|.

Incorrect submission (verdict: Wrong Answer):
x,a,b=input().split()
print(min(abs(int(x)-int(a)),abs(int(x)-int(b))))

Fixed, accepted submission:
x,a,b=input().split()
if abs(int(x)-int(a))<abs(int(x)-int(b)):
  print("A")
else:
  print("B")
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):
print("YES" if int(input())%500 < int(input()) else "NO")

Fixed, accepted submission:
print("Yes" if int(input())%500 <= int(input()) else "No")
Problem:
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.

Incorrect submission (verdict: Wrong Answer):
S=list(input())
A=list("abcdefghijklmnopqrstuvwxyz")
if set(S)!=set(A):
  print(A[A.index(min(S))-1])
else:
  print("None")

Fixed, accepted submission:
S=set(input())
Al="qwertyuiopasdfghjklzxcvbnm"
AL=list(Al)
l=[]
for i in range(len(Al)):
  if not AL[i] in S:
    l.append(AL[i])
if l!=[]:
  print(sorted(l)[0])
else:
  print("None")
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
import sys
N = int(input())
t=[0]*(N+1)
x=[0]*(N+1)
y=[0]*(N+1)

dist = 0

dt = 0 

now_x =0
now_y =0

t[0] = 0
x[0] = now_x
y[0] = now_y
for i in range(1,N+1):
    t[i],x[i],y[i] = map(int, input().split())
    
for i in range(1,N+1):    
    
    dist = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    dt = abs(t[i] - t[i-1])
    
    if(dist > dt):
        print('No')
        sys.exit()
    else:
        
        
        if(dt %2 != dist %2):
            print('No')
            sys.exit()
        else:
            print('Yes')
    
    


Fixed, accepted submission:
import sys
N = int(input())
t=[0]*(N+1)
x=[0]*(N+1)
y=[0]*(N+1)

dist = 0

dt = 0 

now_x =0
now_y =0

t[0] = 0
x[0] = now_x
y[0] = now_y
for i in range(1,N+1):
    t[i],x[i],y[i] = map(int, input().split())
    
for i in range(1,N+1):    
    
    dist = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    dt = abs(t[i] - t[i-1])
    
    if(dist > dt):
        print('No')
        sys.exit()
    else:
        
        
        if(dt %2 != dist %2):
            print('No')
            sys.exit()
    
print('Yes')
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):
n = int(input())
k = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for j in range(n):
  if k[j] == 'AC':
    ac += 1
  elif k[j] == 'WA':
    wa += 1
  elif k[j] == 'TLE':
    tle += 1
  elif k[j] == 'RE':
    re += 1
    
print("AC *",ac)
print("WA *",wa)
print("TLE *",tle)
print("RE *",re)

Fixed, accepted submission:
n = int(input())
k = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0

for j in range(n):
  if k[j] == 'AC':
    ac += 1
  elif k[j] == 'WA':
    wa += 1
  elif k[j] == 'TLE':
    tle += 1
  elif k[j] == 'RE':
    re += 1
    
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
s = input()
words = "eraser", "erase", "dreamer", "dream"

for word in words:
    s = s.replace(word, "")
    print(s)

print("YES" if len(s) == 0 else "NO")


Fixed, accepted submission:
s = input()
words = "eraser", "erase", "dreamer", "dream"

for word in words:
    s = s.replace(word, "")

print("YES" if len(s) == 0 else "NO")
Problem:
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.  Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** :    * Add 2 to a_i.   * Add 1 to b_j.

Incorrect submission (verdict: Wrong Answer):

#!/usr/bin/env python
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if N > sum(b)-sum(a):
	print("No")
else:
	print("Yes")

print(sum(b)-sum(a))


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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(n):
    if a[i] > b[i]:
        res -= a[i] - b[i]
    else:
        res += (b[i] - a[i]) // 2
if res >= 0:
    print("Yes")
else:
    print("No")
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

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

if 1 <= a <= 100 and 1 <= b <= 100:
    print(a * b)



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

if 1 <= a <= 100 and 1 <= b <= 100:
    area = a * b
    perimeter = (a + b) * 2
    print(area, perimeter)
Problem:
Snuke loves working out. He is now exercising N times.  Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i.  Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.

Incorrect submission (verdict: Wrong Answer):
from math import factorial
N = int(input())
P = factorial(N)
print(N%(10**9+7))

Fixed, accepted submission:
from math import factorial
N = int(input())
P = factorial(N)
print(P%(10**9+7))
Problem:
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i.  Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.

Incorrect submission (verdict: Wrong Answer):

from collections import Counter

N = int(input())
A = [int(a) for a in input().split()]

c = Counter(A)

c_v = sorted(c.values())

if N % 2 == 0:
    if c_v == [2] * (N // 2):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    if c_v == [1].extend([2] * ((N - 1) // 2)):
        print(2 ** ((N - 1) // 2))
    else:
        print(0)

Fixed, accepted submission:
from collections import Counter

N = int(input())
A = [int(a) for a in input().split()]
 
check = {}
 
if N % 2 == 0:
    for i in range(1, N, 2):
        check[i] = 2
else:
    check[0] = 1
 
    for i in range(2, N, 2):
        check[i] = 2
 
if check == Counter(A):
    print((2 ** (N // 2)) % (10 ** 9 + 7))
else:
    print(0)
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
A,B,C = map(int,input().split())
Ans = "No"
for i in range(1,101):
    if (A*i)%B==C:
        Ans="Yes"
        break
print(Ans)

Fixed, accepted submission:
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
A,B,C = map(int,input().split())

ans = "NO"
for i in range(1,B+1):
    if (A*i)%B == C:
        ans = "YES"
        break

print(ans)
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
i = 1
while True:
    if i ** 2 > n:
        print(i-1)
        break

    i += 1
    if i >= 10000:
        break

Fixed, accepted submission:
n = int(input())
i = 1
while True:
    if i ** 2 > n:
        print((i-1)**2)
        break

    i += 1
    if i >= 10000000:
        break
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
from collections import deque
N, M = map(int, input().split())
ways = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ways[a].append(b)
  ways[b].append(a)
print(ways)
searched = [0 for i in range(N)]
searched[0] = 1
ans = [0 for i in range(N)]
d = deque([])
d.append(0)
while d:
  tmp = d.popleft()
  for w in ways[tmp]:
    if searched[w] == 0:
      searched[w] = 1
      ans[w] = tmp
      d.append(w)
print("Yes")
for a in ans[1:]:
  print(a + 1)

Fixed, accepted submission:
from collections import deque
N, M = map(int, input().split())
ways = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  ways[a].append(b)
  ways[b].append(a)
searched = [0 for i in range(N)]
searched[0] = 1
ans = [0 for i in range(N)]
d = deque([])
d.append(0)
while d:
  tmp = d.popleft()
  for w in ways[tmp]:
    if searched[w] == 0:
      searched[w] = 1
      ans[w] = tmp
      d.append(w)
print("Yes")
for a in ans[1:]:
  print(a + 1)
Problem:
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.  You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

o = list(input()[::2])
e = list(input()[1::2])
ans = []
while len(o) and len(e):
    if len(o):
        ans.append(o[0])
        del o[0]
    if len(e):
        ans.append(e[0])
        del e[0]
print(''.join(ans))


Fixed, accepted submission:
# -*- coding: utf-8 -*-

o = list(input())
e = list(input())
ans = []
while len(o) or len(e):
    if len(o):
        ans.append(o[0])
        del o[0]
    if len(e):
        ans.append(e[0])
        del e[0]
print(''.join(ans))
Problem:
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.    * Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.  It can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.  You are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.

Incorrect submission (verdict: Wrong Answer):
K = int(input())
print(K+1)
for x in range(K+1,1,-1):
    print(x,end=' ')
print(0)


Fixed, accepted submission:
K = int(input())
if(K==0):
    print(4)
    print(3,3,3,3)
elif(K==1):
    print(3)
    print(1,0,3)
elif(K<50):
    n = K
    li = [i for i in range(n)]
    for i in range(n):
        for j in range(n):
            if(i==j):
                li[j] += n
            else:
                li[j] -= 1
    print(n)
    print(*li)
else:
    x = K%50
    y = K//50
    li = [y+i for i in range(50)]
    for i in range(x):
        for j in range(50):
            if(i==j):
                li[j] += 50
            else:
                li[j] -= 1
    print(50)
    print(*li)
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 0 < X - A <= B:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
A, B, X = map(int, input().split())
if 0 <= X - A <= B:
    print("YES")
else:
    print("NO")
Problem:
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i.  Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.

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

for i in range(len(s)):
  if s[i] == 1:
    cnt += 1

    print(cnt)

Fixed, accepted submission:
s = input()
cnt = 0

for i in range(len(s)):
  if s[i] == "1":
    cnt += 1
    
print(cnt)
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):
n = int(input(">>"))
a = map(int, input(">>").split())

count = 0
flag = True

while(flag):
    tmp_a = []
    for i in a:
        if i % 2 !=0:
            flag = False
            break
        tmp_a.append(i/2)
    a = tmp_a
    if flag == True:
        count += 1

print(count)

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

count = 0
flag = True

while(flag):
    tmp_a = []
    for i in a:
        if i % 2 !=0:
            flag = False
            break
        tmp_a.append(i/2)
    a = tmp_a
    if flag == True:
        count += 1

print(count)
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):
N = int(input())
C = 0
D = 0
E = 0
F = 0
S = ''

for i in range(N):
    S = input()
    if S == 'AC':
        C += 1
    elif S == 'WA':
        D += 1
    elif S == 'TLE':
        E += 1
    elif S == 'RE':
        F += 1
print('AC × '+ str(C))
print('WA × '+ str(D))
print('TLE × '+ str(E))
print('RE × '+ str(F))


Fixed, accepted submission:
N = int(input())
C = 0
D = 0
E = 0
F = 0
S = ''

for i in range(N):
    S = input()
    if S == 'AC':
        C += 1
    elif S == 'WA':
        D += 1
    elif S == 'TLE':
        E += 1
    elif S == 'RE':
        F += 1
print('AC x '+ str(C), 'WA x ' + str(D),  'TLE x ' + str(E),  'RE x ' + str(F), sep='\n')
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
n =int(input())
if n >= 15:
    print(800*n-(n-15)*200)
else:
    print(800*n)


Fixed, accepted submission:
n =int(input())
print(800*n-n//15*200)
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())

count = 0

for l in range(0, a):
    for m in range(0, b):
        for n in range(0, c):
            if(500*l+100*m+50*n == x):
                count+=1
print(count)


Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for l in range(0, a+1):
    for m in range(0, b+1):
        for n in range(0, c+1):
            if(500*l+100*m+50*n == x):
                count+=1
print(count)