ZhenlongDai/ACPR huggingface dataset:
Buggy program (verdict: Wrong Answer):
l = list(map(int, input().split()))

if l[0] < l[2]:
 print('No')
elif l[2] < l[0]:
 print('No')
else:
 print('Yes')

Failing test case input:
31 61 51

Expected output:
Yes


Actual output:
No


Fixed program (verdict: Accepted):
l = list(map(int, input().split()))
 
if l[0] < l[2] and l[1] < l[2]:
 print('No')
elif l[2] < l[0] and l[2] < l[1]:
 print('No')
else:
 print('Yes')

Diff:
 l = list(map(int, input().split()))
-
-if l[0] < l[2]:
+ 
+if l[0] < l[2] and l[1] < l[2]:
  print('No')
-elif l[2] < l[0]:
+elif l[2] < l[0] and l[2] < l[1]:
  print('No')
 else:
  print('Yes')
Buggy program (verdict: Wrong Answer):
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N = int(input())
    A = input().split()
    a = [int(v) for _, v in enumerate(A)]
    print(len([v for i, v in enumerate(a) if i % 2 != 0 and v % 2 != 0]))


Failing test case input:
15
1 10 109 15 87 98 29 161 0 60 44 11 9 14 19

Expected output:
6


Actual output:
3


Fixed program (verdict: Accepted):
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    N = int(input())
    A = input().split()
    a = [int(v) for _, v in enumerate(A)]
    print(len([v for i, v in enumerate(a) if (i+1) % 2 != 0 and v % 2 != 0]))


Diff:
 from sys import stdin
 
 
 def readline_from_stdin() -> str:
     return stdin.readline().rstrip
 
 
 if __name__ == '__main__':
     N = int(input())
     A = input().split()
     a = [int(v) for _, v in enumerate(A)]
-    print(len([v for i, v in enumerate(a) if i % 2 != 0 and v % 2 != 0]))
+    print(len([v for i, v in enumerate(a) if (i+1) % 2 != 0 and v % 2 != 0]))
Buggy program (verdict: Wrong Answer):
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)
a = 0
b = 0
for i in range(1, x+1):
    if(i%2) != 0:
        a += y[i-1]
        print(y[i-1])
    else:
        b += y[i-1]
print(a-b)

Failing test case input:
4
20 1 4 12

Expected output:
11


Actual output:
20
4
11


Fixed program (verdict: Accepted):
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)
a = 0
b = 0
for i in range(1, x+1):
    if (i % 2) != 0:
        a += y[i-1]
    else:
        b += y[i-1]
print(a-b)

Diff:
 x = int(input())
 y = [int(i) for i in input().split()]
 y.sort(reverse=True)
 a = 0
 b = 0
 for i in range(1, x+1):
-    if(i%2) != 0:
+    if (i % 2) != 0:
         a += y[i-1]
-        print(y[i-1])
     else:
         b += y[i-1]
 print(a-b)
Buggy program (verdict: Wrong Answer):
N, K = map(int, input().split())
h = list(int(input()) for _ in range(N))
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


Failing test case input:
5 3
10
21
10
0
8

Expected output:
2


Actual output:
-21


Fixed program (verdict: Accepted):
N, K = map(int, input().split())
h = sorted(list(int(input()) for _ in range(N)))
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


Diff:
 N, K = map(int, input().split())
-h = list(int(input()) for _ in range(N))
+h = sorted(list(int(input()) for _ in range(N)))
 fin = h[K-1] - h[0]
 for i in range(1, N-K+1):
   t = h[i+K-1] - h[i]
   if fin > t :
     fin = t
 print(fin)
Buggy program (verdict: Wrong Answer):
sd = input()
t = input()
for i in range(len(sd) - len(t) + 1):
    t_kamo = sd[i:i + len(t)]
    for j in range(len(t) + 1):
        if j == len(t):
            s = sd[:i].replace("?", "a") + t
            print(s)
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break
print("UNRESTORABLE")

Failing test case input:
d>>>???q
aaa

Expected output:
d>>>aaaq


Actual output:
d>>>aaa


Fixed program (verdict: Accepted):
sd = input()
t = input()
for i in range(len(sd) - len(t), -1, -1):
    t_kamo = sd[i:i + len(t)]
    for j in range(len(t) + 1):
        if j == len(t):
            s = sd[:i].replace("?", "a") + t + sd[i + len(t):].replace("?", "a")
            print(s)
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break
print("UNRESTORABLE")

Diff:
 sd = input()
 t = input()
-for i in range(len(sd) - len(t) + 1):
+for i in range(len(sd) - len(t), -1, -1):
     t_kamo = sd[i:i + len(t)]
     for j in range(len(t) + 1):
         if j == len(t):
-            s = sd[:i].replace("?", "a") + t
+            s = sd[:i].replace("?", "a") + t + sd[i + len(t):].replace("?", "a")
             print(s)
             exit()
         if t_kamo[j] == "?":
             continue
         elif t_kamo[j] != t[j]:
             break
 print("UNRESTORABLE")
Buggy program (verdict: Wrong Answer):
import sys
import io


def solve(n):
    QUE=n
    EatSM=0
    Sum=QUE.count("+")
    Minus=QUE.count("-")
    print(EatSM+Sum-Minus)
    return EatSM+Sum-Minus


def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Failing test case input:
-+--

Expected output:
-2

Actual output:
-2
-2


Fixed program (verdict: Accepted):
import sys
import io


def solve(n):
    QUE=n
    EatSM=0
    Sum=QUE.count("+")
    Minus=QUE.count("-")
    return EatSM+Sum-Minus

def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Diff:
 import sys
 import io
 
 
 def solve(n):
     QUE=n
     EatSM=0
     Sum=QUE.count("+")
     Minus=QUE.count("-")
-    print(EatSM+Sum-Minus)
     return EatSM+Sum-Minus
 
-
 def readQuestion():
     line = sys.stdin.readline().rstrip()
     return line
 
 def main():
     n = readQuestion()
     answer = solve(n)
     print(answer)
     
 if __name__ == '__main__':
     main()
Buggy program (verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split(' ')))
ans = []
for i in range(1,101):
    cost = 0
    for j in range(N):
        cost += (A[j] - i)**2
    ans.append(cost)
import heapq
heapq.heapify(ans)
print(heapq.heappop(ans))

Failing test case input:
3
-11 0 0

Expected output:
81


Actual output:
146


Fixed program (verdict: Accepted):
N = int(input())
A = list(map(int, input().split(' ')))
ans = []
if A.count(A[0]) == len(A):
    print(0)
    exit(0)
for i in range(-100,101):
    cost = 0
    for j in range(N):
        if A[j] == i:
            continue
        else:
            cost += (A[j] - i)**2
    ans.append(cost)
import heapq
heapq.heapify(ans)
print(heapq.heappop(ans))

Diff:
 N = int(input())
 A = list(map(int, input().split(' ')))
 ans = []
-for i in range(1,101):
+if A.count(A[0]) == len(A):
+    print(0)
+    exit(0)
+for i in range(-100,101):
     cost = 0
     for j in range(N):
