ZhenlongDai/ACPR huggingface dataset:
Buggy program (verdict: Wrong Answer):
n = int(input())
A = input().split(' ')
count = 0

for i in range(0, n):
    minj = i

    for j in range(i, n):
        if int(A[j]) < int(A[minj]):
            minj = j
            count += 1

    (A[i], A[minj]) = (A[minj], A[i])

print(" ".join(A))
print(count)

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

Expected output:
-1 -1 -1 -1 0 1
2


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


Fixed program (verdict: Accepted):
n = int(input())
A = input().split(' ')
count = 0

for i in range(0, n):
    minj = i

    for j in range(i, n):
        if int(A[j]) < int(A[minj]):
            minj = j

    if i != minj:
        (A[i], A[minj]) = (A[minj], A[i])
        count += 1

print(" ".join(A))
print(count)

Diff:
 n = int(input())
 A = input().split(' ')
 count = 0
 
 for i in range(0, n):
     minj = i
 
     for j in range(i, n):
         if int(A[j]) < int(A[minj]):
             minj = j
-            count += 1
 
-    (A[i], A[minj]) = (A[minj], A[i])
+    if i != minj:
+        (A[i], A[minj]) = (A[minj], A[i])
+        count += 1
 
 print(" ".join(A))
 print(count)
Buggy program (verdict: Wrong Answer):
S = input()
_ans = 0
_S = len(S)
for s in range(1,_S):
  X = (s) % 2
  if X == 1 :
    if S[s] == 'R':
      _ans += 1
     
  if X == 0 :
    if S[s] == 'L' :
      _ans += 1
  
  
if _ans >= 1:
  print ('No')
elif _ans ==0:
  print ('Yes')

Failing test case input:
LLUD

Expected output:
No


Actual output:
Yes


Fixed program (verdict: Accepted):
S = input()
_ans = 0
_S = len(S)
for s in range(0,_S):
  X = (s) % 2
  if X == 1 :
    if S[s] == 'R':
      _ans += 1
     
  if X == 0 :
    if S[s] == 'L' :
      _ans += 1
  
  
if _ans >= 1:
  print ('No')
elif _ans ==0:
  print ('Yes')

Diff:
 S = input()
 _ans = 0
 _S = len(S)
-for s in range(1,_S):
+for s in range(0,_S):
   X = (s) % 2
   if X == 1 :
     if S[s] == 'R':
       _ans += 1
      
   if X == 0 :
     if S[s] == 'L' :
       _ans += 1
   
   
 if _ans >= 1:
   print ('No')
 elif _ans ==0:
   print ('Yes')
Buggy program (verdict: Wrong Answer):




i = list(map(int, input().split()))
a=i[0]
b=i[1]

if a % 2 == 0 or b % 2 == 0:
    print ("even")
    exit (0)

print ("odd")

Failing test case input:
1 32

Expected output:
Even


Actual output:
even


Fixed program (verdict: Accepted):


i = list(map(int, input().split()))
a=i[0]
b=i[1]

if a % 2 == 0 or b % 2 == 0:
    print ("Even")
    exit (0)

print ("Odd")

Diff:
 
 
-
-
 i = list(map(int, input().split()))
 a=i[0]
 b=i[1]
 
 if a % 2 == 0 or b % 2 == 0:
-    print ("even")
+    print ("Even")
     exit (0)
 
-print ("odd")
+print ("Odd")
Buggy program (verdict: Wrong Answer):
k = input()
a, b = input().split()

for cnt in range(int(b)+1):
    if int(a)-1 < cnt:
        if cnt % int(k) == 0:
            print("OK")
            exit()
print("NO")


Failing test case input:
4
2 2

Expected output:
NG


Actual output:
NO


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

for cnt in range(int(b)):
    if cnt+1 >= int(a):
       

        if int(cnt+1)% int(k) == 0 or int(k) == 1:
            print("OK")
            exit()
print("NG")

Diff:
 k = input()
 a, b = input().split()
 
-for cnt in range(int(b)+1):
-    if int(a)-1 < cnt:
-        if cnt % int(k) == 0:
+for cnt in range(int(b)):
+    if cnt+1 >= int(a):
+       
+
+        if int(cnt+1)% int(k) == 0 or int(k) == 1:
             print("OK")
             exit()
-print("NO")
-
+print("NG")
Buggy program (verdict: Wrong Answer):
n = int(input().split()[0])
print(max(0, n - sum(map(int, input().split()))))

Failing test case input:
28 15
8 23 0 34 5 16 151 1 23 8 46 0 0 70 1

Expected output:
-1


Actual output:
0


Fixed program (verdict: Accepted):
n = int(input().split()[0])
print(max(-1, n - sum(map(int, input().split()))))

Diff:
 n = int(input().split()[0])
-print(max(0, n - sum(map(int, input().split()))))
+print(max(-1, n - sum(map(int, input().split()))))
Buggy program (verdict: Wrong Answer):
N = int(input())
s = [ input() for _ in range(N) ]
M = int(input())
t = [ input() for _ in range(M) ]

max_point = -1000
for string in s:
    point = 0
    for i in s:
        if i == string:
            point += 1
    for j in t:
        if j == string:
            point -= 1
    if point > max_point:
        max_point = point
print(max_point)


Failing test case input:
1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort

Expected output:
0

Actual output:
-9


Fixed program (verdict: Accepted):
N = int(input())
s = [ input() for _ in range(N) ]
M = int(input())
t = [ input() for _ in range(M) ]

max_point = 0
for string in s:
    point = 0
    for i in s:
        if i == string:
            point += 1
    for j in t:
        if j == string:
            point -= 1
    if point > max_point:
        max_point = point
print(max_point)


Diff:
 N = int(input())
 s = [ input() for _ in range(N) ]
 M = int(input())
 t = [ input() for _ in range(M) ]
 
-max_point = -1000
+max_point = 0
 for string in s:
     point = 0
     for i in s:
         if i == string:
             point += 1
     for j in t:
         if j == string:
             point -= 1
     if point > max_point:
         max_point = point
 print(max_point)
Buggy program (verdict: Wrong Answer):
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")

