ZhenlongDai/ACPR huggingface dataset:
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
A, B, N = [int(i) for i in input().split()]

max_n = 0
for x in range(1,N+1):
    f = math.floor((A*x)/B) - (A* math.floor(x/B))
    if f > max_n:
        max_n = x
print(max_n)

Failing test case input:
35 10 3

Expected output:
10


Actual output:
3


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

def floor_calc(x):
    return math.floor((A * x)/B) - (A * math.floor(x / B))

x = min(B-1,N)

print(floor_calc(x))

Problem: p02696
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import floor

A, B, N = map(int, input().split())
if N > B:
    print(A-1)
else:
    print(floor(A*N/B)-A*floor(N/B))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
13


Fixed submission (verdict: Accepted):
from math import floor

def f(x):
    return floor(A*x/B)-A*floor(x/B)
A, B, N = map(int, input().split())
print(f(min(N, B-1)))

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

if n < b:
    print(int(a * n / b) - a * int(n / b))
else:
    print(a - 1)


Failing test case input:
14 7 8

Expected output:
12


Actual output:
13


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

if n < b:
    print(int(a * n / b) - a * int(n / b))
else:

    print((a - 1) - int((a - 1) / b))

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

from math import floor

def parse():
  return map(int, input().split(" "))

def main():
  A, B, N = parse()

  limit_N = 100000
  N = limit_N if N > limit_N else N

  x = 0
  max_val = floor((A * x) / B) - A * floor(x / B)

  for x in range(1, N + 1):
    val = floor((A * x) / B) - A * floor(x / B)
    if max_val < val:
      max_val = val

  print(max_val)

if __name__ == "__main__":
  main()

Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):

from math import floor

def parse():
  return map(int, input().split(" "))

def main():
  A, B, N = parse()
  
  x = B - 1 if B - 1 <= N else N
  print(floor((A * x) / B) - A * floor(x / B))
  exit(0)

  limit_N = 5000000
  N = limit_N if N > limit_N else N

  x = 0
  max_val = floor((A * x) / B) - A * floor(x / B)

  for x in range(1, N + 1):
    val = floor((A * x) / B) - A * floor(x / B)
    if max_val < val:
      max_val = val

  print(max_val)


if __name__ == "__main__":
  main()

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,N=map(int,input().split());print(min(B-1,N))

Failing test case input:
0 130 3

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
A,B,N=map(int,input().split());x=min(B-1,N);print(int(A*x/B)-A*int(x/B))
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,N=[int(x) for x in input().rstrip().split()]
ans=0
now=0
aa=0

cnt=0

if N<B:
  print(int(A*N/B)-A*int(N/B))
else:
  print(int(A*B/B)-A*int(B/B))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
0


Fixed submission (verdict: Accepted):
A,B,N=[int(x) for x in input().rstrip().split()]
ans=0
now=0
aa=0

cnt=0

if N<B:
  print(int(A*N/B)-A*int(N/B))
else:
  print(int(A*(B-1)/B)-A*int((B-1)/B))

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

if A >= B :
    print( int(A/B*(B-1)))

elif A < B:
    if N < B:
        print(int(A/B*N))
    else:
        print( int(A/B*(B-1)))
    

Failing test case input:
9 7 5

Expected output:
6


Actual output:
7


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

if A >= B :
    if N < B:
        print(int(A/B*N))
    else:
        print( int(A/B*(B-1)))

elif A < B:
    if N < B:
        print(int(A/B*N))
    else:
        print( int(A/B*(B-1)))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math


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

    def target(x):
        return math.floor(A * x / B) - A * math.floor(x / B)

    max_value = -1
    max_x = -1
    for i in range(1, min(10**6, N)+1):
        v = target(i)
        
        if v > max_value:
            max_x = i
            max_value = v

    
    print(max_value)


if __name__ == '__main__':
    main()


Failing test case input:
2 11 0

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
import math


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

    def target(x):
        
        
        return math.floor(A * x / B) - A * math.floor(x / B)

    print(target(min(N, B-1)))

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


