TnT/CodeNet4Repair huggingface dataset:
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: Time Limit Exceeded):
n=int(input())
flag=0
nums=list(map(int,input().split()))
cnt=0

while flag==0:
    for i in range(n):
        num=nums[0]/2
        key=nums[0]%2
        if key==1:
            flag==1
            break
        else:
            del nums[0]
            nums.append(num)
    if flag==0:
        cnt+=1
print(cnt)

Fixed, accepted submission:
n=int(input())
nums=list(map(int,input().split()))
cnt=0
flag=0
while flag is 0:
    for i in range(n):
        num=nums[0]/2
        key=nums[0]%2
        if key==1:
            flag=1
            break
        else:
            del nums[0]
            nums.append(num)
    if flag==0:
        cnt+=1

print(cnt)
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())

if a%2 == 0 and b%2 == 0:
    print('Even')
else:
    print('Odd')

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

if a%2 == 0 or b%2 == 0:
    print('Even')
else:
    print('Odd')
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):
import numpy as np

input()
A = np.array(list(map(int, input().split())))

ans = 0
while(all(A%2==0)):
    A = A/2
    ans += 1

print(ans)

Fixed, accepted submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500+b*100+c*50 == X:
                ans += 1

print(ans)
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

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

n = int(input())

s = [input() for _ in range(n)]
print(s)

c0=0
c1=0
c2=0
c3=0
for i in s:
    if i == "AC":
        c0+=1
    elif i == "WA":
        c1+=1
    elif i == "TLE":
        c2+=1
    else:
        c3+=1

print("AC x",c0)
print("WA x",c1)
print("TLE x",c2)
print("RE x",c3)


Fixed, accepted submission:
#! python3
# coding:utf-8

n = int(input())

s = [input() for _ in range(n)]
# print(s)

c0=0
c1=0
c2=0
c3=0
for i in s:
    if i == "AC":
        c0+=1
    elif i == "WA":
        c1+=1
    elif i == "TLE":
        c2+=1
    else:
        c3+=1

print("AC x",c0)
print("WA x",c1)
print("TLE x",c2)
print("RE x",c3)
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

Incorrect submission (verdict: Wrong Answer):
N, M = map(int, input().split())
c = []
for i in range(M):
	c.append(list(map(int, input().split())))

for i in range(M):
	if c[i][0] == 1:
		for j in range(M):
			if c[j][0] == c[i][0]:
				if c[j][1] == N:
					print('POSSIBLE')
					exit()

print('IMPOSSIBLE')

Fixed, accepted submission:
N, M = map(int, input().split())
c = []
for i in range(M):
	c.append(list(map(int, input().split())))
d = []
e = []


for i in range(M):
	if c[i][0] == 1:
		d.append(c[i][1])

for i in range(M):
	if c[i][1] == N:
		e.append(c[i][0])

l = list(set(d) & set(e))

if l == []:
	print('IMPOSSIBLE')
else:
	print('POSSIBLE')
Problem:
You are given three strings A, B and C. Check whether they form a _word chain_.  More formally, determine whether both of the following are true:    * The last character in A and the initial character in B are the same.   * The last character in B and the initial character in C are the same.  If both are true, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:
  print('YES')
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())
print(int(a*b*h/2))

Fixed, accepted submission:
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
Problem:
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.  Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.  Find the maximum possible sum of the values of items that Taro takes home.

Incorrect submission (verdict: Wrong Answer):
n,W = [int(e) for e in input().split()]
v = list([0]*n)
w = list([0]*n)

for i in range(n):
    w[i],v[i] = [int(e) for e in input().split()]

dp = [[0]*(W+1) for _ in range(n)]

for i in range(n-1):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]] + v[i],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n-1][W])

Fixed, accepted submission:
import numpy as np
n,W = [int(e) for e in input().split()]
v = np.zeros(n,dtype='int64')
w = np.zeros(n,dtype='int64')

for i in range(n):
    w[i],v[i] = [int(e) for e in input().split()]

dp = np.zeros(W+1,dtype='int64')

for i in range(n):
    dp[w[i]:] = np.maximum(dp[:W-w[i]+1]+v[i],dp[w[i]:])

print(dp[-1])
Problem:
You are playing the following game with Joisino.    * Initially, you have a blank sheet of paper.   * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.   * Then, you are asked a question: How many numbers are written on the sheet now?  The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
temp=set()
for i in range(0,n):
  a=int(input())
  if a not in temp:
    temp.add(str(a))
  else:
    temp.remove(str(a))
print(len(temp))

Fixed, accepted submission:
n=int(input())
temp=set()
for i in range(0,n):
  a=int(input())
  if a not in temp:
    temp.add(a)
  else:
    temp.discard(a)