Failing test case input:
3
cbaa
d`acc
acacac

Expected output:
ac


Actual output:
a

Fixed program (verdict: Accepted):
n=int(input())
s=[input() for i in range(n)]
l=list("abcdefghijklmnopqrstuvwxyz")
c_tmp=[]
for j in l:
  for i in s:
    c_tmp.append(i.count(j))
  print(j*min(c_tmp),end="")
  c_tmp.clear()

Diff:
 n=int(input())
 s=[input() for i in range(n)]
 l=list("abcdefghijklmnopqrstuvwxyz")
 c_tmp=[]
 for j in l:
   for i in s:
     c_tmp.append(i.count(j))
   print(j*min(c_tmp),end="")
+  c_tmp.clear()
Buggy program (verdict: Wrong Answer):
N,T=map(int,input().split())
cost=1000
for _ in range(N):
    c,t=map(int,input().split())
    if t<=T:
        if cost>=c:
            cost=c
if cost<=1000:
    print(cost)
else:print("TLE")

Failing test case input:
-5 -8
0 0100
2 1
4 0100
6 31

Expected output:
TLE


Actual output:
1000


Fixed program (verdict: Accepted):
N,T=map(int,input().split())
cost=1001
for _ in range(N):
    c,t=map(int,input().split())
    if t<=T:
        cost=min(c,cost)
if cost<=1000:
    print(cost)
else:print("TLE")

Diff:
 N,T=map(int,input().split())
-cost=1000
+cost=1001
 for _ in range(N):
     c,t=map(int,input().split())
     if t<=T:
-        if cost>=c:
-            cost=c
+        cost=min(c,cost)
 if cost<=1000:
     print(cost)
 else:print("TLE")
Buggy program (verdict: Wrong Answer):
n=int(input())
a=[]
for i in range(n):
  a_=list(map(int,input().split()))
  a.append(a_)
  
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
  for k in range(3):
    
    for j in range(3):
      
      if k!=j:
        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i-1][k])

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 3 -1

Expected output:
67


Actual output:
71


Fixed program (verdict: Accepted):
n=int(input())
a=[]
for i in range(n):
  a_=list(map(int,input().split()))
  a.append(a_)
  
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
  for k in range(3):
    
    for j in range(3):
      
      if k!=j:
        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i][k])

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

Diff:
 n=int(input())
 a=[]
 for i in range(n):
   a_=list(map(int,input().split()))
   a.append(a_)
   
 dp=[[0]*3 for i in range(n)]
 dp[0]=a[0]
 for i in range(1,n):
   for k in range(3):
     
     for j in range(3):
       
       if k!=j:
-        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i-1][k])
+        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i][k])
 
 print(max(dp[n-1]))
Buggy program (verdict: Wrong Answer):
K,N = map(int,input().split())
A = list(map(int,input().split()))

m = 0
for i in range(N-1):
    l = A[i+1] - A[i]
    if m <= l:
        m = l
        
if m <= K-A[N-1]+A[0]:
    m = K-A[N-1]+A[0]
    
print(m)

Failing test case input:
3 3
1 8 18

Expected output:
-7


Actual output:
10


Fixed program (verdict: Accepted):
K,N = map(int,input().split())
A = list(map(int,input().split()))

m = 0
for i in range(N-1):
    l = A[i+1] - A[i]
    if m <= l:
        m = l
        
if m <= K-A[N-1]+A[0]:
    m = K-A[N-1]+A[0]
    
print(K-m)

Diff:
 K,N = map(int,input().split())
 A = list(map(int,input().split()))
 
 m = 0
 for i in range(N-1):
     l = A[i+1] - A[i]
     if m <= l:
         m = l
         
 if m <= K-A[N-1]+A[0]:
     m = K-A[N-1]+A[0]
     
-print(m)
+print(K-m)
Buggy program (verdict: Wrong Answer):
def main():
    l, r = map(int, input().split())
    minv = 2019
    if r - l > 2019+1:
        print(0)
    else:
        for i in range(l, r+1):
            for j in range(l, r+1):
                if i < j:
                    minv = min(minv, (i*j)%2019)
    print(minv)

if __name__ == '__main__':
    main()

Failing test case input:
543 3053

Expected output:
0


Actual output:
0
2019


Fixed program (verdict: Accepted):
def main():
    l, r = map(int, input().split())
    minv = 2019
    if r - l > 2019+1:
        print(0)
    else:
        for i in range(l, r+1):
            for j in range(l, r+1):
                if i < j:
                    minv = min(minv, (i*j)%2019)
        print(minv)

if __name__ == '__main__':
    main()

Diff:
 def main():
     l, r = map(int, input().split())
     minv = 2019
     if r - l > 2019+1:
         print(0)
     else:
         for i in range(l, r+1):
             for j in range(l, r+1):
                 if i < j:
                     minv = min(minv, (i*j)%2019)
-    print(minv)
+        print(minv)
 
 if __name__ == '__main__':
     main()
Buggy program (verdict: Wrong Answer):
A, B, C, X, Y = map(int, input().split())

ans = A*X + B*Y

i = 1
while True:
    if X-i < 0 or Y-i < 0:
        break
    cost = A*(X-i) + B*(Y-i) + 2*C*i
    if cost > ans:
        break
    ans = min(cost, ans)
    i += 1

print(ans)


Failing test case input:
251 6 75 6 3

Expected output:
900


Actual output:
1203


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

ans = A*X + B*Y

i = 1
while True:
    cost = A*max(X-i, 0) + B*max(Y-i, 0) + 2*C*i
    if cost > ans:
        break
    ans = min(cost, ans)
    i += 1

print(ans)

Diff:
 A, B, C, X, Y = map(int, input().split())
 
 ans = A*X + B*Y
 
 i = 1
 while True:
-    if X-i < 0 or Y-i < 0:
-        break
-    cost = A*(X-i) + B*(Y-i) + 2*C*i
+    cost = A*max(X-i, 0) + B*max(Y-i, 0) + 2*C*i
     if cost > ans:
         break
     ans = min(cost, ans)
     i += 1
 
 print(ans)
-
Buggy program (verdict: Wrong Answer):
l = list()
l.append(int(input()))
s = set(l)

while(1):
    if(int(l[-1] / 2)):
        l.append(l[-1]/2)
    else:
        l.append(l[-1]*3 + 1)
    s = set(l)
    if(len(s) != len(l)):
        print(len(l))
        break

Failing test case input:
105

Expected output:
40


Actual output:
371


Fixed program (verdict: Accepted):
l = list()
l.append(int(input()))
s = set(l)

while(1):
    if(int(l[-1] % 2) == 0):
        l.append(int(l[-1]/2))
    else:
        l.append(int(l[-1]*3 + 1))
    s = set(l)
    if(len(s) != len(l)):
        print(len(l))
        break

Diff:
 l = list()
 l.append(int(input()))
 s = set(l)
 
 while(1):
-    if(int(l[-1] / 2)):
-        l.append(l[-1]/2)
+    if(int(l[-1] % 2) == 0):
+        l.append(int(l[-1]/2))
     else:
-        l.append(l[-1]*3 + 1)
+        l.append(int(l[-1]*3 + 1))
     s = set(l)
     if(len(s) != len(l)):
         print(len(l))
         break
Buggy program (verdict: Wrong Answer):
result = []
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        result.append('F')
    if m + f >= 80:
        result.append('A')
    if 80 > m + f >= 65:
        result.append('B')
    if 65 > m + f >= 50:
        result.append('C')
    if 50 > m + f >= 30:
        result.append(['D', 'C'][r >= 50])
    if 30 > m + f:
        result.append('F')
for r in result:
    print(r)

Failing test case input:
20 11 -2
30 30 0
1 -1 -1
-1 -1 -1

Expected output:
D
C
F


Actual output:
D
C
F
F


Fixed program (verdict: Accepted):
result = []
while True:
    m, f, r = map(int, input().split())
    if (m, f, r) == (-1, -1, -1):
        break
    if m == -1 or f == -1:
        result.append('F')
        continue
    if m + f >= 80:
        result.append('A')
    if 80 > m + f >= 65:
        result.append('B')
    if 65 > m + f >= 50:
        result.append('C')
    if 50 > m + f >= 30:
        result.append(['D', 'C'][r >= 50])
    if 30 > m + f:
        result.append('F')
for r in result:
    print(r)

Diff:
 result = []
 while True:
     m, f, r = map(int, input().split())
     if (m, f, r) == (-1, -1, -1):
         break
     if m == -1 or f == -1:
         result.append('F')
+        continue
     if m + f >= 80:
         result.append('A')
     if 80 > m + f >= 65:
         result.append('B')
     if 65 > m + f >= 50:
         result.append('C')
     if 50 > m + f >= 30:
         result.append(['D', 'C'][r >= 50])
     if 30 > m + f:
         result.append('F')
 for r in result:
     print(r)
Buggy program (verdict: Wrong Answer):
import math

n = list(map(str, input().split()))
n=n[0]

yes=0
no=0


print(yes,no)
if(no>=8):
  print("NO")
else:
  print("YES")

Failing test case input:
owoxowzoowoxox

Expected output:
YES


Actual output:
0 0
YES


Fixed program (verdict: Accepted):
import math

n = list(map(str, input().split()))
n=n[0]

yes=0
no=0

for i in range(len(n)):
  if(n[i]=='x'):
    no+=1
    
if(no>=8):
  print("NO")
else:
  print("YES")

Diff:
 import math
 
 n = list(map(str, input().split()))
 n=n[0]
 
 yes=0
 no=0
 
-
-print(yes,no)
+for i in range(len(n)):
+  if(n[i]=='x'):
+    no+=1
+    
 if(no>=8):
   print("NO")
 else:
   print("YES")
Buggy program (verdict: Wrong Answer):
n = int(input())
l = list(input())

ans = 100000000
east = 0
west = 0
for i in range(1, n):
    if l[i] == 'E':
        east+=1
ans = east

for i in range(1, n):
    if l[i-1] == 'W':
        west+=1
    elif l[i-1] == 'E':
        east-=1
    ans = min(ans, west + east)
print(ans)


Failing test case input:
8
EWWWWEWE

Expected output:
2


Actual output:
1


Fixed program (verdict: Accepted):
n = int(input())
l = list(input())

ans = 100000000
east = 0
west = 0
for i in range(1, n):
    if l[i] == 'E':
        east+=1
ans = east

if l[0] == 'E':
    east+=1

for i in range(1, n):
    if l[i-1] == 'W':
        west+=1
    elif l[i-1] == 'E':
        east-=1
    if l[i] == 'E':
        ans = min(ans, west + east-1)
    else:
        ans = min(ans, west + east)
print(ans)


Diff:
 n = int(input())
 l = list(input())
 
 ans = 100000000
 east = 0
 west = 0
 for i in range(1, n):
     if l[i] == 'E':
         east+=1
 ans = east
 
+if l[0] == 'E':
+    east+=1
+
 for i in range(1, n):
     if l[i-1] == 'W':
         west+=1
     elif l[i-1] == 'E':
         east-=1
-    ans = min(ans, west + east)
+    if l[i] == 'E':
+        ans = min(ans, west + east-1)
+    else:
+        ans = min(ans, west + east)
 print(ans)
Buggy program (verdict: Wrong Answer):
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])

max = N
min = 0
for i in range(M):
  inputcard = list(map(int, input().split()))
  if min < inputcard[0]:
    min = inputcard[0]
  
  if max > inputcard[1]:
    max = inputcard[1]
  
print(max - min + 1)

Failing test case input:
17 3
3 2
7 7
6 9

Expected output:
0


Actual output:
-4


Fixed program (verdict: Accepted):
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])

max = N
min = 0
for i in range(M):
  inputcard = list(map(int, input().split()))
  if min < inputcard[0]:
    min = inputcard[0]
  
  if max > inputcard[1]:
    max = inputcard[1]
  
if (max - min + 1 < 0):
  print(0)
else:
  print(max - min + 1)

Diff:
 tmp = input().split()
 N = int(tmp[0])
 M = int(tmp[1])
 
 max = N
 min = 0
 for i in range(M):
   inputcard = list(map(int, input().split()))
   if min < inputcard[0]:
     min = inputcard[0]
   
   if max > inputcard[1]:
     max = inputcard[1]
   
-print(max - min + 1)
+if (max - min + 1 < 0):
+  print(0)
+else:
+  print(max - min + 1)
Buggy program (verdict: Wrong Answer):
S = input()
T = input()

success = 0

for i in range(len(S)):
    if S[i:] + S[:i]:
        success += 1

if success >= 1:
    print('Yes')
else:
    print('No')

Failing test case input:
kzqsp
quzmn

Expected output:
No


Actual output:
Yes


Fixed program (verdict: Accepted):
S = input()
T = input()

success = 0

for i in range(len(S)):
    if S[i:] + S[:i] == T:
        success += 1

if success >= 1:
    print('Yes')
else:
    print('No')

Diff:
 S = input()
 T = input()
 
 success = 0
 
 for i in range(len(S)):
-    if S[i:] + S[:i]:
+    if S[i:] + S[:i] == T:
         success += 1
 
 if success >= 1:
     print('Yes')
 else:
     print('No')
Buggy program (verdict: Wrong Answer):
k = int(input())
a,b = map(int,input().split())

flag = False

for i in range(b+1):
    if k * i >= a and k * i <= b:
        flag = True
if flag == True:
    print("Yes")
else:
    print("No")
    

Failing test case input:
4
3 8

Expected output:
OK


Actual output:
Yes


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

flag = False

for i in range(b+1):
    if k * i >= a and k * i <= b:
        flag = True
if flag == True:
    print("OK")
else:
    print("NG")
    

Diff:
 k = int(input())
 a,b = map(int,input().split())
 
 flag = False
 
 for i in range(b+1):
     if k * i >= a and k * i <= b:
         flag = True
 if flag == True:
-    print("Yes")
+    print("OK")
 else:
-    print("No")
+    print("NG")
Buggy program (verdict: Wrong Answer):




antn = list(map(int, open(0).read().split()))
flg = 0
for i in range(0,4):
    for j in range(i+1, 4):
        if (antn[j] - antn[i] > antn[5]):
            flg = 1
print("Yay!" if flg == 0 else ":(")

Failing test case input:
15
5
4
0
38
8

Expected output:
:(


Actual output:
Yay!


Fixed program (verdict: Accepted):




antn = list(map(int, open(0).read().split()))
flg = 0
for i in range(0,4):

    j=0
    for j in range(i+1, 5):
        if (antn[j] - antn[i] > antn[5]):
            flg = 1
print("Yay!" if flg == 0 else ":(")

Diff:
 
 
 
 
 antn = list(map(int, open(0).read().split()))
 flg = 0
 for i in range(0,4):
-    for j in range(i+1, 4):
+
+    j=0
+    for j in range(i+1, 5):
         if (antn[j] - antn[i] > antn[5]):
             flg = 1
 print("Yay!" if flg == 0 else ":(")
Buggy program (verdict: Wrong Answer):
m,f,r=map(int,input().split())


if m+f>=80:
    print("A")

elif 65<=m+f<80:
    print("B")

elif 50<=m+f<65:
    print("C")

elif 30<=m+f<50:
    print("D")

elif 30<m+f<50 and r>50:
    print("C")

elif m+f<30:
    print("F")

elif m or f ==-1:
    print("F")

Failing test case input:
73 64 -1
16 30 -1
1 2 -1
-1 -1 -1

Expected output:
A
D
F


Actual output:
A


Fixed program (verdict: Accepted):
while True:
    m,f,r=map(int,input().split())
    if m==f==r==-1:
        break

    elif m==-1 or f==-1:
        print("F")

    elif m+f>=80:
        print("A")

    elif 65<=m+f<80:
        print("B")

    elif 50<=m+f<65:
        print("C")

    elif r>=50:
        print("C")

    elif 30<=m+f<50:
        print("D")

    else:
        print("F")

Diff:
-m,f,r=map(int,input().split())
+while True:
+    m,f,r=map(int,input().split())
+    if m==f==r==-1:
+        break
 
+    elif m==-1 or f==-1:
+        print("F")
 
-if m+f>=80:
-    print("A")
+    elif m+f>=80:
+        print("A")
 
-elif 65<=m+f<80:
-    print("B")
+    elif 65<=m+f<80:
+        print("B")
 
-elif 50<=m+f<65:
-    print("C")
+    elif 50<=m+f<65:
+        print("C")
 
-elif 30<=m+f<50:
-    print("D")
+    elif r>=50:
+        print("C")
 
-elif 30<m+f<50 and r>50:
-    print("C")
+    elif 30<=m+f<50:
+        print("D")
 
-elif m+f<30:
-    print("F")
-
-elif m or f ==-1:
-    print("F")
+    else:
+        print("F")
Buggy program (verdict: Wrong Answer):
import itertools


n = int(input())



p = input()
q = input()
print(n)
print(p)
i = 0
a = 0 
b = 0

for x in itertools.permutations(range(1,n+1), n):
	
	x = " ".join(map(str,x))
	
	i += 1
	if x == p:
		a = i
		
	elif x == q:
		b = i
		
        
print(abs(a-b))
     

Failing test case input:
3
1 3 2
3 1 2

Expected output:
3

Actual output:
3
1 3 2
3


Fixed program (verdict: Accepted):
import itertools


n = int(input())




p = input()
q = input()


i = 0



for x in itertools.permutations(range(1,n+1), n):
	
	x = " ".join(map(str,x))
	
	i += 1
	if x == p:
		a = i
		
	if x == q:
		b = i
		

print(abs(a-b))
     

Diff:
 import itertools
 
 
 n = int(input())
 
 
 
+
 p = input()
 q = input()
-print(n)
-print(p)
+
+
 i = 0
-a = 0 
-b = 0
+
+
 
 for x in itertools.permutations(range(1,n+1), n):
 	
 	x = " ".join(map(str,x))
 	
 	i += 1
 	if x == p:
 		a = i
 		
-	elif x == q:
+	if x == q:
 		b = i
 		
-        
+
 print(abs(a-b))
Buggy program (verdict: Wrong Answer):
o = input()
o_list = o.split(" ")

p = int(o_list[0])
q = int(o_list[1])
r = int(o_list[2])
pq = p + q
qr = q + r
rp = r + p

if pq <= qr and pq <= rp:
    print(pq)
elif qr <= rp and qr <= pq:
    print(pq)
elif rp <= pq and rp <= qr:
    print(rp)


Failing test case input:
010 -39 -5

Expected output:
-44


Actual output:
-29


Fixed program (verdict: Accepted):
o = input()
o_list = o.split(" ")

p = int(o_list[0])
q = int(o_list[1])
r = int(o_list[2])
pq = p + q
qr = q + r
rp = r + p

if pq <= qr and pq <= rp:
    print(pq)
elif qr <= rp and qr <= pq:
    print(qr)
elif rp <= pq and rp <= qr:
    print(rp)

Diff:
 o = input()
 o_list = o.split(" ")
 
 p = int(o_list[0])
 q = int(o_list[1])
 r = int(o_list[2])
 pq = p + q
 qr = q + r
 rp = r + p
 
 if pq <= qr and pq <= rp:
     print(pq)
 elif qr <= rp and qr <= pq:
-    print(pq)
+    print(qr)
 elif rp <= pq and rp <= qr:
     print(rp)
-
Buggy program (verdict: Wrong Answer):
def nCr(n, r):
    num, den = 1, 1
    for i in range(n, n-r, -1):
        num = num * i % M       
    for i in range(1, r+1):
        den = den * i % M       
    den_inv = pow(den, -1, M)   
    return num * den_inv % M

def is_comb():
    a = 1/3 * (2*X - Y)
    b = 1/3 * (-X + 2*Y)
    if a.is_integer() and b.is_integer():
        return int(a), int(b)
    return 0, 0

M = 10**9 + 7
X, Y  = map(int, input().split())
a, b = is_comb()
if a==b==0:
    print(0)
else:
    n, r  = a+b, a
    print(nCr(n, r))


Failing test case input:
0 195945

Expected output:
0


Actual output:
1


Fixed program (verdict: Accepted):
def nCr(n, r):
    num, den = 1, 1
    for i in range(n, n-r, -1):
        num = num * i % M       
    for i in range(1, r+1):
        den = den * i % M       
    den_inv = pow(den, -1, M)   
    return num * den_inv % M

def is_comb():
    a = 1/3 * (2*X - Y)
    b = 1/3 * (-X + 2*Y)
    if a>=0 and b >= 0 and a.is_integer() and b.is_integer():
        return int(a), int(b)
    return 0, 0

M = 10**9 + 7
X, Y  = map(int, input().split())

a, b = is_comb()   
if a==b==0:
    print(0)
else:
    n, r  = a+b, a
    print(nCr(n, r))

Diff:
 def nCr(n, r):
     num, den = 1, 1
     for i in range(n, n-r, -1):
         num = num * i % M       
     for i in range(1, r+1):
         den = den * i % M       
     den_inv = pow(den, -1, M)   
     return num * den_inv % M
 
 def is_comb():
     a = 1/3 * (2*X - Y)
     b = 1/3 * (-X + 2*Y)
-    if a.is_integer() and b.is_integer():
+    if a>=0 and b >= 0 and a.is_integer() and b.is_integer():
         return int(a), int(b)
     return 0, 0
 
 M = 10**9 + 7
 X, Y  = map(int, input().split())
-a, b = is_comb()
+
+a, b = is_comb()   
 if a==b==0:
     print(0)
 else:
     n, r  = a+b, a
     print(nCr(n, r))
-
Buggy program (verdict: Wrong Answer):
N, X = map(int, input().split())
x = list(map(int, input().split()))
x_gcd = []
for i in range(N):
    x_gcd.append(abs(X-x[i]))


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
ans = [0]*(N-1)

for i in range(N-1):
    ans[i] = gcd(x_gcd[i], x_gcd[i+1])
if ans:
    print(max(ans))
else:
    print(x[0] - X)

Failing test case input:
3 81
17 42 57

Expected output:
1


Actual output:
3


Fixed program (verdict: Accepted):
N, X = map(int, input().split())
x = list(map(int, input().split()))
x_gcd = []
for i in range(N):
    x_gcd.append(abs(X-x[i]))


def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a


ans = x_gcd[0]
for i in range(N):
    ans = gcd(ans, x_gcd[i])
if ans:
    print(ans)
else:
    print(x[0] - X)

Diff:
 N, X = map(int, input().split())
 x = list(map(int, input().split()))
 x_gcd = []
 for i in range(N):
     x_gcd.append(abs(X-x[i]))
 
 
 def gcd(a, b):
     while b != 0:
         a, b = b, a%b
     return a
-ans = [0]*(N-1)
 
-for i in range(N-1):
-    ans[i] = gcd(x_gcd[i], x_gcd[i+1])
+
+ans = x_gcd[0]
+for i in range(N):
+    ans = gcd(ans, x_gcd[i])
 if ans:
-    print(max(ans))
+    print(ans)
 else:
     print(x[0] - X)
Buggy program (verdict: Wrong Answer):
N, A, B = [int(n) for n in input().split()]
if A == 0:
    print(0)
else:
    c , d = divmod(N, A+B)
    print(A*c+d)

Failing test case input:
96 -4 9

Expected output:
-80


Actual output:
-75


Fixed program (verdict: Accepted):
N, A, B = [int(n) for n in input().split()]
if A == 0:
    print(0)
else:
    C, D = divmod(N, A+B)
    print(A*C+min(A, D))

Diff:
 N, A, B = [int(n) for n in input().split()]
 if A == 0:
     print(0)
 else:
-    c , d = divmod(N, A+B)
-    print(A*c+d)
+    C, D = divmod(N, A+B)
+    print(A*C+min(A, D))
Buggy program (verdict: Wrong Answer):
import sys
a,b = map(int,input().split())
s = list(input())
if s[a] != "-":
	print("No")
	sys.exit()
else:
	print("Yes")

Failing test case input:
0 1
-,-

Expected output:
No


Actual output:
Yes


Fixed program (verdict: Accepted):
import sys
a,b = map(int,input().split())
s = list(input())
if s[a] != "-":
	print("No")
	sys.exit()
s[a] = 1
if not "-" in s:
	print("Yes")
else:
	print("No")

Diff:
 import sys
 a,b = map(int,input().split())
 s = list(input())
 if s[a] != "-":
 	print("No")
 	sys.exit()
-else:
+s[a] = 1
+if not "-" in s:
 	print("Yes")
+else:
+	print("No")
Buggy program (verdict: Wrong Answer):
N = int(input())
A = input()
B = input()
C = input()
ans = 0

for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        continue
    elif A[i] != B[i] and B[i] != C[i]:
        ans += 2
    else:
        ans += 1

print(ans)

Failing test case input:
4
wesu
east
w`it

