TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.  Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:    * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.  At least how many explosions do you need to cause in order to vanish all the monsters?

Submission attempts (in order):
N, A, B = map(int, input().split())
D = A - B

H = sorted([int(input()) for _ in range(N)], reverse=True)

def f(n):
    needed_attacks = 0
    for h in H:
        r = h - B * n
        if r < 0:
            r = 0

        if r % D == 0:
            needed_attacks += r // D
        else:
            needed_attacks += r // D + 1

    return needed_attacks <= n

s = 0
e = H[-1] // B + 1

while e - s > 1:
    m = (s + e) // 2
    if f(m):
        e = m
    else:
        s = m

print(e)


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

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

def f(n):
    needed_attacks = 0
    for h in H:
        r = h - B * n
        if r < 0:
            r = 0

        if r % D == 0:
            needed_attacks += r // D
        else:
            needed_attacks += r // D + 1

    return needed_attacks <= n

s = 0
e = max(H) // B + 1

while e - s > 1:
    m = (s + e) // 2
    if f(m):
        e = m
    else:
        s = m

print(e)


Verdicts: Wrong Answer

Accepted
Problem: You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below.  Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows:    * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds.  At least how many explosions do you need to cause in order to vanish all the monsters?

Submission attempts (in order):
a,b,c = map(int, input().split())
l = [int(input()) for _ in range(a)]
flag = True
l = sorted(l)
max_T = 10**18
def ok(k):
    s = k
    for i in l:
        hp = i - c * k
        if hp > 0:
            s -= -(-hp // (b - c))
        if s < 0:
            return False
    return True
def binary_search(l,r):
    mid = (l + r) // 2
    if l == r:
        return l
    elif ok(mid):
        return bbb(l,mid)
    else:
        if mid == l:
            mid += 1
            
        return bbb(mid,r)
binary_search(0,max_T)

a,b,c = map(int, input().split())
l = [int(input()) for _ in range(a)]
flag = True
l = sorted(l)
max_T = l[-1]//c + 1
def ok(k):
    s = k
    for i in l:
        hp = i - c * k
        if hp > 0:
            s -= -(-hp // (b - c))
        if s < 0:
            return False
    return True
def bbb(l,r):
    mid = (l + r) // 2
    if l == r:
        return l
    elif ok(mid):
        return bbb(l,mid)
    else:
        if mid == l:
            mid += 1
            
        return bbb(mid,r)
bbb(0,max_T)

a,b,c = map(int, input().split())
l = [int(input()) for _ in range(a)]
flag = True
l = sorted(l)
max_T = 10**18
def ok(k):
    s = k
    for i in l:
        hp = i - c * k
        if hp > 0:
            s -= -(-hp // (b - c))
        if s < 0:
            return False
    return True
def binary_search(l,r):
    mid = (l + r) // 2
    if l == r:
        return l
    elif ok(mid):
        return bbb(l,mid)
    else:
        if mid == l:
            mid += 1
            
        return bbb(mid,r)
ans =binary_search(0,max_T)
print(ans) 

a,b,c = map(int, input().split())
l = [int(input()) for _ in range(a)]
flag = True
l = sorted(l)
max_T = 10**18
def ok(k):
    s = k
    for i in l:
        hp = i - c * k
        if hp > 0:
            s -= -(-hp // (b - c))
        if s < 0:
            return False
    return True
def binary_search(l,r):
    mid = (l + r) // 2
    if l == r:
        return l
    elif ok(mid):
        return binary_search(l,mid)
    else:
        if mid == l:
            mid += 1
            
        return binary_search(mid,r)
ans = binary_search(0,max_T)
print(ans) 

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.  a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?

Submission attempts (in order):
import sys,bisect,math
input = sys.stdin.readline


def bitsum(bit,i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i&(-i)
    return s
    

def bitadd(bit,i,x):
    while i <= n:
        bit[i] += x
        i += i&(-i)
    return bit

n,k = map(int,input().split())
a = [int(input()) for i in range(n)]

#b[j+1]-b[i]:a[i]~a[j]
b = [0]
for i in range(n):
    b.append(b[-1]+a[i])

#c[i]:b[i]-k*i
c = [0]*(n+1)
for i in range(n+1):
    c[i] = b[i]-k*i

d = sorted(c)
for i in range(n+1):
    k = bisect.bisect_left(d,c[i])
    d[k] = d[k]
    c[i] = k+1
print(c)
n_ = int(math.log2(n+1)) + 1
bit = [0] * (2**n_+1)
ass = 0
for j in range(n+1):
    ass += j-bitsum(bit,c[j])
    
    bit = bitadd(bit,c[j],1)
print(n*(n+1)//2-ass)

import sys,bisect,math
input = sys.stdin.readline


def bitsum(bit,i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i&(-i)
    return s
    

def bitadd(bit,i,x):
    while i <= n:
        bit[i] += x
        i += i&(-i)
    return bit

n,k = map(int,input().split())
a = [int(input()) for i in range(n)]

#b[j+1]-b[i]:a[i]~a[j]
b = [0]
for i in range(n):
    b.append(b[-1]+a[i])

#c[i]:b[i]-k*i
c = [0]*(n+1)
for i in range(n+1):
    c[i] = b[i]-k*i

d = sorted(c)
for i in range(n+1):
    k = bisect.bisect_left(d,c[i])
    d[k] = d[k]-0.1
    c[i] = k+1

n = n+1
n_ = int(math.log2(n)) + 1
bit = [0] * (2**n_+1)
ass = 0
for j in range(n):
    ass += j-bitsum(bit,c[j])
    
    bit = bitadd(bit,c[j],1)


print(n*(n-1)//2-ass)

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.  a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?

Submission attempts (in order):
class BinaryIndexedTree:
  def __init__(self, size):
    self.data = [0] * (size+1)
    self.size = size
  
  def add(self, i, w):
    while i <= self.size:
      self.data[i] += w
      i += i & -i

  def sum(self, i):
    result = 0
    while i > 0:
      result += self.data[i]
      i -= i & -i
    return result

from itertools import accumulate,repeat

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

B = [0] + [sa-sk for sa,sk in zip(accumulate(int(input())), accumulate(repeat(K, N)))]

lookup = dict(((b,i+1) for i,b in enumerate(sorted(B))))

result = 0
bit = BinaryIndexedTree(N+1)

for b in B:
  c = lookup[b]
  result += bit.sum(c)
  bit.add(c,1)

print(result)

class BinaryIndexedTree:
  def __init__(self, size):
    self.data = [0] * (size+1)
    self.size = size
  
  def add(self, i, w):
    while i <= self.size:
      self.data[i] += w
      i += i & -i

  def sum(self, i):
    result = 0
    while i > 0:
      result += self.data[i]
      i -= i & -i
    return result

from itertools import accumulate,repeat

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

B = [0] + [sa-sk for sa,sk in zip(accumulate(int(input()) for _ in range(N)), accumulate(repeat(K)))]

lookup = dict(((b,i+1) for i,b in enumerate(sorted(B))))

result = 0
bit = BinaryIndexedTree(N+1)

for b in B:
  c = lookup[b]
  result += bit.sum(c)
  bit.add(c,1)

print(result)

Verdicts: Runtime Error

Accepted
Problem: You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.  a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?

Submission attempts (in order):
import sys
from itertools import accumulate

inf = 1<<60
ans = 0

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]
    s = [0] + list(accumulate(a))

    print(ans)

def MergeSort(a):
    if len(a) == 1:
        return a

    apre = MergeSort(a[:len(a)//2])
    asuf = MergeSort(a[len(a)//2:])

    res = merge(apre, asuf)

    return res

def merge(a, b):
    global ans
    na = len(a)
    nb = len(b)

    a.append(-inf)
    b.append(-inf)

    la = 0
    lb = 0

    res = []

    for i in range(na + nb):
        if a[la] <= b[lb]:
            ans += na - la
            res.append(b[lb])
            lb += 1
        else:
            res.append(a[la])
            la += 1

    return res

if __name__ == '__main__':
    solve()

import sys
from itertools import accumulate

inf = 1<<60
ans = 0

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]
    s = [0] + list(accumulate(a))

    MergeSort(s)

    print(ans)

def MergeSort(a):
    if len(a) == 1:
        return a

    apre = MergeSort(a[:len(a)//2])
    asuf = MergeSort(a[len(a)//2:])

    res = merge(apre, asuf)

    return res

def merge(a, b):
    global ans
    na = len(a)
    nb = len(b)

    a.append(-inf)
    b.append(-inf)

    la = 0
    lb = 0

    res = []

    for i in range(na + nb):
        if a[la] <= b[lb]:
            ans += na - la
            res.append(b[lb])
            lb += 1
        else:
            res.append(a[la])
            la += 1

    return res

if __name__ == '__main__':
    solve()

Verdicts: Wrong Answer

Accepted
Problem: You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K.  a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?

Submission attempts (in order):
N, K = map(int, input().split())
a = []
for _ in range(N):
    a.append(int(input())-K)
    
su = 0
v = [(0, 0)]
for i in range(N):
    su += a[i]
    v.append((su, i+1))
v = sorted(v)

data = [0]*(N+1)

def sumation(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
    
def add(i, x):
    while i <= N:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += sumation(i+1)
    add(i+1, 1)
    
print(ans)

N, K = map(int, input().split())
a = []
for _ in range(N):
    a.append(int(input())-K)
    
su = 0
v = [(0, 0)]
for i in range(N):
    su += a[i]
    v.append((su, i+1))
v = sorted(v)

data = [0]*(N+2)

def sumation(i):
    s = 0
    while i > 0:
        s += data[i]
        i -= i & -i
    return s
    
def add(i, x):
    while i <= N+1:
        data[i] += x
        i += i & -i
ans = 0
for e, i in v:
    ans += sumation(i+1)
    add(i+1, 1)
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.  You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?

Submission attempts (in order):
def recursion(length, ll, string, cc):
    if ll * 2 < length:
        for i in range(10):
            string1 = string + str(i)
            recursion(length, ll+1, string1, cc)
    else:
        number = str(int(string) + int(cc[-ll:]))
        ds = ""
        for i in range(length // 2):
            if i + 1 <= len(number):
                ds += number[-i-1]
            else:
                ds += "0"
        string = ds + string
        if str(int(string) + int(cc)) == string[::-1] and string[0] != "0":
            global answer
            answer += 1
        elif str(int(string) + int(cc)) == string[::-1]:
            global az
            az += 1
            

d = input()
d1 = d
plus = 0
while True:
    if d[-1] == "0":
        d = d[:-1]
        plus += 1
    else:
        break
answer = 0
az = 0
recursion(len(d), 0, "", d)
recursion(len(d)+1, 0, "", d)
yes = False
while plus > 0:
    yes = True
    if plus == 1:
        plus -= 1
        answer = answer * 9
        az = az * 9
    else:
        plus -= 1
        answer *= 10
        az *= 9
if yes:
    answer += az
    

def result(letters, number, cant_zero):
    if letters <= 1:
        if number == 0:
            return 10 ** letters
        return 0
    diff = (10 - number%10) % 10
    variants = number % 10 - cant_zero
    if number % 10 == 0:
        variants = 10 - cant_zero
    number -= diff * (10**(letters-1) - 1)
    number = abs(number // 10)
    return variants * result(letters-2, number, 0)

d = int(input())
ans = 0
for i in range(20):
    ans += result(i, d, 1)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.  You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?

Submission attempts (in order):
# (10-x) ways: (0,x)-(9-x,9) -> (x, -x)
# (x) ways:    (10-x,0)-(9,x-1) -> (x-10, 10 - x)

def solve(d, k, outer):
  if k <= 1:
    return (10 - outer)**k if d == 0 else 0

  tail = d % 10
  if d >= 10**k:
    return 0
  c = d+tail*10**(k-1)
  return (10-tail-outer)*solve(abs(c//10), k-2, 0) + (tail-outer)*solve(abs((c-10**k)//10 + 1), k-2, 0)

D = int(input())
result = 0
for k in range(1,20):
  result += solve(D, k, 1)
  print(k,result)

print(result)

def solve(d, K):
  r = 1
  for k in range(K,1,-2):
    if d >= 10**k:
      return 0
    t = (-d)%10
    d = abs((d-t*(10**(k-1)-1))//10)
    r *= 10-t-(K==k)
  return r*(10**(K%2)) if d == 0 else 0

D = int(input())
result = 0
l = len(str(D))
for k in range(l,2*l+1):
  result += solve(D, k)

print(result)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.  You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?

Submission attempts (in order):
D = int(input())

def table(i, k):
    if i == k:
        return list(range(9, -1, -1)) + [0]*9
    else:
        return list(range(10, 0, -1)) + list(range(1, 10))

def nine(i):
    return 10**i - 1

def rec(d, i, k):
    res = 0
    num  = table(i, k)
    if i == 1:
        for j in range(-9, 10):
            if 9*j == d:
                return num[j]
        return 0
    if i == 2:
        for j in range(-9, 10):
            if d == 99*j:
                return 10*num[j]
    if not -10*nine(i) <= d <= 10*nine(i):
        return 0
    for j in range(-9, 10):
        if d%10 == j*nine(i)%10:
            res += num[j] * rec((d-j*nine(i))//10, i-2, k)
    return res

l = 0
while D % 10 == 0:
    D//= 10
    l += 1

if l == 0:
    a = 1
else:
    a = 9*10**(l-1)

ans = 0
for i in range(1, 17):
    if not l:
        ans += rec(D, i, i)
    else:
        ans += rec(D, i, 100)
if ans % 9 != 0:
    ans = 0
print(a * ans)

D = int(input())

def table(i, k):
    if i == k:
        return list(range(9, -1, -1)) + [0]*9
    else:
        return list(range(10, 0, -1)) + list(range(1, 10))

def nine(i):
    return 10**i - 1

def rec(d, i, k):
    res = 0
    num  = table(i, k)
    if i == 1:
        for j in range(-9, 10):
            if 9*j == d:
                return num[j]
        return 0
    if i == 2:
        for j in range(-9, 10):
            if d == 99*j:
                return 10*num[j]
    if not -10*nine(i) <= d <= 10*nine(i):
        return 0
    for j in range(-9, 10):
        if d%10 == j*nine(i)%10:
            res += num[j] * rec((d-j*nine(i))//10, i-2, k)
    return res

l = 0
while D % 10 == 0:
    D//= 10
    l += 1

if l == 0:
    a = 1
else:
    a = 9*10**(l-1)

ans = 0
for i in range(1, 20):
    if not l:
        ans += rec(D, i, i)
    else:
        ans += rec(D, i, 100)
print(a * ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = list(map(int, input().split()))

if A == B:
    ans = 1
elif A > B:
    ans = 0
else:
    ans = 0

print(ans)

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

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
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)​

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

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
a,b,c = map(int,input().split())
if a<=1:
    if b==c:
        print(1)
    else:
        print(0)
elif c>=b:
    print(0)
else:
    min = (a-1)*b+c
    max = (a-1)*c+b
    print(max-min+1)

nums = input()
nums = nums.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
    exit(0)
if a > b:
    print(0)
    exit(0)
num = b*(n-2) - a*(n-2) + 1
print(num)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

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

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

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

print(max(B*(N-1)+A-(A*(N-1)+B)+1,0))

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=[int(_) for_ in input().split()]
if n==1:
  if a==b:
    print(1)
  else:
    print(0)
print(max(0,(n-2)*(b-a)+1)

n,a,b=[int(_) for _ in input().split()]
if n==1:
  if a==b:
    print(1)
  else:
    print(0)
  exit()
print(max(0,(n-2)*(b-a)+1))


Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())
if (n == 1 and a == b):
  ans = 1
elif (n == 1):
  ans = 0
elif A > B:
  ans = 0
else:
  ans = (b - a) * (n - 2) + 1
print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N,A,B=map(int,input().split())
print((B-A)*N+1)

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

N,A,B=map(int,input().split())
if N==1:
    if A==B:
        ans=1
    else:
        ans=0
else:
    if A>B:
        ans=0
    else:
        ans=(B-A)*(N-2)+1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
import combinations from itertools
n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    m = range(n[1],n[2]+1)
    c = list(combinations(m,n[0]-2))
    c.extend([(i,i) for i in m])
    print(len(set([i+j for i,j in c])))

n = [int(i) for i in input().split()]
if n[0] == 1 and n[1] < n[2]:
    print(0)
elif n[1]>n[2]:
    print(0)
elif n[0] == 1 and n[1]==n[2]:
    print(1)
else:
    mi = n[1]*(n[0]-1)+n[2]
    ma = n[2]*(n[0]-1)+n[1]
    print(ma-mi+1)

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

if A > B:
    ans = 0
elif N==1:
    ans = 1 if A==B else 0
else:
    sum_min = (N-1) * A
    sum_max = (N-1) * B
    ans = sum_max - sum_min + 1

print(ans)

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

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=map(int, input().split())
ans=(n-2)*(b-a)*2
if n==1:
    if a!=b:
        ans=0
    else:
        ans=1
if b<a:ans=0
print(ans)

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
import numpy as np
import math
import scipy
import itertools

def solve():
    n, a, b = map(int, input().split())
    print(max(b*(n-1)-a*(n-1)+1, 0))
    return 0

if __name__ == "__main__":
    solve()



import numpy as np
import math
import scipy
import itertools

def solve():
    n, a, b = map(int, input().split())
    if a > b:
        print(0)
    elif n == 1:
        if a == b:
            print(1)
        else:
            print(0)
    else:
        print(b*(n-1)+a-a*(n-1)+b+1)
    return 0

if __name__ == "__main__":
    solve()



import numpy as np
import math
import scipy
import itertools

def solve():
    n, a, b = map(int, input().split())
    if a > b:
        print(0)
    elif n == 1:
        if a == b:
            print(1)
        else:
            print(0)
    else:
        print((b*(n-1)+a)-(a*(n-1)+b)+1)
    return 0

if __name__ == "__main__":
    solve()



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N,A,B=map(int,input().split())
if A>B:
  print(0)
if B-A>=1 and N==1:
  print(0)
else:
  print((B-A)**N+1)

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)

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)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())
tmp = abs(b-a)+1
if b < a or (n == 1 and b-a > 1):
    print(0)
else:
    if n == 1:
        print(1)
    else:
        print(tmp**(n-2) - tmp**2)

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

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

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1 and A != B:
    print(0)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
print(1000)


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

if A > B:
    print(0)
elif N == 1 and A != B:
    print(0)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
else:
    print(1000)


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

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())
print(max(0, B*(N-1)+A-(A*(N-1)+B)))


N, A, B = map(int, input().split())
print(max(0, B*(N-1)+A-(A*(N-1)+B)+1))


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=map(int,input().split());n-=2
if a>b:print(0)
else:print((b-a)*n)

n,a,b=map(int,input().split())
if (n==1 and a!=b) or a>b:exit(print(0))
mi=b+(n-1)*a
ma=a+(n-1)*b
print(ma-mi+1)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
print(0)


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

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


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
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)


# ~10m AC
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)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):


n, a, b = map(int, input().split())
if n == 1 or b < a:
    print(0)
elif n == 2 and a <= b:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(minn, maxn)
    print(maxn - minn + 1)






n, a, b = map(int, input().split())
if a == b and n == 1:
    print(1)
elif b < a or n == 1:
    print(0)
elif n == 2 and a <= b:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(maxn - minn + 1)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


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

if __name__ == '__main__':
    main()


# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


    if a > b:
        ans = 0
    elif a == b:
        ans = 1
    elif b < a:
        if n == 1:
            ans = 0
        else:
            min_possible = a * (n - 1) + b
            max_possible = b * (n - 1) + a
            ans = max_possible - min_possible + 1
    
    print(ans)

if __name__ == '__main__':
    main()


# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


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

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=map(int,input().split())
print(n*b-n*a+1)

N=input()
A=input()
B=input()
print((2-N)(A-B))

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

min_sum = a * (n - 1) + b
max_sum = b * (n - 1) + a

print(max(max_sum - min_sum + 1, 0))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
a = int(input())
b = int(input())

if a == b:
    print(1)
    exit()



def bitlen(x):
    return 1 + bitlen(x >> 1) if x else 0

t = a ^ b
n = bitlen(t)

T = 1 << (n - 1)

a = a & (T * 2 - 1)
b = b & (T * 2 - 1)

sb = b & (T - 1)
b_max = (2 ** bitlen(sb) - 1) | T

if (T + a) > b_max:
    print((b_max - a + 1) + (2 * T - 1 - (T + a) + 1))
else:
    print(2 * T - 1 - a + 1)


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

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

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N,A,B = map(int,input().split())
maxi = B*N
mini = A*N
if A > B:
    print(0)
elif A == B:
    print(1)
else:
    print(maxi - mini)

N,A,B = map(int,input().split())
maxi = B*(N-1) + A
mini = A*(N-1) + B
if A > B:
    print(0)
elif N == 0:
    print(0)
elif A == B:
    print(1)
elif N == 1:
    print(0)
else:
    print(maxi - mini + 1)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
s = input()
l = len(s)
su = 0
for i in range(1,l-1):
 # print(su)
  if s[i]=="U":
    su += 1*(l-1-i)+2*(i)
  else:
    su += 1*(i)+2*(l-i-1)
print(su+2*(l-1))

import math 
n,a,b = map(int,input().split())
if a>b:
  print(0)
  exit()
if n==1 and a!=b:
  print(0)
  exit()
if n==2:
  print(1)
  exit()
q = b*(n-2)-a*(n-2)+1
print(q)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N,A,B=map(int,input().split())

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
else n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
if n>=b:
    print(b*n+1)

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

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())

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


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

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


Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

if B < A:
  print(0)
elif N == 1 and A!= B:
  print(0)
elif N == 1 and A == B:
  print(1)
else:
  x = 1
  for i in range(B-A+1):
    x *= B-A+1-i
  print(x)
    

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

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

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())
if (a < b) print(0)
else print(b*(n-1)+a-a*(n-1)-b+1)


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


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


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
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)

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)

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

cnt = 0

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

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

if A > B:
    print(0)
elif N == 1:
    print(0)

else:
    print((B-A)(N-2)+1)

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)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())

if a > b or n < 1 or not (n == 1 and a == b):
    print(0)
else:
    ma, mi = b * (n-1) + a, a * (n - 1) + b
    print(ma - mi + 1)


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

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


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n=input().slipt()
print(int(n[2]*(n[0]-2)-(n[1]*n[0]-2)+1))

s=input().split();n,a,b=int(s[0]),int(s[1]),int(s[2])
if a>b:
    print(0)
elif n=1:
    if a==b:
        print(1)
    else:
        print(0)
else:
    print((a-b)*(n-2)+1)

n,a,b=map(int,input().split())
if n>1 and b>=a or n==1 and a==b: 
    print ((n-2)*(b-a)+1);
else:
    print ("0");

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())A
print((b - a) * (n - 2) + 1)


n, a, b = map(int, input().split())
x = a * n - a + b
y = b * n - b + a


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


Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N, A, B = map(int, input().split())

N -= 1
if A != B:
  N -= 1

if N < 0:
  ans = 0
else:
  M = B - A
  ans = 1
  for k, m in zip(range(M + N, 0, -1), range(1, N+1)):
    ans *= k
    ans //= m

print(ans)


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

N -= 1
if A != B:
  N -= 1
if A > B:
  N = -1

if N < 0:
  ans = 0
else:
  ans = (B - A) * N + 1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=map(int,input().split())
if a>b:
    print(0)
    exit()
elif n=1 and a!=b:
    print(0)
    exit()
print((b-a)*(n-2)+1)


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


Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n, a, b = map(int, input().split())

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

print(ans)


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

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

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
#!/ust/bin/env python

N,A,B=[int(i) for i in input().split()]

def sum(count, num):
    tmp=0
    for i in range(0, count):
        tmp+=num
    print("tmp",tmp)
    return tmp

Max=(A+B)+sum(N-2, B)
Min=(A+B)+sum(N-2, A)

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


#!/ust/bin/env python

N,A,B=[int(i) for i in input().split()]

def main():
    if(A>B):
        print(0)
        return
    elif(A==B):
        print(1)
        return

    ### A<B
    Max=(A+B)+(N-2)*B
    Min=(A+B)+(N-2)*A

    if(N==1):
        print(0)
    elif(N==2):
        print((B+B)-(A+A)+1)
    elif(Max-Min+1<=0):
        print(0)
    else:
        print(Max-Min+1)

main()


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b = map(int, input().split())

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

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

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

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

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

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

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


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
N,A,B = map(int,input().split())
data = range(A,B+1)
if N-2>=0:
  print( (B − A)(N − 2) + 1)
elif N == 1:
  if A!=B:
    print('0')
  else:
    print('1')
else:
  print('0')

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)

Verdicts: Runtime Error

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=list(map(int,input().split(' ')))
print(max(0,n-2)*max(0,b-a+1))


n,a,b=list(map(int,input().split(' ')))
print(max(0,n-2)*max(0,a-b)+1)

n,a,b=list(map(int,input().split(' ')))
if n == 1:
    print(1 if a==b else 0)
else:
    print((b-a)*(n-2)+1 if b >= a else 0)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
s = input()
s = list(s)
s.sort()
ans = list("abc")
if (s == ans):
  print("Yes")
else :
  print("No")

n, a, b = map(int, input().split())
print(max(0, (n-2)*b - (n-2)*a + 1))

Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=map(int,input().split())
if a>b:
  print(0)
elif a==b:
  print(1)
else:
  if n <= 2:
    print(n-1)
  else:
    print((b-a)*(n-2)-1) 

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


Verdicts: Wrong Answer

Accepted
Problem: Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?

Submission attempts (in order):
n,a,b=map(int,input().split())
ans=b*(n-1)+a-a*(n-1)-b
if ans<=0:
  print(0)
else:
  print(ans)

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

Verdicts: Wrong Answer

Accepted