TnT/CodeNet4Repair huggingface dataset:
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):
#!/usr/bin/env python
import itertools
input_str = input()
print(input_str)
A = input_str[0]
B = input_str[1]
C = input_str[2]
D = input_str[3]

ops = ['+', '-']
all_ops = list(itertools.product(A, ops, B, ops, C, ops, D))
for tmp in all_ops:
    result = eval(''.join(tmp))
    if result == 7:
        print(''.join(tmp) + "=7")
        break


Fixed, accepted submission:
#!/usr/bin/env python
import itertools
input_str = input()
A = input_str[0]
B = input_str[1]
C = input_str[2]
D = input_str[3]

ops = ['+', '-']
all_ops = list(itertools.product(A, ops, B, ops, C, ops, D))
for tmp in all_ops:
    result = eval(''.join(tmp))
    if result == 7:
        print(''.join(tmp) + "=7")
        break
Problem:
Alice and Brown loves games. Today, they will play the following game.  In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice:    * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile.  The player who becomes unable to perform the operation, loses the game.  Given X and Y, determine the winner of the game, assuming that both players play optimally.

Incorrect submission (verdict: Wrong Answer):
a = list(map(int,input().split(" ")))
if (a[0] < 2 and a[1] < 2) or a[0] == a[1]:
    print("Brown")
else:
    print("Alice")

Fixed, accepted submission:
a = list(map(int,input().split(" ")))
if abs(a[0] - a[1]) < 2:
    print("Brown")
else:
    print("Alice")
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):
n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1][b-1]=1
    path[b-1][a-1]=1

def connected(v,visited):
    visited[v]=1
    if sum(visited)==n:
        visited=[0]*n
        return 1
    count=0
    for i in range(n):
        if path[v][i]==1 and visited[i]==0:
            visited[i]=1
            count+=connected(i,visited)
    visited=[0]*n
    return count
bridge=0

for x in range(n):
    for y in range(x+1,n):
        if path[x][y]==1:
            visited=[0]*n
            path[x][y]=0
            if not connected(x,visited):
                print(x,y)
                bridge+=1
            path[x][y]=1
print(bridge)


Fixed, accepted submission:
n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1][b-1]=1
    path[b-1][a-1]=1

def connected(v,visited):
    visited[v]=1
    if sum(visited)==n:
        visited=[0]*n
        return 1
    count=0
    for i in range(n):
        if path[v][i]==1 and visited[i]==0:
            visited[i]=1
            count+=connected(i,visited)
    visited=[0]*n
    return count
bridge=0

for x in range(n):
    for y in range(x+1,n):
        if path[x][y]==1:
            visited=[0]*n
            path[x][y]=0
            if not connected(x,visited):
                bridge+=1
            path[x][y]=1
