TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

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

for i in range(X, 0, -1):
    tmp = int(math.sqrt(i))
    if tmp*tmp == i:
        print(tmp)
        break


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

ans = 1
for i in range(1, X):
    for j in range(2, X):
        tmp = i ** j
        if tmp > X:
            break
        ans = max(tmp, ans)
print(ans)
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):
input_str = input()
input = input_str.split(' ')
a = int(input[0])
b = int(input[1])
c = int(input[2])

if a <= c and c <= b:
    print('YES')
else:
    print('NO')


Fixed, accepted submission:
input_str = input()
input = input_str.split(' ')
a = int(input[0])
b = int(input[1])
c = int(input[2])

if a <= c and c <= b:
    print('Yes')
else:
    print('No')
Problem:
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi.  How many ways are there to choose K consecutive integers?

Incorrect submission (verdict: Wrong Answer):
n,k = map(int,input().split())
print(n*(n+1)//2)

Fixed, accepted submission:
n,k = map(int,input().split())
print(n-k+1)
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):
import itertools
n,m = list(map(int,input().split()))

a = []
for i in range(m):
    b = (list(map(int,input().split())))
    b = [b[0]-1,b[1]-1]
    a.append(b)

b = [[0 for i in range(n)] for j in range(n)]
for i in a:
    b[i[0]][i[1]] = 1
    b[i[1]][i[0]] = 1


c = [i+1 for i in range(n-1)]
ans = 0
for i in itertools.permutations(c,n-1):
    j = [0]
    j += i
    count = 0
    for i in range(n-1):
        if b[j[i]][j[i+1]] == 1:
            count += 1
            if count == n-1:
                ans += 1
                count = 0
        else:
            break
print(ans)

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

a = []
for i in range(m):
    a.append(list(map(int,input().split())))

b = [[0 for i in range(n)] for j in range(n)]

for i in a:
    b[i[1]-1][i[0]-1] = 1
    b[i[0]-1][i[1]-1] = 1
c = [sum(b[i]) for i in range(n)]
ans = 0
while 1 in c:
    d = c.index(1)
    e = b[d].index(1)
    b[e][d] = 0
    b[d][e] = 0
    c = [sum(b[i]) for i in range(n)]
    ans += 1
print(ans)
Problem:
M-kun has the following three cards:    * A red card with the integer A.   * A green card with the integer B.   * A blue card with the integer C.  He is a genius magician who can do the following operation at most K times:    * Choose one of the three cards and multiply the written integer by 2.  His magic is successful if both of the following conditions are satisfied after the operations:    * The integer on the green card is **strictly** greater than the integer on the red card.   * The integer on the blue card is **strictly** greater than the integer on the green card.  Determine whether the magic can be successful.

Incorrect submission (verdict: Wrong Answer):
r,g,b = map(int,input().split())
k = int(input())
t=0
t+=k
for i in range(k):
    if(b<=r):
        b*=2
        t-=1
        
    elif(b>r and b<=g):
        b*=2
        t-=1
        
    elif(b>r and b>g and g<=r):
        g*=2
        t-=1
        
        
    if(t==0):
        break
    
if(g>r and b>g):print("YES")
else:print("NO")
    
    

Fixed, accepted submission:
r,g,b = map(int,input().split())
k = int(input())
t=0
t+=k
for i in range(k):
    if(b<=r):
        b*=2
        t-=1
        
    elif(b>r and b<=g):
        b*=2
        t-=1
        
    elif(b>r and b>g and g<=r):
        g*=2
        t-=1
        
        
    if(t==0):
        break
    
if(g>r and b>g):print("Yes")
else:print("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):
l = input().split()
a = l[0]
b = l[1]
x = l[2]
if a > x or a + b < x:
    print('No')
else:
    print('Yes')


Fixed, accepted submission:
l = input().split()
a = int(l[0])
b = int(l[1])
x = int(l[2])

if (a > x) or (a + b < x):
    print('NO')
else:
    print('YES')
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Wrong Answer):
from collections import Counter

