Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
โŒ€
fixed_code
stringlengths
12
526k
โŒ€
labels
listlengths
0
15
โŒ€
buggy_submission_id
int64
1
1.54M
โŒ€
fixed_submission_id
int64
2
1.54M
โŒ€
user_id
stringlengths
10
10
โŒ€
language
stringclasses
9 values
p02823
N,A,B=map(int,input().split()) C=A+B if C%2==0: print(C//2) else: dist_a=A-1 dist_b=N-B base=min(dist_a,dist_b) print(base+(B-A+1)//2)
N,A,B=map(int,input().split()) C=B-A if C%2==0: print(C//2) else: dist_a=A-1 dist_b=N-B base=min(dist_a,dist_b) print(base+(B-A+1)//2)
[ "expression.operation.binary.remove" ]
628,114
628,115
u089142196
python
p02823
N , A, B = map(int, input().split()) if (B-A)%2 == 0: ans = (B-A)//2 else: if A-1<N-B: ans = N-B+(B-A)//2 else: ans = A-1+(B-A)//2 print(ans)
N , A, B = map(int, input().split()) if (B-A)%2 == 0: ans = (B-A)//2 else: if A-1>N-B: ans = N-B+(B-A)//2+1 else: ans = A-1+(B-A)//2+1 print(ans)
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
628,143
628,144
u310678820
python
p02823
import sys readline = sys.stdin.readline N, A, B = map(int, readline().split()) ans = None if (B - A) % 2 == 0: ans = (B-A)//2 else: ans = A + (B - A - 1)//2 ans = min(ans, N-B+1 + (A+N-B+1)//2) print(ans)
import sys readline = sys.stdin.readline N, A, B = map(int, readline().split()) ans = None if (B - A) % 2 == 0: ans = (B-A)//2 else: ans = A + (B - A - 1)//2 ans = min(ans, N-B+1 + (-A+B-1)//2) print(ans)
[ "expression.operation.unary.add", "call.arguments.change", "expression.operation.binary.remove", "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
628,147
628,148
u368780724
python
p02823
import sys readline = sys.stdin.readline N, A, B = map(int, readline().split()) ans = None if (B - A) % 2 == 0: ans = (B-A)//2 else: ans = A + (B - A - 1)//2 ans = min(ans, N-B + (A+N-B+1)//2) print(ans)
import sys readline = sys.stdin.readline N, A, B = map(int, readline().split()) ans = None if (B - A) % 2 == 0: ans = (B-A)//2 else: ans = A + (B - A - 1)//2 ans = min(ans, N-B+1 + (-A+B-1)//2) print(ans)
[ "expression.operation.unary.add", "call.arguments.change", "expression.operation.binary.remove", "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
628,149
628,148
u368780724
python
p02823
n, a, b = map(int, input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) exit() print(min(a+(b-(a+1))//2, n-b+(b-a-1)//2))
n, a, b = map(int, input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) exit() print(min(a+(b-(a+1))//2, n-b+1+(b-a-1)//2))
[ "expression.operation.binary.add" ]
628,152
628,153
u594518120
python
p02823
n, a, b = map(int, input().split()) a, b = min(a,b), max(a,b) if (b-a) % 2 == 0: print(b-a//2) exit(0) d = min(a - 1, n - b) print(d + 1 + (b-a-1)//2)
n, a, b = map(int, input().split()) a, b = min(a,b), max(a,b) if (b-a) % 2 == 0: print((b-a)//2) exit(0) d = min(a - 1, n - b) print(d + 1 + (b-a-1)//2)
[ "call.arguments.change" ]
628,178
628,179
u086980944
python
p02823
n, a, b = map(int, input().split()) a, b = min(a,b), max(a,b) if (b-a) % 2 == 0: print(b-a//2) exit(0) d = min(a - 1, n - a) print(d + 1 + (b-a-1)//2)
n, a, b = map(int, input().split()) a, b = min(a,b), max(a,b) if (b-a) % 2 == 0: print((b-a)//2) exit(0) d = min(a - 1, n - b) print(d + 1 + (b-a-1)//2)
[ "call.arguments.change", "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,180
628,179
u086980944
python
p02823
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b+1 mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-a ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b+1 mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-b+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,189
628,190
u321035578
python
p02823
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b+1 mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-a+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b+1 mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-b+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,191
628,190
u321035578
python
p02823
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a -1 tempL=a+n-b mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-a+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b+1 mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-b+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
[ "expression.operation.binary.remove", "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,192
628,190
u321035578
python
p02823
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-a+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
def main(): n,a,b=map(int,input().split()) if abs(a-b) % 2 == 0: print(abs(a-b)//2) return left=0 temp = max(a,b) left = temp - 1 right = 0 temp = min(a,b) right = n - temp ans = min(left,right) tempR=b-a mid1=10**19 if tempR-1>0: mid1=(tempR-1)//2 + a tempL=a+n-b+1 mid2=10**19 if n-tempL > 0: mid2=(n-tempL)//2 + n-b+1 ans = min(ans,mid1,mid2) print(ans) return if __name__=='__main__': main()
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,193
628,190
u321035578
python
p02823
N, A, B = map(int, input().split()) cnt = 0 if (B - A) % 2: if A - 1 <= N - B: cnt = A A = 1 B -= A else: cnt = N - B + 1 A += N - B + 1 B = N print(cnt + (B - A) // 2)
N, A, B = map(int, input().split()) cnt = 0 if (B - A) % 2: if A - 1 <= N - B: cnt = A B -= A A = 1 else: cnt = N - B + 1 A += N - B + 1 B = N print(cnt + (B - A) // 2)
[ "assignment.remove", "assignment.add" ]
628,209
628,210
u415905784
python
p02823
n, a, b =map(int, input().split()) if (a - b) % 2 == 0: print(abs(a - b) // 2) else: if a > b: a, b = b, a if n - b > a - 1: print((2 * a + b - 3) // 2) else: print((2 * n - b - a + 1) // 2)
n, a, b =map(int, input().split()) if (a - b) % 2 == 0: print(abs(a - b) // 2) else: if a > b: a, b = b, a if n - b > a - 1: print((a + b - 1) // 2) else: print((2 * n - b - a + 1) // 2)
[ "expression.operation.binary.remove", "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
628,223
628,224
u079427319
python
p02823
n, a, b = map(int, input().split()) if (b-a)%2 == 0: print((b-a)//2) else: if (a+b) > n: print(((n-a)+(n-b)-1)//2) else: print((a+b-1)//2)
n, a, b = map(int, input().split()) if (b-a)%2 == 0: print((b-a)//2) else: if (a+b) > n: print(((n-a)+(n-b)+1)//2) else: print((a+b-1)//2)
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
628,236
628,237
u080364835
python
p02823
n, a, b = map(int, input().split()) a -= 1; b -= 1 if (b-a) % 2 == 0: print((b-a) // 2) else: a = min(a, n-1-b) print(a + 1 + (b-a-1) // 2)
n, a, b = map(int, input().split()) a -= 1; b -= 1 if (b-a) % 2 == 0: print((b-a) // 2) else: x = min(a, n-1-b) print(x + 1 + (b-a-1) // 2)
[ "assignment.variable.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
628,238
628,239
u193182854
python
p02823
N, A, B = map(int, input().split()) if A % 2 == B % 2: print((B - A) // 2) else: print(min(A + (B - A + 1) // 2, B - 1, N - A, N - B + 1 + (B - A + 1) // 2))
N, A, B = map(int, input().split()) if A % 2 == B % 2: print((B - A) // 2) else: print(min(A - 1 + (B - A + 1) // 2, B - 1, N - A, N - B + (B - A + 1) // 2))
[ "expression.operation.binary.remove" ]
628,246
628,247
u984276646
python
p02823
n,a0,b0 = map(int,input().split()) a = min(a0,b0) b = max(a0,b0) ans = 0 if abs(a-b) % 2 == 0: ans = abs(a-b)//2 else: if (a-1) < (n-b): ans = (a-1)+(b-a+1)//2 else: ans = (n-b)+(b-a)//2 print(ans)
import math n,a0,b0 = map(int,input().split()) a = min(a0,b0) b = max(a0,b0) ans = 0 if abs(a-b) % 2 == 0: ans = abs(a-b)//2 else: if (a-1) < (n-b): ans = (a-1)+(b-a+2)//2 else: ans = (n-b)+(b-a+1)//2 print(ans)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
628,254
628,255
u738898077
python
p02823
#!/usr/bin/env python3 import sys def solve(N: int, A: int, B: int): if (B-A)%2 == 0: between = (B-A)//2 print(between) else: #็ซฏใงใ—ใ‹ไผšใˆใชใ„ answer = 0 if A-1<=N-B: answer += A A = 1 B -= A answer += (B-A)//2 else: answer += N-B+1 A += N-B+1 B = N answer += (B-A)//2 print(answer) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int A = int(next(tokens)) # type: int B = int(next(tokens)) # type: int solve(N, A, B) if __name__ == '__main__': main()
#!/usr/bin/env python3 import sys def solve(N: int, A: int, B: int): if (B-A)%2 == 0: between = (B-A)//2 print(between) else: #็ซฏใงใ—ใ‹ไผšใˆใชใ„ answer = 0 if A-1<=N-B: answer += A B -= A A = 1 answer += (B-A)//2 else: answer += N-B+1 A += N-B+1 B = N answer += (B-A)//2 print(answer) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int A = int(next(tokens)) # type: int B = int(next(tokens)) # type: int solve(N, A, B) if __name__ == '__main__': main()
[ "assignment.remove", "assignment.add" ]
628,264
628,265
u020390084
python
p02823
N,A,B = list(map(int,input().split())) if (A-B)%2 == 0: print((max(A,B)-min(A,B))//2) else: print(min(min(A,B)+(max(A,B)-min(A,B))//2, N-max(A,B)+ (max(A,B)-min(A,B))//2))
N,A,B = list(map(int,input().split())) if (A-B)%2 == 0: print((max(A,B)-min(A,B))//2) else: print(min(min(A,B)+(max(A,B)-min(A,B))//2, N-max(A,B)+1 + (max(A,B)-min(A,B))//2))
[ "expression.operation.binary.add" ]
628,270
628,271
u441575327
python
p02823
n, a, b = map(int, input().split()) if abs(a - b) % 2: te = [a - 1, b - 1] te.sort() rem = te[1] - te[0] + 1 cand1 = te[0] + rem // 2 te = [n - a, n - b] te.sort() rem = te[1] - te[0] + 1 cand2 = te[0] + rem // 2 print(min(cand2, cand2)) else: print(abs(a-b)//2)
n, a, b = map(int, input().split()) if abs(a - b) % 2: te = [a - 1, b - 1] te.sort() rem = te[1] - te[0] + 1 cand1 = te[0] + rem // 2 te = [n - a, n - b] te.sort() rem = te[1] - te[0] + 1 cand2 = te[0] + rem // 2 print(min(cand1, cand2)) else: print(abs(a-b)//2)
[ "identifier.change", "call.arguments.change", "io.output.change" ]
628,278
628,279
u711539583
python
p02823
N, A, B = map(int, input().split()) A, B = min(A, B), max(A, B) if (B - A) % 2 == 0: print((B - A) // 2) else: L = B - 1 R = N - A if R < L: print((R + (N - A) + 1) // 2) else: print((L + (B - 1) + 1) // 2)
N, A, B = map(int, input().split()) A, B = min(A, B), max(A, B) if (B - A) % 2 == 0: print((B - A) // 2) else: L = A - 1 R = N - B if R < L: print((R + (N - A) + 1) // 2) else: print((L + (B - 1) + 1) // 2)
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,283
628,284
u006657459
python
p02823
n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: c=0 if n-a>b-1: c+=a-1 c+=1 c+=(b-1-1)//2 else: c+=n-b c+=1 c+=(n-a-1)//2 print(c)
n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: c=0 if n-a>b-1: c+=a-1 c+=1 c+=((b-1-c)//2) else: c+=n-b c+=1 c+=((n-a-c)//2) print(c)
[ "identifier.replace.add", "literal.replace.remove", "expression.operation.binary.change" ]
628,296
628,297
u780420070
python
p02823
N , A , B = map(int, input().split()) c = 0 if A%2 == B%2: print((B-A)//2) else: if N - B > A-1: c += N - B c += 1 c += (B-A-1)//2 print(c) else: c += A-1 c += 1 c += (B-A-1)//2 print(c)
N , A , B = map(int, input().split()) c = 0 if A%2 == B%2: print((B-A)//2) else: if N - B < A-1: c += N - B c += 1 c += (B-A-1)//2 print(c) else: c += A-1 c += 1 c += (B-A-1)//2 print(c)
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
628,304
628,305
u226849101
python
p02823
N , A , B = map(int, input().split()) c = 0 if A%2 == B%2: print((B-A)//2) else: if N - B > A: c += N - B c += 1 c += (B-A-1)//2 print(c) else: c += A-1 c += 1 c += (B-A-1)//2 print(c)
N , A , B = map(int, input().split()) c = 0 if A%2 == B%2: print((B-A)//2) else: if N - B < A-1: c += N - B c += 1 c += (B-A-1)//2 print(c) else: c += A-1 c += 1 c += (B-A-1)//2 print(c)
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
628,306
628,305
u226849101
python
p02823
N, A, B = map(int, input().split()) D = B - A ans = float('inf') if D % 2 == 0: ans = D//2 else: # ๅทฆ็ซฏใพใง่กŒใ move = A - 1 L = 1 R = B - move D = R - L if D % 2 == 0: ans = min(ans, D//2 + move) else: ans = min(ans, D//2+1 + move) # ๅณ็ซฏใพใง่กŒใ move = N - A L = A + move R = N D = R - L if D % 2 == 0: ans = min(ans, D//2 + move) else: ans = min(ans, D//2+1 + move) print(ans)
N, A, B = map(int, input().split()) D = B - A ans = float('inf') if D % 2 == 0: ans = D//2 else: # ๅทฆ็ซฏใพใง่กŒใ move = A - 1 L = 1 R = B - move D = R - L if D % 2 == 0: ans = min(ans, D//2 + move) else: ans = min(ans, D//2+1 + move) # ๅณ็ซฏใพใง่กŒใ move = N - B L = A + move R = N D = R - L if D % 2 == 0: ans = min(ans, D//2 + move) else: ans = min(ans, D//2+1 + move) print(ans)
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,310
628,311
u970308980
python
p02823
''' ุจูุณู’ู…ู ุงู„ู„ูŽู‘ู‡ู ุงู„ุฑูŽู‘ุญู’ู…ูŽูฐู†ู ุงู„ุฑูŽู‘ุญููŠู…ู ''' #codeforces gi = lambda : list(map(int,input().split())) n, a, b = gi() if a > b: a, b = b, a if (abs(a - b) % 2): x = a b -= a x += (b - 1) // 2 y = n - b + 1 a += y y += (n - a) // 2 print(min(x, y)) else: print(abs(a - b) // 2)
''' ุจูุณู’ู…ู ุงู„ู„ูŽู‘ู‡ู ุงู„ุฑูŽู‘ุญู’ู…ูŽูฐู†ู ุงู„ุฑูŽู‘ุญููŠู…ู ''' #codeforces gi = lambda : list(map(int,input().split())) n, a, b = gi() if a > b: a, b = b, a if (abs(a - b) % 2): x = a b -= a x += (b - 1) // 2 b += a y = n - b + 1 a += y y += (n - a) // 2 print(min(x, y)) else: print(abs(a - b) // 2)
[]
628,325
628,326
u909815117
python
p02823
n,a,b = map(int, input().split()) ans = b-a if ans%2==0: print(ans//2) else: if a-1 > n-b: a = a+ n-b+1 print((n-a)//2 + n-b) else: b = b-a+2 print((b-1)//2 +a-1)
n,a,b = map(int, input().split()) ans = b-a if ans%2==0: print(ans//2) else: if a-1 > n-b: a = a+ n-b+1 print((n-a)//2 + n-b+1) else: b = b-a+2 print((b-1)//2 +a-1)
[ "expression.operation.binary.add" ]
628,327
628,328
u117348081
python
p02823
N,A,B = map(int,input().split()) if (B-A) % 2 == 0: ans = (B - A) // 2 else: x = (B - A - 1)//2 + A y = (B - A - 1)//2 + N - B ans = min(x,y) print(ans)
N,A,B = map(int,input().split()) if (B-A) % 2 == 0: ans = (B - A) // 2 else: x = (B - A - 1)//2 + A y = (B - A - 1)//2 + N - B + 1 ans = min(x,y) print(ans)
[ "assignment.change" ]
628,346
628,347
u557494880
python
p02823
N, A, B=map(int, input().split()) if A%2==B%2: print((B-A)//2) else: print(min((A+B-1)//2, (B-A+1)//2))
N, A, B=map(int, input().split()) if A%2==B%2: print((B-A)//2) else: print(min((A+B-1)//2, N+(-B-A+1)//2))
[ "expression.operation.unary.add", "call.arguments.change" ]
628,348
628,349
u419877586
python
p02823
N, A, B = [int(i) for i in input().split()] if (B-A) % 2 == 0: print((B- A) // 2) else: if A - 1 <= N - B: print(A + (B - A) // 2) else: print(N - B + (B - A) // 2)
N, A, B = [int(i) for i in input().split()] if (B-A) % 2 == 0: print((B- A) // 2) else: if A - 1 <= N - B: print(A + (B - A) // 2) else: print(N - B + 1 + (B - A) // 2)
[ "expression.operation.binary.add" ]
628,352
628,353
u256281774
python
p02823
N, A, B = map(int, input().split()) if (B-A)%2 == 0: print((B-A)//2) else: if A-1 < (N-B): ans = A B -= A A = 1 ans += (B-A)//2 print(ans) else: ans = N - B + 1 B = N A += N-B+1 ans += (B-A)//2 print(ans)
N, A, B = map(int, input().split()) if (B-A)%2 == 0: print((B-A)//2) else: if A-1 < (N-B): ans = A B -= A A = 1 ans += (B-A)//2 print(ans) else: ans = N-B+1 A += N-B+1 B = N ans += (B-A)//2 print(ans)
[ "assignment.remove", "assignment.add" ]
628,354
628,355
u886747123
python
p02823
N, A, B = map(int, input().split()) if (B - A) % 2 == 0: print((B - A) // 2) else: lose = N - B loseThenMeet = (N - (A + lose)) // 2 win = A - 1 winThenMeet = ((B - win) - 1) // 2 print(min(lose + loseThenMeet, win + winThenMeet))
N, A, B = map(int, input().split()) if (B - A) % 2 == 0: print((B - A) // 2) else: lose = N - B + 1 loseThenMeet = (N - (A + lose)) // 2 win = A - 1 + 1 winThenMeet = ((B - win) - 1) // 2 print(min(lose + loseThenMeet, win + winThenMeet))
[ "assignment.change" ]
628,363
628,364
u183395797
python
p02823
n, a, b = map(int, input().split()) if (b - a) % 2 == 0: print((b - a) // 2) else: ans1 = a c = b - ans1 ans1 += (c - 1) // 2 ans2 = n-b c = a + ans2 ans2 += (n - c) // 2 print(min(ans1, ans2))
n, a, b = map(int, input().split()) if (b - a) % 2 == 0: print((b - a) // 2) else: ans1 = a c = b - ans1 ans1 += (c - 1) // 2 ans2 = n-b+1 c = a + ans2 ans2 += (n - c) // 2 print(min(ans1, ans2))
[ "assignment.change" ]
628,373
628,374
u768128363
python
p02823
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n, a, b = [int(item) for item in input().split()] ans = 10**20 diff = abs(a - b) if diff % 2 == 0: ans = diff // 2 print(ans) else: if a > b: a, b = b, a left = a left += (b - left) // 2 right = 2 * n - b + 1 right += (2 * n - right - a) // 2 print(min(left, right))
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n, a, b = [int(item) for item in input().split()] ans = 10**20 diff = abs(a - b) if diff % 2 == 0: ans = diff // 2 print(ans) else: if a > b: a, b = b, a left = a left += (b - left) // 2 right = n - b + 1 right += (n - right - a) // 2 print(min(left, right))
[ "expression.operation.binary.remove" ]
628,379
628,380
u052499405
python
p02823
N,A,B=map(int,input().split()) if (B-A)%2==0: print((B-A)//2) else: print(min((B+A-1)//2,((2*N-B+1)//2)))
N,A,B=map(int,input().split()) if (B-A)%2==0: print((B-A)//2) else: print(min((B+A-1)//2,((2*N-B+1-A)//2)))
[ "expression.operation.binary.add" ]
628,394
628,395
u187516587
python
p02823
N, A, B = map(int, input().split()) if (B - A) & 1: res = (B - A - 1) // 2 + A A, B = 2 * N - B + 1, 2 * N - A + 1 res = min(res, (B - A - 1) // 2 + A) print(res) else: print((B - A) // 2)
N, A, B = map(int, input().split()) if (B - A) & 1: res = (B - A - 1) // 2 + A A, B = N - B + 1, N - A + 1 res = min(res, (B - A - 1) // 2 + A) print(res) else: print((B - A) // 2)
[ "expression.operation.binary.remove" ]
628,417
628,418
u732412551
python
p02823
N, A, B = map(int, input().split()) if (B - A) % 2 == 0: print ((B - A) // 2) exit() tmp1 = A b = B - A tmp1 += (B - 1) // 2 tmp2 = N - B a = A + tmp2 tmp2 += (N - a) // 2 print (min(tmp1, tmp2) + 1)
N, A, B = map(int, input().split()) if (B - A) % 2 == 0: print ((B - A) // 2) exit() tmp1 = A - 1 b = B - tmp1 tmp1 += (b - 1) // 2 tmp2 = N - B a = A + tmp2 tmp2 += (N - a) // 2 print (min(tmp1, tmp2) + 1)
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
628,428
628,429
u263830634
python
p02823
def main(): N, A, B = [int(i) for i in input().split()] diff = B - A if diff % 2 == 0: ans = diff // 2 else: ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 (diff - 1) // 2) print(ans) if __name__ == '__main__': main()
def main(): N, A, B = [int(i) for i in input().split()] diff = B - A if diff % 2 == 0: ans = diff // 2 else: ans = min(B - 1, N - A, (A - 1) + 1 + (diff - 1) // 2, (N - B) + 1 + (diff - 1) // 2) print(ans) if __name__ == '__main__': main()
[ "call.arguments.change" ]
628,432
628,433
u624689667
python
p02823
N, A, B = map(int, input().split()) if abs(A - B) % 2 == 0: print(abs(A - B) // 2) else: print(min(A-1, B-1) + 1 + (B-A-1)//2)
N, A, B = map(int, input().split()) if abs(A - B) % 2 == 0: print(abs(A - B) // 2) else: print(min(A-1, N-B) + 1 + (B-A-1)//2)
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "identifier.replace.add", "literal.replace.remove" ]
628,464
628,465
u317713173
python
p02823
n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: print(min(a-1+(b-a)//2,n-b+(b-a)//2))
n,a,b=map(int,input().split()) if (b-a)%2==0: print((b-a)//2) else: print(min(a-1+(b-a+1)//2,n-b+(b-a+1)//2))
[ "expression.operation.binary.add" ]
628,468
628,469
u670180528
python
p02823
N,A,B= map(int,input().split()) m = abs(B-A) if m%2==0: ans = m//2 else: ans1 = N-B+1 A1 = A+N-B+1 ans1 += (N-A1)//2 ans2 = A-1+1 B2 = B-A-2 ans2 += (B2-1)//2 ans = min(ans1,ans2) print(ans)
N,A,B= map(int,input().split()) m = abs(B-A) if m%2==0: ans = m//2 else: ans1 = N-B+1 A1 = A+N-B+1 ans1 += (N-A1)//2 ans2 = A B2 = B-A ans2 += (B2-1)//2 ans = min(ans1,ans2) print(ans)
[ "expression.operation.binary.remove" ]
628,480
628,481
u698176039
python
p02823
n,a,b = map(int,input().split()) if abs(a-b)%2 == 0: print(abs(a-b)//2) else: print(min((a+b+1)//2,(n-a+n-b+1)//2))
n,a,b = map(int,input().split()) if abs(a-b)%2 == 0: print(abs(a-b)//2) else: print(min((a+b-1)//2,(n-a+n-b+1)//2))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
628,488
628,489
u667024514
python
p02824
n,m,v,p = map(int, input().split()) a = list(map(int, input().split())) a.sort() def solve(ind): if a[ind]+m < a[-p]: return False thr = a[ind] + m votes=[] for i in range(n): if i<=ind or i>n-p: votes.append(m) else: votes.append(thr-a[i]) sm = sum(votes) return sm >= m*v ok=n-1 ng=0 while abs(ng - ok) > 1: mid = (ng + ok)//2 if solve(mid): ok = mid else: ng = mid print(n-ok)
n,m,v,p = map(int, input().split()) a = list(map(int, input().split())) a.sort() def solve(ind): if a[ind]+m < a[-p]: return False thr = a[ind] + m votes=[] for i in range(n): if i<=ind or i>n-p: votes.append(m) else: votes.append(thr-a[i]) sm = sum(votes) return sm >= m*v ok=n-1 ng=-1 while abs(ng - ok) > 1: mid = (ng + ok)//2 if solve(mid): ok = mid else: ng = mid print(n-ok)
[ "assignment.value.change", "expression.operation.unary.add" ]
628,540
628,541
u358254559
python
p02824
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, M, V, P = mapint() As = list(mapint()) As.sort(reverse=True) threshold = As[P-1] l, r = P, N while l+1<r: half = (l+r)//2 a = As[half]+M if a<threshold: r = half else: rest_sum = 0 for i in range(P-1, N): if As[i]>=a: continue if i==half: continue rest_sum += min(M, a-As[i]) if M*V > rest_sum+P*M: r = half else: l = half print(l+1)
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, M, V, P = mapint() As = list(mapint()) As.sort(reverse=True) threshold = As[P-1] l, r = P-1, N while l+1<r: half = (l+r)//2 a = As[half]+M if a<threshold: r = half else: rest_sum = 0 for i in range(P-1, N): if As[i]>=a: continue if i==half: continue rest_sum += min(M, a-As[i]) if M*V > rest_sum+P*M: r = half else: l = half print(l+1)
[ "assignment.change" ]
628,545
628,546
u054514819
python
p02824
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * from heapq import heapify, heappop, heappush import math import random import string from copy import deepcopy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10 ** 9 + 7 ############# # Main Code # ############# """ # ๅ•้กŒ:Nๅ•ใ€ใ‚ธใƒฃใƒƒใ‚ธ:Mไบบ # Mไบบใฎใ‚ธใƒฃใƒƒใ‚ธใŒใใ‚Œใžใ‚ŒVๅ•ใ‚’้ธใณใ€ๅ•้กŒใฎใ‚นใ‚ณใ‚ขใ‚’๏ผ‘ใšใคใ‚ใ’ใ‚‹ # MไบบใฎๆŠ•็ฅจใฎๅพŒใ€ๅคงใใ„ๆ–นใ‹ใ‚‰Pๅ•ใŒ้ธใฐใ‚Œใ‚‹ # ๅ•้กŒใ‚ปใƒƒใƒˆใซ้ธใฐใ‚Œใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚‹ใฎใฏไฝ•ๅ•ใ‚ใ‚‹ใ‹ Mไบบๅ…จๅ“กใŒๆŠ•็ฅจใ™ใ‚Œใฐ้ธใฐใ‚Œใ‚„ใ™ใใชใ‚‹ ้ธใฐใ‚Œใ‚‹ใจใฏ๏ผŸ ๅฏ่ƒฝๆ€งใŒใชใ„ใ‚‚ใฎใ‚’ๆ•ฐใˆใŸๆ–นใŒๆ—ฉใ„ใฎใงใฏ P็•ช็›ฎไปฅๅ†…ใซใ‚ใ‚Œใฐ็„กๆกไปถใง้€š้Ž ็พๅœจใฎP็•ช็›ฎ <= A[i] + M V <= Pใชใ‚‰ ไธŠใ‹ใ‚‰P - 1็•ช็›ฎใพใงใฎใฉใ‚Œใ‹ + A[i]ใ‚’ๅŠ ็ฎ—ใ•ใ›ใ‚‹ใ“ใจใงA[i]ใ‚’ๅผทใใงใใ‚‹ใ€€ V > Pใชใ‚‰๏ผŸ ไธŠใ‹ใ‚‰P - 1็•ช็›ฎใพใงใจA[i]ใ‚’ๅผทๅŒ–ใ™ใ‚‹ใจใ—ใฆใ€ๆฎ‹ใ‚ŠใฎV - Pๅ€‹ใฏๅฐใ•ใ„ใ‚‚ใฎใ‹ใ‚‰้ †ใซ้ธใถ A[i]ใ‚’ๆŠœใ‹ใ›ใชใ„ใ‚ˆใ†ใซใ—ใŸใ„ A[i]ใ‚ˆใ‚Šๅคงใใ„ๆ•ฐๅญ—ใ‚‚ไธ€็ท’ใซ่ถณใ•ใ‚Œใ‚‹ๅ ดๅˆใซใฏPไปฅๅ†…ใซๅ…ฅใ‚Œใชใ„ """ N, M, V, P = getNM() A = getList() A.sort(reverse = True) def judge(x): if x <= P - 1: return True if A[P - 1] > A[x] + M: return False # P - 1็•ช็›ฎใพใง + ่‡ช่บซไปฅ้™ใฎๆ•ฐๅญ—ใซใคใ„ใฆใฏMๅ€‹่ถณใ™ left = (V - (P - 1) - (N - x)) * M # Pๅ€‹็›ฎใ‹ใ‚‰x-1ใพใง A[x] + Mใ‚’่ถ…ใˆใชใ„ๅˆ†่ถณใ™ for i in range(P, x): left -= A[x] + M - A[i] return left <= 0 ok = -1 ng = N while abs(ok - ng) > 1: mid = (ok + ng) // 2 if judge(mid): ok = mid else: ng = mid print(ok + 1)
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * from heapq import heapify, heappop, heappush import math import random import string from copy import deepcopy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10 ** 9 + 7 ############# # Main Code # ############# """ # ๅ•้กŒ:Nๅ•ใ€ใ‚ธใƒฃใƒƒใ‚ธ:Mไบบ # Mไบบใฎใ‚ธใƒฃใƒƒใ‚ธใŒใใ‚Œใžใ‚ŒVๅ•ใ‚’้ธใณใ€ๅ•้กŒใฎใ‚นใ‚ณใ‚ขใ‚’๏ผ‘ใšใคใ‚ใ’ใ‚‹ # MไบบใฎๆŠ•็ฅจใฎๅพŒใ€ๅคงใใ„ๆ–นใ‹ใ‚‰Pๅ•ใŒ้ธใฐใ‚Œใ‚‹ # ๅ•้กŒใ‚ปใƒƒใƒˆใซ้ธใฐใ‚Œใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚‹ใฎใฏไฝ•ๅ•ใ‚ใ‚‹ใ‹ Mไบบๅ…จๅ“กใŒๆŠ•็ฅจใ™ใ‚Œใฐ้ธใฐใ‚Œใ‚„ใ™ใใชใ‚‹ ้ธใฐใ‚Œใ‚‹ใจใฏ๏ผŸ ๅฏ่ƒฝๆ€งใŒใชใ„ใ‚‚ใฎใ‚’ๆ•ฐใˆใŸๆ–นใŒๆ—ฉใ„ใฎใงใฏ P็•ช็›ฎไปฅๅ†…ใซใ‚ใ‚Œใฐ็„กๆกไปถใง้€š้Ž ็พๅœจใฎP็•ช็›ฎ <= A[i] + M V <= Pใชใ‚‰ ไธŠใ‹ใ‚‰P - 1็•ช็›ฎใพใงใฎใฉใ‚Œใ‹ + A[i]ใ‚’ๅŠ ็ฎ—ใ•ใ›ใ‚‹ใ“ใจใงA[i]ใ‚’ๅผทใใงใใ‚‹ใ€€ V > Pใชใ‚‰๏ผŸ ไธŠใ‹ใ‚‰P - 1็•ช็›ฎใพใงใจA[i]ใ‚’ๅผทๅŒ–ใ™ใ‚‹ใจใ—ใฆใ€ๆฎ‹ใ‚ŠใฎV - Pๅ€‹ใฏๅฐใ•ใ„ใ‚‚ใฎใ‹ใ‚‰้ †ใซ้ธใถ A[i]ใ‚’ๆŠœใ‹ใ›ใชใ„ใ‚ˆใ†ใซใ—ใŸใ„ A[i]ใ‚ˆใ‚Šๅคงใใ„ๆ•ฐๅญ—ใ‚‚ไธ€็ท’ใซ่ถณใ•ใ‚Œใ‚‹ๅ ดๅˆใซใฏPไปฅๅ†…ใซๅ…ฅใ‚Œใชใ„ """ N, M, V, P = getNM() A = getList() A.sort(reverse = True) def judge(x): if x < P: return True if A[P - 1] > A[x] + M: return False # P - 1็•ช็›ฎใพใง + ่‡ช่บซไปฅ้™ใฎๆ•ฐๅญ—ใซใคใ„ใฆใฏMๅ€‹่ถณใ™ left = (V - (P - 1) - (N - x)) * M # Pๅ€‹็›ฎใ‹ใ‚‰x-1ใพใง A[x] + Mใ‚’่ถ…ใˆใชใ„ๅˆ†่ถณใ™ for i in range(P - 1, x): left -= A[x] + M - A[i] return left <= 0 ok = -1 ng = N while abs(ok - ng) > 1: mid = (ok + ng) // 2 if judge(mid): ok = mid else: ng = mid print(ok + 1)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
628,547
628,548
u145231176
python
p02824
from bisect import bisect_left,bisect_right N,M,V,P = map(int,input().split()) A = sorted(list(map(int,input().split()))) low = -1 high = A[-1]+M while high-low>1: mid = (low+high)//2 indL = bisect_left(A,mid-M) indR = bisect_right(A,mid) if indL>N-P: high = mid continue if indR<N-P+1: low = mid continue tot = M*V i = indL while i<N-P+1: if tot-(mid-A[i])<0:break tot -= mid-A[i] i += 1 if i<N-P+1: high = mid break if 0<=tot<=M*(P-1+indL): high = mid else: low = mid ind = bisect_left(A,high-M) print(N-ind)
from bisect import bisect_left,bisect_right N,M,V,P = map(int,input().split()) A = sorted(list(map(int,input().split()))) low = -1 high = A[-1]+M while high-low>1: mid = (low+high)//2 indL = bisect_left(A,mid-M) indR = bisect_right(A,mid) if indL>N-P: high = mid continue if indR<N-P+1: low = mid continue tot = M*V i = indL while i<N-P+1: if tot-(mid-A[i])<0:break tot -= mid-A[i] i += 1 if i<N-P+1 or 0<=tot<=M*(P-1+indL): high = mid else: low = mid ind = bisect_left(A,high-M) print(N-ind)
[ "control_flow.break.remove" ]
628,554
628,555
u644907318
python
p02824
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-1] def binary_search(a): ok=-1 ng=len(a) while abs(ng-ok)>1: mid=(ng+ok)//2 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))
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)//2 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))
[ "control_flow.loop.range.bounds.lower.change", "expression.operation.binary.add" ]
628,571
628,572
u730769327
python
p02824
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)//2 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))
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)//2 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))
[ "control_flow.loop.range.bounds.lower.change", "expression.operation.binary.add" ]
628,573
628,572
u730769327
python
p02824
n,m,v,p = map(int,input().split()) a = list(map(int,input().split())) a.sort(reverse = True) ans = p border = a[p-1] to_border = 0 for i in range(p,n): new_border = a[i] + m if new_border < border: print(ans) exit() possible_votes = 0 possible_votes += (p+n-i-1)*m possible_votes += to_border possible_votes += (new_border-border)*(i-p) if possible_votes >= m*v: ans += 1 to_border += border-a[i] else: print(ans) exit() print(ans) exit()
n,m,v,p = map(int,input().split()) a = list(map(int,input().split())) a.sort(reverse = True) ans = p border = a[p-1] to_border = 0 for i in range(p,n): new_border = a[i] + m if new_border < border: print(ans) exit() possible_votes = 0 possible_votes += (n+p-i-1)*m possible_votes += to_border possible_votes += (new_border-border)*(i-p+1) if possible_votes >= m*v: ans += 1 to_border += border-a[i] else: print(ans) exit() print(ans) exit()
[ "expression.operation.binary.remove" ]
628,574
628,575
u201928947
python
p02824
n, m, v, p = map(int, input().split()) alst = list(map(int, input().split())) alst.sort(reverse = True) left = p - 1 right = n while right - left > 1: pos = (left + right) // 2 if alst[pos] + m < alst[p - 1]: right = pos continue cnt = (p - 1) * m base = alst[pos] + m for i in range(p, n): cnt += min(m, base - alst[i]) if cnt >= m * v: left = pos else: right = pos print(left + 1)
n, m, v, p = map(int, input().split()) alst = list(map(int, input().split())) alst.sort(reverse = True) left = p - 1 right = n while right - left > 1: pos = (left + right) // 2 if alst[pos] + m < alst[p - 1]: right = pos continue cnt = (p - 1) * m base = alst[pos] + m for i in range(p - 1, n): cnt += min(m, base - alst[i]) if cnt >= m * v: left = pos else: right = pos print(left + 1)
[ "control_flow.loop.range.bounds.lower.change", "expression.operation.binary.add" ]
628,581
628,582
u745514010
python
p02824
#!/usr/bin python3 # -*- coding: utf-8 -*- n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse = True) def f(x): if x < p: return True if a[p-1] > a[x] + m: return False else: res = m * v res -= m * (n-x) res -= m * (p-1) for i in range(p-1, x): res -= min(m, max(0,a[x]+m-a[i])) return res < 0 ok = 0 ng = n while ng - ok > 1: nw = (ok+ng) // 2 if f(nw): ok = nw else: ng = nw print(ng)
#!/usr/bin python3 # -*- coding: utf-8 -*- n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse = True) def f(x): if x < p: return True if a[p-1] > a[x] + m: return False else: res = m * v res -= m * (n-x) res -= m * (p-1) for i in range(p-1, x): res -= min(m, max(0,a[x]+m-a[i])) return res <= 0 ok = 0 ng = n while ng - ok > 1: nw = (ok+ng) // 2 if f(nw): ok = nw else: ng = nw print(ng)
[ "expression.operator.compare.change", "function.return_value.change" ]
628,583
628,584
u113971909
python
p02824
#!/usr/bin python3 # -*- coding: utf-8 -*- n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse = True) def f(x): if x < p: return True if a[p-1] > a[x] + m: return False else: res = m * v res -= m * (n-x) res -= m * (p-1) for i in range(p-1, x): res -= min(m, max(0,a[x]+m-a[i])) return res >= 0 ok = 0 ng = n while ng - ok > 1: nw = (ok+ng) // 2 if f(nw): ok = nw else: ng = nw print(ng)
#!/usr/bin python3 # -*- coding: utf-8 -*- n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse = True) def f(x): if x < p: return True if a[p-1] > a[x] + m: return False else: res = m * v res -= m * (n-x) res -= m * (p-1) for i in range(p-1, x): res -= min(m, max(0,a[x]+m-a[i])) return res <= 0 ok = 0 ng = n while ng - ok > 1: nw = (ok+ng) // 2 if f(nw): ok = nw else: ng = nw print(ng)
[ "misc.opposites", "expression.operator.compare.change", "function.return_value.change" ]
628,585
628,584
u113971909
python
p02824
N, M, V, P = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) def solve(n): if n < P: return True if A[n-1] > A[n] + M: return False cnt = M * (P - 1 + N - n) for i in range(P-1,n): cnt += A[n] + M - A[i] return cnt >= M * V left = 0 right = N while left + 1 < right: mid = (left + right) // 2 if solve(mid): left = mid else: right = mid print(right)
N, M, V, P = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) def solve(n): if n < P: return True if A[P-1] > A[n] + M: return False cnt = M * (P - 1 + N - n) for i in range(P-1,n): cnt += max(0, A[n] + M - A[i]) return cnt >= M * V left = 0 right = N while left + 1 < right: mid = (left + right) // 2 if solve(mid): left = mid else: right = mid print(right)
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "call.add", "call.arguments.change" ]
628,638
628,639
u189479417
python
p02824
N, M, V, P = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) def solve(n): if n < P: return True if A[n-1] > A[n] + M: return False cnt = M * (P - 1 + N - n) for i in range(P-1,n): cnt += max(0, A[n] + M - A[i]) return cnt >= M * V left = 0 right = N while left + 1 < right: mid = (left + right) // 2 if solve(mid): left = mid else: right = mid print(right)
N, M, V, P = map(int,input().split()) A = list(map(int,input().split())) A.sort(reverse = True) def solve(n): if n < P: return True if A[P-1] > A[n] + M: return False cnt = M * (P - 1 + N - n) for i in range(P-1,n): cnt += max(0, A[n] + M - A[i]) return cnt >= M * V left = 0 right = N while left + 1 < right: mid = (left + right) // 2 if solve(mid): left = mid else: right = mid print(right)
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
628,640
628,639
u189479417
python
p02824
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)
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)
[ "identifier.change", "control_flow.branch.if.condition.change" ]
628,654
628,655
u490642448
python
p02824
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,p-1)*m): print(i) exit() higher += a[i] print(n)
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)
[ "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
628,656
628,655
u490642448
python
p02824
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)
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)
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
628,657
628,655
u490642448
python
p02824
# ไธŠใ‹ใ‚‰xๅ•็›ฎใ‚’้ธใถใ“ใจใŒใงใใ‚‹ใ‹ไบŒๅˆ†ๆŽข็ดข # x <= Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใ‚‹ # A_x + M < A_Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใชใ„ # ใใ‚Œไปฅๅค–ใฎๅ ดๅˆ # A_xใซใฏๅฟ…ใšๆŠ•็ฅจใ™ใ‚‹ใฎใงA_x + MใŒๅŸบๆบ–็‚น # A_xใŒPไฝใงใ‚ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ # ไธŠไฝP - 1ไฝใพใงใซใฏM็ฅจๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # P + 1ไฝไปฅไธ‹ใซๅฏพใ—ใฆใฏใ€A_x + MใพใงใฏๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # ใ“ใฎๆŠ•็ฅจใ—ใฆ่‰ฏใ„ๆ•ฐใŒM * Vใ‚’ไธŠๅ›žใ‚ŒใฐOK import sys readline = sys.stdin.readline N,M,V,P = map(int,readline().split()) A = sorted(list(map(int,readline().split())),reverse = True) # ๆœ€ๅˆใฎๆ™‚็‚นใงไธŠไฝPไฝใฎ็‚นๆ•ฐใ‚’ๆฑ‚ใ‚ใฆใŠใ border = A[P - 1] # ๅคงใใ„้ †ใซไธฆในใ‚‹ ok = -1 ng = N def isOk(x): # ไธŠใ‹ใ‚‰x็•ช็›ฎใ‚’้ธใถใ“ใจใŒๅ‡บๆฅใ‚‹ใ‹ if x <= P: return True if A[x] + M < border: return False # ๅŸบๆบ–็‚น base = A[x] + M # ไธŠไฝP - 1ใซใฏๅฟ…ใšๆŠ•็ฅจใ—ใฆ่‰ฏใ„ vote = (P - 1) * M # Pไฝไปฅไธ‹ใซใฏใ€baseใ‚’่ถ…ใˆใชใ„ใ‚ˆใ†ใซๆŠ•็ฅจใ—ใฆ่‰ฏใ„ for i in range(P - 1,len(A)): can = max(base - A[i],0) can = min(can, M) vote += can if vote >= M * V: return True return False while abs(ok - ng) > 1: mid = abs(ok + ng)//2 if isOk(mid): ok = mid else: ng = mid print(ok + 1)
# ไธŠใ‹ใ‚‰xๅ•็›ฎใ‚’้ธใถใ“ใจใŒใงใใ‚‹ใ‹ไบŒๅˆ†ๆŽข็ดข # x <= Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใ‚‹ # A_x + M < A_Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใชใ„ # ใใ‚Œไปฅๅค–ใฎๅ ดๅˆ # A_xใซใฏๅฟ…ใšๆŠ•็ฅจใ™ใ‚‹ใฎใงA_x + MใŒๅŸบๆบ–็‚น # A_xใŒPไฝใงใ‚ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ # ไธŠไฝP - 1ไฝใพใงใซใฏM็ฅจๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # P + 1ไฝไปฅไธ‹ใซๅฏพใ—ใฆใฏใ€A_x + MใพใงใฏๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # ใ“ใฎๆŠ•็ฅจใ—ใฆ่‰ฏใ„ๆ•ฐใŒM * Vใ‚’ไธŠๅ›žใ‚ŒใฐOK import sys readline = sys.stdin.readline N,M,V,P = map(int,readline().split()) A = sorted(list(map(int,readline().split())),reverse = True) # ๆœ€ๅˆใฎๆ™‚็‚นใงไธŠไฝPไฝใฎ็‚นๆ•ฐใ‚’ๆฑ‚ใ‚ใฆใŠใ border = A[P - 1] # ๅคงใใ„้ †ใซไธฆในใ‚‹ ok = -1 ng = N def isOk(x): # ไธŠใ‹ใ‚‰x็•ช็›ฎใ‚’้ธใถใ“ใจใŒๅ‡บๆฅใ‚‹ใ‹ if (x + 1) <= P: return True if A[x] + M < border: return False # ๅŸบๆบ–็‚น base = A[x] + M # ไธŠไฝP - 1ใซใฏๅฟ…ใšๆŠ•็ฅจใ—ใฆ่‰ฏใ„ vote = (P - 1) * M # Pไฝไปฅไธ‹ใซใฏใ€baseใ‚’่ถ…ใˆใชใ„ใ‚ˆใ†ใซๆŠ•็ฅจใ—ใฆ่‰ฏใ„ for i in range(P - 1,len(A)): limit = max(base - A[i], 0) can = min(limit, M) vote += can if vote >= M * V: return True return False while abs(ok - ng) > 1: mid = abs(ok + ng)//2 if isOk(mid): ok = mid else: ng = mid print(ok + 1)
[ "control_flow.branch.if.condition.change", "assignment.variable.change", "identifier.change", "assignment.value.change", "call.arguments.change" ]
628,664
628,665
u936985471
python
p02824
# ไธŠใ‹ใ‚‰xๅ•็›ฎใ‚’้ธใถใ“ใจใŒใงใใ‚‹ใ‹ไบŒๅˆ†ๆŽข็ดข # x <= Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใ‚‹ # A_x + M < A_Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใชใ„ # ใใ‚Œไปฅๅค–ใฎๅ ดๅˆ # A_xใซใฏๅฟ…ใšๆŠ•็ฅจใ™ใ‚‹ใฎใงA_x + MใŒๅŸบๆบ–็‚น # A_xใŒPไฝใงใ‚ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ # ไธŠไฝP - 1ไฝใพใงใซใฏM็ฅจๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # P + 1ไฝไปฅไธ‹ใซๅฏพใ—ใฆใฏใ€A_x + MใพใงใฏๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # ใ“ใฎๆŠ•็ฅจใ—ใฆ่‰ฏใ„ๆ•ฐใŒM * Vใ‚’ไธŠๅ›žใ‚ŒใฐOK import sys readline = sys.stdin.readline N,M,V,P = map(int,readline().split()) A = sorted(list(map(int,readline().split())),reverse = True) # ๆœ€ๅˆใฎๆ™‚็‚นใงไธŠไฝPไฝใฎ็‚นๆ•ฐใ‚’ๆฑ‚ใ‚ใฆใŠใ border = A[P - 1] # ๅคงใใ„้ †ใซไธฆในใ‚‹ ok = -1 ng = N def isOk(x): # ไธŠใ‹ใ‚‰x็•ช็›ฎใ‚’้ธใถใ“ใจใŒๅ‡บๆฅใ‚‹ใ‹ if x <= P: return True if A[x] + M < border: return False # ๅŸบๆบ–็‚น base = A[x] + M # ไธŠไฝP - 1ใซใฏๅฟ…ใšๆŠ•็ฅจใ—ใฆ่‰ฏใ„ vote = (P - 1) * M # Pไฝไปฅไธ‹ใซใฏใ€baseใ‚’่ถ…ใˆใชใ„ใ‚ˆใ†ใซๆŠ•็ฅจใ—ใฆ่‰ฏใ„ for i in range(P - 1,len(A)): can = max(base - A[i],0) can = min(can, M) vote += can if vote >= M * V: return True return False while abs(ok - ng) > 1: mid = abs(ok + ng)//2 if isOk(mid): ok = mid else: ng = mid print(ok + 1)
# ไธŠใ‹ใ‚‰xๅ•็›ฎใ‚’้ธใถใ“ใจใŒใงใใ‚‹ใ‹ไบŒๅˆ†ๆŽข็ดข # x <= Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใ‚‹ # A_x + M < A_Pใงใ‚ใ‚Œใฐๅฟ…ใš้ธในใชใ„ # ใใ‚Œไปฅๅค–ใฎๅ ดๅˆ # A_xใซใฏๅฟ…ใšๆŠ•็ฅจใ™ใ‚‹ใฎใงA_x + MใŒๅŸบๆบ–็‚น # A_xใŒPไฝใงใ‚ใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ # ไธŠไฝP - 1ไฝใพใงใซใฏM็ฅจๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # P + 1ไฝไปฅไธ‹ใซๅฏพใ—ใฆใฏใ€A_x + MใพใงใฏๆŠ•็ฅจใ—ใฆ่‰ฏใ„ # ใ“ใฎๆŠ•็ฅจใ—ใฆ่‰ฏใ„ๆ•ฐใŒM * Vใ‚’ไธŠๅ›žใ‚ŒใฐOK import sys readline = sys.stdin.readline N,M,V,P = map(int,readline().split()) A = sorted(list(map(int,readline().split())),reverse = True) # ๆœ€ๅˆใฎๆ™‚็‚นใงไธŠไฝPไฝใฎ็‚นๆ•ฐใ‚’ๆฑ‚ใ‚ใฆใŠใ border = A[P - 1] # ๅคงใใ„้ †ใซไธฆในใ‚‹ ok = -1 ng = N def isOk(x): # ไธŠใ‹ใ‚‰x็•ช็›ฎใ‚’้ธใถใ“ใจใŒๅ‡บๆฅใ‚‹ใ‹ # print("x",x,"A[x]",A[x]) if (x + 1) <= P: return True if A[x] + M < border: return False # ๅŸบๆบ–็‚น base = A[x] + M # print("base",base,"็‚นใ‚’ๅ–ใฃใฆๅˆๆ ผใ—ใŸใ„") # ไธŠไฝP - 1ใซใฏๅฟ…ใšๆŠ•็ฅจใ—ใฆ่‰ฏใ„ vote = (P - 1) * M # print("ใพใš",vote,"็ฅจใ‚’ๆŠ•็ฅจ") # Pไฝไปฅไธ‹ใซใฏใ€baseใ‚’่ถ…ใˆใชใ„ใ‚ˆใ†ใซๆŠ•็ฅจใ—ใฆ่‰ฏใ„ for i in range(P - 1,len(A)): limit = max(base - A[i], 0) can = min(limit, M) # print(A[i],"ใซใฏcan",can,"็ฅจๆŠ•็ฅจใงใใ‚‹") vote += can # print("vote",vote) if vote >= M * V: return True return False while abs(ok - ng) > 1: mid = abs(ok + ng)//2 if isOk(mid): # print(mid,"is ok") ok = mid else: # print(mid,"is ng") ng = mid print(ok + 1)
[ "control_flow.branch.if.condition.change", "assignment.variable.change", "identifier.change", "assignment.value.change", "call.arguments.change" ]
628,664
628,666
u936985471
python
p02824
import bisect n,m,v,p = map(int, input().split()) a = list(map(int, input().split())) a.sort() #print(a) if (v<=p): limit = a[n-p] if (a[n-p] <= m): print(n) else: x = bisect.bisect_left(a,a[n-p]-m) print(n-x) else: limit = a[n-p] #print(1,limit) wa = [0]*n wa[0] = a[0] for i in range(1,n): wa[i] = wa[i-1] + a[i] #print(limit,wa) ans = 0 for i in range(n-p-1,-1,-1): sa = limit - a[i] if (sa==0): ans += 1 continue elif (sa > m): continue if (i>=v): ans += 1 else: nokori = (v-i-1-(p-1))*m #x = bisect.bisect_left(a,a[i]+m) #print(i,nokori) if (nokori <= (a[i]+m)*(n-p-1-i) - (wa[n-p-1]-wa[i])): ans += 1 #print(i) print(ans + p)
import bisect n,m,v,p = map(int, input().split()) a = list(map(int, input().split())) a.sort() #print(a) if (v<=p): limit = a[n-p] if (a[n-p] <= m): print(n) else: x = bisect.bisect_left(a,a[n-p]-m) print(n-x) else: limit = a[n-p] #print(1,limit) wa = [0]*n wa[0] = a[0] for i in range(1,n): wa[i] = wa[i-1] + a[i] #print(limit,wa) ans = 0 for i in range(n-p-1,-1,-1): sa = limit - a[i] if (sa==0): ans += 1 continue elif (sa > m): continue if (i>=v): ans += 1 else: nokori = (v-i-1-(p-1))*m #x = bisect.bisect_left(a,a[i]+m) #print(i,nokori) if (nokori <= (a[i]+m)*(n-p-i) - (wa[n-p]-wa[i])): ans += 1 #print(i) print(ans + p)
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
628,682
628,683
u262597910
python
p02824
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline n,m,v,p = map(int,readline().split()) a = [int(i) for i in readline().split()] a.sort(reverse=True) ans = p v -= (p-1) g = a[p-1] L = 1 use = m-g if v > 0: for i in range(p,n): mar = g-a[i] V = v-(n-1-i) if mar > m: break if V <= 1: if mar <= m: ans += 1 L += 1 use += m-a[i] else: break else: if use+a[i]*L >= (V-1)*m: ans += 1 L += 1 use += m-a[i] else: break print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline n,m,v,p = map(int,readline().split()) a = [int(i) for i in readline().split()] a.sort(reverse=True) ans = p v -= (p-1) g = a[p-1] L = 1 use = m-g for i in range(p,n): mar = g-a[i] V = v-(n-1-i) if mar > m: break if V <= 1: if mar <= m: ans += 1 L += 1 use += m-a[i] else: break else: if use+a[i]*L >= (V-1)*m: ans += 1 L += 1 use += m-a[i] else: break print(ans)
[]
628,686
628,687
u075595666
python
p02824
n, m, v, p = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ok = p - 1 ng = n while ok - ng > 1: mid = (ok + ng) // 2 if A[mid] + m < A[p - 1]: ng = mid continue used = m * p for i in range(p - 1, n): if i == mid: continue used += min(m, max(0, A[mid] + m - A[i])) if used >= m * v: ok = mid else: ng = mid print(ok + 1)
n, m, v, p = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ok = p - 1 ng = n while abs(ok - ng) > 1: mid = (ok + ng) // 2 if A[mid] + m < A[p - 1]: ng = mid continue used = m * p for i in range(p - 1, n): if i != mid: used += min(m, max(0, A[mid] + m - A[i])) if used >= m * v: ok = mid else: ng = mid print(ok + 1)
[ "control_flow.loop.condition.change", "call.add", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
628,695
628,696
u802963389
python
p02824
n, m, v, p = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ok = p - 1 ng = n while ok - ng > 1: mid = (ok + ng) // 2 if A[mid] + m < A[p - 1]: ng = mid continue used = m * p for i in range(p - 1, n): if i == mid: continue used += min(m, max(0, A[mid] + m - A[i])) if used >= m * v: ok = mid else: ng = mid print(ok + 1)
n, m, v, p = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ok = p - 1 ng = n while abs(ok - ng) > 1: mid = (ok + ng) // 2 if A[mid] + m < A[p - 1]: ng = mid continue used = m * p for i in range(p - 1, n): if i == mid: continue used += min(m, max(0, A[mid] + m - A[i])) if used >= m * v: ok = mid else: ng = mid print(ok + 1)
[ "control_flow.loop.condition.change", "call.add" ]
628,695
628,697
u802963389
python
p02824
import bisect n, m, v, p = map(int, input().split()) ls = list(map(int, input().split())) ls.sort() total=m*v for i in range(min(v-1,p-1)): ls[-i-1]+=m total-=m ac = [0]*n for i in range(n-1): ac[i+1] = ac[i]+(ls[i+1]-ls[i])*(i+1) ans=p for i in range(n-p): idx=bisect.bisect_right(ls,ls[i]+m) if n-idx>=p: continue totalnow=total-m*(i+1) if totalnow <= 0: ans += 1 continue if ac[-p]-ac[i]-(ls[-p]-ls[i])*(i+1)+(ls[i]+m-ls[-p])*(n-p-i-1)< totalnow: continue ans += 1 print(ans)
import bisect n, m, v, p = map(int, input().split()) ls = list(map(int, input().split())) ls.sort() total=m*v for i in range(min(v-1,p-1)): ls[-i-1]+=m total-=m ac = [0]*n for i in range(n-1): ac[i+1] = ac[i]+(ls[i+1]-ls[i])*(i+1) ans=p for i in range(n-p): idx=bisect.bisect_right(ls,ls[i]+m) if n-idx>=p: continue totalnow=total-m*(i+1) if totalnow <= 0: ans += 1 continue ok=ac[-p]-ac[i]-(ls[-p]-ls[i])*(i+1)+(ls[i]+m-ls[-p])*(n-p-i) if ok< totalnow: continue ans += 1 print(ans)
[ "assignment.variable.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.branch.if.add" ]
628,698
628,699
u802234509
python
p02824
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 n,m,v,p=map(int,input().split()) A=list(map(int,input().split())) A.sort() # print(A) B=A[:] A.append(inf) for i in range(n-1): B[i+1]+=B[i] i=0 while i < n: count=1 while A[i]==A[i+1]: i+=1; count+=1 K=v-p-(i) # print(i,K,ans) if i>=n-p: ans+=count; i+=1 continue if K<=0: if bisect.bisect_right(A,A[i]+m)>=n-p: ans += count i+=1 else: i+=1 else: if A[n-p]>A[i]+m: i+=1 else: S=B[n-p]-B[i] if (A[i]+m)*(n-p-i)>=S+K*m: ans+=count i+=1 else: i+=1 print(ans)
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 n,m,v,p=map(int,input().split()) A=list(map(int,input().split())) A.sort() # print(A) B=A[:] A.append(inf) for i in range(n-1): B[i+1]+=B[i] i=0 while i < n: count=1 while A[i]==A[i+1]: i+=1; count+=1 K=v-p-(i) # print(i,K,ans) if i>=n-p: ans+=count; i+=1 continue if K<=0: if bisect.bisect_right(A,A[i]+m)>=n-p+1: ans += count i+=1 else: i+=1 else: if A[n-p]>A[i]+m: i+=1 else: S=B[n-p]-B[i] if (A[i]+m)*(n-p-i)>=S+K*m: ans+=count i+=1 else: i+=1 print(ans)
[ "control_flow.branch.if.condition.change" ]
628,755
628,756
u716530146
python
p02824
# B import numpy as np N, M, V, P = map(int, input().split()) A = np.array(input().split(), dtype=int) A = np.sort(A)[::-1] # X(1-origin)ใŒๅ†้Œฒใ•ใ‚Œใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚‹ใ‹ def f(X): # MไบบใŒ, Pใซ็ฅจใ‚’ๅ…ฅใ‚Œใšใ€Xใซๅ…จๆŒฏใ‚Šใ—ใฆๅฏ่ƒฝๆ€งใŒใชใ„ใชใ‚‰็ต‚ไบ† if (A[P-1] > A[X-1] + M): # print("C1") return False # MไบบใŒV2ๅ›žๆŠ•็ฅจใ‚’่กŒใ† V2 = V - (P-1) - 1 - (N-X) if V2 < 0: V2 = 0 # A[P:X]ใฎ็ฏ„ๅ›ฒใซMไบบใŒV2ๅ›žๆŠ•็ฅจใ‚’่กŒใฃใŸใจใใ€Ax = A[X-1] + Mใ‚’่ถ…ใˆใŸใ‚‰็ต‚ไบ†(ๅŒ็‚นใฏOK) # ่‡ชๆ˜Žใซๅฐใ•ใ„Aใซ็ฅจใ‚’ๅ…ฅใ‚Œใ‚‹ Ax = A[X-1] + M RANGE = Ax - A[P:X-1] # ๅ…ˆใซAxใ‹ใ‚‰ๅผ•ใ„ใฆใŠใใฎใงใ€่ฒ ๆ•ฐใซใชใฃใŸใ‚‰็ต‚ไบ† # RANGEใฎๅ„่ฆ็ด ใฏPใพใงๅธๅŽใงใใ‚‹โ†’Mใจmaxใ‚’ใจใฃใฆใ€ๅˆ่จˆๅ€คใŒM*Vไปฅไธ‹ใชใ‚‰OK # print(RANGE) RANGE = np.minimum(RANGE, M) # print(RANGE) # print(np.sum(RANGE), M*V2) return np.sum(RANGE) >= M*V2 # ไบŒๅˆ†ๆŽข็ดข lo, up = P, N while(lo!=up): ta = (lo + up + 1) // 2 # print(lo, up, ta) if f(ta): lo = ta else: up = ta - 1 print(lo)
# B import numpy as np N, M, V, P = map(int, input().split()) A = np.array(input().split(), dtype=int) A = np.sort(A)[::-1] # X(1-origin)ใŒๅ†้Œฒใ•ใ‚Œใ‚‹ๅฏ่ƒฝๆ€งใŒใ‚ใ‚‹ใ‹ def f(X): # MไบบใŒ, Pใซ็ฅจใ‚’ๅ…ฅใ‚Œใšใ€Xใซๅ…จๆŒฏใ‚Šใ—ใฆๅฏ่ƒฝๆ€งใŒใชใ„ใชใ‚‰็ต‚ไบ† if (A[P-1] > A[X-1] + M): # print("C1") return False # MไบบใŒV2ๅ›žๆŠ•็ฅจใ‚’่กŒใ† V2 = V - (P-1) - 1 - (N-X) if V2 < 0: V2 = 0 # A[P:X]ใฎ็ฏ„ๅ›ฒใซMไบบใŒV2ๅ›žๆŠ•็ฅจใ‚’่กŒใฃใŸใจใใ€Ax = A[X-1] + Mใ‚’่ถ…ใˆใŸใ‚‰็ต‚ไบ†(ๅŒ็‚นใฏOK) # ่‡ชๆ˜Žใซๅฐใ•ใ„Aใซ็ฅจใ‚’ๅ…ฅใ‚Œใ‚‹ Ax = A[X-1] + M RANGE = Ax - A[P-1:X-1] # ๅ…ˆใซAxใ‹ใ‚‰ๅผ•ใ„ใฆใŠใใฎใงใ€่ฒ ๆ•ฐใซใชใฃใŸใ‚‰็ต‚ไบ† # RANGEใฎๅ„่ฆ็ด ใฏPใพใงๅธๅŽใงใใ‚‹โ†’Mใจmaxใ‚’ใจใฃใฆใ€ๅˆ่จˆๅ€คใŒM*Vไปฅไธ‹ใชใ‚‰OK # print(RANGE) RANGE = np.minimum(RANGE, M) # print(RANGE) # print(np.sum(RANGE), M*V2) return np.sum(RANGE) >= M*V2 # ไบŒๅˆ†ๆŽข็ดข lo, up = P, N while(lo!=up): ta = (lo + up + 1) // 2 # print(lo, up, ta) if f(ta): lo = ta else: up = ta - 1 print(lo)
[ "assignment.change" ]
628,779
628,780
u663093503
python
p02824
n, m, v, p = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) lim_A = A[p-1] res_A = A[p:] res_n = len(res_A) for i in range(res_n): res_A[i] = lim_A - res_A[i] ans = lim_A cnt = 0 for i in range(res_n): if m >= res_A[i] and m * max(v-p-(res_n-i-1), 0) <= cnt + (m-res_A[i])*(i+1): ans += 1 cnt += res_A[i] print(ans)
n, m, v, p = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) lim_A = A[p-1] res_A = A[p:] res_n = len(res_A) for i in range(res_n): res_A[i] = lim_A - res_A[i] ans = p cnt = 0 for i in range(res_n): if m >= res_A[i] and m * max(v-p-(res_n-i-1), 0) <= cnt + (m-res_A[i])*(i+1): ans += 1 cnt += res_A[i] print(ans)
[ "assignment.value.change", "identifier.change" ]
628,799
628,800
u328364772
python
p02824
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n,m,v,p = LI() a = LI() a.sort(reverse=True) x = a[p-1] a = a[p-1:] l = list(accumulate(a)) ans = p for i in range(n-p): if a[i] + m < x: continue s = (n-(p+i+1))*m + p*m s += (a[i+1] + m) * (i+1) s -= l[i] if s >= m*v: ans += 1 print(ans)
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n,m,v,p = LI() a = LI() a.sort(reverse=True) x = a[p-1] a = a[p-1:] l = list(accumulate(a)) ans = p for i in range(n-p): if a[i+1] + m < x: continue s = (n-(p+i+1))*m + p*m s += (a[i+1] + m) * (i+1) s -= l[i] if s >= m*v: ans += 1 print(ans)
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
628,805
628,806
u191874006
python
p02824
import sys import math import numpy as np stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] n, m, v, p = na() a = na() a.sort(reverse=True) a = np.array(a) left = p - 1 right = n - 1 def check(i): c = a[i] + m s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m)) if i+1 <= p: return True elif a[i] + m < a[p-1]: return False elif s >= m * v: return True else: return False while left + 1 < right: x = (left + right) // 2 if check(x): left = x else: right = x print(left + 1)
import sys import math import numpy as np stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] n, m, v, p = na() a = na() a.sort(reverse=True) a = np.array(a) left = p - 1 right = n def check(i): c = a[i] + m s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m)) if i+1 <= p: return True elif a[i] + m < a[p-1]: return False elif s >= m * v: return True else: return False while left + 1 < right: x = (left + right) // 2 if check(x): left = x else: right = x print(left + 1)
[ "expression.operation.binary.remove" ]
628,809
628,810
u524870111
python
p02824
import sys import math import numpy as np stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] n, m, v, p = na() a = na() a.sort(reverse=True) a = np.array(a) print(a) left = 0 right = n def check(i): c = a[i] + m s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m)) if i+1 <= p: return True elif a[i] + m < a[p-1]: return False elif s >= m * v: return True else: return False while left + 1 < right: x = (left + right) // 2 if check(x): left = x else: right = x print(left + 1)
import sys import math import numpy as np stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] n, m, v, p = na() a = na() a.sort(reverse=True) a = np.array(a) left = 0 right = n def check(i): c = a[i] + m s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m)) if i+1 <= p: return True elif a[i] + m < a[p-1]: return False elif s >= m * v: return True else: return False while left + 1 < right: x = (left + right) // 2 if check(x): left = x else: right = x print(left + 1)
[ "call.remove" ]
628,811
628,812
u524870111
python
p02824
import sys import math import numpy as np stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] n, m, v, p = na() a = na() a.sort(reverse=True) a = np.array(a) left = p - 1 right = n - 1 def check(i): c = a[i] + m s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m)) if i+1 <= p: return True elif a[i] + m < a[p-1]: return False elif s >= m * v: return True else: return False while left + 1 < right: x = (left + right) // 2 if check(x): left = x else: right = x print(left + 1)
import sys import math import numpy as np stdin = sys.stdin mod = 10**9 + 7 ns = lambda: stdin.readline().rstrip() ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)] n, m, v, p = na() a = na() a.sort(reverse=True) a = np.array(a) left = 0 right = n def check(i): c = a[i] + m s = (p-1) * m + np.sum(np.minimum(c - a[p-1:], m)) if i+1 <= p: return True elif a[i] + m < a[p-1]: return False elif s >= m * v: return True else: return False while left + 1 < right: x = (left + right) // 2 if check(x): left = x else: right = x print(left + 1)
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "expression.operation.binary.remove" ]
628,809
628,812
u524870111
python
p02824
import sys input = sys.stdin.readline N, M, V, P = map(int, input().split()) a = list(map(int, input().split())) a.sort() ng = -1 ok = N - P #print(a) def check(x): vs = M * V p = N for i in range(N): if a[i] > a[x] + M: p = i - 1 break #print(x, vs, p) if p < N - P: return False #print(x, vs) for i in range(N - P + 1, N): vs -= M #print(x, vs) for i in range(N - P): vs -= min(max(a[x] + M - a[i], 0), M) #print(x, vs) return vs <= 0 while ok - ng > 1: m = (ok + ng) // 2 if check(m): ok = m else: ng = m print(N - (ng + 1))
import sys input = sys.stdin.readline N, M, V, P = map(int, input().split()) a = list(map(int, input().split())) a.sort() ng = -1 ok = N - P #print(a) def check(x): vs = M * V p = N for i in range(N): if a[i] > a[x] + M: p = i - 1 break #print(x, vs, p) if p < N - P: return False #print(x, vs) for i in range(N - P + 1, N): vs -= M #print(x, vs) for i in range(N - P + 1): vs -= min(max(a[x] + M - a[i], 0), M) #print(x, vs) return vs <= 0 while ok - ng > 1: m = (ok + ng) // 2 if check(m): ok = m else: ng = m print(N - (ng + 1))
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
628,815
628,816
u141610915
python
p02824
import sys input = sys.stdin.readline N, M, V, P = map(int, input().split()) a = list(map(int, input().split())) a.sort() ng = -1 ok = N - P #print(a) def check(x): vs = M * V p = N for i in range(N): if a[i] > a[x] + M: p = i break #print(x, vs, p) if p < N - P: return False #print(x, vs) for i in range(N - P + 1, N): vs -= M #print(x, vs) for i in range(N - P): vs -= min(max(a[x] + M - a[i], 0), M) #print(x, vs) return vs <= 0 while ok - ng > 1: m = (ok + ng) // 2 if check(m): ok = m else: ng = m print(N - (ng + 1))
import sys input = sys.stdin.readline N, M, V, P = map(int, input().split()) a = list(map(int, input().split())) a.sort() ng = -1 ok = N - P #print(a) def check(x): vs = M * V p = N for i in range(N): if a[i] > a[x] + M: p = i - 1 break #print(x, vs, p) if p < N - P: return False #print(x, vs) for i in range(N - P + 1, N): vs -= M #print(x, vs) for i in range(N - P + 1): vs -= min(max(a[x] + M - a[i], 0), M) #print(x, vs) return vs <= 0 while ok - ng > 1: m = (ok + ng) // 2 if check(m): ok = m else: ng = m print(N - (ng + 1))
[ "assignment.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
628,817
628,816
u141610915
python
p02824
n,m,v,p=map(int,input().split()) A=sorted(list(map(int,input().split())))[-p::-1] s=0;p-=1 for u,a in enumerate(A): if a>=A[0]-m and u*a+m*n-m*v>=s:s+=a;p+=1 print(p)
n,m,v,p=map(int,input().split()) A=sorted(list(map(int,input().split())))[-p::-1] s=0;p-=1 for u,a in enumerate(A): if a<A[0]-m or u*a+m*n-m*v<s:break s+=a;p+=1 print(p)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.break.add" ]
628,820
628,821
u956530786
python
p02824
# A[i]ใŒๆŽก็”จใ•ใ‚Œใ‚‹ใจใใ€A[i-1]ใ‚‚ๆŽก็”จใ•ใ‚Œใ‚‹ใจใ„ใ†ๅ˜่ชฟๆ€งใŒใ‚ใ‚‹ใฎใงไบŒๅˆ†ๆŽข็ดขใง่งฃใ N, M, V, P = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) capacity = M * (N-V) def isOK(i): ai = A[i] # ๅŸบๆบ–ใจใชใ‚‹ๅ€ค s = 0 # 0~P-2็•ช็›ฎใฎP-1ๅ•ใจi็•ช็›ฎใจi็•ช็›ฎไปฅ้™ใซใฏๅ…จๅ“กใŒๆŠ•็ฅจใ—ใฆใ‚‚ๆง‹ใ‚ใชใ„ # P-1็•ช็›ฎใ‹ใ‚‰i-1็•ช็›ฎใพใงใซใคใ„ใฆ่€ƒใˆใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ for j in range(P-i, i): d = A[j] - ai # A[j]ใจaiใฎๅทฎใŒMไปฅไธŠใ‚ใ‚‹ใจใ„ใ†ใ“ใจใฏใ€A[0]ใ‹ใ‚‰A[j-1]ใพใงใ‚‚ๅทฎใŒMไปฅไธŠใ‚ใ‚Š่ฟฝใ„ใคใ‘ใชใ„ if d > M: # ใ“ใฎๆ™‚็‚นใงๅ…ˆ้ ญใฎA[j]ๅ•ใ‚’ๅซใ‚€ๅ…ˆ้ ญใฎๅ•้กŒใŸใกใฏaiใŒ่ฟฝใ„ใคใ‘ใชใ„ใ‚นใ‚ณใ‚ขใ‚’ใ‚‚ใฃใฆใ„ใ‚‹ return False s += d if s > capacity: return False else: return True left = -1 right = N while right - left > 1: mid = right + (left-right)//2 if isOK(mid): # ไธญๅคฎๅ€คใŒๆบ€ใŸใ™ใชใ‚‰ไธ‹็•Œใ‚’ใ‚ใ’ใ‚‹ left = mid else: # ไธญๅคฎๅ€คใŒๆบ€ใŸใ•ใชใ„ใชใ‚‰ไธŠ็•Œใ‚’ไธ‹ใ’ใ‚‹ right = mid print(left + 1)
# A[i]ใŒๆŽก็”จใ•ใ‚Œใ‚‹ใจใใ€A[i-1]ใ‚‚ๆŽก็”จใ•ใ‚Œใ‚‹ใจใ„ใ†ๅ˜่ชฟๆ€งใŒใ‚ใ‚‹ใฎใงไบŒๅˆ†ๆŽข็ดขใง่งฃใ N, M, V, P = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) capacity = M * (N-V) def isOK(i): ai = A[i] # ๅŸบๆบ–ใจใชใ‚‹ๅ€ค s = 0 # 0~P-2็•ช็›ฎใฎP-1ๅ•ใจi็•ช็›ฎใจi็•ช็›ฎไปฅ้™ใซใฏๅ…จๅ“กใŒๆŠ•็ฅจใ—ใฆใ‚‚ๆง‹ใ‚ใชใ„ # P-1็•ช็›ฎใ‹ใ‚‰i-1็•ช็›ฎใพใงใซใคใ„ใฆ่€ƒใˆใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ for j in range(P-1, i): d = A[j] - ai # A[j]ใจaiใฎๅทฎใŒMไปฅไธŠใ‚ใ‚‹ใจใ„ใ†ใ“ใจใฏใ€A[0]ใ‹ใ‚‰A[j-1]ใพใงใ‚‚ๅทฎใŒMไปฅไธŠใ‚ใ‚Š่ฟฝใ„ใคใ‘ใชใ„ if d > M: # ใ“ใฎๆ™‚็‚นใงๅ…ˆ้ ญใฎA[j]ๅ•ใ‚’ๅซใ‚€ๅ…ˆ้ ญใฎๅ•้กŒใŸใกใฏaiใŒ่ฟฝใ„ใคใ‘ใชใ„ใ‚นใ‚ณใ‚ขใ‚’ใ‚‚ใฃใฆใ„ใ‚‹ return False s += d if s > capacity: return False else: return True left = -1 right = N while right - left > 1: mid = (right+left)//2 if isOK(mid): # ไธญๅคฎๅ€คใŒๆบ€ใŸใ™ใชใ‚‰ไธ‹็•Œใ‚’ใ‚ใ’ใ‚‹ left = mid else: # ไธญๅคฎๅ€คใŒๆบ€ใŸใ•ใชใ„ใชใ‚‰ไธŠ็•Œใ‚’ไธ‹ใ’ใ‚‹ right = mid print(left + 1)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.remove" ]
628,824
628,825
u708255304
python
p02824
# A[i]ใŒๆŽก็”จใ•ใ‚Œใ‚‹ใจใใ€A[i-1]ใ‚‚ๆŽก็”จใ•ใ‚Œใ‚‹ใจใ„ใ†ๅ˜่ชฟๆ€งใŒใ‚ใ‚‹ใฎใงไบŒๅˆ†ๆŽข็ดขใง่งฃใ N, M, V, P = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) capacity = M * (N-V) def isOK(i): ai = A[i] # ๅŸบๆบ–ใจใชใ‚‹ๅ€ค s = 0 # 0~P-2็•ช็›ฎใฎP-1ๅ•ใจi็•ช็›ฎใจi็•ช็›ฎไปฅ้™ใซใฏๅ…จๅ“กใŒๆŠ•็ฅจใ—ใฆใ‚‚ๆง‹ใ‚ใชใ„ # P-1็•ช็›ฎใ‹ใ‚‰i-1็•ช็›ฎใพใงใซใคใ„ใฆ่€ƒใˆใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ for j in range(P-i, i): d = A[j] - ai # A[j]ใจaiใฎๅทฎใŒMไปฅไธŠใ‚ใ‚‹ใจใ„ใ†ใ“ใจใฏใ€A[0]ใ‹ใ‚‰A[j-1]ใพใงใ‚‚ๅทฎใŒMไปฅไธŠใ‚ใ‚Š่ฟฝใ„ใคใ‘ใชใ„ if d > M: # ใ“ใฎๆ™‚็‚นใงๅ…ˆ้ ญใฎA[j]ๅ•ใ‚’ๅซใ‚€ๅ…ˆ้ ญใฎๅ•้กŒใŸใกใฏaiใŒ่ฟฝใ„ใคใ‘ใชใ„ใ‚นใ‚ณใ‚ขใ‚’ใ‚‚ใฃใฆใ„ใ‚‹ return False s += d if s > capacity: return False else: return True left = -1 right = N while right - left > 1: mid = right + (left-right)//2 if isOK(mid): # ไธญๅคฎๅ€คใŒๆบ€ใŸใ™ใชใ‚‰ไธ‹็•Œใ‚’ใ‚ใ’ใ‚‹ left = mid else: # ไธญๅคฎๅ€คใŒๆบ€ใŸใ•ใชใ„ใชใ‚‰ไธŠ็•Œใ‚’ไธ‹ใ’ใ‚‹ right = mid print(left + 1)
# A[i]ใŒๆŽก็”จใ•ใ‚Œใ‚‹ใจใใ€A[i-1]ใ‚‚ๆŽก็”จใ•ใ‚Œใ‚‹ใจใ„ใ†ๅ˜่ชฟๆ€งใŒใ‚ใ‚‹ใฎใงไบŒๅˆ†ๆŽข็ดขใง่งฃใ N, M, V, P = map(int, input().split()) A = sorted(list(map(int, input().split())), reverse=True) capacity = M * (N-V) def isOK(i): ai = A[i] # ๅŸบๆบ–ใจใชใ‚‹ๅ€ค s = 0 # 0~P-2็•ช็›ฎใฎP-1ๅ•ใจi็•ช็›ฎใจi็•ช็›ฎไปฅ้™ใซใฏๅ…จๅ“กใŒๆŠ•็ฅจใ—ใฆใ‚‚ๆง‹ใ‚ใชใ„ # P-1็•ช็›ฎใ‹ใ‚‰i-1็•ช็›ฎใพใงใซใคใ„ใฆ่€ƒใˆใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ for j in range(P-1, i): d = A[j] - ai # A[j]ใจaiใฎๅทฎใŒMไปฅไธŠใ‚ใ‚‹ใจใ„ใ†ใ“ใจใฏใ€A[0]ใ‹ใ‚‰A[j-1]ใพใงใ‚‚ๅทฎใŒMไปฅไธŠใ‚ใ‚Š่ฟฝใ„ใคใ‘ใชใ„ if d > M: # ใ“ใฎๆ™‚็‚นใงๅ…ˆ้ ญใฎA[j]ๅ•ใ‚’ๅซใ‚€ๅ…ˆ้ ญใฎๅ•้กŒใŸใกใฏaiใŒ่ฟฝใ„ใคใ‘ใชใ„ใ‚นใ‚ณใ‚ขใ‚’ใ‚‚ใฃใฆใ„ใ‚‹ return False s += d if s > capacity: return False else: return True left = -1 right = N while right - left > 1: mid = right + (left-right)//2 if isOK(mid): # ไธญๅคฎๅ€คใŒๆบ€ใŸใ™ใชใ‚‰ไธ‹็•Œใ‚’ใ‚ใ’ใ‚‹ left = mid else: # ไธญๅคฎๅ€คใŒๆบ€ใŸใ•ใชใ„ใชใ‚‰ไธŠ็•Œใ‚’ไธ‹ใ’ใ‚‹ right = mid print(left + 1)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
628,824
628,826
u708255304
python
p02824
from itertools import * n, m, v, p, *a = map(int, open(0).read().split()) a.sort(reverse=True) acc = list(accumulate(a)) + [0] ok, ng = p - 1, n while ng - ok > 1: mid = (ok + ng) // 2 if a[mid] + m > a[p - 1] and (a[mid] + m) * (mid - p + 1) - (acc[mid - 1] - acc[p - 2]) >= m * ( v - (p - 1) - (n - mid)): ok = mid else: ng = mid print(ok + 1)
from itertools import * n,m,v,p,*a=map(int,open(0).read().split()) a.sort(reverse=True) acc=list(accumulate(a))+[0] ok,ng=p-1,n while ng-ok>1: mid=(ok+ng)//2 if a[mid]+m>=a[p-1] and (a[mid]+m)*(mid-p+1)-(acc[mid-1]-acc[p-2])>=m*(v-(p-1)-(n-mid)): ok=mid else: ng=mid print(ok+1)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
628,856
628,857
u670180528
python
p02824
n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) def can_be_used(x): # x: 0-index if x < p: return True if a[x] + m < a[p-1]: return False vote_max = (p - 1 + n - x) * m for i in range(p-1, x): vote_max += a[x] + m - a[i] if vote_max < m * v: return False return True l = 0 r = n - 1 while r - l > 1: mid = (l + r) // 2 if can_be_used(mid): l = mid else: r = mid ans = l + 1 print(ans)
n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) def can_be_used(x): # x: 0-index if x < p: return True if a[x] + m < a[p-1]: return False vote_max = (p - 1 + n - x) * m for i in range(p-1, x): vote_max += a[x] + m - a[i] if vote_max < m * v: return False return True l = 0 r = n while r - l > 1: mid = (l + r) // 2 if can_be_used(mid): l = mid else: r = mid ans = l + 1 print(ans)
[ "expression.operation.binary.remove" ]
628,865
628,866
u893063840
python
p02824
N, M, V, P = map(int, input().split()) As = list(map(int, input().split())) As.sort(reverse=True) scoreP = As[P-1] def isOK(k): if k < P or As[k] == scoreP: return True scoreK = As[k] + M if scoreK < scoreP: return False rest = M*(V-1) rest -= M*(P-1) if rest <= 0: return True for i in range(P, N): if i != k: rest -= min(M, scoreK-As[i]) if rest <= 0: return True return False ng, ok = N, -1 while abs(ok-ng) > 1: mid = (ng+ok) // 2 if isOK(mid): ok = mid else: ng = mid print(ok+1)
N, M, V, P = map(int, input().split()) As = list(map(int, input().split())) As.sort(reverse=True) scoreP = As[P-1] def isOK(k): if k < P or As[k] == scoreP: return True scoreK = As[k] + M if scoreK < scoreP: return False rest = M*(V-1) rest -= M*(P-1) if rest <= 0: return True for i in range(P-1, N): if i != k: rest -= min(M, scoreK-As[i]) if rest <= 0: return True return False ng, ok = N, -1 while abs(ok-ng) > 1: mid = (ng+ok) // 2 if isOK(mid): ok = mid else: ng = mid print(ok+1)
[ "control_flow.loop.range.bounds.lower.change", "expression.operation.binary.add" ]
628,878
628,879
u297574184
python
p02824
import sys from bisect import * sys.setrecursionlimit(10**9) INF=10**18 def input(): return sys.stdin.readline().rstrip() def main(): def nibutan(ok,ng): while abs(ok-ng) > 1: mid = (ok + ng) // 2 if solve(mid): ok = mid else: ng = mid return ok N,M,V,P=map(int,input().split()) A=sorted(list(map(int,input().split()))) def solve(mid): point=A[mid]+M z=0 c=0 i=1 while c<P-1: if N-i!=mid: z+=min(M+A[N-i]-point,M) c+=1 i+=1 for i in range(N): if i!=mid: z+=min(M,max(point-A[i],0)) if point>=A[N-P] and z>=M*(V-1): return True else: return False print(N-nibutan(N-1,-1)) if __name__ == '__main__': main()
import sys from bisect import * sys.setrecursionlimit(10**9) INF=10**18 def input(): return sys.stdin.readline().rstrip() def main(): def nibutan(ok,ng): while abs(ok-ng) > 1: mid = (ok + ng) // 2 if solve(mid): ok = mid else: ng = mid return ok N,M,V,P=map(int,input().split()) A=sorted(list(map(int,input().split()))) def solve(mid): point=A[mid]+M z=0 c=0 i=1 while c<P-1: if N-i!=mid: z+=max(min(M+A[N-i]-point,M),0) c+=1 i+=1 for i in range(N): if i!=mid: z+=min(M,max(point-A[i],0)) if point>=A[N-P] and z>=M*(V-1): return True else: return False print(N-nibutan(N-1,-1)) if __name__ == '__main__': main()
[ "call.add", "call.arguments.add" ]
628,904
628,905
u714642969
python
p02824
n,m,v,p = map(int, input().split()) a = sorted(list(map(int, input().split())), reverse=True) #ใ€€ใ›ใฃใ‹ใใชใฎใงใ‚ใจใงmarginใ‚’ๅ‰่จˆ็ฎ—ใ—ใฆm*vไปฅไธŠใ‚’bisect def isOK(x): border = a[x-1] if border + m < a[p-1]: return False elif x <= p: return True else: margin = m * n for i in range(p-1,x-1): margin -= a[i] - border if margin >= m * v: return True else: return False def binary_search(): ok = p-1 ng = n while abs(ok-ng) > 1: mid = (ok+ng)//2 if isOK(mid): ok = mid else: ng = mid return ok ans = binary_search() print(ans)
n,m,v,p = map(int, input().split()) a = sorted(list(map(int, input().split())), reverse=True) #ใ€€ใ›ใฃใ‹ใใชใฎใงใ‚ใจใงmarginใ‚’ๅ‰่จˆ็ฎ—ใ—ใฆm*vไปฅไธŠใ‚’bisect def isOK(x): border = a[x-1] if border + m < a[p-1]: return False elif x <= p: return True else: margin = m * n for i in range(p-1,x-1): margin -= a[i] - border if margin >= m*v: return True else: return False def binary_search(): ok = p-1 ng = n+1 while abs(ok-ng) > 1: mid = (ok+ng)//2 if isOK(mid): ok = mid else: ng = mid return ok ans = binary_search() print(ans)
[ "assignment.change" ]
628,922
628,923
u102960641
python
p02824
N,M,V,P = map(int,input().split()) import numpy as np A = list(map(int,input().split())) A = np.array(sorted(A,reverse=True)) ans = P x = A[P-1] y = N-1 for i in range(P,N): a = A[i] if x==a: ans+=1 else: y=i break z = sum(A[P-1:y]) for i in range(y,N): a = A[i] d = a+M if x<=d: b = N-i+P-1 c = M*(V-b) e = z+c f = d*(i-P+1) if f>=e: ans+=1 z+=a print(ans)
N,M,V,P = map(int,input().split()) import numpy as np A = list(map(int,input().split())) A = np.array(sorted(A,reverse=True)) ans = P x = A[P-1] y = N for i in range(P,N): a = A[i] if x==a: ans+=1 else: y=i break z = sum(A[P-1:y]) for i in range(y,N): a = A[i] d = a+M if x<=d: b = N-i+P-1 c = M*(V-b) e = z+c f = d*(i-P+1) if f>=e: ans+=1 z+=a print(ans)
[ "expression.operation.binary.remove" ]
628,937
628,938
u268554510
python
p02824
N,M,V,P = map(int,input().split()) import numpy as np A = list(map(int,input().split())) A = np.array(sorted(A,reverse=True)) ans = P x = A[P-1] for i in range(P,N): a = A[i] if x==a: ans+=1 else: y=i break z = sum(A[P-1:y]) for i in range(y,N): a = A[i] d = a+M if x<=d: b = N-i+P-1 c = M*(V-b) e = z+c f = d*(i-P+1) if f>=e: ans+=1 z+=a print(ans)
N,M,V,P = map(int,input().split()) import numpy as np A = list(map(int,input().split())) A = np.array(sorted(A,reverse=True)) ans = P x = A[P-1] y = N for i in range(P,N): a = A[i] if x==a: ans+=1 else: y=i break z = sum(A[P-1:y]) for i in range(y,N): a = A[i] d = a+M if x<=d: b = N-i+P-1 c = M*(V-b) e = z+c f = d*(i-P+1) if f>=e: ans+=1 z+=a print(ans)
[ "assignment.add" ]
628,939
628,938
u268554510
python
p02824
import sys def I(): return int(sys.stdin.readline()) def LI(): return [int(x) for x in sys.stdin.readline().split()] N,M,V,P = LI() A = LI() A.sort() def check(x): if (N-x)<=P: return True x_score = A[x] + M if (V-x-P) <= 0: return(A[N-P]<=x_score) total_v = (V-x-P)*M if(A[N-P]>x_score): return False for i in range(x+1,N-P+1): total_v -= min(M,(x_score - A[i])) if(total_v<0): return True return False def main(): if(check(0)): print(N) return isOK = N-1 isNG = 0 while(isOK-isNG>1): mid = (isOK+isNG)//2 if(check(mid)): isOK = mid else: isNG = mid print(N-isOK) return if __name__ == "__main__": main()
import sys def I(): return int(sys.stdin.readline()) def LI(): return [int(x) for x in sys.stdin.readline().split()] N,M,V,P = LI() A = LI() A.sort() def check(x): if (N-x)<=P: return True x_score = A[x] + M if (V-x-P) <= 0: return(A[N-P]<=x_score) total_v = (V-x-P)*M if(A[N-P]>x_score): return False for i in range(x+1,N-P+1): total_v -= min(M,(x_score - A[i])) if(total_v>0): return False return True def main(): if(check(0)): print(N) return isOK = N-1 isNG = 0 while(isOK-isNG>1): mid = (isOK+isNG)//2 if(check(mid)): isOK = mid else: isNG = mid print(N-isOK) return if __name__ == "__main__": main()
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.return.remove", "control_flow.return.add" ]
628,962
628,963
u118642796
python
p02824
from bisect import bisect_left n,m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort() if v >= p: l, r = -1, n - p - 1 while r - l > 1: flg = 0 med = (l + r) // 2 t = (v - p) * m for i in range(n - p + 1): if a[med] + m < a[i]: flg = 1 break for i in range(n - p + 1): if i == med: continue t -= min(m, a[med] + m - a[i]) if t > 0: flg = 1 if flg: l = med else: r = med print(n - r) else: exit(1) print(n - bisect_left(a,a[n - p] - m))
from bisect import bisect_left n,m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort() if v >= p: l, r = -1, n - p while r - l > 1: flg = 0 med = (l + r) // 2 t = (v - p) * m for i in range(n - p + 1): if a[med] + m < a[i]: flg = 1 break for i in range(n - p + 1): if i == med: continue t -= min(m, a[med] + m - a[i]) if t > 0: flg = 1 if flg: l = med else: r = med print(n - r) else: print(n - bisect_left(a,a[n - p] - m))
[ "expression.operation.binary.remove", "call.remove" ]
628,977
628,978
u143509139
python
p02824
from bisect import bisect_left n,m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort() if v >= p: l, r = -1, n - p - 1 while r - l > 1: flg = 0 med = (l + r) // 2 t = max(v - p, 0) * m for i in range(n - p + 1): if a[med] + m < a[i]: flg = 1 break for i in range(n - p + 1): if i == med: continue t -= min(m, a[med] + m - a[i]) if t > 0: flg = 1 if flg: l = med else: r = med print(n - r) else: print(n - bisect_left(a,a[n - p] - m))
from bisect import bisect_left n,m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort() if v >= p: l, r = -1, n - p while r - l > 1: flg = 0 med = (l + r) // 2 t = (v - p) * m for i in range(n - p + 1): if a[med] + m < a[i]: flg = 1 break for i in range(n - p + 1): if i == med: continue t -= min(m, a[med] + m - a[i]) if t > 0: flg = 1 if flg: l = med else: r = med print(n - r) else: print(n - bisect_left(a,a[n - p] - m))
[ "expression.operation.binary.remove", "call.arguments.change" ]
628,979
628,978
u143509139
python
p02824
def main(): n, m, v, p = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) # print(a) def value(i): if i+p >= n: return True if a[n-p] > a[i]+m: return False b = list(reversed([a[i]+m-j for j in a[:i] + a[i+1:n]]))[p-2:] # print(b) if b[0] < 0: return False rest = v-n+len(b) if rest <= 0: return False # print(rest) c = [min(m, i) for i in b] d = [i for i in c][:-rest] e = [m-i for i in c][-rest:] #print(d, e) if sum(d) < sum(e): return False else: return True def b_search(a, b, value): while a+1 < b: med = (a+b)//2 if value(med): b = med else: a = med+1 if a == b: return a else: if value(a): return a else: return b # print(value(2)) print(n-b_search(0, n-1, value)) main()
def main(): n, m, v, p = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) # print(a) def value(i): if i+p >= n: return True if a[n-p] > a[i]+m: return False b = list(reversed([a[i]+m-j for j in a[:i] + a[i+1:n]]))[p-1:] #print(b) if b[0] < 0: return False rest = v-n+len(b) if rest <= 0: return True #print(rest) c = [min(m, i) for i in b] d = [i for i in c][:-rest] e = [m-i for i in c][-rest:] #print(d, e) if sum(d) < sum(e): return False else: return True def b_search(a, b, value): while a+1 < b: med = (a+b)//2 if value(med): b = med else: a = med+1 if a == b: return a else: if value(a): return a else: return b #print(value(1)) print(n-b_search(0, n-1, value)) main()
[ "literal.number.integer.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "misc.opposites", "function.return_value.change" ]
628,984
628,986
u532966492
python
p02824
N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A = list(reversed(sorted(A))) def ok(x): if x + M < A[P]: return False sc = M * V for a in A[:P-1]: sc = sc - M for a in A[P-1:]: sc = sc - min(M, x + M - a) return sc <= 0 l, r = -1, N while r - l > 1: m = l + (r - l) // 2 if not ok(A[m]): r = m else: l = m print(r)
N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A = list(reversed(sorted(A))) def ok(x): if x + M < A[P-1]: return False sc = M * V for a in A[:P-1]: sc = sc - M for a in A[P-1:]: sc = sc - min(M, x + M - a) return sc <= 0 l, r = -1, N while r - l > 1: m = l + (r - l) // 2 if not ok(A[m]): r = m else: l = m print(r)
[ "control_flow.branch.if.condition.change" ]
628,987
628,988
u382423941
python
p02824
N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A = list(reversed(sorted(A))) def ok(x): if x + M < A[P]: return False sc = M * V for a in A[:P-1]: sc = sc - M for a in A[P:]: sc = sc - min(M, x + M - a) return sc <= 0 l, r = -1, N while r - l > 1: m = l + (r - l) // 2 if not ok(A[m]): r = m else: l = m print(r)
N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A = list(reversed(sorted(A))) def ok(x): if x + M < A[P-1]: return False sc = M * V for a in A[:P-1]: sc = sc - M for a in A[P-1:]: sc = sc - min(M, x + M - a) return sc <= 0 l, r = -1, N while r - l > 1: m = l + (r - l) // 2 if not ok(A[m]): r = m else: l = m print(r)
[ "control_flow.branch.if.condition.change" ]
628,989
628,988
u382423941
python
p02824
def check(i, N, M, V, P, A): K = N - V tot = sum(A[(P-1):i]) - A[i]*(i-(P-1)) if K*M >= tot and (A[P-1]-A[i])<=N: return True else: return False N, M, V, P = map(int,input().split()) A = [int(i) for i in input().split()] A.sort(reverse=True) start = P end = N-1 if check(end, N, M, V, P, A): print(N) elif not check(start, N, M, V, P, A): print(P) else: while True: if (end - start) == 1: break new = (start + end)//2 flag = check(new, N, M, V, P, A) if flag: start = new else: end = new print(start+1)
def check(i, N, M, V, P, A): K = N - V tot = sum(A[(P-1):i]) - A[i]*(i-(P-1)) if K*M >= tot and (A[P-1]-A[i])<=M: return True else: return False N, M, V, P = map(int,input().split()) A = [int(i) for i in input().split()] A.sort(reverse=True) start = P end = N-1 if check(end, N, M, V, P, A): print(N) elif not check(start, N, M, V, P, A): print(P) else: while True: if (end - start) == 1: break new = (start + end)//2 flag = check(new, N, M, V, P, A) if flag: start = new else: end = new print(start+1)
[ "identifier.change", "control_flow.branch.if.condition.change" ]
629,009
629,010
u749359783
python
p02824
n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort() a = a[::-1] s = [0] * p for i in range(p, n + 1): s.append(s[-1] + a[i - 1]) s = s[1:] ans = 0 for i in range(1, n + 1): if i <= p: ans += 1 else: if v - 1 <= p - 1: if a[i - 1] + m >= a[p - 1]: ans += 1 else: if v - p <= n - i: if a[i - 1] + m >= a[p - 1]: ans += 1 else: if a[i - 1] + m < a[p - 1]: continue elif a[i-1] * (i - p) >= m * (v - n) + s[i - 1]: ans += 1 print(ans)
n, m, v, p = map(int, input().split()) a = list(map(int, input().split())) a.sort() a = a[::-1] s = [0] * p for i in range(p, n + 1): s.append(s[-1] + a[i - 1]) s = s[1:] ans = 0 for i in range(1, n + 1): if i <= p: ans += 1 else: if v - 1 <= p - 1: if a[i - 1] + m >= a[p - 1]: ans += 1 else: if v - p <= n - i: if a[i - 1] + m >= a[p - 1]: ans += 1 else: if a[i - 1] + m < a[p - 1]: continue elif a[i-1] * (i - p) >= m * (v - n) + s[i - 2]: ans += 1 print(ans)
[ "literal.number.integer.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
629,013
629,014
u470542271
python
p02824
from bisect import bisect_right as br n,m,v,p=map(int,input().split()) a=sorted(list(map(int,input().split()))) l,r=n,0 while l-r>1: t=(l+r)//2 s=a[t]+m w=a[:] k=m*(v-1) for i in range(n): if i!=t: if i<t: c=min(k,m) k-=c w[i]+=c else: if w[i]>=s: break else: c=min(k,s-w[i]) k-=c w[i]+=c if k==0: break if k>0: for j in range(n-1,-1,-1): if j!=t: g=min(k,m-w[j]+a[j]) w[j]+=g k-=g if k==0: break w.pop(t) w=sorted(w) if n-br(w,s)<=p: l=t else: r=t print(n-l)
from bisect import bisect_right as br n,m,v,p=map(int,input().split()) a=sorted(list(map(int,input().split()))) l,r=n,-1 while l-r>1: t=(l+r)//2 s=a[t]+m w=a[:] k=m*(v-1) for i in range(n): if i!=t: if i<t: c=min(k,m) k-=c w[i]+=c else: if w[i]>=s: break else: c=min(k,s-w[i]) k-=c w[i]+=c if k==0: break if k>0: for j in range(n-1,-1,-1): if j!=t: g=min(k,m-w[j]+a[j]) w[j]+=g k-=g if k==0: break w.pop(t) w=sorted(w) if n-br(w,s)<=p: l=t else: r=t print(n-l)
[ "assignment.value.change", "expression.operation.unary.add" ]
629,041
629,042
u619819312
python
p02824
N,M,V,P = map(int,input().split()) A = list(map(int,input().split())) A = sorted(A) S = sum(A) for i in range(P-1): x = A.pop() S -= x print(A) total_score = M*(V-P+1) kazu = N - P + 1 for i in range(N-P+1): a = A.pop(0) total_score -= M S -= a kazu -= 1 T = (M+a)*kazu - S if i == N - P: ans = P else: if (a+M) >= A[-1]: if T >= total_score: ans = kazu + P break print(ans)
N,M,V,P = map(int,input().split()) A = list(map(int,input().split())) A = sorted(A) S = sum(A) for i in range(P-1): x = A.pop() S -= x total_score = M*(V-P+1) kazu = N - P + 1 for i in range(N-P+1): a = A.pop(0) total_score -= M S -= a kazu -= 1 T = (M+a)*kazu - S if i == N - P: ans = P else: if (a+M) >= A[-1]: if T >= total_score: ans = kazu + P break print(ans)
[ "call.remove" ]
629,047
629,048
u557494880
python
p02824
import bisect N,M,V,P=map(int,input().split()) A=list(map(int,input().split())) A.sort() def is_ok(ind): bigs = bisect.bisect_right(A,A[ind]+M) if N-bigs >= P: return False votes = M*(V-1) j = 0 for i in range(N-1,-1,-1): if i==ind: continue if j < P-1: votes = max(votes-M,0) else: cur = min(A[ind]+M,A[i]+M,A[i]+votes) votes -= max(0,cur-A[i]) j += 1 if votes == 0: return True else: return False lo = -1 hi = N mid = (lo+hi)//2 while lo < hi: mid = (lo+hi)//2 if is_ok(mid): hi = mid else: lo = mid+1 print(N-hi)
import bisect N,M,V,P=map(int,input().split()) A=list(map(int,input().split())) A.sort() def is_ok(ind): bigs = bisect.bisect_right(A,A[ind]+M) if N-bigs >= P: return False votes = M*(V-1) j = 0 for i in range(N-1,-1,-1): if i==ind: continue if j < P-1: votes = max(votes-M,0) else: cur = min(A[ind]+M,A[i]+M,A[i]+votes) votes -= max(0,cur-A[i]) j += 1 if votes == 0: return True else: return False lo = 0 hi = N mid = (lo+hi)//2 while lo < hi: mid = (lo+hi)//2 if is_ok(mid): hi = mid else: lo = mid+1 print(N-hi)
[ "assignment.value.change", "expression.operation.unary.remove" ]
629,065
629,066
u375076148
python
p02824
from bisect import bisect_right N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A.sort() A_m = sorted(set(A)) n = len(A_m) ok = n-1 ng = -1 while ng+1 < ok: c = (ok+ng)//2 a = A_m[c] idx = bisect_right(A, a) if idx >= N-P: ok = c continue if M < A[-P]-a: ng = c continue s = 0 for aa in A[-P:idx-1:-1]: s += aa-a if s > M*(N-V): ng = c else: ok = c a = A_m[ok] print(sum(a<=aa for aa in A))
from bisect import bisect_right N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A.sort() A_m = sorted(set(A)) n = len(A_m) ok = n-1 ng = -1 while ng+1 < ok: c = (ok+ng)//2 a = A_m[c] idx = bisect_right(A, a) if idx > N-P: ok = c continue if M < A[-P]-a: ng = c continue s = 0 for aa in A[-P:idx-1:-1]: s += aa-a if s > M*(N-V): ng = c else: ok = c a = A_m[ok] print(sum(a<=aa for aa in A))
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
629,074
629,075
u467736898
python
p02824
from bisect import bisect_right N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A.sort() A_m = sorted(set(A)) n = len(A_m) ok = n-1 ng = -1 while ng+1 < ok: c = (ok+ng)//2 a = A_m[c] idx = bisect_right(A, a) if idx >= N-P: ok = c continue if N-V < A[-P]-a: ng = c continue s = 0 for aa in A[-P:idx-1:-1]: s += aa-a if s > M*(N-V): ng = c else: ok = c a = A_m[ok] print(sum(a<=aa for aa in A))
from bisect import bisect_right N, M, V, P = map(int, input().split()) A = list(map(int, input().split())) A.sort() A_m = sorted(set(A)) n = len(A_m) ok = n-1 ng = -1 while ng+1 < ok: c = (ok+ng)//2 a = A_m[c] idx = bisect_right(A, a) if idx > N-P: ok = c continue if M < A[-P]-a: ng = c continue s = 0 for aa in A[-P:idx-1:-1]: s += aa-a if s > M*(N-V): ng = c else: ok = c a = A_m[ok] print(sum(a<=aa for aa in A))
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
629,076
629,075
u467736898
python
p02824
n,m,v,p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) tg = a[p-1] l = p-1 r = n biggest = 0 print(a) while l<r: x = (l+r)//2 if a[p-1]-a[x]<=m: border = v*m-(n-x+p-1)*m biggest = sum([a[x]+m-a[j] for j in range(p-1,x)]) else: r = x continue if border > biggest: r = x elif border <= biggest: l = x+1 print(l)
n,m,v,p = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) tg = a[p-1] l = p-1 r = n biggest = 0 while l<r: x = (l+r)//2 if a[p-1]-a[x]<=m: border = v*m-(n-x+p-1)*m biggest = sum([a[x]+m-a[j] for j in range(p-1,x)]) else: r = x continue if border > biggest: r = x elif border <= biggest: l = x+1 print(l)
[ "call.remove" ]
629,115
629,116
u905582793
python
p02829
A = int(input()) B = int(input()) l = [1,2,3] l.remove(A) l.remove(B) print(l)
A = int(input()) B = int(input()) l = [1,2,3] l.remove(A) l.remove(B) print(l[0])
[]
629,456
629,457
u309120194
python
p02829
a = int(input()) b = int(input()) t = set([1, 2, 3]) s = set([a,b]) ans = t - s print(list(ans[0]))
a = int(input()) b = int(input()) t = set([1, 2, 3]) s = set([a,b]) ans = t - s print(list(ans)[0])
[ "call.arguments.change" ]
629,466
629,467
u871841829
python
p02829
a=int(input()) b=int(input()) x=[1,2,3] x=x.remove(a) x=x.remove(b) print(x[0])
a=int(input()) b=int(input()) x=[1,2,3] x.remove(a) x.remove(b) print(x[0])
[ "assignment.remove" ]
629,472
629,473
u243159381
python