TnT/CodeNet4Repair huggingface dataset:
Problem:
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.  Snuke's objective is to permute the element in a so that the following condition is satisfied:    * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.  Determine whether Snuke can achieve his objective.

Incorrect submission (verdict: Wrong Answer):
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

li = [0,0]

for i in range(n):
    if a[i]%4 == 0:
        li[0] += 1
    elif a[i]%2 == 1:
        li[1] += 1

if li[0] >= li[1]+1:
    print("Yes")
else:
    print("No")



Fixed, accepted submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

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

li = [0,0,0]

for i in range(n):
    if a[i]%4 == 0:
        li[0] += 1
    elif a[i]%2 == 1:
        li[1] += 1
    elif a[i]%2 == 0:
        li[2] += 1

if (li[0] >= li[1]-1 and li[2]==0) or (li[0] >= li[1]):
    print("Yes")
else:
    print("No")
Problem:
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems.  The score allocated to the i-th (1≦i≦N) problem is i points.  Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve.  As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him.  Determine the set of problems that should be solved.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
ans = []
for i in range(10**7):
  ans.append(i+1)
  su = i+1*(i+2)//2
  if su > n:
   ans.remove(su-n)

   break
  elif su == n:
    break
print(*ans)

Fixed, accepted submission:
n = int(input())
ans = []
for i in range(10**7):
  ans.append(i+1)
  su = (i+1)*(i+2)//2
  if su > n:
   ans.remove(su-n)
   break
  elif su == n:
    break
for i in ans:
 print(i)
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):
#-*-coding:utf-8-*-

def main():
    n, m, x, y = map(int, input().split())
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    for z in range(x + 1, y+1):
        if all(x < z for x in x_list) and all(y >= z for y in y_list):
            print('No War')
            print(z)
            exit()
    print('War')

if __name__ == '__main__':
    main()

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

def main():
    n, m, x, y = map(int, input().split())
    x_list = list(map(int, input().split()))
    y_list = list(map(int, input().split()))
    for z in range(x + 1, y+1):
        if all(x < z for x in x_list) and all(y >= z for y in y_list):
            print('No War')
            exit()
    print('War')

if __name__ == '__main__':
    main()
Problem:
Takahashi is a user of a site that hosts programming contests.   When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows:    * Let the current rating of the user be a.   * Suppose that the performance of the user in the contest is b.   * Then, the new rating of the user will be the avarage of a and b.  For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.  Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.   Find the performance required to achieve it.

Incorrect submission (verdict: Wrong Answer):
print(input() * -1 + input() * 2)

Fixed, accepted submission:
print(int(input()) * -1 + int(input()) * 2)
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, C = map(int, input().split())

if A<=C and C<= A+B:
    print("Yes")
else:
    print("NO")


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

if A<=C and C<= A+B:
    print("YES")
else:
    print("NO")
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: Time Limit Exceeded):
n = int(input())
ans = 1
i = 1
while i<=n:
  ans = ans*i%(1000000007)
  i=+1
print(ans)
  

Fixed, accepted submission:
n = int(input())
ans = 1
i = 1
while i<=n:
  ans = ans*i%(1000000007)
  i += 1
print(ans)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):
A,B,K = map(int,input().split())
C = [i for i in range(A,B+1)]
N = len(C)
L = set(C[N-K:]+C[:K])
for l in L:
    print(l)

Fixed, accepted submission:
A,B,K = map(int,input().split())
if B-A+1 <= K*2:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
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=input()

w = 0
e = 0
for i in s:
  if i =="W":
    w +=1
  else:
    e +=1
print(min(w,e))

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

w = 0
e = 0
for i in s:
  if i =="W":
    pass
  else:
    e +=1
n=e
for i in s:
  if i=="E":
    e-=1
    n = min(n,e+w)
  if i =="W":
    w+=1
print(n)
Problem:
There are N integers, A_1, A_2, ..., A_N, written on a blackboard.  We will repeat the following operation N-1 times so that we have only one integer on the blackboard.    * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.  Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.

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

A.sort()
xy=[]
l=0
r=N-1
for i in range(N-1):
    if (N-1-i)&1:
        
        x=A[r]
        y=A[l]
        A[r]-=y
        l+=1
    else:
        
        x=A[l]
        y=A[r]
        A[l]-=y
        r-=1
    xy.append((x,y))

print(A[r])
print('\n'.join([' '.join(map(str,t)) for t in xy]))

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

A.sort()
xy=[]
for i in range(N-2,0,-1):
    y=A[i]
    if y>0:
        x=A[0]
        A[0]-=y
    else:
        x=A[N-1]
        A[N-1]-=y
    xy.append((x,y))

print(A[N-1]-A[0])
xy.append((A[N-1],A[0]))
print('\n'.join([' '.join(map(str,t)) for t in xy]))
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):
a, s, c = input().split()
print(a, s[0], c)

