ZhenlongDai/ACPR huggingface dataset:
Buggy program (verdict: Wrong Answer):
n, m = map(int,input().split())
box = [[1,0] for i in range(n)]
box[0][1] = 1
ans = 1

for i in range(m):
    x, y = map(int,input().split())
    box[x-1][0] -= 1
    box[y-1][0] += 1
    if box[x-1][1] == 1:
        if box[y-1][1] == 0:
            box[y-1][1] = 1
            ans += 1
        if box[x-1][0] == 0:
            ans -= 1

print(ans)


Failing test case input:
6 4
1 2
2 0
4 1
1 0

Expected output:
2


Actual output:
1


Fixed program (verdict: Accepted):
n, m = map(int,input().split())
box = [[1,0] for i in range(n)]
box[0][1] = 1
ans = 1

for i in range(m):
    x, y = map(int,input().split())
    if box[x-1][0] == 0:
        continue
    box[x-1][0] -= 1
    box[y-1][0] += 1
    if box[x-1][1] == 1:
        if box[y-1][1] == 0:
            box[y-1][1] = 1
            ans += 1
        if box[x-1][0] == 0:
            box[x-1][1] = 0
            ans -= 1


print(ans)




Diff:
 n, m = map(int,input().split())
 box = [[1,0] for i in range(n)]
 box[0][1] = 1
 ans = 1
 
 for i in range(m):
     x, y = map(int,input().split())
+    if box[x-1][0] == 0:
+        continue
     box[x-1][0] -= 1
     box[y-1][0] += 1
     if box[x-1][1] == 1:
         if box[y-1][1] == 0:
             box[y-1][1] = 1
             ans += 1
         if box[x-1][0] == 0:
+            box[x-1][1] = 0
             ans -= 1
 
+
 print(ans)
 
+
+
Buggy program (verdict: Wrong Answer):
A,B=list(map(int,input().split()))
C=0
for i in range(1):
    if A>B:
        C+=A
        A=A-1
    else:
        C+=B
        B=B-1
print(C)

Failing test case input:
-4 -16

Expected output:
-9


Actual output:
-4


Fixed program (verdict: Accepted):
A,B=list(map(int,input().split()))
C=0
for i in range(2):
    if A>B:
        C+=A
        A=A-1
    else:
        C+=B
        B=B-1
print(C)

Diff:
 A,B=list(map(int,input().split()))
 C=0
-for i in range(1):
+for i in range(2):
     if A>B:
         C+=A
         A=A-1
     else:
         C+=B
         B=B-1
 print(C)
Buggy program (verdict: Wrong Answer):
newArray = []

x, y = input().split()

while x + y != "00":
    if x < y or x == y:
        newArray.append([x, y])
    else:
        newArray.append([y, x])
    x, y = input().split()

for i in range(len(newArray)):
    print(newArray[i][0] + " " + newArray[i][1])

Failing test case input:
4 -1
0 2
18 3
0 0

Expected output:
-1 4
0 2
3 18


Actual output:
-1 4
0 2
18 3


Fixed program (verdict: Accepted):
newArray = []

x, y = input().split()

while x + y != "00":
    x = int(x)
    y = int(y)
    if x < y or x == y:
        newArray.append([str(x), str(y)])
    else:
        newArray.append([str(y), str(x)])
    x, y = input().split()

for i in range(len(newArray)):
    print(newArray[i][0] + " " + newArray[i][1])

Diff:
 newArray = []
 
 x, y = input().split()
 
 while x + y != "00":
+    x = int(x)
+    y = int(y)
     if x < y or x == y:
-        newArray.append([x, y])
+        newArray.append([str(x), str(y)])
     else:
-        newArray.append([y, x])
+        newArray.append([str(y), str(x)])
     x, y = input().split()
 
 for i in range(len(newArray)):
     print(newArray[i][0] + " " + newArray[i][1])
Buggy program (verdict: Wrong Answer):
N, M = map(int, input().split())
L = 0
R = N
for i in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r)

print(L - R + 1)

Failing test case input:
14 3
3 6
7 7
6 9

Expected output:
0


Actual output:
2


Fixed program (verdict: Accepted):
N, M = map(int, input().split())
L = 0
R = N
for i in range(M):
    l, r = map(int, input().split())
    L = max(L, l)
    R = min(R, r)

print(max(0, R - L + 1))

Diff:
 N, M = map(int, input().split())
 L = 0
 R = N
 for i in range(M):
     l, r = map(int, input().split())
     L = max(L, l)
     R = min(R, r)
 
-print(L - R + 1)
+print(max(0, R - L + 1))
Buggy program (verdict: Wrong Answer):
S = input()
T = input()

max_cnt = 0
max_ind = 0
for i in range(len(S)-len(T)):
  cnt = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      cnt += 1
    max_cnt = max(max_cnt, cnt)
print(len(T) - max_cnt)

Failing test case input:
ccbaac
aac

Expected output:
0


Actual output:
2


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

max_cnt = 0
for i in range(len(S)-len(T)+1):
  cnt = 0
  for j in range(len(T)):
    if S[i+j] == T[j]:
      cnt += 1
    max_cnt = max(max_cnt, cnt)
print(len(T) - max_cnt)

Diff:
 S = input()
 T = input()
 
 max_cnt = 0
-max_ind = 0
-for i in range(len(S)-len(T)):
+for i in range(len(S)-len(T)+1):
   cnt = 0
   for j in range(len(T)):
     if S[i+j] == T[j]:
       cnt += 1
     max_cnt = max(max_cnt, cnt)
 print(len(T) - max_cnt)
Buggy program (verdict: Wrong Answer):
N=int(input())
P=list(map(int,input().split()))
ans=1
MIN=10**6
for i in range(1,N):
  MIN=min(MIN,P[i])
  if MIN>=P[i]:
    ans+=1
print(ans)    

Failing test case input:
6
2 6 17 0 2 19

Expected output:
2


Actual output:
3


Fixed program (verdict: Accepted):
N=int(input())
P=list(map(int,input().split()))
ans=0
MIN=10**6
for i in range(N):
  MIN=min(MIN,P[i])
  if MIN>=P[i]:
    ans+=1
print(ans)   

Diff:
 N=int(input())
 P=list(map(int,input().split()))
-ans=1
+ans=0
 MIN=10**6
-for i in range(1,N):
+for i in range(N):
   MIN=min(MIN,P[i])
   if MIN>=P[i]:
     ans+=1
-print(ans)    
+print(ans)
Buggy program (verdict: Wrong Answer):
a = list(map(int,input().split()))
A = a[0]
B = a[1]
K = a[2]
taka = A
aoki = B
if K < A:
    aoki = B
    taka = A - K
elif K>=(A+B):
    pass
else:
    taka = 0
    b = K - A
    aoki = B - b
print(str(taka)+" "+str(aoki))

Failing test case input:
223869749260 13514692621 1010010100011