print(len(temp))
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())
num = a * b
mod = num % 2

if mod == 0:
  print("EVEN")
else:
  print("0dd")

Fixed, accepted submission:
a,b = map(int,input().split())
if a*b%2==0:
  print("Even")
else:
  print("Odd")
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())

li = [2**i for i in range(7)]

for i, x in enumerate(li, 1):
    if N < li[len(li)-i]:
        print(li[len(li)-i-1])
        break
    else:
        continue


Fixed, accepted submission:
#!/usr/bin/env python3
N = int(input())

if N >= 64:
    N = 64
elif N >= 32:
    N = 32
elif N >= 16:
    N = 16
elif N >= 8:
    N = 8
elif N >= 4:
    N = 4
elif N >= 2:
    N = 2
elif N == 1:
    N = 1

print(N)
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):
s = list(input().split())[1]
print("A"+s+"C")

Fixed, accepted submission:
s = list(input().split())[1]
print("A"+s[0]+"C")
Problem:
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Incorrect submission (verdict: Wrong Answer):
A=list(input().split())
for i in range(110):
    if int(A[0]+A[1])==i**2:
        ans='YES'
        break
    else:
        ans='No'
print(ans)

Fixed, accepted submission:
c=int(input().replace(" ",""))
print("Yes" if c==int(c**.5)**2 else "No")
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):
import sys
import math
X = int(input())
i = 1
k = int(100*1.01)
while 1:
  if X < k:
    break
  k = int(k * 1.01)
  i += 1
  
print(i)

Fixed, accepted submission:
import sys
import math
X = int(input())
i = 1
k = int(100*1.01)
while 1:
  if X <= k:
    break
  k = int(k * 1.01)
  i += 1
  
print(i)
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):
o=list(input())
e=list(input())+[""]
for x,y in zip(o,e):print(x+y)

Fixed, accepted submission:
o = input()
e = input()

answer = ''

for s,t in zip(o,e):
  answer += s
  answer += t

  
if len(o) > len(e):
  answer += o[-1]

print(answer)
Problem:
Write a program which reads an integer and prints sum of its digits.

Incorrect submission (verdict: Wrong Answer):
print(sum([int(i) for i in input()]))

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

Incorrect submission (verdict: Wrong Answer):
n, m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]

print('No')

Fixed, accepted submission:
from collections import deque
n, m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]

q = deque([])
path = [-1] * n
ver = [[] for _ in range(n)]
for i in range(m):
    ab[i].sort()
    if ab[i][0] == 1:
        q.append([ab[i][0]-1,ab[i][1]-1])
        #path[ab[i][1]-1] = 1
    ver[ab[i][0]-1].append(ab[i][1]-1)
    ver[ab[i][1]-1].append(ab[i][0]-1)

def bfs(q, visited_list):
    while len(q) > 0:
        now = q.popleft()
        go = now[1]
        if visited_list[go] == -1:
            visited_list[go] = now[0]+1
            for i in range(len(ver[go])):
                q.append([go,ver[go][i]])
    return visited_list
ans = bfs(q,path)
print('Yes')
for i in range(1,n):
    print(ans[i])
Problem:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).  First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.  How much do you have left after shopping?

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

X1 = A - X

Dcount = X1 // B

Dprice = B * Dcount

print(X1 - Dprice)

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

X1 = X -A
print(X1 % B)
Problem:
Snuke, who loves animals, built a zoo.  There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.  There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.  Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species.  More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise.  Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.

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





pat = [(0,0),(0,1),(1,0),(1,1)]
fl = False

for p in pat:
  ans = []
  x_now = p[0]
  x_prev = p[1]
  ans.append(x_now)
  for i in range(N):
    if ST[i] == 'o':
      if x_now == 0:
        x_next = x_prev
      else:
        x_next = 1 - x_prev
    else:
      if x_now == 0:
        x_next = 1 - x_prev
      else:
        x_next = x_prev
  
    x_prev, x_now = x_now, x_next
    ans.append(x_next)

  #print(p, ans)
  if ans[-1] == ans[0]:
    #correct case
    fl = True
    break

if fl:
  for i in range(N):
    print("S" if ans[i] == 0 else "W", end="")
else:
  print("-1")
  

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





pat = [(0,0),(0,1),(1,0),(1,1)]
fl = False

