ZhenlongDai/ACPR huggingface dataset:
Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("Red")

Failing test case input:
3199
pink

Expected output:
red

Actual output:
Red


Fixed submission (verdict: Accepted):
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
s = input()
if a < 3200:
  print(s)
else:
  print("red")

Failing test case input:
4049
qdd

Expected output:
qdd


Actual output:
red


Fixed submission (verdict: Accepted):
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
s = str(input())
if a > 3200:
	print(s)
else:
	print('red')

Failing test case input:
3200
nhoo

Expected output:
nhoo


Actual output:
red


Fixed submission (verdict: Accepted):
a = int(input())
s = str(input())
if a >= 3200:
	print(s)
else:
	print('red')

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

input = sys.stdin.readline


def main():
    a = int(input())
    s = input().strip()
    print("red" if a < 3200 else a)


if __name__ == "__main__":
    main()


Failing test case input:
4049
abp

Expected output:
abp


Actual output:
4049


Fixed submission (verdict: Accepted):
import sys

input = sys.stdin.readline


def main():
    a = int(input())
    s = input().strip()
    print("red" if a < 3200 else s)


if __name__ == "__main__":
    main()

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
b = input()
if a >= 3200:
  print("red")
else:
  print(b)

Failing test case input:
4049
bap

Expected output:
bap


Actual output:
red


Fixed submission (verdict: Accepted):
a = int(input())
b = input()
if a >= 3200:
    print(b)
else: 
    print("red")

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
s = str(input())

if a <=3200:
    print(s)
else:
    print("red")

Failing test case input:
4049
qdd

Expected output:
qdd


Actual output:
red


Fixed submission (verdict: Accepted):
a = int(input())
s = str(input())

if a >=3200:
    print(s)
else:
    print("red")

Problem: p02933
Buggy submission (Python (3.8.2), verdict: Wrong Answer):




a = int(input())

if a >= 3200:
    print('pink')

elif a < 3200:
    print('red')

Failing test case input:
4049
rdc

Expected output:
rdc


Actual output:
pink


Fixed submission (verdict: Accepted):
a = int(input())
s = input()

if a < 3200:
    print('red')

else:
    print(s)

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
s=input()
if a>=3200: 
  print(a)
else:
  print("red")

Failing test case input:
3200
ogom

Expected output:
ogom


Actual output:
3200


Fixed submission (verdict: Accepted):
a=int(input())
s=input()
if 2800<=a<3200:
  print("red")
elif 3200<=a<5000:
  print(s)
Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
s = input()
if a >= 3200:
	print(a)
else:
	print("red")

Failing test case input:
4049
cqa

Expected output:
cqa


Actual output:
4049


Fixed submission (verdict: Accepted):
a = int(input())
s = input()
if a >= 3200:
	print(s)
else:
	print("red")

Problem: p02933
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
s=input()

if a >=3200:
  print('red')
else:
  print(s)

Failing test case input:
4049
bcq

Expected output:
bcq


Actual output:
red


Fixed submission (verdict: Accepted):
a=int(input())
s=input()

if a >=3200:
  print(s)
else:
  print('red')
Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = int(input())
W = list(map(int,input().split()))
tmp = 0
ans = 0
wa = 0

for i in range (A):
    wa += W[i]
for i in range (A):
    tmp += W[i]
    tmp_r = wa-tmp
    if i == 0:
        ans = tmp
    if ans > abs(tmp-tmp_r):
        ans = abs(tmp-tmp_r)
print(ans)

Failing test case input:
8
1 5 38 0 0 1 235 5

Expected output:
195


Actual output:
1


Fixed submission (verdict: Accepted):
A = int(input())
W = list(map(int,input().split()))
tmp = 0
ans = 0
wa = 0

for i in range (A):
    wa += W[i]
for i in range (A):
    tmp += W[i]
    tmp_r = wa-tmp
    if i == 0:
        ans = abs(tmp-tmp_r)
    if ans > abs(tmp-tmp_r):
        ans = abs(tmp-tmp_r)
print(ans)

Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=input().split()
d=list(map(int,d))
s1=[]
s2=0
difn=10000000000000000000
dif=0
i=0
while i<=len(d):
    s1.append(d[0])
    d.remove(d[0])
    s2=sum(d)
    if sum(s1)>=s2:
        dif=sum(s1)-s2
    elif s2>sum(s1):
        dif=s2-sum(s1)
    if dif<difn:
        difn=dif
    else:
        break
    i+=1