Expected output:
5


Actual output:
6


Fixed program (verdict: Accepted):
N = int(input())
A = input()
B = input()
C = input()
ans = 0

for i in range(N):
    if A[i] == B[i] and B[i] == C[i]:
        continue
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        ans += 2
    else:
        ans += 1

print(ans)

Diff:
 N = int(input())
 A = input()
 B = input()
 C = input()
 ans = 0
 
 for i in range(N):
     if A[i] == B[i] and B[i] == C[i]:
         continue
-    elif A[i] != B[i] and B[i] != C[i]:
+    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
         ans += 2
     else:
         ans += 1
 
 print(ans)
Buggy program (verdict: Wrong Answer):
import math
x=int(input())
f = math.floor(x ** (1/5)) * 5
for i in range(-f-1,f+1):
    for j in range(-f+1,f+1):
        if i**5-j**5==x:
            print(i,j,sep=" ")

Failing test case input:
244

Expected output:
1 -3


Actual output:
1 -3
3 -1


Fixed program (verdict: Accepted):
import math
x=int(input())
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5-j**5==x:
            print(i,j,sep=" ")
            exit()

Diff:
 import math
 x=int(input())
-f = math.floor(x ** (1/5)) * 5
-for i in range(-f-1,f+1):
-    for j in range(-f+1,f+1):
+for i in range(-1000,1000):
+    for j in range(-1000,1000):
         if i**5-j**5==x:
             print(i,j,sep=" ")