Expected output:
0 0


Actual output:
223869749260 13514692621


Fixed program (verdict: Accepted):
a = list(map(int,input().split()))
A = a[0]
B = a[1]
K = a[2]
taka = A
aoki = B
if K < A:
    aoki = B
    taka = A - K
elif K>=(A+B):
    taka = 0
    aoki = 0
else:
    
    taka = 0
    b = K - A
    aoki = B - b
print(str(taka)+" "+str(aoki))

Diff:
 a = list(map(int,input().split()))
 A = a[0]
 B = a[1]
 K = a[2]
 taka = A
 aoki = B
 if K < A:
     aoki = B
     taka = A - K
 elif K>=(A+B):
-    pass
+    taka = 0
+    aoki = 0
 else:
+    
     taka = 0
     b = K - A
     aoki = B - b
 print(str(taka)+" "+str(aoki))
Buggy program (verdict: Wrong Answer):
a,b=(int(x) for x in input().split())
gcc=1
i=2
while True:
    if(a<i or b<i):
        break
    elif (a%i==0 and b%i==0):
        print(i)
        gcc*=i
        a/=i
        b/=i
        i=2
    else:
        i+=1

print(int(a*b*gcc))

Failing test case input:
001000 22

Expected output:
11000


Actual output:
2
11000


Fixed program (verdict: Accepted):
a,b=(int(x) for x in input().split())
gcc=1
i=2
while True:
    if(a<i or b<i):
        break
    elif (a%i==0 and b%i==0):
        gcc*=i
        a/=i
        b/=i
        i=2
    else:
        i+=1

print(int(a*b*gcc))


Diff:
 a,b=(int(x) for x in input().split())
 gcc=1
 i=2
 while True:
     if(a<i or b<i):
         break
     elif (a%i==0 and b%i==0):
-        print(i)
         gcc*=i
         a/=i
         b/=i
         i=2
     else:
         i+=1
 
 print(int(a*b*gcc))
+
Buggy program (verdict: Wrong Answer):
a, b, c = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1 and c % 2 == 1:
    print(b * c)
else:
    print(0)


Failing test case input:
3 5 5

Expected output:
15


Actual output:
25


Fixed program (verdict: Accepted):
a, b, c = list(map(int, input().split()))
if a % 2 == 1 and b % 2 == 1 and c % 2 == 1:
    print(min(a*b, b*c, a*c))
else:
    print(0)


Diff:
 a, b, c = list(map(int, input().split()))
 if a % 2 == 1 and b % 2 == 1 and c % 2 == 1:
-    print(b * c)
+    print(min(a*b, b*c, a*c))
 else:
     print(0)
Buggy program (verdict: Wrong Answer):
i = [input() for i in range(2)]

if 1 not in i:
  print("1")
elif 2 not in i:
  print("2")
else:
  print("3")

Failing test case input:
3
001

Expected output:
2


Actual output:
1


Fixed program (verdict: Accepted):
i = [int(input()) for i in range(2)]

if 1 not in i:
  print("1")
elif 2 not in i:
  print("2")
else:
  print("3")

Diff:
-i = [input() for i in range(2)]
+i = [int(input()) for i in range(2)]
 
 if 1 not in i:
   print("1")
 elif 2 not in i:
   print("2")
 else:
   print("3")
Buggy program (verdict: Wrong Answer):
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    for y in range(x, k + 1):
        for z in range(y, k + 1):
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 3
print(cnt)


Failing test case input:
100 58

Expected output:
1770


Actual output:
930


Fixed program (verdict: Accepted):
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)


Diff:
 k, s = [int(x) for x in input().split()]
 cnt = 0
 for x in range(k + 1):
+    if x > s:
+        continue
     for y in range(x, k + 1):
-        for z in range(y, k + 1):
+        if y > s:
+            break
+        z = s - x - y
+        if y <= z and z <= k:
             if x + y + z == s:
                 if x == y == z:
                     cnt += 1
                 elif x == y or y == z:
                     cnt += 3
                 else:
-                    cnt += 3
+                    cnt += 6
 print(cnt)
Buggy program (verdict: Wrong Answer):
_,x=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
for i,j in enumerate(l):
  tmp+=j
  if tmp>x:
    print(i+1)
    exit()
  

Failing test case input:
4 9
4 0 -1 5

Expected output:
5


Actual output:

Fixed program (verdict: Accepted):
_,x=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
for i,j in enumerate(l):
  tmp+=j
  if tmp>x:
    print(i+1)
    exit()
print(len(l)+1)

Diff:
 _,x=map(int,input().split())
 l=list(map(int,input().split()))
 tmp=0
 for i,j in enumerate(l):
   tmp+=j
   if tmp>x:
     print(i+1)
     exit()
-  
+print(len(l)+1)
Buggy program (verdict: Wrong Answer):
A , B, C = map(int, input().split())
L = [A,B,C]
if not len(set(L)) == len(L):
    print("No")
else:
    print("Yes")

Failing test case input:
5 5 6

Expected output:
Yes


Actual output:
No


Fixed program (verdict: Accepted):
A , B, C = map(int, input().split())
L = [A,B,C]
if len(set(L)) == 2:
    print("Yes")
else:
    print("No")

Diff:
 A , B, C = map(int, input().split())
 L = [A,B,C]
-if not len(set(L)) == len(L):
-    print("No")
-else:
+if len(set(L)) == 2:
     print("Yes")
+else:
+    print("No")
Buggy program (verdict: Wrong Answer):
n = int(input())
ans = 0
if n < 10:
  ans += n
else:
  ans += 9
  if n < 1000:
    ans += max(0, n-100)
  else:
    ans += 900
    if n < 100000:
      ans += max(0, n-10000)
    else:
      ans += 90000
print(ans)


Failing test case input:
215

Expected output:
125


Actual output:
124


Fixed program (verdict: Accepted):
n = int(input())
ans = 0
if n < 10:
  ans += n
else:
  ans += 9
  if n < 1000:
    ans += max(0, n-99)
  else:
    ans += 900
    if n < 100000:
      ans += max(0, n-9999)
    else:
      ans += 90000
print(ans)


Diff:
 n = int(input())
 ans = 0
 if n < 10:
   ans += n
 else:
   ans += 9
   if n < 1000:
-    ans += max(0, n-100)
+    ans += max(0, n-99)
   else:
     ans += 900
     if n < 100000:
-      ans += max(0, n-10000)
+      ans += max(0, n-9999)
     else:
       ans += 90000
 print(ans)

Buggy program (verdict: Wrong Answer):
n = int(input())
ans = 0
for i in range(1,n+1):
  if len(str(i)) == 1:
    ans += 1
    
print(ans)

Failing test case input:
289

Expected output:
199


Actual output:
9


Fixed program (verdict: Accepted):
n = int(input())
ans = 0
for i in range(1,n+1):
  if len(str(i))%2 == 1:
    ans += 1
    
