ZhenlongDai/ACPR huggingface dataset:
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
print(a - b < a)

Failing test case input:
155 0

Expected output:
154


Actual output:
False


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
  a, b = map(int, input().split())
  if a >= b:
    print(a)
  elif a < b:
    print(b)

Failing test case input:
63 011

Expected output:
62


Actual output:
63


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    a, b = map(int, input().split())
    if a > b:
        print(a-1)
    elif a <= b:
        print(a)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if a <= b:
    print(a)
else:
    print(min(a,b))

Failing test case input:
39 -1

Expected output:
38


Actual output:
-1


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if a>=b:
  print(a)
else:
  print(a-1)

Failing test case input:
315 3

Expected output:
314


Actual output:
315


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = (int(_) for _ in input().split())  

if a >= b:
  print(a)
else:
  print(a-1)



Failing test case input:
51 -1

Expected output:
50


Actual output:
51


Fixed submission (verdict: Accepted):
a, b = (int(_) for _ in input().split())  

if a <= b:
  print(a)
else:
  print(a-1)

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

if a > b + 1:
    print(a)
else:
    print(a + 1)

Failing test case input:
39 -1

Expected output:
38


Actual output:
39


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

if a > b:
    print(a - 1)
else:
    print(a)

Problem: p03359
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b = map(int,input().split())
if a==1 and b==1:
  print(1)
else:
  print(min(a,b))


Failing test case input:
121 0

Expected output:
120


Actual output:
0


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

Problem: p03359
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b = map(int,input().split())
ans = a
if b < 5:
    ans -= 1
print(ans)

Failing test case input:
-212 0

Expected output:
-212


Actual output:
-213


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

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

print(min(a, b))


Failing test case input:
33 010

Expected output:
32


Actual output:
10


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

print(a-1 + int(b >= a))
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

if a >= b:
    print(a)

else:
    print(a - 1)


Failing test case input:
91 -1

Expected output:
90


Actual output:
91


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

if a <= b:
    print(a)

else:
    print(a - 1)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if max(a,b) <= 12:
    print(min(a,b))
else:
    print(a)

Failing test case input:
34 011

Expected output:
33


Actual output:
34


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if a >= b:
    print(a)
else:
    print(a-1)

Failing test case input:
-55 5

Expected output:
-55


Actual output:
-56


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

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

print(a - (a < b))

Failing test case input:
121 0

Expected output:
120


Actual output:
121


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

print(a - (a > b))

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

if b>=12:
    print(a)
elif a>=b:
    print(b)
else:
    print(a)

Failing test case input:
215 0

Expected output:
214


Actual output:
0


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

if a<=b:
    print(a)
else:
    print(a-1)

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

Failing test case input:
33 010

Expected output:
32


Actual output:
a-1


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int,input().split())
if a > b:
	print(a)
else:
	print(a + 1)


Failing test case input:
39 -1

Expected output:
38


Actual output:
39


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def resolve():
    a,b=map(int, input().split())
    if b<5:
        print(a-1)
    else:
        print(a)
resolve()


Failing test case input:
63 011

Expected output:
62


Actual output:
63


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split());print(a+(a>=b))

Failing test case input:
155 0

Expected output:
154


Actual output:
156


Fixed submission (verdict: Accepted):
a,b=map(int,input().split());print(a-(a>b))
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    if a<b:
        print(a)
    else:
        print(b)


solve()


Failing test case input:
110 1

Expected output:
109


Actual output:
1


Fixed submission (verdict: Accepted):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    if a<=b:
        print(a)
    else:
        print(a-1)


solve()

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
ans = a
if b <= a:
    ans += 1
print(ans)


Failing test case input:
237 0

Expected output:
236


Actual output:
238


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
ans = a
if a > b:
    ans -= 1
print(ans)

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

print(a if a<= b else b)

Failing test case input:
33 010

Expected output:
32


Actual output:
10


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

print(a if a<= b else a-1)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if a >= b:
  print(a)
else:
  print(a-1)

Failing test case input:
29 -16

Expected output:
28


Actual output:
29


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if a <= b: 
 	print(a)
else:
 	print(b)

Failing test case input:
78 2

