Problem p02782 (python)

Fixed submission:
import sys
import math
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    K= c+d+5
    fac = [0 for i in range(K+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,K+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(e,f):
        return (fac[e+f]*pow(fac[e],MOD-2,MOD)*pow(fac[f],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()
#print the result

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    K= c+d+5
    fac = [0 for _ in range(K+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,K+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(e,f):
        return (fac[e+f]*pow(fac[e],MOD-2,MOD)*pow(fac[f],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()
#print the result

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    P= c+d+5
    fac = [0 for _ in range(P+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,P+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MODE = 10**9+7
    NU = c+d+5
    fac = [0 for _ in range(NU+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,NU+1):
        fac[i] = (fac[i-1]*i)%MODE
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MODE-2,MODE)*pow(fac[y],MODE-2,MODE))%MODE
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MODE)
    
if _name_ == "_main_":
    main()