if __name__ == '__main__':
    main()

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	if(n>b):
		f = math.floor((a*(b-1))/b)
		s = math.floor((b-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	else:
		f = math.floor((a*(n-1))/b)
		s = math.floor((n-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	print(ans)
	

Failing test case input:
56 12 1

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	ni = min(n,b-1)
	f = math.floor((a*(ni))/b)
	s = math.floor((ni)/b)
	temp = int(f) - (a*int(s))
	ans = temp
	
	
	
	
	
	
	
	
	
	
	print(ans)
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
import collections
def f(a,b,x):
    return math.floor((a*x)/b) - a*math.floor(x/b)
a,b,n=map(int, input().split())
dd = collections.defaultdict(int)

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


Failing test case input:
2 11 0

Expected output:
0


Actual output:
1


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

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

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

def f(n):
    d = int(A*n/B) - A*int(n/B)
    return d

if N < B==0:
    ans = int(A*N/B)
else:
    ans = A-1

Failing test case input:
0 486 4

Expected output:
0


Actual output:

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

def f(n):
    d = int(A*n/B) - A*int(n/B)
    return d

print(f(min(B-1,N)))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
a, b, n = map(int, input().split())
m = min(b, n)
print(math.floor(a*m/b))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
14


Fixed submission (verdict: Accepted):
import math
a, b, n = map(int, input().split())
if n >= b:
    n = b-1
print(math.floor(a*n/b))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

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

print(math.floor(A*N/B))



Failing test case input:
14 7 8

Expected output:
12


Actual output:
16


Fixed submission (verdict: Accepted):
import math

A, B, N = map(int, input().split())
x = min(B-1, N)
print(math.floor(A*x/B) - math.floor(x/B)*A)

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math


nums = [int(e) for e in input().split()]

a = nums[0]
b = nums[1]
n = nums[2]

max_score = -1
score = -1

for x in range(1, n+1):
    score = math.floor(a*x/b) - a* math.floor(x/b)
    if max_score < score:
        max_score = score
        x += 1
    else:
        break

print(max_score)


Failing test case input:
4 7 4

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import math


nums = [int(e) for e in input().split()]

a = nums[0]
b = nums[1]
n = nums[2]

max_score = -1
score = -1








if b > n:
    max_score = math.floor(a*n/b)
else:
    max_score = math.floor(a*(b-1)/b)

print(max_score)
Problem: p02696
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
import random

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(1000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)


Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
0


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

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

def quick(x):
  pri = (A * x 
  lat = A * (x 
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,n =map(int,input().split())
x = 0

def floor(x,y):
  return int(x/y)

if b > n:
  x = n
  print(floor(a*x, b)-a*floor(x, b))
else:
  print(floor(a*b, b)-a*floor(b,b))

Failing test case input:
14 7 8

Expected output:
12


Actual output:
0


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

def floor(x,y):
  return int(x/y)

if b > n:
  print(floor(a*n, b)-a*floor(n, b))
else:
  print(floor(a*(b-1), b)-a*floor(b-1,b))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,n=map(int,input().split())
if b<=n:
  print(int((a*(b-0.1)/b)-a*int((b-0.1)/b)))
else:
  print(int((a*(n-0.1)/b)-a*int((n-0.1)/b)))
  

Failing test case input:
11 11 9

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
a,b,n=map(int,input().split())
if b<=n:
  print(int((a*(b-1)/b)))
else:    
  print(int((a*(n)/b)))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,n=map(int,input().split())
if b<=n:
  print(int((a*(b)/b))-1)
else:
  print(int((a*(n)/b)))
  

Failing test case input:
14 7 8

Expected output:
12


Actual output:
13


Fixed submission (verdict: Accepted):
a,b,n=map(int,input().split())
if b<=n:
  print(int((a*(b-1)/b)))
else:    
  print(int((a*(n)/b)))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

def floor(A, B, x):
    return math.floor(A * x / B) - A * math.floor(x/B) 

A, B, N = map(int, input().split(' '))
x = min(N, B-1)
print(min(floor(A,B,N), floor(A,B,B-1)))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


Fixed submission (verdict: Accepted):
import math

def floor(A, B, x):
    return math.floor(A * x / B) - A * math.floor(x/B) 

A, B, N = map(int, input().split(' '))
x = min(N, B-1)
print(floor(A,B,x))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, n = map(int, input().split(' '))
c = int(a*n/b) - a*int(n/b)
print(c)

Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


Fixed submission (verdict: Accepted):
a, b, n = map(int, input().split(' '))
r = min(b-1, n)
c = int(a*r/b) - a*int(r/b)
print(c)
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
A,B,N = [int(x) for x in input().split(' ')]
if N/B >= 1:
  print(int(A-math.floor(-float(A)/float(B))))
else:
  print(int(math.floor(float(N)*float(A)/float(B))))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
16


Fixed submission (verdict: Accepted):
import math
A,B,N = [int(x) for x in input().split(' ')]
if N/B >= 1:
  print(int(A+math.floor(-float(A)/float(B))))
else:
  print(int(math.floor(float(N)*float(A)/float(B))))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
def LI():return list(map(int,input().split()))

a,b,n=LI()

def f(x):
    ret=math.floor(a*x/b)-a*math.floor(x/b)
    return ret

if n>=a:
    ans=a-1
else:
    ans=f(n)
print(ans)

Failing test case input:
0 19 2

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
import math
def LI():return list(map(int,input().split()))

a,b,n=LI()

def f(x):
    ret=math.floor(a*x/b)-a*math.floor(x/b)
    return ret

if n<b:
    ans=f(n)
else:
    ans=f(b-1)
    
print(ans)

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,n=map(int,input().split())
print(int((a*n)/b)-a*int(n/b))

Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


Fixed submission (verdict: Accepted):
a,b,n=map(int,input().split())
k=min(n,b-1)
print(int((a*k)/b)-a*int(k/b))

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

Failing test case input:
14 7 8

Expected output:
12


Actual output:
-72


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

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
A,B,N=map(int,input().split())

if B >N:
  print(math.floor((A*N)/B))
else:
  print(math.floor((A*N)/B)-(A*(math.floor(N/B))))

Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


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

if B >N:
  print(math.floor((A*N)/B))
else:
  print(math.floor((A*(B-1)/B)))

Problem: p02696
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math

def func(x):
    global a,b
    return int(math.floor(a*x/b)-a*math.floor(x/b))

a,b,n = map(int,input().split())
print(func(b-1))

Failing test case input:
11 19 2

Expected output:
1


Actual output:
10


Fixed submission (verdict: Accepted):
import math

def func(x):
    global a,b
    return int(math.floor(a*x/b)-a*math.floor(x/b))

a,b,n = map(int,input().split())
if n < b-1:
    x = n
else:
    x = b-1
print(func(x))
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    from builtins import int, map, list, print, max
    import sys, math
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, N = input_number_list()
    m = 0
    for i in range(1, A):
        t = math.floor(A*i/B) - A*math.floor(i/B)
        m = max(m,t)
    print(m)


if __name__ == '__main__':
    main()


Failing test case input:
11 11 9

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):
def main():
    from builtins import int, map, list, print, max
    import sys, math
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, N = input_number_list()
    x = min(B - 1, N)
    print(math.floor(A * x / B) - A * math.floor(x / B))


if __name__ == '__main__':
    main()

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

def main():
    a, b, n = map(int, input().split())
    x = n-1 if b-1 > n else b-1
    print(math.floor(a*x/b)-a*math.floor(x/b))
         
if __name__ == '__main__':
    main()

Failing test case input:
56 12 1

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
import math

def main():
    a, b, n = map(int, input().split())
    x = n if (b-1) > n else b-1
    print(math.floor(a*x/b)-a*math.floor(x/b))
         
if __name__ == '__main__':
    main()

Problem: p02696
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import floor

def main():
    A, B, N = list(map(int, input().split(' ')))
    
    tmp = 0
    
    for x in range(1, N+1):
        out = floor(A * x / B) - floor(x / B)
        tmp = max(tmp, out)
    print(tmp)
    
    
main()

Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
from math import floor, gcd

def f(x, A, B):
    return floor(A * x / B) - A * floor(x / B)

def main():
    A, B, N = list(map(int, input().split(' ')))
    
    tmp = 0
    
    
    
    a = f(min(B-1, N), A, B)
    print(a)
    
    
main()

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import floor
a,b,n = map(int,input().split())

if a <= 1:
    n = 0

print (floor((a*n)/b) - a*(floor(n/b)))


Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


Fixed submission (verdict: Accepted):
from math import floor
a,b,n = map(int,input().split())
x = min(b-1,n)
print (floor((a*x/b) - a*(floor(x/b))))
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
a,b,n=map(int, input().split()) 
max = -1000
tmp = 0

for i in range(1,n+1):
    tmp = math.floor(a * i / b) - a * math.floor(i / b)
    if max < tmp:
        max = tmp
    else:
        break

print(max)

Failing test case input:
1 15 0

Expected output:
0


Actual output:
-1000


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

if n >= b:
    max = math.floor(a * (b - 1) / b) - a * math.floor((b - 1) / b)
else:
    max = math.floor(a * n / b) - a * math.floor(n / b)
print(max)

Problem: p02696
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

import sys
import math

def solve(A: int, B: int, N: int):
    print(math.floor(A*min(B, N)/B) - A * math.floor(min(B, N)/B))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    N = int(next(tokens))  
    solve(A, B, N)

if __name__ == '__main__':
    main()

Failing test case input:
14 7 8

Expected output:
12


Actual output:
0


Fixed submission (verdict: Accepted):

import sys
import math

def solve(A: int, B: int, N: int):
    print(math.floor(A*min(B-1, N)/B) - A * math.floor(min(B-1, N)/B))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    N = int(next(tokens))  
    solve(A, B, N)

if __name__ == '__main__':
    main()

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
a,b,n=map(int, input().split()) 
max = -10000
tmp = 0

for i in range(1, n + 1):
    tmp = math.floor(a * i / b) - math.floor(i / b)
    if max < tmp:
        max = tmp
    else:
        break

print(max)

Failing test case input:
1 15 0

Expected output:
0


Actual output:
-10000


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

if n >= b:
    max = math.floor(a * (b - 1) / b) - a * math.floor((b - 1) / b)
else:
    max = math.floor(a * n / b) - a * math.floor(n / b)
print(max)

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
A, B, N = map(int, input().split())
def kansu(x):
  S = math.floor(A*x/B)
  return S
print(min(kansu(N), kansu(B)))

Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
-2


Fixed submission (verdict: Accepted):
import math
A, B, N = map(int, input().split())
def kansu(x):
  S = math.floor(A*x/B)
  return S
print(min(kansu(N), kansu(B-1)))
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import floor

def parse():
  return map(int, input().split(" "))

def main():
  A, B, N = parse()

  limit_N = 1000000
  N = limit_N if N > limit_N else N

  x = 0
  max_val = floor((A * x) / B) - A * floor(x / B)

  for x in range(1, N + 1):
    val = floor((A * x) / B) - A * floor(x / B)
    if max_val < val:
      max_val = val

  print(max_val)

if __name__ == "__main__":
  main()

Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):

from math import floor

def parse():
  return map(int, input().split(" "))

def main():
  A, B, N = parse()
  
  x = B - 1 if B - 1 <= N else N
  print(floor((A * x) / B) - A * floor(x / B))
  exit(0)

  limit_N = 5000000
  N = limit_N if N > limit_N else N

  x = 0
  max_val = floor((A * x) / B) - A * floor(x / B)

  for x in range(1, N + 1):
    val = floor((A * x) / B) - A * floor(x / B)
    if max_val < val:
      max_val = val

  print(max_val)


if __name__ == "__main__":
  main()

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,N=map(int,input().split())
import math

if A == B :
  if N >= B-1:
    print(int(B-1))
  else:
    print(N)
else:
  print(math.floor(N/abs(A-B)))
  
  

Failing test case input:
4 7 4

Expected output:
2


Actual output:
1


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

if N >= B-1:
  print(math.floor(A*(B-1)/B))
else:
  print(math.floor(A*N/B))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, N = mapint_inp()

from math import floor

S_1 = floor(A*N/B)
S_2 = A*floor(N/B)

print(S_1-S_2)

Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


Fixed submission (verdict: Accepted):
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, N = mapint_inp()

from math import floor

S_1 = (A*N)
S_2 = A*(N
if N < B:
    print(S_1-S_2)
else:
    print(((A*(B-1))
Problem: p02696
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B,N = LMIIS()

    ans = 0
    
    for i in range(1,int(N**0.5)+1):
        ans = max(ans,floor(A*i/B)-A*floor(i/B))
        i2 = N
        ans = max(ans,floor(A*i2/B)-A*floor(i2/B))
        
    print(ans)

    
    
    
    
    

if __name__ == '__main__':
    main()

Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B,N = LMIIS()

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

    
    
    
    
    

if __name__ == '__main__':
    main()

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


def calc(a, b, n):
    return int(math.floor((a * n)/b) - (a * math.floor(n/b)))


print(max(calc(a, b, n), calc(a, b, b-1)))

Failing test case input:
2 10 0

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import math
a, b, n = map(int, input().split())
 
 
def calc(a, b, n):
    return int(math.floor((a * n)/b) - (a * math.floor(n/b)))
 
if n <= b -1:
  print(calc(a,b,n))
else:
  print(calc(a,b,b-1))

Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

a,b,n=i2()
c=0
d=0
for i in range(n+1):
	if c < int(a*i/b):
		c=int(a*i/b)
	if d > int(i/b):
		d=int(i/b)
print(c-a*d)

Failing test case input:
-2 2 1

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

a,b,n=i2()
if b<=n:
	print( a*(b-1)
else:
	print( a*n
Problem: p02696
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,n=map(int,input().split())
x=n%b
print(int(a*x/b)-a*int(x/b))

Failing test case input:
14 7 8

Expected output:
12


Actual output:
2


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

x=min(n,b-1)
print(int(a*x/b)-a*int(x/b))
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, x = map(int, input().split())
*A, = map(int, input().split())
ans = max(A[0] - x, 0)
if A[0] > x: A[0] = x
for i in range(N-1):
    S = A[i] + A[i+1]
    if S > x:
        ans += S - x
        t = min(S, A[i+1])
        A[i+1] -= t
print(ans)

Failing test case input:
3 3
2 2 4

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N, x = map(int, input().split())
*A, = map(int, input().split())
ans = max(A[0] - x, 0)
if A[0] > x: A[0] = x
for i in range(N-1):
    S = A[i] + A[i+1]
    if S > x:
        ans += S - x
        A[i+1] -= min(S - x, A[i+1])
print(ans)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,x = list(map(int,input().split()))
a=list(map(int,input().split()))

eat=0

if a[0]>x:
  eat+=a[0]-x+1
  a[0]=x-1
  
for i in range(N-1):
  if a[i]+a[i+1]>x:
    eat+=a[i+1]-x+a[i]
    a[i+1]=x-a[i]
    
print(eat)

Failing test case input:
2 0
4 0

Expected output:
4


Actual output:
5


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

eat=0

if a[0]>x:
  eat+=a[0]-x
  a[0]=x

if a[N-1]>x:
  eat+=a[N-1]-x
  a[N-1]=x
  
for i in range(N-1):
  if a[i]+a[i+1]>x:
    eat+=a[i+1]-x+a[i]
    a[i+1]=x-a[i]
    
print(eat)

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

def eat(i,candies,counter):
    s=candies[i]+candies[i-1]
    nc=max(0,s-x)
    counter+=nc
    candies[i]-=nc
    return counter

def main(n,x,candies):
    counter=0
    if candies[0]>x:
        counter=x-candies[0]
        candies[0]=x
    for i in range(1,n):
        counter=eat(i,candies,counter)
    return counter

n,x=map(int,sys.stdin.readline().strip().split())
candies=list(map(int,sys.stdin.readline().strip().split()))
print(main(n,x,candies))


Failing test case input:
2 0
1 0

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
import sys

def eat(i,candies,counter):
    s=candies[i]+candies[i-1]
    nc=max(0,s-x)
    counter+=nc
    candies[i]-=nc
    return counter

def main(n,x,candies):
    counter=0
    if candies[0]>x:
        counter=candies[0]-x
        candies[0]=x
    for i in range(1,n):
        counter=eat(i,candies,counter)
    return counter

n,x=map(int,sys.stdin.readline().strip().split())
candies=list(map(int,sys.stdin.readline().strip().split()))
print(main(n,x,candies))
Problem: p03862
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, x = map(int, input().split())
a = list(map(int, input().split()))

r = 0
flow = 0

for i in range(1, N):
    t = (a[i] + a[i - 1]) - x
    if flow != 0:
        r += flow
        t -= flow
        flow = 0

    if t > 0:
        if t > a[i]:
            r += t - a[i]
            t -= a[i]

        flow = max(0, t)

r += flow

print(r)

Failing test case input:
2 0
4 0

Expected output:
4


Actual output:
8


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

r1 = sum(a)
flow = 0

for i in range(1, N):
    t = (a[i] + a[i - 1]) - x
    if flow != 0:
        a[i-1] -= flow
        t -= flow
        flow = 0

    if t > 0:
        if t > a[i]:
            t -= a[i]
            a[i - 1] -= t
            t = a[i]

        flow = t

a[-1] -= flow

r2 = sum(a)

print(r1 - r2)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,x = map(int,input().split())
a = list(map(int,input().split()))
count=0
for i in range(N-1):
    if a[i]+a[i+1] >x:
        if a[i]>x:
            count+=a[i+1]-a[i]+x
            a[i]=x
            a[i+1] = 0
        else:
            count += a[i]+a[i+1]-x
            a[i + 1] -=a[i]+a[i+1]-x
print(count)

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

Expected output:
12


Actual output:
10


Fixed submission (verdict: Accepted):
N,x = map(int,input().split())
a = list(map(int,input().split()))
count=0
for i in range(N-1):
    if a[i]+a[i+1] >x:
        if a[i]>x:
            count+=a[i+1]+a[i]-x
            a[i]=x
            a[i+1] = 0
        else:
            count += a[i]+a[i+1]-x
            a[i + 1] -=a[i]+a[i+1]-x
print(count)

Problem: p03862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

if a[0]+a[1]>x:
    if a[0]<=x:
        ans += a[0]+a[1]-x
        a[1] = x-a[0]
    else:
        ans += a[1]
        a[1] = 0
        ans += a[0]-x
        a[0] = x

for i in range(3, N):
    if a[i-1]+a[i]<=x:
        continue
    
    ans += a[i-1]+a[i]-x
    a[i] = x-a[i-1]

print(ans)

Failing test case input:
3 3
2 2 4

Expected output:
3


Actual output:
1


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

N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

if a[0]+a[1]>x:
    if a[0]<=x:
        ans += a[0]+a[1]-x
        a[1] = x-a[0]
    else:
        ans += a[1]
        a[1] = 0
        ans += a[0]-x
        a[0] = x

for i in range(2, N):
    if a[i-1]+a[i]<=x:
        continue
    
    ans += a[i-1]+a[i]-x
    a[i] = x-a[i-1]

print(ans)
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] > x:
    ans += a[1]
    a[1] = 0
    ans += (a[0] - x)
    a[0] = x
else:
    ans += (a[0] + a[1] - x)
    a[1] = x - a[0]
for i in range(2,N):
    if (a[i - 1] + a[i]) > x:
        ans += (a[i - 1] + a[i] - x)
        a[i] = x - a[i - 1] 
print(ans)

Failing test case input:
-2 124
4 2 4 3 3

Expected output:
0


Actual output:
-118


Fixed submission (verdict: Accepted):
N, x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if a[0] > x:
    ans += a[1]
    a[1] = 0
    ans += (a[0] - x)
    a[0] = x
elif (a[0] + a[1]) > x:
    ans += (a[0] + a[1] - x)
    a[1] = x - a[0]
for i in range(2,N):
    if (a[i - 1] + a[i]) > x:
        ans += (a[i - 1] + a[i] - x)
        a[i] = x - a[i - 1] 
print(ans)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, x = map(int, input().split())
nums = list(map(int, input().split()))
before = nums[0]
cnt = 0
for i in range(1, N):
  ope = before+nums[i]-x
  if ope >= 0:
    before = max(nums[i]-ope, 0)
    cnt += ope
print(cnt)


Failing test case input:
5 9
6 2 4 2 5

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N, x = map(int, input().split())
nums = list(map(int, input().split()))
before = nums[0]
cnt = 0
for i in range(1, N):
  ope = before+nums[i]-x
  if ope > 0:
    before = max(nums[i]-ope, 0)
    cnt += ope
  else:
    before = nums[i]
print(cnt)

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


def solve():
    N, x = list(map(int, input().split()))
    A = list(map(int, input().split()))

    ans = 0
    for i in range(1, N):
        if i%2 == 0: continue

        
        if A[i-1]+A[i] > x:
            diff = (A[i-1]+A[i]) - x
            if A[i] <= diff:
                A[i] -= diff
                ans += diff
    
    for i in range(0, N):
        if i%2 != 0: continue
        
        if i+1 == N: break

        
        if A[i]+A[i+1] > x:
            diff = (A[i]+A[i+1]) - x
            A[i] -= diff
            ans += diff
    
    print(ans)


if __name__ == "__main__":
    solve()


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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):


def solve():
    N, x = list(map(int, input().split()))
    A = list(map(int, input().split()))

    ans = 0

    total = A[1] + A[0]
    if total > x:
        diff = min(total-x, A[1])
        A[1] -= diff
        ans += diff

    total = A[1] + A[0]
    if total > x:
        diff = total - x
        A[0] -= diff
        ans += diff

    for i in range(2, N):
        total = A[i] + A[i-1]

        if total > x:
            diff = total - x
            A[i] -= diff
            ans += diff
    
    print(ans)


if __name__ == "__main__":
    solve()
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int, input().split())
a=list(map(int, input().split()))
count=0
for i in a:
    if i>x:count+=i-x
print(count)
a=[min(x,i) for i in a]
print(a)
a2=[a[0]]
for i in range(1,n):
    if a2[-1]+a[i]-x>0:
        count+=a2[-1]+a[i]-x
        a2.append(x-a2[-1])
    else:a2.append(a[i])
print(count)

Failing test case input:
-4 124
3 2 2 3 3

Expected output:
0


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


Fixed submission (verdict: Accepted):
n,x=map(int, input().split())
a=list(map(int, input().split()))
count=0
for i in a:
    if i>x:count+=i-x
a=[min(x,i) for i in a]
a2=[a[0]]
for i in range(1,n):
    if a2[-1]+a[i]-x>0:
        count+=a2[-1]+a[i]-x
        a2.append(x-a2[-1])
    else:a2.append(a[i])
print(count)

Problem: p03862
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,x=map(int,input().split())
a=list(map(int,input().split()))
c=0
if a[0]>x:
    c+=a[0]-x
    a[0]=x
for i in range(1,n,2):
    if a[i]+a[i-1]>x:
        c+=min(a[i],a[i]+a[i-1]-x)
        a[i]-=min(a[i],a[i]+a[i-1]-x)

print(c)


Failing test case input:
3 3
2 2 4

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
n,x=map(int,input().split())
a=list(map(int,input().split()))
c=0
if a[0]>x:
    c+=a[0]-x
    a[0]=x
for i in range(1,n):
    if a[i]+a[i-1]>x:
        c+=a[i]+a[i-1]-x
        a[i]-=a[i]+a[i-1]-x
print(c)

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

def eat(i,candies,counter):
    s=candies[i]+candies[i-1]
    nc=max(0,s-x)
    counter+=nc
    candies[i]-=nc
    return counter

def main(n,x,candies):
    counter=0
    print(candies)
    if candies[0]>x:
        counter=candies[0]-x
        candies[0]=x
    for i in range(1,n):
        counter=eat(i,candies,counter)
    return counter

n,x=map(int,sys.stdin.readline().strip().split())
candies=list(map(int,sys.stdin.readline().strip().split()))
print(main(n,x,candies))


Failing test case input:
-2 63
5 1 4 3 0

Expected output:
0


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


Fixed submission (verdict: Accepted):
import sys

def eat(i,candies,counter):
    s=candies[i]+candies[i-1]
    nc=max(0,s-x)
    counter+=nc
    candies[i]-=nc
    return counter

def main(n,x,candies):
    counter=0
    if candies[0]>x:
        counter=candies[0]-x
        candies[0]=x
    for i in range(1,n):
        counter=eat(i,candies,counter)
    return counter

n,x=map(int,sys.stdin.readline().strip().split())
candies=list(map(int,sys.stdin.readline().strip().split()))
print(main(n,x,candies))
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,x = map(int,input().split())
a = list(map(int,input().split()))
i = 0
answer = 0
if a[0] > x:
  answer = a[0] - x
  a[0] = x
for i in range(1,N-1):
  if i % 2 == 0:
    if a[i] > a[0]:
      answer += a[i] - a[0]
  else:
    if a[i] > x - a[0]:
      answer += a[i] - x + a[0]
print(answer)

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

Expected output:
13


Actual output:
9


Fixed submission (verdict: Accepted):
N,x = map(int,input().split())
a = list(map(int,input().split()))
i = 0
answer = 0
if a[0] > x:
  answer = a[0] - x
  a[0] = x
for i in range(N-1):
    if a[i] + a[i+1] > x:
        answer += a[i] + a[i+1] - x
        a[i+1] = x - a[i]
print(answer)

Problem: p03862
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def candy():
    boxNum, x = [int(i) for i in input().split()]
    ain = input()
    alist = ain.split(' ')

    s = 0
    for i in range(0, boxNum-1):
        if int(alist[i]) > x:
            s = s + (int(alist[i]) -x)
            alist[i] = x - int(alist[i])

        elif int(alist[i+1]) + int(alist[i]) > x:
            s = s + (int(alist[i+1]) + int(alist[i]) - x)
            alist[i+1] = x - int(alist[i])
        
    print(s)
    
candy()

Failing test case input:
2 0
1 10

Expected output:
11


Actual output:
1


Fixed submission (verdict: Accepted):
def candy():
    n = []
    n = input().split()
    N = int(n[0])
    x = int(n[1])
    alist = [int(i) for i in input().split()]

    s = 0
    for i in range(0, N - 1):
        c = int(alist[i])
        d = int(alist[i + 1])
        if int( alist[i] + alist[i + 1] ) > x:
            if int( alist[i] ) >= x:
                alist[i] = x
                alist[i + 1] = 0
            else :
                alist[i + 1] = int(x - alist[i] )
            s += c - int(alist[i]) + d - int(alist[i + 1])
        
    print(s)
candy()

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int,input().split())
A = list(map(int,input().split()))
sum = []
ans = 0
for i in range(n-1):
    sum.append(A[i]+A[i+1])
for j in range(n-1):
    if j != n-2:
        if sum[j] > x:
            diff = sum[j]-x
            sum[j] -= diff
            sum[j+1] = min(sum[j+1] - diff, 0)
            ans += diff
    else:
        if sum[j] > x:
            diff = sum[j]-x
            sum[j] -= diff
            ans += diff

print(ans)

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n, x = map(int,input().split())
A = list(map(int,input().split()))
if A[0] > x:
    ans = A[0] - x
    A[0] -= ans
else:
    ans = 0
for j in range(n):
    if j != n-1:
        if A[j]+A[j+1]> x:
            diff = A[j+1]+A[j]-x
            ans += diff
            if A[j+1] - diff > 0:
                A[j+1] -= diff
            else:
                A[j+1] = 0
    else:
        if A[j]> x:
            diff = A[j]-x
            ans += diff
print(ans)
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input().split()
n=int(s[0])
x=int(s[1])
s=input().split()
ans=max(0,int(s[0])+int(s[1])-x)
prev=max(0,int(s[1])-ans)
for i in range(2,len(s)):
 now=max(0,int(s[i])+prev-x)
 ans+=now
 prev=now
print(ans)

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

Expected output:
12


Actual output:
11


Fixed submission (verdict: Accepted):
s=input().split()
n=int(s[0])
x=int(s[1])
s=input().split()
ans=max(0,int(s[0])+int(s[1])-x)
prev=max(0,int(s[1])-ans)
for i in range(2,len(s)):
 now=max(0,int(s[i])+prev-x)
 ans+=now
 prev=int(s[i])-now
print(ans)

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

ans = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        ans += (A[i] + A[i+1] - x)
        A[i+1] -= max(A[i+1] - (A[i] + A[i+1] - x), A[i+1])

print(ans)

Failing test case input:
3 3
2 2 4

Expected output:
3


Actual output:
2


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

ans = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        ans += (A[i] + A[i+1] - x)
        A[i+1] = max((-A[i] + x), 0)

print(ans)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
cnt=0
if a[0]>x:
    cnt += a[0] - x
    a[0]=x 
for i in range(N-1):
    if a[i]+a[i+1]:
        cnt += a[i] + a[i+1] - x
        a[i+1]=x-a[i]
    
print(cnt)


Failing test case input:
5 9
6 2 4 2 5

Expected output:
0


Actual output:
-5


Fixed submission (verdict: Accepted):
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
cnt=0
if a[0]>x:
    cnt += a[0] - x
    a[0]=x 
for i in range(N-1):
    if a[i]+a[i+1] >x:
        cnt += a[i] + a[i+1] - x
        a[i+1]=x-a[i]
print(cnt)

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

ans=0

if A[0] > x:
    ans += A[0]-x
    A[0]=x

for i in range(N-1):
    if A[i]+A[i+1] > x:
        ans +=  A[i]+A[i-1] -x
        A[i+1] = x-A[i]

print(ans)

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

Expected output:
12


Actual output:
4


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

ans=0

if A[0] > x:
    ans += A[0]-x
    A[0]=x

for i in range(N-1):
    if A[i]+A[i+1] > x:
        ans +=  A[i]+A[i+1] -x
        A[i+1] = x-A[i]

print(ans)
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
a=list(map(int,input().split()))

ans=0
for i in range(n-1):
    left=a[i]
    right=a[i+1]
    if left+right<=x:
        continue
    eat=(left+right)-x
    ans+=eat
    a[i+1]=min(0, right-eat)
print(ans)


Failing test case input:
3 3
2 2 4

Expected output:
3


Actual output:
2


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

ans=0
for i in range(n-1):
    left=a[i]
    right=a[i+1]
    if left+right<=x:
        continue
    eat=(left+right)-x
    ans+=eat
    a[i+1]=max(0, right-eat)
print(ans)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
N,x = list(map(int,input().split(" ")))
l = list(map(int,input().split(" ")))
ans = 0
for i in range(0,N-1):
    j = i+1
    total = l[i]+l[j]
    right = l[j]
    left = l[i]
    diff = total - x
    if right > diff:
        l[j] -= diff
        ans += diff
    else:
        ans += right
        l[j] = 0
        diff -= right

        ans += diff
        l[j] -= diff

ans = max(0,ans)
print(ans)





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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import itertools
N,x = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))
ans = 0
for i in range(0,N-1):
    l = As[i]
    r = As[i+1]
    diff = max((r+l) - x,0)
    if diff >= r:
        ans += r

        diff -= r
        As[i + 1] = r = 0
        ans += diff

    else:
        r -= diff
        As[i + 1] = r
        ans += diff

print(ans)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for i in range(N-1):
    if a[i] + a[i+1] > x:
        if a[i] >= a[i+1]:
            tmp = x - a[i]
            count += a[i+1] - tmp
            a[i+1] = tmp
        else:
            tmp = x - a[i+1]
            count += a[i] - tmp
            a[i] = tmp

print(count)

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

Expected output:
12


Actual output:
16


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

count = 0
if a[0] > x:
    count = a[0] - x
    a[0] = x

for i in range(N-1):
    if a[i] + a[i+1] > x:
        tmp = x - a[i]
        count += a[i+1] - tmp
        a[i+1] = tmp

print(count)

Problem: p03862
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

for i in range(n - 1):
    ref = a[i] + a[i + 1]
    ans += max(ref - x, 0)
    a[i + 1] = max(a[i + 1] - abs(ref - x), 0)

print(ans)

Failing test case input:
5 5
5 1 4 1 5

Expected output:
2


Actual output:
1


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

for i in range(n - 1):
    ref = a[i] + a[i + 1]
    ans += max(ref - x, 0)
    if ref - x > 0:
        a[i + 1] = max(a[i + 1] - (ref - x), 0)

print(ans)
Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, x = map(int,input().split())
a = list(map(int,input().split()))
Nc = 0
if a[0] > x:
    a[0] = x
    Nc += a[0] - x

for i in range(N-1):
    if (a[i] + a[i+1] - x) > 0:
        Nc += a[i] + a[i+1] -x
        a[i+1] = x - a[i]

print(Nc)



Failing test case input:
2 0
1 10

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
N, x = map(int,input().split())
a = list(map(int,input().split()))
Nc = 0
if a[0] > x:
    Nc += a[0] - x
    a[0] = x
for i in range(N-1):
    if (a[i] + a[i+1] - x) > 0:
        Nc += a[i] + a[i+1] -x
        a[i+1] = x - a[i]

print(Nc)

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        count += a[i] + a[i + 1] - x
        if a[i + 1] >= x:
            a[i + 1] = x - a[i]
        else:
            a[i + 1] = 0
            a[i] = x
print(int(count))


Failing test case input:
3 3
2 2 4

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        count += a[i] + a[i + 1] - x
        if a[i + 1] >= a[i] + a[i + 1] - x:
            a[i + 1] = x - a[i]
        else:
            a[i + 1] = 0
            a[i] = x
print(int(count))

Problem: p03862
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    s = a[i] + a[i+1]
    if i % 2 == 0:
        if s > x:
            minus = s - x
            if a[i+1] >= minus:
                a[i+1] -= minus
                cnt += minus
            else:
                a[i+1] = 0
                a[i] -= minus - a[i+1]
                cnt += minus
print(cnt)

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
for i in range(1, n):
    s = a[i-1] + a[i]
    
    if s > x:
        minus = s - x
        if a[i] >= minus:
            a[i] -= minus
            cnt += minus
        else:
            a[i] = 0
            a[i-1] -= minus - a[i]
            cnt += minus
print(cnt)