Expected output:
77


Actual output:
2


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
goop=input().split()
if int(goop[0])<int(goop[1]):
    print(int(goop[0])-1)
else:
    print(int(goop[0]))


Failing test case input:
65 110

Expected output:
65


Actual output:
64


Fixed submission (verdict: Accepted):
goop=input().split()
if int(goop[0])<=int(goop[1]):
    print(int(goop[0]))
else:
    print(int(goop[0])-1)

Problem: p03359
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b = map(int,input().split())
mn = min(a,b)
ans = min(mn,12)
print(ans)

Failing test case input:
146 -1

Expected output:
145


Actual output:
-1


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
ans = a-1
if a<=b:
    ans += 1
print(ans)

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

if __name__ == "__main__":
    a, b = list(map(int, input().split()))
    ans = a - 1
    if a == b:
        ans += 1
    print(ans)


Failing test case input:
-55 5

Expected output:
-55


Actual output:
-56


Fixed submission (verdict: Accepted):

if __name__ == "__main__":
    a, b = list(map(int, input().split()))
    ans = a - 1
    if a <= b:
        ans += 1
    print(ans)
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = list(map(int, input().split()))
print(min(a, b))

Failing test case input:
29 -16

Expected output:
28


Actual output:
-16


Fixed submission (verdict: Accepted):
a, b = list(map(int, input().split()))
print(a if b >= a else a-1)

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

if b<a:
  print(b)
else:
  print(a)


Failing test case input:
34 011

Expected output:
33


Actual output:
11


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

if b<a:
  print(a-1)
else:
  print(a)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print(a-b if a <= b else a-1)


Failing test case input:
45 111

Expected output:
45


Actual output:
-66


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

if b < a:
    a -= 1
print(a)

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

print(a - 1 + (a == b))

Failing test case input:
-18 766

Expected output:
-18


Actual output:
-19


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

print(a - (a > b))

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if a < b: print(a - 1)
else: print(a)

Failing test case input:
-26 0

Expected output:
-26


Actual output:
-27


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print(a if a>=b else a-1)

Failing test case input:
44 -1

Expected output:
43


Actual output:
44


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

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


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

if a >= b:
    print(b)
else:
    print(a)


Failing test case input:
237 0

Expected output:
236


Actual output:
0


Fixed submission (verdict: Accepted):


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

if a <= b:
    print(a)
else:
    print(a-1)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print(a if a>=b else a-1)

Failing test case input:
34 011

Expected output:
33


Actual output:
34


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

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

if a < b:
  print(a-1)
else:
  print(a)

Failing test case input:
85 -3

Expected output:
84


Actual output:
85


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

if a > b:
  print(a-1)
else:
  print(a)
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = list(map(int, input().split()))
if b - a < 0 :
  print(b - 1)
else :
  print(b)

Failing test case input:
44 -1

Expected output:
43


Actual output:
-2


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

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

import sys



def solve(lines):
    A,B = map(int, lines.pop(0).split(' '))
    if A < B:
        print(A)
    else:
        print(B)



lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Failing test case input:
34 011

Expected output:
33


Actual output:
11


Fixed submission (verdict: Accepted):

import sys



def solve(lines):
    A,B = map(int, lines.pop(0).split(' '))
    if A <= B:
        print(A)
    else:
        print(A-1)



lines = [x.strip() for x in sys.stdin.readlines()]

 

solve(lines)

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

Failing test case input:
44 -1

Expected output:
43


Actual output:
-1


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if a<b:
    print(a)
elif a>=b:
    print(b)

Failing test case input:
63 011

Expected output:
62


Actual output:
11


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
if a<=b:
    print(a)
elif a>b:
    print(a-1)

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

if a <= b:
    print(a)
else:
    print(b)


Failing test case input:
36 -1

Expected output:
35


Actual output:
-1


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

if a <= b:
    print(a)
else:
    print(a-1)

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

Failing test case input:
-212 0

Expected output:
-212


Actual output:
a


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

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

if a<=b:
        print(a)
else:
        print(a-b)

Failing test case input:
315 3

Expected output:
314


Actual output:
312


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

if a<=b:
        print(a)
