TnT/CodeNet4Repair huggingface dataset:
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: Time Limit Exceeded):
a,b,c,d,e,f = map(int, input().split())
con = list()
s = list()
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
                w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w2,w3)
                con1 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                con.append(con1)
                s.append([x,y,v,w])
conm = max(con)
conin =con.index(conm)
t = s[conin]
# print(t)
ans1 = 100*a*t[0] + 100*b*t[1] + c*t[2] + d*t[3]
ans2 = c*t[2] + d*t[3]
print(ans1,ans2)


Fixed, accepted submission:
a,b,c,d,e,f = map(int, input().split())
s = [0,0,0,0]
con1 = 0
for x in range(31):
    for y in range(31):
        for v in range(1501):
            if x == y == 0:
                continue
            else:
                w1 = (f-(100*a*x + 100*b*y + c*v))//d
#                 w2 = (100*a*x + 100*b*y -c*v)//d
                w3 = ((100*a*x + 100*b*y)*e -c*v*100)//(100*d)
                w = min(w1,w3)
                con2 = 100*(c*v + d*w)/(100*a*x + 100*b*y +c*v +d*w)
                if con1 <= con2 and w >= 0:
                    con1 = con2
                    s = [x,y,v,w]
                else:
                    continue

ans1 = 100*a*s[0] + 100*b*s[1] + c*s[2] + d*s[3]
ans2 = c*s[2] + d*s[3]
print(ans1,ans2)
Problem:
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:    * For any two vertices painted in the same color, the distance between them is an even number.  Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
N=int(input())
s=[[]for i in range(N)]
c=[None]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    s[v-1].append(u)
    s[u-1].append(v)
def mu(n,l,co):
    for i in l:
        if c[i-1]==None:
            if co==1:
                c[i-1]=0
                mu(i,s[i-1],0)
            else:
                c[i-1]=1
                mu(i,s[i-1],1)
mu(1,s[0],0)
print(*c,sep="\n")

Fixed, accepted submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
N=int(input())
s=[[]for i in range(N)]
c=[None]*N
for i in range(N-1):
    u,v,w=map(int,input().split())
    s[v-1].append((u,w%2))
    s[u-1].append((v,w%2))
def mu(n,l,co):
    for i in l:
        if c[i[0]-1]==None:
            if co==i[1]%2:
                c[i[0]-1]=0
                mu(i,s[i[0]-1],0)
            else:
                c[i[0]-1]=1
                mu(i,s[i[0]-1],1)
mu(1,s[0],0)
print(*c,sep="\n")
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())
x = list([int(i) for i in input().split()])
cnt = 0
while True:
    flag = False
    for i in x:
        if i % 2:
            flag = True
            break
        else:
            i /= 2
    else:
        cnt += 1
    if flag:
        break
print(cnt)

Fixed, accepted submission:
N = int(input())
x = list(map(int, input().split()))
mn_lst = []
for i in x:
    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i >>= 1
    mn_lst.append(cnt)
    
print(min(mn_lst))
Problem:
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

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

ans = 0

even = 0
odd = 0
for a in A:
  if(a%2==0):
    even += 1

for i in range(len(A)):
  if(A[i]%2==0 and even == 2):
    A[i] += 1
  elif(A[i]%2==1 and even == 1):
    A[i] += 1

for a in A:
  ans += (max(A) - a) // 2

print(a)
      

Fixed, accepted submission:
A = list(map(int, input().split()))
 
even = 0
odd = 0
for a in A:
  if(a%2==0):
    even += 1
 
for i in range(len(A)):
  if(A[i]%2==0 and even == 2):
    A[i] += 1
  elif(A[i]%2==1 and even == 1):
    A[i] += 1
 
if(even == 2 or even == 1):
  ans = 1
else:
  ans = 0
 
for a in A:
  ans += (max(A) - a) // 2
 
print(ans)
Problem:
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.  Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.

Incorrect submission (verdict: Wrong Answer):


n=int(input())
A=[0]*n
for m in range(n):
 A[m]=int(input())

k=0
for i in range(n):
 for j in range(1,A[n-1]):
  if j==1:
   continue
  if j==(A[n-1]-1):
   k+=1
  if (A[i-1]%j)==0:
   break

