TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
import sys
sys.setrecursionlimit(2000000000)

p = 10 ** 9 + 7
N = 2*10 ** 6  
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

def comb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p



a1,b1,a2,b2=map(int,input().split())
score=comb(a2+b2+2,a2+1,p)-comb(a2+b1+1,a2+1,p)-comb(a1+b2+1,a1,p)+comb(a1+b1,a1,p)
print(score%(10**9+7))

import sys
sys.setrecursionlimit(2000000000)

def comb(n,r):
  def cmb(n, r, p):
      if (r < 0) or (n < r):
          return 0
      r = min(r, n - r)
      return fact[n] * factinv[r] * factinv[n-r] % p

  p = 10 ** 9 + 7
  N = 10 ** 6  
  fact = [1, 1]  # fact[n] = (n! mod p)
  factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
  inv = [0, 1]  

  for i in range(2, N + 1):
      fact.append((fact[-1] * i) % p)
      inv.append((-inv[p % i] * (p // i)) % p)
      factinv.append((factinv[-1] * inv[-1]) % p)
  return cmb(n, r, p)

a1,b1,a2,b2=map(int,input().split())
score=comb(a2+b2+2,a2+1)-comb(a2+b1+1,a2+1)-comb(a1+b2+1,a1)+comb(a1+b1,a1)
print(score%(10**9+7))

a1,b1,a2,b2=map(int,input().split())

import sys
sys.setrecursionlimit(2000000000)

p = 10 ** 9 + 7
N = a2+b2+2  
R = max(a2+1,b2+1)
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  
for i in range(2, R + 1):
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

def comb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

score=comb(a2+b2+2,a2+1,p)-comb(a2+b1+1,a2+1,p)-comb(a1+b2+1,a1,p)+comb(a1+b1,a1,p)
print(score%(10**9+7))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
#import sys
#input = sys.stdin.readline
Q = 10**9+7
def getInv(N):
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv


#     inv = [0] * (N + 1)
#     inv[0] = 1
#     inv[1] = 1


#         inv[i] = (-(Q // i) * inv[Q%i]) % Q
#         ret[i] = ret[i-1]*inv[i]
#     return ret

def getFactorial(N):
    ret = [1]*(N+1)
    for i in range(2,N+1):
        ret[i] = ret[i-1]*i%Q
    return ret

def main():
    r1, c1, r2, c2 = map( int, input().split())
    F = getFactorial(2*(10**6))
    J = getInv(2*(10**6))
    I = [0]*(2*(10**6)+1)
    I[0] = 1
    I[1] = 1
    for i in range(2,2*(10**6)+1):
        I[i] = I[i-1]*J[i]%Q
    #print(F[5]*I[5]%Q)
    a = 0
    b = 0
    c = 0
    d = 0
    for i in range(1, c2+1):
        a += F[r2+i+1]*I[i+1]%Q*I[r2]%Q-1
#        print(F[r2+i+1]*I[i+1]%Q*I[r2]%Q-1)
        a %= Q
    if r1 == 1:
        b = 0
    else:
        for i in range(1, c2+1):
            b += F[r1+i]*I[i]%Q*I[r1]%Q-1
            b %= Q
    if c1 == 1:
        c = 0
    else:
        for i in range(1, c1):
            c += F[r2+i+1]*I[i+1]%Q*I[r2]%Q-1
            c %= Q
    if c1 == 1 or r1 == 1:
        d = 0
    else:
        for i in range(1, c1):
            d += F[r1+i]*I[i]%Q*I[r1]%Q-1
            d %= Q
#    print(a, b,c, d)
    print((a-b-c+d)%Q)
if __name__ == '__main__':
    main()


Q = 10**9+7
def getInv(N):
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv

def getFactorialInv(N):
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    ret = [1]*(N+1)
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
        ret[i] = ret[i-1]*inv[i]%Q
    return ret

def getFactorial(N):
    ret = [1]*(N+1)
    for i in range(2,N+1):
        ret[i] = ret[i-1]*i%Q
    return ret

def main():
    r1, c1, r2, c2 = map( int, input().split())
    F = getFactorial(2*10**6+2)
    I = getFactorialInv(10**6+1)

    def G(a, b):
        return F[a+b+2]*I[a+1]%Q*I[b+1]%Q
    
    print( ( G(r2,c2) - G(r2, c1-1) - G(r1-1, c2) + G(r1-1, c1-1))%Q)
if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
MOD = 10**9+7
list_size = (10**6+10)*4

f_list = [1]*list_size
f_r_list = [1]*list_size

for i in range(list_size - 1):
    f_list[i+1] = ((f_list[i] * (i+2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
    f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)



r1,c1,r2,c2 = map(int,input().split())

ans = f_list[(r2+c2)*2]*f_r_list[r2*2]*f_r_list[c2*2]
ans %= MOD
ans += f_list[(r1+c1-2)*2]*f_r_list[r1*2-2]*f_r_list[c1*2-2]
ans %= MOD
ans -= f_list[(r2+c1)*2]*f_r_list[r2*2]*f_r_list[c1*2]
ans %= MOD
ans -= f_list[(c2+r1)*2]*f_r_list[c2*2]*f_r_list[r1*2]
ans %= MOD

print(ans)




MOD = 10**9+7
list_size = (10**6+10)*4

f_list = [1]*list_size
f_r_list = [1]*list_size

for i in range(list_size - 1):
    f_list[i+1] = ((f_list[i] * (i+2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
    f_r_list[i] = ((f_r_list[i+1] * (list_size + 2 + i)) % MOD)



r1,c1,r2,c2 = map(int,input().split())

ans = f_list[(r2+c2)*2]*f_r_list[r2*2]*f_r_list[c2*2]
ans %= MOD
ans += f_list[(r1+c1)*2]*f_r_list[r1*2]*f_r_list[c1*2]
ans %= MOD
ans -= f_list[(r2+c1)*2]*f_r_list[r2*2]*f_r_list[c1*2]
ans %= MOD
ans -= f_list[(c2+r1)*2]*f_r_list[c2*2]*f_r_list[r1*2]
ans %= MOD

print(ans)




MOD = 10**9+7
r1,c1,r2,c2 = map(int,input().split())

size = 1010000*2
f_list = [1]*(size)
for i in range(1,size):
    f_list[i] = (f_list[i-1]*i)%MOD

def func(r,c):
    return (f_list[r+c]*pow(f_list[r],MOD-2,MOD)*pow(f_list[c],MOD-2,MOD))

ans = func(r2+1,c2+1)-1
ans += func(r1,c1)-1
ans -= func(r2+1,c1)-1
ans -= func(r1,c2+1)-1
print(ans%MOD)



Verdicts: Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
#from scipy.special import comb
r1, c1, r2, c2 = map(int, input().split())
#mod = 1000000007
#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod



p = 10 ** 9 + 7
N = 10 ** 6  * 2 + 100
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p

hole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)
rect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)
rect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)
duplicate = (cmb(r1 + c1, r1, p) - 1)
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

from scipy.misc import comb
r1, c1, r2, c2 = map(int, input().split())
mod = 1000000007
hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
ans = (hole - rect1 - rect2 + duplicate) % mod
print(ans)

#from scipy.special import comb
r1, c1, r2, c2 = map(int, input().split())
#mod = 1000000007
#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod



p = 10 ** 9 + 7
N = 1010000*2  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p

hole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)
rect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)
rect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)
duplicate = (cmb(r1 + c1, r1, p) - 1)
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if n<k:
    return 0
  if n-k<k:
    k=n-k
  c=1
  for x in range(n-k+1,n+1):
    c=(c*x)%mod
  d=1
  for x in range(1,k+1):
    d=(d*x)%mod
  c=c*pow(d,mod-2,mod)
  return c%mod
def f(i,j):
  return comb(i+j,i,mod)
ans=f(r2+1,c2+1)-f(r2+1,c1+1)-f(r1+1,c2+1)+f(r1+1,r2+1)
ans%=mod
print(ans)

r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if n<k:
    return 0
  if n-k<k:
    k=n-k
  c=1
  for x in range(n-k+1,n+1):
    c=(c*x)%mod
  d=1
  for x in range(1,k+1):
    d=(d*x)%mod
  c=c*pow(d,mod-2,mod)
  return c%mod
def f(i,j):
  return comb(i+j,i,mod)
ans=f(r2+1,c2+1)-f(r2+1,c1+1)-f(r1+1,c2+1)+f(r1+1,c1+1)
ans%=mod
print(ans)


r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if n<k:
    return 0
  if n-k<k:
    k=n-k
  c=1
  for x in range(n-k+1,n+1):
    c=(c*x)%mod
  d=1
  for x in range(1,k+1):
    d=(d*x)%mod
  c=c*pow(d,mod-2,mod)
  return c%mod
def f(i,j):
  return comb(i+j,i,mod)
ans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,r2)
ans%=mod
print(ans)


r1,c1,r2,c2=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if n<k:
    return 0
  if n-k<k:
    k=n-k
  c=1
  for x in range(n-k+1,n+1):
    c=(c*x)%mod
  d=1
  for x in range(1,k+1):
    d=(d*x)%mod
  c=c*pow(d,mod-2,mod)
  return c%mod
def f(i,j):
  return comb(i+j,i,mod)
ans=f(r2+1,c2+1)-f(r2+1,c1)-f(r1,c2+1)+f(r1,c1)
ans%=mod
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
import os
import sys

from scipy.misc import comb

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# MOD = 998244353


R1, C1, R2, C2 = list(map(int, sys.stdin.buffer.readline().split()))




# ncr(n, r) == ncr(n-1,r) + (n-1,r-1)
# nhr(n, r) == sum([nhr(n-1,k) for k in range(r)])


# g(R2, C2) - g(R1-1, C2) - g(R2, C1-1) + g(R1-1, C1-1)

def f(n, r):
    return comb(n + r, r, exact=True)


# @debug
def g(r, c):
    
    
    
    

    
    return f(r + 1, c + 1) - f(r, 0)


ans = g(R2, C2) - g(R1 - 1, C2) - g(R2, C1 - 1) + g(R1 - 1, C1 - 1)
ans %= MOD
print(ans)


import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def mod_invs(max, mod):
    
    invs = [1] * (max + 1)
    invs[0] = 0
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    
    ret = [1]
    r = 1
    for inv in mod_invs(max, mod)[1:]:
        r = r * inv % mod
        ret.append(r)
    return ret


def get_factorials(max, mod=None):
    
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


class Combination:
    def __init__(self, max, mod):
        
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


R1, C1, R2, C2 = list(map(int, sys.stdin.buffer.readline().split()))

comb = Combination(max=10 ** 6 * 2 + 100, mod=MOD)




# ncr(n, r) == ncr(n-1,r) + (n-1,r-1)
# nhr(n, r) == sum([nhr(n-1,k) for k in range(r)])


# g(R2, C2) - g(R1-1, C2) - g(R2, C1-1) + g(R1-1, C1-1)

def f(n, r):
    return comb.ncr(n + r, r)


# @debug
def g(r, c):
    
    
    
    

    
    return f(r + 1, c + 1) - f(r, 0)


ans = g(R2, C2) - g(R1 - 1, C2) - g(R2, C1 - 1) + g(R1 - 1, C1 - 1)
ans %= MOD
print(ans)


Verdicts: Time Limit Exceeded

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
import sys
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
K = ir()
length = len(str(N))

def F(length, K, N):
    if length < K:
        return 0
    if K == 0:
        return 1
    if length == 1: 
        return N
    ret = 0
    top = int(str(N)[0])
    if length-K >= 1:
        ret += factorial(length-1) // factorial(K) // factorial(length-K-1) * 9 ** K 
    ret += factorial(length-1) // factorial(K-1) // factorial(length-K) * (top-1) * 9 ** (K-1) 
    
    if K > 1: 
        N = int(str(N)[1:])
        length = len(str(N))
        ret += F(length, K-1, N)
    else:
        ret += 1 
    return ret

answer = F(length, K, N)
print(answer)


# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7

def cmb(n, k):
    if k < 0 or k > n: return 0 
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 2 * 10 ** 6 + 3  
fact, fact_inv = make_fact(U, MOD)

r1, c1, r2, c2 = lr()
answer = cmb(r2+c2+2, r2+1) - 1
answer -= cmb(r2+c1+1, r2+1) - 1
answer -= cmb(r1+c2+1, c2+1) - 1
answer += cmb(r1+c1, r1) - 1
print(answer % MOD)
# 26

Verdicts: Runtime Error

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
#F
from operator import mul
from functools import reduce

r1, c1, r2, c2 = [int(i) for i in input().split()]
mod = 10**9 + 7

#pre-caluculation of the factorial
num = 10**7
fact=[0] * num
fact[0]=1
for i in range(1, num):
    fact[i] = (fact[i-1] * i) % mod

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def f(rr,cc):
    
    #print(rr+cc+2, cc+1)
    #print(combinations_count(rr+cc+2, cc+1))
    #return combinations_count(rr+cc+2, cc+1) - 1
    return (fact[rr+cc+2]%mod * pow(fact[rr+1]*fact[cc+1], mod-2, mod)) % mod -1

ans = f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)
print(ans % mod)