for p in pat:
  ans = []
  x_now = p[0]
  x_prev = p[1]
  ans.append(x_now)
  for i in range(N):
    if ST[i] == 'o':
      if x_now == 0:
        x_next = x_prev
      else:
        x_next = 1 - x_prev
    else:
      if x_now == 0:
        x_next = 1 - x_prev
      else:
        x_next = x_prev
  
    #print(i, ST[i], x_prev, x_now, x_next)
    ans.append(x_next)
    x_prev, x_now = x_now, x_next

  #if ans[-1] == ans[0]:
  if ans[-2] == p[1] and ans[-1] == ans[0]:
    #correct case
    fl = True
    #print(ans)
    break

if fl:
  for i in range(N):
    print("S" if ans[i] == 0 else "W", end="")
  print()
else:
  print("-1")
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):
# C - 100 to 105


x = int(input())
d, m = divmod(x, 100)

D = [0] * 5

for i in range(4, -1, -1):
  D[i], m = divmod(m, i + 1)

print(D)

if d >= sum(D):
  print(1)
else:
  print(0)

Fixed, accepted submission:
# C - 100 to 105


x = int(input())
d, m = divmod(x, 100)

D = [0] * 5

for i in range(4, -1, -1):
  D[i], m = divmod(m, i + 1)

if d >= sum(D):
  print(1)
else:
  print(0)
Problem:
Write a program which reads two integers a and b, and calculates the following values:    * a ÷ b: d (in integer)   * remainder of a ÷ b: r (in integer)   * a ÷ b: f (in real number)

Incorrect submission (verdict: Wrong Answer):
n = list(map(int, input().split()))
a = n[0]
b = n[1]
d = a // b
r = a % b
f = a / b
print('{} {} {}'.format(d, r, f))

Fixed, accepted submission:
n = list(map(int, input().split()))
a = n[0]
b = n[1]
d = a // b
r = a % b
f = a / b
print('{} {} {:.5f}'.format(d, r, f))
Problem:
Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each.  Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
tarou = 0
hanako = 0
for x in range(n):
    if hanako > tarou:
        hanako += 3
    elif tarou > hanako:
        tarou += 3
    else:
        tarou += 1
        hanako += 1
print("{0} {1}".format(tarou, hanako))

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

tarou = 0
hanako = 0

for x in range(i):
    a,b = input().split()
    if b > a:
        hanako += 3
    elif a > b:
        tarou += 3
    else:
        hanako += 1
        tarou += 1
print("{0} {1}".format(tarou, hanako))
Problem:
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:    * The graph is simple and connected.   * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.  It can be proved that at least one such graph exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N = int(input())
    else:
        pass

    T = np.asarray([False]*(N**2))
    T = T.reshape(N,N)
    Res = np.copy(T)
    range_N = np.asarray(range(N))
    #range_N += 1

    if N % 2 == 0:
        for i,j in zip(range_N,range_N[::-1]):
            if i >= j: break
            T[i,j] = True
    else:
        for i,j in zip(range_N,range_N[:-1:-1]):
            if i >= j: break
            T[i,j] = True

    Res[T==True] = False
    Res[T==False] = True
    
    for i in range_N:
        Res[i,i] = False

    #print(Res)

    for i in range_N:
        for j in range_N[i:]:
            if Res[i,j] == True: print(i+1,j+1)
if __name__ =='__main__':
    main()

Fixed, accepted submission:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N = int(input())
    else:
        pass

    T = np.asarray([False]*(N**2))
    T = T.reshape(N,N)
    Res = np.copy(T)
    range_N = np.asarray(range(N))
    #range_N += 1

    if N % 2 == 0:
        for i,j in zip(range_N,range_N[::-1]):
            if i >= j: break
            T[i,j] = True
            T[j,i] = True
    else:
        for i,j in zip(range_N,range_N[::-1]):
            j -= 1
            if i >= j: break
            T[i,j] = True
            T[j,i] = True

    Res[T==True] = False
    Res[T==False] = True
    
    for i in range_N:
        Res[i,i] = False

    #print(Res)
    print(Res[Res].size//2)

    for i in range_N:
        for j in range_N[i:]:
            if Res[i,j] == True: print(i+1,j+1)
if __name__ =='__main__':
    main()
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):
import math

def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(math.sqrt(n))):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)


Fixed, accepted submission:
def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(n ** 0.5)+1):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)
Problem:
We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this:                 1 2 3 4 5 6 7 8 9 . . . N N . . . 9 8 7 6 5 4 3 2 1   Two numbers faced each other form a pair. Your task is to compute the number of pairs P such that both numbers in the pairs are prime.

Incorrect submission (verdict: Wrong Answer):
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0

while True:
    try:
        N = int(input())
    except:
        break
    print(sum(primes[i] & primes[-i] for i in range(1, N+1)))

Fixed, accepted submission:
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0

while True:
    try:
        N = int(input())
    except:
        break
    print(sum(primes[i] and primes[N-i+1] for i in range(1, N+1)))