print (difn)

Failing test case input:
8
56 0 33 7 1 11 140 4

Expected output:
36


Actual output:
140


Fixed submission (verdict: Accepted):
n=int(input())
d=input().split()
d=list(map(int,d))
s1=[]
s2=0
difn=10000000000000000000
dif=0
i=0
while i<=n:
    s1.append(d[0])
    d.remove(d[0])
    s2=sum(d)
    if sum(s1)>=s2:
        dif=sum(s1)-s2
    elif s2>sum(s1):
        dif=s2-sum(s1)
    if dif<=difn:
        difn=dif
    else:
        break
    i+=1
print(difn)

Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
w = sorted([ int(x) for x in input().split() ])
ans = sum(w)
l, r = 0, sum(w)
for i in range(n):
    l += w[i]
    r -= w[i]
    ans = min(ans, abs(l-r))

print(ans)


Failing test case input:
8
1 5 20 0 0 1 106 5

Expected output:
84


Actual output:
74


Fixed submission (verdict: Accepted):
n = int(input())
w = [ int(x) for x in input().split() ]
ans = sum(w)
l, r = 0, sum(w)
for i in range(n):
    l += w[i]
    r -= w[i]
    ans = min(ans, abs(l-r))

print(ans)

Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
lis = list(map(int,input().split()))
ans = 10 ** 9
le = sum(lis)
ri = sum(lis)
for num in lis:
  le += num
  ri -= num
  ans = min(ans,abs(ri-le))
print(ans)

Failing test case input:
8
47 30 99 2 5 2 102 4

Expected output:
61


Actual output:
94


Fixed submission (verdict: Accepted):
n = int(input())
lis = list(map(int,input().split()))
ans = 10 ** 9
le = 0
ri = sum(lis)
ans = sum(lis)
for num in lis:
  le += num
  ri -= num
  ans = min(ans,abs(ri-le))
print(ans)
Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=0
t_list=[]
try:
  t_list = [int(n) for n in input().split(' ')]
except:
  print('age,price must be numbers')
  sys.exit(1)

min_v = 10000
for i in range(n):
    diff = abs(sum(t_list[0:i]) - sum(t_list[i:n]))
    if min_v > diff:
        min_v = diff
print(min_v)

Failing test case input:
8
1 5 10 0 1 0 190 0

Expected output:
173


Actual output:
10000


Fixed submission (verdict: Accepted):
n=0
t_list=[]
try:
    n=int(input())
    t_list = [int(n) for n in input().split(' ')]
except:
  print('age,price must be numbers')
  sys.exit(1)

min_v = 10000
for i in range(n):
    diff = abs(sum(t_list[0:i]) - sum(t_list[i:n]))
    if min_v > diff:
        min_v = diff
print(min_v)

Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
m=[]
for i in range(1,n-1):
    m.append(abs(-sum(l[:i])*2))
print(min(m))

Failing test case input:
8
1 5 22 0 1 1 106 3

Expected output:
79


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
s=sum(l)
m=[]
for i in range(n):
    m.append(abs(s-sum(l[:i+1])*2))
print(min(m))

Problem: p03012
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
W = list(map(int,input().split()))
print(W)
ans = 10 ** 9
for i in range(1,N):
  ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)
             
                       

Failing test case input:
8
1 5 1 0 1 0 106 4

Expected output:
102


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


Fixed submission (verdict: Accepted):
N = int(input())
W = list(map(int,input().split()))
ans = 10 ** 9
for i in range(1,N):
  ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))
print(ans)

Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ans = 0
n = int(input())
w = list(map(int,input().split()))
mid = sum(w)
ans = 0
for i in w:
    ans += i
    if mid <= ans:
        print(ans-(sum(w)-ans))
        break

Failing test case input:
8
1 5 38 0 0 1 235 5

Expected output:
195


Actual output:
285


Fixed submission (verdict: Accepted):
n = int(input())
w = list(map(int,input().split()))
ans = []
s = 0
for i in range(n):
    s += w[i]
    ans.append(abs(s-sum(w[i+1:])))
print(min(ans))