else:
        print(a-1)

Problem: p03359
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
a, b = map(int,input().split())
if a <= b:
    print(a)
else:
    print(b)

Failing test case input:
315 3

Expected output:
314


Actual output:
3


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
a, b = map(int,input().split())
if a <= b:
    print(a)
else:
    print(a-1)
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print(a if a >= b else a-1)


Failing test case input:
43 2

Expected output:
42


Actual output:
43


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

if b < a:
    a -= 1
print(a)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = list(map(int, input().split()))
print(a if a >= b else a-1)

Failing test case input:
43 2

Expected output:
42


Actual output:
43


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

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

print(min(a, b))

Failing test case input:
78 2

Expected output:
77


Actual output:
2


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

print(a if a <= b else a-1)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=list(map(int,input().split()))
if a<=b:
	print(a)
else:
	print(b)

Failing test case input:
110 1

Expected output:
109


Actual output:
1


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if a == 1 and b == 1:
    print(0)
else:
    print(min(a, b))

Failing test case input:
172 3

Expected output:
171


Actual output:
3


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

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

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

Failing test case input:
121 0

Expected output:
120


Actual output:
121


Fixed submission (verdict: Accepted):

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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int,input().split())
if a <= b:
    print(a)
else:
    print(b)

Failing test case input:
36 -1

Expected output:
35


Actual output:
-1


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = (int(_) for _ in input().split())

if a>b:
    print(a-1)
else:
    print(b)


Failing test case input:
-99 0

Expected output:
-99


Actual output:
0


Fixed submission (verdict: Accepted):
a,b = (int(_) for _ in input().split())

if a>b:
    print(a-1)
else:
    print(a)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a >= b:
    print(b)
else:
    print(a)

Failing test case input:
37 -1

Expected output:
36


Actual output:
-1


Fixed submission (verdict: Accepted):
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a > b:
    print(a-1)
else:
    print(a)
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    print(min(a,b))


solve()


Failing test case input:
215 0

Expected output:
214


Actual output:
0


Fixed submission (verdict: Accepted):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    if a<=b:
        print(a)
    else:
        print(a-1)


solve()

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




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


if __name__ == "__main__":
    main()


Failing test case input:
315 3

Expected output:
314


Actual output:
3


Fixed submission (verdict: Accepted):




def main():
    A, B = map(int, input().split())
    print(A if A <= B else A - 1)


if __name__ == "__main__":
    main()

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
result = a
if a > b:
    result = b
print(result)

Failing test case input:
91 -1

Expected output:
90


Actual output:
-1


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
result = a
if a > b:
    result -= 1
print(result)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if a < b:
  print(a)
else:
  print(b)

Failing test case input:
43 2

Expected output:
42


Actual output:
2


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

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b =map(int, input().split())
print(a if a>b else a+1)

Failing test case input:
49 -3

Expected output:
48


Actual output:
49


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

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

Failing test case input:
44 -1

Expected output:
43


Actual output:
-1


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

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

if b <= a:
    print(a)
else: 
    print(a-1)

Failing test case input:
65 110

Expected output:
65


Actual output:
64


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

count=0
if a <= b:
    print(a)
else:
    print(a-1)

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

Failing test case input:
44 -1

Expected output:
43


Actual output:
-1


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
if a==b:
	print(b)
elif b<a:
	print(a-1)
else:
	print(a)
Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
if a>b:
    print(b)
else:
    print(a)

Failing test case input:
172 3

Expected output:
171


Actual output:
3


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

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

if a<=b:
    t=a
else:
    t=b-1
print(t)


Failing test case input:
78 2

Expected output:
77


Actual output:
1


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

if a<=b:
    t=a
else:
    t=a-1
print(t)

Problem: p03359
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
if a<b:
    print(a)
else:
    print(b)

Failing test case input:
172 3

Expected output:
171


Actual output:
3


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
if a<=b:
    print(a)
else:
  	print(a-1)
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    l = rp - i
    if l >= rv and (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)


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

Expected output:
8

Actual output:
7


Fixed submission (verdict: Accepted):

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    if a[i] + m < a[rp]:
        continue
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m,v,p = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)

