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

Fixed submission:
N=int(input())
a=input().split(" ")
b=[]
for p in range(0,N):
    b.append(int(a[p]))
if N==1:
    print(0)
else:
    c=[]
    if b[0]-b[1]>=0:
        c.append(1)
    else:
        c.append(0)
    for q in range(1,N-1):
        if b[q]-b[q+1]>=0:
            c.append(c[q-1]+1)
        else:
            c.append(0)
    print(max(c))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=input().split(" ")
b=[]
for p in range(0,N):
    b.append(int(a[p]))
if N=1:
    print(0)
else:
    c=[]
    if b[0]-b[1]>=0:
        c.append(1)
    else:
        c.append(0)
    for q in range(1,N-1):
        if b[q]-b[q+1]>=0:
            c.append(c[q-1]+1)
        else:
            c.append(0)
    print(max(c))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=input().split(" ")
b=[]
for p in range(0,N):
    b.append(int(a[p]))
if N=1:
    print(0)
else:
    c=[]
    if b[0]-b[1]>=0:
        c.append(1)
    else:
        c.append(0)
    for q in range(1,N-1):
        if b[q]-b[q+1]>=0:
            c.append(c[q-1]+1)
        else:
            c.append(0)
    print(max(c))

Buggy submission (verdict: Runtime Error):
N=int(input())
a=input().split(" ")
b=[]
for p in range(0,N):
    b.append(int(a[p]))
c=[]
if b[0]-b[1]>=0:
    c.append(1)
else:
    c.append(0)
for q in range(1,N-1):
    if b[q]-b[q+1]>=0:
        c.append(c[q-1]+1)
    else:
        c.append(0)
print(max(c))
Problem p02957 (python)

Fixed submission:
a=input().split(" ")
A=int(a[0])
B=int(a[1])
answer=int((A+B)/2)
if (A+B)%2==0 :
    print(answer)
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=input().split(" ")
sequence=[]
for i in range(0,a):
    sequence.append(int(b[i]))
error=[]
for q in range(0,a-1):
    if sequence[q]-sequence[q+1]>0:
        error.append(q)
        error.append(q+1)

if len(error)==0:
    print("YES")

elif len(error)==2:
    if a==2:
        print("YES")
    elif error[0]==0:
        if sequence[error[0]+2]-sequence[error[0]]>0:
            print("YES")
        else:
            print("NO")
    elif error[1]==a:
        if sequence[error[1]]-sequence[error[1]-2]>0:
            print("YES")
        else:
            print("NO")
    else:
        if  sequence[error[1]]-sequence[error[1]-2]>0 and sequence[error[0]+2]-sequence[error[0]]>0:
            print("YES")
        else:
            print("NO")

elif len(error)==4:
    if error[1]==error[2]:
        if sequence[error[0]]>sequence[error[3]]:
            if error[0]==0 and error[3]==a-1:
                if sequence[error[0]]-sequence[error[3]-1]>0 and sequence[error[0]+1]-sequence[error[3]]>0:
                    print("YES")
                else:
                    print("NO")
            elif error[0]==0:
                if sequence[error[0]+3]-sequence[error[0]]>0:
                    print("YES")
                else:
                    print("NO")
            elif error[1]==a:
                if sequence[error[3]]-sequence[error[3]-3]>0:
                    print("YES")
                else:
                    print("NO")
            else:
                if  sequence[error[3]]-sequence[error[3]-3]>0 and sequence[error[0]+3]-sequence[error[0]]>0:
                    print("YES")
                else:
                    print("NO")
    elif sequence[error[0]]-sequence[error[2]]>0 and sequence[error[1]]-sequence[error[3]]>0:
        if error[0]==0 and error[3]==a-1:
            if sequence[error[0]]-sequence[error[3]-1]>0 and sequence[error[0]+1]-sequence[error[3]]>0:
                print("YES")
            else:
                print("NO")
        elif error[0]==0:
            if sequence[error[3]+1]-sequence[error[0]]>0:
                print("YES")
            else:
                print("NO")
        elif error[3]==a:
            if sequence[error[3]]-sequence[error[0]-1]>0:
                print("YES")
            else:
                print("NO")
        elif sequence[error[3]]-sequence[error[0]-1]>0 and sequence[error[3]+1]-sequence[error[0]]>0:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

else:
    print("NO")
Problem p02675 (python)

Fixed submission:
s = int(input())
ichi = s%10
if ichi == 3:
    print('bon')
elif ichi == 0 or ichi==1 or ichi== 6 or ichi ==8:
    print('pon')
else :
    print('hon')

