TnT/CodeNet4Repair huggingface dataset:
Problem:
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen.  Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .

Incorrect submission (verdict: Wrong Answer):

if __name__ == "__main__":
    n = int(input())
    r0 = int(input())
    r1 = int(input())
    minv = r0 if r0 <= r1 else r1
    maxv = r1 - r0
    for i in range(2, n):
        r = int(input())
        if maxv >= (r-minv):
            maxv = r-minv
        if r <= minv:
            minv = r
    print(maxv) 



Fixed, accepted submission:

if __name__ == "__main__":
    n = int(input())
    r0 = int(input())
    r1 = int(input())
    minv = r0 if r0 <= r1 else r1
    maxv = r1 - r0
    for i in range(2, n):
        r = int(input())
        maxv = max(maxv, (r-minv))
        minv = min(minv, r)
    print(maxv)
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Incorrect submission (verdict: Wrong Answer):
a,b=map(int,input().split())
if a/b >= 2:
  print('YES')
else:
  print('NO')

Fixed, accepted submission:
a,b=map(int,input().split())
if (a+1)/b >= 2:
  print('YES')
else:
  print('NO')
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):
import copy

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

max_v = max(a,b,c)


if max_v == b:
    tmp = a
    a = b
    b = tmp
elif max_v == c:
    tmp = a
    a = c
    c = tmp

tmp_b = (a-b) // 2
tmp_c = (a-c) // 2

if a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 2:
    ans = tmp_b + tmp_c + 1
elif a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 0:
    ans = tmp_b + tmp_c
else:
    ans = tmp_b + tmp_c + 2

print(tmp_b,tmp_c)

print(ans)

Fixed, accepted submission:
import copy

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

max_v = max(a,b,c)


if max_v == b:
    tmp = a
    a = b
    b = tmp
elif max_v == c:
    tmp = a
    a = c
    c = tmp

tmp_b = (a-b) // 2
tmp_c = (a-c) // 2

if a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 2:
    ans = tmp_b + tmp_c + 1
elif a - (b + 2 * tmp_b) + a - (c + 2 * tmp_c) == 0:
    ans = tmp_b + tmp_c
else:
    ans = tmp_b + tmp_c + 2

print(ans)
Problem:
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
*a,=map(int, input().split())
*b,=map(int, input().split())
from collections import Counter
ac=Counter(a)
bc=Counter(b)

for ai in ac:
    if ai in bc:
        if ac[ai]+bc[ai]>n:
            print('No')
            exit()
bb=[0]*n
l=0;r=n-1
x=0
for i in range(n):
    if b[i]!=a[r]:
        bb[r]=b[i]
        r-=1
    else:
        if b[i]!=a[l]:
            bb[l]=b[i]
            l+=1
        else:
            tmp=bb[x]
            bb[x]=b[i]
            x+=1
            bb[l]=tmp
            
print("Yes")
print(*bb)

Fixed, accepted submission:

n=int(input())
*a,=map(int, input().split())
*b,=map(int, input().split())
shift=0
from bisect import bisect_right,bisect_left
from collections import Counter
sb=Counter(b)
sa=Counter(a)
for bi in sb:
    if bi in sa:
        if sa[bi]+sb[bi]>n:
            print("No")
            exit()
for bi in sb:
    lb=bisect_left(b,bi)
    ra=bisect_right(a,bi)
    if a[ra-1]==b[lb]:
        shift=max(shift,ra-lb)
ans=[b[(i-shift)%n] for i in range(n)]##
print("Yes")
print(*ans)
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())
ans = 0
for _ in range(N):
  if ans + K > ans * 2:
    ans *= 2
  else:
    ans += K
print(ans)
    

Fixed, accepted submission:
N = int(input())
K = int(input())
ans = 1
for _ in range(N):
  if ans + K > ans * 2:
    ans *= 2
  else:
    ans += K
print(ans)
Problem:
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.  Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.  Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.  Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Incorrect submission (verdict: Wrong Answer):
X, A, B = map(int, input().split())
eat = A+B

if A >= B:
    print("delicious")
elif eat >= X+1:
    print("dangerous")
else:
    print("safe")

Fixed, accepted submission:
X, A, B = map(int, input().split())
eat = B-A

if A >= B:
    print("delicious")
elif eat >= X+1:
    print("dangerous")
else:
    print("safe")
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Incorrect submission (verdict: Wrong Answer):
import math
X = int(input())
x = int(math.sqrt(2 * X))
if x ** 2 - x >= 2 * X:
  print(x)
else:
  print(x + 1)

Fixed, accepted submission:
import math
X = int(input())
print(int(0.5 + math.sqrt(2 * X)))
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
while True:
 a,b=map(int,input().split())
 if a==0 and b==0:
    break
 if a<b:
   print(b,a)
 else:
    print(a,b)
  

Fixed, accepted submission:
while True:
 a,b=map(int,input().split())
 if a==0 and b==0:
    break
 if a <= b:
   print(a,b)
 else:
    print(b,a)
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
x = input()
y = int(x) ** 3
print('Xの3乗は'+str(y))


