ZhenlongDai/ACPR huggingface dataset:
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
[n,a,b] = [int(i) for i in input().split()]
c = 1
if a > b:
    c = 0
if n == 1 and a != b:
    c = 0
if n == 1 and a == b:
    c = -1

if c == 1:
    print(b * (n-1) + a - (a * (n-1) + b) + 1)
elif c == -1:
    print(1)


Failing test case input:
5 5 3

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
[n,a,b] = [int(i) for i in input().split()]
c = 1

if a > b:
    c = 0

if n == 1 and a != b:
    c = 0

if n == 1 and a == b:
    c = -1

if c == 1:
    print(b * (n-1) + a - (a * (n-1) + b) + 1)
elif c == -1:
    print(1)
else:
    print(0)

Problem: p03705
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, A, B = map(int, input().split())
if A > B:
  print(0)
elif A == B:
  print(1)
elif B-A >=N:
  print(0)
else: 
  print((B-A)*(N-2)+1)

Failing test case input:
3 -4 0

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
if A > B:
  print(0)
else:
  if N == 1 and A == B:
    print(1)
  elif N == 1:
    print(0)
  else:
    print((B-A)*(N-2)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int, input().split())
if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
elif n == 2:
  if a == b or a < b:
    print(1)
  else:
    print(0)
else:
  if  a > b:
    print(0)
  else:
    print((b - a) * (n - 2))

Failing test case input:
26 0 4

Expected output:
97


Actual output:
96


Fixed submission (verdict: Accepted):
n,a,b = map(int, input().split())
if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
elif n == 2:
  if a == b or a < b:
    print(1)
  else:
    print(0)
else:
  if  a > b:
    print(0)
  else:
    print((b - a) * (n - 2) + 1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int,input().split())
if N-2>=0:
  print((B-A)*(N-2)+1)
elif N == 1:
  if A!=B:
    print('0')
  else:
    print('1')
else:
  print('0')

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


Fixed submission (verdict: Accepted):
N,A,B = map(int,input().split())
if A>B:
  print('0')
elif N == 1:
  if A!=B:
    print('0')
  else:
    print('1')
else:
  print((B-A)*(N-2)+1)

Problem: p03705
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,a,b=map(int,input().split())
ans=0
if a>b or n==0:
  ans=0
elif a==b:
  ans=1
else:
  ans=(n-2)*(b-a)+1
print(ans)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
ans=0
if a>b or n==1:
  if a==b:
    ans=1
  else:
    ans=0
elif a==b:
  ans=1
else:
  ans=(n-2)*(b-a)+1
print(ans)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
x=0
if a>b:
  x=0
elif a==b:
  x=1
else:
  x=(b-a)*(n-2)+1
print(x)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
x=0
if a>b:
  x=0
elif n==1 and a==b:
  x=1
elif n==1 and a!=b:
  x=0
else:
  x=(b-a)*(n-2)+1
print(x)
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def FI(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline().split())
def S(): return input()

n, a, b = LI()

if a>b:
	print(0)
else:
	mi = a*(n-1)+b
	ma = a+b*(n-1)
	print(ma-mi+1)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


Fixed submission (verdict: Accepted):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def FI(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline().split())
def S(): return input()

n, a, b = LI()

if a>b:
	print(0)
elif n==1 and a!=b:
	print(0)
else:
	mi = a*(n-1)+b
	ma = a+b*(n-1)
	print(ma-mi+1)

Problem: p03705
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

def pin(type=int):
    return map(type,input().split())




N,A,B=pin()
if A==B:
    print(1)
elif A>B or N==1:
    print(0)
else:
    print((N-1)*(B-A))

Failing test case input:
12 -3 0

Expected output:
31


Actual output:
33


Fixed submission (verdict: Accepted):

def pin(type=int):
    return map(type,input().split())




N,A,B=pin()
if A==B:
    print(1)
elif A>B or N==1:
    print(0)