+            exit()
Buggy program (verdict: Wrong Answer):
ss=input().strip()
flg=False
for i in range(1,len(ss)):
  if ss[i]==ss[i-1]:
    True
    
if flg==True:
  print("Bad")
else:
  print("Good")

Failing test case input:
22385

Expected output:
Bad


Actual output:
Good


Fixed program (verdict: Accepted):
ss=input().strip()
flg=False
for i in range(1,len(ss)):
  if ss[i]==ss[i-1]:
    flg=True
    
if flg==True:
  print("Bad")
else:
  print("Good")

Diff:
 ss=input().strip()
 flg=False
 for i in range(1,len(ss)):
   if ss[i]==ss[i-1]:
-    True
+    flg=True
     
 if flg==True:
   print("Bad")
 else:
   print("Good")
Buggy program (verdict: Wrong Answer):
x,y=[int(s) for s in input().split()]
ans=0
if x<4:
  ans+=10000
if x<3:
  ans+=10000
if x<2:
  ans+=10000
if y<4:
  ans+=10000
if y<3:
  ans+=10000
if y<2:
  ans+=10000
if x*y==1:
  ans+=40000
print(ans)
  

Failing test case input:
3 21

Expected output:
100000


Actual output:
10000


Fixed program (verdict: Accepted):
x,y=[int(s) for s in input().split()]
ans=0
if x<4:
  ans+=100000