print(ans)

Diff:
 n = int(input())
 ans = 0
 for i in range(1,n+1):
-  if len(str(i)) == 1:
+  if len(str(i))%2 == 1:
     ans += 1
     
 print(ans)
Buggy program (verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
p=[1,-1]
j=[-1,1]
c=0
l=0
d=0
e=0
for i in range(n):
    s=i%2
    c+=a[i]
    l+=a[i]
    print(c,l)
    if p[s]*c<=0:
        d+=abs(c-p[s])
        c=p[s]
    if j[s]*l<=0:
        e+=abs(l-j[s])
        l=j[s] 
print(min(e,d))

Failing test case input:
4
1 -3 1 0

Expected output:
4

Actual output:
1 1
-2 -4
-1 2
1 -1
4


Fixed program (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
p=[1,-1]
j=[-1,1]
c=0
l=0
d=0
e=0
for i in range(n):
    s=i%2
    c+=a[i]
    l+=a[i]
    if p[s]*c<=0:
        d+=abs(c-p[s])
        c=p[s]
    if j[s]*l<=0:
        e+=abs(l-j[s])
        l=j[s] 
print(min(e,d))

Diff:
 n=int(input())
 a=list(map(int,input().split()))
 p=[1,-1]
 j=[-1,1]
 c=0
 l=0
 d=0
 e=0
 for i in range(n):
     s=i%2
     c+=a[i]
     l+=a[i]
-    print(c,l)
     if p[s]*c<=0:
         d+=abs(c-p[s])
         c=p[s]
     if j[s]*l<=0:
         e+=abs(l-j[s])
         l=j[s] 
 print(min(e,d))
Buggy program (verdict: Wrong Answer):
a = input().split()
c, d = map(int, input().split())
e = input()

if (e == a): c -= 1
else: d -= 1

print("{}" "{}" "{}".format(c," ",d))


Failing test case input:
red blue
10 1
red

Expected output:
9 1


Actual output:
10 0


Fixed program (verdict: Accepted):
a = input().split()
c, d = map(int, input().split())
e = input()

if (e == a[0]): c -= 1
else: d -= 1

print("{}" "{}" "{}".format(c," ",d))


Diff:
 a = input().split()
 c, d = map(int, input().split())
 e = input()
 
-if (e == a): c -= 1
+if (e == a[0]): c -= 1
 else: d -= 1
 
 print("{}" "{}" "{}".format(c," ",d))
Buggy program (verdict: Wrong Answer):
a, b = list(map(int, input().split()))

aa = str(a)
bb = ''
for i in range(a):
	bb += str(b)

for i in range(b):
	aa += str(a)


if int(aa) > int(bb):
	print(bb)
else:
	print(aa)


Failing test case input:
67 1

Expected output:
1111111111111111111111111111111111111111111111111111111111111111111


Actual output:
6767


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

aa = ''
bb = ''
for i in range(a):
	bb += str(b)

for i in range(b):
	aa += str(a)


if aa > bb:
	print(bb)
else:
	print(aa)


Diff:
 a, b = list(map(int, input().split()))
 
-aa = str(a)
+aa = ''
 bb = ''
 for i in range(a):
 	bb += str(b)
 
 for i in range(b):
 	aa += str(a)
 
 
-if int(aa) > int(bb):
+if aa > bb:
 	print(bb)
 else:
 	print(aa)
Buggy program (verdict: Wrong Answer):
N,C,K=map(int,input().split())
T=[int(input())for i in range(N)]
T.sort()
ans=0
bus_seat=0
tmp_time=0
for i in range(len(T)):
    if T[i]>=tmp_time+K:
        bus_seat=0
    if bus_seat==0:
        ans+=1
        tmp_time=T[i]
    
    bus_seat+=1
    if bus_seat==C:
        bus_seat=0
print(ans)

Failing test case input:
5 5 5
1
1
3
6
12

Expected output:
2


Actual output:
3


Fixed program (verdict: Accepted):
N,C,K=map(int,input().split())
T=[int(input())for i in range(N)]
T.sort()
ans=0
bus_seat=0
tmp_time=0
for i in range(len(T)):
    if T[i]>tmp_time+K:
        bus_seat=0
    if bus_seat==0:
        ans+=1
        tmp_time=T[i]
    
    bus_seat+=1
    if bus_seat==C:
        bus_seat=0
print(ans)

Diff:
 N,C,K=map(int,input().split())
 T=[int(input())for i in range(N)]
 T.sort()
 ans=0
 bus_seat=0
 tmp_time=0
 for i in range(len(T)):
-    if T[i]>=tmp_time+K:
+    if T[i]>tmp_time+K:
         bus_seat=0
     if bus_seat==0:
         ans+=1
         tmp_time=T[i]
     
     bus_seat+=1
     if bus_seat==C:
         bus_seat=0
 print(ans)
Buggy program (verdict: Wrong Answer):
import math
A, B, N = map(int, input().split())

left = -1
right = N
def check(x):
    global A, B
    return math.floor(A * x / B) - A * math.floor(x / B)

if B == N:
    print(check(N - 1))
else:
    print(check(N))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


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

left = -1
right = N
def check(x):
    global A, B
    return math.floor(A * x / B) - A * math.floor(x / B)

if B <= N:
    print(check(B - 1))
else:
    print(check(N))



Diff:
 import math
 A, B, N = map(int, input().split())
 
 left = -1
 right = N
 def check(x):
     global A, B
     return math.floor(A * x / B) - A * math.floor(x / B)
 
-if B == N:
-    print(check(N - 1))
+if B <= N:
+    print(check(B - 1))
 else:
     print(check(N))
 
+
Buggy program (verdict: Wrong Answer):
import math
from statistics import mean

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

m = mean(a)
if m - math.floor(m) < 0.5:
    m = math.floor(m)
else:
    m = math.floor(m) + 1

diff = 0
for v in a:
    diff = (m - v) ** 2

print(diff)


Failing test case input:
3
-20 0 -3

Expected output:
233


Actual output:
25


Fixed program (verdict: Accepted):
import math
from statistics import mean

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

m = mean(a)
if m - math.floor(m) < 0.5:
    m = math.floor(m)
else:
    m = math.floor(m) + 1

diff = 0
for v in a:
    diff += (m - v) ** 2

print(diff)


Diff:
 import math
 from statistics import mean
 
 n = int(input())
 a = list(map(int, input().split()))
 
 m = mean(a)
 if m - math.floor(m) < 0.5:
     m = math.floor(m)
 else:
     m = math.floor(m) + 1
 
 diff = 0
 for v in a:
-    diff = (m - v) ** 2
+    diff += (m - v) ** 2
 
 print(diff)
Buggy program (verdict: Wrong Answer):
import collections

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

cc = dict(collections.Counter(lst))
ans = 0
for i in cc.values():
  if (i == 1):
    ans += 1
print(ans)

Failing test case input:
3
1
1
1

Expected output:
1


Actual output:
0


Fixed program (verdict: Accepted):
import collections

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

cc = dict(collections.Counter(lst))
ans = 0
for i in cc.values():
  if (i % 2 != 0):
    ans += 1
print(ans)

Diff:
 import collections
 
 N = int(input())
 lst = [int(input()) for i in range(N)]
 
 cc = dict(collections.Counter(lst))
 ans = 0
 for i in cc.values():
-  if (i == 1):
+  if (i % 2 != 0):
     ans += 1
 print(ans)
Buggy program (verdict: Wrong Answer):
x,y = map(int,input().split())
if x * y == 1:
    print(1000000)
elif x*y == 2:
    print(500000)
elif x == 2 and y == 2:
    print(400000)
elif x*y == 3:
    print(400000)
elif x == 1 or y == 1:
    print(300000)
elif x == 2 and y == 3:
    print(300000)
elif x == 3 and y == 2:
    print(300000)
elif x == 3 and y == 3:
    print(200000)
elif x == 3 or y == 3:
    print(100000)
else:
    print(0)

Failing test case input:
2 122

Expected output:
200000


Actual output:
0


Fixed program (verdict: Accepted):
x,y = map(int,input().split())
if x * y == 1:
    print(1000000)
elif x*y == 2:
    print(500000)
elif x == 2 and y == 2:
    print(400000)
elif x*y == 3:
    print(400000)
elif x == 1 or y == 1:
    print(300000)
elif x == 2 and y == 3:
    print(300000)
elif x == 3 and y == 2:
    print(300000)
elif x == 3 and y == 3:
    print(200000)
elif x ==2 or y == 2:
    print(200000)
    
elif x == 3 or y == 3:
    print(100000)
else:
    print(0)

Diff:
 x,y = map(int,input().split())
 if x * y == 1:
     print(1000000)
 elif x*y == 2:
     print(500000)
 elif x == 2 and y == 2:
     print(400000)
 elif x*y == 3:
     print(400000)
 elif x == 1 or y == 1:
     print(300000)
 elif x == 2 and y == 3:
     print(300000)
 elif x == 3 and y == 2:
     print(300000)
 elif x == 3 and y == 3:
     print(200000)
+elif x ==2 or y == 2:
+    print(200000)
+    
 elif x == 3 or y == 3:
     print(100000)
 else:
     print(0)
Buggy program (verdict: Wrong Answer):
K, T = map(int, input().split())
A = list(map(int, input().split()))

if T == 1:
    print(K)
    exit()
print(max(0, max(A) - (K-max(A)+1)))

Failing test case input:
7 1
1 1 2

Expected output:
0


Actual output:
7


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

print(max(0, max(A) - (K-max(A)+1)))

Diff:
 K, T = map(int, input().split())
 A = list(map(int, input().split()))
 
-if T == 1:
-    print(K)
-    exit()
 print(max(0, max(A) - (K-max(A)+1)))
Buggy program (verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
cnt=[]
m=0
ans=0
for i in range(n):
  if a[m] in d:
    ans+=1
    cnt.append(a[m])
    if ans==k:
      print(a[m])
    break
  else:
    d[a[m]]=0
    cnt.append(a[m])
    ans+=1
    if ans==k:
      print(a[m])
      break
    m=a[m]-1
if ans!=k:
  print(cnt[(k-ans)%len(cnt)])

Failing test case input:
6 2190427306125562200
6 4 6 2 3 3

Expected output:
3


Actual output:
6


Fixed program (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
cnt=[]
m=0
ans=0
for i in range(2*n):
  if a[m] in d:
    ans+=1
    cnt.append(a[m])
    if ans==k:
      print(a[m])
    break
  else:
    d[a[m]]=0
    cnt.append(a[m])
    ans+=1
    if ans==k:
      print(a[m])
      break
    m=a[m]-1
if ans!=k:
  if cnt[-1]==cnt[-2]:
    print(cnt[-1])
  else:
    cnt=cnt[cnt.index(cnt[-1]):-1]
    print(cnt[(k-ans)%len(cnt)])

Diff:
 n,k=map(int,input().split())
 a=list(map(int,input().split()))
 d={}
 cnt=[]
 m=0
 ans=0
-for i in range(n):
+for i in range(2*n):
   if a[m] in d:
     ans+=1
     cnt.append(a[m])
     if ans==k:
       print(a[m])
     break
   else:
     d[a[m]]=0
     cnt.append(a[m])
     ans+=1
     if ans==k:
       print(a[m])
       break
     m=a[m]-1
 if ans!=k:
-  print(cnt[(k-ans)%len(cnt)])
+  if cnt[-1]==cnt[-2]:
+    print(cnt[-1])
+  else:
+    cnt=cnt[cnt.index(cnt[-1]):-1]
+    print(cnt[(k-ans)%len(cnt)])
Buggy program (verdict: Wrong Answer):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))


Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed program (verdict: Accepted):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)+1):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))