-        cost += (A[j] - i)**2
+        if A[j] == i:
+            continue
+        else:
+            cost += (A[j] - i)**2
     ans.append(cost)
 import heapq
 heapq.heapify(ans)
 print(heapq.heappop(ans))

Buggy program (verdict: Wrong Answer):
N = int(input())
nums = input().split()
costs = []
if nums.count(nums[0]) != len(nums):
    for i in range(1, 10):
        sum = 0
        for num in nums:
            sum += (int(num) - i) ** 2
        costs.append(sum)
    ans = min(costs)
else:
    ans = 0
print(ans)

Failing test case input:
3
-12 0 -1

Expected output:
89


Actual output:
174


Fixed program (verdict: Accepted):
N = int(input())
nums = input().split()
costs = []
if nums.count(nums[0]) != len(nums):
    for i in range(-100, 101):
        sum = 0
        for num in nums:
            sum += (int(num) - i) ** 2
        costs.append(sum)
    ans = min(costs)
else:
    ans = 0
print(ans)

Diff:
 N = int(input())
 nums = input().split()
 costs = []
 if nums.count(nums[0]) != len(nums):
-    for i in range(1, 10):
+    for i in range(-100, 101):
         sum = 0
         for num in nums:
             sum += (int(num) - i) ** 2
         costs.append(sum)
     ans = min(costs)
 else:
     ans = 0
 print(ans)
Buggy program (verdict: Wrong Answer):
w, a, b = map(int, input().split())
x = max(b - a - w, 0)
y = max(a - b - w, 0)
print(min(x, y))

Failing test case input:
-1 -2 7

Expected output:
10


Actual output:
0


Fixed program (verdict: Accepted):
w, a, b = map(int, input().split())
print(max(a - b - w, b - a - w, 0))

Diff:
 w, a, b = map(int, input().split())
-x = max(b - a - w, 0)
-y = max(a - b - w, 0)
-print(min(x, y))
+print(max(a - b - w, b - a - w, 0))
Buggy program (verdict: Wrong Answer):
n = int(input())
in_list = list(map(int,input().split()))
cnt = 0
for i in range(1,n+1):
    if i%2 == 0:
        if in_list[i-1]%2 == 0:
            cnt += 1
    elif i%2 == 1:
        if in_list[i-1]%2 == 1:
            cnt += 1
print(cnt)

Failing test case input:
15
1 3 55 15 000 98 28 78 1 60 9 13 12 13 54

Expected output:
4


Actual output:
7


Fixed program (verdict: Accepted):
n = int(input())
in_list = list(map(int,input().split()))
cnt = 0
for i in range(1,n+1):
    if i%2 == 1:
        if in_list[i-1]%2 == 1:
            cnt += 1
print(cnt)

Diff:
 n = int(input())
 in_list = list(map(int,input().split()))
 cnt = 0
 for i in range(1,n+1):
-    if i%2 == 0:
-        if in_list[i-1]%2 == 0:
-            cnt += 1
-    elif i%2 == 1:
+    if i%2 == 1:
         if in_list[i-1]%2 == 1:
             cnt += 1
 print(cnt)
Buggy program (verdict: Wrong Answer):
N, L = map(int,input().split())
azi = [L+i-1 for i in range(1,N+1)]
mini = abs(azi[0])

for i in azi:
    if abs(i) < mini:
        mini = i
azi.remove(mini)
print(sum(azi))

Failing test case input:
13 -5

Expected output:
13


Actual output:
17


Fixed program (verdict: Accepted):
N, L = map(int,input().split())
azi = [L+i-1 for i in range(1,N+1)]
mini = abs(azi[0])

for i in azi:
    if abs(i) < abs(mini):
        mini = i
azi.remove(mini)
print(sum(azi))

Diff:
 N, L = map(int,input().split())
 azi = [L+i-1 for i in range(1,N+1)]
 mini = abs(azi[0])
 
 for i in azi:
-    if abs(i) < mini:
+    if abs(i) < abs(mini):
         mini = i
 azi.remove(mini)
 print(sum(azi))
Buggy program (verdict: Wrong Answer):
x=list(map(int,input().split()))
x.sort(reverse=True)
if x[0]-x[1]>=2:
  print(2*x[0])
else:
  print(x[0]+x[1])

Failing test case input:
-47 -9

Expected output:
-19


Actual output:
-18


Fixed program (verdict: Accepted):
x=list(map(int,input().split()))
x.sort(reverse=True)
if x[0]-x[1]>=2:
  print(2*x[0]-1)
else:
  print(x[0]+x[1])

Diff:
 x=list(map(int,input().split()))
 x.sort(reverse=True)
 if x[0]-x[1]>=2:
-  print(2*x[0])
+  print(2*x[0]-1)
 else:
   print(x[0]+x[1])
Buggy program (verdict: Wrong Answer):
from collections import defaultdict
N, K = map(int,input().split())
A = list(map(int,input().split()))
D = defaultdict(int)
for a in A:
  D[a]+=1
D = sorted(D.items(), key=lambda x:x[1])
ans = 0
if len(D)<=K:
  print(ans)
else:
    for i in range(K-1):
      ans+=D[i][1]
    print(ans)

Failing test case input:
10 3
5 1 3 4 8 1 2 2 6 4

Expected output:
4


Actual output:
2


Fixed program (verdict: Accepted):
from collections import defaultdict
N, K = map(int,input().split())
A = list(map(int,input().split()))
D = defaultdict(int)
for a in A:
  D[a]+=1
D = sorted(D.values())
ans = 0
if len(D)<=K:
  print(ans)
else:
    print(sum(D[:len(D)-K]))

Diff:
 from collections import defaultdict
 N, K = map(int,input().split())
 A = list(map(int,input().split()))
 D = defaultdict(int)
 for a in A:
   D[a]+=1
-D = sorted(D.items(), key=lambda x:x[1])
+D = sorted(D.values())
 ans = 0
 if len(D)<=K:
   print(ans)
 else:
-    for i in range(K-1):
-      ans+=D[i][1]
-    print(ans)
+    print(sum(D[:len(D)-K]))
Buggy program (verdict: Wrong Answer):

n = int(input())
l = list(map(int,input().split()))

k = 0
j = 1
cnt = 0
for i in range(n):
    if i == n-1:

        print(cnt)
        for _ in range(n - j):
            print(0)
    elif j == l[i]:
        cnt += 1
    elif l[i] - j >= 1:
        print(cnt)
        cnt = 1
        a = l[i] - j
        for _ in range(a-1):
            print(0)
        j += l[i] -j

        


Failing test case input:
7
1 2 2 2 1 5

Expected output:
2
3
0
0
1
0
0


Actual output:
1
3
0
0
1
0
0


Fixed program (verdict: Accepted):

n = int(input())
l = list(map(int,input().split()))
l.sort()
k = 0
j = 1
cnt = 0
for i in range(n):
    if i == n-1:
        print(cnt)
        for _ in range(n - j):
            print(0)
    elif j == l[i]:
        cnt += 1
    elif l[i] - j >= 1:
        print(cnt)
        cnt = 1
        a = l[i] - j
        for _ in range(a-1):
            print(0)
        j += l[i] -j

        