if x<3:
  ans+=100000
if x<2:
  ans+=100000
if y<4:
  ans+=100000
if y<3:
  ans+=100000
if y<2:
  ans+=100000
if x*y==1:
  ans+=400000
print(ans)
  


Diff:
 x,y=[int(s) for s in input().split()]
 ans=0
 if x<4:
-  ans+=10000
+  ans+=100000
 if x<3:
-  ans+=10000
+  ans+=100000
 if x<2:
-  ans+=10000
+  ans+=100000
 if y<4:
-  ans+=10000
+  ans+=100000
 if y<3:
-  ans+=10000
+  ans+=100000
 if y<2:
-  ans+=10000
+  ans+=100000
 if x*y==1:
-  ans+=40000
+  ans+=400000
 print(ans)
   
+
Buggy program (verdict: Wrong Answer):
s = int(input())
count1=-1
count2=-1
while s>=0:
 s=s-500
 count1=count1 +1
s=s+500
print(count1)
if s==0:
  yasashisa=count1*1000
  print(yasashisa)
else:
   while s >=0:
     s=s-5
     count2=count2 +1
   yasashisa=count1*1000+count2* 5
   print(yasashisa)





Failing test case input:
1254

Expected output:
2250


Actual output:
2
2250


Fixed program (verdict: Accepted):
s = int(input())
count1=-1
count2=-1
while s>=0:
 s=s-500
 count1=count1 +1
