Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02935 (python)

Fixed submission:
N = int(input())
v = list(map(int,input().split()))

v.sort()

son = v[0]

for i in range(1,len(v)):
	son = (v[i] + son)/2

print(son)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = list(map(int,input().split()))
cnt = N

while cnt is not 1:
		
    titi = max(v)
    haha = min(v)

    v.remove(titi)
    v.remove(haha)

    son = (titi + haha)/2 
    
    cnt = N - 1
    
print(son)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = map(int,input().split())

for i in N:

    titi = max(v)
    haha = min(v)

    v.remove(titi)
    v.remove(haha)

    son = (titi + haha)/2 

    v.add(son)

res = v[0] 
print(str(res))

Buggy submission (verdict: Runtime Error):
N = int(input())
v =  list(map(int,input().split()))

for i in N:

    titi = max(v)
    haha = min(v)

    v.remove(titi)
    v.remove(haha)

    son = (titi + haha)/2 

    v.add(son)

res = v[0] 
print(str(res))

Buggy submission (verdict: Runtime Error):
kazu,sozai =  map(int,input().split())

for i in kazu:

    titi = max(int(sozai))
    haha = min(int(sozai))

    int(sozai).remove(titi)
    int(sozai).remove(haha)

    son = (titi + haha)/2 

    sozai.add(str(son))

print(str(sozai))

Buggy submission (verdict: Runtime Error):
sozai = input()

while len(sozai) != 1:

    titi = max(sozai)
    haha = min(sozai)

    sozai.remove(titi)
    sozai.remove(haha)

    son = (titi + haha)/2 

    sozai.add(son)

print(str(sozai))
Problem p02862 (python)

Fixed submission:
import sys
from math import factorial
sys.setrecursionlimit(100000)

input = sys.stdin.readline

X, Y = list(map(int,input().split()))

mod = 10**9 + 7

def mm(a, b):
    return ((a % mod) * (b % mod)) % mod

