Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
s = [[x, *(input().split())] for x in range(n)]

s = sorted(s, key = itemgetter(2), reverse=True)
s = sorted(s, key = itemgetter(1))

for i in s:
    print(i[0]+1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append([s, int(p), i])

a.sort(key=lambda x:x[1], reverse=True)
a.sort(key=lambda x:x[0])

for x in a:
    print(x[2]+1)

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
s = [[x, *(input().split())] for x in range(n)]

s = sorted(s, key = itemgetter(2), reverse=True)
s = sorted(s, key = itemgetter(1))

for i in s:
    print(i[0]+1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append([s, int(p), i])

a.sort(key=lambda x:x[1], reverse=True)
a.sort(key=lambda x:x[0])

for x in a:
    print(x[2]+1)
Buggy python submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
# n < k の場合も考える必要がある

p = 0
for i in range(1, n+1):
    tmp = (n**-1)*(0.5)**int(math.log2(k//i) + 1)
    p+=tmp

print(p)

Fixed submission:
import math
N, K = map(int, input().split())
score = 0

if K <= N:
	ans = (N-K+1)/N
	end = K
else:
	ans = 0
	end = N+1
for i in range(1, end):
	ans += (1/N) * (1/2)**math.ceil(math.log2(K/i))
	
print(ans)
Buggy python submission (verdict: Runtime Error):
def dfs(v, c, total):
	if color[v] != -1:
		return
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		total+=w
		if total%2 == 0:
			dfs(u, c, total)
		else:
			dfs(u, 1-c, total)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0, total=0)
#for i in range(n):
#	print(i, glaph[i])
for i in color:
	print(i)

Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 7))

def dfs(v, c, parent):
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		if color[u] != -1:
			continue
		if w%2 == 0:
			dfs(u, c, v)
		else:
			dfs(u, 1-c, v)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0, parent=0)
#for i in range(n):
#	print(i, glaph[i])
for i in color:
	print(i)

Buggy python submission (verdict: Runtime Error):
def dfs(v, c, total):
	if color[v] != -1:
		return
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		total+=w
		if total%2 == 0:
			dfs(u, 0, total)
		else:
			dfs(u, 1, total)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(0, 0, 0)
for i in color:
	print(i)

Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 7))

def dfs(v, c, parent):
	color[v] = c
	for x in glaph[v]:
		u, w = x[0], x[1]
		if color[u] != -1:
			continue
		if w%2 == 0:
			dfs(u, c, v)
		else:
			dfs(u, 1-c, v)
			
n = int(input())
glaph = [[]*n for _ in range(n)]
color = [-1]*n

for _ in range(n-1):
	u,v,w = map(int, input().split())
	glaph[u-1].append((v-1, w))
	glaph[v-1].append((u-1, w))	

dfs(v=0, c=0, parent=0)
#for i in range(n):
#	print(i, glaph[i])
for i in color:
	print(i)
Buggy python submission (verdict: Runtime Error):
s = str(input())

test0 = [x%2 for x in range(n)]
test1 = [x%2+1 for x in range(n)]

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1
        
print(min(cnt0, cnt1))

Fixed submission:
s = str(input())

test0 = [x%2 for x in range(len(s))]
test1 = [x%2 for x in range(len(s) - 1)]
test1.insert(0, 1)

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1

print(min(cnt0, cnt1))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
quiz = [list(map(int, input().split())) for i in range(q)]

for i in quiz:
    print(s[i[0]-1:(i[1])].count('AC'))

Fixed submission:
# ACのインデックスを求める
# インデックスから、含まれる個数を求める(2分探索)
from bisect import bisect_left
N,Q = map(int, input().split())
S = input()
tmp = ''
ac_count = []
for i, c in enumerate(S):
	if tmp + c == 'AC':
		ac_count.append(i-1)
	tmp = c
ac_count.sort()