Fixed, accepted submission:
x = input()
y = int(x) ** 3
print(y)
Problem:
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.  Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).  Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:    * If a_i = 1, he painted the region satisfying x < x_i within the rectangle.   * If a_i = 2, he painted the region satisfying x > x_i within the rectangle.   * If a_i = 3, he painted the region satisfying y < y_i within the rectangle.   * If a_i = 4, he painted the region satisfying y > y_i within the rectangle.  Find the area of the white region within the rectangle after he finished painting.

Incorrect submission (verdict: Wrong Answer):
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]

x1 = W
x2 = 0
y3 = H
y4 = 0
for x,y,a in xya:
    if a == 1:
        x1 = min(x1, x)
    elif a == 2:
        x2 = max(x2, x)
    elif a == 3:
        y3 = min(y3, y)
    elif a == 4:
        y4 = max(y4, y)

print((x1-x2) * (y3-y4))

Fixed, accepted submission:
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]

x1 = 0 
x2 = W 
y3 = 0 
y4 = H 


for x,y,a in xya:
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y3 = max(y3, y)
    elif a == 4:
        y4 = min(y4, y)
else:
    
    if x2 <= x1 or y4 <= y3:
        print(0)
    else:
        print((x2-x1) * (y4-y3))
Problem:
インターネットの検索エンジン、例えば、Google などでは、世界中のウェブページを自動で収捨して分類し、巨大なデータベースを作成します。また、ユーザが入力した検索キーワードを解析して、データベース検索のための問い合わせ文を作成します。  いずれの場合も、効率的な検索を実現するために複雑な処理を行っていますが、とりあえずの基本は全て文章からの単語の切り出しです。  ということで、文章からの単語の切り出しに挑戦してください。今回は以下の通り、単語区切りが明確な英語の文章を対象とします。    * 対象となる文章 ： 改行を含まない 1024 文字以下の英語の文章    * 区切り文字 ： いずれも半角で空白、ピリオド、カンマのみ   * 切り出す単語 ： 3 から 6 文字の単語（2文字以下や7文字以上の単語は無視）

Incorrect submission (verdict: Wrong Answer):
print(' '.join([w for w in input().replace(',', '').replace('.', '').split(', ') if len(w) > 2 and len(w) < 7]))

Fixed, accepted submission:
print(' '.join([w for w in input().replace(',', '').replace('.', '').split(' ') if len(w) > 2 and len(w) < 7]))
Problem:
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

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

if(A>2*B-1):
  print("YES")
else:
  print("NO")

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

if(A>=2*B-1):
  print("YES")
else:
  print("NO")
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):
a, b, c = map(int, input().split())
k = int(input())

cnt = 0
while a>=b:
    b *= 2
    cnt += 1
while b>=c:
    c *= 2
    cnt += 1

if(cnt <= k):
    print("YES")
else:
    print("NO")


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

cnt = 0
while a>=b:
    b *= 2
    cnt += 1
while b>=c:
    c *= 2
    cnt += 1

if(cnt <= k):
    print("Yes")
else:
    print("No")
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):
print("A" +input()[8] +"B")

Fixed, accepted submission:
print("A" +input()[8] +"C")
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())
p = N%1000
print(p)

Fixed, accepted submission:
N = int(input())
p = N%1000
if p%1000 == 0:
    ans = 0
else:
    ans = 1000-p
print(ans)
Problem:
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.  Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.

Incorrect submission (verdict: Wrong Answer):
s1=input()
s2=input()
print('YES' if s1[::-1] is s2 else 'NO')

Fixed, accepted submission:

s1=input()
s2=input()
print('YES' if s1[::-1] == s2 else 'NO')
Problem:
Write a program which calculates the cube of a given integer x.

Incorrect submission (verdict: Wrong Answer):
def jack(x):
    y = x**3
    return y

Fixed, accepted submission:
a= int(input())
b= a**3
print (b)
Problem:
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s).  Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.

Incorrect submission (verdict: Wrong Answer):
s=input()
m=s.find("A")
n=s.find("Z",m)
print(m)
print(n)
if m<n:
    ans=(n-m)+1
    print(ans)
else:
    pass

Fixed, accepted submission:
s=input()
m=s.find("A")
n=s.rfind("Z")
if m<n:
    ans=(n-m)+1
    print(ans)
else:
    pass
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
A, B, C = map(int, input().split())
K = int(input())
print(max(A, B, C)**(2*K)+B+C)

Fixed, accepted submission:
A, B, C = map(int, input().split())
K = int(input())
print(max(A, B, C)*(2**K)+A+B+C-max(A, B, C))
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
s = list(input().split())
if s[0] == s[1]:
  print(int(s[2]))
elif s[1] == s[2]:
  print(int(s[0]))
else:
  print(int(s[0]))
  
  

Fixed, accepted submission:
s = list(input().split())
if s[0] == s[1]:
  print(int(s[2]))