Problem: p03012
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input().split()
del a[0]
for i in range(0,len(a)):
    a[i]=int(a[i])
b=0
c=0
answer=sum(a)
for i in range(0,len(a)):
    b=b+a[i]
    c=sum(a)-b
    if (b-c>=0 and answer>b-c):
        answer=b-c
    if (c-b>0 and answer>c-b):
        answer=c-b
print(answer)

Failing test case input:
8
47 30 99 2 5 2 102 4

Expected output:
61


Actual output:
0


Fixed submission (verdict: Accepted):
b=input()
a=input().split()
for i in range(0,len(a)):
    a[i]=int(a[i])
b=0
c=0
answer=sum(a)
for i in range(0,len(a)):
    b=b+a[i]
    c=sum(a)-b
    if (b-c>=0 and answer>b-c):
        answer=b-c
    elif (c-b>0 and answer>c-b):
        answer=c-b
print(answer)
Problem: p03012
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = l()
S.sort()
ans1 = 0
ans2 = sum(S)
sa = 1000000000
i=0

for i in range(N):
    ans1 += S[i]
    ans2 -= S[i]
    sa = min(sa,abs(ans2-ans1))
    i += 1

print(sa)


Failing test case input:
8
1 5 1 0 1 0 106 4

Expected output:
102


Actual output:
94


Fixed submission (verdict: Accepted):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = l()
sa = 1000000000

for i in range(1,N):
    sa = min(sa,abs(sum(S[:i])-sum(S[i:])))

print(sa)
Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = (int(x) for x in input().split())
if(K==0):
    print("YES")
    exit()
if(N-2 >= 10):
    print("YES")
else:
    print("NO")





Failing test case input:
151 97

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N,K = (int(x) for x in input().split())
if((N+1)/2 >= K):
    print("YES")
else:
    print("NO")

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())

ans='NO'

if N%2==0 and K<=(N/2):
    ans=''
if N%2==1 and K<=((N/2)+1) :
    ans='YES'

print(ans)


Failing test case input:
70 10

Expected output:
YES


Actual output:

Fixed submission (verdict: Accepted):
N,K=map(int,input().split())

ans='NO'

if N%2==0 and K<=(N/2):
    ans='YES'
if N%2==1 and K<=((N+1)/2) :
    ans='YES'

print(ans)

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
print( "YES" if n -k >= 1 else "NO")

Failing test case input:
51 27

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())

if k * 2 -1 <= n:
	print("YES")
else:
	print("NO")

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())

if N > K:
    print('YES')
else:
    print('NO')


Failing test case input:
87 50

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())

if (N % 2 == 0 and N 
    print('YES')
else:
    print('NO')

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
N=int(a.split()[0])
K=int(a.split()[1])

if(N>(K/2-1)):
  print('YES')
else:
  print('NO')

Failing test case input:
10 19

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
a=input()
N=int(a.split()[0])
K=int(a.split()[1])

if((N/2+1)>K):
  print('YES')
else:
  print('NO')

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

N,K = [int(x) for x in input().split()]
if K <= math.ceil(N/2):
    print('Yes')
else:
    print('No')


Failing test case input:
77 50

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
import math

N,K = [int(x) for x in input().split()]
if K <= math.ceil(N/2):
    print('YES')
else:
    print('NO')

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if a > b:
    print("YES")
else:
    print("NO")

Failing test case input:
87 50

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
if a >= 2 * b - 1:
    print("YES")
else:
    print("NO")
Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = list(map(int, input().split()))
num = 0

for n in range(1,N+1):
    if n%2!=0:
        num += 1
if num < K:
    print("No")
else:
    print("Yes")

Failing test case input:
67 19

Expected output:
YES


Actual output:
Yes


Fixed submission (verdict: Accepted):
N, K = list(map(int, input().split()))
num = 0

for n in range(1,N+1):
    if n%2!=0:
        num += 1
if num<K:
    print("NO")
else:
    print("YES")

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

n, k = map(int, input().split())

cnt = 1
for i in range(1,n,2):
    cnt += 1
if cnt < k:
    print("NO")
else:
    print("YES")

Failing test case input:
98 50

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
import sys

n, k = map(int, input().split())

cnt = 0
for i in range(1,n+1,2):
    cnt += 1
if cnt < k:
    print("NO")
else:
    print("YES")

Problem: p03129
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N, K = map(int, input().split())

if int((N+1) /2) >= K:
    print("Yes")
else:
    print("No")

Failing test case input:
98 50

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):