#F
from operator import mul
from functools import reduce

r1, c1, r2, c2 = [int(i) for i in input().split()]
mod = 10**9 + 7

#pre-caluculation of the factorial
num = 10**6*2+3
fact=[0] * num
fact[0]=1
for i in range(1, num):
    fact[i] = (fact[i-1] * i) % mod

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def f(rr,cc):
    
    #print(rr+cc+2, cc+1)
    #print(combinations_count(rr+cc+2, cc+1))
    #return combinations_count(rr+cc+2, cc+1) - 1
    return (fact[rr+cc+2]%mod * pow(fact[rr+1]*fact[cc+1], mod-2, mod)) % mod -1

ans = f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)
print(ans % mod)

Verdicts: Time Limit Exceeded

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
mod = 10**9+7

def f(n,k,p):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)
        denom = denom*i
    return numer*pow(denom,p-2,p)%p

r1,c1,r2,c2 = map(int,input().split(" "))
ans = f(r2+c2+2,c2+1,mod)-g(r2+c1+1,c1,mod)-g(r1+c2+1,c2+1,mod)+g(r1+c1,c1,mod)
print(ans%mod)

mod = 10**9+7

f = [1]*(2*10**6+5)
f[0] = 1
for i in range(1,2*10**6+4):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)

Verdicts: Runtime Error

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
import sys
from itertools import product
from collections import defaultdict
read = sys.stdin.read
sys.setrecursionlimit(1000000)