def main(N):
    lst = []
    for x in range(1, 142):
        for y in range(1, 142):
            for z in range(1, 142):
                r = (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2
                if r <= 2 * 10 ** 4:
                    lst.append(r // 2)
                else:
                    break
    c = Counter(lst)
    st = set(lst)

    for n in range(1, N):
        if n in st:
            print(c[n])
        else:
            print(0)


if __name__ == '__main__':
    N = int(input())
    main(N)

Fixed, accepted submission:
from collections import Counter

def main(N):
    lst = []
    for x in range(1, 142):
        for y in range(1, 142):
            for z in range(1, 142):
                r = (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2
                if r <= 2 * 10 ** 4:
                    if r % 2 == 1:
                        print('奇数')
                    lst.append(r // 2)
                else:
                    break
    c = Counter(lst)
    st = set(lst)

    for n in range(1, N+1):
        if n in st:
            print(c[n])
        else:
            print(0)


if __name__ == '__main__':
    N = int(input())
    main(N)
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):
abcd = input()


def dfs(i, f, sum):
  print(i,f,sum)
  if i == 3:
    if sum ==7:
      print(f + '=7')
      exit()
    
  else:
    dfs(i+1, f + '+' + abcd[i+1], sum + int(abcd[i+1]))
    dfs(i+1, f + '-' + abcd[i+1], sum - int(abcd[i+1]))

f = abcd[0]
dfs(0, f, int(f))

Fixed, accepted submission:
s = input()

for bit in range(1<<len(s)):
  f = s[0]
  ans = int(s[0])
  for i in range(1,len(s)):
    if bit & 1<<i:
      f = f + '+' + s[i]
      ans += int(s[i])
    else:
      f = f + '-' + s[i]
      ans -= int(s[i])
  
  if ans == 7:
    print(f + '=7')
    exit()
Problem:
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.   According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.   Determine if he is correct.

Incorrect submission (verdict: Wrong Answer):
c = [list(map(int, input().split())) for _ in range(3)]
b0, b1, b2 = c[0][0], c[0][1], c[0][1]
for i in range(1, 3):
    if not ((c[i][0]-b0)==(c[i][1]-b1)==(c[i][2]-b2)):
        print('No')
        exit()
print('Yes')

Fixed, accepted submission:
c = [list(map(int, input().split())) for _ in range(3)]
b0 = c[0][0]
b1 = c[0][1]
b2 = c[0][2]
for i in range(1, 3):
    a0 = c[i][0] - b0
    a1 = c[i][1] - b1
    a2 = c[i][2] - b2
    if not a0 == a1 == a2:
        print('No')
        exit()
print('Yes')
Problem:
Compute A \times B, truncate its fractional part, and print the result as an integer.

Incorrect submission (verdict: Wrong Answer):
a, b = input().split()
a = int(a)
b = float(b) * 100
print(str(a*b)[:-2])

Fixed, accepted submission:
a, b = input().split()
a = int(a)
b = int(b.replace(".",""))
print((a*b)//100)
Problem:
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?

Incorrect submission (verdict: Wrong Answer):
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math










'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''







N = int(stdin.readline().rstrip())
N = (N-1) / 2
print(N)


Fixed, accepted submission:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math


N = int(stdin.readline().rstrip())
N = int((N-1) / 2)
print(N)
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

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

if a+b == c and a+c == b and b+c==a:
    print("Yes")
else:
    print("No")

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

if a+b == c or a+c == b or b+c==a:
    print("Yes")
else:
    print("No")
Problem:
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if a+b%2 == 0:
    print((a+b)//2)

else:
    print((a+b)//2 + 1)

Fixed, accepted submission:
a, b = map(int, input().split())
if (a+b)%2 == 0:
    print((a+b)//2)

else:
    print((a+b)//2 + 1)
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())
su =0
for i in range(1,N+1):
  si = str(i)
  c = 0
  for s in si:
    c += int(s)
  if A <= c <= B:
    su += c
print(su)
  
  

Fixed, accepted submission:
N, A, B = map(int,input().split())
su =0
for i in range(1,N+1):
  si = str(i)
  c = 0
  for s in si:
    c += int(s)
  if A <= c <= B:
    su += i
print(su)
Problem:
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:    * Operation A: The displayed value is doubled.   * Operation B: The displayed value increases by K.  Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
K = int(input())
C = N*K
if K == 0:
 B=0
elif K == 1 or 2:
 B=1
elif K==3:
 B=2
elif K== 4 or 5 or 6 or 7 or 8:
 B=3
elif K==9 or 10:
 B=4
p=0
i=1
while p<B:
 i=i*2
 p=p+1
A=N-B
print(i+A*K)


Fixed, accepted submission:
a = int(input())
b = int(input())
ans = 1
for i in range(a):
  ans = min(ans * 2,ans + b)
print(ans)
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= [int(i) for i in input().split()]

if (b - a) == (c - b):
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
a, b, c= [int(i) for i in input().split()]

if (b - a) == (c - b):
  print("YES")
else:
  print("NO")
Problem:
Niwango-kun is an employee of Dwango Co., Ltd.   One day, he is asked to generate a thumbnail from a video a user submitted.   To generate a thumbnail, he needs to select a frame of the video according to the following procedure:    * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video.   * Select t-th frame whose representation a_t is nearest to the average of all frame representations.   * If there are multiple such frames, select the frame with the smallest index.  Find the index t of the frame he should select to generate a thumbnail.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = list(map(int,input().split()))
c = sum(b)/a
d = []
for i in b:
    d.append(abs(i-c))
    print(d)
print(d.index(min(d)))

Fixed, accepted submission:
a = int(input())
b = list(map(int,input().split()))
c = sum(b)/a
d = []
for i in b:
    d.append(abs(i-c))
print(d.index(min(d)))
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Wrong Answer):
a = input()
while not "?" in a:
    print(eval(a))
    a = input()


Fixed, accepted submission:
a = input()
while not "?" in a:
    print(int(eval(a)))
    a = input()
Problem:
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.  In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.  When activated, each type of robot will operate as follows.    * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.    * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.  Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
k = int(input())
x_l = list(map(int, input().split()))
th = k/2

ans = 0
for x in x_l:
  if x >= th:
    ans += abs(x-k)
  else:
    ans += x
print(ans)
    

Fixed, accepted submission:
n = int(input())
k = int(input())
x_l = list(map(int, input().split()))
th = k/2

ans = 0
for x in x_l:
  if x >= th:
    ans += abs(x-k)
  else:
    ans += x
print(ans*2)
Problem:
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.    * Operation 1: Pour 100A grams of water into the beaker.   * Operation 2: Pour 100B grams of water into the beaker.   * Operation 3: Put C grams of sugar into the beaker.   * Operation 4: Put D grams of sugar into the beaker.  In our experimental environment, E grams of sugar can dissolve into 100 grams of water.  Snuke will make sugar water with the highest possible density.  The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted.  We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.

Incorrect submission (verdict: Wrong Answer):
A,B,C,D,E,F = map(int,input().split())

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,31):
    for j in range(1,31):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(120):
    for j in range(120):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)
print(ans[0][1],ans[0][2])

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

MAX_SUGER = E*F/(E+100)


water = [min(A,B)*100,max(A,B)*100]
for i in range(1,31):
    for j in range(1,31):
        water.append(100*A*i+100*B*j)
water = sorted(list(set(water)))

suger = []
for i in range(101):
    for j in range(101):
        if C*i + D*j <= MAX_SUGER:
            suger.append(C*i+D*j)
suger = sorted(list(set(suger)))

ans = []
for s in suger:
    min_water = 100*s/E
    for w in water:
        if w >= min_water:
            ans.append([s/(w+s),w+s,s])
            break
ans.sort(reverse=True)

for c,w,s in ans:
    if w <= F:
        print(w,s)
        break
Problem:
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.

Incorrect submission (verdict: Wrong Answer):
lis=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,216,36,343,49,100,1000]
for i in range(11,32):
    t=i*i
    lis.append(t)
listt=list(set(lis))
listt=sorted(listt)
print(listt)
a=int(input())
for i in range(300):
    if a <= listt[i]:
        print (listt[i-1])
        break

Fixed, accepted submission:
lis=[1,2,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,216,36,343,49,100,1000]
for i in range(11,32):
    t=i*i
    lis.append(t)
listt=list(set(lis))
listt=sorted(listt)
a=int(input())
for i in range(300):
    if a < listt[i]:
        print (listt[i-1])
        break
    elif a == listt[i]:
        print(listt[i])
        break
Problem:
JOI君は小学 1 年生である．JOI君は教わったばかりの足し算，引き算がとても好きで，数字が並んでいるのを見ると最後の 2 つの数字の間に「=」を入れ，残りの数字の間に必ず「+」または「-」を入れて等式を作って遊んでいる．例えば「8 3 2 4 8 7 2 4 0 8 8」から，等式「8+3-2-4+8-7-2-4-0+8=8」を作ることができる．  JOI 君は等式を作った後，それが正しい等式になっているかを計算して確かめる．ただし，JOI君はまだ負の数は知らないし，20 を超える数の計算はできない．したがって，正しい等式のうち左辺を左から計算したとき計算の途中で現れる数が全て 0 以上 20 以下の等式だけがJOI君が確かめられる正しい等式である．例えば，「8+3-2-4-8-7+2+4+0+8=8」は 正しい等式だが，途中に現れる 8+3-2-4-8 が負の数なのでJOI君はこの等式が正しいかどうか確かめることができない．  入力として数字の列が与えられたとき，JOI君が作り，確かめることができる正しい等式の個数を求めるプログラムを作成せよ．

Incorrect submission (verdict: Wrong Answer):



n = int(input())
A = list(map(int,input().split()))
m = A.pop()
maxN = sum(A)
dp = [[0 for i in range(maxN + 1)] for _ in A]
for i in range(len(A)):
  for j in range(maxN + 1):
    if i == 0:
      dp[0][A[i]] = 1
    else:
      if j - A[i] >= 0:
        dp[i][j] += dp[i - 1][j - A[i]]
      if j + A[i] <= maxN:
        dp[i][j] += dp[i - 1][j + A[i]]

print(dp[len(A) - 1][m])



Fixed, accepted submission:



n = int(input())
A = list(map(int,input().split()))
m = A.pop()
maxN = min(sum(A), 20)
dp = [[0 for i in range(maxN + 1)] for _ in A]
for i in range(len(A)):
  for j in range(maxN + 1):
    if i == 0:
      dp[0][A[i]] = 1
    else:
      if j - A[i] >= 0:
        dp[i][j] += dp[i - 1][j - A[i]]
      if j + A[i] <= maxN:
        dp[i][j] += dp[i - 1][j + A[i]]

print(dp[len(A) - 1][m])
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python3
# import sys, math, itertools, heapq, collections, bisect, fractions


inf = float('inf')
ans = count = 0

a,b,c=map(int,input().split())
print(0)

#     if i[0]==sum(i[1:]) or sum(i[:2])==i[2]:
#         print("Yes")
#         exit()

# print("No")z

Fixed, accepted submission:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

a,b,c=map(int,input().split())
# print(0)
for i in itertools.permutations([a,b,c],3):
    if i[0]==sum(i[1:]) or sum(i[:2])==i[2]:
        print("Yes")
        exit()

print("No")
Problem:
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.

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



min0 = 1000000
max0 = -10000000
sum0 = 0
for x in ns:
    min0 = min(min0, x)
    max0 = max(max0, x)
    sum0 += x
    
    print(min0,max0,sum0)


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

print(min(ns), max(ns), sum(ns))
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())
h = S / 3600
m = S / 60
s = S % 3600
print(h,':', m, ':', s, ':')

Fixed, accepted submission:
S = int(input())
h = S // 3600
m = S % 3600 // 60
s = S % 60
print(h, m, s, sep = ':')
Problem:
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately.  He has very high awareness of safety, and decides to buy two bells, one for each hand.  The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.

Incorrect submission (verdict: Wrong Answer):
import numpy as np

a,b,c = map(int,input().split())
np.sum(np.sort([a,b,c])[0:2])

Fixed, accepted submission:
import numpy as np

a,b,c = map(int,input().split())
ans = np.sum(np.sort([a,b,c])[0:2])
print(ans)