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):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
    if a[i]%4 == 0:
        li4.append(a[i])
    elif a[i]%2 == 0:
        li2.append(a[i])
    else:
        li.append(a[i])
if len(li4)>len(li):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in range(n):
    if a[i]%4 == 0:
        n4+=1
    elif a[i]%2 == 0:
        n2 +=1
    else:
        n1+=1

if n2 == 1:
    n2 = 0

if n4*2 + n2 >= n or n4*2 + 1 == n:
    print("Yes")
else:
    print("No")
Problem:
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).  A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.  At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
red = []
blue = []
for i in range(n):
    red.append(list(map(int,input().split())))
for i in range(n):
    blue.append(list(map(int,input().split())))
red.sort(reverse = True)
blue.sort(reverse = True)
print(red)
print(blue)
ans = 0
for i in range(n):
    redx,redy = red[i][0],red[i][1]
    for j in range(len(blue)):
        print(blue)
        bluex,bluey = blue[j][0],blue[j][1]
        if redx < bluex and redy < bluey:
            ans += 1
            blue.pop(0)
            break
print(ans)

Fixed, accepted submission:
n = int(input())
red = []
blue = []
for i in range(n):
    red.append(list(map(int,input().split())))
for i in range(n):
    blue.append(list(map(int,input().split())))
red.sort(reverse = True)
blue.sort(key=lambda x:x[1])
ans = 0
for i in range(n):
    redx,redy = red[i][0],red[i][1]
    for j in range(len(blue)):
        bluex,bluey = blue[j][0],blue[j][1]
        if redx < bluex and redy < bluey:
            ans += 1
            blue.pop(j)
            break
print(ans)
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):
N = 3
print(N *(N + 1) // 2)

N = 10
print(N * (N + 1) // 2)

N = 1
print(N * (N + 1) // 2)

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

candy = int(N * (N + 1) / 2)

print(candy)
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())
ans = 0
for i in range(n+1):
  for j in range(n+1):
    k = (n - (i*r+j*g))/b
    #for k in range(n+1):
    if k < 0:
      continue
    if i*r+j*g+k*b == n and k.is_integer():
      ans += 1
      print(i, j, k)
print(ans)

Fixed, accepted submission:
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
  for j in range((N-R*i)//G+1):
     if (N - R*i - G*j) % B == 0:
        ans += 1
print(ans)
Problem:
Write a program which identifies the number of combinations of three integers which satisfy the following conditions:    * You should select three distinct integers from 1 to n.   * A total sum of the three integers is x.  For example, there are two combinations for n = 5 and x = 9.    * 1 + 3 + 5 = 9   * 2 + 3 + 4 = 9

Incorrect submission (verdict: Wrong Answer):
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for i in range(1,n):
        for j in range(1,n):
            for k in range(1,n):
                if i+j+k ==x:
                    count += 1
    print(count)

Fixed, accepted submission:
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                if (i < j < k):
                    if i+j+k == x:
                        count += 1
    print(count)
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()))
a = sum(A)

B=[0]*N
B[0] = A[0]
saitei = float("inf")
for i in range(1, N):
    B[i] += B[i-1]
    saitei = min(abs(B[i]-(a-B[i])), saitei)

print(saitei)

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

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

B=[0]*N
B[0] = A[0]
saitei = float("inf")
for i in range(N-1):
    saitei = min(abs(B[i]-(a-B[i])), saitei)
    B[i+1] += (A[i+1] + B[i])
    
print(saitei)
Problem:
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.  You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Incorrect submission (verdict: Wrong Answer):
a=list(map(int,input().split()))
S=input()
print(a[0])
if S.count("-") ==1 and S[a[0]]=="-":
	print("Yes")
else:
	print("No")


Fixed, accepted submission:
a=list(map(int,input().split()))
S=input()
if S.count("-") ==1 and S[a[0]]=="-":
	print("Yes")
else:
	print("No")
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):
abc = list(input())
print('YES' if abc.count('5')==2 & abc.count('7')==1 else 'NO')


Fixed, accepted submission:
abc = input().replace(' ', '')