Diff:
 n = int(input())
 s = input()
 I, D = [], []
-for i in range(len(s)):
+for i in range(len(s)+1):
     I.append(s[0:i].count('I'))
     D.append(s[0:i].count('D'))
 print(max([i - d for i, d in zip(I, D)]))
Buggy program (verdict: Wrong Answer):
N,K = map(int,input().split())
H = list(map(int,input().split()))
if N<=K:
    print(0)
else:
    print(sum(H[:N-K]))

Failing test case input:
8 2
6 9 8 0 2 4 8 6

Expected output:
26


Actual output:
29


Fixed program (verdict: Accepted):
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
if N<=K:
    print(0)
else:
    print(sum(H[:N-K]))

Diff:
 N,K = map(int,input().split())
 H = list(map(int,input().split()))
+H.sort()
 if N<=K:
     print(0)
 else:
     print(sum(H[:N-K]))
Buggy program (verdict: Wrong Answer):
n = input()
sum = 0
if n[0] == "1" and n[1:-1]=="0"*(len(n)-1):
  print("10")
else:
  for i in range(len(n)):
    sum +=int(i)
  print(sum)

Failing test case input:
234

Expected output:
9


Actual output:
3


Fixed program (verdict: Accepted):
n = input()
sum = 0
if n[0] == "1" and n[1:len(n)]=="0"*(len(n)-1):
  print("10")
else:
  for i in range(len(n)):
    sum +=int(n[i])
  print(sum)

Diff:
 n = input()
 sum = 0
-if n[0] == "1" and n[1:-1]=="0"*(len(n)-1):
+if n[0] == "1" and n[1:len(n)]=="0"*(len(n)-1):
   print("10")
 else:
   for i in range(len(n)):
-    sum +=int(i)
+    sum +=int(n[i])
   print(sum)
Buggy program (verdict: Wrong Answer):
A, B, C, K = map(int,input().split())

if K < A:
    print(K)
if A <= K < A + B:
    print(A)