Fixed, accepted submission:
a, s, c = input().split()
print("{}{}{}".format(a[0], s[0], c[0]))
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):
input()
A = list(map(int, input().split()))
count = 1

while all(a%2 == 0 for a in A):
  A = [a/2 for a in A]
  count += 1
print(count)

Fixed, accepted submission:
input()
A = list(map(int, input().split()))
count = 0

while all(a%2==0 for a in A):
  A = [a/2 for a in A]
  count += 1
print(count)
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):
N,E = map(int,input().split(" "))
x,y,z = 0,0,0
x = int(E / 10000)
E = E - 10000 * x
y = int(E / 5000)
E = E - 5000 * y
z = int(E / 1000)
E = E - 1000 * z
if N < x+y+z:
    print("-1 -1 -1")

Fixed, accepted submission:
N,Y = map(int,input().split(" "))
M10000,M5000,M1000 = -1,-1,-1
for a in range(N+1):
  for b in range(N-a+1):
    c = N - a - b
    total = 10000 * a + 5000 * b + 1000 * c
    if total == Y:
      M10000 = a
      M5000 = b
      M1000 = c
ans = str(M10000) + " " + str(M5000) + " " + str(M1000)
print(ans)
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):
a = list(input())
b = list(input())
b.append("__DUMMY__")
c = sum(map(list, zip(a, b)), [])
print(c)
print("".join(c).replace("__DUMMY__", ""))


Fixed, accepted submission:
a = list(input())
b = list(input())
b.append("__DUMMY__")
c = sum(map(list, zip(a, b)), [])
print("".join(c).replace("__DUMMY__", ""))
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):
x, y  = map(int,input().split())

if x > y:
    print("Yes")
else:
    print("No")

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

if x >= y*2-1:
    print("YES")
else:
    print("NO")
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: Time Limit Exceeded):
a, b, c, x, y= map(int, input().split())


price = []
for i in range(10000000):
    price.append(i * 2*c + max(0,x-i) * a + max(0,y-i) * b)

print(min(price))

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

price = []
for i in range(10**5+1):
    price.append(i * 2*c + max(0,x-i) * a + max(0,y-i) * b)
print(min(price))
Problem:
Write a program which reads an integer and prints sum of its digits.

Incorrect submission (verdict: Wrong Answer):
while True:
    x=int(input())
    if x==0:
        break
    i=x%10
    j=(x-i)%100/10
    k=(x-j*10-i)%1000/100
    print(int(i+j+k))


Fixed, accepted submission:
while True:
    n=input()
    if n=='0':
        break
    s=list(n)
    a=[int(i) for i in s]
    print(sum(a))
Problem:
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.  Snuke's objective is to permute the element in a so that the following condition is satisfied:    * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4.  Determine whether Snuke can achieve his objective.

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

def main(N,A):
    count4 = count2 = count = 0
    for a in A:
        if(a%4==0):
            count4 += 1
        elif(a%2==0):
            count2 += 1
        else:
            count += 1
            
    if(count-1<=count4 and count2!=1):
        print("Yes")
    else:
        print("No")
    
            
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    main(N,A)

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

def main(N,A):
    count4 = count2 = count = 0
    for a in A:
        if(a%4==0):
            count4 += 1
        elif(a%2==0):
            count2 += 1
        else:
            count += 1
            
    if(count2==0):
        if(count-1<=count4):
            print("Yes")
        else:
            print("No")
    else:
        if(count<=count4):
            print("Yes")
        else:
            print("No")
            
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    main(N,A)
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

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

