s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s336153891 | p02555 | u773081031 | 1600061691 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8932 | 102 | n = int(input())
s = [s[i-1] + s[i-3] for i in range(n) if i>2 elif i<2 0 elif i==2 1]
print(s[n-1])
|
s713624884 | p02555 | u453623947 | 1600057333 | Python | Python (3.8.2) | py | Runtime Error | 35 | 11500 | 236 | S = int(input())
l = [1,1]
for i in range(2,S+1) :
l.append(l[-1]*i)
ans = 0
for i in range(S//3) :
kou = i+1
maru = S - 3*kou
shikiri = i
ans += l[maru+shikiri] / (l[maru]*l[shikiri])
print(int(ans%((10**9)+7)))
|
s107240476 | p02555 | u802781234 | 1600052100 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 74740 | 422 | def inN():
return int(input())
def inL():
return list(map(int,input().split()))
def inNL(n):
return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
import numpy
n = inN()
if n < 3:
print(0)
exit()
elif n < 6:
print(1)
exit()
m = n//3
n -= 5
l = [1]*n
ans = 1
for i in ... |
s678318044 | p02555 | u067937922 | 1600050994 | Python | Python (3.8.2) | py | Runtime Error | 420 | 9144 | 527 | """
At Coder :: Beginner Contest 178 :: D - Redistribution
https://atcoder.jp/contests/abc178/tasks/abc178_d
"""
MOD = pow(10, 9) + 7
def solve(S):
"""Solve problem."""
A = [1 for _ in range(S+1)]
A[0] = A[1] = A[2] = 0
for i in range(3, S+1):
k = 3
while i - k >= 0:
A[i... |
s848020783 | p02555 | u806976856 | 1600050330 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 68472 | 227 | s=int(input())
p=10**9+7
if s<=2:
print(0)
exit()
n=s//3
ans=0
for k in range(1,n+1):
a=1
b=1
for j in range(k-1):
a=a*(s-3*k+1+j)%p
b=b*(j+1)%p
ans=(ans+a*pow(b,-1,p))%p
print(ans%p)
|
s292861452 | p02555 | u463470469 | 1600049199 | Python | Python (3.8.2) | py | Runtime Error | 84 | 9084 | 282 | import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
S = int(input())
if S == 1 or S == 2:
print(0)
else:
n = S//3
ans = 0
for i in range(n+1):
a = S-3*i
b = i
ans += comb(a, b)
print(ans%((10**9)+7)) |
s463922006 | p02555 | u679817762 | 1600041995 | Python | Python (3.8.2) | py | Runtime Error | 84 | 9012 | 281 | from math import *
s = int(input())
t = s // 3
def nHr(n, r):
return factorial(n+r-1) / (factorial(r) * factorial(n-1))
count = 0
for i in range(t):
k = s - 3*(i+1)
count += nHr(i+1, k)
ans = int(count)
M = 10**9 + 7
if ans < M:
print(ans)
else:
print(ans%M) |
s993632844 | p02555 | u961223096 | 1600041862 | Python | PyPy3 (7.3.0) | py | Runtime Error | 100 | 68772 | 405 | import numpy as np
MOD = 10**9+7
n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
arr[0,i] = 1
for i in np.arange(1,n+1):
sum_ = 0
for j in np.arange(3*i,n+1):
sum_ += arr[i-1,j]
sum_ %= MOD
if j+3 >= n + 1:
break
arr[i,j+3] = su... |
s142029824 | p02555 | u364555831 | 1600041406 | Python | Python (3.8.2) | py | Runtime Error | 101 | 9572 | 1524 | mod = 10 ** 9 + 7
class Solution:
def FactorialMod(self, n):
if n <= 1:
return 1
else:
return n * self.FactorialMod(n - 1) % mod
def ModInv(self, p):
if p <= 1:
return 1
return (-self.ModInv(mod % p) * (mod // p)) % mod
def FactorialModInv... |
s118588058 | p02555 | u364555831 | 1600041375 | Python | Python (3.8.2) | py | Runtime Error | 101 | 9756 | 1516 | mod = 10 ** 9 + 7
class Solution:
def FactorialMod(self, n):
if n <= 1:
return 1
else:
return n * self.FactorialMod(n - 1) % mod
def ModInv(self, p):
if p <= 1:
return 1
return (-self.ModInv(mod % p) * (mod // p)) % mod
def FactorialModInv... |
s082913920 | p02555 | u961223096 | 1600040220 | Python | PyPy3 (7.3.0) | py | Runtime Error | 100 | 74724 | 405 | import numpy as np
MOD = 10**9+7
n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
arr[0,i] = 1
for i in np.arange(1,n+1):
sum_ = 0
for j in np.arange(3*i,n+1):
sum_ += arr[i-1,j]
sum_ %= MOD
if j+3 >= n + 1:
break
arr[i,j+3] = su... |
s950569146 | p02555 | u961223096 | 1600040195 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 74812 | 405 | import numpy as np
MOD = 10**9+7
n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
arr[0,i] = 1
for i in np.arange(1,n+1):
sum_ = 0
for j in np.arange(3*i,n+1):
sum_ += arr[i-1,j]
sum_ %= MOD
if j+3 >= n + 1:
break
arr[i,j+3] = su... |
s973537460 | p02555 | u314089899 | 1600040070 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9468 | 461 | #再帰の限度を拡張
import sys
sys.setrecursionlimit(1000000)
#再帰メモ化
from functools import lru_cache
MOD_BY = 10**9 +7
S = int(input())
@lru_cache(maxsize=2000)
def dp_search(n):
if n in dp_dict:
return dp_dict[n]
if n <= 2:
return 0
elif 3 <= n <= 5:
return 1
else:
ans = [dp_se... |
s721048649 | p02555 | u961223096 | 1600039261 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 74868 | 405 | import numpy as np
MOD = 10**9+7
n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
arr[0,i] = 1
for i in np.arange(1,n+1):
sum_ = 0
for j in np.arange(3*i,n+1):
sum_ += arr[i-1,j]
sum_ %= MOD
if j+3 >= n + 1:
break
arr[i,j+3] = su... |
s565752209 | p02555 | u961223096 | 1600039164 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 74872 | 405 | import numpy as np
MOD = 10**9+7
n = int(input())
arr = np.zeros((n+1,n+1), dtype=int)
for i in np.arange(3,n+1):
arr[0,i] = 1
for i in np.arange(1,n+1):
sum_ = 0
for j in np.arange(3*i,n+1):
sum_ += arr[i-1,j]
sum_ %= MOD
if j+3 >= n + 1:
break
arr[i,j+3] = su... |
s708666161 | p02555 | u185249212 | 1600037685 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1320 | 78228 | 1927 | from __future__ import print_function
from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq imp... |
s170995638 | p02555 | u185249212 | 1600037637 | Python | PyPy3 (7.3.0) | py | Runtime Error | 224 | 84124 | 1923 | from __future__ import print_function
from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq imp... |
s811480052 | p02555 | u822662438 | 1600036737 | Python | Python (3.8.2) | py | Runtime Error | 86 | 9176 | 217 | import math
s = int(input())
MOD = 10**9+7
maximum = int(s/3)
ans = 0
for i in range(maximum):
ans += (math.factorial(i + s-(i*3+3))/(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD
print(int(ans)%(10**9+7))
|
s006492835 | p02555 | u325282913 | 1600036339 | Python | Python (3.8.2) | py | Runtime Error | 317 | 9336 | 155 | MOD = 10**9 + 7
S = int(input())
dp = [0]*(S+1)
dp[0] = 1
dp[3] = 1
for i in range(4,S+1):
for k in range(i-2):
dp[i] += dp[k]
print(dp[S]%MOD) |
s072910178 | p02555 | u597455618 | 1600036149 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9160 | 126 | MOD = 10**9+7
s = int(input())
a = [0]*range(s+1)
a[0] = 1
for i in range(3, s+1):
a[i] = sum(a[:i-2]) % MOD
print(a[s])
|
s895557329 | p02555 | u822662438 | 1600035863 | Python | Python (3.8.2) | py | Runtime Error | 81 | 8996 | 206 | import math
s = int(input())
MOD = 10**9+7
maximum = int(s/3)
ans = 0
for i in range(maximum):
ans += (math.factorial(i + s-(i*3+3))/(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD
print(int(ans)) |
s991051049 | p02555 | u180172332 | 1600035312 | Python | PyPy3 (7.3.0) | py | Runtime Error | 112 | 74636 | 396 | temp_dic = {}
def rec(s,n):
if n==1:
return 1
total = 0
if (s,n) in temp_dic:
total = temp_dic[(s,n)]
else:
for i in range(3*(n-1),s-2):
#print(i)
total += rec(i,n-1)
temp_dic[(s,n)]=total
return total
s = int(input())
total = 0
for i in range(... |
s468324851 | p02555 | u636290142 | 1600035126 | Python | Python (3.8.2) | py | Runtime Error | 484 | 9176 | 172 | S = int(input())
mod = 10**9 + 7
dp = [0] * (S+1)
dp[0] = 1
for i in range(1, S+1):
for j in range((i+3)+1):
dp[i] += dp[j]
dp[i] %= mod
print(dp[S])
|
s780384905 | p02555 | u636290142 | 1600035089 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9104 | 172 | S = int(input())
mod = 10**9 + 7
dp = [0] * (S+1)
dp[0] = 1
for i in range(1, s+1):
for j in range((i+3)+1):
dp[i] += dp[j]
dp[i] %= mod
print(dp[S])
|
s267151363 | p02555 | u707808519 | 1600034665 | Python | Python (3.8.2) | py | Runtime Error | 60 | 9292 | 577 | MOD = 10**9+7
s = int(input())
x = s//3
MAX = s
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX
def COMinit():
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, MAX):
fac[i] = fac[i-1] * i % MOD
inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
finv[i] = finv[i-1... |
s553590175 | p02555 | u588794534 | 1600034519 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74532 | 198 | s=int(input())
mod=10**9+7
dp=[1]*(s+1)
dp[0]=0
dp[1]=0
dp[2]=0
#print(dp)
for i in range(3,s+1):
for j in range(3,s-i+1):
dp[i+j]+=dp[i]%mod
#print(i,dp)
print(dp[s]%mod)
|
s477923845 | p02555 | u991542950 | 1600034074 | Python | PyPy3 (7.3.0) | py | Runtime Error | 80 | 74852 | 168 | mod = (10 ** 9 + 7)
tot = 1
l = [1, 0, 0]
for i in range(3, 2000):
nex = (tot - l[-1] - l[-2]) % mod
tot = (tot + nex) % mod
l.append(nex)
print(l[int(input())])
|
s849122984 | p02555 | u991542950 | 1600033987 | Python | PyPy3 (7.3.0) | py | Runtime Error | 83 | 68768 | 156 | mod = (10 ** 9 + 7)
tot = 1
l = [1, 0, 0]
for i in range(3, 2000):
nex = (tot - l[-1] - l[-2])
tot = (tot + nex)
l.append(nex)
print(l[int(input())]) |
s620259399 | p02555 | u173925978 | 1600033748 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9064 | 160 | S = int(input())
if S < 3: return 0
MODULO = int(1e9+7)
dp = [0,0,0,1]
for i in range(4,S+1):
x = dp[i-3] + dp[i-1]
x %= MODULO
dp.append(x)
print(dp[-1]) |
s727406569 | p02555 | u173925978 | 1600033700 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8984 | 159 | S = int(input())
if S < 3: return 0
MODULO = int(1e9+7)
dp = [0,0,0,1]
for i in range(4,S+1):
x = dp[i-3] + dp[i-1]
x %= MODULO
dp.append(x)
print(dp[-1] |
s786612205 | p02555 | u273914730 | 1600033369 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9152 | 326 | N=int(input())
xy=[map(int,input().split()) for i in range(N)]
x,y=[list(j) for j in zip(*xy)]
t=0
m=0
for k in range(0,len(x)-1):
for l in range(k,len(y)):
if abs(x[k]-x[l])<t:
m=m
elif abs(x[k]-x[l])+abs(y[k]-y[l])>m:
m=abs(x[k]-x[l])+abs(y[k]-y[l])
t=abs(x[k]-x[l])
pri... |
s408519044 | p02555 | u732061897 | 1600032959 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9088 | 156 | N = int(input())
dp = [0] * 701
dp[0] = 1
target = [3, 4, 5, 6, 7, 8, 9]
for i in range(0, 600):
for t in target:
dp[i+t] += dp[i]
print(dp[N])
|
s288153923 | p02555 | u402228762 | 1600032456 | Python | Python (3.8.2) | py | Runtime Error | 1215 | 140108 | 523 |
"""a = int(input())
import itertools
a_list = [i for i in range(3,a+1)]
#print(a_list)
for i in itertools.combinations_with_replacement(a_list,len(a_list)):
if(sum(i) == a):
print(sum(i))
"""
MOD = 10**9 + 7
S = int(input())
dp = [1] * 2001
dp[0] = dp[1] = dp[2] = 0
"""
for i in range(S+1):
... |
s421260414 | p02555 | u407778590 | 1600032442 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9172 | 178 | N = int(input())
MOD_CONST = 10 ** 9 + 7
res = [1] * N
res[0] = res[1] = 0
for i in range(5, N):
res[i] = res[i - 4] + res[i - 3] + res[i - 2]
print(res[N-1] % MOD_CONST) |
s312461512 | p02555 | u941407962 | 1600032118 | Python | PyPy3 (7.3.0) | py | Runtime Error | 251 | 68652 | 311 | mod = 10**9+7
N, = map(int, input().split())
dp1 = [0]*N
dp2 = [0]*N
for i in range(N):
if i < 3:
dp1[i] = 1
dp2[i] = 0
else:
dp1[i] = dp1[i-1] + dp2[i-1]
dp2[i] = dp1[i-3] + dp2[i-3]
dp1[i] %= mod
dp2[i] %= mod
print(dp1)
print(dp2)
print((dp1[-1]+dp2[-3])%mod)
|
s817340300 | p02555 | u224353074 | 1600032109 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 41948 | 890 | import sys
sys.setrecursionlimit(10000)
S = int(input())
mod = 10**9+7
ans = 1
cnt = 0
memo = [[-1]*2010 for i in range(2000)]
def f(r,bar):
global cnt
cnt += 1
ans = 0
if ((r//3)-1) < bar:
memo[r][bar] = 0
return 0
if bar == 1:
memo[r][bar] = (r-5)%mod
return r-5
... |
s176165700 | p02555 | u078816252 | 1600031945 | Python | Python (3.8.2) | py | Runtime Error | 33 | 9532 | 216 | import sys
import threading
S = int(input())
A = [-1 for _ in range(S+1)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1
A[4] = 1
A[5] = 1
for i in range(S+1):
if A[i] == -1:
A[i] = A[i-1] + A[i-3]
print(A[S]%(10**9+7)) |
s976310605 | p02555 | u078816252 | 1600031932 | Python | Python (3.8.2) | py | Runtime Error | 32 | 9420 | 216 | import sys
import threading
S = int(input())
A = [-1 for _ in range(S+1)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1
A[4] = 1
A[5] = 1
for i in range(S+1):
if A[i] == -1:
A[i] = A[i-1] + A[i-3]
print(A[S]%(10**9+7)) |
s780845763 | p02555 | u008992227 | 1600031847 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 69104 | 524 | from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math
mod = 10**9+7
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n = ni()
s = [0 fo... |
s099933938 | p02555 | u083497269 | 1600031162 | Python | Python (3.8.2) | py | Runtime Error | 388 | 9248 | 357 | S = int(input())
p = S // 3
A = 0
for b in range(p):
r = S-3*(b+1)
if b == 0:
A+=1
else:
x = 1
y = 1
z = 1
for k in range(r+b):
x *= k+1
for k in range(r):
y *= k+1
for k in range(b):
z *= k+1
A += int(x... |
s960018241 | p02555 | u874151776 | 1600031006 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9180 | 205 | #!/usr/bin/env python3
s = int(input())
if s <= 2:
print(0)
else:
a = [0] * (s + 1)
a[0] = 1
for i in range(3, s + 1):
a[i] = int((a[i - 1] + a[i - 3]) % (1e9 + 7))
print(a[s]) |
s862035684 | p02555 | u165318982 | 1600030898 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9172 | 183 | N = int(input())
table = [0,0,1]
if N >= 4:
for i in range(3, N):
table.append((table[i-1] + table[i-3]) % mod)
print(table[-1] % mod)
elif N == 3:
print(1)
else:
print(0) |
s435617250 | p02555 | u278057806 | 1600030754 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9376 | 363 | from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10 ** 8)
S = int(input())
A = [-1] * (S + 1)
mod = 10 ** 9 + 7
for i in range(3):
A[i] = 0
for i in range(3, 6):
A[i] = 1
def dfs(n):
if A[n] != -1:
return A[n]
else:
A[n] = (dfs(n - 3) + dfs(n - 1))... |
s258771929 | p02555 | u278057806 | 1600030697 | Python | Python (3.8.2) | py | Runtime Error | 33 | 9452 | 316 | from sys import stdin
input = stdin.readline
S = int(input())
A = [-1] * (S + 1)
mod = 10 ** 9 + 7
for i in range(3):
A[i] = 0
for i in range(3, 6):
A[i] = 1
def dfs(n):
if A[n] != -1:
return A[n]
else:
A[n] = (dfs(n - 3) + dfs(n - 1)) % mod
return A[n]
print(dfs(S))
|
s138105422 | p02555 | u190616335 | 1600030678 | Python | Python (3.8.2) | py | Runtime Error | 30 | 8856 | 264 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
s = int(input())
mod = 10**9 + 7
a_list = [0] * (s + 1)
a_list[0] = 1
a_list[1] = 0
a_list[2] = 0
a_list[3] = 1
for i in range(4, s + 1):
a_list[i] = a_list[i - 1] + a_list[i - 3]
a_list[i] %= mod
print(a_list[s]) |
s296152759 | p02555 | u556594202 | 1600030332 | Python | Python (3.8.2) | py | Runtime Error | 22 | 9140 | 265 | bun=[]
bun.append([0,0]+[1]*(s-2))
for j in range(1,s//3):
bun.append([0]*(3*(j+1)-1)+[1])
for i in range(3*(j+1),s):
bun[j].append((bun[j][i-1]+bun[j-1][i-3])%(10**9+7))
ans=0
for i in range(s//3):
ans = (ans+bun[i][s-1])%(10**9+7)
print(ans) |
s386261514 | p02555 | u535117304 | 1600030232 | Python | Python (3.8.2) | py | Runtime Error | 148 | 9156 | 251 | S=int(input())
c=10**9+7
def A(n):
j=1
for i in range(1,n+1):
j*=i
return j
if S<3:
ans=0
else:
ans=0
b=int((S-S%3)/3)
for x in range(1,b+1):
h=A(S-2*x-1)/A(S-3*x)/A(x-1)
ans+=h
print(int(ans%c)) |
s729767418 | p02555 | u189806337 | 1600030138 | Python | Python (3.8.2) | py | Runtime Error | 43 | 9180 | 140 | s = int(input())
p = [1]*(s+1)
mod = 10**9 + 7
p[1] = 0
p[2] = 0
if s >= 3:
for i in range(3,s+1):
p[i] = (sum(p[:i-2]))%mod
print(p[s]) |
s506280980 | p02555 | u189806337 | 1600030108 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8868 | 139 | s = int(input())
p = [1]*(s+1)
mod = 10**9 + 7
p[1] = 0
p[2] = 0
if s >= 3
for i in range(3,s+1):
p[i] = (sum(p[:i-2]))%mod
print(p[s]) |
s192075200 | p02555 | u961223096 | 1600030076 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 68724 | 45 | import numpy as np
n = int(input())
print(n) |
s371258434 | p02555 | u189806337 | 1600030065 | Python | Python (3.8.2) | py | Runtime Error | 45 | 9064 | 128 | s = int(input())
p = [1]*(s+1)
mod = 10**9 + 7
p[1] = 0
p[2] = 0
for i in range(3,s+1):
p[i] = (sum(p[:i-2]))%mod
print(p[s]) |
s023168304 | p02555 | u961223096 | 1600030016 | Python | PyPy3 (7.3.0) | py | Runtime Error | 96 | 68740 | 60 | import numpy as np
MOD = 10**9+7
n = int(input())
print(n) |
s262283599 | p02555 | u961223096 | 1600029985 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 68720 | 51 | import numpy as np
MOD = 10**9+7
n = int(input()) |
s939962804 | p02555 | u961223096 | 1600029954 | Python | PyPy3 (7.3.0) | py | Runtime Error | 104 | 68312 | 137 | import numpy as np
MOD = 10**9+7
n = int(input())
arr = np.zeros((n+1,n+1), dtype=np.int16)
for i in np.arange(3,n+1):
arr[0,i] = 1 |
s137184837 | p02555 | u860002137 | 1600029930 | Python | Python (3.8.2) | py | Runtime Error | 1097 | 127412 | 491 | 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
MOD = 10**9 + 7
N = 10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
fact.append((fact[-1] * i) % MOD)
inv.append((-inv[MOD % i] * (MOD // i)) % MO... |
s344965908 | p02555 | u947664173 | 1600029927 | Python | PyPy3 (7.3.0) | py | Runtime Error | 227 | 68612 | 247 | s=int(input())
import math
from scipy.special import comb
ketamax=int(math.floor(s/3))
waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
nokori=s-3*i
kazu=comb(nokori+i-1,i-1)%waru
ans=(ans+kazu)%waru
answer=int(ans%waru)
print(answer) |
s128202445 | p02555 | u217571418 | 1600029594 | Python | Python (3.8.2) | py | Runtime Error | 85 | 9108 | 287 | import math
S = int(input())
le = S // 3
count = 0
if le >= 1:
for i in range(1, le):
sa = S - 3 * i
if sa >= 0:
count += math.factorial(i + sa)/(math.factorial(i) * math.factorial(sa))
count = int(count)
ans = count % (10 ** 9 + 7)
print(ans) |
s172336429 | p02555 | u142211940 | 1600029592 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 68744 | 215 | import itertools
S = int(input())
N = S//3
if N==0:
print(0)
exit()
ans = 0
for i in range(N):
xx = S-(3*(i+1))+1
ans += sum(list(itertools.combinations_with_replacement([1, 2, 3], i)))
print(ans) |
s738465229 | p02555 | u642426958 | 1600029585 | Python | Python (3.8.2) | py | Runtime Error | 54 | 9536 | 482 | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, range(n, n - r, -1))
under = reduce(mul, range(1,r + 1))
return over // under
s = int(input())
MOD = 1000000007
count = 0
ans = 0
if s == 1:
ans = 0
print(ans)
elif s == 2... |
s144894588 | p02555 | u775278230 | 1600029584 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9160 | 306 | n = int(input())
m = n // 3 #max項数
def kaijo(x):
x = int(x)
k = 1
if x == 0:
return 1
elif x != 0:
for a in range(1,x+1):
k = k * a
return k
y = 0
for i in range(1,m+1):
r = n - 3*i
z = kaijo(i-1+r) / (kaijo(i-1)*kaijor)
y = y + z
print(z)
|
s205048110 | p02555 | u535117304 | 1600029582 | Python | Python (3.8.2) | py | Runtime Error | 147 | 9056 | 252 | S=int(input())
c=10**9+7
def A(n):
j=1
for i in range(1,n+1):
j*=i
return j
if S<3:
ans=0
else:
ans=0
b=int((S-S%3)/3)
for x in range(1,b+1):
h=A(S-2*x-1)/A(S-3*x)/A(x-1)
ans+=h
print(ans%c) |
s350607004 | p02555 | u002067779 | 1600029581 | Python | Python (3.8.2) | py | Runtime Error | 33 | 9004 | 164 | import math
s = int(input())
m = 1
for i in range(2,s//3):
m += (math.factorial(s-2*i-1)/math.factorial(i-1)/math.factorial(s-3*i))%(10**9+7)
print(m%(10**9+7)) |
s165095649 | p02555 | u285443936 | 1600029569 | Python | Python (3.8.2) | py | Runtime Error | 215 | 42152 | 270 | from scipy.special import comb
S = int(input())
n = S//3
k = S%3
Q = 10**9+7
ans = 0
for i in range(n):
#iはしきりをとった数
m = n-i #要素数
ans += comb(n-1,i,exact=true)*comb(m,k,exact=True)
if k==2:
ans += k
ans %=Q
print(ans) |
s852589082 | p02555 | u473234868 | 1600029568 | Python | Python (3.8.2) | py | Runtime Error | 116 | 9016 | 276 | s = int(input())
b = s // 3
if s<= 2:
print(0)
else:
import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
total = 0
for i in range(b+1):
c = s-3*(i+1)
total += comb(c+i, i)
print(total%(10**9 + 7))
|
s413444054 | p02555 | u168416324 | 1600029561 | Python | PyPy3 (7.3.0) | py | Runtime Error | 103 | 68612 | 476 | #import random
n=int(input())
pnt=[]
for i in range(n):
pnt.append(list(map(int,input().split())))
#pnt.append([random.randint(int(-1e9),int(1e9)),random.randint(int(-1e9),int(1e9))])
pnt.sort(key=lambda x:abs(x[0])+abs(x[1]),reverse=True)
mn=list(reversed(pnt))
mx=0
for i in range(min(n,5000)):
for j in range(... |
s152181874 | p02555 | u375172966 | 1600029559 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 81612 | 443 | def P(n):
# n=0 のときは初期値として空のリストを返す。
if n == 0:
yield []
return
for p in P(n-1):
p.append(1)
yield p
p.pop()
# 最大値を 3 とする
val = 3
if p and p[-1] != val:
p[-1] += 1
yield p
if __name__ == '__main__':
# 10の分割(最大値3)
... |
s141705257 | p02555 | u808817704 | 1600029558 | Python | PyPy3 (7.3.0) | py | Runtime Error | 158 | 68568 | 1107 | #import numpy as np
#from collections import Counter
#import sys
#sys.setrecursionlimit(10000000)
def main(S_: int):
MOD = int(10**9+7)
dp = []
for _ in range(2002):
dp.append([0]*2002)
#dp = np.full((2001, 2001), 0)
# dp[s][p] = sをp通りに分割する方法
dp[1][1] = 0
dp[2][1] = 0
#print(dp)... |
s239147767 | p02555 | u535117304 | 1600029537 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9172 | 244 | S=int(input())
c=10**9+7
def A(n):
j=1
for i in range(1,n+1):
j*=i
return j
if S<3:
ans=0
else:
ans=0
h=A(S-2*x-1)/A(S-3*x)/A(x-1)
b=int((S-S%3)/3)
for x in range(1,b+1):
ans+=h
print(ans%c) |
s404785348 | p02555 | u224353074 | 1600029517 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2209 | 105552 | 842 | import sys
sys.setrecursionlimit(10000)
S = int(input())
mod = 10**9+7
ans = 1
memo = [[-1]*2010 for i in range(2000)]
def f(r,bar):
ans = 0
if ((r//3)-1) < bar:
memo[r][bar] = 0
return 0
if bar == 1:
memo[r][bar] = (r-5)%mod
return r-5
else:
if memo[r][bar] ==... |
s456943537 | p02555 | u002067779 | 1600029501 | Python | Python (3.8.2) | py | Runtime Error | 82 | 9172 | 166 | import math
s = int(input())
m = 0
for i in range(1,s//3):
m += (math.factorial(s-2*i-1)/(math.factorial(i-1)*math.factorial(s-3*i))%(10**9+7))
print(m%(10**9+7)) |
s248098568 | p02555 | u137346245 | 1600029442 | Python | Python (3.8.2) | py | Runtime Error | 34 | 9140 | 346 | import math
N = int(input())
a = 1
k = 1
s = 1
o = 5
b = N // 3
for i in range (b - 1):
k = 1
n = N - o
for i in range (a):
k = k * n
n = n - 1
k = k % 1000000007
p = float(math.factorial(a))
a = a + 1
d = (k / p) % 1000000007
s = s + d
o = o + 2
if N < 3:
s = 0
... |
s514152263 | p02555 | u473234868 | 1600029420 | Python | Python (3.8.2) | py | Runtime Error | 115 | 9204 | 235 | s = int(input())
b = s // 3
import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
total = 0
for i in range(b+1):
c = s-3*(i+1)
total += comb(c+i, i)
print(total%(10**9 + 7))
|
s572038915 | p02555 | u224353074 | 1600029416 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 100896 | 842 | import sys
sys.setrecursionlimit(10000)
S = int(input())
mod = 10**9+7
ans = 1
memo = [[-1]*2010 for i in range(2000)]
def f(r,bar):
ans = 0
if ((r//3)-1) < bar:
memo[r][bar] = 0
return 0
if bar == 1:
memo[r][bar] = (r-5)%mod
return r-5
else:
if memo[r][bar] ==... |
s765786499 | p02555 | u002067779 | 1600029399 | Python | Python (3.8.2) | py | Runtime Error | 32 | 9180 | 164 | import math
s = int(input())
m = 0
for i in range(1,s//3):
m += (math.factorial(s-2*i-1)/math.factorial(i-1)/math.factorial(s-3*i))%(10**9+7)
print(m%(10**9+7)) |
s756357242 | p02555 | u217571418 | 1600029357 | Python | Python (3.8.2) | py | Runtime Error | 90 | 9180 | 257 | import math
S = int(input())
le = S // 3
count = 0
if le >= 1:
for i in range(1, le):
sa = S - 3 * i
if sa >= 0:
count += math.factorial(i + sa)/(math.factorial(i) * math.factorial(sa))
ans = count % (10 ** 9 + 7)
print(ans) |
s301482768 | p02555 | u428699622 | 1600029349 | Python | PyPy3 (7.3.0) | py | Runtime Error | 114 | 70748 | 254 | S = int(input())
a = S//3
def comb(n,k):
if k == 1:
return n
else:
return int(n/k*comb(n-1,k-1))
answer = 0
for i in range(2,a+1):
answer = answer + comb(S-2*i-1,i-1)
if S > 2:
answer = answer + 1
print(answer%(10**9+7))
|
s653190815 | p02555 | u473234868 | 1600029346 | Python | Python (3.8.2) | py | Runtime Error | 84 | 9212 | 233 | s = int(input())
b = s // 3
import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
total = 0
for i in range(b+1):
c = s-3*(i+1)
total += comb(c, i)
print(total%(10**9 + 7))
|
s461588015 | p02555 | u224353074 | 1600029342 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 100904 | 827 | import sys
sys.setrecursionlimit(10000)
S = int(input())
mod = 10**9+7
ans = 1
memo = [[-1]*2010 for i in range(2000)]
def f(r,bar):
ans = 0
if ((r//3)-1) < bar:
memo[r][bar] = 0
return 0
if bar == 1:
memo[r][bar] = (r-5)%mod
return r-5
else:
if memo[r][bar] ==... |
s214650853 | p02555 | u630511239 | 1600029330 | Python | Python (3.8.2) | py | Runtime Error | 54 | 8996 | 260 | S = int(input())
shou = int(S // 3) - 1
m = 10 ** 9 + 7
ans = 0
for j in range(shou + 1):
s = shou - j
A = S - 3 * (s + 1) + s
a = 1
for i in range(s):
a *= (A - i) / (s - i)
a %= m
ans += int(a)
ans %= m
ans %= m
print(ans) |
s203013003 | p02555 | u473234868 | 1600029318 | Python | Python (3.8.2) | py | Runtime Error | 87 | 9164 | 232 | s = int(input())
b = s // 3
import math
def comb(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
total = 0
for i in range(b+1):
c = s-3*(i+1)
total += comb(c, i)
print(total%(10**7 + 9))
|
s918545699 | p02555 | u032798323 | 1600029300 | Python | Python (3.8.2) | py | Runtime Error | 56 | 8952 | 569 | import math
S=int(input())
if S>= 7:
ans = 2
n = S//3
b = S%3
a = 3+b
z = 10**9+7
c = n-1
for i in range(n-2):
# s=math.factorial(a+c-1)/(math.factorial(a)*math.factorial(c-1))
y = max([a,c-1])
r = min([a,c-1])
# print(y,r,a+c)
s = 1
for k in ... |
s202575462 | p02555 | u910632349 | 1600029287 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9060 | 233 | n=int(input())
r=[list(map(int,input().split())) for _ in range(n)]
a,c,b,d=0,10**10,0,10**10
for i in range(n):
x,y=r[i]
a=max(a,x+y)
c=min(c,x+y)
b=max(b,x-y)
d=min(d,x-y)
d=max(0,d)
print(abs(max(a-c,b-d))) |
s886285431 | p02555 | u736729525 | 1600029218 | Python | Python (3.8.2) | py | Runtime Error | 255 | 9200 | 352 |
def solve(S):
dp = [0]*(S+1)
dp[0] = 1
dp[3] = 1
MOD = 10**9+7
for n in range(4, S+1):
answer = 0
for c in range(3, n+1):
#print(n, "c=%d"%c, dp[c])
answer = (answer + dp[n-c]) % MOD
dp[n] = answer % MOD
#print(n, dp[n])
return dp[S]
#solv... |
s041766534 | p02555 | u408148811 | 1600029208 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9012 | 1682 | #include <bits/stdc++.h>
#include<numeric>
#include<cstdlib>
#define ll long long int
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define v vector<long long int>
#define vv vector< int>
#define gcd(m,n) __gcd(m,n)
#define vp vector<pair<long long ... |
s718079107 | p02555 | u125799132 | 1600029168 | Python | Python (3.8.2) | py | Runtime Error | 89 | 9072 | 199 | import math
S = int(input())
ans = 0
if S >= 3:
for i in range(1, int(S/3)+1):
ans += math.factorial(S-2*i-1) / (math.factorial(i-1) * math.factorial(S-3*i))
print(int(ans)%(10**9 + 7)) |
s282085725 | p02555 | u354174235 | 1600029104 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9012 | 317 | import math
int_s = int(input())
num = int_s // 3
count = 0
while num >= 1:
if num == 1:
count = count + 1
else:
amari = int_s - (num*3)
sum = math.factorial(amari + num - 1) / (math.factorial(amari)+math.factorial(num - 1))
count = count + sum
print(num)
num = num - 1
print(int(count)) |
s945311832 | p02555 | u874151776 | 1600029087 | Python | Python (3.8.2) | py | Runtime Error | 36 | 9208 | 754 | #!/usr/bin/env python3
s = int(input())
#2以下だったら0で決まり
if s <= 2:
print(0)
else:
#結果
result = 0
#項数でループ
for i in range(1, s // 3 + 1):
# #あまり
r = s - i * 3
if r == 0:
result += 1
else:
h = 1.0
# print(r)
# for j in ... |
s087739867 | p02555 | u224353074 | 1600029079 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2212 | 168836 | 768 | S = int(input())
mod = 10**9+7
ans = 1
memo = [[-1]*2010 for i in range(2000)]
def f(r,bar):
ans = 0
if ((r//3)-1) < bar:
memo[r][bar] = 0
return 0
if bar == 1:
memo[r][bar] = r-5
return r-5
else:
if memo[r][bar] == -1:
for i in range(r-3,5,-1):
... |
s767811120 | p02555 | u354174235 | 1600029039 | Python | Python (3.8.2) | py | Runtime Error | 47 | 9196 | 484 | import math
int_s = int(input())
num = int_s // 3
count = 0
while num >= 1:
if num == 1:
count = count + 1
else:
amari = int_s - (num*3)
nume = 1
for i in range(amari + num - 1):
nume = nume*(i+1)
deno_1 = 1
for i in range(amari):
deno_1 = deno_1*(i+1)
deno_2 = 1
for i... |
s813826087 | p02555 | u018808362 | 1600029035 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9248 | 692 | def main(S):
n=ceil(S/3)
ans=0
while n>0:
s=S-n*3
if s<=6 and s>=0:
ans+=cmb(s+n-1, n-1)
elif s>6*n:
ans+=0
else:
ans+=cmb2(s, n)
n-=1
print(int(ans))
def cmb(n, r):
return factorial(n) / factorial(r) /... |
s289780875 | p02555 | u408148811 | 1600029028 | Python | Python (3.8.2) | py | Runtime Error | 33 | 9140 | 352 | def ncr(n, r, p):
# initialize numerator
# and denominator
num = den = 1
for i in range(r):
num = (num * (n - i)) % p
den = (den * (i + 1)) % p
return (num * pow(den,
p - 2, p)) % p
ans=0
n=int(input())
for i in range(n/3+1):
ans+=(ncr(n-2*i-1,i-1,10**9+7))
... |
s099609103 | p02555 | u217571418 | 1600029016 | Python | Python (3.8.2) | py | Runtime Error | 56 | 9116 | 229 | import math
S = int(input())
le = S // 3
count = 0
for i in range(1, le):
sa = S - 3 * i
if sa >= 0:
count += math.factorial(i + le)/(math.factorial(i) * math.factorial(le))
ans = count % (10 ** 9 +7)
print(ans) |
s558367330 | p02555 | u573234244 | 1600028901 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9184 | 727 | s = int(input())
def cmb(n, r):
if n - r < r: r = n - r
if r == 0: return 1
if r == 1: return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2,r+1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % ... |
s475128453 | p02555 | u905029819 | 1600028771 | Python | Python (3.8.2) | py | Runtime Error | 54 | 9132 | 257 | import math
S = int(input())
divider = 10**9 + 7
sum = 0
if S > 5:
for i in range(1, S//3 + 1):
sum += math.factorial(S-2*i-1) / math.factorial(S-3*i) / math.factorial(i-1)
print(int(sum % divider))
elif 3 <= S <= 5 :
print(1)
else:
print(0) |
s584713631 | p02555 | u642426958 | 1600028740 | Python | Python (3.8.2) | py | Runtime Error | 1337 | 733172 | 531 | # 再帰制限に引っかかった場合に外す
import sys
sys.setrecursionlimit(1000000000)
nCr = {}
def cmb(n, r):
if r == 0 or r == n: return 1
if r == 1: return n
if (n,r) in nCr: return nCr[(n,r)]
nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
return nCr[(n,r)]
n = int(input())
MOD = 1000000007
count = 0
ans = 0
if n == 1... |
s904167811 | p02555 | u588592871 | 1600028722 | Python | Python (3.8.2) | py | Runtime Error | 77 | 9196 | 258 | import math
n=int(input())
n_0=int(n/3)
S=0
if n>3:
for i in range(1,n_0+1):
n_1 = n - i * 3
sumup=int(math.factorial(i-1 + n_1)/((math.factorial(i-1))*(math.factorial(n_1))))
sumup%(10**9+7)
S+=sumup
S=S%(10**9+7)
else:
S=0
print(S) |
s494701515 | p02555 | u372802746 | 1600028571 | Python | Python (3.8.2) | py | Runtime Error | 23 | 9184 | 217 | N = int(input())
x = [0] * N
y = [0] * N
z=[]
for i in range(N):
x[i], y[i] = map(int, input().split())
for i in range(0,(int((1/2)*N*(N+1)-1))):
z.append(abs(x[i//N]-x[i%N])+abs(y[i//N]-y[i%N]))
print(max(z)) |
s926837884 | p02555 | u561615664 | 1600028569 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 74652 | 306 | S = int(input())
mod = 10**9+7
s = S%3
n = int((S-s)/3)
ss = 0
for i in range(n):
jj = 1
for j in range(n-i,2*i+s+n):
if n-i==1:
jj = 1
else:
jj *= j
kk = 1
for k in range(n-i-1):
kk *= k+1
ss += ((jj/kk)%mod)
print(int(ss%mod)) |
s855817448 | p02555 | u947664173 | 1600028529 | Python | PyPy3 (7.3.0) | py | Runtime Error | 111 | 68108 | 403 | s=int(input())
import math
ketamax=int(math.floor(s/3))
def kaijo(a,b):
x=a
for i in range(a+1,b+1):
x=x*i
return x
def comb(n, r):
if r==0:
return 1
else:
a=kaijo(n-r+1,n)/kaijo(1,r)
return a
waru=pow(10,9)+7
ans=0
for i in range(1,ketamax+1):
nokori=s-3*i
kazu=c... |
s648592309 | p02555 | u905029819 | 1600028512 | Python | Python (3.8.2) | py | Runtime Error | 86 | 9240 | 264 | import math
S = int(input())
divider = 10**9 + 7
sum = 0
if S > 5:
for i in range(1, S//3 + 1):
sum += int(math.factorial(S-2*i-1) / (math.factorial(S-3*i) * math.factorial(i-1)))
print(int(sum % divider))
elif 3 <= S <= 5 :
print(1)
else:
print(0) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.