sm = sum(a[:n-p+1])

for k in range(n-p):
    sm -= a[k]
    if (n-p-k)*(a[k]+m) - sm <= (v-k-p)*m:
        continue
    else:
        print(n-k)
        exit()

print(p)

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

Expected output:
5


Actual output:
4


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

a = sorted(a)

sm = sum(a[:n-p+1])

for k in range(n-p+1):
    sm -= a[k]
    if a[k]+m < a[n-p]:
        continue
    elif (n-p-k)*(a[k]+m) - sm +(p+k)*m < v*m:
        continue
    else:
        print(n-k)
        exit()

Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():

    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse = True)

    ans = P
    for i in range(P, N):
        v = P * M + (N-1-i-1+1) * M
        for j in range(P, i):
            v += min(A[i] + M - A[j], M)
        if v >= M * V:
            ans += 1
    return ans

if __name__ == '__main__':
    print(main())


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

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):
import bisect
def main():

    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    prefix = [0]
    for i in range(N):
        prefix.append(prefix[-1] + A[i])

    ans = P
    for i in range(N-P):
        if A[i] + M >= A[N-P]:
            v = i * M + P * M
            v += (A[i] + M) * (N-P-i)
            v -= prefix[N-P+1] - prefix[i+1]
            if v >= M * V:
                ans += 1

    return ans

if __name__ == '__main__':
    print(main())
Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M, V, P = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)


ans = P
S = A[P-1]
for i in range(P, N):
    if A[i]+M >= A[P-1] and V <= P-1+N-i:
        ans += 1
    else:
        if S+M*(V-(P-1)-(N-i)) <= (A[i]+M)*(i-(P-1)):
            ans += 1
    S += A[i]
print(ans)


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

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
N, M, V, P = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)


ans = P
S = A[P-1]
for i in range(P, N):
    if A[i]+M < A[P-1]:
        continue
    if V <= P-1+N-i:
        if A[i]+M >= A[P-1]:
            ans += 1
    else:
        if S+M*(V-P+1-N+i) <= (A[i]+M)*(i-(P-1)):
            ans += 1
    S += A[i]
print(ans)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif M*(V-((P-1)+(N-i)))+dif<=(B[i]+M)*(i-P+1):
        count+=1
print(count)

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

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V) and B[P-1]<=B[i]+M:
        count+=1
print(count)

Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = p
c = [0]
cnt = 0
for i in range(n):
  
  cnt += a[i]
  c.append(cnt)
for i in range(p,n):
  h = a[i]+m
  free = v - (p-1) - (n-i)
  d = h * (i-p+1) - (c[i]-c[p-1]) 
  if d >= free*m:
    ans += 1
print(ans)

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

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = p
c = [0]
cnt = 0
for i in range(n):
  
  cnt += a[i]
  c.append(cnt)
  
from bisect import bisect_right
for i in range(p,n):
  h = a[i]+m
  free = v - (p-1) - (n-i)
  if free >= 0 and h >= a[p-1]:
    d = h * (i-p+1) - (c[i]-c[p-1]) 
    if d >= free*m:
      ans += 1
  else:
    if h >= a[p-1]:
      ans += 1
print(ans)
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():

    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse = True)

    ans = 0
    for i in range(N):
        v = P * M + (N-1-i-1+1) * M
        for j in range(P, i):
            v += A[i] + M - A[j]
        if v >= M * V:
            ans += 1
    return ans
    
if __name__ == '__main__':
    print(main())


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

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
import bisect
def main():

    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    prefix = [0]
    for i in range(N):
        prefix.append(prefix[-1] + A[i])

    ans = P
    for i in range(N-P):
        if A[i] + M >= A[N-P]:
            v = i * M + P * M
            v += (A[i] + M) * (N-P-i)
            v -= prefix[N-P+1] - prefix[i+1]
            if v >= M * V:
                ans += 1

    return ans

if __name__ == '__main__':
    print(main())

Problem: p02824
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def is_ok(index):
  s=0
  for i in range(p,index):
    s+=a[index]+m-a[i]
  return s+m*(n-index+p-1)>=m*v and a[index]+m>=a[p]