for i in range(Q):
	l, r = map(int, input().split())
	print(len(S[bisect_left(ac_count, l-1) : bisect_left(ac_count, r-1)]))

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
quiz = [list(map(int, input().split())) for i in range(q)]

for i in quiz:
    print(s[i[0]-1:(i[1])].count('AC'))

Fixed submission:
# ACのインデックスを求める
# インデックスから、含まれる個数を求める(2分探索)
from bisect import bisect_left
N,Q = map(int, input().split())
S = input()
tmp = ''
ac_count = []
for i, c in enumerate(S):
	if tmp + c == 'AC':
		ac_count.append(i-1)
	tmp = c
ac_count.sort()

for i in range(Q):
	l, r = map(int, input().split())
	print(len(S[bisect_left(ac_count, l-1) : bisect_left(ac_count, r-1)]))

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
quiz = [list(map(int, input().split())) for i in range(q)]

for i in quiz:
    cnt = s[i[0]-1:(i[1])].count('AC')
    print(cnt)

Fixed submission:
# ACのインデックスを求める
# インデックスから、含まれる個数を求める(2分探索)
from bisect import bisect_left
N,Q = map(int, input().split())
S = input()
tmp = ''
ac_count = []
for i, c in enumerate(S):
	if tmp + c == 'AC':
		ac_count.append(i-1)
	tmp = c
ac_count.sort()

for i in range(Q):
	l, r = map(int, input().split())
	print(len(S[bisect_left(ac_count, l-1) : bisect_left(ac_count, r-1)]))

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
quiz = [list(map(int, input().split())) for i in range(q)]

for i in quiz:
    cnt = s[i[0]-1:(i[1])].count('AC')
    print(cnt)

Fixed submission:
# ACのインデックスを求める
# インデックスから、含まれる個数を求める(2分探索)
from bisect import bisect_left
N,Q = map(int, input().split())
S = input()
tmp = ''
ac_count = []
for i, c in enumerate(S):
	if tmp + c == 'AC':
		ac_count.append(i-1)
	tmp = c
ac_count.sort()

for i in range(Q):
	l, r = map(int, input().split())
	print(len(S[bisect_left(ac_count, l-1) : bisect_left(ac_count, r-1)]))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l1 = len(s)

for i in range(l1):
    if '01' in s or '10' in s:
        s = s.replace('01', '')
        s = s.replace('10', '')
    else:
        break
        
print(l1 - len(s))

Fixed submission:
s = input()
cnt = [s.count('0'), s.count('1')]

print(len(s) - (max(cnt) - min(cnt)))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l1 = len(s)

for i in range(l1):
    if '01' in s or '10' in s:
        s = s.replace('01', '')
        s = s.replace('10', '')
    else:
        break
        
print(l1 - len(s))

Fixed submission:
s = input()
cnt = [s.count('0'), s.count('1')]

print(len(s) - (max(cnt) - min(cnt)))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
l1 = len(s)

for i in range(l1):
    if '01' in s:
        s = s.replace('01', '')
    elif '10' in s:
        s = s.replace('10', '')
    else:
        break
        
print(l1 - len(s))

Fixed submission:
s = input()
cnt = [s.count('0'), s.count('1')]

print(len(s) - (max(cnt) - min(cnt)))

Buggy python submission (verdict: Runtime Error):
import copy

s = input()
l1 = len(s)

for i in range(n):
    if '01' in s:
        s = s.replace('01', '')
    elif '10' in s:
        s = s.replace('10', '')
    else:
        break
        
print(l1 - len(s))

Fixed submission:
s = input()
cnt = [s.count('0'), s.count('1')]

print(len(s) - (max(cnt) - min(cnt)))
Buggy python submission (verdict: Runtime Error):
#間隔が大きいところを含まないように分割すればいいのでは？
import bisect
n,m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
ans = []
xmin = X.pop(0)
prev = xmin
for x in X:
	if len(ans) < n-1:
		bisect.insort(ans, abs(prev - x))
	elif ans[0] < abs(prev - x):
		ans[0] = abs(prev - x)
	prev = x