def pp(x, y):
    if   y == 0     :
    	return 1
    elif y == 1     : 
    	return x % mod
    elif y % 2 == 0 : 
    	return (pp(x, y/2)**2) % mod
    else            : 
    	return (pp(x, y//2)**2 * x) % mod

def dd(a, b):
    return mm(a, pp(b, mod-2))

def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
	    q, a, b = a // b, b, a % b
	    x0, x1 = x1, x0 - q * x1
	    y0, y1 = y1, y0 - q * y1
	return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

if (X+Y)%3!=0:
	ans = 0
else:
	nmsum = (X+Y)//3
	nmdif = Y-X
	if (nmsum+nmdif)%2!=0:
		ans = 0
	else:
		n = (nmsum+nmdif)//2
		m = (nmsum-nmdif)//2
		if n<0 or m<0:
			ans = 0
		elif n==0 or m==0:
			ans = 1
		else:
			t = 1
			for i in range(1,n+m+1):
				t = (t*i)%mod
				if i==n: bb = t
				if i==m: cc = t
				if i==n+m: aa = t
			# aa = factorial(n+m)%mod
			# bb = factorial(n)%mod
			# cc = factorial(m)%mod
			ans = aa * modinv(bb,mod) %mod
			ans = ans * modinv(cc,mod) %mod

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from math import factorial
sys.setrecursionlimit(100000)

input = sys.stdin.readline

X, Y = list(map(int,input().split()))

mod = 10**9 + 7

def mm(a, b):
    return ((a % mod) * (b % mod)) % mod

def pp(x, y):
    if   y == 0     :
    	return 1
    elif y == 1     : 
    	return x % mod
    elif y % 2 == 0 : 
    	return (pp(x, y/2)**2) % mod
    else            : 
    	return (pp(x, y//2)**2 * x) % mod

def dd(a, b):
    return mm(a, pp(b, mod-2))

def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
	    q, a, b = a // b, b, a % b
	    x0, x1 = x1, x0 - q * x1
	    y0, y1 = y1, y0 - q * y1
	return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

if (X+Y)%3!=0:
	ans = 0
else:
	nmsum = (X+Y)//3
	nmdif = Y-X
	if (nmsum+nmdif)%2!=0:
		ans = 0
	else:
		n = (nmsum+nmdif)//2
		m = (nmsum-nmdif)//2
		if n<0 or m<0:
			ans = 0
		else:
			t = 1
			for i in range(1,n+m+1):
				t = (t*i)%mod
				if i==n: bb = t
				if i==m: cc = t
				if i==n+m: aa = t
			# aa = factorial(n+m)%mod
			# bb = factorial(n)%mod
			# cc = factorial(m)%mod
			ans = aa * modinv(bb,mod) %mod
			ans = ans * modinv(cc,mod) %mod

print(ans)
Problem p03253 (python)

Fixed submission:
from collections import Counter

mod = 1000000007

# nの素因数分解

def prime(n):
    d = Counter()
    i = 2
    while i*i <= n:
        while n%i == 0:
            n //= i
            d[i] += 1
        i += 1
    if n > 1:
        d[n] += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [1] * 100100
inv = [1] * 100100
for k in range(1, 100100):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p.values():
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()

Buggy submission (verdict: Runtime Error):
mod = 1000000007

# nの素因数分解

def prime(n):
    d = []
    i = 2
    while n != 1:
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        d.append(s)
        i += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 1:
        return x
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [0] * 100099
inv = [0] * 100099
frac[0] = 1
inv[0] = 1
for k in range(1, 100099):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p:
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

mod = 1000000007

f = [] # 素因数分解(指数部のみ)

for p in range(2, M): # 素因数分解
    e = 0
    while M%p == 0:
        e += 1
        M /= p
    
    if e>0:
        f.append(e)
    
    if M == 1:
        break

def pw(a, e):
    if e == 1:
        return a
    p = pw(a, e // 2)
    if e%2 == 1:
        return p * p % mod a % mod
    else:
        return p * p % mod

# fact, inv の計算
fact = [1] * 100040
inv = [1] * 100040
for k in range(1, 100040):
    fact[k] = fact[k-1] * k % mod
    inv[k] = pw(fact[k], mod-2)

ans = 1
for e in f:
    ans = ans * fact[e+N-1] % mod * inv[e] % mod * inv[N-1] % mod # N_H_e (重複組合せ)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

mod = 1000000007

f = [] # 素因数分解(指数部のみ)

for p in range(2, M): # 素因数分解
    e = 0
    while M%p == 0:
        e += 1
        M /= p
    
    if e>0:
        f.append(e)
    
    if M == 1:
        break

def pw(a, e):
    if e == 1:
        return a
    p = pw(a, e // 2)
    if e%2 == 1:
        return p * p % mod * a % mod
    else:
        return p * p % mod

# fact, inv の計算
fact = [1] * 100033
inv = [1] * 100033
for k in range(1, 100033):
    fact[k] = fact[k-1] * k % mod
    inv[k] = pw(fact[k], mod-2))

def combine(n, k):
    return fact[n] * inv[k] % mod * inv[n-k] % mod

ans = 1
for e in f:
    ans *= combine(e+N-1, e) # N_H_e (重複組合せ)
    ans %= mod

print(ans)
Problem p03042 (python)

Fixed submission:
s = input()
a = int(s[:2])
b = int(s[2:])
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")

Buggy submission (verdict: Runtime Error):
s = input()
a = int(s[:2]) > 13 or int(s[:2])=0
b = int(s[2:]) > 13 or int(s[2:])=0
if a and b:
  print("NA")
elif not a and not b:
  print("AMBIGUOUS")
elif not a and b:
  print("MMYY")
else:
  print("YYMM")
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n, m = lmi()

l = [0] * (n+1)
l[0] = 1

a = 0
if m != 0:
    a = int(input())
k = 1
for i in range(n+1):

    if i != a:
        if i == 1:
            l[i] = 1
        elif i >= 2:
            l[i] = l[i-1] + l[i-2]
            l[i] %= 1000000007
    else:
        k += 1
        if k <= m:
            a = int(input())



#print(l)
print(l[n] % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n, m = lmi()

l = [0] * (n+1)
l[0] = 1

a = int(input())
k = 1
for i in range(n+1):

    if i != a:
        if i == 1:
            l[i] = 1
        elif i >= 2:
            l[i] = l[i-1] + l[i-2]
            l[i] %= 1000000007
    else:
        k += 1
        if k <= m:
            a = int(input())



#print(l)
print(l[n] % 1000000007)
Problem p03045 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)


def root(x):
    if c[x] == x:
        return x
    else:
        c[x] = root(c[x])
        return c[x]


def uni(x,y):
    rx = root(x)
    ry = root(y)
    c[ry] = rx


n, m = map(int, input().split())
c = [i for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uni(x,y)

for i in range(n):
    root(i)

print(len(set(c)))

Buggy submission (verdict: Runtime Error):
def root(x):
    if c[x] == x:
        return x
    else:
        c[x] = root(c[x])
        return c[x]


def uni(x,y):
    rx = root(x)
    ry = root(y)
    c[ry] = rx


n, m = map(int, input().split())
c = [i for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uni(x,y)

for i in range(n):
    root(i)

print(len(set(c)))
Problem p03077 (python)

Fixed submission:
n = int(input())
c = [int(input()) for i in range(5)]
mc = min(c)
b = n // mc
r =  0 if n % mc == 0 else 1

print(4 + b + r)

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])
Problem p03011 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

# import sys, math, random
# import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    A, B, C = list(map(int,input().split()))
    o=max(A,B,C)
    print(A+B+C-o)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    A, B, C = list(map(int,input().split()))
    OUT=max(A,B,C)
    print(A+B+C-OUT)
    
if __name__ == "__main__":
    main()
Problem p03017 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import math
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']




def main():
    N, A, B, C, D = list(map(int,input().split()))
    S= str(input())
    # print(S[2:5])-> [2]~[4]
    if C>D:
        if '##' in S[A-1:C+1]:
            print("No")
        elif "..." in S[B-2:D+1]:
            print("Yes")
        else:
            print("No")
    else:
        if '##' in S[A-1:D]:
            print("No")
        else:
            print("Yes")
    # elif C>D and  ("..." in S[B-2:])
    # print(S[B-2:])
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import math
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']




def main():
    N, A, B, C, D = list(map(int,input().split()))
    S= str(input())
    # print(S[2:5])-> [2]~[4]
    if C>D:
        if '##' in S[A:C]:
            print("No")
        elif "..." in S[B-2:C]:
            print("Yes")
        else:
            print("No")
    else:
        if '##' in S[A:D]:
            print("No")
        else:
            print("Yes")
    # elif C>D and  ("..." in S[B-2:])
    # print(S[B-2:])
    
if __name__ == "__main__":
    main()
Problem p03207 (python)

Fixed submission:
A = int(input())
B = [int(input()) for _ in range(A)]
p = 0
B = sorted(B)
b = B.pop(-1)
for i in B:
  p += i
print(b//2 + p)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
C = [int(input()) for _ in range(A)]
c = []
p = 0
C = sorted(C)
for i in range(B,A+1):
  c.append(max(C[i-(B):i]) - min(C[i-(B):i]))
  print(C[i-(B):i])
print(min(c))

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
C = [int(input()) for _ in range(A)]
c = []
p = 0
C = sorted(C)
for i in range(B-1,A):
  c.append(max(C[i-(B-1):i]) - min(C[i-(B-1):i]))
print(min(c))
Problem p03774 (python)

Fixed submission:
a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(b)]
for s in S:
  count = 0
  ab = 10**9
  p = 10**9
  for i,cp in zip(range(b),CP):
    total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
    count +=1
    if ab > total:
      ab = total
      p = i+1
      
  print(p)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(a)]
for s in S:
  count = 0
  ab = 10**8
  p = 10**8
  for cp in CP:
    total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
    count +=1
    if ab > total:
      ab = total
      p = count
      
  print(p)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(a)]


for s in S:
  count = 0
  ab = 10**8
  p = 10**8
  for cp in CP:
    total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
    count +=1
    if ab > total:
      ab = total
      p = count
  print(p)
Problem p02881 (python)

Fixed submission:
from math import ceil, sqrt
N = int(input())

for i in range(ceil(sqrt(N)), 0, -1):
    if N % i == 0:
        print((N//i) + i - 2)
        break

Buggy submission (verdict: Runtime Error):
from math import ceil, sqrt
N = int(input())

for i in range(floor(sqrt(N)), 0, -1):
    if N % i == 0:
        print((N//i) + i - 2)
        break
Problem p02862 (python)

Fixed submission:
#!/usr/bin/python3

import os
import sys


def main():
    X, Y = read_ints()
    print(solve(X, Y))


MOD = 10 ** 9 + 7


def mpow(a, n):
    p = a
    v = 1
    while n > 0:
        if n & 1:
            v *= p
            v %= MOD
        n >>= 1
        p *= p
        p %= MOD
    return v


def solve(X, Y):
    s = X + Y
    if s % 3 != 0:
        return 0
    s //= 3

    a = 2 * s - X
    b = 2 * s - Y
    if a < 0 or b < 0:
        return 0

    c = a + b

    facts = [0] * (c + 1)
    facts[0] = 1
    for i in range(1, c + 1):
        facts[i] = (facts[i - 1] * i) % MOD

    return (facts[c] * mpow(facts[a], MOD - 2) * mpow(facts[b], MOD - 2)) % MOD


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

import os
import sys


def main():
    X, Y = read_ints()
    print(solve(X, Y))


MOD = 10 ** 9 + 7


def mpow(a, n):
    p = a
    v = 1
    while n > 0:
        if n & 1:
            v *= p
            v %= MOD
        n >>= 1
        p *= p
        p %= MOD
    return v


def solve(X, Y):
    s = X + Y
    if s % 3 != 0:
        return 0
    s //= 3

    a = 2 * s - X
    b = 2 * s - Y
    c = a + b

    facts = [0] * (c + 1)
    facts[0] = 1
    for i in range(1, c + 1):
        facts[i] = (facts[i - 1] * i) % MOD

    return (facts[c] * mpow(facts[a], MOD - 2) * mpow(facts[b], MOD - 2)) % MOD


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()
Problem p03207 (python)

Fixed submission:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# 3
# hoge
# foo
# bar
# n=int(input())
# string_list=[input() for i in range(n)]
n=int(input())
p=[int(input()) for _ in range(n)]

print(sum(p)-int(max(p)/2))

Buggy submission (verdict: Runtime Error):
N=int(input())
p=[input() for i in range(n)]

print(sum(p)-max(p)/2)
Problem p03776 (python)

Fixed submission:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

def C(n,r):
    f = math.factorial
    return int(f(n) // f(r) // f(n-r))

N, A, B = l_inpl()
v = l_inpl()

sort_v = sorted(v, reverse=True)
ans_1 = sum(sort_v[:A])/A
print(ans_1)

max_v = sort_v[A-1]
max_v_count = sort_v.count(max_v)
max_v_count_in_ans = sort_v[:A].count(max_v)

if max_v != sort_v[0]: # 1つでも増やすと平均が減少する場合
    ans = C(max_v_count, max_v_count_in_ans)
else:
    ans = 0
    for i in range(A, min(B, max_v_count) + 1):
        ans += C(max_v_count, i)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W
 
# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

N, A, B = l_inpl()
v = l_inpl()

sort_v = sorted(v, reverse=True)
ans_1 = sum(sort_v[:A])/A
print(ans_1)

max_v = sort_v[A-1]
max_v_count = sort_v.count(max_v)
max_v_count_in_ans = sort_v[:A].count(max_v)

if max_v != sort_v[0]: # 1つでも増やすと平均が減少する場合
    ans = comb(max_v_count, max_v_count_in_ans)
else:
    ans = 0
    for i in range(A, min(B, max_v_count) + 1):
        ans += comb(max_v_count, i)

print(int(ans))
Problem p03745 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
incr = None
for i, x in enumerate(a):
    if i==0:
        before = x
        continue
    if incr==None:
        if x > before:
            incr = 1
        elif x < before:
            incr = -1
        before = x
        continue
    if (incr==1)and(x < before):
        ans += 1
        incr = None
    elif (incr==-1)and(x > before):
        ans += 1
        incr = None
    before = x    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 1
def incr(a,b):
    if a>b:
        return -1
    elif a==b:
        return 0
    else:
        return 1
init = incr(a[0], a[1])
flag = True
for i in range(1, n-1):
    tmp = incr(a[i], a[i+1])
    #print("a[i]=", a[i]," a[i+1]=", a[i+1], " init=", init, " tmp=", tmp)
    if tmp==0:
        tmp = init
    if init*tmp<0 and flag:
        ans += 1
        init = tmp
        flag = False
        #print(i)
        continue
    init = tmp
    flag = True
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
del_a = [a[i+1]-a[i] for i in range(n-1)]
ans = 1
tmp = 0
before = del_a[0]
length = 1 
for i in range(1,n-1):
    tmp = del_a[i]
    if(before*tmp<0)and(length>1):
        length = 1
        ans += 1
    elif(before*tmp<0)and(i==n-2):
        ans+=1
    else:
        length += 1
    before = del_a[i]
print(ans)