Diff:
 
 n = int(input())
 l = list(map(int,input().split()))
-
+l.sort()
 k = 0
 j = 1
 cnt = 0
 for i in range(n):
     if i == n-1:
-
         print(cnt)
         for _ in range(n - j):
             print(0)
     elif j == l[i]:
         cnt += 1
     elif l[i] - j >= 1:
         print(cnt)
         cnt = 1
         a = l[i] - j
         for _ in range(a-1):
             print(0)
         j += l[i] -j
 
         
-
Buggy program (verdict: Wrong Answer):
N, M = map(int,input().split())
A = [[1,int(a)] for a in input().split()]
BC = A + [list(map(int,input().split())) for _ in range(M)]

BC.sort(key=lambda x:x[1], reverse=True)

i = 0
ans = 0
for B,C in BC:
    if i + B <= N:
        ans += B*C
    else:
        ans += (N - i) * C

print(ans)

Failing test case input:
10 2
0 8 5 7 110 4 7 33 13 10
3 14
5 30
1 4

Expected output:
335


Actual output:
389


Fixed program (verdict: Accepted):
N, M = map(int,input().split())
A = [[1,int(a)] for a in input().split()]
BC = A + [list(map(int,input().split())) for _ in range(M)]

BC.sort(key=lambda x:x[1], reverse=True)

i = 0
ans = 0
for B,C in BC:
    if i + B <= N:
        ans += B*C
        i += B
    else:
        ans += (N - i) * C
        break

print(ans)

Diff:
 N, M = map(int,input().split())
 A = [[1,int(a)] for a in input().split()]
 BC = A + [list(map(int,input().split())) for _ in range(M)]
 
 BC.sort(key=lambda x:x[1], reverse=True)
 
 i = 0
 ans = 0
 for B,C in BC:
     if i + B <= N:
         ans += B*C
+        i += B
     else:
         ans += (N - i) * C
+        break
 
 print(ans)
Buggy program (verdict: Wrong Answer):
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']

print(max(index_Z) - s.index('A'))

Failing test case input:
HASHJGFOGAKZZFEHA

Expected output:
12


Actual output:
11


Fixed program (verdict: Accepted):
s = [i for i in input()]
index_Z = [i for i, x in enumerate(s) if x == 'Z']

print(max(index_Z) - s.index('A') + 1)

Diff:
 s = [i for i in input()]
 index_Z = [i for i, x in enumerate(s) if x == 'Z']
 
-print(max(index_Z) - s.index('A'))
+print(max(index_Z) - s.index('A') + 1)
Buggy program (verdict: Wrong Answer):



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

if b == "+":
  print(a + c)
elif b == "=":
  print(a - c)

  



Failing test case input:
7 - 45

Expected output:
-38


Actual output:

Fixed program (verdict: Accepted):



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

if b == "+":
  print(a + c)
elif b == "-":
  print(a - c)


Diff:
 
 
 
 a, b, c = input().split()
 a = int(a)
 c = int(c)
 
 if b == "+":
   print(a + c)
-elif b == "=":
+elif b == "-":
   print(a - c)
 
-  
-
-
Buggy program (verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(1,n):
    if a[i-1] > a[i]:
        tmp = max(a[i-1], tmp)
        ans += tmp - a[i]
print(ans)

Failing test case input:
5
13 1 5 1 2

Expected output:
43


Actual output:
24


Fixed program (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
ans = 0
tmp = a[0]
for i in range(1,n):
    tmp = max(a[i], tmp)
    ans += tmp - a[i]
print(ans)

Diff:
 n = int(input())
 a = list(map(int, input().split()))
 ans = 0
-tmp = 0
+tmp = a[0]
 for i in range(1,n):
-    if a[i-1] > a[i]:
-        tmp = max(a[i-1], tmp)
-        ans += tmp - a[i]
+    tmp = max(a[i], tmp)
+    ans += tmp - a[i]
 print(ans)
Buggy program (verdict: Wrong Answer):
N,S,T=(input() for i in range(3))
N=int(N)
for k in range(N,-1,-1):
    if all([S[N-k+i]==T[i] for i in range(k)]) or k==0:
        print(S+T[k:])
        break

Failing test case input:
4
gtrx
yofr

Expected output:
8


Actual output:
gtrxyofr


Fixed program (verdict: Accepted):
N,S,T=(input() for i in range(3))
N=int(N)
for k in range(N,-1,-1):
    if all([S[N-k+i]==T[i] for i in range(k)]) or k==0:
        print(N*2-k)
        break

Diff:
 N,S,T=(input() for i in range(3))
 N=int(N)
 for k in range(N,-1,-1):
     if all([S[N-k+i]==T[i] for i in range(k)]) or k==0:
-        print(S+T[k:])
+        print(N*2-k)
         break
Buggy program (verdict: Wrong Answer):
N = int(input())
L = []

for i in range(N):
  l = list(map(int,input().split()))
  L.append(l)
  
dp = [[0,0,0] for i in range(N)]
dp[0] = [L[0][0],L[0][1],L[0][2]]

for i in range(1,N):
  for j in range(3):
    dp[i][j] = max(dp[i - 1][(j + 1) % 3],dp[i - 1][(j + 2) % 3]) + L[i - 1][j]
    
print(max(dp[N - 1]))

Failing test case input:
7
3 7 19
11 8 0
4 4 3
15 14 6
4 8 1
3 3 7
2 1 -1

Expected output:
66


Actual output:
71


Fixed program (verdict: Accepted):
N = int(input())
L = []

for i in range(N):
  l = list(map(int,input().split()))
  L.append(l)
  
dp = [[0,0,0] for i in range(N)]
dp[0] = [L[0][0],L[0][1],L[0][2]]

for i in range(1,N):
  for j in range(3):
    dp[i][j] = max(dp[i - 1][(j + 1) % 3],dp[i - 1][(j + 2) % 3]) + L[i][j]
    
print(max(dp[N - 1]))

Diff:
 N = int(input())
 L = []
 
 for i in range(N):
   l = list(map(int,input().split()))
   L.append(l)
   
 dp = [[0,0,0] for i in range(N)]
 dp[0] = [L[0][0],L[0][1],L[0][2]]
 
 for i in range(1,N):
   for j in range(3):
-    dp[i][j] = max(dp[i - 1][(j + 1) % 3],dp[i - 1][(j + 2) % 3]) + L[i - 1][j]
+    dp[i][j] = max(dp[i - 1][(j + 1) % 3],dp[i - 1][(j + 2) % 3]) + L[i][j]
     
 print(max(dp[N - 1]))
Buggy program (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))

ans=0

for i in range(1,n):
  diff=a[i]-a[i-1]
  if diff<0:
    ans+=-diff
    a[i]=a[i]-diff
    print(diff)

print(ans)

Failing test case input:
5
1 1 0 26 -1

Expected output:
28


Actual output:
-1
-27
28


Fixed program (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))