N, K = map(int, input().split())

if int((N+1) /2) >= K:
    print("YES")
else:
    print("NO")
Problem: p00591
Buggy submission (Python3, verdict: Wrong Answer):
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    students = []
    for i in range(n):
        students.append(sys.stdin.readline().rstrip().split(' '))
    s_list=[[min(row)==s for s in row] for row in students]
    t_list=[[max(col)==s for s in col] for col in zip(*students)]
    ret = 0
    for i,data in enumerate(zip(s_list, zip(*t_list))):
        for j,d in enumerate(zip(*data)):
            if all(d):
                ret = students[i][j]
                break;
    print(ret)

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

Expected output:
7
7


Actual output:
0
0


Fixed submission (verdict: Accepted):
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    students = []
    for i in range(n):
        students.append(list(map(int, sys.stdin.readline().rstrip().split(' '))))
    s_list=[[min(row)==s for s in row] for row in students]
    t_list=[[max(col)==s for s in col] for col in zip(*students)]
    ret = [0]
    for i,data in enumerate(zip(s_list, zip(*t_list))):
        for j,d in enumerate(zip(*data)):
            if all(d):
                ret.append(students[i][j])
    print(max(ret))

Problem: p00591
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    n = int(input())
    if not n:
        break
    a = [list(map(int, input().split())) for j in range(n)]
    c = [max(a[i][j] for i in range(n)) for j in range(n)]
    r = [min(a[i]) for i in range(n)]

    print(*(c[j] for i in range(n) for j, x in enumerate(a[i]) if x == r[i] and c[j] == r[i]))

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

Expected output:
0
4


Actual output:

4


Fixed submission (verdict: Accepted):
while True:
    n = int(input())
    if not n: break
    a = [list(map(int, input().split())) for _ in range(n)]
    s = max(min(a[i]) for i in range(n))
    c = [max(a[i][j] for i in range(n)) for j in range(n)]
    for j in range(n):
        if c[j] == s:
            print(s)
            break
    else:
        print(0)
Problem: p02536
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math





class UnionFind:

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):  
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):  
        u = self.find(u)
        v = self.find(v)
        if u == v:
            return
        if self.parents[u] > self.parents[v]:  
            u, v = v, u
        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):  
        return -self.parents[self.find(v)]

    def same(self, u, v):  
        return self.find(u) == self.find(v)


N, M = map(int, input().split())
G = [[] for _ in range(N)]
uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

root_list = []
for i in range(N):
    r = uf.find(i)
    root_list.append(r)

root_list = list(set(root_list))
num = len(root_list)





def comb(n, r):  
    if r < 0 or r > n:
        return 0
    else:
        n1 = math.factorial(n)
        n21 = math.factorial(n - r)
        n22 = math.factorial(r)
        ans = n1 
        return ans



ans = comb(num, 2)
print(ans)


Failing test case input:
50 1
2 5

Expected output:
48


Actual output:
608281864034267560872252163321295376887552831379210240000000000


Fixed submission (verdict: Accepted):
import math



class UnionFind:

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):  
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):  
        u = self.find(u)
        v = self.find(v)
        if u == v:
            return
        if self.parents[u] > self.parents[v]:  
            u, v = v, u
        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):  
        return -self.parents[self.find(v)]

    def same(self, u, v):  
        return self.find(u) == self.find(v)






def comb(n, r):  
    if r < 0 or r > n:
        return 0
    else:
        n1 = math.factorial(n)
        n21 = math.factorial(n - r)
        n22 = math.factorial(r)
        ans = n1 
        return ans


N, M = map(int, input().split())
uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

root_list = []
for i in range(N):
    r = uf.find(i)
    root_list.append(r)

root_list = list(set(root_list))
num = len(root_list)