def binary_search(a):
  ok=-1
  ng=len(a)
  while abs(ng-ok)>1:
    mid=(ng+ok)
    if is_ok(mid):ok=mid
    else:ng=mid
  return ng
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
print(binary_search(a))

Failing test case input:
10 4 8 5
4 2 3 6 1 6 5 4 6 14

Expected output:
9


Actual output:
8


Fixed submission (verdict: Accepted):
def is_ok(index):
  s=0
  for i in range(p-1,index):
    s+=a[index]+m-a[i]
  return s+m*(n-index+p-1)>=m*v and a[index]+m>=a[p-1]
def binary_search(a):
  ok=-1
  ng=len(a)
  while abs(ng-ok)>1:
    mid=(ng+ok)
    if is_ok(mid):ok=mid
    else:ng=mid
  return ok+1
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
print(binary_search(a))

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

higher = a[p-1]
for i in range(p,n):
    if(a[i] == a[i-1]):
        higher += a[i]
        continue

    if(a[p-1]- a[i] > v):
        print(i)
        exit()

    if(higher - a[i]*(i-p+1) > min(n-v,i-p+1)*m):
        print(i)
        exit()

    higher += a[i]

print(n)

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

Expected output:
9


Actual output:
10


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

a.sort(reverse=True)

higher = a[p-1]
for i in range(p,n):
    if(a[i] == a[i-1]):
        higher += a[i]
        continue

    if(a[p-1]- a[i] > m):
        print(i)
        exit()

    if(higher - a[i]*(i-p+1) > min(n-v,i-p+1)*m):
        print(i)
        exit()

    higher += a[i]

print(n)
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + max(0, l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)


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

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    if a[i] + m < a[rp]:
        continue
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m,v,p = map(int, input().split())
al = list(map(int, input().split()))
al.sort(reverse=True)

def check(x):
    if x<p:
        return True

    s = 0
    for i in range(n):
        if i<p-1:
            s += m
        elif p-1<=i<x:
            s += al[x]+m-al[i]
        else:
            s += m
    return s>=m*v

ok = -1
ng = n
while ng-ok>1:
    mid = (ok+ng)
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok+1)

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

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n,m,v,p = map(int, input().split())
al = list(map(int, input().split()))
al.sort(reverse=True)

def check(x):
    if x<p:
        return True
    if al[p-1]>al[x]+m:
        return False

    s = 0
    for i in range(n):
        if i<p-1:
            s += m
        elif p-1<=i<x:
            s += al[x]+m-al[i]
        else:
            s += m
    return s>=m*v

ok = -1
ng = n
while ng-ok>1:
    mid = (ok+ng)
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok+1)

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

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = 0
rv = n - v
rp = n - p
for i in range(n):
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)


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

Expected output:
10


Actual output:
8


Fixed submission (verdict: Accepted):

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    if a[i] + m < a[rp]:
        continue
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
pre_num=1
dsum=0
for i in range(P,N):
    rest_m=M*(N-V)
    p=A[i]
    dsum+=(A[i-1]-p)*pre_num
    pre_num+=1
    rest_m-=dsum
    if rest_m<0:break
    ans+=1
print(P+ans)

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

Expected output:
7


Actual output:
9


Fixed submission (verdict: Accepted):
N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
pre_num=1
dsum=0
th=A[P-1]
for i in range(P,N):
    rest_m=M*(N-V)
    p=A[i]
    if th-p>M:break
    dsum+=(A[i-1]-p)*pre_num
    pre_num+=1
    rest_m-=dsum
    if rest_m<0:break
    ans+=1
print(P+ans)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)

higher = a[p-1]
for i in range(p,n):
    if(a[i] == a[p-1]):
        higher += a[i]
        continue

    if(a[p-1]- a[i] > v):
        print(i)
        exit()

    if(higher - a[i]*(i-p+1) > min(n-v,p-1)*m):
        print(i)
        exit()

    higher += a[i]

print(n)

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

Expected output:
9


Actual output:
5


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

a.sort(reverse=True)