if A + B <= K < A + B + C:
    print(2*A + B - K)
    

Failing test case input:
2000000000 0 0 2000000000

Expected output:
2000000000

Actual output:

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

if K < A:
    print(K)
if A <= K < A + B:
    print(A)
if A + B <= K <= A + B + C:
    print(2*A + B - K)
    

Diff:
 A, B, C, K = map(int,input().split())
 
 if K < A:
     print(K)
 if A <= K < A + B:
     print(A)
-if A + B <= K < A + B + C:
+if A + B <= K <= A + B + C:
     print(2*A + B - K)
Buggy program (verdict: Wrong Answer):
N = int(input())
T,A = map(int, input().split())
H = input().split() 
Hls = []

c = 1
for i in H:
    Hls.append((abs(A - (T - int(i)*0.006)),int(c)))
    c = c+1



Failing test case input:
2
12 5
1000 2000

Expected output:
1

Actual output:

Fixed program (verdict: Accepted):
N = int(input())
T,A = map(int, input().split())
H = input().split() 
Hls = []

c = 1
for i in H:
    Hls.append((abs(A - (T - int(i)*0.006)),int(c)))
    c = c+1

print(min(Hls)[1])

Diff:
 N = int(input())
 T,A = map(int, input().split())
 H = input().split() 
 Hls = []
 
 c = 1
 for i in H:
     Hls.append((abs(A - (T - int(i)*0.006)),int(c)))
     c = c+1
 
-
+print(min(Hls)[1])
Buggy program (verdict: Wrong Answer):
s = int(input())
a = [s]
ans = -1
for i in range(1000000):
    if ans != -1:
        if a[-1] % 2 == 0:
            a.append(a[-1]/2)
        else:
            a.append(3*a[-1]+1)    

        for j in range(len(a)-1):
            if a[-1] == a[j]:
                ans = len(a)
                break
    else:
        print(ans)
        break

Failing test case input:
601

Expected output:
58


Actual output:
-1


Fixed program (verdict: Accepted):
s = int(input())
a = [s]
ans = -1
for i in range(1000000):
    if ans == -1:
        if a[-1] % 2 == 0:
            a.append(a[-1]/2)
        else:
            a.append(3*a[-1]+1)    

        for j in range(len(a)-1):
            if a[-1] == a[j]:
                ans = len(a)
                break
    else:
        print(ans)
        break

Diff:
 s = int(input())
 a = [s]
 ans = -1
 for i in range(1000000):
-    if ans != -1:
+    if ans == -1:
         if a[-1] % 2 == 0:
             a.append(a[-1]/2)
         else:
             a.append(3*a[-1]+1)    
 
         for j in range(len(a)-1):
             if a[-1] == a[j]:
                 ans = len(a)
                 break
     else:
         print(ans)
         break
Buggy program (verdict: Wrong Answer):
s = input()
for i in s:
  if i == ',':
    i = ' '
print(s)


Failing test case input:
fbtka,spselsf/sucka

Expected output:
fbtka spselsf/sucka


Actual output:
fbtka,spselsf/sucka


Fixed program (verdict: Accepted):
s = input()
for i in s:
  if i == ',':
    i = ' '
  print(i,end="")

print()


Diff:
 s = input()
 for i in s:
   if i == ',':
     i = ' '
-print(s)
+  print(i,end="")
+
+print()
Buggy program (verdict: Wrong Answer):
K, N = map(int, input().split())
A = list(map(int, input().split()))

B = []
for i in range(len(A) - 1):
    B.append(A[i + 1] - A[i])
B.append(K - A[-1])

print(sum(sorted(B)[:-1]))

Failing test case input:
8 3
2 8 64

Expected output:
-48


Actual output:
-50


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

B = []
for i in range(len(A) - 1):
    B.append(A[i + 1] - A[i])
B.append(A[0] + K - A[-1])

print(sum(sorted(B)[:-1]))

Diff:
 K, N = map(int, input().split())
 A = list(map(int, input().split()))
 
 B = []
 for i in range(len(A) - 1):
     B.append(A[i + 1] - A[i])
-B.append(K - A[-1])
+B.append(A[0] + K - A[-1])
 
 print(sum(sorted(B)[:-1]))
Buggy program (verdict: Wrong Answer):
n=int(input())
a=[]
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.append(b)
a.append(c)
d=[]
cnd=a[0][0]
for i in range(n):
  for j in range(n):
    if i>j+1:
      cnd+=a[0][j]
    else:
      cnd+=a[1][j]
  d.append(cnd)
  cnd=a[0][min(n-1,i+1)]
print(max(d))

  


Failing test case input:
7
-1 4 -1 4 2 16 0
136 4 -4 6 -1 -1 -1

Expected output:
138


Actual output:
143


Fixed program (verdict: Accepted):
n=int(input())
a=[]
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.append(b)
a.append(c)
d=[]
cnd=a[0][0]
for i in range(n):
  for j in range(n):
    if i>j:
      cnd+=a[0][j]
    else:
      cnd+=a[1][j]
  d.append(cnd)
  cnd=a[0][min(n-1,i+1)]
print(max(d))

  


Diff:
 n=int(input())
 a=[]
 b=list(map(int,input().split()))
 c=list(map(int,input().split()))
 a.append(b)
 a.append(c)
 d=[]
 cnd=a[0][0]
 for i in range(n):
   for j in range(n):
-    if i>j+1:
+    if i>j:
       cnd+=a[0][j]
     else:
       cnd+=a[1][j]
   d.append(cnd)
   cnd=a[0][min(n-1,i+1)]
 print(max(d))
Buggy program (verdict: Wrong Answer):



N, M = map(int, input().split())
x, y = [], []

for i in range(M):
    x_tmp, y_tmp = map(int, input().split())
    x.append(x_tmp)
    y.append(y_tmp)

box = [1] * N 
ball_set = set()
ball_set.add(1)
start_flg = True
for i in range(len(x)):
    ball_set.add(y[i])
    box[x[i] - 1] -= 1
    box[y[i] - 1] += 1
    if box[x[i] - 1] == 0:
        ball_set.discard(x[i])

print(len(ball_set))



Failing test case input:
6 2
2 0
2 6

Expected output:
1


Actual output:
3


Fixed program (verdict: Accepted):



N, M = map(int, input().split())
x, y = [], []

for i in range(M):
    x_tmp, y_tmp = map(int, input().split())
    x.append(x_tmp)
    y.append(y_tmp)

box = [1] * N 
ball_set = set()
ball_set.add(1)
start_flg = True
for i in range(len(x)):
    if x[i] in ball_set:
        ball_set.add(y[i])
    box[x[i] - 1] -= 1
    box[y[i] - 1] += 1
    if box[x[i] - 1] == 0:
        ball_set.discard(x[i])

print(len(ball_set))