print(j)



Fixed, accepted submission:

import math as mh
a=int(input())
A=[0]*a
x=0
for i in range(a):
 A[i]=int(input())
 for j in range(1,A[i]):
  if A[i]==2:
    x+=1
    continue
  if j==1:
   continue
  elif (A[i]%j)==0:
   break
  elif j>=mh.sqrt(A[i]):
   x+=1
   break
print(x)
Problem:
In this problem, we only consider strings consisting of lowercase English letters.  Strings s and t are said to be **isomorphic** when the following conditions are satisfied:    * |s| = |t| holds.   * For every pair i, j, one of the following holds:     * s_i = s_j and t_i = t_j.     * s_i \neq s_j and t_i \neq t_j.  For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not.  A string s is said to be in **normal form** when the following condition is satisfied:    * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison.  For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`.  You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.

Incorrect submission (verdict: Wrong Answer):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

l = 'abcdefghijklmnopqrstuvwxyz'
N = INT()

# ans = (N-1) * "a" + 


# p1 = "a" * N
q = ["a"]


    
    # while q:
a = "a"
k = [n for n in l[:N]]
# print(k)


kazu = []
for i in range(1, N):
    y = k[:i]
    u = k[:i+1]
    B = list(product(y, u))
    for b in B:
        # for c in b:
        kazu.append("".join(b))
kazu.sort()
print(*kazu, sep="\n")




    



Fixed, accepted submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = "abcdefghijk"


ans = 0

def dfs(a, mx):
    
    # while q:
    
    if len(a) == N:
        print(a)
        return
    for c in range(len(S[:mx+2])):
        t = a
        t += S[:mx+2][c]
        dfs(t, max(c, mx))

dfs("", -1)
Problem:
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B.  The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y.  One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control.  If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out.    * X < Z \leq Y   * x_1, x_2, ..., x_N < Z   * y_1, y_2, ..., y_M \geq Z  Determine if war will break out.

Incorrect submission (verdict: Wrong Answer):
n,m,x,y = map(int,input().split())
x_list = sorted(list(map(int,input().split())))
y_list = sorted(list(map(int,input().split())))
if x < y and x < y_list[0] and x_list[-1] < y:
    print('No war')
else:
    print('War')

Fixed, accepted submission:
n,m,x,y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))
x_list.append(x)
y_list.append(y)
if max(x_list) < min(y_list):
    print('No War')
else:
    print('War')
Problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.  Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
if a == b and b == c:
    print(1)
elif (a != b and b == c) or (a == b or b != c):
    print(2)
else:
    print(3)

Fixed, accepted submission:
a, b, c = map(int, input().split())
if a == b and b == c:
    print(1)
elif (a != b and b == c) or (a == b and b != c) or (a == c and a != b):
    print(2)
else:
    print(3)
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())
a = [input() for i in range(h)]
print(a)
print('#'*(w+2))
for i in a:
    print('#'+i+'#')
print('#'*(w+2))

Fixed, accepted submission:
h,w = map(int,input().split())
a = [input() for i in range(h)]
print('#'*(w+2))
for i in a:
    print('#'+i+'#')
print('#'*(w+2))
Problem:
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.  Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int, input().split())
s = [h//2+w//3+1, h//1+w//2+1]
if h%3 == 0 and w%3 == 0:
  s += [0]
if h%2 == 0:
  s += [h//2]
if w%2 == 0:
  s += [w//2]
print(min(s))

Fixed, accepted submission:
h,w = map(int, input().split())
s = [h//2+w//3+1, h//3+w//2+1, h, w]
if h%3 == 0 or w%3 == 0:
  s += [0]
if h%2 == 0:
  s += [h//2]
if w%2 == 0:
  s += [w//2]
print(min(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):
import math
n = int(input())
math.ceil(n/1000)*1000 - n

Fixed, accepted submission:
import math
n = int(input())
print(math.ceil(n/1000)*1000 - n)
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
half = maxA/2
t = 100000009
for i in range(N):
    print("i",i,"t",t,"Ai",A[i],)
    if abs(A[i]-half) < abs(t-half):
        t = A[i]
print(maxA,t)

Fixed, accepted submission:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))


maxA = max(A)
half = maxA/2

t = 10**10
for i in range(N):
    
    if A[i] != maxA and abs(A[i]-half) < abs(t-half):
        t = A[i]

print(maxA,t)
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
N,L = map(int,input().split())
wordlist = []
for i in range(N):
    x = input()
    wordlist.append(x)

print(sorted(wordlist))
            





Fixed, accepted submission:
N,L = map(int,input().split())
wordlist = []
for i in range(N):
    x = input()
    wordlist.append(x)

answer = "".join(sorted(wordlist))
print(answer)
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):
n = int(input())
print(n%1000)

Fixed, accepted submission:
n = int(input())
if n % 1000 == 0:
    print(n % 1000)
else:
    print(1000 - (n % 1000))
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+1, a):
    if i % b == c:
        print('Yes')
        exit()

print('No')


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

for i in range(a, a*b+1, a):
    if i % b == c:
        print('YES')
        exit()

print('NO')
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="dreamerer"

s=s.replace('eraser','').replace('erase','').replace('dreamer','').replace('dream','')

if len(s)==0:print("YES")
else:print("NO")    


Fixed, accepted submission:
s=input()
s=s.replace('eraser','0').replace('erase','0').replace('dreamer','0').replace('dream','0')
s=s.replace('0','')

if len(s)==0:print("YES")
else:print("NO")
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):
N = int(input())
a = 0
w = 0
t = 0
r = 0
for i in range(N):
    i = input()
    if i == 'AC':
        a += 1
    elif i == 'WA':
        w += 1
    elif i == 'TLE':
        t += 1
    else:
        r += 1

print('AC × ' + str(a))
print('WA × ' + str(w))
print('TLE × ' + str(t))

print('RE × ' + str(r))

Fixed, accepted submission:
N = int(input())
a, w, t, r = 0, 0, 0, 0
for _ in range(N):
    S = input()
    if S == 'AC':
        a += 1
    elif S == 'WA':
        w += 1
    elif S == 'TLE':
        t += 1
    else:
        r += 1
print('AC x ' + str(a))
print('WA x ' + str(w))
print('TLE x ' + str(t))
print('RE x ' + str(r))
Problem:
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.  The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.  How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?

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

ans = (n-a+1)+(n-b+1)

print(ans)

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

ans = (n-a+1)*(n-b+1)

print(ans)
Problem:
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second.  He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    a, v = rli()
    b, w = rli()
    t = ri()
    if t*(v-w) >= abs(a-b):
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()


Fixed, accepted submission:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    a, v = rli()
    b, w = rli()
    t = ri()
    if t*(v-w) >= abs(a-b):
        print("YES")
    else:
        print("NO")



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

P = 0

for i in range(1,n):
    P += i
    
print(P)

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

P = 0

for i in range(1,n+1):
    P += i
    
print(P)
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):
def Haiku(check,syllables):
    check.sort()
    syllables.sort()
    if check==syllables:
        return "YES"
    else:
        return "NO"

Fixed, accepted submission:
syllables=[5,5,7]
check=list(map(int,input().split()))
check.sort()
syllables.sort()
if check==syllables:
    print("YES")
else:
    print("NO")
Problem:
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i.  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
ls_s = [input() for _ in range(n)]
m = int(input())
ls_t = [input() for _ in range(m)]

ls_u =ls_s + ls_t
p = m + n 

ans = 0

for i in range(n):
    cnt = 0
    for j in range(p):
        if ls_u[i] == ls_u[j] and j < n - 1:
            cnt += 1
        elif ls_u[i] == ls_u[j] and n - 1 <= j:
            cnt += -1
    if cnt >= ans:
        ans = cnt

print(ans)

Fixed, accepted submission:
n = int(input())
ls_s = [input() for _ in range(n)]
m = int(input())
ls_t = [input() for _ in range(m)]

ls_u =ls_s + ls_t
p = m + n 

ans = 0


for i in range(n):
    cnt = 0
    for j in range(p):
        if ls_u[i] == ls_u[j] and j <= n - 1:
            cnt += 1
        elif ls_u[i] == ls_u[j] and n - 1 < j:
            cnt += -1
    if cnt >= ans:
        ans = cnt

print(ans)