higher = a[p-1]
for i in range(p,n):
    if(a[i] == a[i-1]):
        higher += a[i]
        continue

    if(a[p-1]- a[i] > m):
        print(i)
        exit()

    if(higher - a[i]*(i-p+1) > min(n-v,i-p+1)*m):
        print(i)
        exit()

    higher += a[i]

print(n)

Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

ok = -1
ng = N


V = N - V
def isOk(n):
    b = A[n]
    cnt = [max(0, a - b) for a in A]
    cnt = cnt[P - 1:]
    return max(max(cnt), sum(cnt)) <= M * V

while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(max(P, ng))

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

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
W = N - V

def isOk(n):
    if n < P:
        return True
    b = A[n]

    D = [max(0, a - b) for a in A][P - 1:]
    cnt = -(-(sum(D) - W) 

    return max(max(D), cnt) <= M

ok = -1
ng = N
while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ng)
Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V):
        count+=1
print(count)

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

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V) and B[P-1]<=B[i]+M:
        count+=1
print(count)

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

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)


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

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):

from itertools import accumulate

n, m, v, p = map(int, input().split())
a = sorted(map(int, input().split()))
cs = [0] + list(accumulate(a))
ans = p
rv = n - v
rp = n - p
for i in range(rp):
    if a[i] + m < a[rp]:
        continue
    l = rp - i
    if (cs[rp + 1] - cs[i + 1]) + (l - rv) * m <= (a[i] + m) * l:
        ans += 1
print(ans)

Problem: p02824
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def is_ok(index):
  s=0
  for i in range(p,index):
    s+=a[index]+m-a[i]
  return s+m*(n-index+p-1)>=m*v and a[index]+m>=a[p]
def binary_search(a):
  ok=-1
  ng=len(a)
  while abs(ng-ok)>1:
    mid=(ng+ok)
    if is_ok(mid):ok=mid
    else:ng=mid
  return ok+1
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
print(binary_search(a))

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

Expected output:
10


Actual output:
9


Fixed submission (verdict: Accepted):
def is_ok(index):
  s=0
  for i in range(p-1,index):
    s+=a[index]+m-a[i]
  return s+m*(n-index+p-1)>=m*v and a[index]+m>=a[p-1]
def binary_search(a):
  ok=-1
  ng=len(a)
  while abs(ng-ok)>1:
    mid=(ng+ok)
    if is_ok(mid):ok=mid
    else:ng=mid
  return ok+1
n,m,v,p=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
print(binary_search(a))
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))

ok = max(A)
ng = -1

def isOk(n):
    cnt = [max(0, a - n) for a in A]
    return sum(sorted(cnt, reverse=True)[P - 1:]) <= (N - V) * M

while ok - ng > 1:
    mid = (ok + ng) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

ans = sum([a >= ok for a in A])
print(ans)

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

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
W = N - V

def isOk(n):
    if n < P:
        return True
    b = A[n]

    D = [max(0, a - b) for a in A][P - 1:]
    cnt = -(-(sum(D) - W) 

    return max(max(D), cnt) <= M

ok = -1
ng = N
while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ng)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif=+B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif M*(V-((P-1)+(N-i)))+dif<=(B[i]+M)*(i-P+1):
        count+=1
print(count)

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

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V) and B[P-1]<=B[i]+M:
        count+=1
print(count)

Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

ok = -1
ng = N


V = N - V
def isOk(n):
    b = A[n]
    cnt = [max(0, a - b) for a in A]
    cnt = cnt[P - 1:]
    return sum(cnt) <= M * V

while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(max(P, ng))

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

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
W = N - V

def isOk(n):
    if n < P:
        return True
    b = A[n]

    D = [max(0, a - b) for a in A][P - 1:]
    cnt = -(-(sum(D) - W) 

    return max(max(D), cnt) <= M

ok = -1
ng = N
while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ng)
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

ok = -1
ng = N


V = N - V
def isOk(n):
    b = A[n]
    cnt = [max(0, a - b) for a in A]
    cnt = cnt[P:]
    return sum(cnt) <= M * V

while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(max(P, ng))

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

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
W = N - V

def isOk(n):
    if n < P:
        return True
    b = A[n]

    D = [max(0, a - b) for a in A][P - 1:]
    cnt = -(-(sum(D) - W) 

    return max(max(D), cnt) <= M

ok = -1
ng = N
while ng - ok > 1:
    mid = (ng + ok) 
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ng)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)[::-1]