Diff:
 
 
 
 N, M = map(int, input().split())
 x, y = [], []
 
 for i in range(M):
     x_tmp, y_tmp = map(int, input().split())
     x.append(x_tmp)
     y.append(y_tmp)
 
 box = [1] * N 
 ball_set = set()
 ball_set.add(1)
 start_flg = True
 for i in range(len(x)):
-    ball_set.add(y[i])
+    if x[i] in ball_set:
+        ball_set.add(y[i])
     box[x[i] - 1] -= 1
     box[y[i] - 1] += 1
     if box[x[i] - 1] == 0:
         ball_set.discard(x[i])
 
 print(len(ball_set))
Buggy program (verdict: Wrong Answer):

N = int(input())
a = list(map(int,input().split()))
print(a)
ans=0
for i, v in enumerate(a):
    if v != None:
        if a[v-1] == i+1:
            ans+=1
            a[v-1] = None
print(ans)

Failing test case input:
5
4 0 5 1 1

Expected output:
1


Actual output:
[4, 0, 5, 1, 1]
1


Fixed program (verdict: Accepted):

N = int(input())
a = list(map(int,input().split()))
ans=0
for i, v in enumerate(a):
    if v != None:
        if a[v-1] == i+1:
            ans+=1
            a[v-1] = None
print(ans)

Diff:
 
 N = int(input())
 a = list(map(int,input().split()))
-print(a)
 ans=0
 for i, v in enumerate(a):
     if v != None:
         if a[v-1] == i+1:
             ans+=1
             a[v-1] = None
 print(ans)
Buggy program (verdict: Wrong Answer):
a,b,c,x,y=map(int,input().split())
if a+b<=2*c: print(a*x+b*y)
else:
    ans=min(x,y)*2*c
    print(ans)
    dif=abs(x-y)
    if x>y:
        if a>=2*c:
            ans+=2*dif*c
        else:
            ans+=a*dif
    else:
        if b>=2*c:
            ans+=2*dif*c
        else:
            ans+=b*dif
    print(ans)

Failing test case input:
1500 2000 1166 0 2

Expected output:
4000


Actual output:
0
4000


Fixed program (verdict: Accepted):
a,b,c,x,y=map(int,input().split())
if a+b<=2*c: print(a*x+b*y)
else:
    ans=min(x,y)*2*c
    dif=abs(x-y)
    if x>y:
        if a>=2*c:
            ans+=2*dif*c
        else:
            ans+=a*dif
    else:
        if b>=2*c:
            ans+=2*dif*c
        else:
            ans+=b*dif
    print(ans)

Diff:
 a,b,c,x,y=map(int,input().split())
 if a+b<=2*c: print(a*x+b*y)
 else:
     ans=min(x,y)*2*c
-    print(ans)
     dif=abs(x-y)
     if x>y:
         if a>=2*c:
             ans+=2*dif*c
         else:
             ans+=a*dif
     else:
         if b>=2*c:
             ans+=2*dif*c
         else:
             ans+=b*dif
     print(ans)
Buggy program (verdict: Wrong Answer):
first = input().split()
n = int(first[0])
r = int(first[1])
while n != 0 or r != 0:
    i = 0
    card = list(range(1,n+1))[::-1]
    while i < r:
        sh = input().split()
        p, c = list(map(int,sh))
        card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:]
        i = i + 1
    print(card)
    next = input().split()
    n, r = list(map(int,next))

Failing test case input:
5 0
3 1
3 1
2 3
1 10
10 1
8 1
0 0

Expected output:
5
1
2


Actual output:
[5, 4, 3, 2, 1]
[1, 3, 2]
[2, 1]


Fixed program (verdict: Accepted):
first = input().split()
n = int(first[0])
r = int(first[1])
while n != 0 or r != 0:
    i = 0
    card = list(range(1,n+1))[::-1]
    while i < r:
        sh = input().split()
        p, c = list(map(int,sh))
        card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:]
        i = i + 1
    print(card[0])
    next = input().split()
    n, r = list(map(int,next))

Diff:
 first = input().split()
 n = int(first[0])
 r = int(first[1])
 while n != 0 or r != 0:
     i = 0
     card = list(range(1,n+1))[::-1]
     while i < r:
         sh = input().split()
         p, c = list(map(int,sh))
         card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:]
         i = i + 1
-    print(card)
+    print(card[0])
     next = input().split()
     n, r = list(map(int,next))
Buggy program (verdict: Wrong Answer):

a, b = map(str, input().split())

A = int(a * int(b))
B = int(b * int(a))

if A > B:
  print(A)
else:
  print(B)
  
print(B)

Failing test case input:
1 76

Expected output:
1111111111111111111111111111111111111111111111111111111111111111111111111111


Actual output:
1111111111111111111111111111111111111111111111111111111111111111111111111111
76


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

A = int(a * int(b))
B = int(b * int(a))

if A > B:
  print(A)
else:
  print(B)
  

Diff:
-
 a, b = map(str, input().split())
 
 A = int(a * int(b))
 B = int(b * int(a))
 
 if A > B:
   print(A)
 else:
   print(B)
   
-print(B)
Buggy program (verdict: Wrong Answer):
n=int(input())
if n%2==1:
    print(0)
else:
    n=round(n/2)
    k=0
    while n>0:
        k+=round(n/5)
        n=round(n/5)
    print(k)


Failing test case input:
1000000011000000100

Expected output:
125000001375000004


Actual output:
125000001375000022


Fixed program (verdict: Accepted):
n=int(input())
if n%2==1:
    print(0)