ans = num - 1
print(ans)
Problem: p02536
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
sys.setrecursionlimit(200000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       
        return self.ro(a)==self.ro(b)
    def rl(self):           
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
u=uf(N)
for i in range(M):
    u.me(*map(lambda x: int(x)-1,input().split()))
print(N-u.len())

Failing test case input:
34 1
2 13

Expected output:
32


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
sys.setrecursionlimit(200000)
class uf:
    def __init__(self,n):
        self.n=n
        self.l=[-1]*n
    def ro(self,n):         
        if self.l[n]<0:
            return n
        r=self.ro(self.l[n])
        self.l[n]=r
        return r
    def me(self,a,b):       
        ra=self.ro(a)
        rb=self.ro(b)
        if self.l[ra]>self.l[rb]:
            ra,rb=rb,ra
        if ra!=rb:
            self.l[ra]+=self.l[rb]
            self.l[rb]=ra
    def size(self,n):
        return -self.l[self.ro(n)]
    def sa(self,a,b):       
        return self.ro(a)==self.ro(b)
    def rl(self):           
        return [i for i,v in enumerate(self.l) if v<0]
    
    def len(self):          
        return len(self.rl())
    def ul(self):
        d={n:i for i,n in enumerate(self.rl())}
        m=[[]for i in range(self.len())]
        for i in range(self.n):
            m[d[self.ro(i)]].append(i)
        return m
    def __str__(self):
        return f"{self.ul()}"
    def __setitem__(self,i,v):
        self.l[i]=v
u=uf(N)
for i in range(M):
    u.me(*map(lambda x: int(x)-1,input().split()))
print(u.len()-1)
Problem: p02536
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
uf = UnionFind(N)
ans = 0
for i in range(M):
    A, B = map(int, input().split())
    if not uf.same(A-1,B-1):
        ans += 1
    else:
        uf.union(A-1,B-1)
print(ans)

Failing test case input:
27 1
1 1

Expected output:
26


Actual output:
0


Fixed submission (verdict: Accepted):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
uf = UnionFind(N)
ans = 0
for i in range(M):
    A, B = map(int, input().split())
    uf.union(A-1,B-1)
print(uf.group_count()-1)
Problem: p02536
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = [int(i) for i in input().split()]
    uf = UnionFind(N)
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        uf.union(A-1,B-1)
    print(N-uf.group_count())

if __name__ == "__main__":
    main()

Failing test case input:
18 1
1 2

Expected output:
16


Actual output:
1


Fixed submission (verdict: Accepted):

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = [int(i) for i in input().split()]
    uf = UnionFind(N)
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        uf.union(A-1,B-1)
    print(uf.group_count()-1)

if __name__ == "__main__":
    main()
Problem: p02536
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
class UnionFind():
    
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
    
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def unite(self, x, y):
    
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
    
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
    
        return self.find(x) == self.find(y)
 
    def members(self, x):
    
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
    
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
    
        return len(self.roots())
 
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
 
 
 
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n,m=map(int,input().split())
u=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    u.unite(a,b)
print(n-len(u.roots()))

Failing test case input:
13 1
4 2

Expected output:
11


Actual output:
1


Fixed submission (verdict: Accepted):
class UnionFind():
    
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
    
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def unite(self, x, y):
    
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
    
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
    
        return self.find(x) == self.find(y)
 
    def members(self, x):
    
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
    
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
    
        return len(self.roots())
 
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
 
 
 
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n,m=map(int,input().split())
u=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    u.unite(a,b)
print(len(u.roots())-1)
Problem: p02536
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,m = map(int,input().split())

ans = 0

class UnionFind:
    def __init__(self,n):
        self.root = [i for i in range(n+1)]

    def Root_Find(self,x):
        if self.root[x] == x:
            return x
        else:
            self.root[x] = self.Root_Find(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x = self.Root_Find(x)
        y = self.Root_Find(y)
        if x == y:
            return
        self.root[y] = x

tree = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    tree.Unite(a,b)
    
ans = len(list(set(tree.root))) - 1
print(ans)

Failing test case input:
5 1
1 1

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())

ans = 0

class UnionFind:
    def __init__(self,n):
        self.root = [i for i in range(n+1)]

    def Root_Find(self,x):
        if self.root[x] == x:
            return x
        else:
            self.root[x] = self.Root_Find(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x = self.Root_Find(x)
        y = self.Root_Find(y)
        if x == y:
            return
        self.root[y] = x

tree = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    tree.Unite(a,b)

for i in range(n+1):
    tree.Root_Find(i)

ans = len(list(set(tree.root))) - 2
print(ans)
Problem: p02536
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
class UnionFind:
    __slots__ = ["_data_size", "_roots"]
 
    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size
 
    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x
 
    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]
 
    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x
 
 
import sys
 
readline = sys.stdin.readline
 
N, Q = map(int, readline().split())
tree = UnionFind(N)
res = []
ans=0
for _ in range(Q):
  u, v = map(int, readline().split())
  tree.unite(u-1, v-1)
for u in range(1,N):
  
  if not tree.is_connected(u, 0):
      ans+=1
      tree.unite(u-1, 0)
print(ans)


Failing test case input:
6 1
3 4

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
class UnionFind:
    __slots__ = ["_data_size", "_roots"]
 
    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size
 
    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x
 
    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]
 
    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x
 
 