print(bridge)
Problem:
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`.  Consider doing the following operation:    * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.  You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

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

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)
black = 0
H = []
W = []
ans = 0

for bit_h in range(2**h):
    for bit_w in range(2**w):
        black = 0
        for i in range(h):
            if not ((bit_h >> 1) & 1):
                continue
            for j in range(w):
                if not ((bit_w >> 1) & 1):
                    continue
                if c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)


Fixed, accepted submission:
# coding:utf-8

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)
black = 0
ans = 0

for bit_h in range(2**h):
    for bit_w in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((bit_h >> i) & 1) and ((bit_w >> j) & 1) and c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
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):
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, bin(i).rfind("1") - 1)
print(round(ans))

Fixed, accepted submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
Problem:
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).

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

rslt = 0
for i in range(1,n+1):
    s = str(i)
    sum = 0
    for j in s:
        sum = sum + int(j)
    if sum >= a and sum <= b:
        rslt += sum

print(rslt)

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

rslt = 0
for i in range(1,n+1):
    s = str(i)
    sum = 0
    for j in s:
        
        sum = sum + int(j)
    if sum >= a and sum <= b:
        rslt += i

print(rslt)
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):
n=int(input())
from numpy import log
print(int(log(n)/log(2)))

Fixed, accepted submission:
n=int(input())
from numpy import log
print(pow(2,int(log(n)/log(2))))
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 - a:
  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:
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())
for i in range(a,a*b,a):
    if i%b == c:
        print("Yes")
        break
else:print("No")


Fixed, accepted submission:
a,b,c = map(int,input().split())
for i in range(a,a*b,a):
    if i%b == c:
        print("YES")
        break
else:print("NO")
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())

s = (a + b) * h

print(s)

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

s = (a + b) * h / 2
  
print(int(s))
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())
d = 100
i = 0

while d <= x:
  d += d//100
  i += 1
else:
  print(i)

Fixed, accepted submission:
x = int(input())
d = 100
i = 0

while d < x:
  d += d//100
  i += 1
else:
  print(i)
Problem:
選手の皆さん、パソコン甲子園にようこそ。イベントに参加するには体調管理が大切です。気温が大きく変動する季節の変わり目には体に負担がかかり、風邪をひきやすいと言われています。一番気を付けなければいけない日は、最高気温と最低気温の差が最も大きい日です。１日の最高気温と最低気温が７日分与えられたとき、それぞれの日について最高気温から最低気温を引いた値を出力するプログラムを作成してください。

Incorrect submission (verdict: Wrong Answer):
for i in range(7):
    ls = list(map(int, input().split()))
    if max(ls) > 0 and min(ls) > 0:
        print(max(ls) - min(ls))
    elif max(ls) > 0 and min(ls) < 0:
        print(max(ls) + min(ls))
    elif max(ls) < 0 and min(ls) < 0:
        print(abs(max(ls)) - abs(min(ls)))

Fixed, accepted submission:
for i in range(7):
    a, b = map(int, input().split())
    print(a-b)
Problem:
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

Incorrect submission (verdict: Wrong Answer):
def main():
    n = int(input())
    res = 0
    if n<=8:
        for i in range(1,n):
            if n//i == n%i:
                res += n%i
    else:
        for i in range(1,int(n**(1/2))+1):
            if (n-i)/i == (n-i)//i and (n-i)//i>0:
                res += (n-i)//i 
    print(res)
if __name__ == '__main__':
    main()

Fixed, accepted submission:
def main():
    n = int(input())
    res = 0
    if n<=8:
        for i in range(1,n):
            if n//i == n%i:
                res += i
    else:
        for i in range(1,int(n**(1/2))):
            if (n-i)/i == (n-i)//i and (n-i)//i>0:
                res += (n-i)//i
    print(res)
if __name__ == '__main__':
    main()
Problem:
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.  Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests.    * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B.   * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students.  A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these.  Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.

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

ans = []
df = 0
f = 0

for i in range(N):
  s = S[i]
  if s == 'c':
    ans.append('No')
    continue
  elif s == 'a':
    df += 1
    if df <= A:
      ans.append('Yes')
    else:
      ans.append('No')
  elif s == 'b':
    df += 1
    f += 1
    if df <= A and f <= B:
      ans.append('Yes')
    else:
      ans.append('No')
      
print('\n'.join(ans))
      

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

C = A + B
ans = []
df = 0
f = 0

for i in range(N):
  s = S[i]
  if s == 'c':
    ans.append('No')
    continue
  elif s == 'a':
    df += 1
    if df <= C:
      ans.append('Yes')
    else:
      ans.append('No')
  elif s == 'b':
    df += 1
    f += 1
    if df <= C and f <= B:
      ans.append('Yes')
    else:
      df -= 1
      ans.append('No')
      
print('\n'.join(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):
r,g,b=map(int,input().split())
a=r*100+g*10+b
print('Yes' if a%4==0 else 'No')

Fixed, accepted submission:
r,g,b=map(str,input().split())
ans=int(r+g+b)
print('YES' if ans%4==0 else 'NO')
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 X - A in range(B):
    print("Yes")
else:
    print("No")

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

Incorrect submission (verdict: Wrong Answer):
if __name__=="__main__":
    [N, A, B] = map(int,input().split())
    xs = list(map(int,input().split()))
    d_xs = [xs[i] - xs[i-1] for i in range(1,len(xs))]
    print(d_xs)
    s = 0
    for d in d_xs:
        if(d*A < B):
            s+=d*A
        else:
            s+=B
    print(s)

Fixed, accepted submission:
if __name__=="__main__":
    [N, A, B] = map(int,input().split())
    xs = list(map(int,input().split()))
    d_xs = [xs[i] - xs[i-1] for i in range(1,len(xs))]
    s = 0
    for d in d_xs:
        if(d*A < B):
            s+=d*A
        else:
            s+=B
    print(s)
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
a=int(input())
print(a%1000)

Fixed, accepted submission:
a=int(input())
print((a//1000+min(a%1000,1))*1000-a)
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):
[r,g,b] = list(map(int, input().split()))
num = r*100+g*10+b
if num % 4 == 0:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
[r,g,b] = list(map(int, input().split()))
x = r*100 + g*10 + b
if x % 4 == 0:
  print("YES")
else:
  print("NO")
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

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

c = (a*b)%2

if c == 0:
  print("even")
  
else:
  print("odd")

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

c = (a*b)%2

if c == 0:
  print("Even")
  
else:
  print("Odd")
Problem:
You are given two positive integers A and B. Compare the magnitudes of these numbers.

Incorrect submission (verdict: Wrong Answer):
# vim: set fileencoding=utf-8:


def main():
    O = input()
    E = input()

    ans = ''
    for o, e in zip(O, E):
        ans += o + e

    if len(O) > len(E):
        ans += O[-1]
    elif len(O) < len(E):
        ans += E[-1]
    elif len(O) == len(E):
        pass

    print(ans)


if __name__ == "__main__":
    main()


Fixed, accepted submission:
# vim: set fileencoding=utf-8:


def main():
    A = int(input())
    B = int(input())
    if A == B:
        print('EQUAL')
    elif A > B:
        print('GREATER')
    elif A < B:
        print('LESS')


if __name__ == "__main__":
    main()
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())
if a+k >= b:
    ans = [i for i in range(a,b+1)]
else:
    ans = []
    for i in range(k):
        ans.append(a+i)
        ans.append(b-i)
    ans = sorted(set(ans))
print(ans)

Fixed, accepted submission:
a,b,k=map(int,input().split())
if a+k >= b:
    ans = [i for i in range(a,b+1)]
else:
    ans = []
    for i in range(k):
        ans.append(a+i)
        ans.append(b-i)
    ans = sorted(set(ans))
for x in ans:
    print(x)
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

Incorrect submission (verdict: Wrong Answer):
N = input()
num_list = []
num_list.append(N[:1])
num_list.append(N[1:2])
num_list.append(N[2:3])
num_list.append(N[3:4])

n_1 = num_list[1:4]
n_2 = num_list[2:4]

same_list_1 = [0]
for m in n_1:
    if num_list[0] == m:
        same_list_1.append(m)
same_list_2 = [0]
for n in n_2:
    if num_list[1] == n:
        same_list_2.append(n)

len_1 = len(same_list_1)
len_2 = len(same_list_2)

if len_1 == 3:
    print('yes')
elif len_2 == 3:
    print('yes')
elif len_1 == 4:
    print('yes')
elif len_2 == 4:
    print('yes')
else:
    print('no')


Fixed, accepted submission:
n = input()
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')
Problem:
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_.  When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.  What is the abbreviation for the N-th round of ABC? Write a program to output the answer.

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

ans = []
for i in range(1, n + 1):
    x = i
    for j in range(100):
        if x % 2 == 0:
            x = int(x // 2)
            #ans.append(j)
        else:
            #ans.append(j)
            break
    ans.append(j)

#print(ans)
print(ans.index(max(ans)) + 1)


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

print("ABC" + str(n))
Problem:
Write a program which calculates the area and perimeter of a given rectangle.

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

print(a*b,a+a+b+b)

Fixed, accepted submission:
a,b=map(int,input().split())
print(a*b,a+a+b+b)
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):
r,g,b=input().split()
print('Yes' if int(r+g+b)%4==0 else 'No')

Fixed, accepted submission:
r,g,b=input().split()
num=int(r+g+b)
print('YES' if num%4==0 else 'NO')
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):
a,b,c,d = map(int,list(input()))
sum_abcd=a+b+c+d

gap = (sum_abcd-7)/2
ans = [a,'+',b,'+',c,'+',d]
if gap==0:
    print(''.join(map(str,ans)))
elif gap==(b+c+d):
    for i in range(1,len(ans),2):
        ans[i]='-'
    print(''.join(map(str,ans)))
elif gap in [b,c,d]:
    for i in range(2,len(ans),2):
        if ans[i]==gap:
            ans[i-1]='-'
            break
    print(''.join(map(str,ans)))
else:
    for i in range(2,len(ans)-1,2):
        for j in range(i+2,len(ans),2):
            if ans[i]+ans[j]==gap:
                ans[i-1]='-'
                ans[j-1]='-'
                break
    print(''.join(map(str,ans)))

            

        

    


Fixed, accepted submission:
s = list(map(int,list(input())))
a = s.pop(0)

bit_n = 3
for i in range(2**bit_n):
    sign = ['+']*3
    tmp = a
    for j in range(bit_n):
        if ((i>>j)&1):
            tmp+=s[j]
        else:
            tmp-=s[j]
            sign[j]='-'
    if tmp==7:
        print("{0}{1[0]}{2[0]}{1[1]}{2[1]}{1[2]}{2[2]}=7".format(a,sign,s));exit()
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())
num = []
for a_ in range(a+1):
    for b_ in range(b+1):
        for c_ in range(c+1):
            cal = a_ * 500 + b_ * 100 + c_ * 50
            num.append(cal)
print(num.count(6000))

Fixed, accepted submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
num = []
for a_ in range(a+1):
    for b_ in range(b+1):
        for c_ in range(c+1):
            cal = a_ * 500 + b_ * 100 + c_ * 50
            num.append(cal)
print(num.count(x))