r1, c1, r2, c2 = map(int, read().split())
mod = 10 ** 9 + 7
dic = {}


def count(r, c):
    if r * c == 0:
        return 1
    if (r - 1, c) in dic:
        a = dic[(r - 1, c)]
    else:
        a = dic[(r - 1, c)] = count(r - 1, c) % mod
    if (r, c - 1) in dic:
        b = dic[(r, c - 1)]
    else:
        b = dic[(r, c - 1)] = count(r, c - 1) % mod
    return (a + b) % mod


dic[(r1 - 1, c2)] = count(r1 - 1, c2)
dic[(r2, c1 - 1)] = count(r2, c1 - 1)
res = 0
for r, c in product(range(r1, r2 + 1), range(c1, c2 + 1)):
    tmp = dic[(r, c)] = dic[(r - 1, c)] + dic[(r, c - 1)]
    res += tmp % mod
print(res % mod)

import sys
from itertools import product
read = sys.stdin.read
sys.setrecursionlimit(1000000)

r1, c1, r2, c2 = map(int, read().split())
mod = 10 ** 9 + 7
dic = {}


def count(r, c):
    if r * c == 0:
        return 1
    if (r - 1, c) in dic:
        a = dic[(r - 1, c)]
    else:
        a = dic[(r - 1, c)] = count(r - 1, c) % mod
    if (r, c - 1) in dic:
        b = dic[(r, c - 1)]
    else:
        b = dic[(r, c - 1)] = count(r, c - 1) % mod
    return (a + b) % mod