Buggy submission (verdict: Runtime Error):
s = int(intpu())
if s[-1] == 3:
  print('bon')
elif s[-1] == 0 or s[-1] == 1 or s[-1] == 6 or s[-1] == 8:
  print('pon')
else:
  print('hon')
Problem p02705 (python)

Fixed submission:
import math as mt
r = int(input())
R = 2*r*mt.pi
print(R)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input().split()
count = 0
for i in range(n-1):
    if s[i] == '1':
        count += 1
print(count)
for i in range(n-1):
    count = 0
    num = i + 2
    for j in range(i+1,n-1):
        NUM = int(s[j])
        if NUM == num:
            count += 1
    print(count)
Problem p02924 (python)

Fixed submission:
n = int(input())

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

Buggy submission (verdict: Runtime Error):
print(int(n * (n-1) // 2))
Problem p02947 (python)

Fixed submission:
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    r = {}
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        s = "".join(sorted(m[i]))
        if r.get(s) is None :
            r[s] = 1
        else:
            count += r[s]
            r[s] += 1
    print(count)


main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        shurui = 1
        if anagramed[i]:
            continue
        else:
            for j in range(i+1, n):
                if anagramed[j]:
                    continue
                elif is_anagram(m[i], m[j]):
                    shurui += 1
                    anagramed[i] = True
                    anagramed[j] = True
        if shurui > 1:
            count += int(math.factorial(shurui) / 2)
    print(count)


def is_anagram(s1, s2):
    s1_length = len(s1)
    s2_length = len(s2)
    if s1_length != s2_length:
        return False
    else:
        for index in range(s1_length):
            search_char = s1[index: index+1]
            search_result = s2.find(search_char)
            if search_result == -1:
                return False
            else:
                s2 = s2.replace(search_char, "", 1)
    return True

main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        shurui = 1
        if anagramed[i]:
            pass
        else:
            for j in range(i+1, n):
                if anagramed[j]:
                    pass
                elif is_anagram(m[i], m[j]):
                    shurui += 1
                    anagramed[i] = True
                    anagramed[j] = True
        if shurui > 1:
            count += int(math.factorial(shurui) / 2)
    print(count)


def check_dp(i, j):
    length_dp2 = len(dp2[i])
    if length_dp2 == 0:
        return False
    else:
        if j in dp2[i]:
            return True


def is_anagram(s1, s2):
    s1_length = len(s1)
    s2_length = len(s2)
    if s1_length != s2_length:
        return False
    else:
        for index in range(s1_length):
            search_char = s1[index: index+1]
            search_result = s2.find(search_char)
            if search_result == -1:
                return False
            else:
                s2 = s2.replace(search_char, "", 1)
    return True

main()
Problem p02971 (python)

Fixed submission:

def main():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(int(input()))

    sorted_a = sorted(a, reverse=True)
    one = sorted_a[0]
    two = sorted_a[1]

    for i in range(n):
        if one == a[i]:
            print(two)
        else:
            print(one)

main()

Buggy submission (verdict: Runtime Error):

def main():
    l, r = list(map(int, input().split(" ")))

    m = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            r = (i*j) % 2019
            if r == 0:
                print(0)
                return
            else:
                m = min(m, r)
    print(m)


main()
Problem p02983 (python)

Fixed submission:
l, r = list(map(int, input().split()))

ans = 3000

for i in range(l, r):
  for j in range(i + 1, r + 1):
    if (i * j) % 2019 < ans:
      ans = (i * j) % 2019
    if ans == 0:
      print(ans)
      exit() 
print(ans)

Buggy submission (verdict: Runtime Error):
     
    l, r = list(map(int, input().split()))
     
    ans = 2018
     
    for i in range(l, r + 1):
      for j in range(i + 1, r + 1):
        if ((i * j) % 2019) < ans:
          ans = (i * j) % 2019
        if ans == 0:
          print(ans)
          exit()
     
    print(ans)
Problem p03037 (python)

Fixed submission:
# coding: utf-8

(N, M) = map(int, input().split(" "))

ids = list(range(1, N+1))

L_max = 0
R_min = 10000000000000000000
for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

ids = [i for i in ids if L_max <= i <= R_min]
print(len(ids))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

(N, M) = map(int, input().split(" "))

ids = list(range(1, N+1))

L_max = 0
R_min = 10000000000000000000
for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

ids = [i for i in ids if L_min <= i <= R_min]
print(len(ids))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

(N, M) = map(int, input().split(" "))

ids = list(range(1, N+1))

L_min = 0
R_min = 10000000000000000000
for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

ids = [i for i in ids if L_min <= i <= R_min]
print(len(ids))
Problem p03796 (python)

Fixed submission:
# coding: utf-8

n = int(input())

power = 1
for i in range(1, n+1):
    power *= i
    power = power % (10**9+7)

print(power)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

n = int(N)

power = 1
for i in range(1, n+1):
    power *= i
    power = power % (10**9+7)

print(power)
Problem p03861 (python)

Fixed submission:
# coding: utf-8

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


def f(n):
    if n == -1:
        return 0
    else:
        return n // x + 1

print(f(b) - f(a-1))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

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

n = b - a - 1
# coding: utf-8

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

n = b - a
if a % x == 0 or b % x == 0:
    print(n // x + 1)
else:
    print(n // x)
Problem p02687 (python)

Fixed submission:
instr = input()

if instr == 'ABC':
    print('ARC')
else:
    print('ABC')

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

nn = n + max(a)
ml = [0] * nn
pl = [0] * nn

out = 0

for i in range(0, n):
    pl[i+a[i]] += 1
    if(i-a[i]>=0):
        ml[i-a[i]] += 1

for i in range(0, n):
    out += pl[i] * ml[i]

print(out)

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

out = 0

for i in range(n):
    w = i-a[i]
    for j in range(i):
        if(w == a[j] + j):
            out += 1
print(out)
Problem p02690 (python)

Fixed submission:
x = int(input())

a = 0
b = -1

while True:
    a5 = pow(a, 5)
    b5 = pow(b, 5)
    if(a5-b5 == x):
        print("{} {}".format(a, b))
        break
    if(a5+b5 == x):
        print("{} {}".format(a, -b))
        break
    if(-a5-b5 == x):
        print("{} {}".format(-a, b))
        break
    if(-a5+b5 == x):
        print("{} {}".format(-a, -b))
        break

    b += 1
    if(a==b-1):
        a +=1
        b =0

Buggy submission (verdict: Runtime Error):
x = int(input())

a = 0
b = 0


while True:
    a5 = pow(a, 5)
    b5 = pow(b, 5)
    if(a5-b5 == x):
        print("{} {}".format(a, b))
        exit(1)
    if(a5+b5 == x):
        print("{} {}".format(a, -b))
        exit(1)
    if(-a5-b5 == x):
        print("{} {}".format(-a, b))
        exit(1)
    if(-a5+b5 == x):
        print("{} {}".format(-a, -b))
        exit(1)

    b += 1
    if(a==b):
        a +=1
        b =0
Problem p02691 (python)

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

ml = [0] * n
pl = [0] * n

out = 0

for i in range(0, n):
    if(i+a[i]<n):
        pl[i+a[i]] += 1
    if(i-a[i]>=0):
        ml[i-a[i]] += 1

for i in range(0, n):
    out += pl[i] * ml[i]

print(out)

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

nn = n + max(a)
ml = [0] * nn
pl = [0] * nn

out = 0

for i in range(0, n):
    pl[i+a[i]] += 1
    if(i-a[i]>=0):
        ml[i-a[i]] += 1

for i in range(0, nn):
    out += pl[i] * ml[i]

print(out)

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

nn = n + max(a)
ml = [0] * nn
pl = [0] * nn

out = 0

for i in range(0, n):
    pl[i+a[i]] += 1
    if(i-a[i]>=0):
        ml[i-a[i]] += 1

for i in range(0, n):
    out += pl[i] * ml[i]

print(out)
Problem p02574 (python)

Fixed submission:
#!/usr/bin/env python3

import sys
from math import gcd
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

dup = False
dup_key = None
counter = Counter(A)
for key, val in counter.items():
    if val > 1:
        dup = True
        if dup_key is None:
            dup_key = key
        else:
            dup_key = max(dup_key, key)


def max_gcd_pair(S):
    # Assumption 1: S is the list of numbers
    # Assumption 2: There are no duplicates in S
    s = set(S)
    m = max(S)
    res = 1
    i = m
    while i > 0:
        a = i
        cnt = 0
        while a <= m: # a maxed at max of the list
            if a in s:
                cnt += 1
            a += i
        if cnt >= 2:  # we have found the result
            res = i
            break
        i = i - 1
    return res


pair = max_gcd_pair(A)
if dup:
    pair *= dup_key

if pair == 1:
    print('pairwise coprime')
    sys.exit()


setw = A[0]
for j in range(N):
    setw = gcd(setw, A[j])
if setw == 1:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
from math import gcd
MAX = 10**6

sieve = [i for i in range(MAX+1)]

p = 2
while p * p <= MAX:
    if sieve[p] == p:
        for i in range(p*2, MAX+1, p):
            if sieve[i] == i:
                sieve[i] = p
    p += 1


N = int(input())
A = list(map(int, input().split()))
pf = []

for a in A:
    tmp = set()
    b = a
    while b != 1:
        tmp.add(sieve[b])
        b //= sieve[b]
    pf.append(tmp)


soin = [0] * (10 ** 6 + 1)
for f in pf:
    for n in f:
        soin[n] += 1

if max(soin[2:]) <= 1:
    print('pairwise coprime')
    exit()


setwise = a[0]

for a in A:
    setwise = gcd(setwise, a)
    
if setwise == 1:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
import numpy as np
MAX = 10**6

sieve = [i for i in range(MAX+1)]

p = 2
while p * p <= MAX:
    if sieve[p] == p:
        for i in range(p*2, MAX+1, p):
            if sieve[i] == i:
                sieve[i] = p
    p += 1


N = int(input())
A = list(map(int, input().split()))
pf = []

for a in A:
    tmp = set()
    b = a
    while b != 1:
        tmp.add(sieve[b])
        b //= sieve[b]
    pf.append(tmp)


soin = [0] * (10 ** 6 + 1)
for f in pf:
    for n in f:
        soin[n] += 1

if max(soin[2:]) <= 1:
    print('pairwise coprime')
    exit()

flag = np.gcd.reduce(A)

if flag == 1:
    print('setwise coprime')
else:
    print('not coprime')
Problem p02608 (python)

Fixed submission:
from collections import defaultdict

N = int(input())


def fun(x, y, z):
  return x**2 + y**2 + z**2 + x*y + y*z + z*x

res = defaultdict(int)

for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      res[fun(x, y, z)] += 1
        
for n in range(1, N+1):
  print(res[n])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())


def fun(x, y, z):
  return x**2 + y**2 + z**2 + x*y + y*z + z*x

res = defaultdict(int)

for x in range(1, 50):
  for y in range(1, 50):
    for z in range(1, 50):
      dict[fun(x, y, z)] += 1
        
for n in range(1, N):
  print(dict[n])
Problem p02614 (python)

Fixed submission:
from itertools import combinations
import numpy as np

H, W, K = map(int, input().split())

C = []
base = 0
for i in range(H):
	string = input()
	string = string.replace('.', '0')
	string = string.replace('#', '1')
	lst = list(string)
	lst = [int(c) for c in lst]
	C.append(lst)
	base += sum(lst)

C = np.array(C)
orig = C.copy()
count = 0

for i in range(H+1):
	for j in range(W+1):
		for c in combinations(range(H), i):
			for d in combinations(range(W), j):
				for row in c:
					C[row] = [0] * W
				for col in d:
					C[:, col] = [0] * H
				if np.sum(C) == K:
					count += 1
				C = orig.copy()

print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.buffer.read

H, W, K = map(int, input().split())

C = np.frombuffer(read(), dtype='S1').reshape(H, -1)

def f(x, y, C):
	rows = [i for i in range(H) if x & (1<<i)]
	cols = [i for i in range(W) if y & (1<<i)]
	D = C[rows][:, cols]
	return D.sum() == K

res = 0
for x in range(1<<H):
	for y in range(1<<W):
		res += f(x, y, C)
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np

H, W, K = map(int, input().split())

C = np.frombuffer(read(), dtype='S1').reshape(H, -1)
print(C)
Problem p02618 (python)

Fixed submission:
D = 365

for i in range(D):
  print(1)

Buggy submission (verdict: Runtime Error):
def data_input():
    D = int(input())
    C = tuple(map(int, input().split()))

    S = []
    for i in range(D):
        s = tuple(map(int, input().split()))
        S.append(s)

    return D, C, S


def score(D, C, S, T):
    """入力D, C, Sと出力Tからスコアを計算する関数"""

    last = [0] * 26  # 0で初期化されている

    def decrease(d, last):
        """d日めにiを開催した時の満足度の減少を返す関数"""
        res = 0
        for i in range(26):
            ith = C[i] * (d+1 - last[i])
            res -= ith
        return res

    V = []  # V[d]はd日めの満足度を表す
    for d, i in enumerate(T):
        if d == 0:
            v = 0
        last[i] = d + 1
        v += S[d][i] + decrease(d, last)
        # print(d, i, v, S[d][i], decrease(d, last), last)
        V.append(v)
    return V

T = []
for d in range(D):
    local_max = 0
    for i in range(26):
        if score(d, C, S, T+[i])[-1] >= local_max:
            max_i = i
            local_max = score(d, C, S, T+[i])[-1]
            # print(f'local_max at {d}-day is updated to {local_max}')
    T.append(max_i)

V = score(D, C, S, T)

for v in V:
    print(v)
Problem p02630 (python)

Fixed submission:
from collections import defaultdict

N = int(input())
A = tuple(map(int, input().split()))
dic = defaultdict(int)

for a in A:
  dic[a] += 1
    
Q = int(input())

base = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  tmp = dic[B]
  dic[B] = 0
  dic[C] += tmp
  base += (C-B)*tmp
  print(base)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
dic = {}

for i in range(100000):
  dic[i] = A.count(i)
    
Q = int(input())

base = sum(A)

for i in range(Q):
  B, C = map(int, input().split())
  tmp = dic[B]
  dic[B] = 0
  dic[C] += tmp
  base += (C-B)*tmp
  print(base)
Problem p02690 (python)

Fixed submission:
import sys
X = int(input())

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        cand = i ** 5 - j ** 5
        if X == cand:
            print(i, j)
            sys.exit()

Buggy submission (verdict: Runtime Error):
X = int(input())

cand = int(pow(X, 0.2))
diff = - (X - pow(cand, 5))

for i in range(-cand, cand + 1):
    if pow(cand, 5) - pow(i, 5) == X:
        other = i

print(cand, other)
Problem p02761 (python)

Fixed submission:
import sys
N, M = map(int, input().split())

A = [-1] * N

for i in range(M):
  s, c = map(int, input().split())
  if A[s-1] != c and A[s-1] != -1:
    print(-1)
    sys.exit()
  else:
    A[s-1] = c
  
if N >= 2 and A[0] == 0:
  print(-1)
  sys.exit()

res = 0

for i in range(N):
  if A[i] == -1:
    if i == 0 and N >= 2:
      A[i] = 1
    else:
      A[i] = 0
  res += A[i] * 10 ** (N-i-1)

print(res)

Buggy submission (verdict: Runtime Error):
import sys

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

S = []
C = []
for m in range(M):
  s, c = map(int, input().split())
  S.append(s)
  C.append(c)

for i in range(10**N):
  tes = str(i)
  flag = True
  if len(tes) < N:
    flag = False
  for s, c in zip(S, C):
    if tes[s-1] != str(c):
      flag = False
  if flag:
    print(tes)
    sys.exit()


print(-1)

Buggy submission (verdict: Runtime Error):
import sys

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

S = []
C = []
for m in range(M):
  s, c = map(int, input().split())
  S.append(s)
  C.append(c)

for i in range(10**(N-1)-1, 10**N):
  tes = str(i)
  flag = True
  for s, c in zip(S, C):
    if tes[s-1] != str(c):
      flag = False
  if flag:
    print(tes)
    sys.exit()

print(-1)
Problem p02768 (python)

Fixed submission:
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

MOD = 10**9 + 7
# 二項展開より 2**n - 1 - nCa - nCb を MOD 10**9 + 7 で求めればよい


def combination(n, a):
    # nCk = n! / k! (n-k)! のうち、 n!/(n-k)! を計算する
    res = 1
    div = 1
    for i in range(a):
        res *= n-i
        res %= MOD
        div *= a - i
        div %= MOD

    # print(f'n {n}, a {a}, res {res}, div {div}')
    res = (res * pow(div, MOD-2, MOD)) % MOD
    return res


count = (pow(2, n, MOD) - 1 - combination(n, a) - combination(n, b)) % MOD
print(count)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
MOD = 10**9 + 7

res = 0

def comb(n, k):
    """nCkを計算する関数"""
    fact = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1] * i % MOD

    # k!と(n-k)!の逆元はそれぞれ、(k!) ** (MOD-2), (n-k)!**(MOD-2)
    res = fact[n] * pow(fact[k], -1, MOD) * pow(fact[n-k], -1, MOD)
    return res % MOD


for i in range(n):
    if i != a and i != b:
        res += comb(n, i)

print(res)
Problem p02780 (python)

Fixed submission:
N, K = map(int, input().split())
P = tuple(map(int, input().split()))
P2 = P[K:]

max_sum = 0
sum_ = sum(P[:K])

for p, q in zip(P, P2):
  max_sum = max(max_sum, sum_)
  sum_ += q - p
  
max_sum = max(max_sum, sum_)
          
res = (max_sum + K)/ 2
print(res)

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

S = []
sum_ = 0
for i, p in enumerate(P):
  sum_ += p
  S.append(sum_)


max_sum = 0
for i in range(N-K+1):
  max_sum = max(max_sum, S[i+K] - S[i])

res = (max_sum + K) / 2

print(res)