else:
    n=(n
    k=0
    while n>0:
        k+=(n
        n=(n
    print(k)


Diff:
 n=int(input())
 if n%2==1:
     print(0)
 else:
-    n=round(n/2)
+    n=(n
     k=0
     while n>0:
-        k+=round(n/5)
-        n=round(n/5)
+        k+=(n
+        n=(n
     print(k)
Buggy program (verdict: Wrong Answer):
import math
import collections
def f(a,b,x):
    return math.floor((a*x)/b) - a*math.floor(x/b)
a,b,n=map(int, input().split())
dd = collections.defaultdict(int)

if(f(a,b,b-1)>0):
    print(f(a,b,b-1))
else:
    print(0)


Failing test case input:
2 11 0

Expected output:
0


Actual output:
1


Fixed program (verdict: Accepted):
import math
import collections
def f(a,b,x):
    return math.floor((a*x)/b) - a*math.floor(x/b)
a,b,n=map(int, input().split())
dd = collections.defaultdict(int)

print(f(a,b,min(b-1,n)))


Diff:
 import math
 import collections
 def f(a,b,x):
     return math.floor((a*x)/b) - a*math.floor(x/b)
 a,b,n=map(int, input().split())
 dd = collections.defaultdict(int)
 
-if(f(a,b,b-1)>0):
-    print(f(a,b,b-1))
-else:
-    print(0)
+print(f(a,b,min(b-1,n)))
Buggy program (verdict: Wrong Answer):
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
x = [0]*n
import sys
for i in t:
    if not i in d:
        print('NO')
        sys.exit()
    x[d.index(i)] += 1
print('YES') if max(x) == 1 else print('NO')

Failing test case input:
15
1 2 2 3 4 3 4 7 8 6 8 3 1 5 7
9
7 4 1 4 1 2 3 8 5

Expected output:
YES


Actual output:
NO


Fixed program (verdict: Accepted):
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
import sys
from collections import Counter
d = Counter(d)
for i in t:
    if not i in d:
        print('NO')
        sys.exit()
    d[i] -= 1
print('YES') if min(d.values()) >= 0 else print('NO')

Diff:
 n = int(input())
 d = [int(i) for i in input().split()]
 m = int(input())
 t = [int(i) for i in input().split()]
-x = [0]*n
 import sys
+from collections import Counter
+d = Counter(d)
 for i in t:
     if not i in d:
         print('NO')
         sys.exit()
-    x[d.index(i)] += 1
-print('YES') if max(x) == 1 else print('NO')
+    d[i] -= 1
+print('YES') if min(d.values()) >= 0 else print('NO')
Buggy program (verdict: Wrong Answer):
n=input()
s=list(input())
x=0
l=[]
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
    l.append(x)
print(max(l))


Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed program (verdict: Accepted):
n=input()
s=list(input())
x=0
l=[0]
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
    l.append(x)
print(max(l))

Diff:
 n=input()
 s=list(input())
 x=0
-l=[]
+l=[0]
 for i in s:
     if i=="I":
         x+=1
     elif i=="D":
         x-=1
     l.append(x)
 print(max(l))
-
Buggy program (verdict: Wrong Answer):
(N,K) = map(int,input().split())
h = list(map(int,input().split()))
n = 2
cost = [0]*N
cost[1] = abs(h[1]-h[0])
for n in range(2,N):
    costmin = 10**10
    for i in range(max(0,n-K),min(n,K)):
        costmin = min(costmin,cost[i]+abs(h[n]-h[i]))
    cost[n] = costmin
    
print(cost[N-1])

Failing test case input:
3 1
10 31 10

Expected output:
42


Actual output:
10000000000


Fixed program (verdict: Accepted):
(N,K) = map(int,input().split())
h = list(map(int,input().split()))
n = 2
cost = [0]*N
cost[1] = abs(h[1]-h[0])
for n in range(2,N):
    costmin = 10**10
    for i in range(max(0,n-K),n):
        costmin = min(costmin,cost[i]+abs(h[n]-h[i]))
    cost[n] = costmin
    
print(cost[N-1])

Diff:
 (N,K) = map(int,input().split())
 h = list(map(int,input().split()))
 n = 2
 cost = [0]*N
 cost[1] = abs(h[1]-h[0])
 for n in range(2,N):
     costmin = 10**10
-    for i in range(max(0,n-K),min(n,K)):
+    for i in range(max(0,n-K),n):
         costmin = min(costmin,cost[i]+abs(h[n]-h[i]))
     cost[n] = costmin
     
 print(cost[N-1])
Buggy program (verdict: Wrong Answer):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
if K == 2:
    print(N-1)
else:
    ans = ceil(N/(K-1))
    print(ans)


Failing test case input:
3 3
0 2 4

Expected output:
1


Actual output:
1
2


Fixed program (verdict: Accepted):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
elif (N-1)%(K-1) == 0:
    print((N-1)
elif K == 2:
    print(N-1)
else:
    ans = ceil(N/(K-1))
    print(ans)


Diff:
 from math import ceil
 N, K = map(int, input().split())
 A = list(map(int, input().split()))
 if N == K:
     print(1)
-if K == 2:
+elif (N-1)%(K-1) == 0:
+    print((N-1)
+elif K == 2:
     print(N-1)
 else:
     ans = ceil(N/(K-1))
     print(ans)
Buggy program (verdict: Wrong Answer):
x,y=map(int,input().split())
if x==1 and y==1:
    print(1000000)
    exit()
a=[300000,200000,100000]
if x>3:
    x=0
if y>3:
    y=0
if x==0 and y==0:
    print(0)
    exit()
print(a[x-1]+a[y-1])

Failing test case input:
2 122

Expected output:
200000


Actual output:
300000


Fixed program (verdict: Accepted):
x,y=map(int,input().split())
if x==1 and y==1:
    print(1000000)
    exit()
a=[300000,200000,100000,0]
if x>3:
    x=0
if y>3:
    y=0
if x==0 and y==0:
    print(0)
    exit()
print(a[x-1]+a[y-1])

Diff:
 x,y=map(int,input().split())
 if x==1 and y==1:
     print(1000000)
     exit()
-a=[300000,200000,100000]
+a=[300000,200000,100000,0]
 if x>3:
     x=0
 if y>3:
     y=0
 if x==0 and y==0:
     print(0)
     exit()
 print(a[x-1]+a[y-1])
Buggy program (verdict: Wrong Answer):
N, M = map(int, input().split())

penalty = 0
a = [[False, 0] for i in range(N)]
count = 0

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if a[p][0] == False:
        if S == 'WA':
            a[p][1] += 1
        else:
            a[p][0] = True
            count += 1
    else:
        pass

print(count, sum([a[i][1] for i in range(N)]))

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

penalty = 0
a = [[False, 0] for i in range(N)]
count = 0

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if a[p][0] == False:
        if S == 'WA':
            a[p][1] += 1
        else:
            a[p][0] = True
            count += 1
    else:
        pass

print(count, sum([a[i][1] for i in range(N) if a[i][0] is True]))

Diff:
 N, M = map(int, input().split())
 
 penalty = 0
 a = [[False, 0] for i in range(N)]
 count = 0
 
 for i in range(M):
     p, S = input().split()
     p = int(p) - 1
     if a[p][0] == False:
         if S == 'WA':
             a[p][1] += 1
         else:
             a[p][0] = True
             count += 1
     else:
         pass
 
-print(count, sum([a[i][1] for i in range(N)]))
+print(count, sum([a[i][1] for i in range(N) if a[i][0] is True]))
Buggy program (verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
s = 0

for i in range(0, n - 1):
    h = a[i] - a[i+1]
    if h > 0:
        s += h
        a[i] += h

print(str(s))


Failing test case input:
5
10 1 5 2 3

Expected output:
29


Actual output:
12


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

for i in range(0, n - 1):
    h = a[i] - a[i+1]
    if h > 0:
        s += h
        a[i+1] = a[i]

print(str(s))


Diff:
 n = int(input())
 a = list(map(int, input().split()))
 s = 0
 
 for i in range(0, n - 1):
     h = a[i] - a[i+1]
     if h > 0:
         s += h
-        a[i] += h
+        a[i+1] = a[i]
 
 print(str(s))
Buggy program (verdict: Wrong Answer):
N=int(input())
s=input()
t=input()
for i in range(len(s),-1,-1):
  if s[-i:]==t[:i]:
    break
print(s+t[i:])

Failing test case input:
1
[
~

Expected output:
2


Actual output:
[~


Fixed program (verdict: Accepted):
N=int(input())
s=input()
t=input()
for i in range(len(s),-1,-1):
  if s[-i:]==t[:i]:
    break
print(len(s+t[i:]))

Diff:
 N=int(input())
 s=input()
 t=input()
 for i in range(len(s),-1,-1):
   if s[-i:]==t[:i]:
     break
-print(s+t[i:])
+print(len(s+t[i:]))
Buggy program (verdict: Wrong Answer):
n = int(input())

l = list(map(int, input().split()))
thr = sum(l) / 2

for i in range(n):
  if l[i] > thr:
    print("No")
else: print("Yes")

Failing test case input:
4
12 -5 -2 -1

Expected output:
No


Actual output:
No
Yes


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

l = list(map(int, input().split()))
thr = sum(l) / 2

for i in range(n):
  if l[i] >= thr:
    print("No")
    break
else: print("Yes")


Diff:
 n = int(input())
 
 l = list(map(int, input().split()))
 thr = sum(l) / 2
 
 for i in range(n):
-  if l[i] > thr:
+  if l[i] >= thr:
     print("No")
+    break
 else: print("Yes")
+
Buggy program (verdict: Wrong Answer):
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        return
    i = 1
    ans = 1
    while i*i <= m:
        if m % i != 0:
            i += 1
            continue
        a = i
        if m / i >= n:
            ans = max(ans, i)
        if m / (m / i) >= n:
            ans = max(ans, i)
        i += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Failing test case input:
000101 1110110010

Expected output:
332070


Actual output:
33207


Fixed program (verdict: Accepted):
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        return
    i = 1
    ans = 1
    while i*i <= m:
        if m % i != 0:
            i += 1
            continue
        a = i
        if m 
            ans = max(ans, i)
        if m 
            ans = max(ans, m 
        i += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Diff:
 def main():
     n, m = map(int, input().split())
     if n == 1:
         print(m)
         return
     i = 1
     ans = 1
     while i*i <= m:
         if m % i != 0:
             i += 1
             continue
         a = i
-        if m / i >= n:
-            ans = max(ans, i)
-        if m / (m / i) >= n:
+        if m 
             ans = max(ans, i)
+        if m 
+            ans = max(ans, m 
         i += 1
     print(ans)
     
 if __name__ == '__main__':
     main()
Buggy program (verdict: Wrong Answer):
S = sorted(input())
T = sorted(input())

print("Yes" if (S < T) else "No")



Failing test case input:
ratcode
salta

Expected output:
Yes


Actual output:
No


Fixed program (verdict: Accepted):
S = "".join(sorted(input()))
T = "".join(sorted(input()))[::-1]

print("Yes" if (S < T) else "No")



Diff:
-S = sorted(input())
-T = sorted(input())
+S = "".join(sorted(input()))
+T = "".join(sorted(input()))[::-1]
 
 print("Yes" if (S < T) else "No")
Buggy program (verdict: Wrong Answer):
a, b, k = map(int, input().split())

if a >= k:
  if b-(k-a) > 0:
    print(0, b-(k-a))
  else:
    print(0, 0)
else:
  print(a-k, b)

Failing test case input:
551061056476 2744039490 0000010100000

Expected output:
551050956476 2744039490


Actual output:
0 553794995966


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

if a <= k:
  if b-(k-a) > 0:
    print(0, b-(k-a))
  else:
    print(0, 0)
else:
  print(a-k, b)

Diff:
 a, b, k = map(int, input().split())
 
-if a >= k:
+if a <= k:
   if b-(k-a) > 0:
     print(0, b-(k-a))
   else:
     print(0, 0)
 else:
   print(a-k, b)
Buggy program (verdict: Wrong Answer):
n = int(input())
a =list(map(int, input().split()))
l =[0] * (n+1)

for i in range(0,n-1):
    l[a[i]] +=1
    
for i in l[1:]:
    print(l[i])
    

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

Expected output:
3
0
1
1
0
0
1


Actual output:
1
0
3
3
0
0
3


Fixed program (verdict: Accepted):
n = int(input())
a =list(map(int, input().split()))
l =[0] * (n+1)

for i in range(0,n-1):
    l[a[i]] +=1
    
for i in range(1,n+1):
    print(l[i])
    

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


N = int(input())
S = list(input())

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = S.index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)


Failing test case input:
19
3551214087457625496

Expected output:
367


Actual output:
448


Fixed program (verdict: Accepted):


N = int(input())
S = list(input())

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)


Diff:
 
 
 N = int(input())
 S = list(input())
 
 ans = 0
 for i in range(1000):
     pw = list("{0:03d}".format(i))
 
     if pw[0] in S:
         w1 = S.index(pw[0])
         if pw[1] in S[w1+1:]:
-            w2 = S.index(pw[1])
+            w2 = w1+1 + S[w1+1:].index(pw[1])
             if pw[2] in S[w2+1:]:
                 ans += 1
 
 print(ans)
Buggy program (verdict: Wrong Answer):
n=int(input())
s=str(input())
ans=0

for i in range(n-1):
    n=i+1
    if s[n]=='E':
        ans=ans+1

cnt=ans

for i in range(n):
    if s[i:i+2]=='WW':
        cnt=cnt+1
    elif s[i:i+2]=='EE':
        cnt=cnt-1
    else:
        0
        
    print('i,s[i:i+2],ans,cnt',i,s[i:i+2],ans,cnt)
    ans=min(ans,cnt)
print(ans)

Failing test case input:
5
WEEWW

Expected output:
1

Actual output:
i,s[i:i+2],ans,cnt 0 WE 2 2
i,s[i:i+2],ans,cnt 1 EE 2 1
i,s[i:i+2],ans,cnt 2 EW 1 1
i,s[i:i+2],ans,cnt 3 WW 1 2
1


Fixed program (verdict: Accepted):
n=int(input())
s=str(input())
ans=0

for i in range(n-1):
    n=i+1
    if s[n]=='E':
        ans=ans+1

cnt=ans

for i in range(n):
    if s[i:i+2]=='WW':
        cnt=cnt+1
    elif s[i:i+2]=='EE':
        cnt=cnt-1
    else:
        0
        
    
    ans=min(ans,cnt)
print(ans)

Diff:
 n=int(input())
 s=str(input())
 ans=0
 
 for i in range(n-1):
     n=i+1
     if s[n]=='E':
         ans=ans+1
 
 cnt=ans
 
 for i in range(n):
     if s[i:i+2]=='WW':
         cnt=cnt+1
     elif s[i:i+2]=='EE':
         cnt=cnt-1
     else:
         0
         
-    print('i,s[i:i+2],ans,cnt',i,s[i:i+2],ans,cnt)
+    
     ans=min(ans,cnt)
 print(ans)