s=s+500
if s==0:
  yasashisa=count1*1000
  print(yasashisa)
else:
   while s >=0:
     s=s-5
     count2=count2 +1
   yasashisa=count1*1000+count2* 5
   print(yasashisa)





Diff:
 s = int(input())
 count1=-1
 count2=-1
 while s>=0:
  s=s-500
  count1=count1 +1
 s=s+500
-print(count1)
 if s==0:
   yasashisa=count1*1000
   print(yasashisa)
 else:
    while s >=0:
      s=s-5
      count2=count2 +1
    yasashisa=count1*1000+count2* 5
    print(yasashisa)
Buggy program (verdict: Wrong Answer):
a, b = map(int, input().split())
m,n=max(a,b),min(a,b)
if m%n==0:
    print(m)
else:
    while m%n!=0:
        m%=n
        m,n=max(m,n),min(m,n)
print(int(a*b/n))

Failing test case input:
2 68

Expected output:
68


Actual output:
68
68


Fixed program (verdict: Accepted):
a, b = map(int, input().split())
m,n=max(a,b),min(a,b)
if m%n==0:
    print(m)
else:
    while m%n!=0 and n!=1:
        m%=n
        m,n=max(m,n),min(m,n)
    print(int(a*b/n))

Diff:
 a, b = map(int, input().split())
 m,n=max(a,b),min(a,b)
 if m%n==0:
     print(m)
 else:
-    while m%n!=0:
+    while m%n!=0 and n!=1:
         m%=n
         m,n=max(m,n),min(m,n)
-print(int(a*b/n))
+    print(int(a*b/n))
Buggy program (verdict: Wrong Answer):
dg = input().split()
m = int(dg[0])
d = int(dg[1])
count = 0
for i in range(m + 1):
    if i !=0:
        for e in range(d):
            if(len(str(e)) >= 2):
                ee = str(e)
                d1 = int(ee[0])
                d2 = int(ee[1])
                
                if d1*d2 == i and d1 >=2 and d2>=2:
                    count = count +1

                    
                    
print(count)

Failing test case input:
19 28

Expected output:
7


Actual output:
6


Fixed program (verdict: Accepted):
dg = input().split()
m = int(dg[0])
d = int(dg[1])
count = 0
for i in range(m + 1):
    if i !=0:
        for e in range(d + 1):
            if(len(str(e)) >= 2):
                ee = str(e)
                d1 = int(ee[0])
                d2 = int(ee[1])
                
                if d1*d2 == i and d1 >=2 and d2>=2:
                    count = count +1

                    
                    
print(count)

Diff:
 dg = input().split()
 m = int(dg[0])
 d = int(dg[1])
 count = 0
 for i in range(m + 1):
     if i !=0:
-        for e in range(d):
+        for e in range(d + 1):
             if(len(str(e)) >= 2):
                 ee = str(e)
                 d1 = int(ee[0])
                 d2 = int(ee[1])
                 
                 if d1*d2 == i and d1 >=2 and d2>=2:
                     count = count +1
 
                     
                     
 print(count)
Buggy program (verdict: Wrong Answer):
S = input()

if S[0] != S[1] and S[1] != S[2] and S[2] != S[3]:
  print("good")
else:
  print("sad")

Failing test case input:
3291

Expected output:
Good


Actual output:
good


Fixed program (verdict: Accepted):
S = input()

if S[0] != S[1] and S[1] != S[2] and S[2] != S[3]:
  print("Good")
else:
  print("Bad")

Diff:
 S = input()
 
 if S[0] != S[1] and S[1] != S[2] and S[2] != S[3]:
-  print("good")
+  print("Good")
 else:
-  print("sad")
+  print("Bad")
Buggy program (verdict: Wrong Answer):
N = int(input())
num = list(map(int, input().split(" ")))
oparation = 10 ^ 8

for i in range(N):
    temp = 0
    while(1):
        if(num[i] % 2 or num[i] == 0):
            break
        else:
            num[i] /= 2
            temp += 1
    if(oparation > temp):
        oparation = temp

print(oparation)


Failing test case input:
6
382253568 723152896 37802240 379425024 404894720 471526144

Expected output:
8

Actual output:
2


Fixed program (verdict: Accepted):
N = int(input())
num = list(map(int, input().split(" ")))
oparation = 10 ** 8

for i in range(N):
    temp = 0
    while(1):
        if(num[i] % 2 or num[i] == 0):
            break
        else:
            num[i] /= 2
            temp += 1
    if(oparation > temp):
        oparation = temp
        
print(oparation)


Diff:
 N = int(input())
 num = list(map(int, input().split(" ")))
-oparation = 10 ^ 8
+oparation = 10 ** 8
 
 for i in range(N):
     temp = 0
     while(1):
         if(num[i] % 2 or num[i] == 0):
             break
         else:
             num[i] /= 2
             temp += 1
     if(oparation > temp):
         oparation = temp
-
+        
 print(oparation)
Buggy program (verdict: Wrong Answer):
def main():
    N, M = map(int, input().split())
    ans = [False for _ in range(N)]

    ac = 0
    wa = 0

    for _ in range(M):
        i, result = input().split()
        i = int(i)
        if result == "AC":
            if ans[i-1] == False:
                ac += 1
                ans[i - 1] = True
        else:
            if ans[i - 1] == False:
                wa += 1

    print(ac, wa)
    return 0
if __name__ == '__main__':
    main()

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):
def main():
    N, M = map(int, input().split())
    ans = [False for _ in range(N)]
    wa_list = [0 for _ in range(N)]

    ac = 0
    wa = 0

    for _ in range(M):
        i, result = input().split()
        i = int(i)
        if result == "AC":
            if ans[i-1] == False:
                ac += 1
                ans[i - 1] = True
                wa += wa_list[i-1]
        else:
            if ans[i - 1] == False:
                wa_list[i - 1] += 1
    if sum(ans) == 0:
        wa = 0

    print(ac, wa)
    return 0
if __name__ == '__main__':
    main()

Diff:
 def main():
     N, M = map(int, input().split())
     ans = [False for _ in range(N)]
+    wa_list = [0 for _ in range(N)]
 
     ac = 0
     wa = 0
 
     for _ in range(M):
         i, result = input().split()
         i = int(i)
         if result == "AC":
             if ans[i-1] == False:
                 ac += 1
                 ans[i - 1] = True
+                wa += wa_list[i-1]
         else:
             if ans[i - 1] == False:
-                wa += 1
+                wa_list[i - 1] += 1
+    if sum(ans) == 0:
+        wa = 0
 
     print(ac, wa)
     return 0
 if __name__ == '__main__':
     main()
Buggy program (verdict: Wrong Answer):
a, b, c, d = map(int, input().split())
if a > c:
    a, b, c, d = c, d, a, b
if b <= c:
    print(0)
else:
    if b <= d:
        print(b - c)
    else:
        print(c - d)


Failing test case input:
16 90 28 58

Expected output:
30


Actual output:
-30


Fixed program (verdict: Accepted):
a, b, c, d = map(int, input().split())
if a > c:
    a, b, c, d = c, d, a, b
if b <= c:
    print(0)
else:
    if b <= d:
        print(b - c)
    else:
        print(d - c)



Diff:
 a, b, c, d = map(int, input().split())
 if a > c:
     a, b, c, d = c, d, a, b
 if b <= c:
     print(0)
 else:
     if b <= d:
         print(b - c)
     else:
-        print(c - d)
+        print(d - c)
+
Buggy program (verdict: Wrong Answer):
X,A,B=map(int,input().split())

if (A-B)>=0:
    print('delicious')
elif (A-B)<0:
    if abs(A-B)<=X:
        print('safe')
    else :
        print('dengerous')

Failing test case input:
1 -2 10

Expected output:
dangerous


Actual output:
dengerous


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

if (A-B)>=0:
    print('delicious')
elif (A-B)<0:
    if abs(A-B)<=X:
        print('safe')
    else :
        print('dangerous')

Diff:
 X,A,B=map(int,input().split())
 
 if (A-B)>=0:
     print('delicious')
 elif (A-B)<0:
     if abs(A-B)<=X:
         print('safe')
     else :
-        print('dengerous')
+        print('dangerous')
Buggy program (verdict: Wrong Answer):
x = int(input())
for b in range(1,32):
	for p in range(2,32):
		bp = b**p
		if bp <= x:
			ans = bp
print(ans)

Failing test case input:
354

Expected output:
343


Actual output:
324


Fixed program (verdict: Accepted):
x = int(input())
ans = 1
for b in range(1,32):
	for p in range(2,32):
		bp = b**p
		if bp <= x:
			ans = max(bp,ans)
print(ans)

Diff:
 x = int(input())
+ans = 1
 for b in range(1,32):
 	for p in range(2,32):
 		bp = b**p
 		if bp <= x:
-			ans = bp
+			ans = max(bp,ans)
 print(ans)
Buggy program (verdict: Wrong Answer):
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]

choco = X
j = 0

for i in range(N):
  j = 0
  a = 0
  while a <= D:
    a = j*A[i] + 1
    print(a)
    if a <= D:
      choco += 1
    j += 1
    
print(choco)


Failing test case input:
3
13 2
2
10
1

Expected output:
24


Actual output:
1
3
5
7
9
11
13
15
1
11
21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
24


Fixed program (verdict: Accepted):
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for i in range(N)]

choco = X

for i in range(N):
  j = 0
  a = 0
  while a <= D:
    a = j*A[i] + 1
    if a <= D:
      choco += 1
    j += 1
    
print(choco)


Diff:
 N = int(input())
 D, X = map(int, input().split())
 A = [int(input()) for i in range(N)]
 
 choco = X
-j = 0
 
 for i in range(N):
   j = 0
   a = 0
   while a <= D:
     a = j*A[i] + 1
-    print(a)
     if a <= D:
       choco += 1
     j += 1
     
 print(choco)
Buggy program (verdict: Wrong Answer):
import sys

N = int(input())

dp = [[0]*3  for i in range(N)]

dp[0][0], dp[0][1], dp[0][2] = map(int, sys.stdin.readline().split())

tmp = [0, 0, 0]

for i in range(1, N):
    tmp[0], tmp[1], tmp[2] = map(int, sys.stdin.readline().split())
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[(j+2)%3], dp[i-1][(j+2)%3]+tmp[(j+2)%3])

print(max(dp[N-1]))

Failing test case input:
7
5 1 66
0 1 1
0 2 -2
5 4 1
0 12 0
0 1 12
2 1 -5

Expected output:
99


Actual output:
100


Fixed program (verdict: Accepted):
import sys

N = int(input())

dp = [[0]*3  for i in range(N)]

dp[0][0], dp[0][1], dp[0][2] = map(int, sys.stdin.readline().split())

tmp = [0, 0, 0]

for i in range(1, N):
    tmp[0], tmp[1], tmp[2] = map(int, sys.stdin.readline().split())
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[j], dp[i-1][(j+2)%3]+tmp[j])

print(max(dp[N-1]))

Diff:
 import sys
 
 N = int(input())
 
 dp = [[0]*3  for i in range(N)]
 
 dp[0][0], dp[0][1], dp[0][2] = map(int, sys.stdin.readline().split())
 
 tmp = [0, 0, 0]
 
 for i in range(1, N):
     tmp[0], tmp[1], tmp[2] = map(int, sys.stdin.readline().split())
     for j in range(3):
-        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[(j+2)%3], dp[i-1][(j+2)%3]+tmp[(j+2)%3])
+        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[j], dp[i-1][(j+2)%3]+tmp[j])
 
 print(max(dp[N-1]))
Buggy program (verdict: Wrong Answer):
N = int(input())
A =[i for i in input().split()]
A = sorted(A,reverse=True)
Alice = 0
Bob = 0
while len(A) != 0:
    Alice += int(A.pop(0))
    if len(A) == 0:
        break
    else:
        Bob += int(A.pop(0))
print(Alice - Bob)

Failing test case input:
4
139 1 2 5

Expected output:
135


Actual output:
141


Fixed program (verdict: Accepted):
N = int(input())
A =[i for i in map(int,input().split())]
A = sorted(A,reverse=True)
Alice = 0
Bob = 0
while len(A) != 0:
    Alice += int(A.pop(0))
    if len(A) == 0:
        break
    else:
        Bob += int(A.pop(0))

print(Alice - Bob)

Diff:
 N = int(input())
-A =[i for i in input().split()]
+A =[i for i in map(int,input().split())]
 A = sorted(A,reverse=True)
 Alice = 0
 Bob = 0
 while len(A) != 0:
     Alice += int(A.pop(0))
     if len(A) == 0:
         break
     else:
         Bob += int(A.pop(0))
+
 print(Alice - Bob)
Buggy program (verdict: Wrong Answer):
a , b  = map(int,input().split())
print(min( int( str(a) * b) , int( str(b) * a)))

Failing test case input:
67 1

Expected output:
1111111111111111111111111111111111111111111111111111111111111111111


Actual output:
67


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

Diff:
 a , b  = map(int,input().split())
-print(min( int( str(a) * b) , int( str(b) * a)))
+print(min(str(a) * b ,str(b) * a))
Buggy program (verdict: Wrong Answer):
K = int(input())
A = list(map(int, input().split()))
d=A[1]-A[0]
ok=0
if d==0:
    if A[0]%K==0:
        print("OK")
        ok+=1
        