else:
    print((N-2)*(B-A)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(map(int, input().split()))
N = S[0]
A = S[1]
B = S[2]
combi = 0
if(A > B):
    print(0)
elif(N == 1):
    combi = 1 if (A == B) else 0
    print(1)
else:
    cand = N - 2
    combi = (cand * B) - (cand * A) + 1
    print(combi)


Failing test case input:
1 7 10

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
S = list(map(int, input().split()))
N = S[0]
A = S[1]
B = S[2]
combi = 0
if(A > B):
    print(0)
elif(N == 1):
    combi = 1 if (A == B) else 0
    print(combi)
else:
    cand = N - 2
    combi = (cand * B) - (cand * A) + 1
    print(combi)

Problem: p03705
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,A,B = map(int,input().split())
if A > B:
    print(0)
if N == 1:
    if A != B:
        print(0)
    else:
        print(1)
else:
    print((B*(N-1)+A)-(A*(N-1)+B)+1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
0
-5


Fixed submission (verdict: Accepted):
N,A,B = map(int,input().split())
if A > B:
    print(0)
elif N == 1:
    if A != B:
        print(0)
    else:
        print(1)
else:
    print((B*(N-1)+A)-(A*(N-1)+B)+1)
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    n, a, b = map(int, input().split())
    if b-a < 0:
        print(0)
        exit(0)
    if n == 1:
        if b != a:
            print(0)
        else:
            print(1)
        exit(0)
    print((n-1)*(b-a)-1)


if __name__ == '__main__':
    main()


Failing test case input:
28 -3 2

Expected output:
131


Actual output:
134


Fixed submission (verdict: Accepted):

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    n, a, b = map(int, input().split())
    if b-a < 0:
        print(0)
        exit(0)
    if n == 1:
        if b != a:
            print(0)
        else:
            print(1)
        exit(0)
    print((n-2)*(b-a)+1)


if __name__ == '__main__':
    main()

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B = map(int, input().split())
if A > B:
    print(0)
elif N == 1:
    print(1 if A == B else 0)
elif N == 2:
    print(1)
else:
    print(N*(B-A-1)+1)

Failing test case input:
33 -1 1

Expected output:
63


Actual output:
34


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
if A > B:
    print(0)
elif N == 1:
    print(1 if A == B else 0)
elif N == 2:
    print(1)
else:
    print((N-2)*(B-A)+1)

Problem: p03705
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,A,B=map(int,input().split())
if A>B:
    print(0)
elif A==B:
    print(1)
else:
    if N==1:
        print(0)
    else:
        print((B-A+1)+(B-A))

Failing test case input:
13 -6 2

Expected output:
89


Actual output:
17


Fixed submission (verdict: Accepted):
N,A,B=map(int,input().split())
if A>B:
    print(0)
elif A==B:
    print(1)
else:
    if N==1:
        print(0)
    else:
        print((B*(N-2)-A*(N-2))+1)

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
















N,A,B = map(int,input().split())

if N == 0:
    print(0)
    exit()
elif N == 1 and A==B:
    print(1)
    exit()
elif N == 1 and A!=B:
    print(0)
    exit()
elif A>B:
    print(0)
    exit()
elif N==2:
    print(1)
    exit()
else:
    n = N-2
    ans = B*n - A*2 +1
    print(ans)
    exit()





Failing test case input:
13 -3 2

Expected output:
56


Actual output:
29


Fixed submission (verdict: Accepted):
















N,A,B = map(int,input().split())

if N == 0:
    print(0)
    exit()
elif N == 1 and A==B:
    print(1)
    exit()
elif N == 1 and A!=B:
    print(0)
    exit()
elif A>B:
    print(0)
    exit()
elif N==2:
    print(1)
    exit()
else:
    n = N-2
    ans = B*n - A*n +1
    print(ans)
    exit()
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

mi = a * (n-2)
ma = b * (n-2)
result = ma - mi + 1
if a > b:
    print(0)
elif a == b and n != 1:
    print(0)
elif n == 1 and a <= b:
    print(b-a+1)
elif result < 0:
    print(0)
else:
    print(result)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
4


Fixed submission (verdict: Accepted):

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

mi = a * (n-2)
ma = b * (n-2)
result = ma - mi + 1
if a > b:
    print(0)
elif n == 1 and a != b:
    print(0)
elif n == 1 and a == b:
    print(1)
    
else:
    print(result)

Problem: p03705
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, A, B = map(int, input().split())
if N == 1 and A != B:
  print(0)
else:
  print((N-2)*(B-A)+1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


Fixed submission (verdict: Accepted):
N, A, B = map(int, input().split())
if (N == 1 and A != B) or A > B:
  print(0)
else:
  print((N-2)*(B-A)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        print((a+3*b)-(3*a+b)+1)
resolve()

Failing test case input:
32 0 4

Expected output:
121


Actual output:
9


Fixed submission (verdict: Accepted):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        print((a+(n-1)*b)-((n-1)*a+b)+1)
resolve()

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = list(map(int,input().split()))
M = (N[2] - N[1]) * (N[0] - 2) + 1
if N[0] == 1:
    print(1)
elif N[1] == 2:
    print(1)
else:
    print(M)

Failing test case input:
56 2 4

Expected output:
109


Actual output:
1


Fixed submission (verdict: Accepted):
N = list(map(int,input().split()))
M = (N[2] - N[1]) * (N[0] - 2) + 1
if N[0] == 1 and N[1] == N[2]:
    print(1)
elif N[0] == 1:
    print(0)
elif N[0] == 2:
    print(1)
elif N[1] > N[2]:
    print(0)
else:
    print(M)

Problem: p03705
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, a, b = [ int(v) for v in input().split() ]
if n == 1:
    if a != b:
        ans = 1
    else:
        ans = 0
else:
    if a <= b:
        maxsum = a + b*(n-1)
        minsum = a*(n-1) + b
        ans = maxsum - minsum + 1

    else:
        ans = 0
print(ans)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
1


Fixed submission (verdict: Accepted):
n, a, b = [ int(v) for v in input().split() ]
if n == 1:
    if a != b:
        ans = 0
    else:
        ans = 1
else:
    if a <= b:
        maxsum = a + b*(n-1)
        minsum = a*(n-1) + b
        ans = maxsum - minsum + 1

    else:
        ans = 0
print(ans)
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int,input().split())

if A > B or A == B:
  print(0)
else:
  a = (N-2)*(B-A) + 1
  print(a)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


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

if A > B :
  print(0)
elif N == 1 and A == B:
  print(1)
elif N == 1 and A!= B:
  print(0)
else:
  a = (N-2)*(B-A) + 1
  print(a)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int,input().split())
if N <= 2:
    print(1)
    exit()
elif A > B:
    print(0)
    exit()
print((N-2)*(B-A) + 1)


Failing test case input:
1 7 10

Expected output:
0

Actual output:
1


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

if A > B or (N == 1 and A != B):
    print(0)
    exit()
print((N-2)*(B-A) + 1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = [int(i) for i in input().split()]

hanni = B-A+1
N -= 2

if A == B:
    print(1)
    exit()

if hanni <= 0 or N <= 0:
    print(0)
else:
    ans = (hanni-1)*2+1
    print(ans)


Failing test case input:
125 -2 0

Expected output:
247


Actual output:
5


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

hanni = B-A+1
N -= 2

if A == B:
    print(1)
    exit()

if hanni <= 0 or N <= 0:
    print(0)
else:
    ans = (hanni-1)*N+1
    print(ans)

Problem: p03705
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, a, b = map(int, input().split())

if b-a < 0:
    print(0)
elif a == b:
    print(1)
elif b-a+1 < n:
    print((n-2)**2+1)
else:
    print((n-2)**3+1)

Failing test case input:
12 -1 0

Expected output:
11


Actual output:
101


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

if b-a < 0 or n == 1 and a != b:
    print(0)
elif a == b:
    print(1)
else:
    print((b-a)*(n-2)+1)

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


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, a, b = LI()

min_s = a * (n - 1) + b
max_s = a + (n - 1) * b
print(f'{min_s=}, {max_s=}')
ans = max_s - min_s + 1
if ans < 0:
    ans = 0
print(ans)


Failing test case input:
36 -1 2

Expected output:
103


Actual output:
min_s=-33, max_s=69
103


Fixed submission (verdict: Accepted):

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, a, b = LI()

min_s = a * (n - 1) + b
max_s = a + (n - 1) * b
ans = max_s - min_s + 1
if ans < 0:
    ans = 0
print(ans)
Problem: p03705
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,a,b=map(int,input().split())
if b<a:
  print(0)
  exit()
  
if a==b:
  print(1)
  exit()
  

n-=2

print(b*n-a*n+1)



Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


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

n-=2

if n<0:
  print(0)
  exit()

if n==0:
  print(1)
  exit()

print(b*n-a*n+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
n,a,b = map(int, input().split())

if a>b:
    print(0)
elif n==1:
    print(1)
else:
    print((b*3+a) - (a*3+b) +1 )


Failing test case input:
39 0 1

Expected output:
38


Actual output:
3


Fixed submission (verdict: Accepted):
import math
n,a,b = map(int, input().split())

if a>b:
    print(0)
elif n==1 and a != b:
    print(0)
else:
    print((b*(n-1)+a) - (a*(n-1)+b) +1 )

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = list(map(int,input().split()))

if a>b:
    print(0)
elif a == b:
    print(1)
elif n == 2:
    print(1)
elif n == 1:
    print(0)
else:
    print(2*b-2*a+1)

Failing test case input:
19 0 1

Expected output:
18


Actual output:
3


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

if a>b:
    print(0)
elif a == b:
    print(1)
elif n == 2:
    print(1)
elif n == 1:
    print(0)
else:
    print((n-2)*b-(n-2)*a+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif A == B or N <= 2:
    print(1)
else:
    print((N - 2) * (B - A) + 1)


Failing test case input:
1 7 10

Expected output:
0

Actual output:
1


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

if A > B:
    print(0)
elif A == B:
    print(1)
else:
    if N == 1:
        print(0)
    else:
        print((N - 2) * (B - A) + 1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
if a>b:
  print(0)
elif n==1 and a<b:
  print(0)
else:
  print((b-a)*n+1)

Failing test case input:
11 -3 1

Expected output:
37


Actual output:
45


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
if a>b:
  print(0)
elif n==1 and a<b:
  print(0)
else:
  print((b-a)*(n-2)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = map(int,input().split())

print((b - a + 1) * (n - 2) - 1)

Failing test case input:
28 -2 1

Expected output:
79


Actual output:
103


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

print(max(0,(n-1)*b + a - ((n-1)*a + b) + 1))
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
if n == 1:
  if a == b:
    print(1)
  else:
    print(0)
  exit()
if n == 2:
  print(1)
  exit()
print((b-a)*(n-2)+1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
if a>b:
  print(0)
  exit()
if n == 1:
  if a == b:
    print(1)
  else:
    print(0)
  exit()
if n == 2:
  print(1)
  exit()
print((b-a)*(n-2)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())

if n == 1:
    print(0)
else:
    print((n-2)*(b-a)+1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


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

if n == 1 and a == b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print((n-2)*(b-a)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B = map(int,input().split())
if A>B:
    print(0)
    exit()
else:
    print((B*(N-1)+A-(A*(N-1)+B)+1))

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


Fixed submission (verdict: Accepted):
N,A,B = map(int,input().split())
if A>B:
    print(0)
    exit()
elif A != B and N == 1:
    print(0)
    
else:
    print((B*(N-1)+A-(A*(N-1)+B)+1))

Problem: p03705
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        print(0)
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    else:
        print((B-A)*B - (B-A)*A + 1)


if __name__ == '__main__':
    main()


Failing test case input:
48 0 2

Expected output:
93


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        print(0)
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    else:
        print((N-2)*B - (N-2)*A + 1)


if __name__ == '__main__':
    main()

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

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

mi = a * (n-2)
ma = b * (n-2)
result = ma - mi + 1
if a > b:
    print(0)
elif a == b and n != 1:
    print(0)
elif n == 1:
    print(b-a+1)
elif result < 0:
    print(0)
else:
    print(result)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
4


Fixed submission (verdict: Accepted):

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

mi = a * (n-2)
ma = b * (n-2)
result = ma - mi + 1
if a > b:
    print(0)
elif n == 1 and a != b:
    print(0)
elif n == 1 and a == b:
    print(1)
    
else:
    print(result)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B=map(int,input().split())
if A>B:
  print(0)
  exit()
print((N-2)*(B-A)+1)
  

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


Fixed submission (verdict: Accepted):
N,A,B=map(int,input().split())
if A>B:
  print(0)
  exit()
elif N==1:
  if A!=B:
    print(0)
    exit()
print((N-2)*(B-A)+1)
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b=map(int,input().split())
if n==1 and a==b:
  print(1)
elif a>b or (n==1 and a!=b):
  print(0)
else:
  print(2*(b-a)+1)


Failing test case input:
18 -2 2

Expected output:
65


Actual output:
9


Fixed submission (verdict: Accepted):
n,a,b=map(int,input().split())
if n==1 and a==b:
  print(1)
elif a>b or (n==1 and a!=b):
  print(0)
else:
  print((n-2)*(b-a)+1)

Problem: p03705
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def comb(a, b):
    return math.factorial(a)

def main():
    n, a, b = map(int, input().split())
    if (a > b) or (n==1 and a<b):
        print(0)
    elif n == 1 and a == b:
        print(1)
    else:
        print(comb(b-a+n, n) - comb(b-a+n-1, n) * 2)
            
if __name__ == '__main__':
    main()

Failing test case input:
13 -1 0

Expected output:
12


Actual output:
74724249600


Fixed submission (verdict: Accepted):
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, a, b = map(int, input().split())
    if (a > b) or (n==1 and a<b):
        print(0)
    elif n == 1 and a == b:
        print(1)
    else:
        print(n*(b-a)+2*(a-b)+1)
            
if __name__ == '__main__':
    main()

Problem: p03705
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,a,b=map(int,input().split())

if a==b:
  print(1)
elif n==1:
  print(0)
elif n==2:
  print(2)
else:
  print((b-a)*(n-2)+1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


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

if a>b:
  print(0)
elif a==b:
  print(1)
elif n==1:
  print(0)
elif n==2:
  print(2)
else:
  print((b-a)*(n-2)+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())
min_a_b = a * (n-1) + b
max_a_b = a + n * (n-1)
print(max_a_b - min_a_b + 1)

Failing test case input:
13 -1 2

Expected output:
34


Actual output:
166


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())
min_a_b = a * (n-1) + b
max_a_b = a + b * (n-1)
print(max(0, max_a_b - min_a_b + 1))

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
min_ = A * (N - 1) + B
max_ = B * (N - 1) + A
print(max_ - min_ + 1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


Fixed submission (verdict: Accepted):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
if A > B or ((N == 1) and (A != B)):
  print(0)
else:
  min_ = A * (N - 1) + B
  max_ = B * (N - 1) + A
  print(max_ - min_ + 1)
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())

if a > b:
    print(0)
    exit(0)
if n == 1:
    if a == b:
        print(1)
        exit(0)
    else:
        print(1)
        exit(0)
print((n-2) * (b-a) + 1)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
1


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

if a > b:
    print(0)
    exit(0)
if n == 1:
    if a == b:
        print(1)
        exit(0)
    else:
        print(0)
        exit(0)
print((n-2) * (b-a) + 1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b = list(map(int,input().split()))

if a>b:
    print(0)
elif a == b:
    print(1)
elif n == 2:
    print(1)
elif n == 1:
    print(0)
else:
    print(2*b-2*a)

Failing test case input:
15 1 2

Expected output:
14


Actual output:
2


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

if a>b:
    print(0)
elif a == b:
    print(1)
elif n == 2:
    print(1)
elif n == 1:
    print(0)
else:
    print((n-2)*b-(n-2)*a+1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())

if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
elif n == 2:
  print(1)
else:
  if a == b:
    print(1)
  else:
    print((b-a) * (n-2) + 1)

Failing test case input:
5 5 3

Expected output:
0


Actual output:
-5


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

if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
elif n == 2:
  print(1)
else:
  if a == b:
    print(1)
  elif a > b:
    print(0)
  else:
    print((b-a) * (n-2) + 1)

Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B=map(int,input().split())
if A<B:
  print(0)
if N==1 and A!=B:
  print(0)
else:
  print((N-2)*(B-A)+1)

Failing test case input:
29 -2 1

Expected output:
82


Actual output:
0
82


Fixed submission (verdict: Accepted):
N,A,B=map(int,input().split())
if A>B:
  print(0)
elif N==1 and A!=B:
  print(0)
else:
  print((N-2)*(B-A)+1)

Problem: p03705
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   
   sys.stdin = open(name)

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

if a > b:
   print(0)
   exit()

if b-a+1 == n:
   print(1)
   exit()
elif b-a+1 > n:
   print(0)
   exit()

print( (b-a)*(n-2)+1 )


Failing test case input:
3 -4 0

Expected output:
5


Actual output:
0


Fixed submission (verdict: Accepted):
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   
   sys.stdin = open(name)

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

if a > b:
   print(0)
   exit()

if n == 1:
	if a == b:
		print(1)
		exit()
	else:
		print(0)
		exit()

print( (b-a)*(n-2)+1 )
Problem: p03705
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b = map(int, input().split())
min_a_b = a * (n-1) + b
max_a_b = a + b * (n-1)
print(max_a_b - min_a_b + 1)

Failing test case input:
1 7 10

Expected output:
0

Actual output:
-2


Fixed submission (verdict: Accepted):
n, a, b = map(int, input().split())
min_a_b = a * (n-1) + b
max_a_b = a + b * (n-1)
print(max(0, max_a_b - min_a_b + 1))
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
m=0
a=0
r=0
c=0
h=0
for _ in range(N):
  s=input()
  if s[0]=="M":
    m+=1
  elif s[0]=="A":
    a+=1
  elif s[0]=="R":
    r+=1
  elif s[0]=="C":
    c+=1
  elif s[0]=="H":
    h+=1
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=a*r*c
ans+=a*r*h
ans+=r*c*h
print(ans)

Failing test case input:
5
MASIHLE
IOTMR
ACIOR
RACOHO
HOROL@NAJ

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
m=0
a=0
r=0
c=0
h=0
for _ in range(N):
  s=input()
  if s[0]=="M":
    m+=1
  elif s[0]=="A":
    a+=1
  elif s[0]=="R":
    r+=1
  elif s[0]=="C":
    c+=1
  elif s[0]=="H":
    h+=1
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=m*r*c
ans+=m*r*h
ans+=m*c*h
ans+=a*r*c
ans+=a*r*h
ans+=a*c*h
ans+=r*c*h
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
N=int(input())
S=list(str(input()) for i in range(N))
m,a,r,c,h=[0]*5
ans=0
if S[0]=="M":m+=1
if S[0]=="A":a+=1
if S[0]=="R":r+=1
if S[0]=="C":c+=1
if S[0]=="H":h+=1

x=[m,a,r,c,h]
for i in itertools.combinations(x,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Failing test case input:
5
MASHILE
RMUOI
AOICR
HABOQN
JAN@LOROH

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
import itertools
N=int(input())
S=list(str(input()) for i in range(N))
m,a,r,c,h=[0]*5
ans=0
for i in range(len(S)):
  if S[i][0]=="M":m+=1
  if S[i][0]=="A":a+=1
  if S[i][0]=="R":r+=1
  if S[i][0]=="C":c+=1
  if S[i][0]=="H":h+=1

x=[m,a,r,c,h]
for i in itertools.combinations(x,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [input()[0] for _ in range(N)]
t = []
ans = 0
for k in 'MARCH':
    t.append(s.count(k))
for i in range(32):
    u = []
    for j in range(5):
        u.append(t[j])
    if len(u) == 3:
        ans += u[0]*u[1]*u[2]
print(ans)

Failing test case input:
5
MASIHLE
IOTMR
ACIOR
RACOHO
KAN@LOROI

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
s = [input()[0] for _ in range(N)]
t = []
ans = 0
for k in 'MARCH':
    t.append(s.count(k))
for i in range(32):
    u = []
    for j in range(5):
        if i&(1<<j):
            u.append(t[j])
    if len(u) == 3:
        ans += u[0]*u[1]*u[2]
print(ans)
Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections

N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0 

for i in S:
    if i == 'M' or i == 'A' or i == 'R' or i == 'C' or i == 'H':
        A.append(i)
        
if len(A) != 0:       
    C = collections.Counter(A).most_common()
    v,c = zip(*C)
    s = c[0]

    for i in range(1,len(c)):
        s *= c[i]

    ans = s
    
print(ans)





Failing test case input:
5
E@DKUOHI
GNR
PKOATM
NIAK
RNNFI

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import collections
import itertools

N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0

for i in S:
    if i == 'M' or i == 'A' or i == 'R' or i == 'C' or i == 'H':
        A.append(i)
        
if len(A) != 0:       
    C = collections.Counter(A).most_common()
    v,c = zip(*C)
    
    

    for a,b,c in itertools.combinations(c,3):
        
        ans += a*b*c

print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
M,A,R,C,H=0,0,0,0,0
for i in range(N):
    name=input()
    if name[0]=='M':
        M+=1
    elif name[0]=='A':
        A+=1
    elif name[0]=='R':
        R+=1
    elif name[0]=='C':
        C+=1
    elif name[0]=='H':
        H+=1

print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + \
      M*C*H + A*R*C + A*C*H + A*C*H + R*C*H)

Failing test case input:
5
I@DUKOGE
HNR
MTAOKP
AINK
RINGN

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
M,A,R,C,H=0,0,0,0,0
for i in range(N):
    s=input()[0]
    if s=='M':
        M+=1
    elif s=='A':
        A+=1
    elif s=='R':
        R+=1
    elif s=='C':
        C+=1
    elif s=='H':
        H+=1

print(M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + \
      M*C*H + A*R*C + A*R*H + A*C*H + R*C*H)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

list_pop = [0] * 5
for i in range(N):
    s = input()
    if list(s)[0] == 'M':
        list_pop[0] += 1
    if list(s)[0] == 'A':
        list_pop[1] += 1
    if list(s)[0] == 'R':
        list_pop[2] += 1
    if list(s)[0] == 'C':
        list_pop[3] += 1
    if list(s)[0] == 'H':
        list_pop[4] += 1


print(list_pop)

answer = 0
for i in range(3):
    for j in range(4)[i+1:]:
        for k in range(5)[j+1:]:
            answer += list_pop[i] * list_pop[j] * list_pop[k]
    
    
print(int(answer))

Failing test case input:
5
MASIHLE
IOTMR
ACIOR
QACOHO
JAN@LOROH

Expected output:
0


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


Fixed submission (verdict: Accepted):
N = int(input())

list_pop = [0] * 5
for i in range(N):
    s = input()
    if list(s)[0] == 'M':
        list_pop[0] += 1
    if list(s)[0] == 'A':
        list_pop[1] += 1
    if list(s)[0] == 'R':
        list_pop[2] += 1
    if list(s)[0] == 'C':
        list_pop[3] += 1
    if list(s)[0] == 'H':
        list_pop[4] += 1




answer = 0
for i in range(3):
    for j in range(4)[i+1:]:
        for k in range(5)[j+1:]:
            answer += list_pop[i] * list_pop[j] * list_pop[k]
    
    
print(int(answer))
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
import collections

N = int(input()) 
A = []
for i in range(N):
    A.append(input()[0])
c = collections.Counter(A)

if len(set(A)) >= 3:
    ans = 1
    for i in c.values():
        ans *= i
else:
    ans = 0

print(ans)

Failing test case input:
5
EKIHSAM
IOMUR
OCIRA
HABORN
IANAKOROH

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
from itertools import combinations
import collections

N = int(input()) 

A = []
for i in range(N):
    A.append(input()[0])

C = collections.Counter(A)
print(sum(C[a]*C[b]*C[c] for a, b, c in combinations("MARCH", 3)))

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for _ in range(N):
  s = input()
  if s[0] in 'MARCH':
    d[s[0]] += 1

if d:
  ans = 1
  for c in d.values():
    ans *= c
else:
  ans = 0
print(ans)

Failing test case input:
5
EKIHSAM
IOMUR
AOICR
HABOQN
IAN@LOROH

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict
import itertools
N = int(input())
d = defaultdict(int)
for _ in range(N):
  s = input()
  if s[0] in 'MARCH':
    d[s[0]] += 1

ans = 0
if len(d.keys()) >= 3:
  for c in itertools.combinations(d.values(), 3):
    ans += c[0] * c[1] * c[2]

print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = [0]*5
x = 1

for i in range(n):
    s = input()
    if s[0] == "M":
        ans[0] = ans[0] + 1
    if s[0] == "A":
        ans[1] = ans[1] + 1
    if s[0] == "R":
        ans[2] = ans[2] + 1
    if s[0] == "C":
        ans[3] = ans[3] + 1
    if s[0] == "H":
        ans[4] = ans[4] + 1

if ans.count(0) == 5:
    print(0)
else:
    for i in ans:
        if i != 0:
            x *= i
    print(x)
print(ans)

Failing test case input:
5
IHDUKO@E
GNR
PKOATM
KIAN
RNNFI

Expected output:
0


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


Fixed submission (verdict: Accepted):
import itertools

n = int(input())
li = [0]*5
ans = 0

for i in range(n):
    s = input()
    if s[0] == "M":
        li[0] = li[0] + 1
    if s[0] == "A":
        li[1] = li[1] + 1
    if s[0] == "R":
        li[2] = li[2] + 1
    if s[0] == "C":
        li[3] = li[3] + 1
    if s[0] == "H":
        li[4] = li[4] + 1

for l in itertools.combinations(li, 3):
    ans += l[0] * l[1] * l[2]    

print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import re
from itertools import groupby
from itertools import groupby, combinations
import functools
import operator

pattern = r"^(M|A|R|C|H).*"
checker = re.compile(pattern)

N = int(input())
names = []
for i in range(N):
    name = input()
    if checker.match(name):
        names.append(name)

counts = []
for group, item in groupby(names, lambda x:x[0]):
    counts.append(len(list(item)))
comb = functools.reduce(operator.mul, counts) if len(counts) >= 3 else 0
print(comb)

Failing test case input:
5
CHOKUD@I
RNG
MAKOTO
AOKI
RINGO

Expected output:
7


Actual output:
1


Fixed submission (verdict: Accepted):
import re
from itertools import groupby
from itertools import groupby, combinations
import functools
import operator

pattern = r"^(M|A|R|C|H).*"
checker = re.compile(pattern)

N = int(input())
names = []
for i in range(N):
    name = input()
    if checker.match(name):
        names.append(name)
        
counts = {}
for group, item in groupby(names, lambda x:x[0]):
    counts[group] = counts[group]+(len(list(item))) if group in counts.keys() else (len(list(item)))

total = 0
for comb in combinations(counts.keys(), 3):
    tmp = []
    for letter in comb:
        tmp.append(counts[letter])

    n_comb = functools.reduce(operator.mul, tmp)
    total += n_comb
    
print(total)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[0]*5
for i in range(n):
  x=input()
  y=x[0]
  if y=='M':
    l[0]+=1
  elif y=='A':
    l[1]+=1
  elif y=='R':
    l[2]+=1
  elif y=='C':
    l[3]+=1
  elif y=='H':
    l[4]+=1
ans=l[0]*l[1]*l[2]
print(ans)

Failing test case input:
5
MASHILE
RMUOI
ACIOR
HABOQO
JAN@LOROH

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
l=[0]*10
for i in range(n):
  x=input()
  y=x[0]
  if y=='M':
    l[0]+=1
  elif y=='A':
    l[1]+=1
  elif y=='R':
    l[2]+=1
  elif y=='C':
    l[3]+=1
  elif y=='H':
    l[4]+=1
ans=0
for i in range(3):
  for j in range(i+1,i+4):
    for k in range(j+1,j+4):
      ans+=l[i]*l[j]*l[k]
print(ans)
Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import defaultdict
from itertools import combinations

N=int(input())
S=[input() for _ in range(N)]

c = defaultdict(int)

for i in range(N):
  if S[i][0] in {'M','A','R','C','H'}:
    c[S[i][0]] += 1

if len(c) < 3:
  print(0)
  exit()

if len(c)==3:
  ans=0
  for k in c.keys():
    ans *= c[k]
  print(ans)
  exit()

else:
  ans = 0
  l = len(c)
  keys = list(c.keys())
  for C in combinations(range(l),3):
    tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]]
    ans += tmp
  print(ans)

Failing test case input:
5
MASHILE
RMUOI
ROICA
HABOQN
JAN@LOROH

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
from collections import defaultdict
from itertools import combinations

N=int(input())
S=[input() for _ in range(N)]

c = defaultdict(int)

for i in range(N):
  if S[i][0] in {'M','A','R','C','H'}:
    c[S[i][0]] += 1

if len(c) < 3:
  print(0)
  exit()

if len(c)==3:
  ans=1
  for k in c.keys():
    ans *= c[k]
  print(ans)
  exit()

else:
  ans = 0
  l = len(c)
  keys = list(c.keys())
  for C in combinations(range(l),3):
    tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]]
    ans += tmp
  print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
N = int(input())

num_dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
    S = input()
    if S[0] in num_dic.keys():
        num_dic[S[0]] += 1

ans = 0
print(num_dic)
for i, j, k in itertools.combinations(num_dic.keys(), 3):
    ans += num_dic[i] * num_dic[j] * num_dic[k]
print(ans)


Failing test case input:
4
YX
ZZZ
W
YXZZZZZ[ZZ

Expected output:
0


Actual output:
{'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
0


Fixed submission (verdict: Accepted):
import itertools
N = int(input())

num_dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
    S = input()
    if S[0] in num_dic.keys():
        num_dic[S[0]] += 1

ans = 0
for i, j, k in itertools.combinations(num_dic.keys(), 3):
    ans += num_dic[i] * num_dic[j] * num_dic[k]
print(ans)

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

Failing test case input:
5
EKIHSAM
IOMUR
OCIRA
HABORN
IANAKOROH

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
n=int(input())
cnt=[0]*5
check='MARCH'
for i in range(n):
  s=input()
  for j in range(5):
    if s[0]==check[j]:
      cnt[j]+=1
      break
ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ans+=cnt[i]*cnt[j]*cnt[k]
print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = [input()[0] for _ in range(n)]

from collections import Counter

c = Counter(s)

c = list(c.values())

c_len = len(c)

ans = 0
for i in range(c_len):
    for j in range(i+1, c_len):
        for k in range(j+1, c_len):
            ans += c[i] * c[j] * c[k]

print(ans)


Failing test case input:
5
MASHIKE
RUMOI
OBIRA
OROBAH
HOROKANAI

Expected output:
1


Actual output:
7


Fixed submission (verdict: Accepted):
n = int(input())
s = [input()[0] for _ in range(n)]

c = []
c.append(s.count("M"))
c.append(s.count("A"))
c.append(s.count("R"))
c.append(s.count("C"))
c.append(s.count("H"))
c_len = len(c)
ans = 0
for i in range(c_len):
    for j in range(i+1, c_len):
        for k in range(j+1, c_len):
            ans += c[i] * c[j] * c[k]

print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=[]
a,b,c,d,e=0,0,0,0,0
for i in range(n):
  S=input()
  if S[0]=='M':
    a+=1
  if S[0]=='A':
    b+=1
  if S[0]=='R':
    c+=1
  if S[0]=='C':
    d+=1
  if S[0]=='H':
    e+=1
print(a*b*c*+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e)



Failing test case input:
5
I@DUKOGE
HNR
MTAOKP
AINK
RINGN

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
s=[]
a,b,c,d,e=0,0,0,0,0
for i in range(n):
  S=input()
  if S[0]=='M':
    a+=1
  if S[0]=='A':
    b+=1
  if S[0]=='R':
    c+=1
  if S[0]=='C':
    d+=1
  if S[0]=='H':
    e+=1
print(a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
print(a)
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Failing test case input:
5
MASHIKE
IOMUR
ARIBO
HABORN
HOROKANAI

Expected output:
2


Actual output:
[1, 1, 0, 0, 2]
2


Fixed submission (verdict: Accepted):
from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
N = int(input())
d = defaultdict(int)
for _ in range(N):
  s = input()
  if s[0] in 'MARCH':
    d[s[0]] += 1

if len(d.keys()) >= 3:
  ans = 1
  for c in d.values():
    ans *= c
else:
  ans = 0
print(ans)

Failing test case input:
5
MASHILE
RMUOI
AOICR
HABOQN
JAN@LOROH

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict
import itertools
N = int(input())
d = defaultdict(int)
for _ in range(N):
  s = input()
  if s[0] in 'MARCH':
    d[s[0]] += 1

ans = 0
if len(d.keys()) >= 3:
  for c in itertools.combinations(d.values(), 3):
    ans += c[0] * c[1] * c[2]

print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
import math

n = int(input())
names = []

for _ in range(n):
    names.append(input())


march = {"M":0,"A":0,"R":0,"C":0,"H":0}

for name in names:
    if name[0] in march:
        march[name[0]]+=1
march_num = 0
for count in march.values():
    if count > 0:
        march_num += 1

if march_num >= 3:
    ans = math.factorial(march_num)
    for capital , cnt in march.items():
        if cnt > 1:
            ans += math.factorial(march_num-1)
else:
    ans = 0


print(ans)

Failing test case input:
5
I@DUKOGE
HNR
MTAOKP
AINK
RINGN

Expected output:
4


Actual output:
24


Fixed submission (verdict: Accepted):
import itertools
import math

n = int(input())
names = []

for _ in range(n):
    names.append(input())


march = {"M":0,"A":0,"R":0,"C":0,"H":0}

for name in names:
    if name[0] in march:
        march[name[0]]+=1
march_num = 0
for count in march.values():
    if count > 0:
        march_num += 1

if march_num >= 3:
    ans = 0
    for cap_1,cap_2,cap_3 in itertools.combinations(march,3):
        cap_1_num = march[cap_1]
        cap_2_num = march[cap_2]
        cap_3_num = march[cap_3]
        ans += cap_1_num*cap_2_num*cap_3_num

else:
    ans = 0

print(ans)

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



import itertools


def main():
    N = int(input())
    S = [input()[0] for _ in range(N)]

    result = []
    for comb in list(itertools.combinations(S, 3)):
        if comb[0] != comb[1] and comb[0] != comb[2] and comb[1] != comb[2]:
            result.append(comb)

    print(len(result))


if __name__ == "__main__":
    main()


Failing test case input:
4
YW
ZZZ
X
YXZZZZZ[ZZ

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):



from itertools import combinations


def main():

    N = int(input())

    count = {x: 0 for x in "MARCH"}

    for _ in range(N):
        s = input()[0]
        if s in count:
            count[s] += 1

    result = 0
    for a, b, c in combinations("MARCH", 3):
        result += count[a] * count[b] * count[c]

    print(result)


if __name__ == "__main__":
    main()

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=[input() for _ in range(n)]

march=["M","A","R","C","H"]
count=[0]*5
for i in range(n):
    for j in range(5):
        if s[i][0]==march[j]:
            count[j]+=1
            
def f(a,b,c):
    return a*b*c

c0=count[0]
c1=count[1]
c2=count[2]
c3=count[3]
c4=count[4]
ans=f(c0,c1,(c2+c3+c4))+f((c0+c1),c2,(c3+c4))+f((c0+c2),c3,c4)+f(c1,c2,c4)
print(ans)

Failing test case input:
5
MASHIKE
RUMOI
AOICR
HABOQN
IAN@LOROH

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
n=int(input())
march=["M","A","R","C","H"]
count=[0]*5
for i in range(n):
    s=input()
    for j in range(5):
        if s[0]==march[j]:
            count[j]+=1
c0=count[0]
c1=count[1]
c2=count[2]
c3=count[3]
c4=count[4]
ans=c0*c1*c2+c0*c1*c3+c0*c1*c4+c0*c2*c3+c0*c2*c4+c0*c3*c4+c1*c2*c3+c1*c2*c4+c1*c3*c4+c2*c3*c4
print(ans)