if n >= m:
	print(0)
else:
	print(X[m-2]-xmin - sum(ans))


Fixed submission:
n,m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

length = X[m-1] - X[0]
L = []
for i in range(m-1):
	L.append(X[i+1] - X[i])
L.sort()

if n >= m:
	print(0)
else:
	print(length - sum(L[m-1-(n-1):m-1]))
Buggy python submission (verdict: Runtime Error):
 s = int(input())
a = [s]

for i in range(1, 1000000):
    if a[i-1]%2 == 0:
        tmp = (a[i-1]//2)
    else:
        tmp = (3*a[i-1] + 1)
    
    if a.count(tmp):
        ans = i+1
        break
    else:
        a.append(tmp)
        
print(ans)

Fixed submission:
s = int(input())
a = [s]

for i in range(1, 1000000):
    if a[i-1]%2 == 0:
        tmp = (a[i-1]//2)
    else:
        tmp = (3*a[i-1] + 1)
    
    if a.count(tmp):
        ans = i+1
        break
    else:
        a.append(tmp)
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]

# dp[i][j] := i番目の以前の品物から、重さがj以下になるような最大の価値
dp = [[-1]*(w+1) for _ in range(n+1)]
for i in range(w+1):
    dp[0][i] = 0

for i in range(1, n+1):
    for j in range(w+1):
        # 重さjより上なら、選ばない
        if j < a[i-1][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i-1][0]] + a[i-1][1])
            
print(dp[n][w])

Fixed submission:
n, w = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]

# dp[i][j] := i番目の以前の品物から、重さがj以下になるような最大の価値
dp = [[-1]*(w+1) for _ in range(n+1)]
for i in range(w+1):
    dp[0][i] = 0

for i in range(1, n+1):
    for j in range(w+1):
        # 重さjより上なら、選ばない
        if j < a[i-1][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i-1][0]] + a[i-1][1])
            