print('YES' if abc.count('7')==1 and abc.count('5')==2 else 'NO')
Problem:
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.   The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.  An edge whose removal disconnects the graph is called a _bridge_.   Find the number of the edges that are bridges among the M edges.

Incorrect submission (verdict: Wrong Answer):
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    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:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        
        return self.find(x) == self.find(y)

    def size(self, x):
        return len(set(self.par))

N, M = map(int, input().split())
a, b = [0] * M, [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())

ans = 0
for i in range(M):
    uf = UnionFind(n=N+1)
    for j in range(M):
        if j == i:
            continue
        uf.union(a[j], b[j])
    if uf.size(a[0]) != 1:
        ans += 1
print(ans)

Fixed, accepted submission:
class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = n

    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:
            self._size -= 1
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self):
        return self._size

N, M = map(int, input().split())
a, b = [0] * M, [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())

ans = 0
for i in range(M):
    uf = UnionFind(n=N)
    for j in range(M):
        if j == i:
            continue
        uf.union(a[j]-1, b[j]-1)
    if uf.size() != 1:
        ans += 1
print(ans)
Problem:
AtCoder Mart sells 1000000 of each of the six items below:    * Riceballs, priced at 100 yen (the currency of Japan) each   * Sandwiches, priced at 101 yen each   * Cookies, priced at 102 yen each   * Cakes, priced at 103 yen each   * Candies, priced at 104 yen each   * Computers, priced at 105 yen each  Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible.   (Ignore consumption tax.)

Incorrect submission (verdict: Wrong Answer):
X = int(input())
price = [100, 101, 102, 103, 104, 105]

dp = [False for _ in range(X + 1)]

dp[0] = True
for i in range(1, X + 1):
    for j in range(6):
        if i - price[j] >= 0:
            if dp[i - price[j]]:
                dp[i] = True
                break
    else:
        dp[i] = False

if dp[X]:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
X = int(input())
price = [100, 101, 102, 103, 104, 105]

dp = [False for _ in range(X + 1)]

dp[0] = True
for i in range(1, X + 1):
    for j in range(6):
        if i - price[j] >= 0:
            if dp[i - price[j]]:
                dp[i] = True
                break
    else:
        dp[i] = False

if dp[X]:
    print(1)
else:
    print(0)
Problem:
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides.  Print the answer in degrees, but do not print units.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
print(N-1*90)

Fixed, accepted submission:
N = int(input())
print((N-2)*180)
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):
a=int(input())
if 1==a:
    print(a)
else:
    while 0!=a%2:
        a=a-1
    print(a)


Fixed, accepted submission:
a=int(input())
b=int(2)
c=int
if 1==a:
    print(a)
else:
    while b<100:
        c=b
        b=b*2
        
        if(a<b)and(a>=c):
            print (c)
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):
y, m = map(int, input().split())
print(y + (1 if y <= m else 0))

Fixed, accepted submission:
y, m = map(int, input().split())
print(y - 1 + (1 if y <= m else 0))
Problem:
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.  The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it.  Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up.  Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
a=[int(input()) for i in range(n)]
memo=[0]*n

for i in range(n):
  if i == 0:
    k=0
    memo[0]=1
    ans=0
  else:
    k=a[k]-1
    if memo[k]==0:
      memo[k]=1
    else:
      print(-1)
      exit()
    ans += 1
  if k==2:
    print(ans)
    exit()
  
  

Fixed, accepted submission:
n=int(input())
a=[int(input()) for i in range(n)]
memo=[0]*n

for i in range(n):
  if i == 0:
    k=0
    memo[0]=1
    ans=0
  else:
    k=a[k]-1
    if memo[k]==0:
      memo[k]=1
    else:
      print(-1)
      exit()
    ans += 1
  if k==1:
    print(ans)
    exit()
Problem:
There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.

Incorrect submission (verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    pair = 0
    for i in range(n):
        if a[i-1] == i - 1 and a[i-1] >= i - 1:
            pair += 1
            
    print(pair)
    
    
if __name__ == "__main__":
    main()

Fixed, accepted submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    pair = 0
    for i in range(n):
        if a[a[i]-1] == i + 1 and a[a[i]-1] <= a[i]:
            pair += 1
            
    print(pair)
    
    
if __name__ == "__main__":
    main()
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):
i = int(input())
x = i * 800
y = i % 15 * 200
print(x -y)

