Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    #s = x+ y+ z
    ret =[0]*(N+1)
    for n in range(1,N+1):
        for s in range(3,int(N**0.5)+3):
            for z in range(1,s+1):
                for y in range(1,s-z+1):
                    x = s - z - y
                    if s**2==n + x*y+y*z+z*x:
                        if x>=1 and y>=1 and z>=1:
                            ret[n]+=1
    for a in ret[1:]:
        print(a)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    #s = x+ y+ z
    ret =[0]*(N+1)
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                n = x**2+y**2+z**2+x*y+y*z+z*x
                if n<=N:
                    ret[n] += 1
    for i in ret[1:N+1]:
        print(i)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def factorization(n):
    primen, degree, primend = [], [], {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            primen.append(i)
            degree.append(cnt)
            primend[i] = cnt
    if temp!=1:
        primen.append(temp)
        degree.append(1)
        primend[temp] = 1
    if primen==[]:
        primen.append(n)
        degree.append(1)
        primend[n] = 1
    return degree

def main():
    N = int(input())
    ret = 0
    for i in range(1,N+1):
        x = factorization(i)
        cnt = 1
        for xx in x:
            cnt*=(xx+1)
        ret += i * cnt

    print(ret-1)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    ret = 0
    for i in range(1,N+1):
        x = (N//i)
        ret += x*(x+1)*i//2
    print(ret)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [None]*N
B = [None]*N

for i in range(N):
  a,b = map(int, input().split())
  A[i]=a
  B[i]=b
  A.sort()
  B.sort()

  if N%2==0:
    x=A[N//2-1]
    y=B[N//2]
    else:
      x=A[N//2]
      y=B[N//2]
      print(y-x+1)


Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = [None]*N
    B = [None]*N

    for i in range(N):
        a,b = map(int, input().split())
        A[i]=a
        B[i]=b
    A.sort()
    B.sort()

    if N%2==0:
        x=A[N//2-1]+A[N//2]
        y=B[N//2-1]+B[N//2]
        print(y-x+1)
    else:
        x=A[N//2]
        y=B[N//2]
        print(y-x+1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N,S=map(int, input().split())
    A = list(map(int,input().split()))
    mod = 998244353
    dp = [[0]*(S+1) for i in range(N+1)]
    dp[0][0]=1
    for i in range(N):
        vi = A[i]
        for j in range(S+1):
            dp[i+1][j] += 2 * dp[i][j]
            dp[i+1][j] %= mod
            if j+vi<=S:
                dp[i+1][j+vi] += dp[i][j]
                dp[i+1][j+vi] %= mod

    print(dp[N][S])

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N,S=map(int, input().split())
    A = list(map(int,input().split()))
    mod = 998244353
    dp = [[0]*(S+1) for i in range(N+1)]
    dp[0][0]=1
    for i in range(N):
        vi = A[i]
        for j in range(S+1):
            dp[i+1][j] += 2 * dp[i][j]
            dp[i+1][j] %= mod
            if j+vi<=S:
                dp[i+1][j+vi] += dp[i][j]
                dp[i+1][j+vi] %= mod

    print(dp[N][S])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N,S=map(int, input().split())
    A = list(map(int,input().split()))
    mod = 998244353
    dp = [[0]*(S+1) for i in range(N+1)]
    dp[0][0]=1
    for i in range(N):
        vi = A[i]
        for j in range(S+1):
            if j+vi<=S:
                dp[i+1][j+vi] += dp[i][j]
                dp[i+1][j] += 2 * dp[i][j]
                dp[i+1][j+vi] %= mod
            else:
                dp[i+1][j] += 2 * dp[i][j]
            dp[i+1][j] %= mod

    print(dp[N][S])

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N,S=map(int, input().split())
    A = list(map(int,input().split()))
    mod = 998244353
    dp = [[0]*(S+1) for i in range(N+1)]
    dp[0][0]=1
    for i in range(N):
        vi = A[i]
        for j in range(S+1):
            dp[i+1][j] += 2 * dp[i][j]
            dp[i+1][j] %= mod
            if j+vi<=S:
                dp[i+1][j+vi] += dp[i][j]
                dp[i+1][j+vi] %= mod

    print(dp[N][S])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int,input().split())
li = [1]*a
li += [0]*b
li += [-1]*c
print(sum(li[:k]))

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    A, B, C, K = map(int, input().split())
    if K<=A:
        print(K)
    elif K<=(A+B):
        print(A)
    elif K<=(A+B+C):
        print(A-(K-A-B))
    else:
        print(A-C)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    nw = 1
    lp0 = [1]
    for i in range(N):
        nw = A[nw-1]
        if nw in lp0:
            break
        else:
            lp0.append(nw)
    lpc = i+1 - lp0.index(nw)
    lp = lp0[-lpc:]

    if K<=len(lp0)-1:
        print(lp0[K])
    else:
        K-= len(lp0)-1
        K=K%lpc - 1
        print(lp[K])

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    nw = 1
    lp0 = [1]
    lpl = {1}
    for i in range(N):
        nw = A[nw-1]
        if nw in lpl:
            break
        else:
            lp0.append(nw)
            lpl.add(nw)
    lpc = i+1 - lp0.index(nw)
    lp = lp0[-lpc:]

    if K<=len(lp0)-1:
        print(lp0[K])
    else:
        K-= len(lp0)-1
        K=K%lpc - 1
        print(lp[K])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    nw = 1
    lp0 = [1]
    for i in range(N):
        nw = A[nw-1]
        if nw in lp0:
            break
        else:
            lp0.append(nw)
    lpc = i+1 - lp0.index(nw)
    lp = lp0[-lpc:]

    if K<=len(lp0)-1:
        print(lp0[K])
    else:
        K-= len(lp0)-1
        K=K%lpc - 1
        print(lp[K])

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    nw = 1
    lp0 = [1]
    lpl = {1}
    for i in range(N):
        nw = A[nw-1]
        if nw in lpl:
            break
        else:
            lp0.append(nw)
            lpl.add(nw)
    lpc = i+1 - lp0.index(nw)
    lp = lp0[-lpc:]

    if K<=len(lp0)-1:
        print(lp0[K])
    else:
        K-= len(lp0)-1
        K=K%lpc - 1
        print(lp[K])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    dic_Lg = {}
    dic_Lw = {}
    for i in range(N):
        x = i - A[i]
        if x in dic_Lg:
            dic_Lg[x]+=1
        else:
            dic_Lg[x]=1
        y = i + A[i]
        if y in dic_Lw:
            dic_Lw[y]+=1
        else:
            dic_Lw[y]=1
        LP = list(dic_Lw.keys()) + list(dic_Lg.keys())
        LP = set(LP)

    ret = 0
    for i in LP:
        if i in dic_Lg and i in dic_Lw:
            ret += dic_Lg[i] * dic_Lw[i]
    print(ret)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    dic_Lg = {}
    for i in range(N):
        x = i - A[i]
        if x in dic_Lg:
            dic_Lg[x].append(i)
        else:
            dic_Lg[x]=[i]
    ret = 0
    for i in range(N):
        y = i+A[i]
        if not y in dic_Lg:
            continue
        arr = dic_Lg[y]
        r = bisect_right(arr, i)    # 5が入るべき境目のうち最も右側の境目を返す
        ret += len(arr)-r
    print(ret)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    A, B, N = map(int, input().split())
    N = min(B-1, N)
    ret = 0
    for x in range(N+1):
        ret = max(ret, (x * A)//B - A * (x//B))

    print(ret)



if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    A, B, N = map(int, input().split())
    N = min(B-1, N)
    ret = (N * A)//B - A * (N//B)
    print(ret)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    A, B, N = map(int, input().split())
    ret = 0
    for i in range(min(B,N+1)):
        ret = max(ret, i*A//B)
    print(ret)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    A, B, N = map(int, input().split())
    N = min(B-1, N)
    ret = (N * A)//B - A * (N//B)
    print(ret)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()[::-1]
    L = len(S)
    dp = [0] * 2019
    wk = 0
    r = 1
    for i in range(L):
        wk += int(S[i])*r
        wk %= 2019
        r *= 10
        dp[wk] += 1
    ret = dp[0]
    for i in range(2019):
        ret += dp[i]*(dp[i]-1)//2
    print(ret)


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()[::-1]
    L = len(S)
    dp = [0] * 2019
    wk = 0
    r = 1
    for i in range(L):
        wk += int(S[i])*r
        wk %= 2019
        r *= 10
        r %= 2019
        dp[wk] += 1
    ret = dp[0]
    for i in range(2019):
        ret += dp[i]*(dp[i]-1)//2
    print(ret)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()[::-1]
    L = len(S)
    dp = [0] * 2019
    wk = 0
    for i in range(L):
        wk = (int(S[i])*(10**i) + wk)%2019
        dp[wk] += 1
    ret = dp[0]
    for i in range(2019):
        ret += dp[i]*(dp[i]-1)//2
    print(ret)


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()[::-1]
    L = len(S)
    dp = [0] * 2019
    wk = 0
    r = 1
    for i in range(L):
        wk += int(S[i])*r
        wk %= 2019
        r *= 10
        r %= 2019
        dp[wk] += 1
    ret = dp[0]
    for i in range(2019):
        ret += dp[i]*(dp[i]-1)//2
    print(ret)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ret = 0
for j in range(1,N-1):
  if S[j]=='R':
    ret += S[:j].count('G')*S[j+1:].count('B')
    ret += S[:j].count('B')*S[j+1:].count('G')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='R' and S[j+(j-i)]!='R':
          ret -=1
  elif S[j]=='G':
    ret += S[:j].count('B')*S[j+1:].count('R')
    ret += S[:j].count('R')*S[j+1:].count('B')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='G' and S[j+(j-i)]!='G':
          ret -=1
  elif S[j]=='B':
    ret += S[:j].count('R')*S[j+1:].count('G')
    ret += S[:j].count('G')*S[j+1:].count('R')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='B' and S[j+(j-i)]!='B':
          ret -=1
print(ret)

Fixed submission:
N=int(input())
S=input()
ret = 0
for j in range(1,N-1):
  if S[j]=='R':
    ret += S[:j].count('G')*S[j+1:].count('B')
    ret += S[:j].count('B')*S[j+1:].count('G')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='R' and S[j+(j-i)]!='R':
          ret -=1
  elif S[j]=='G':
    ret += S[:j].count('B')*S[j+1:].count('R')
    ret += S[:j].count('R')*S[j+1:].count('B')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='G' and S[j+(j-i)]!='G':
          ret -=1
  elif S[j]=='B':
    ret += S[:j].count('R')*S[j+1:].count('G')
    ret += S[:j].count('G')*S[j+1:].count('R')
    for i in range(j):
      if j+j-i<N:
        if S[i]!=S[j+(j-i)] and S[i]!='B' and S[j+(j-i)]!='B':
          ret -=1
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
md = pow(10,9) + 7

cnt_memo = [0]*(K+1)
cnt_R_memo = [0]*(K+1)

def main():
    ret = 0
    for k in range(1,K+1):
        cnt_R_memo[k]=pow(K//k,N)%md
    for k in range(K,0,-1):
        cnt_memo[k]=(cnt_R_memo[k] - sum(cnt_memo[2*k::k]))%md
        ret += (cnt_memo[k]*k)%md
    print(ret%md)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
md = pow(10,9) + 7

cnt_memo = [0]*(K+1)
cnt_R_memo = [0]*(K+1)

def main():
    ret = 0
    for k in range(1,K+1):
        cnt_R_memo[k]=pow(K//k,N,md)
    for k in range(K,0,-1):
        cnt_memo[k]=(cnt_R_memo[k] - sum(cnt_memo[2*k::k]))%md
        ret += (cnt_memo[k]*k)%md
    print(ret%md)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
md = pow(10,9) + 7

cnt_memo = [0]*(K+1)
cnt_R_memo = [0]*(K+1)

def main():
    ret = 0
    for k in range(1,K+1):
        cnt_R_memo[k]=pow(K//k,N)%md
    for k in range(K,0,-1):
        cnt_memo[k]=(cnt_R_memo[k] - sum(cnt_memo[2*k::k]))%md
        ret += (cnt_memo[k]*k)%md
    print(ret%md)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
md = pow(10,9) + 7

cnt_memo = [0]*(K+1)
cnt_R_memo = [0]*(K+1)

def main():
    ret = 0
    for k in range(1,K+1):
        cnt_R_memo[k]=pow(K//k,N,md)
    for k in range(K,0,-1):
        cnt_memo[k]=(cnt_R_memo[k] - sum(cnt_memo[2*k::k]))%md
        ret += (cnt_memo[k]*k)%md
    print(ret%md)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

# 有向グラフで優先度付きキューで探索

from heapq import heapify, heappop, heappush, heappushpop
from collections import Counter

INF = float('inf')

def dijkstra(s,n,g):
    seen = [False]*n
    cost = [INF]*n
    cost[s] = 0 #スタートはコスト0
    next_q = [(0,s)]
    heapify(next_q)
    while len(next_q)>0:
        c, i = heappop(next_q)
        if cost[i] < c:
            continue
        for nedge, ncost in g[i]:
            nc = cost[i]+ncost
            if cost[nedge]>nc:
                cost[nedge] = nc
                heappush(next_q,(nc, nedge))
    return cost

def main():
    N, X, Y = map(int, input().split())
    graph_F = [[] for _ in range(N)]
    #リストの作成
    for i in range(N-1):
        graph_F[i].append((i+1,1))
        graph_F[i+1].append((i,1))
    graph_F[X-1].append((Y-1,1))
    graph_F[Y-1].append((X-1,1))

    ret = []
    for s in range(N):
        ret += dijkstra(s,N,graph_F)
    ret = Counter(ret)
    for i in range(1,N):
        print(ret[i]//2)

if __name__ == '__main__':
    main()

Fixed submission:
from heapq import heapify, heappop, heappush, heappushpop
import sys
input = sys.stdin.readline
N,X,Y=map(int, input().split())
def f(i,j):
  ret1 = abs(j-i)
  ret2 = abs(j-Y)+1+abs(i-X)
  ret3 = abs(i-Y)+1+abs(j-X)
  return min(ret1,ret2,ret3)
  
dp=[0]*N
for i in range(1,N+1):
  for j in range(i+1,N+1):
    dp[f(i,j)] += 1
for i in range(1,N):
  print(dp[i])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
lQ = list(range(int(input())))
def main(S):
  T = True
  for i in lQ:
    q = list(input().split())
    if q[0]=='1':
      T = not(T)
    else:
      if (T and q[1]=='1') or (not(T) and q[1]=='2'):
        S = q[2] + S
      elif (T and q[1]=='2') or (not(T) and q[1]=='1'):
        S = S + q[2]
  if T:
    print(S)
  else:
    print(S[::-1])
main(S)

Fixed submission:
S = input()
lQ = list(range(int(input())))
def main(S):
  T = True
  L = ''
  R = ''
  for i in lQ:
    q = list(input().split())
    if q[0]=='1':
      T = not(T)
    else:
      if (T and q[1]=='1') or (not(T) and q[1]=='2'):
        L += q[2]
      elif (T and q[1]=='2') or (not(T) and q[1]=='1'):
        R += q[2]
  SS = L[::-1] + S + R
  if T:
    print(SS)
  else:
    print(SS[::-1])
main(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
T = True
for i in range(Q):
  q = list(input().split())
  if q[0]=='1':
    T = not(T)
  else:
    if (T and q[1]=='1') or (not(T) and q[1]=='2'):
      S = q[2] + S
    elif (T and q[1]=='2') or (not(T) and q[1]=='1'):
      S = S + q[2]
if T:
  print(S)
else:
  print(S[::-1])

Fixed submission:
S = input()
lQ = list(range(int(input())))
def main(S):
  T = True
  L = ''
  R = ''
  for i in lQ:
    q = list(input().split())
    if q[0]=='1':
      T = not(T)
    else:
      if (T and q[1]=='1') or (not(T) and q[1]=='2'):
        L += q[2]
      elif (T and q[1]=='2') or (not(T) and q[1]=='1'):
        R += q[2]
  SS = L[::-1] + S + R
  if T:
    print(SS)
  else:
    print(SS[::-1])
main(S)
Buggy python submission (verdict: Time Limit Exceeded):
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=1
for i in range(1, k+1):
  com=(((com*(n-i+1))%p)*modinv(i,p))%p
  if i==a:
    coma=com
  if i==b:
    comb=com
print((2**n-1-coma-comb)%p)


Fixed submission:
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((pow(2,n,p)-1-com[a]-com[b])%p)

Buggy python submission (verdict: Time Limit Exceeded):
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
com=[0]*(k+1)
com[0]=1
def ma():
  for i in list(range(1, k+1)):
    dm=(com[i-1]*(n-i+1))%p
    com[i]=(dm*pow(i,p-2,p))%p
  print((2**n-1-com[a]-com[b])%p)
ma()

Fixed submission:
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((pow(2,n,p)-1-com[a]-com[b])%p)

Buggy python submission (verdict: Time Limit Exceeded):
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((2**n-1-com[a]-com[b])%p)

Fixed submission:
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((pow(2,n,p)-1-com[a]-com[b])%p)
Buggy python submission (verdict: Runtime Error):
int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    cnt-=1
  else:
    prev=B[i]
print(cnt)  


Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = [X-L,X+L]
    XL.sort(key=lambda x:x[1])
    ret = 1
    TMP = XL[0][1]
    for x in XL[1:]:
        if TMP<=x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    nt-=1
  else:
    prev=B[i]
print(cnt)  


Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = [X-L,X+L]
    XL.sort(key=lambda x:x[1])
    ret = 1
    TMP = XL[0][1]
    for x in XL[1:]:
        if TMP<=x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
 int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    nt-=1
  else:
    prev=B[i]
print(cnt)  

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = [X-L,X+L]
    XL.sort(key=lambda x:x[1])
    ret = 1
    TMP = XL[0][1]
    for x in XL[1:]:
        if TMP<=x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
elif:
  print(0,max(b+a-k,0))

Fixed submission:
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
else:
  print(0,max(b+a-k,0))
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N%2==1:
  print(ans)
else:
  cnt = 0
  NN = (N//10)*10
  for i in range(25):
    cnt += NN//((5**(i+1))*2)
  print(cnt)

Fixed submission:
N = int(input())

if N%2==1:
  print(0)
else:
  cnt = 0
  NN = (N//10)*10
  for i in range(25):
    cnt += NN//((5**(i+1))*2)
  print(cnt)