import sys
 
readline = sys.stdin.readline
 
N, Q = map(int, readline().split())
tree = UnionFind(N)
res = []
ans=0
for _ in range(Q):
  u, v = map(int, readline().split())
  tree.unite(u-1, v-1)
for u in range(1,N):
  if not tree.is_connected(u, 0):
      ans+=1
      tree.unite(u, 0)
print(ans)
Problem: p02536
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
AB= [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
for ab in AB:
    uf.union(ab[0]-1,ab[1]-1)
print(N-uf.group_count())

Failing test case input:
42 1
1 6

Expected output:
40


Actual output:
1


Fixed submission (verdict: Accepted):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
AB= [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
for ab in AB:
    uf.union(ab[0]-1,ab[1]-1)
print(uf.group_count()-1)
Problem: p02536
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

class UnionFind:
    def __init__(self, size):
        self.parent_indexes = [-1] * size
        
    def find(self, n):
        if self.parent_indexes[n] < 0:
            return n
        
        
        self.parent_indexes[n] = self.find(self.parent_indexes[n])
        return self.parent_indexes[n] 
    
    def union(self, n1, n2):
        if self.same_group(n1, n2):
            return False
        
        
        if self.size(n1) >= self.size(n2):
            tmp = self.size(n2)
            self.parent_indexes[self.find(n2)] = self.find(n1)
            self.parent_indexes[self.find(n1)] -= tmp
            return True
        
        
        tmp = self.size(n1)
        self.parent_indexes[self.find(n1)] = self.find(n2)
        self.parent_indexes[self.find(n2)] -= tmp
        return True
        
    
    def size(self, n):
        return -self.parent_indexes[self.find(n)]
    
    def same_group(self, n1, n2):
        return self.find(n1) == self.find(n2)

n, m = map(lambda x: int(x), input().split())


uf = UnionFind(n)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    uf.union(a-1, b-1)
    
num_parents = 0
    
for p_index in uf.parent_indexes:
    if p_index < 0:
        num_parents += 1
print(math.ceil((math.log2(num_parents))))

Failing test case input:
79 1
2 9

Expected output:
77


Actual output:
7


Fixed submission (verdict: Accepted):
import math

class UnionFind:
    def __init__(self, size):
        self.parent_indexes = [-1] * size
        
    def find(self, n):
        if self.parent_indexes[n] < 0:
            return n
        
        
        self.parent_indexes[n] = self.find(self.parent_indexes[n])
        return self.parent_indexes[n] 
    
    def union(self, n1, n2):
        if self.same_group(n1, n2):
            return False
        
        
        if self.size(n1) >= self.size(n2):
            tmp = self.size(n2)
            self.parent_indexes[self.find(n2)] = self.find(n1)
            self.parent_indexes[self.find(n1)] -= tmp
            return True
        
        
        tmp = self.size(n1)
        self.parent_indexes[self.find(n1)] = self.find(n2)
        self.parent_indexes[self.find(n2)] -= tmp
        return True
        
    
    def size(self, n):
        return -self.parent_indexes[self.find(n)]
    
    def same_group(self, n1, n2):
        return self.find(n1) == self.find(n2)

n, m = map(lambda x: int(x), input().split())


uf = UnionFind(n)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    uf.union(a-1, b-1)
    
num_parents = 0
    
for p_index in uf.parent_indexes:
    if p_index < 0:
        num_parents += 1

print(num_parents - 1)
Problem: p02536
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m = map(int,input().split())

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

d = Unionfind(n)

for i in range(m):
    a,b = map(int,input().split())
    d.union(a-1,b-1)
    
L = []
for i in range(n):
    c = d.size(i)
    L.append(c)
print(len(set(L))-1)

Failing test case input:
3 1
3 3

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

d = Unionfind(n)

for i in range(m):
    a,b = map(int,input().split())
    d.union(a-1,b-1)
    
L = []
for i in range(n):
    c = d.find(i)
    L.append(c)

print(len(set(L))-1)
Problem: p03419
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


n, m = map(int, input().split())

peremeter = 0
if n == 1 or m == 1:
    peremeter += 2
else:
    if n - 1 > 0:
        peremeter += (n - 1) * 2
    if m - 1 > 0:
        peremeter += (m - 1) * 2
ans = n * m - peremeter
print(ans)

Failing test case input:
69 -1

Expected output:
-201


Actual output:
-205


Fixed submission (verdict: Accepted):


n, m = map(int, input().split())

peremeter = 0
if n == 1 and m == 1:
    pass 
elif n == 1 or m == 1:
    peremeter += 2
else:
    peremeter += (n - 1) * 2
    peremeter += (m - 1) * 2
ans = n * m - peremeter
print(ans)

Problem: p03419
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]









n,m=l()
if(n==1 and m==1):
    print(1)
    exit()
if(n<=2 and m<=2):
    print(0)
    exit()
if(n==2):
    print((m-2)*2)
    exit()
if(m==2):
    print((n-2)*2)
    exit()
print(max(1,n-2)*max(1,m-2))



Failing test case input:
40 -1

Expected output:
-114


Actual output:
38


Fixed submission (verdict: Accepted):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]