minp = a[p-1]
result = 0
td = 0
count = 1
for i in range(p, n):
    if m * (n-v) >= (minp - a[i]) * count - td :
        result+=1
        count+=1
        td+= minp - a[i]
    else:
        break
print(result+p)

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

Expected output:
1


Actual output:
2


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

a = sorted(a)[::-1]

minp = a[p-1]
result = 0
td = 0
count = 0
tpcount = 1
tptd = 0
pre = minp
for i in range(p, n):
    if pre != a[i]:
        td += tptd
        count += tpcount
        tptd = 0
        tpcount = 0
    if m * min(n-v, count) >= (minp - a[i]) * count - td and minp <= a[i] + m:
        result+=1
        tpcount+=1
        tptd+= minp - a[i]
        pre = a[i]
    else:
        break
print(result+p)

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())))
if p >= v:
  print(sum([1 for b in a if b >= a[n-p]-m]))
else:
  s = p
  for i in range(n-p+1):
    if a[i] >= a[n-p]-m:
      if sum([max(a[i]+m-a[j],0) for j in range(i+1,n-p+1)]) >= (v-p-i+1)*m:
        s += 1
  print(s)

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

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())))
if p >= v:
  print(sum([1 for b in a if b+m >= a[n-p]]))
else:
  s = p-1
  t = sum(a[:(n-p+1)])
  for i in range(n-p+1):
    t -= a[i]
    if a[i]+m >= a[n-p] and (a[i]+m)*(n-p-i) - t >= (v-p-i)*m:
      s += 1
  print(s)
Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m,v,p = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
ans = 0
trash = 0
print(lis)
for i in range(n):
    if i+1 <= p:
        ans += 1
    else:
        if lis[i] + m >= lis[p-1]:
            if (lis[i]+m)*(i-(p-1))-trash >= m * (v-(p-1)-(n-i)):
  
                ans += 1
    if i+1 >= p:
        trash += lis[i]
print(ans)


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

Expected output:
10


Actual output:
[7, 7, 6, 6, 5, 4, 3, 3, 2, 1]
10


Fixed submission (verdict: Accepted):
n,m,v,p = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
ans = 0
trash = 0
for i in range(n):
    if i+1 <= p:
        ans += 1
    else:
        if lis[i] + m >= lis[p-1]:
            if (lis[i]+m)*(i-(p-1))-trash >= m * (v-(p-1)-(n-i)):
  
                ans += 1
    if i+1 >= p:
        trash += lis[i]
print(ans)

Problem: p02824
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():

    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse = True)

    ans = 0
    for i in range(N):
        v = P * M + (N-1-i-1+1) * M
        for j in range(P, i):
            v += min(A[i] + M - A[j], M)
        if v >= M * V:
            ans += 1
    return ans

if __name__ == '__main__':
    print(main())


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

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
import bisect
def main():

    N, M, V, P = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    prefix = [0]
    for i in range(N):
        prefix.append(prefix[-1] + A[i])

    ans = P
    for i in range(N-P):
        if A[i] + M >= A[N-P]:
            v = i * M + P * M
            v += (A[i] + M) * (N-P-i)
            v -= prefix[N-P+1] - prefix[i+1]
            if v >= M * V:
                ans += 1

    return ans

if __name__ == '__main__':
    print(main())

Problem: p02824
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(A, reverse=True)
count=P
for i in range(P,N):
    dif=sum(B[P-1:i])
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif M*(V-((P-1)+(N-i)))+dif<=(B[i]+M)*(i-P+1):
        count+=1
    else:
      break
print(count)

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

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):
N,M,V,P=map(int,input().split())
B = sorted(list(map(int, input().split())))[::-1]
count=P
dif=0
for i in range(P,N):
    dif+=B[i-1]
    if V<=(P-1)+(N-i) and B[P-1]<=B[i]+M:
        count+=1
    elif dif-B[i]*(i-P+1)<=M*(N-V) and B[P-1]<=B[i]+M:
        count+=1
print(count)