for i in range(d):
    if A[0]%K==0:
        print("OK")
        ok+=1
        break
    else:
        a=A[0]
        A[0]=a+1

if ok==0:
    print("NG")


Failing test case input:
4
3 4

Expected output:
OK


Actual output:
NG


Fixed program (verdict: Accepted):
K = int(input())
A = list(map(int, input().split()))
d=A[1]-A[0]+1
ok=0

for i in range(d):
    if A[0]%K==0:
        print("OK")
        ok+=1
        break
    else:
        a=A[0]
        A[0]=a+1

if ok==0:
    print("NG")


Diff:
 K = int(input())
 A = list(map(int, input().split()))
-d=A[1]-A[0]
+d=A[1]-A[0]+1
 ok=0
-if d==0:
-    if A[0]%K==0:
-        print("OK")
-        ok+=1
-        
+
 for i in range(d):
     if A[0]%K==0:
         print("OK")
         ok+=1
         break
     else:
         a=A[0]
         A[0]=a+1
 
 if ok==0:
     print("NG")
Buggy program (verdict: Wrong Answer):
s=str(input())
if s.count('1')>s.count('0'):
    print(s.count('1')-s.count('0'))
else:
    print(s.count('0')-s.count('1'))


Failing test case input:
01001000101001

Expected output:
10


Actual output:
4


Fixed program (verdict: Accepted):
s=str(input())
if s.count('1')>s.count('0'):
    print(s.count('0')*2)
else:
    print(s.count('1')*2)

Diff:
 s=str(input())
 if s.count('1')>s.count('0'):
-    print(s.count('1')-s.count('0'))
+    print(s.count('0')*2)
 else:
-    print(s.count('0')-s.count('1'))
-
+    print(s.count('1')*2)
Buggy program (verdict: Wrong Answer):
K = int(input())
A,B = map(int,input().split())
c = 0

if (B-A) >= K:
  print("OK")
else:
  for i in range(K):
    if ( A + i ) < B:
      if ( A + i ) % K == 0:
        print("OK")
        c = 1
        break
if c == 0:
  print("NG")
    

Failing test case input:
4
-1 95

Expected output:
OK


Actual output:
OK
NG


Fixed program (verdict: Accepted):
K = int(input())
A,B = map(int,input().split())
c = 0

if (B-A) >= K:
  print("OK")
  c = 1
else:
  for i in range(K):
    if ( A + i ) <= B:
      if ( A + i ) % K == 0:
        print("OK")
        c = 1
        break
if c == 0:
  print("NG")

Diff:
 K = int(input())
 A,B = map(int,input().split())
 c = 0
 
 if (B-A) >= K:
   print("OK")
+  c = 1
 else:
   for i in range(K):
-    if ( A + i ) < B:
+    if ( A + i ) <= B:
       if ( A + i ) % K == 0:
         print("OK")
         c = 1
         break
 if c == 0:
   print("NG")
-
Buggy program (verdict: Wrong Answer):


def Insertion_Sort():
    N=int(input())
    A=list(map(int,input().split()))
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j=j-1
        A[j+1]=v
        
        print(A[0],end="")
        for i in range(1,N):
            print(" {}".format(A[i]),end="")
        print('\n',end="")
        


if __name__ == "__main__":
    Insertion_Sort()

    


Failing test case input:
6
5 4 5 7 1 3

Expected output:
5 4 5 7 1 3
4 5 5 7 1 3
4 5 5 7 1 3
4 5 5 7 1 3
1 4 5 5 7 3
1 3 4 5 5 7


Actual output:
4 5 5 7 1 3
4 5 5 7 1 3
4 5 5 7 1 3
1 4 5 5 7 3
1 3 4 5 5 7


Fixed program (verdict: Accepted):


def Insertion_Sort():
    N=int(input())
    A=list(map(int,input().split()))
    for i in range(0,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j=j-1
        A[j+1]=v
        
        print(A[0],end="")
        for i in range(1,N):
            print(" {}".format(A[i]),end="")
        print('\n',end="")
        


if __name__ == "__main__":
    Insertion_Sort()

    



Diff:
 
 
 def Insertion_Sort():
     N=int(input())
     A=list(map(int,input().split()))
-    for i in range(1,N):
+    for i in range(0,N):
         v=A[i]
         j=i-1
         while j>=0 and A[j]>v:
             A[j+1]=A[j]
             j=j-1
         A[j+1]=v
         
         print(A[0],end="")
         for i in range(1,N):
             print(" {}".format(A[i]),end="")
         print('\n',end="")
         
 
 
 if __name__ == "__main__":
     Insertion_Sort()
 
     
 
+
Buggy program (verdict: Wrong Answer):
if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] <= a[2] and a[1] >=a[2]:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    elif a[0] <= a[3] and a[1] >=a[3]:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    else:
        print(0)




Failing test case input:
-1 33 66 10

Expected output:
0


Actual output:
-56


Fixed program (verdict: Accepted):
if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if min(a[3],a[1]) - max(a[0],a[2]) > 0:
        print(min(a[3],a[1]) - max(a[0],a[2]))
    else:
        print(0)





Diff:
 if __name__ == '__main__':
     a = [int(i) for i in input().split()]
 
-    if a[0] <= a[2] and a[1] >=a[2]:
-        print(min(a[3],a[1]) - max(a[0],a[2]))
-    elif a[0] <= a[3] and a[1] >=a[3]:
+    if min(a[3],a[1]) - max(a[0],a[2]) > 0:
         print(min(a[3],a[1]) - max(a[0],a[2]))
     else:
         print(0)
 
 
 
+
Buggy program (verdict: Wrong Answer):
N=input()
arr=input().split()

min=int(arr[0])
cnt=0
for i in range(len(arr)):
    if min >= int(arr[i]):
        cnt+=1
    else:
        min = int(arr[i])

print(cnt)

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

Expected output:
2


Actual output:
3


Fixed program (verdict: Accepted):
N=input()
arr=input().split()

min=int(arr[0])
cnt=0
for i in range(len(arr)):
    if min >= int(arr[i]):
        cnt+=1
        min = int(arr[i])
print(cnt)

Diff:
 N=input()
 arr=input().split()
 
 min=int(arr[0])
 cnt=0
 for i in range(len(arr)):
     if min >= int(arr[i]):
         cnt+=1
-    else:
         min = int(arr[i])
-
 print(cnt)
Buggy program (verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
Max = a[0]
ans = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        Max = a[i+1]
    else:
        ans += Max-a[i+1]
print(ans)

Failing test case input:
5
16 2 5 8 2

Expected output:
47


Actual output:
20


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

Diff:
 n = int(input())
 a = list(map(int, input().split()))
 Max = a[0]
 ans = 0
-for i in range(n-1):
-    if a[i] < a[i+1]:
-        Max = a[i+1]
+for i in range(1, n):
+    if Max < a[i]:
+        Max = a[i]
     else:
-        ans += Max-a[i+1]
+        ans += Max-a[i]
 print(ans)