n,m=l()
if(n>m):
    n,m=m,n
if(n==1 and m==1):
    print(1)
    exit()
if(n==1 and m!=1):
    print(m-2)
    exit()
print((n-2)*(m-2))
Problem: p03419
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int, input().split())
if n <= 1 or m <= 1:
  print(max(n-2, m-2, 0))
else:
  print((n-2)*(m-2))

Failing test case input:
115 0

Expected output:
-226


Actual output:
113


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
if n == 1 and m==1:
  print(1)
elif n == 1 or m == 1:
  print(max(n-2, m-2, 0))
else:
  print((n-2)*(m-2))

Problem: p03419
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
  exit(0)

w = n - 2
h = m - 2
if w < 1 or h < 1:
  print(max(w, h))
  exit(0)
  
print(w*h)


Failing test case input:
63 0

Expected output:
-122


Actual output:
61


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
  exit(0)

w = n - 2
h = m - 2
if n == 1:
  print(h)
  exit(0)
if m == 1:
  print(w)
  exit(0)
  
print(w*h)

Problem: p03419
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m = map(int,input().split())
if(n==2)or(m==2):
  print(0)
elif(n==1)or(m==1):
  if(n==1)and(m==1):
    print(1)
  else:
    print(max(0,max(n,m)-2))
else:
  print((n-2)*(m-1))

Failing test case input:
527 374

Expected output:
195300


Actual output:
195825


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
if(n==2)or(m==2):
  print(0)
elif(n==1)or(m==1):
  if(n==1)and(m==1):
    print(1)
  else:
    print(max(0,max(n,m)-2))
else:
  print((n-2)*(m-2))

Problem: p03419
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, m = inm()
print(n*m - min(2, m) * n - (0 if n <= 2 else 2*m - 4))

Failing test case input:
48 -1

Expected output:
-138


Actual output:
6


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, m = inm()
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    print((m-2) * (n-2))

Problem: p03419
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

N, M = map(int, sys.stdin.readline().split())

if N > 1 and M > 1:
    four = 4
    six = (N - 2) * 2 + (M - 2) * 2
    nine = N * M - four - six
    print(nine)
elif N == 2 or M == 2:
    print(0)
else:
    two = 2
    three = N * M - two
    print(three)

Failing test case input:
124 0

Expected output:
-244


Actual output:
-2


Fixed submission (verdict: Accepted):
import sys

N, M = map(int, sys.stdin.readline().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    two = 2
    three = N * M - two
    print(three)
else:
    four = 4
    six = (N - 2) * 2 + (M - 2) * 2
    nine = N * M - four - six
    print(nine)