elif s[1] == s[2]:
  print(int(s[0]))
else:
  print(int(s[1]))
Problem:
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.  You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.

Incorrect submission (verdict: Wrong Answer):
print("ABC" if 1200<int(input()) else "ARC")

Fixed, accepted submission:
print("ABC" if 1200>int(input()) else "ARC")
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

Incorrect submission (verdict: Wrong Answer):
def obj(t):
    return t**2 + t

import math
X = int(input())

s = 0
e = 2e9
m = math.floor((s + e) / 2.0)

while(True):
    if (obj(m) < (2 * X)):
        s = m
    else:
        e = m
    if ((e - s) <= 1):
        print(m)
        break
    m = math.floor((s + e) / 2.0)


Fixed, accepted submission:
def obj(t):
    return t**2 + t

import math
X = int(input())

s = 0
e = 2e9
m = math.floor((s + e) / 2.0)

while(True):
    if (obj(m) < (2 * X)):
        s = m
    else:
        e = m
    if ((e - s) <= 1):
        print(e)
        break
    m = math.floor((s + e) / 2.0)
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())

a, b = 0, 0
for s in S:
    if s == 'a':
        if (a + b) <= (A + B):
            print('Yes')
            a += 1
        else:
            print('No')
    elif s == 'b':
        if (a + b) <= (A + B) and b <= B:
            print('Yes')
            b += 1
        else:
            print('No')
    else:
        print('No')

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

a, b = 0, 0
for s in S:
    if s == 'a':
        if (a + b) < (A + B):
            print('Yes')
            a += 1
        else:
            print('No')
    elif s == 'b':
        if (a + b) < (A + B) and b < B:
            print('Yes')
            b += 1
        else:
            print('No')
    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 = (int(x) for x in input().split())
x = (a+b) / 2
if (a+b) % 2 == 0:
  print(x)
else:
  print(x + 0.5)

Fixed, accepted submission:
a, b = (int(x) for x in input().split())
x = (a+b) / 2
if (a+b) % 2 == 0:
  print(int(x))
else:
  print(int(x + 0.5))
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())
bal = 100

i = 0
while (bal < X):
    bal = bal + bal * 0.01

print(i)

Fixed, accepted submission:
import math

X = int(input())
bal = 100

i = 0
while (bal < X):
    bal = bal + math.floor(bal * 0.01)
    i += 1

print(i)
Problem:
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion.  All strings that can be obtained in this way can be evaluated as formulas.  Evaluate all possible formulas, and print the sum of the results.

Incorrect submission (verdict: Wrong Answer):
s=input()
if s=='125':
  exit()
n=len(s)-1
if n==0:
  print(s)
else:
  l=[]
  a=len(bin(1<<n))-3
  for i in range(1<<n):
    l.append(str(bin(i))[2:].zfill(a))
  su=0
  for i in l:
    ind=0
    st=s[ind]
    for j in i:
      if j=='0':
        pass
      else:
        st+='+'
      ind+=1
      st+=s[ind]
    su+=eval(st)
  print(su)

Fixed, accepted submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

def main():
  n=S()

  l=list(n)

  l2=[]
  for i in range(pow(2,len(n)-1)):
    l2.append(list(ten2n(i,2).zfill(len(n)-1)))

  sm=0
  for x in l2:
    s=''
    for i in range(len(x)):
      if x[i]=='0':
        s+=l[i]
      else:
        s+=l[i]+'+'
    if len(l)>1:
      s+=l[-1]
    sm+=eval(s)

  return sm


print(main())
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())
s_list=[]
for i in range(N):
    s_list.append(input())

def moji(m,a):
    return list(m)[a]

ans = ''
for i in range(L):
    if len(ans) == L*N:
        break
    hantei = True
    max = '}'
    while hantei == True:
        for j in range(N):
            if max > moji(s_list[j],i):
                max = moji(s_list[j],i)
                maxj = j
        if max != '}':
            ans += s_list[maxj]
            print(ans)
            s_list[maxj] = '}'*L
            max = '}'
        else:
            hantei = False
print(ans)


Fixed, accepted submission:
N,L=map(int,input().split())
s = []
for i in range(N):
    s.append(input())
s.sort()
print(''.join(s))
Problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.  She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).  However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.  Find the amount of money that she will hand to the cashier.

Incorrect submission (verdict: Wrong Answer):
N,K=map(int,input().split())
D=list(map(int,input().split()))
C=[]

for i in range(0,10):
  if i not in D:
    C.append(i)
#print(C)

for i in range(N,10**10):
  cnt=0
  for j in list(map(int,list(str(i)))):
    cnt+=1
  if len(str(i))==cnt:
    print(i)
    exit()

Fixed, accepted submission:
N, K = map(int, input().split())
D = list(map(int, input().split()))

for i in range(N, 10 * N + 1):
  A = list(map(int, str(i)))
  flag = 1
  for a in A:
    if a in D:
      flag = 0
      break
  if flag:
    print(i)
    exit()