Fixed, accepted submission:
i = int(input())
x = i * 800
y = i // 15 * 200
print(x -y)
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
n, a, b = map(int, input().split())
print(n*a if n*a >= b else b)


Fixed, accepted submission:
n, a, b = map(int, input().split())
print(n*a if n*a <= b else b)
Problem:
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Incorrect submission (verdict: Wrong Answer):

s = input()
t = input()

# sort
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))
st_list = [s, t]


if s == t:
    print("NO")
elif st_list == sorted(st_list):
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
# coding: utf-8


s = input()
t = input()

# sort
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))
st_list = [s, t]


if s == t:
    print("No")
elif st_list == sorted(st_list):
    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(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
  for i in range(n):
    A[i]=A[i]/2
    ans+=1
print(ans)

Fixed, accepted submission:
n=int(input())
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
    for i in range(n):
        A[i]=A[i]/2
    ans+=1
print(ans)
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

Incorrect submission (verdict: Wrong Answer):
print("Yes" if int(input().replace(" ",""))%4==0 else "No")

Fixed, accepted submission:
print("YES" if int(input().replace(" ",""))%4==0 else "NO")
Problem:
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

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

Fixed, accepted submission:
n = int(input())
x = list(map(int, input().split()))
m1, m2 = sorted(x)[n//2-1], sorted(x)[n//2]
for i in x:
  print(m1) if i >= (m1+m2)/2 else print(m2)
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
eval(input().replace(*" ^"))

Fixed, accepted submission:
print(eval(input().replace(*" ^")))
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
a = []
while True:
    b = input()
    b = int(b)
    if b == 0:
        break
    else:
        a.append(b)
for i in range(len(a)):
    print("Case "+str(i)+": "+str(a[i]))


Fixed, accepted submission:
a = []
while True:
    b = input()
    b = int(b)
    if b == 0:
        break
    else:
        a.append(b)
for i in range(len(a)):
    c = i+1
    print("Case "+str(c)+": "+str(a[i]))
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 = list(input())
s.reverse()
s = "".join(s)
before_s = s
while(True):
    if s[:5]=="maerd" or s[:5] =="esare":
        s = s[5:]
    elif s[:7]=="remaerd" :
        s = s[7:]
    elif s[:6] == "resare":
        s = s[6:]
    if s == "":
        ans = "Yes"
        break
    if s == before_s:
        ans ="No"
        break
print(ans)


Fixed, accepted submission:
s = list(input())
s.reverse()
s = "".join(s)

for _ in range(10**5):
    before_s = s
    if s[:5]=="maerd" or s[:5] =="esare":
        s = s[5:]
    elif s[:7]=="remaerd" :
        s = s[7:]
    elif s[:6] == "resare":
        s = s[6:]
    if s == "":
        ans = "YES"
        break
    if s == before_s:
        ans ="NO"
        break
print(ans)
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

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

for i in range(10**5):
  if (1+i)*i//2>=X:
    print(i)

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

for i in range(10**5):
  if (1+i)*i//2>=X:
    print(i)
    exit()
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):
# coding: utf-8
# Your code here!



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

# print(A)

# print(C)

if C >= A and C <= B:
 print('YES')
else:
 print('NO')

Fixed, accepted submission:
# coding: utf-8
# Your code here!



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

# print(A)

# print(C)


if C >= A and C <= B:
 print('Yes')
else:
 print('No')
Problem:
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.

Incorrect submission (verdict: Wrong Answer):
s = int(input())
a = s//(60*60)
b = (s-(a*60*60))//60
c = s-(b*60)
print("{}:{}:{}".format(a,b,c))

Fixed, accepted submission:
s=int(input())
h=s//3600
ss=(s-3600*h)//60
se=(s-3600*h-ss*60)
print("{}:{}:{}".format(h,ss,se))
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:
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.

Incorrect submission (verdict: Wrong Answer):
a=input()
if "abc" in a:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
a=input()
if set("abc") == set(a):
    print("Yes")
else:
    print("No")