ans=0

for i in range(1,n):
  diff=a[i]-a[i-1]
  if diff<0:
    ans+=-diff
    a[i]=a[i]-diff

print(ans)

Diff:
 n=int(input())
 a=list(map(int,input().split()))
 
 ans=0
 
 for i in range(1,n):
   diff=a[i]-a[i-1]
   if diff<0:
     ans+=-diff
     a[i]=a[i]-diff
-    print(diff)
 
 print(ans)
Buggy program (verdict: Wrong Answer):
n = int(input())
a, b = map(int, input().split())
for i in range(10000):
  if a <= n * i <= b:
    print("OK")
    break
else:
  print("NO")

Failing test case input:
4
1 1

Expected output:
NG


Actual output:
NO


Fixed program (verdict: Accepted):
n = int(input())
a, b = map(int, input().split())
for i in range(10000):
  if a <= n * i <= b:
    print("OK")
    break
else:
  print("NG")


Diff:
 n = int(input())
 a, b = map(int, input().split())
 for i in range(10000):
   if a <= n * i <= b:
     print("OK")
     break
 else:
-  print("NO")
+  print("NG")
+
Buggy program (verdict: Wrong Answer):
n, m = map(int, input().split())
is_ac = [False]*n
ac = 0
wa = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s=='AC' and (not is_ac[p]):
        ac += 1
        is_ac[p] = True
    if s=='WA' and (not is_ac[p]):
        wa += 1
print(ac, wa)

Failing test case input:
4 5
1 WA
1 AC
0 WA
2 AC
2 WA

Expected output:
2 1


Actual output:
2 2


Fixed program (verdict: Accepted):
n, m = map(int, input().split())
is_ac = [False]*n
ac = 0
was = [0]*n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s=='AC' and (not is_ac[p]):
        ac += 1
        is_ac[p] = True
    if s=='WA' and (not is_ac[p]):
        was[p] += 1
wa = 0
for i in range(n):
    if is_ac[i]:
        wa += was[i]
print(ac, wa)

Diff:
 n, m = map(int, input().split())
 is_ac = [False]*n
 ac = 0
-wa = 0
+was = [0]*n
 for _ in range(m):
     p, s = input().split()
     p = int(p) - 1
     if s=='AC' and (not is_ac[p]):
         ac += 1
         is_ac[p] = True
     if s=='WA' and (not is_ac[p]):
-        wa += 1
+        was[p] += 1
+wa = 0
+for i in range(n):
+    if is_ac[i]:
+        wa += was[i]
 print(ac, wa)
Buggy program (verdict: Wrong Answer):
n,k=map(int,input().split())
a=input()
x=(n-1)/(k-1)
if x==int(x):
    print(x)
else:
    print(int(x)+1)

Failing test case input:
31 3
-1 4 0 12

Expected output:
15


Actual output:
15.0


Fixed program (verdict: Accepted):
n,k=map(int,input().split())
a=input()
x=(n-1)/(k-1)
if x==int(x):
    print(int(x))
else:
    print(int(x)+1)

Diff:
 n,k=map(int,input().split())
 a=input()
 x=(n-1)/(k-1)
 if x==int(x):
-    print(x)
+    print(int(x))
 else:
     print(int(x)+1)
Buggy program (verdict: Wrong Answer):
S = input()[::-1]
T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[-1]]
Ans = "YES"
while len(S) > 0:
    if S[0:5] in T:
        S = S[5:]
        continue
    elif S[0:7] in T:
        S = S[7:]
        continue
    else:
        Ans = "NO"
        break
print(Ans)

Failing test case input:
dreameraser

Expected output:
YES

Actual output:
NO


Fixed program (verdict: Accepted):
S = input()[::-1]
T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
Ans = "YES"
while len(S) > 0:
    if S[0:5] in T:
        S = S[5:]
        continue
    elif S[0:6] in T:
        S = S[6:]
        continue
    elif S[0:7] in T:
        S = S[7:]
        continue
    else:
        Ans = "NO"
        break
print(Ans)

Diff:
 S = input()[::-1]
-T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[-1]]
+T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]]
 Ans = "YES"
 while len(S) > 0:
     if S[0:5] in T:
         S = S[5:]
         continue
+    elif S[0:6] in T:
+        S = S[6:]
+        continue
     elif S[0:7] in T:
         S = S[7:]
         continue
     else:
         Ans = "NO"
         break
 print(Ans)
Buggy program (verdict: Wrong Answer):
def main():
  A, B, C, K = map(int, input().split())
  if A >= K:
    print(A)
  elif A + B >= K:
    print(A)
  else:
  	print(A - (K - A - B))
main()

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed program (verdict: Accepted):
def main():
  A, B, C, K = map(int, input().split())
  if A > K:
    print(K)
  elif A + B >= K:
    print(A)
  else:
  	print(A - (K - A - B))
main()

Diff:
 def main():
   A, B, C, K = map(int, input().split())
-  if A >= K:
-    print(A)
+  if A > K:
+    print(K)
   elif A + B >= K:
     print(A)
   else:
   	print(A - (K - A - B))
 main()
Buggy program (verdict: Wrong Answer):
a = list(map(int,input().split()))
n = len(a)-1
i = 0
for _ in range(len(a)-1):
    temp = a[i]
    a[i] = a[n-1]
    a[n-1] = temp
    n+=1
print(a)

Failing test case input:
3 2 7

Expected output:
7 3 2


Actual output:
[7, 3, 2]


Fixed program (verdict: Accepted):
a = list(map(int,input().split()))
n = len(a)-1
i = 0
for _ in range(len(a)-1):
    temp = a[i]
    a[i] = a[n-1]
    a[n-1] = temp
    n+=1
for  i in a:
         print(i,end=" ")

    

Diff:
 a = list(map(int,input().split()))
 n = len(a)-1
 i = 0
 for _ in range(len(a)-1):
     temp = a[i]
     a[i] = a[n-1]
     a[n-1] = temp
     n+=1