dic[(r1 - 1, c2)] = count(r1 - 1, c2)
dic[(r2, c1 - 1)] = count(r2, c1 - 1)
res = 0
for r, c in product(range(r1, r2 + 1), range(c1, c2 + 1)):
    tmp = dic[(r, c)] = dic[(r - 1, c)] + dic[(r, c - 1)]
    res += tmp % mod
print(res % mod)

import numpy as np
import sys
read = sys.stdin.read
r1, c1, r2, c2 = map(int, read().split())
MOD = 10 ** 9 + 7


def cumprod(A, MOD=MOD):
    L = len(A)
    Lsq = int(L**.5 + 1)
    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        A[:, n] *= A[:, n - 1]
        A[:, n] %= MOD
    for n in range(1, Lsq):
        A[n] *= A[n - 1, -1]
        A[n] %= MOD
    return A.ravel()[:L]


def make_fact(U, MOD=MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    fact.flags.writeable = False
    fact_inv.flags.writeable = False
    return fact, fact_inv


fac, finv = make_fact(2 * 10**6 + 10, MOD)


def comb(n, k, mod=MOD, fac=fac, finv=finv):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


answer = comb(r2 + c2 + 2, r2 + 1) - comb(r1 + c2 + 1, r1) - \
    comb(c1 + r2 + 1, c1) + comb(r1 + c1, r1)
answer %= MOD
print(answer)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
r1, c1, r2, c2 = map(int, input().split())
L = 10 ** 9 + 7
  

def get_combi (n, k):

  r = k if k > n - k else n - k
  s = n - r
  M = [0] * (s + 1)
  N = 1
  for i in range(n, r, -1):
    for j in range(2, s + 1):
      if M[j] == 0 and i % j == 0:
        i = i / j
        M[j] = 1
    N *= i
    N = N % L

  return (N)

combi1 = get_combi(r2 + c2 + 2, r2 + 1)
combi2 = get_combi(r2 + c1 + 1, c1)
combi3 = get_combi(r1 + c2 + 1, r1)
combi4 = get_combi(r1 + c1, r1)

print (combi1)
print (combi2)
print (combi3)
print (combi4)
print (combi1 - combi2 - combi3 + combi4)

r1, c1, r2, c2 = map(int, input().split())
L = 10 ** 9 + 7
  

def get_combi (n, k):

  r = k if k > n - k else n - k
  s = n - r
  M = [0] * (s + 1)
  N = 1
  for i in range(n, r, -1):
    for j in range(2, s + 1):
      if M[j] == 0 and i % j == 0:
        i = i / j
        M[j] = 1
    N *= i
    N = N % L

  return (N)

combi1 = get_combi(r2 + c2 + 2, r2 + 1)
combi2 = get_combi(r2 + c1 + 1, c1)
combi3 = get_combi(r1 + c2 + 1, r1)
combi4 = get_combi(r1 + c1, r1)

print (combi1 - combi2 - combi3 + combi4)

r1, c1, r2, c2 = map(int, input().split())
L = 10 ** 9 + 7


def get_euclidian (A, B):
  if B == 1:
    return (1)
  else:
    return (int((1 - A * get_euclidian (B, A % B)) / B))


F = [1]
for i in range(1, r2 + c2 + 3):
  F.append((F[i - 1] * i) % L)


def get_combi (n, r):

  Euc = get_euclidian(L, (F[r] * F[n - r]) % L)
  return ((F[n] * Euc) % L)

combi1 = get_combi(r2 + c2 + 2, r2 + 1)
combi2 = get_combi(r2 + c1 + 1, c1)
combi3 = get_combi(r1 + c2 + 1, r1)
combi4 = get_combi(r1 + c1, r1)

print ((int(combi1 - combi2 - combi3 + combi4) + L) % L)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
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(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()

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 j in range(2,N+1):
        fac[j] = (fac[j-1]*j)%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()

import sys
input = sys.stdin.buffer.readline
 
def main():
    t,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(x1,y2):
        return (fac[x1+y2]*pow(fac[x1],MOD-2,MOD)*pow(fac[y2],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,t)+comb(t,b))%MOD)
    
if _name_ == "_main_":
    main()
#print the result

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(g,h):
        return (fac[g+h]*pow(fac[g],MOD-2,MOD)*pow(fac[h],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()

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.  Let us define a function f(r, c) as follows:    * f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)  Given are integers r_1, r_2, c_1, and c_2. Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

Submission attempts (in order):
r1, c1, r2, c2 = map(int, input().split())
mod = int(1e+9) + 7
def inved(x):
  a, b, c, d, k, l = 1, 0, 0, 1, x, mod
  while l != 0:
    a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)
    k, l = l, k & l
  return a % mod
frac = [1]
for i in range(r2 + c2 + 2):
  frac.append(((i+1) * frac[i]) % mod)
fracr2c2 = frac[r2 + c2 + 2]
fracr1c2 = frac[r1 + c2 + 1]
fracr2c1 = frac[r2 + c1 + 1]
fracr1c1 = frac[r1 + c1]
fracr2 = frac[r2 + 1]
fracr1 = frac[r1]
fracc2 = frac[c2 + 1]
fracc1 = frac[c1]
g = 0
g += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod
g %= mod
g += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod
g %= mod
g -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod
g %= mod
g -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod
g %= mod
print(g)

r1, c1, r2, c2 = map(int, input().split())
mod = int(1e+9) + 7
def inved(x):
  a, b, c, d, k, l = 1, 0, 0, 1, x, mod
  while l != 0:
    a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)
    k, l = l, k % l
  return a % mod