print(dp[n][w])
Buggy python submission (verdict: Runtime Error):
k = int(input())
print((n//2)*(k-n//2))

Fixed submission:
k = int(input())
print((k//2)*(k-k//2))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
ab = [i for i in range(a, b+1)]
if (b-a)//2 < k:
    ans = ab
else:
    ans = ab[0:k] + ab[len(ab)-k:len(ab)]
print(*ans)

Fixed submission:
a, b, k = map(int, input().split())
if (b-a)//2 < k:
    ans = [i for i in range(a, b+1)]
else:
    ans = [i for i in range(a, a+k)] + [i for i in range(b-k+1, b+1)]
print(*ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

h, w = map(int, input().split())
p = (input() for i in range(h))

# メモ配列
INF = 10**7
memo = [[INF]*w for i in range(h)]

# 白マスをカウント
wcnt = 0
for i in p:
    for j in i:
        if j == '.':
            wcnt+=1

# 幅探索用キュー初期化
q = deque()
q.append((0, 0))
memo[0][0]  = 0

# 探索用ベクトル
vx = (0, -1, 0, 1)
vy = (-1, 0, 1, 0)

ans = -1
for i in range(INF):
    # キューが空なら終了
    if len(q) == 0:
        break
        
    # キューから一つ取り出す
    x, y = map(int, q.pop())
    
    # ゴールなら終了
    if x == w-1 and y == h-1:
        ans = memo[y][x]
        break
        
    # 4方向の距離を確定して、エンキューする
    for j in range(4):
        nx, ny = x+vx[j], y+vy[j]
        
        # エリア外 or 探索済み or 黒色なら探索しない
        if nx < 0 or w <= nx or ny < 0 or h <= ny or memo[ny][nx] != INF or p[ny][nx] == '#':
            continue
            
        memo[ny][nx] = memo[y][x]+1
        q.appendleft((nx, ny))

if ans == -1:
    print(ans)
else:
    print(wcnt-ans-1)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
p = [input() for i in range(h)]

# メモ配列
INF = 10**7
memo = [[INF]*w for i in range(h)]

# 白マスをカウント
wcnt = 0
for i in p:
    for j in i:
        if j == '.':
            wcnt+=1

# 幅探索用キュー初期化
q = deque()
q.append((0, 0))
memo[0][0]  = 0

# 探索用ベクトル
vx = (0, -1, 0, 1)
vy = (-1, 0, 1, 0)

ans = -1
for i in range(INF):
    # キューが空なら終了
    if len(q) == 0:
        break
        
    # キューから一つ取り出す
    x, y = map(int, q.pop())
    
    # ゴールなら終了
    if x == w-1 and y == h-1:
        ans = memo[y][x]
        break
        
    # 4方向の距離を確定して、エンキューする
    for j in range(4):
        nx, ny = x+vx[j], y+vy[j]
        
        # エリア外 or 探索済み or 黒色なら探索しない
        if nx < 0 or w <= nx or ny < 0 or h <= ny or memo[ny][nx] != INF or p[ny][nx] == '#':
            continue
            
        memo[ny][nx] = memo[y][x]+1
        q.appendleft((nx, ny))

if ans == -1:
    print(ans)
else:
    print(wcnt-ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = -10**15
for i in range(n, 2*n+1):
    a_front = a[0 : i]
    a_back = a[i : 3*n]
    a_front.sort(reverse=True)
    a_back.sort()
    tmp = sum(a_front[0:n]) - sum(a_back[0:n])
    if tmp > ans:
        ans = tmp

print(ans)    

Fixed submission:
from heapq import heappop, heapify, heappush

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

a_front = a[0 : n]
a_back = list(map(lambda x: -1*x, a[2*n : 3*n]))
heapify(a_front)
heapify(a_back)

sum_f = [0]*(n+1)
sum_b = [0]*(n+1)
sum_f[0] = sum(a_front)
sum_b[n] = sum(a_back)*-1

for i in range(n, 2*n):
    # 前半の処理
    heappush(a_front, a[i])
    sum_f[i-n+1] = sum_f[i-n] + a[i] - heappop(a_front)
    # 後半の処理
    heappush(a_back, -1 * a[3*n-i-1])
    sum_b[2*n-i-1] = sum_b[2*n-i] + a[3*n-i-1] + heappop(a_back)

ans = sum_f[0] - sum_b[0]
for i in range(1, n+1):
    tmp = sum_f[i] - sum_b[i]
    if tmp > ans:
        ans = tmp
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = -10**15
for i in range(n, 2*n+1):
    a_front = a[0 : i]
    a_back = a[i : 3*n]
    a_front.sort(reverse=True)
    a_back.sort()
    tmp = sum(a_front[0:n]) - sum(a_back[0:n])
    if tmp > ans:
        ans = tmp

print(ans)    

Fixed submission:
from heapq import heappop, heapify, heappush

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

a_front = a[0 : n]
a_back = list(map(lambda x: -1*x, a[2*n : 3*n]))
heapify(a_front)
heapify(a_back)

sum_f = [0]*(n+1)
sum_b = [0]*(n+1)
sum_f[0] = sum(a_front)
sum_b[n] = sum(a_back)*-1

for i in range(n, 2*n):
    # 前半の処理
    heappush(a_front, a[i])
    sum_f[i-n+1] = sum_f[i-n] + a[i] - heappop(a_front)
    # 後半の処理
    heappush(a_back, -1 * a[3*n-i-1])
    sum_b[2*n-i-1] = sum_b[2*n-i] + a[3*n-i-1] + heappop(a_back)

ans = sum_f[0] - sum_b[0]
for i in range(1, n+1):
    tmp = sum_f[i] - sum_b[i]
    if tmp > ans:
        ans = tmp
        
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1a

print(ans)


Fixed submission:
x,y = map(int, input().split())

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)

def dfs(tmp, s):
    if len(s) == 1:
        return int(tmp)+int(s)+int(tmp+s)
    
    return int(tmp)*2**(len(s)-1)+dfs(s[0], s[1:]) + dfs(tmp+s[0], s[1:])

print(dfs(s[0], s[1:]))

Fixed submission:
s = input()
n = len(s)

def dfs(tmp, s):
    if len(s) == 1:
        return int(tmp)+int(s)+int(tmp+s)
    
    return int(tmp)*2**(len(s)-1)+dfs(s[0], s[1:]) + dfs(tmp+s[0], s[1:])

if n > 1:
    print(dfs(s[0], s[1:]))
else:
    print(int(s))
Buggy python submission (verdict: Runtime Error):
'''--- input ---'''

# N is Amount of song
N:int = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X:str = input()
#print("X = " + X)
'''--- search ---'''
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        #print("mach is " + Song_List[i][0])
        #print("i is " + str(i))
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
                #print(str(i+1))
        else:
            continue
    else:
        continue
print(ans)

Fixed submission:
# N is Amount of song
N = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X = input()
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
        else:
            continue
    else:
        continue
print(ans)
Buggy python submission (verdict: Runtime Error):
ans=input()
if ans.find!=-1:
    print "Yes"
else:
    print "No"

Fixed submission:
ans=raw_input()
if ans.find('AC')!=-1:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
a = [int(i) for i in input().split()]
if a[0] > a[1]:
  pass
else:
  b = a[0]
  c = a[1]
  a[0] = c
  a[1] = b

b = a[0]
c = a[1]

import fractions

g = fractions.gcd(b,c)

print(int((b * c) / g))

Fixed submission:
t = [int(input()) for i in range(2)] 
k = [1,2,3]
for i in k:
  if i in t:
    pass
  else:
    print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = input().split()
c = ""
for i in list(range(2)):
  c += k[0][i]
  c += k[1][i]
  
print(c)

Fixed submission:
n = int(input())
k = input().split()
c = ""
for i in list(range(n)):
  c += k[0][i]
  c += k[1][i]
  
print(c)
Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	HeightList = list(map(int, input().split()))

	numOfOceanView = 1
	max = HeightList[0] # 0origin
	for i in range(1, N):
		if max < HeightList[i]:
			max = HeightList[i]
			numOfOceanView += 1
	print(numOfOceanView)

main()

Fixed submission:
def main():
	buttons = list(map(int, input().split()))
	aa = buttons[0] + (buttons[0] - 1)
	ab = buttons[0] + buttons[1]
	bb = buttons[1] + (buttons[1] - 1)
	print(max(aa, ab, bb))

main()
Buggy python submission (verdict: Runtime Error):
# バケット法を用いる
def kagamiMochi():
	N = int(input())
	d = []
	for _ in range(0, N):
		d.append(int(input()))

	num = [0] * 100
	for i in range(0, N):
		num[d[i]] += 1

	count = 0
	for j in num:
		if j:
			count += 1
	print(count)

kagamiMochi()

Fixed submission:
def kagamiMochi():
	N = int(input())
	d = []
	for _ in range(0, N):
		d.append(int(input()))
	d.sort()
	count = 1
	for j in range(1, N):
		if d[j] != d[j-1]:
			count += 1
	print(count)

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

MOD = 10**9+7

def combination(n, r):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % MOD
        denom = denom * i % MOD
    return numer * pow(denom, MOD-2, MOD) % MOD


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

if (X+Y)%3!=0:
    print(0)
else:
    a = (2*X-Y)/3
    b = (2*Y-X)/3
    if a<0 or b<0:
        print(0)
    else:
        print(combination(a+b, a))


Fixed submission:
#coding: utf-8
import math
import heapq

MOD = 10**9+7

def combination(n, r):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % MOD
        denom = denom * i % MOD
    return numer * pow(denom, MOD-2, MOD) % MOD


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

if (X+Y)%3!=0:
    print(0)
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    if a<0 or b<0:
        print(0)
    else:
        print(combination(a+b, a))
Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
import math
import heapq

MOD = 10**9+7

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if(L[c]<L[a]+L[b]):
                ans+=1
            else:
                break

print(ans)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        c = bisect.bisect_left(L,L[a]+L[b])
        ans += c-b-1
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
import math
import heapq

MOD = 10**9+7

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if(L[c]<L[a]+L[b]):
                ans+=1

print(ans)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        c = bisect.bisect_left(L,L[a]+L[b])
        ans += c-b-1
            
print(ans)
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def gcd(A,B):
    if A>B:
        A,B = B,A

    if(A%B==0):
        return B
    else:
        return gcd(B,A%B)

A,B = map(int, input().split())
G = gcd(A,B)

ans = 1
for i in range(2,math.ceil(math.sqrt(G))+1):
    if G%i==0:
        ans+=1
        while G%i==0:
            G/=i
if G!=1:
    ans+=1

print(ans)


Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def gcd(A,B):
    if B>A:
        A,B = B,A

    if(A%B==0):
        return B
    else:
        return gcd(B,A%B)

A,B = map(int, input().split())
G = gcd(A,B)

ans = 1
for i in range(2,math.ceil(math.sqrt(G))+1):
    if G%i==0:
        ans+=1
        while G%i==0:
            G/=i
if G!=1:
    ans+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

# 複数個の数値を、intの配列として取得
A = list(map(int, input().split()))
A.sort()

for i in range(M):
    d = A.pop(-1)/2
    bisect.insort_left(A,d)

ans=0
for i in range(N):
    ans+=math.floor(A[i])

print(ans)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

# 複数個の数値を、intの配列として取得
A = list(map(int, input().split()))
A = list(map(lambda x: x * (-1),A))

heapq.heapify(A)
for i in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A,x/2)

ans=0
for a in A:
    ans+=math.floor(-a)

print(ans)
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
B = list(map(int, input().split()))

ans=B[0]+B[N-2]
for i in range(N-1):
    ans+=max(B[i],B[i+1])

print(ans)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
B = list(map(int, input().split()))

ans=B[0]+B[N-2]
for i in range(N-2):
    ans+=min(B[i],B[i+1])

print(ans)
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
from scipy.special import comb

MOD = 10**9+7

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

for i in range(1,K+1):
    ans = (comb(K-1,i-1,exact=True)%MOD)*(comb(N-K+1,i,exact=True)%MOD)%MOD
    print(ans)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
from scipy.misc import comb

MOD = 10**9+7

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

for i in range(1,K+1):
    ans = (comb(K-1,i-1,exact=True)%MOD)*(comb(N-K+1,i,exact=True)%MOD)%MOD
    print(ans)
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
#from scipy.misc import comb

MOD = 10**9+7

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

# 複数個の数値を、intの配列として取得
L = list(map(int, input().split()))

# (x,y)みたいな構造体をN個まとめてリストにするとき
A = []
for i in range(N):
    a = tuple(map(int, input().split()))
    A.append(a)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
#from scipy.misc import comb

MOD = 10**9+7

N,M = map(int, input().split())
A = []
for i in range(M):
    a = int(input())
    A.append(a)    

ans = [1,1]+[0]*(N-1)
for a in A:
    ans[a]=-1

for i in range(2,N+1):
    if ans[i]!=-1:
        if ans[i-2]!=-1:
            ans[i]=(ans[i]+ans[i-2])%MOD
        if ans[i-1]!=-1:
            ans[i]=(ans[i]+ans[i-1])%MOD

print(ans[N])