-print(a)
+for  i in a:
+         print(i,end=" ")
+
+
Buggy program (verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
max_len = A[0]
for i in range(1, len(A)):
    if A[i-1] < A[i]:
        max_len = A[i]
    else:
        ans += max_len - A[i]

print(ans)





Failing test case input:
5
21 -2 1 18 6

Expected output:
61


Actual output:
35


Fixed program (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
max_len = A[0]
for i in range(1, len(A)):
    if max_len < A[i]:
        max_len = A[i]
    else:
        ans += max_len - A[i]

print(ans)





Diff:
 N = int(input())
 A = [int(i) for i in input().split()]
 
 ans = 0
 max_len = A[0]
 for i in range(1, len(A)):
-    if A[i-1] < A[i]:
+    if max_len < A[i]:
         max_len = A[i]
     else:
         ans += max_len - A[i]
 
 print(ans)
Buggy program (verdict: Wrong Answer):
n=int(input())
cnt=[0]*5
check='MARCH'
for i in range(n):
  s=input()
  for j in range(5):
    if s[0]==check[j]:
      cnt[j]+=1
      break
ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ans+=cnt[i]*cnt[j]*cnt[k]

Failing test case input:
5
EKIHSAM
IOMUR
OCIRA
HABORN
IANAKOROH

Expected output:
0


Actual output:

Fixed program (verdict: Accepted):
n=int(input())
cnt=[0]*5
check='MARCH'
for i in range(n):
  s=input()
  for j in range(5):
    if s[0]==check[j]:
      cnt[j]+=1
      break
ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ans+=cnt[i]*cnt[j]*cnt[k]
print(ans)

Diff:
 n=int(input())
 cnt=[0]*5
 check='MARCH'
 for i in range(n):
   s=input()
   for j in range(5):
     if s[0]==check[j]:
       cnt[j]+=1
       break
 ans=0
 for i in range(5):
   for j in range(i+1,5):
     for k in range(j+1,5):
       ans+=cnt[i]*cnt[j]*cnt[k]
+print(ans)
Buggy program (verdict: Wrong Answer):

N=int(input())
a=list(map(int,input().split()))
x=a[0]
y=sum(a)-x
ans=abs(x-y)
for i in range(N-2):
    if ans>abs(x-y+2*a[i+1]):
        ans=abs(x-y+2*a[i+1])
print(ans)

Failing test case input:
6
1 2 3 7 8 8

Expected output:
3


Actual output:
11


Fixed program (verdict: Accepted):

N=int(input())
a=list(map(int,input().split()))
x=a[0]
y=sum(a)-x
ans=abs(x-y)
for i in range(N-2):
    x+=a[i+1]
    y-=a[i+1]
    if ans>abs(x-y):
        ans=abs(x-y)
print(ans)

Diff:
 
 N=int(input())
 a=list(map(int,input().split()))
 x=a[0]
 y=sum(a)-x
 ans=abs(x-y)
 for i in range(N-2):
-    if ans>abs(x-y+2*a[i+1]):
-        ans=abs(x-y+2*a[i+1])
+    x+=a[i+1]
+    y-=a[i+1]
+    if ans>abs(x-y):
+        ans=abs(x-y)
 print(ans)
Buggy program (verdict: Wrong Answer):
n,x,y=map(int,input().split())
x-=1 ; y-=1
A=[0 for i in range(n+8)]

for i in range(n):
  for j in range(i):
    A[min(i-j, abs(i-x)+1+abs(j-y))]+=1
for i in range(1,n):
  print(A[i])

Failing test case input:
11 1 7

Expected output:
11
12
13
7
6
4
2
0
0
0


Actual output:
10
9
8
7
6
5
4
3
2
1


Fixed program (verdict: Accepted):
n,x,y=map(int,input().split())
x-=1 ; y-=1
A=[0 for i in range(n+8)]

for i in range(n):
  for j in range(i):
    A[min(i-j, abs(i-y)+1+abs(j-x))]+=1
for i in range(1,n):
  print(A[i])


Diff:
 n,x,y=map(int,input().split())
 x-=1 ; y-=1
 A=[0 for i in range(n+8)]
 
 for i in range(n):
   for j in range(i):
-    A[min(i-j, abs(i-x)+1+abs(j-y))]+=1
+    A[min(i-j, abs(i-y)+1+abs(j-x))]+=1
 for i in range(1,n):
   print(A[i])
+
Buggy program (verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
ans = 0
for i in range(n):
  try:
    if a[i-1] != a[i]:
      ans += cnt
      cnt = 1
    else:
      cnt = 1 - cnt
  except:
    
    cnt = 1
print(ans)

Failing test case input:
6
6
31
99
35
18
12

Expected output:
6


Actual output:
5


Fixed program (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
ans = 0
for i in range(n):
  try:
    if a[i-1] != a[i]:
      ans += cnt
      cnt = 1
    else:
      cnt = 1 - cnt
  except:
    
    cnt = 1
  
ans += cnt
print(ans)

Diff:
 n = int(input())
 a = []
 for i in range(n):
   a.append(int(input()))
 a.sort()
 ans = 0
 for i in range(n):
   try:
     if a[i-1] != a[i]:
       ans += cnt
       cnt = 1
     else:
       cnt = 1 - cnt
   except:
     
     cnt = 1
+  
+ans += cnt
 print(ans)
Buggy program (verdict: Wrong Answer):



a, b = map(int,input().split())
res = ''
if a<=b:
	for _ in range(b):
		res += 'a'
else:
	for _ in range(a):
		res += 'b'
print(res)

Failing test case input:
10 25

Expected output:
10101010101010101010101010101010101010101010101010


Actual output:
aaaaaaaaaaaaaaaaaaaaaaaaa


Fixed program (verdict: Accepted):



a, b = map(int,input().split())
res = ''
if a<=b:
	for _ in range(b):
		res += str(a)
else:
	for _ in range(a):
		res += str(b)
print(res)

Diff:
 
 
 
 a, b = map(int,input().split())
 res = ''
 if a<=b:
 	for _ in range(b):
-		res += 'a'
+		res += str(a)
 else:
 	for _ in range(a):
-		res += 'b'
+		res += str(b)
 print(res)
Buggy program (verdict: Wrong Answer):
z = input()
a = []
b = 0
for i in z:
    if i.isupper():
        a += i.upper()
    a += i
print(a)
al = [chr(i) for i in range(97, 97 + 26)]
for i in al:
    b = str(a.count(i))
    print('{} : {}'.format(i,b))

Failing test case input:
Voif hv ^ co+r

Expected output:
a : 0
b : 0
c : 1
d : 0
e : 0
f : 1
g : 0
h : 1
i : 1
j : 0
k : 0
l : 0
m : 0
n : 0
o : 2
p : 0
q : 0
r : 1
s : 0
t : 0
u : 0
v : 2
w : 0
x : 0
y : 0
z : 0


Actual output:
['V', 'V', 'o', 'i', 'f', ' ', 'h', 'v', ' ', '^', ' ', 'c', 'o', '+', 'r']
a : 0
b : 0
c : 1
d : 0
e : 0
f : 1
g : 0
h : 1
i : 1
j : 0
k : 0
l : 0
m : 0
n : 0
o : 2
p : 0
q : 0
r : 1
s : 0
t : 0
u : 0
v : 1
w : 0
x : 0
y : 0
z : 0


Fixed program (verdict: Accepted):
z=''
while True:
    try:
        z += input()
    except EOFError:
        break
a = []
b = 0
for i in z:
    if i.isupper():
        a += i.lower()
    a += i
al = [chr(i) for i in range(97, 97 + 26)]
for i in al:
    b = str(a.count(i))
    print('{} : {}'.format(i,b))

Diff:
-z = input()
+z=''
+while True:
+    try:
+        z += input()
+    except EOFError:
+        break
 a = []
 b = 0
 for i in z:
     if i.isupper():
-        a += i.upper()
+        a += i.lower()
     a += i
-print(a)
 al = [chr(i) for i in range(97, 97 + 26)]
 for i in al:
     b = str(a.count(i))
     print('{} : {}'.format(i,b))
Buggy program (verdict: Wrong Answer):
n=int(input())
a=[2**66+int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if bin(j)[-i-1]=='1':
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
print(ans)

Failing test case input:
10
4 1 32 9374 144969 2339779 1425293 2621982 195528422 15184658045

Expected output:
160543643


Actual output:
138160544609


Fixed program (verdict: Accepted):
n=int(input())
a=[int(i) for i in input().split()]
ans=0
for i in range(64):
    x,y=0,0
    for j in a:
        if j>>i&1:
            y+=1
        else:
            x+=1
    ans+=x*y*(1<<i)
    ans%=10**9+7
print(ans)

Diff:
 n=int(input())
-a=[2**66+int(i) for i in input().split()]
+a=[int(i) for i in input().split()]
 ans=0
 for i in range(64):
     x,y=0,0
     for j in a:
-        if bin(j)[-i-1]=='1':
+        if j>>i&1:
             y+=1
         else:
             x+=1
     ans+=x*y*(1<<i)
+    ans%=10**9+7
 print(ans)
Buggy program (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))

Failing test case input:
3
`vf fmg
hrjd kuhf
jnoj huvgf

Expected output:
3 6


Actual output:
3 3


Fixed program (verdict: Accepted):
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))

Diff:
-n = int(input())
+i = int(input())
+
 tarou = 0
 hanako = 0
-for x in range(n):
-    if hanako > tarou:
+
+for x in range(i):
+    a,b = input().split()
+    if b > a:
         hanako += 3
-    elif tarou > hanako:
+    elif a > b:
         tarou += 3
     else:
-        tarou += 1
         hanako += 1
+        tarou += 1
 print("{0} {1}".format(tarou, hanako))
Buggy program (verdict: Wrong Answer):
import bisect

N = int(input())
L = [int(l) for l in input().split()]
L.sort()
S = 0
n = 0
print(L)
S = 0
for i in range(N - 2):
    
    for j in range(i + 1, N - 1):
        
        l = L[i] + L[j]
        s = bisect.bisect_left(L, l)
        
        S += bisect.bisect_left(L, L[i] + L[j]) - j - 1

print(S)

Failing test case input:
7
91 574 704 384 645 728 374

Expected output:
25


Actual output:
[91, 374, 384, 574, 645, 704, 728]
25


Fixed program (verdict: Accepted):
import bisect

N = int(input())
L = [int(l) for l in input().split()]
L.sort()
S = 0
n = 0
S = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        l = L[i] + L[j]
        s = bisect.bisect_left(L, l)
        S += bisect.bisect_left(L, L[i] + L[j]) - j - 1

print(S)

Diff:
 import bisect
 
 N = int(input())
 L = [int(l) for l in input().split()]
 L.sort()
 S = 0
 n = 0
-print(L)
 S = 0
 for i in range(N - 2):
-    
     for j in range(i + 1, N - 1):
-        
         l = L[i] + L[j]
         s = bisect.bisect_left(L, l)
-        
         S += bisect.bisect_left(L, L[i] + L[j]) - j - 1
 
 print(S)
Buggy program (verdict: Wrong Answer):
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pab*2*x)
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*y)
    li.append(pab*2*y)
li.sort()
print(li[0])

Failing test case input:
97 2 21 1 8

Expected output:
56


Actual output:
113


Fixed program (verdict: Accepted):
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pab*2*x)
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*x)
    li.append(pab*2*y)
li.sort()
print(li[0])

Diff:
 pa, pb, pab, x, y = map(int, input().split())
 li = []
 if x-y>= 0:
     li.append(pa*x+pb*y)
     li.append(pa*(x-y)+pab*2*y)
     li.append(pab*2*x)
 if y-x>= 0:
     li.append(pa*x+pb*y)
-    li.append(pb*(y-x)+pab*2*y)
+    li.append(pb*(y-x)+pab*2*x)
     li.append(pab*2*y)
 li.sort()
 print(li[0])
Buggy program (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
x=0
b=0
for i in range(n):
    b+=a[i]%2
while a[i]%2==0 :
    x += 1
    for i in range(n):
        a[i]/=2
        b+=a[i]%2
print(x)


Failing test case input:
6
586050932 1892549229 30334838 27068201 10685560 243833698

Expected output:
0


Actual output:
1


Fixed program (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
x=0
b=0
for i in range(n):
    b+=a[i]%2
while b==0 :
    x += 1
    for i in range(n):
        a[i]/=2
        b+=a[i]%2
print(x)


Diff:
 n=int(input())
 a=list(map(int,input().split()))
 x=0
 b=0
 for i in range(n):
     b+=a[i]%2
-while a[i]%2==0 :
+while b==0 :
     x += 1
     for i in range(n):
         a[i]/=2
         b+=a[i]%2
 print(x)
Buggy program (verdict: Wrong Answer):
import sys
sys.setrecursionlimit(1000000)
n = int(input())
a = 0
for i in range(n):
    if (i % 3 !=0) and (i % 5 !=0):
        a += i
    else:
        continue
print(a)


Failing test case input:
1110001

Expected output:
328561110001


Actual output:
328560000000


Fixed program (verdict: Accepted):
import sys
sys.setrecursionlimit(1000000)
n = int(input())
a = 0
for i in range(n+1):
    if (i % 3 !=0) and (i % 5 !=0):
        a += i
    else:
        continue
print(a)


Diff:
 import sys
 sys.setrecursionlimit(1000000)
 n = int(input())
 a = 0
-for i in range(n):
+for i in range(n+1):
     if (i % 3 !=0) and (i % 5 !=0):
         a += i
     else:
         continue
 print(a)
Buggy program (verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(lambda x: x-1, map(int, input().split())))
T = [False]*N

initcount = 0
count = 0
cur = 0
for _ in range(N):
    count += 1
    T[cur] = True
    cur = A[cur]
    if T[cur]:
        break
initcur = 0
for _ in range(count+1):
    initcount += 1
    initcur = A[initcur]
    if initcur == cur:
        break
if count != initcount:
    count -= initcount

if K <= initcount:
    cur = 0
    for _ in range(K):
        cur = A[cur]
    print(cur+1)
    print("aa")
else:
    K -= initcount
    count = K%count
    for _ in range(count):
        cur = A[cur]
    print(cur+1)



Failing test case input:
4 0
3 1 4 1

Expected output:
1


Actual output:
1
aa


Fixed program (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(lambda x: x-1, map(int, input().split())))
T = [False]*N

initcount = 0
count = 0
cur = 0
for _ in range(N):
    count += 1
    T[cur] = True
    cur = A[cur]
    if T[cur]:
        break
initcur = 0
for _ in range(count+1):
    initcount += 1
    initcur = A[initcur]
    if initcur == cur:
        break
if count != initcount:
    count -= initcount

if K <= initcount:
    cur = 0
    for _ in range(K):
        cur = A[cur]
    print(cur+1)
else:
    K -= initcount
    count = K%count
    for _ in range(count):
        cur = A[cur]
    print(cur+1)



Diff:
 N, K = map(int, input().split())
 A = list(map(lambda x: x-1, map(int, input().split())))
 T = [False]*N
 
 initcount = 0
 count = 0
 cur = 0
 for _ in range(N):
     count += 1
     T[cur] = True
     cur = A[cur]
     if T[cur]:
         break
 initcur = 0
 for _ in range(count+1):
     initcount += 1
     initcur = A[initcur]
     if initcur == cur:
         break
 if count != initcount:
     count -= initcount
 
 if K <= initcount:
     cur = 0
     for _ in range(K):
         cur = A[cur]
     print(cur+1)
-    print("aa")
 else:
     K -= initcount
     count = K%count
     for _ in range(count):
         cur = A[cur]
     print(cur+1)
Buggy program (verdict: Wrong Answer):


N, X, Y = map(int, input().split())
X -= 1
Y -= 1
cnt = [0] * N

for i in range(N):
    for j in range(i+1,N):
         tmp = min(j-i, abs(i-X)+abs(j-Y)+1)
         cnt[tmp] += 1

for k in range(1, N):
    print(cnt[k])

print(cnt)

Failing test case input:
19 4 8

Expected output:
19
21
19
18
16
13
12
11
10
9
8
7
5
2
1
0
0
0


Actual output:
19
21
19
18
16
13
12
11
10
9
8
7
5
2
1
0
0
0
[0, 19, 21, 19, 18, 16, 13, 12, 11, 10, 9, 8, 7, 5, 2, 1, 0, 0, 0]


Fixed program (verdict: Accepted):


N, X, Y = map(int, input().split())
X -= 1
Y -= 1
cnt = [0] * N

for i in range(N):
    for j in range(i+1,N):
         tmp = min(j-i, abs(i-X)+abs(j-Y)+1)
         cnt[tmp] += 1

for k in range(1, N):
    print(cnt[k])

Diff:
 
 
 N, X, Y = map(int, input().split())
 X -= 1
 Y -= 1
 cnt = [0] * N
 
 for i in range(N):
     for j in range(i+1,N):
          tmp = min(j-i, abs(i-X)+abs(j-Y)+1)
          cnt[tmp] += 1
 
 for k in range(1, N):
     print(cnt[k])
-
-print(cnt)
Buggy program (verdict: Wrong Answer):
n=int(input())
l=[int(i) for i in input().split()]
c=0
for i in range(1,n):
    c=max(c,max(l[i-1]-l[i],0))
    l[i]+=max(l[i-1]-l[i],0)
print(c)

Failing test case input:
5
2 1 0 8 2

Expected output:
9


Actual output:
6


Fixed program (verdict: Accepted):
n=int(input())
l=[int(i) for i in input().split()]
c=0
for i in range(1,n):
    c+=max(l[i-1]-l[i],0)
    l[i]+=max(l[i-1]-l[i],0)
print(c)

Diff:
 n=int(input())
 l=[int(i) for i in input().split()]
 c=0
 for i in range(1,n):
-    c=max(c,max(l[i-1]-l[i],0))
+    c+=max(l[i-1]-l[i],0)
     l[i]+=max(l[i-1]-l[i],0)
 print(c)
Buggy program (verdict: Wrong Answer):

a,b,c,d = map(float, input().split())

a,b = max(a,c), min(b,d)

a = max(0.0, b-a)

print(a)


Failing test case input:
2 1 -1 0

Expected output:
0


Actual output:
0.0


Fixed program (verdict: Accepted):

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

a,b = max(a,c), min(b,d)

a = max(0, b-a)

print(a)


Diff:
 
-a,b,c,d = map(float, input().split())
+a,b,c,d = map(int, input().split())
 
 a,b = max(a,c), min(b,d)
 
-a = max(0.0, b-a)
+a = max(0, b-a)
 
 print(a)
Buggy program (verdict: Wrong Answer):
A,B,C,D=map(int, input().split())


if abs(B-A)<=D and abs(C-B) <= D:
    print('Yes')
else:
    print('No')

Failing test case input:
-1 111 2 50

Expected output:
Yes


Actual output:
No


Fixed program (verdict: Accepted):
A,B,C,D=map(int, input().split())


if abs(B-A)<=D and abs(C-B) <= D or abs(A-C) <= D:
    print('Yes')
else:
    print('No')

Diff:
 A,B,C,D=map(int, input().split())
 
 
-if abs(B-A)<=D and abs(C-B) <= D:
+if abs(B-A)<=D and abs(C-B) <= D or abs(A-C) <= D:
     print('Yes')
 else:
     print('No')
Buggy program (verdict: Wrong Answer):
def calc(x:list, y:int):
    if x.count(y) == 0:
        return -100
    elif x.count(y) == 1:
        return -1
    elif x.count(y) == 2:
        return 1
    elif x.count(y) > 2:
        return -100

loads = []
for _ in range(3):
    loada, loadb = input().split()
    loads.append(int(loada))
    loads.append(int(loadb))

x = 0
for i in range(1,5):
    print(i, calc(loads, i))
    x = x + calc(loads, i)

if x == 0:
    print('YES')
else:
    print('NO')

Failing test case input:
1 4
2 3
2 3

Expected output:
YES


Actual output:
1 -1
2 1
3 1
4 -1
YES


Fixed program (verdict: Accepted):
def calc(x:list, y:int):
    if x.count(y) == 0:
        return -100
    elif x.count(y) == 1:
        return -1
    elif x.count(y) == 2:
        return 1
    elif x.count(y) > 2:
        return -100

loads = []
for _ in range(3):
    loada, loadb = input().split()
    loads.append(int(loada))
    loads.append(int(loadb))

x = 0
for i in range(1,5):
    x = x + calc(loads, i)

if x == 0:
    print('YES')
else:
    print('NO')

Diff:
 def calc(x:list, y:int):
     if x.count(y) == 0:
         return -100
     elif x.count(y) == 1:
         return -1
     elif x.count(y) == 2:
         return 1
     elif x.count(y) > 2:
         return -100
 
 loads = []
 for _ in range(3):
     loada, loadb = input().split()
     loads.append(int(loada))
     loads.append(int(loadb))
 
 x = 0
 for i in range(1,5):
-    print(i, calc(loads, i))
     x = x + calc(loads, i)
 
 if x == 0:
     print('YES')
 else:
     print('NO')
Buggy program (verdict: Wrong Answer):
import copy

N = int(input())

A = [int(input()) for i in range(N)]

for i in range(N):
    remain = set(A) - set([A[i]])

    if remain == set():
        print(A[i])
    else:
        print(max(remain))

Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
-2
3
-2


Fixed program (verdict: Accepted):
import copy

N = int(input())

A = [int(input()) for i in range(N)]

B = copy.copy(A)
B.sort()

for i in range(N):
    if A[i] == B[-1]:
        print(B[-2])
    else:
        print(B[-1])


Diff:
 import copy
 
 N = int(input())
 
 A = [int(input()) for i in range(N)]
 
-for i in range(N):
-    remain = set(A) - set([A[i]])
+B = copy.copy(A)
+B.sort()
 
-    if remain == set():
-        print(A[i])
+for i in range(N):
+    if A[i] == B[-1]:
+        print(B[-2])
     else:
-        print(max(remain))
+        print(B[-1])
+
Buggy program (verdict: Wrong Answer):


import sys


N = int(input())

a = list(map(int, input().split())) 

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    print(" ".join(map(str, a)))

Failing test case input:
6
0 3 0 1 1 0

Expected output:
0 3 0 1 1 0
0 3 0 1 1 0
0 0 3 1 1 0
0 0 1 3 1 0
0 0 1 1 3 0
0 0 0 1 1 3


Actual output:
0 3 0 1 1 0
0 0 3 1 1 0
0 0 1 3 1 0
0 0 1 1 3 0
0 0 0 1 1 3


Fixed program (verdict: Accepted):


N = int(input())

a = list(map(int, input().split())) 
print(" ".join(map(str, a)))

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    print(" ".join(map(str, a)))

Diff:
 
 
-import sys
-
-
 N = int(input())
 
 a = list(map(int, input().split())) 
+print(" ".join(map(str, a)))
 
 for i in range(1, N):
     tmp = a[i]
     j = i - 1
     while j >= 0 and a[j] > tmp:
         a[j + 1] = a[j]
         j -= 1
     
     a[j + 1] = tmp
     print(" ".join(map(str, a)))
Buggy program (verdict: Wrong Answer):
from bisect import bisect_left
n = int(input())
dp = []
a=[int(input()) for i in range(n)]
length=-1
for i in range(n):
    k = bisect_left(dp, a[i])
    dp.append(a[i])
    if(length < k):
        dp.append(a[i])
        length += 1
    else:   
        dp[k] = a[i]
print(length+1)


Failing test case input:
5
0
2
1
0
11

Expected output:
3


Actual output:
4


Fixed program (verdict: Accepted):
from bisect import bisect_left
n = int(input())
dp = []
a=[int(input()) for i in range(n)]
length=-1
for i in range(n):
    k = bisect_left(dp, a[i])
    if(length < k):
        dp.append(a[i])
        length += 1
    else:   
        dp[k] = a[i]
print(length+1)



Diff:
 from bisect import bisect_left
 n = int(input())
 dp = []
 a=[int(input()) for i in range(n)]
 length=-1
 for i in range(n):
     k = bisect_left(dp, a[i])
-    dp.append(a[i])
     if(length < k):
         dp.append(a[i])
         length += 1
     else:   
         dp[k] = a[i]
 print(length+1)
 
+
Buggy program (verdict: Wrong Answer):
a, b = map(int, input().split())

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

Failing test case input:
1 32

Expected output:
Even


Actual output:
Odd


Fixed program (verdict: Accepted):
a, b = map(int, input().split())

if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")

Diff:
 a, b = map(int, input().split())
 
-if (a % 2 == 0) and (b % 2 == 0):
+if a*b % 2 == 0:
     print("Even")
 else:
     print("Odd")
Buggy program (verdict: Wrong Answer):
A,B,C,K = map(int,input().split())
if A + B >= K:
	print(max(K,A))
else:
	print(A-(K-(A+B)))

Failing test case input:
1 7 3 6

Expected output:
1


Actual output:
6


Fixed program (verdict: Accepted):
A,B,C,K = map(int,input().split())
if A + B >= K:
	print(min(K,A))
else:
	print(A-(K-(A+B)))

Diff:
 A,B,C,K = map(int,input().split())
 if A + B >= K:
-	print(max(K,A))
+	print(min(K,A))
 else:
 	print(A-(K-(A+B)))
Buggy program (verdict: Wrong Answer):
N, M, X = map(int, input().split())
list =  map(int, input().split())
A = sum(x>X for x in list)
B = sum(x<X for x in list)
if A >= B:
  print(B)
else:
  print(A)

Failing test case input:
5 3 3
1 2 4

Expected output:
1

Actual output:
0


Fixed program (verdict: Accepted):
N, M, X = map(int, input().split())
list = list(map(int, input().split()))
A = sum(n > X for n in list)
B = sum(n < X for n in list)
if A >= B:
  print(B)
else:
  print(A)

Diff:
 N, M, X = map(int, input().split())
-list =  map(int, input().split())
-A = sum(x>X for x in list)
-B = sum(x<X for x in list)
+list = list(map(int, input().split()))
+A = sum(n > X for n in list)
+B = sum(n < X for n in list)
 if A >= B:
   print(B)
 else:
   print(A)
Buggy program (verdict: Wrong Answer):
N = int(input())
A1 = input().split()
A2 = input().split()

max_point = 0
point = int(A1[0])
for i in range(N):
    for j in range(i):
        point += int(A1[j])
    for j in range(N-i):
        point += int(A2[i+j])

    if(point > max_point):
        max_point = point
    point = int(A1[0])


print(max_point)

Failing test case input:
7
0 0 -1 0 -1 30 -2
4 0 0 0 -8 -4 1

Expected output:
27


Actual output:
29


Fixed program (verdict: Accepted):
N = int(input())
A1 = input().split()
A2 = input().split()

max_point = 0
point = int(A1[0])
for i in range(N):
    for j in range(i):
        point += int(A1[1+j])
    for j in range(N-i):
        point += int(A2[i+j])

    if(point > max_point):
        max_point = point
    point = int(A1[0])


print(max_point)

Diff:
 N = int(input())
 A1 = input().split()
 A2 = input().split()
 
 max_point = 0
 point = int(A1[0])
 for i in range(N):
     for j in range(i):
-        point += int(A1[j])
+        point += int(A1[1+j])
     for j in range(N-i):
         point += int(A2[i+j])
 
     if(point > max_point):
         max_point = point
     point = int(A1[0])
 
 
 print(max_point)
Buggy program (verdict: Wrong Answer):
sample = input()
sample_list = sample.split(" ")
count = 0
flag = 0
for i in range(len(sample_list)):
  for j in range(1, i):
    if sample_list[i] == sample_list[j]:
      flag = 1
    if flag == 0:
      count += 1
    flag = 0
print(count)


Failing test case input:
94 1 0

Expected output:
3


Actual output:
1


Fixed program (verdict: Accepted):
sample = input()
sample_list = sample.split(" ")
count = 0
flag = 0
i = 0
j = 1
for i in range(len(sample_list)):
  for j in range(i):
    if sample_list[i] == sample_list[j]:
      flag = 1
  if flag == 0:
    count += 1
  flag = 0
print(count)


Diff:
 sample = input()
 sample_list = sample.split(" ")
 count = 0
 flag = 0
+i = 0
+j = 1
 for i in range(len(sample_list)):
-  for j in range(1, i):
+  for j in range(i):
     if sample_list[i] == sample_list[j]:
       flag = 1
-    if flag == 0:
-      count += 1
-    flag = 0
+  if flag == 0:
+    count += 1
+  flag = 0
 print(count)