frac = [1]
for i in range(r2 + c2 + 2):
  frac.append(((i+1) * frac[i]) % mod)
fracr2c2 = frac[r2 + c2 + 2]
fracr1c2 = frac[r1 + c2 + 1]
fracr2c1 = frac[r2 + c1 + 1]
fracr1c1 = frac[r1 + c1]
fracr2 = frac[r2 + 1]
fracr1 = frac[r1]
fracc2 = frac[c2 + 1]
fracc1 = frac[c1]
g = 0
g += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod
g %= mod
g += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod
g %= mod
g -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod
g %= mod
g -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod
g %= mod
print(g)


Verdicts: Time Limit Exceeded

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h,a = map(int,input().split())
if h % a = 0:
  print(h//a)
else:
  print(h//a+1)


h,a = map(int,input().split())
if h % a == 0:
  print(h//a)
else:
  print(h//a+1)

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
H=int(input())
A=int(input())
a=int(H/A)
if H%A!=0:
    a+=1
print(a)

H,A=map(int,input().split())
a=int(H/A)
if H%A!=0:
    a+=1
print(a)

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h, a = map(int, input().split())

 index = 0
 while h > 0:
     h -= a
     index += 1

print(index)

h, a = map(int, input().split())

index = 0
while h > 0:
    h -= a
    index += 1
    
print(index)

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
input_line = list(map(int,input().split()))
if input_line[0] % input_line[1]:
    result = input_line[0] // input_line[1]
else:
    result = input_line[0] // input_line[1] + 1

print(result)

input_line = list(map(int,input().split()))
if input_line[0] % input_line[1] == 0:
    result = input_line[0] // input_line[1]
else:
    result = input_line[0] // input_line[1] + 1

print(result)

Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h,a=map(int,input.split())
if h>a:
  print(h//a)
if h<a:
  print(1)

h,a=map(int,input().split())
if h>a:
  print(h//a)
if h<=a:
  print(1)

h,a=map(int,input.split())
if h>a:
  print(h//a)
if h<=a:
  print(1)

h,a=map(int,input().split())
if h>a:
  if h%a==0:print(h//a)
  if h%a>0:print(h//a+1)
if h<=a:
  print(1)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
n = int(input())
a = [1]

if n % 2 == 1:
    n -= 1

if n % 2 == 0:
    for i in range(int(n / 2)):
        a.append(2 * a[i])

print(a[-1]*2 - 1)

a, b = map(int, input().split())
ans = 0
if a % b ==0:
    ans = a//b
else:
    ans = a//b + 1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h,a=def main():
    h,a=map(int,input().split())
    if h % a:
        print(h//a+1)
    else:
        print(h//a)

main()

def main():
    h,a=map(int,input().split())
    if h % a:
        print(h//a+1)
    else:
        print(h//a)
 
main()

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
import math
A,B = [int(c) for o in input().spit()]
print(math.ceil(A/B))

import math
H,A = [int(x) for x in input().spit()] print(math.ceil(A/B)) 

import math H,A = [int(c) for c in input().spit()] print(math.ceil(A/B))

import math A,B = [int(c) for o in input().spit()] print(math.ceil(A/B))

import math A,B = [int(c) for o in input().spit()]
print(math.ceil(A/B))

import math

H, A = [int(x) for x in input().split()]
print(math.ceil(H/A))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
import math

H = 10000
A = 1

answer = math.ceil(H / A)

print(answer)


import math

inputted = list(map(int, input().split()))

H = inputted[0]
A = inputted[1]

answer = math.ceil(H / A)

print(answer)


Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
H = int(input())
K = int(input())
cnt=0
while(H>0):
  H=H-K
  cnt=cnt+1

print(cnt)

n,b=map(int,input().split())
import math
print(math.ceil(n/b))

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
H,N=map(int, input().split())
v = list(input().split())
v = [int(x) for x in v]
if H <= sum(v):
    print("Yes")
else:
    print("No")

import math
H,A=map(int, input().split())
print(math.ceil(H / A))

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
h,a = iim()


print((h+1)//a)

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
h,a = iim()
if h%a == 0:
    f = 0
else:
    f = 1

print(h//a+f)

Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
import math
import copy
H,N=map(int,input().split())

inf=float('inf')
dp=[0]+[inf]*H

for i in range(N):
    A,B=map(int,input().split())
    ndp=copy.deepcopy(dp)
    for j in range(A,H+1):
        ndp[j]=min(ndp[j-A]+B,dp[j])

        if j > H-A:
            ndp[-1]=min(ndp[-1],ndp[j]+B)

    dp=ndp

print(dp[-1])

import math

H,N=map(int,input().split())
A_list=[]
B_list=[]
for i in range(N):
    A,B=map(int,input().split())
    A_list.append(A)
    B_list.append(B)

amax=max(A_list)

inf=float('inf')
dp=[0]+[inf]*(H+amax)

for i in range(N):
    A=A_list[i]
    B=B_list[i]
    if A > H and B<dp[-1]:
        dp[-1]=B
        continue

    for j in range(A,1+H):
        if dp[j-A]+B<dp[j]:
            dp[j]=dp[j-A]+B
    
    minA=min(dp[H-A:])+B
    if minA < dp[-1]:
        dp[-1]=minA

print(dp[-1])


H,A = map(int,input().split())

N=0
while H > 0:
    N+=1
    H-=A

print(N)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h, n = map(int, input().split())
l = list(map(int, input().split()))
if h > sum(l):
    print("No")
else:
    print("Yes")

h, a = map(int, input().split())
count = 0
while h > 0:
    h -= a
    count += 1
print(count)

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
H,A = map(int, input().split())
# N = int(input())

# C = int(input())
# s= input()
i=0
while H < 0:
    H - A
    i += 1
print(i)

H,A = map(int, input().split())
# N = int(input())

# C = int(input())
# s= input()
i=1
while H < 0:
    H - A
    i += 1
print(i)

H,A = map(int, input().split())
# N = int(input())

# C = int(input())
# s= input()
i=0
while H > 0:
    H  = H - A
    i += 1
print(i)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h, a = map(int, input().split())

q= h//a

print(q)


h, a = map(int, input().split())

q= h//a

print(a)

import math

h, a = map(int, input().split())
q= h/a

print(math.ceil(q))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h, a = map(int, input().split())
print((h+a-1)/a)

h, a = map(int, input().split())
print(int((h+a-1)/a))

Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
H=int(input())
A=int(input())
count=0
while H>0:
    H=H-A
    count+=1
else:
print(count)

H=int(input())
A=int(input())
count=0
while H>0:
    H=H-A
    count+=1
else:
    print(count)

H,A=map(int, input().split())
count=0
while H>0:
    H=H-A
    count+=1
else:
    print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h, n = (int(x) for x in input().split())
A = list(map(int, input().split()))

if n == len(A):
    if sum(A) >= h:
        print('yes')
    else:
        print('No')

a,b=(int(x) for x in input().split())

print(-(-a//b))

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]


a_max = max(a for a, b in ab)

dp = [0]*(h + a_max)

for i in range(h + a_max):
	dp[i] = min(dp[i - a] + b for a, b in ab)

print(min(dp[h:]))

h, a = map(int, input().split())

q   = h // a
mod = h % a

if(mod == 0):
  ans = q
else:
  ans = q + 1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
h,a = map(int,input().split())
print(h//a)

h,a = map(int,input().split())
print((h + a - 1) // a)

Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
import math
h, a = map(int, input().split())

print(math.ceil(h // a))

import math
h, a = map(int, input().split())

print(math.ceil(h / a))

Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
import math 
h, a = map(float, input().split())

print(-(-h//a))

import math 
h, a = map(float, input().split())

print(int(-(-h//a)))

Verdicts: Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
print(a)

a = 1
print(a)

h, a = [int(i) for i in input().split()]
i = h//a + 1
if h%a == 0:
  i -= 1
print(i)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Serval is fighting with a monster.  The _health_ of the monster is H.  In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health.  Serval wins when the monster's health becomes 0 or below.  Find the number of attacks Serval needs to make before winning.

Submission attempts (in order):
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N:
	print(0)
else:
	b=sorted(a)
	c=0
	for i in range(N-K):
		c+=b[i]
	print(c)

H, A=map(int,input().split())
if H//A==H/A:
	print(H//A)
else:
	print(H//A+1)

Verdicts: Runtime Error

Accepted