n = int(input())
print((n*(n-1))//2)

Fixed, accepted submission:
#coding:utf-8

n = int(input())
print((n*(n+1))//2)
Problem:
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.

Incorrect submission (verdict: Wrong Answer):
def main():
    inp = input()
    [x, y, z] = list(map(int, inp.split()))
    count = 0
    for i in range(x, y + 1):
        count += 1 if x % i == 0 else 0
    print(count)

if __name__ == '__main__':
    main()


Fixed, accepted submission:
a, b, c = map(int, input().split())
count = 0
for i in range(a, b+1):
    if c % i == 0:
        count += 1

print(count)
Problem:
底辺が x 軸に対して平行な 2 つの長方形があります。長方形 A の左下の座標 (xa1, ya1) と右上の座標 (xa2, ya2)、長方形 B の左下の座標 (xb1, yb1) と右上の座標 (xb2, yb2) を読み込んで、長方形 A と長方形 B が一部でも重なっていれば YES を、まったく重なっていなければ NO を出力するプログラムを作成してください。ただし、長方形 A と長方形 B は同じものではないとします。また、接しているものも重なっているとみなします。  

Incorrect submission (verdict: Wrong Answer):
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        dx = abs((xa2 - xa1) - (xb2 - xb1))
        dy = abs((ya2 - ya1) - (yb2 - yb1))
        w = (xa2 - xa1)/2 + (xb2 - xb1)/2
        h = (ya2 - ya1)/2 + (yb2 - yb1)/2
        if dx <= w or dy <= h:
            print("YES")
        else:
            print("NO")
    except:
        break



Fixed, accepted submission:
while True:
    try:
        xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, input().split())
        if (xa1 <= xb2 and xb1 <= xa2) and (ya1 <= yb2 and yb1 <= ya2):
            print("YES")
        else:
            print("NO")
    except:
        break
Problem:
Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.

Incorrect submission (verdict: Wrong Answer):
n, k = map(int, input().split())
ans = 0
for b in range(k+1,n+1):
  ans += (n-k) // b + 1
  
print(ans)

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

ans = 0

for b in range(k+1,n+1):
  s = n // b
  a = n % b
  ans += s * (b - k)
  ans += max(a - k + 1, 0)
  if k == 0:
    ans -= 1

print(ans)
Problem:
Today is August 24, one of the five Product Days in a year.  A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day):    * d_1 \geq 2   * d_{10} \geq 2   * d_1 \times d_{10} = m  Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D.  In Takahashi Calendar, how many Product Days does a year have?

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

M, D = map(int, input().split())
result =0
for i in range(4,M):
    for j in range(22, D):
        d1 =(j % 10)
        d2 =(j // 10)
        if d1 <2 or d2<2 or (d1*d2!=i):
            continue
        result += 1
print(result)


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

M, D = map(int, input().split())
result =0
for i in range(4,M+1):
    for j in range(22, D+1):
        d1 =(j % 10)
        d2 =(j // 10)
        if d1 <2 or d2<2 or (d1*d2!=i):
            continue
        result += 1
print(result)
Problem:
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b.  The i-th operation is as follows:    1. Append a_i to the end of b.   2. Reverse the order of the elements in b.  Find the sequence b obtained after these n operations.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
s = []
for i in a:
    s.append(i)
    s.reverse()
print(s)

Fixed, accepted submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.appendleft(a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)
Problem:
We have N cards. A number a_i is written on the i-th card.   Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.   The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

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

x_list=list(map(int,input().split()))
x_list=sorted(x_list)

a,b=0,0

for i in range(N):
    if((i+1)%2!=0):
        a+=x_list[i]
    else:
        b+=x_list[i]

print(a-b)

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

x_list=list(map(int,input().split()))
x_list=sorted(x_list,reverse=True)

a,b=0,0

for i in range(N):
    if((i+1)%2!=0):
        a+=x_list[i]
    else:
        b+=x_list[i]

print(a-b)
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):
n,a,b = map(int,input().split())
cnt=sum=0

for i in range(1,n+1):
    for j in list(str(i)):sum+=int(j)
    if a <= sum <= b:cnt+=1

print(cnt)


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

for i in range(1,n+1):
    c = sum(list(map(int,list(str(i)))))
    if a <= c <= b:res+=i

print(res)
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):
S = input()
print(S.replace(S[3],"8"))

Fixed, accepted submission:
S = input()
print(S.replace("2017","2018"))
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
print('Yes' if max(a, b) <= c <= min(a, b) else 'No')

Fixed, accepted submission:
a, b, c = map(int, input().split())
print('Yes' if min(a, b) <= c <= max(a, b) else 'No')
Problem:
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows:    * Rating 1-399 : gray   * Rating 400-799 : brown   * Rating 800-1199 : green   * Rating 1200-1599 : cyan   * Rating 1600-1999 : blue   * Rating 2000-2399 : yellow   * Rating 2400-2799 : orange   * Rating 2800-3199 : red  Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not.   Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i.   Find the minimum and maximum possible numbers of different colors of the users.

Incorrect submission (verdict: Wrong Answer):
n, *A = map(int, open(0).read().split())
B = [0] * 9
for a in A:
  if a < 3200:
  	B[a // 400] = 1
  else:
    B[8] += 1
print(min(8, sum(B)))

Fixed, accepted submission:
n, *A = map(int, open(0).read().split())
B = [0] * 9
for a in A:
  if a < 3200:
  	B[a // 400] = 1
  else:
    B[8] += 1
print(max(sum(B[:8]), 1), sum(B))
Problem:
Snuke has N sticks. The length of the i-th stick is l_i.  Snuke is making a snake toy by joining K of the sticks together.  The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.

Incorrect submission (verdict: Wrong Answer):
n,m=map(int,input().split())
a=sorted([int(i) for i in input().split()])
print(sum(a[-m:]),a[-m:])

Fixed, accepted submission:
n,m=map(int,input().split())
a=sorted([int(i) for i in input().split()])
print(sum(a[-m:]))