buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> using namespace std; #define int long long int #define fi first #define se second #define pb push_back #define soo(v) sort(v.rbegin(), v.rend()) #define so(v) sort(v.begin(), v.end()) #define lb(v, x) lower_bound(v.begin(), v.end(), x) #define ub(v, x) upper_bound(v.begin(), v.end(), x) #define...
#include <bits/stdc++.h> using namespace std; #define int long long int #define fi first #define se second #define pb push_back #define soo(v) sort(v.rbegin(), v.rend()) #define so(v) sort(v.begin(), v.end()) #define lb(v, x) lower_bound(v.begin(), v.end(), x) #define ub(v, x) upper_bound(v.begin(), v.end(), x) #define...
[["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38]]
1
342
S=int(input()) a = [0]*(S+1) a[3]=1 for i in range(4, S+1): a[i] = a[i-3] + a[i-1] mod=10**9+7 print(a[S]%mod)
S=int(input()) a = [0]*(2000+1) a[3]=1 for i in range(4, S+1): a[i] = a[i-3] + a[i-1] mod=10**9+7 print(a[S]%mod)
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 31, 612]]
5
71
#include <iostream> typedef long long ll; using namespace std; static const int MOD = 1000000007; // DPテーブル ll dp[2005]; int main() { int S; cin >> S; // 初期条件 dp[0] = 1; for (int i = 3; i <= S; i++) { dp[i] = (dp[i - 1] + dp[i - 3]) % MOD; } if (S >= 1 && S <= 3) cout << 0 << endl; else co...
#include <iostream> typedef long long ll; using namespace std; static const int MOD = 1000000007; // DPテーブル ll dp[2005]; int main() { int S; cin >> S; // 初期条件 dp[0] = 1; for (int i = 3; i <= S; i++) { dp[i] = (dp[i - 1] + dp[i - 3]) % MOD; } if (S >= 1 && S <= 2) cout << 0 << endl; else co...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
114
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; #define fi first #define se second #define pb push_back #define wzh(x) cerr << #x << '=' << x << endl; int s; const int mod = 1e9 + 7; int add(int &x, int y) { x += y; if (x >...
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; #define fi first #define se second #define pb push_back #define wzh(x) cerr << #x << '=' << x << endl; int s; const int mod = 1e9 + 7; void add(int &x, int y) { x += y; if (x ...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
1
168
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...
def solve(S): dp = [0]*(2000+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): answer = (answer + dp[n-c]) % MOD dp[n] = answer return dp[S] print(solve(int(input())))
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 31, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
105
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...
def solve(S): dp = [0]*(2000+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] #s...
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 31, 612]]
5
105
#include <bits/stdc++.h> using namespace std; #define reps(i, a, n) for (int i = (a); i < (n); ++i) #define rep(i, n) reps(i, 0, n) #define deps(i, a, n) for (int i = (a); i >= (n); --i) #define dep(i, n) deps(i, n, 0) #define inf 2147483647 #define int long long #define mod 1000000007 signed main(void) { int n; c...
#include <bits/stdc++.h> using namespace std; #define reps(i, a, n) for (int i = (a); i < (n); ++i) #define rep(i, n) reps(i, 0, n) #define deps(i, a, n) for (int i = (a); i >= (n); --i) #define dep(i, n) deps(i, n, 0) #define inf 2147483647 #define int long long #define mod 1000000007 signed main(void) { int n; c...
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13]]
1
127
#include <algorithm> #include <iostream> #include <vector> using namespace std; using lld = long long int; #define mod 1000000007; typedef long long ll; const ll M = 1000000007; vector<ll> fac(300001); // n!(mod M) vector<ll> ifac(300001); // k!^{M-2} (mod M) // a,bの範囲的にこれだけ配列を用意していけば十分 ll mpow(ll x, ll n)...
#include <algorithm> #include <iostream> #include <vector> using namespace std; using lld = long long int; #define mod 1000000007; typedef long long ll; const ll M = 1000000007; vector<ll> fac(300001); // n!(mod M) vector<ll> ifac(300001); // k!^{M-2} (mod M) // a,bの範囲的にこれだけ配列を用意していけば十分 ll mpow(ll x, ll n)...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
361
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define dup(x, y) (((x) + (y)-1) / (y)) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef pair<int, int> pii; const double EPS = 1e-10; const int INF = 1e9; const ll LINF = 1e15; const int MOD = 1000000007; c...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define dup(x, y) (((x) + (y)-1) / (y)) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef pair<int, int> pii; const double EPS = 1e-10; const int INF = 1e9; const ll LINF = 1e15; const int MOD = 1000000007; c...
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
1
582
#include <iostream> using namespace std; int main() { int s; cin >> s; long long ans[2005]; ans[0] = 0; ans[1] = 0; ans[2] = 0; ans[3] = 1; for (int i = 4; i <= s; ++i) { ans[i] += 1; for (int j = 3; j <= i - 3; ++j) { ans[i] += ans[j]; ans[i] %= 1000000007ll; } } cout <...
#include <iostream> using namespace std; int main() { int s; cin >> s; long long ans[2005] = {}; ans[0] = 0; ans[1] = 0; ans[2] = 0; ans[3] = 1; for (int i = 4; i <= s; ++i) { ans[i] += 1; for (int j = 3; j <= i - 3; ++j) { ans[i] += ans[j]; ans[i] %= 1000000007ll; } } c...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
1
122
#include <bits/stdc++.h> #define rep(X, N) for (ll X = 0LL; X < (N); X++) #define ALL(V) (V).begin(), (V).end() #define endl "\n" using namespace std; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; const double PI = 3.1415926535897932384626; const ll MODN = 1000000007; const ll MODN...
#include <bits/stdc++.h> #define rep(X, N) for (ll X = 0LL; X < (N); X++) #define ALL(V) (V).begin(), (V).end() #define endl "\n" using namespace std; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; const double PI = 3.1415926535897932384626; const ll MODN = 1000000007; const ll MODN...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
868
#include <algorithm> #include <bits/stdc++.h> #include <string> using namespace std; // std::の省略のため using ll = long long; #define INF 1000000000000 // 10^12:∞ #define MOD 1000000007 // 10^9+7:合同式の法 #define MAXR 100000 // 10^5:配列の最大のrange const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; // テー...
#include <algorithm> #include <bits/stdc++.h> #include <string> using namespace std; // std::の省略のため using ll = long long; #define INF 1000000000000 // 10^12:∞ #define MOD 1000000007 // 10^9+7:合同式の法 #define MAXR 100000 // 10^5:配列の最大のrange const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; // テー...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22]]
1
320
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define ll long long #define pb push_back #define bg begin() #define en end() #define vvl(n, m) vector<vector<ll>> a(n, vector<ll>(m)) #define fast ...
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <bits/stdc++.h> #define ll long long #define pb push_back #define bg begin() #define en end() #define vvl(n, m) vector<vector<ll>> a(n, vector<ll>(m)) #define fast ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
868
/* // ABC141 D - Powerful Discount Tickets // 優先度キュー プライオリティーキュー int main() { ll n,m; cin >> n >> m; // プライオリティーキューに突っ込む priority_queue<ll> q; rep(i,n){ ll k; cin >> k; q.push(k); } // 値段の高いものから割引券を適応して戻す rep(i,m){ ll now = q.top(); q.pop(); now /= 2; q.push(now); } ...
/* // ABC141 D - Powerful Discount Tickets // 優先度キュー プライオリティーキュー int main() { ll n,m; cin >> n >> m; // プライオリティーキューに突っ込む priority_queue<ll> q; rep(i,n){ ll k; cin >> k; q.push(k); } // 値段の高いものから割引券を適応して戻す rep(i,m){ ll now = q.top(); q.pop(); now /= 2; q.push(now); } ...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
234
S=int(input()) c=S//3 import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) f=0 for i in range(1,c+1): #i個の箱にansを分ける ans=S-3*i#振り分けるべき残りの数 #ball ans個 #i-1 仕切りの数 if ans>0: f+=combinations_count(ans+i-1,i-1) print(f%(10**9+7))
S=int(input()) c=S//3 import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) f=0 for i in range(1,c+1): #i個の箱にansを分ける ans=S-3*i#振り分けるべき残りの数 #ball ans個 #i-1 仕切りの数 #print(ans,i) f+=combinations_count(ans+i-1,i-1) print(f%(10**9+7))
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 102]]
5
105
def comb(n,k,p): """power_funcを用いて(nCk) mod p を求める""" from math import factorial if n<0 or k<0 or n<k: return 0 if n==0 or k==0: return 1 a=factorial(n) %p b=factorial(k) %p c=factorial(n-k) %p return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p def power_func(a,b,p): """a^b mod p を求める""" if b==0: ...
def comb(n,k,p): """power_funcを用いて(nCk) mod p を求める""" from math import factorial if n<0 or k<0 or n<k: return 0 if n==0 or k==0: return 1 a=factorial(n) %p b=factorial(k) %p c=factorial(n-k) %p return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p def power_func(a,b,p): """a^b mod p を求める""" if b==0: ...
[["-", 0, 656, 0, 57, 75, 665, 15, 666, 0, 612], ["+", 0, 656, 0, 57, 75, 665, 15, 666, 0, 612]]
5
245
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) int main() { int S; cin >> S; int mo = 1000000007; VV<ll> dp(667, V<ll>(1998))...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) int main() { int S; cin >> S; int mo = 1000000007; VV<ll> dp(667, V<ll>(1998))...
[["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]]
1
275
#include <iostream> #include <vector> constexpr long long MOD = 1000000007; template <typename T> struct Choose { std::vector<T> fact, inv, invFact; Choose(T N) : fact(N), inv(N), invFact(N) { inv[1] = 1; for (int i = 2; i < inv.size(); ++i) inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD; fact[0] ...
#include <iostream> #include <vector> constexpr long long MOD = 1000000007; template <typename T> struct Choose { std::vector<T> fact, inv, invFact; Choose(T N) : fact(N), inv(N), invFact(N) { inv[1] = 1; for (int i = 2; i < inv.size(); ++i) inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD; fact[0] ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
359
import math S=int(input()) count = 1 if S>=3: i=1 while S>3*(i+1): count += math.factorial(S-3*(i+1)+i)//(math.factorial(S-3*(i+1))*math.factorial(i)) i+=1 print(count%1000000007) else: print(0)
import math S=int(input()) count = 1 if S>=3: i=1 while S>=3*(i+1): count += math.factorial(S-3*(i+1)+i)//(math.factorial(S-3*(i+1))*math.factorial(i)) i+=1 print(count%1000000007) else: print(0)
[["-", 0, 57, 64, 196, 0, 52, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 52, 15, 666, 667, 20]]
5
89
import math n=int(input()) i=1 k=0 ans=0 while True: zan=n-3*i if zan<=0: break ans+=math.factorial(zan+k)//(math.factorial(zan)*math.factorial(k)) i+=1 k+=1 print(ans%(10**9+7))
import math n=int(input()) i=1 k=0 ans=0 while True: zan=n-3*i if zan<0: break ans+=math.factorial(zan+k)//(math.factorial(zan)*math.factorial(k)) i+=1 k+=1 print(ans%(10**9+7))
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18]]
5
79
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll S; cin >> S; ll N = 4000; vector<vector<ll>> pascal(N + 1, vector<ll>(N + 1)); pascal.at(0).at(0) = 1; for (int i = 1; i < N + 1; i++) { pascal.at(i).at(0) = 1; pascal.at(i).at(i) = 1; for (int j = 1; j < i...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll S; cin >> S; ll N = 4000; vector<vector<ll>> pascal(N + 1, vector<ll>(N + 1)); pascal.at(0).at(0) = 1; for (int i = 1; i < N + 1; i++) { pascal.at(i).at(0) = 1; pascal.at(i).at(i) = 1; for (int j = 1; j < i...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
1
253
#include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { long long int N, i, j; cin >> N; vector<long long int> S(N + 1); S[0] = S[1] = S[2] = 0; S[3] = S[4] = S[5] = 1; for (i = 6; i <= N; i += 1) { S[i] = 1; for (j = 3; j <= i - 3; j ...
#include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { int N, i, j; cin >> N; vector<int> S(N + 1); S[0] = S[1] = S[2] = 0; S[3] = S[4] = S[5] = 1; for (i = 6; i <= N; i += 1) { S[i] = 1; for (j = 3; j <= i - 3; j += 1) { S[i] =...
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96]]
1
149
def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = 10**4 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inver...
def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = 10**4 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inver...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
220
import sys import math,bisect sys.setrecursionlimit(10 ** 5) from collections import defaultdict from itertools import groupby,accumulate from heapq import heapify,heappop,heappush from collections import deque,Counter,OrderedDict def I(): return int(sys.stdin.readline()) def neo(): return map(int, sys.stdin.readline()...
import sys import math,bisect sys.setrecursionlimit(10 ** 5) from collections import defaultdict from itertools import groupby,accumulate from heapq import heapify,heappop,heappush from collections import deque,Counter,OrderedDict def I(): return int(sys.stdin.readline()) def neo(): return map(int, sys.stdin.readline()...
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
246
from math import comb mod = 10**9 + 7 s = 1729 ans = 0 n = 1 while s - 2*n - 1 >= 0: ans += comb(s-2*n-1, n-1) ans %= mod n += 1 print(ans)
from math import comb mod = 10**9 + 7 s = int(input()) ans = 0 n = 1 while s - 2*n - 1 >= 0: ans += comb(s-2*n-1, n-1) ans %= mod n += 1 print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
57
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #inc...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #inc...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
1
895
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int inf = 1000000000; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; const ll mod = 1e9 + 7; ll solve(ll a) { if (a == 0) { return 1; } else if (a == 1 || a == 2) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const int inf = 1000000000; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; const ll mod = 1e9 + 7; ll solve(ll a) { if (a == 0) { return 1; } else if (a == 1 || a == 2) { ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
304
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX = 670; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MO...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAX = 2000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % M...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
285
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const int NINF = -1 * INF; const long long LLINF = 1ll << 60; const long long LLNINF = -1 * LLINF; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr> &operator<<(basic...
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const int NINF = -1 * INF; const long long LLINF = 1ll << 60; const long long LLNINF = -1 * LLINF; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr> &operator<<(basic...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
647
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 // (-2^63 <= long < 2^63) #define INF (1 << 30) // 1,073,741,824 //= 536,870,912 *2 #define MOD 1000000007 #...
#include <bits/stdc++.h> using namespace std; typedef long long ll; // int/long: -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31) // long/long long: -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 // (-2^63 <= long < 2^63) #define INF (1 << 30) // 1,073,741,824 //= 536,870,912 *2 #define MOD 1000000007 #...
[["+", 0, 7, 8, 7, 15, 16, 31, 16, 31, 22], ["+", 0, 7, 8, 7, 15, 16, 31, 16, 17, 72], ["-", 8, 9, 0, 7, 8, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 12, 22]]
1
626
import sys #import time from collections import deque, Counter, defaultdict #from fractions import gcd import bisect import heapq #import math import itertools import numpy as np input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda : int(input()) rs = lambda : input().strip(...
import sys #import time from collections import deque, Counter, defaultdict #from fractions import gcd import bisect import heapq #import math import itertools import numpy as np input = sys.stdin.readline sys.setrecursionlimit(10**8) inf = 10**18 MOD = 1000000007 ri = lambda : int(input()) rs = lambda : input().strip(...
[["+", 0, 1, 0, 662, 12, 657, 12, 652, 63, 22], ["+", 0, 662, 12, 657, 12, 652, 3, 4, 0, 612], ["+", 0, 662, 12, 657, 12, 652, 3, 4, 0, 21], ["+", 12, 657, 12, 652, 3, 4, 0, 23, 0, 24], ["+", 12, 657, 12, 652, 3, 4, 0, 23, 0, 25]]
5
165
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <iterator> #include <unordered_map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> dp(n, 0); const unsigned int M = 1000000007; // dp[i] = how many ways to get this sum dp[0] = 1; // th...
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <iterator> #include <unordered_map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> dp(n + 1, 0); const unsigned int M = 1000000007; // dp[i] = how many ways to get this sum dp[0] = 1; /...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
125
#include <bits/stdc++.h> //#include<atcoder/all> using namespace std; // using namespace atcoder; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #de...
#include <bits/stdc++.h> //#include<atcoder/all> using namespace std; // using namespace atcoder; #define rep(i, n) for (ll i = 0; i < n; i++) #define repl(i, l, r) for (ll i = (l); i < (r); i++) #define per(i, n) for (ll i = n - 1; i >= 0; i--) #define perl(i, r, l) for (ll i = r - 1; i >= l; i--) #define fi first #de...
[["-", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["-", 0, 52, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["-", 0, 52, 8, 9, 0, 57, 15, 339, 0, 25]]
1
1,737
#include <bits/stdc++.h> #define maxn 2333 #define mod 1000000007 using namespace std; typedef long long ll; ll dp[maxn / 3][maxn]; int main() { int S; cin >> S; for (int j = 0; j <= S; ++j) dp[0][j] = 1; for (int i = 1; i <= S / 3; ++i) { for (int j = 3; j <= S; ++j) { dp[i][j] = (dp[i][j - 1] + ...
#include <bits/stdc++.h> #define maxn 2333 #define mod 1000000007 using namespace std; typedef long long ll; ll dp[maxn / 3][maxn]; int main() { int S; cin >> S; for (int j = 0; j <= S; ++j) dp[0][j] = 1; for (int i = 1; i <= S / 3; ++i) { for (int j = 3; j <= S; ++j) { dp[i][j] = (dp[i][j - 1] + ...
[["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
1
188
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define rrep(i, n) for (int i = n - 1; i >= 0; --i) #define fi first #define se second using namespace std; using lint = long long; using uint = unsigned int; using ulint = unsigned long long; using ldouble = long double; using pii = pair<int, int>;...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define rrep(i, n) for (int i = n - 1; i >= 0; --i) #define fi first #define se second using namespace std; using lint = long long; using uint = unsigned int; using ulint = unsigned long long; using ldouble = long double; using pii = pair<int, int>;...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
486
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mod 998244353 #define INF 1 << 30 #define MAX (1 << 20) #define NINF (-(1 << 30)) #define triplet pair<pair<int, int>, int> const int maxs = 2000; ll fact[maxs]; ll power(ll base, ll p, ll pr) { ll ans = 1; ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mod 1e9 + 7 #define INF 1 << 30 #define MAX (1 << 20) #define NINF (-(1 << 30)) #define triplet pair<pair<int, int>, int> const int maxs = 2000; ll fact[maxs]; ll power(ll base, ll p, ll pr) { ll ans = 1; i...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
330
def nCr(n,r,mod): p=1 q=1 # print(n,r) for i in range(r): q *= i+1 q %= mod p *= n-i p %= mod # print(p,q) return (p * pow(q,mod-2,mod)) % mod s=int(input()) mod = 10**9+7 ans = 0 for i in range(1,s//3+1): if i==1: ...
def nCr(n,r,mod): p=1 q=1 # print(n,r) for i in range(r): q *= i+1 q %= mod p *= n-i p %= mod # print(p,q) return (p * pow(q,mod-2,mod)) % mod s=int(input()) mod = 10**9+7 ans = 0 for i in range(1,s//3+1): if i==1: ...
[["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 132], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22]]
5
129
s=int(input()) ans=0 mod=10**9+7 from operator import mul from functools import reduce 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 for i in range(0,s//3+1): ans+=(combinations_count(s-3*i+...
s=int(input()) ans=0 mod=10**9+7 from operator import mul from functools import reduce 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 for i in range(1,s//3+1): ans+=(combinations_count(s-3*i+...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
129
S = int(input()) a = [0] * 2000 a[0] = 0 a[1] = 0 a[2] = 1 a[3] = 1 a[4] = 1 a[5] = 2 k = 0 for i in range(6, S): for l in range(2, i-2): k += a[l] a[i] = 1 + k p = a[S-1] % (10**9 + 7) print(p)
S = int(input()) a = [0] * 2000 a[0] = 0 a[1] = 0 a[2] = 1 a[3] = 1 a[4] = 1 a[5] = 2 for i in range(6, S): k = 0 for l in range(2, i-2): k += a[l] a[i] = 1 + k p = a[S-1] % (10**9 + 7) print(p)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]]
5
110
def main(): 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(1, (i-3)+1): dp[i] += dp[j] dp[i] %= mod print(dp[s]) if __name__ == "__main__": main()
def main(): 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(0, (i-3)+1): dp[i] += dp[j] dp[i] %= mod print(dp[s]) if __name__ == "__main__": main()
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
97
#include <bits/stdc++.h> using namespace std; const long long MD = 1e9 + 7; long long n, fact[2005], ans; long long qpow(long long b, long long exp) { long long ret = 1; while (exp != 0) { if (exp % 2 == 1) { ret *= b; ret %= MD; } b *= b; b %= MD; exp /= 2; } return ret; } long ...
#include <bits/stdc++.h> using namespace std; const long long MD = 1e9 + 7; long long n, fact[2005], ans; long long qpow(long long b, long long exp) { long long ret = 1; while (exp != 0) { if (exp % 2 == 1) { ret *= b; ret %= MD; } b *= b; b %= MD; exp /= 2; } return ret; } long ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
300
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FILL0(x) memset(x, 0, sizeof(x)) #define FILL1(x) memset(x, -1, sizeof(x)) using namespace std; typedef long long ll; typedef pair<ll, ll> P; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FILL0(x) memset(x, 0, sizeof(x)) #define FILL1(x) memset(x, -1, sizeof(x)) using namespace std; typedef long long ll; typedef pair<ll, ll> P; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
433
S=int(input()) ans=int(0) iqs=[1] for i in range(1,S): iqs.append(i*iqs[-1]) #print(iqs) for i in range(1,S//3+1): raw=S-i*3 #(i-1)とrawの重複組み合わせ ans+=iqs[raw+i-1]//iqs[i-1]//iqs[raw] ans=ans%(10**9+7) print(ans) print(ans)
S=int(input()) ans=int(0) iqs=[1] for i in range(1,S): iqs.append(i*iqs[-1]) #print(iqs) for i in range(1,S//3+1): raw=S-i*3 #(i-1)とrawの重複組み合わせ ans+=iqs[raw+i-1]//iqs[i-1]//iqs[raw] ans=ans%(10**9+7) print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
105
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll M = 1e9 + 7; int main() { ll n; cin >> n; ll dp[n + 1] = {0}; dp[0] = 0; dp[1] = 0; dp[2] = 0; dp[3] = 1; dp[4] = 1; dp[5] = 1; dp[6] = 2; if (n < 3) cout << 0 << "\n"; else { for (int i = 7; i <= n; i++) { ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; ll M = 1e9 + 7; int main() { ll n; cin >> n; ll dp[2005] = {0}; dp[0] = 0; dp[1] = 0; dp[2] = 0; dp[3] = 1; dp[4] = 1; dp[5] = 1; dp[6] = 2; if (n < 3) cout << 0 << "\n"; else { for (int i = 7; i <= n; i++) { ...
[["-", 0, 43, 49, 50, 49, 80, 81, 16, 31, 22], ["-", 0, 43, 49, 50, 49, 80, 81, 16, 17, 72], ["-", 0, 43, 49, 50, 49, 80, 81, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
1
184
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; vector<uint64_t> a(s + 1, 0); if (s == 0) { cout << 1 << endl; } else if (s < 3) { cout << 0 << endl; } else { a.at(0) = 1; uint64_t sum; for (int i = 1; i < s + 1; i++) { sum = 0; if (i >= 3) { ...
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; vector<uint64_t> a(s + 1, 0); if (s == 0) { cout << 1 << endl; } else if (s < 3) { cout << 0 << endl; } else { a.at(0) = 1; uint64_t sum; for (int i = 1; i < s + 1; i++) { sum = 0; if (i >= 3) { ...
[["-", 64, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 64, 9, 0, 7, 15, 16, 12, 16, 31, 22]]
1
157
s = int(input()) dp = [0]*(s+1) MOD = 10**9+7 dp[0] = 1 dp[1] = 0 dp[2] = 0 if s >= 3: for i in range(3, s+1): dp[i] = (dp[i-1] + dp[i-3]) % MOD print(dp[s]) else: print(0)
s = int(input()) dp = [0]*(2001) MOD = 10**9+7 dp[0] = 1 dp[1] = 0 dp[2] = 0 if s >= 3: for i in range(3, s+1): dp[i] = (dp[i-1] + dp[i-3]) % MOD print(dp[s]) else: print("0")
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["-", 0, 662, 12, 657, 12, 23, 0, 657, 17, 72], ["-", 0, 662, 12, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 23, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655]]
5
96
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) % ...
s = int(input()) x = s // 3 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 ...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]]
5
218
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1000000007; int main() { ll s; cin >> s; ll dp[s + 1]; // oooo|ooooooo i番目の右に仕切り dp[0] = dp[1] = dp[2] = 0; // 数列なし dp[3] = dp[4] = dp[5] = 1; // 数列はひとつだけ(仕切りが右端) dp[6] = dp[3] + 1; // dp[7] = dp[4] + dp[3] ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1000000007; int main() { ll s; cin >> s; ll dp[2001]; // oooo|ooooooo i番目の右に仕切り dp[0] = dp[1] = dp[2] = 0; // 数列なし dp[3] = dp[4] = dp[5] = 1; // 数列はひとつだけ(仕切りが右端) dp[6] = dp[3] + 1; // dp[7] = dp[4] + dp[3] ...
[["-", 8, 9, 0, 43, 49, 80, 81, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
150
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; ll a[20005]; int main() { ll s; cin >> s; a[0] = a[1] = a[2] = 0; a[3] = 1; for (int i = 4; i <= s; i++) { a[i] = a[i - 1] + a[i - 3]; } cout << a[s] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; ll a[20005]; int main() { ll s; cin >> s; a[0] = a[1] = a[2] = 0; a[3] = 1; for (int i = 4; i <= s; i++) { a[i] = (a[i - 1] + a[i - 3]) % mod; } cout << a[s] << endl; return 0; }
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
109
#include <iostream> using namespace std; const int kMaxS = 2001; const int kM = 1000000007; int s; int f[kMaxS]; int main() { cin >> s; fill_n(f, s + 1, 1); for (int i = 1; i <= s; i++) { for (int j = 3; j <= i - 3; j++) { f[i] = (f[i] + f[j]) % kM; } } cout << (f[s] == 1 ? 0 : f[s]); ret...
#include <iostream> using namespace std; const int kMaxS = 2001; const int kM = 1000000007; int s; int f[kMaxS]; int main() { cin >> s; fill_n(f, s + 1, 1); for (int i = 1; i <= s; i++) { for (int j = 3; j <= i - 3; j++) { f[i] = (f[i] + f[j]) % kM; } } cout << (s < 3 ? 0 : f[s]); return ...
[["-", 12, 23, 0, 41, 15, 16, 31, 69, 28, 22], ["-", 0, 41, 15, 16, 31, 69, 341, 342, 0, 70], ["-", 0, 41, 15, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 16, 12, 23, 0, 41, 15, 16, 17, 60], ["-", 0, 16, 12, 23, 0, 41, 15, 16, 12, 13], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 17, 18], ["+", 0, 16, 12, 23, 0, 41, 15, 16, 12, 13]]
1
122
#include <iostream> using namespace std; const int MAX = 3000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[...
#include <iostream> using namespace std; const int MAX = 3000; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[...
[["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
293
from operator import mul from functools import reduce 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 N = int(input()) ans = 0 amari = int(N % 3) shou = int(N // 3) for i in range(shou): a...
from operator import mul from functools import reduce 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 N = int(input()) ans = 0 amari = int(N % 3) shou = int(N // 3) for i in range(shou): a...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
142
import math s = int(input()) if s < 6: print("0") else: bar = (s // 3) - 1 ans = 0 for i in range(bar+1): if i == 0: ans += 1 else: val = s - 3 * (i+1) count = math.factorial(val+i) // (math.factorial(val) * math.factorial(i)) ans += count ...
import math s = int(input()) if s < 3: print("0") else: bar = (s // 3) - 1 ans = 0 for i in range(bar+1): if i == 0: ans += 1 else: val = s - 3 * (i+1) count = math.factorial(val+i) // (math.factorial(val) * math.factorial(i)) ans += count ...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 612]]
5
115
import math mod = (int)(1e9+7) def fat(N): ret = 1 for i in range(1, N+1): ret*=i ret%=mod return ret def modInverse(b): g = math.gcd(b, mod) if (g != 1): return -1 else: return pow(b, mod-2, mod) def modDivide(a, b): a %= mod inv = modInv...
import math mod = (int)(1e9+7) def fat(N): ret = 1 for i in range(1, N+1): ret*=i ret%=mod return ret def modInverse(b): g = math.gcd(b, mod) if (g != 1): return -1 else: return pow(b, mod-2, mod) def modDivide(a, b): a %= mod inv = modInv...
[["-", 8, 196, 0, 57, 15, 23, 0, 666, 667, 19], ["+", 8, 196, 0, 57, 15, 23, 0, 666, 667, 18]]
5
178
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, s, n) for (int i = s; i < (int)(n); i++) ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; #define rep(i, s, n) for (int i = s; i < (int)(n); i++) ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } // a^{-1...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
392
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (int)(n); i++) #define all(a) a.begin(), a.end() #define put(i) cout << fixed << i << endl using namespace std; using ll = long long; ll s; ll mod = 1e9 + 7; static vector<ll> dp(4010, -1); ll dfs(ll sum = 0) { if (sum == s) { return 1; }...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (int)(n); i++) #define all(a) a.begin(), a.end() #define put(i) cout << fixed << i << endl using namespace std; using ll = long long; ll s; ll mod = 1e9 + 7; static vector<ll> dp(4010, -1); ll dfs(ll sum = 0) { if (sum == s) { return 1; }...
[["-", 8, 9, 0, 7, 15, 16, 12, 2, 63, 22], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 21], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 13], ["-", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]]
1
198
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define mp make_pair #define pb push_back #define pll pair<ll, ll> ll INF = 1000000007; //-----------------// #define amin main //----------------// ll dp[2002] = {0}; int amin() { ios_base::sync_with_stdio(false); cin...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define mp make_pair #define pb push_back #define pll pair<ll, ll> ll INF = 1000000007; //-----------------// #define amin main //----------------// ll dp[2002] = {0}; int amin() { ios_base::sync_with_stdio(false); cin...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
1
178
// Problem : D - Redistribution // Contest : AtCoder - AtCoder Beginner Contest 178 // URL : https://atcoder.jp/contests/abc178/tasks/abc178_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; #define endl "\n...
// Problem : D - Redistribution // Contest : AtCoder - AtCoder Beginner Contest 178 // URL : https://atcoder.jp/contests/abc178/tasks/abc178_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; #define endl "\n...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 20], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
1
438
import sys import math import itertools import collections from collections import deque from collections import defaultdict sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD2 = 998244353 INF = float('inf') input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split(...
import sys import math import itertools import collections from collections import deque from collections import defaultdict sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD2 = 998244353 INF = float('inf') input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split(...
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
242
#include <bits/stdc++.h> using namespace std; #define FAST_IO \ \ ios::sync_with_stdio(false); \ cin.tie(0); #define DEBUG #ifdef DEBUG #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__) template <type...
#include <bits/stdc++.h> using namespace std; #define FAST_IO \ \ ios::sync_with_stdio(false); \ cin.tie(0); #define DEBUG #ifdef DEBUG #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__) template <type...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
423
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define db(a) cout << fixed << #a << " = " << a << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const ll MOD = 1e9 + 7; const int MAXN = 20 + 5; vector<vector<ll>> dp(MAXN, vector<ll>(MAXN, 0)); int main() { ios_base::sync_w...
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define db(a) cout << fixed << #a << " = " << a << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const ll MOD = 1e9 + 7; const int MAXN = 2000 + 5; vector<vector<ll>> dp(MAXN, vector<ll>(MAXN, 0)); int main() { ios_base::sync...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13]]
1
278
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define int long long int #define setbits(x) __builtin_popcountll(x) #define mod 1000000007 #define modp 998244353 #define inf (ll)1e18 #define ps(x, y) fixed << setprecision(y) << x ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define int long long int #define setbits(x) __builtin_popcountll(x) #define mod 1000000007 #define modp 998244353 #define inf (ll)1e18 #define ps(x, y) fixed << setprecision(y) << x ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
431
a = b = 0; c = 1 for _ in range(int(input()) - 3): a, b, c = b, c, (a + c) % (10**9 + 7) print(c)
a = 1; b = c = 0 for _ in range(int(input()) - 2): a, b, c = b, c, (a + c) % (10**9 + 7) print(c)
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 36, 36, 36, 36, 0, 656, 0, 35], ["-", 0, 656, 0, 1, 0, 662, 12, 662, 12, 612], ["-", 36, 36, 36, 36, 36, 36, 0, 656, 0, 35], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 662, 12, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 61...
5
51
s = int(input()) a = b = 0; c = s > 2 for _ in range(s - 3): a, b, c = b, c, (a + c) % (10**9 + 7) print(c)
s = int(input()) a = b = 0; c = int(s > 2) for _ in range(s - 3): a, b, c = b, c, (a + c) % (10**9 + 7) print(c)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
56
#include <bits/stdc++.h> using namespace std; #define ll long long #define lvector vector<ll> #define cvector vector<char> #define svector vector<string> #define lque queue<ll> #define lpque priority_queue<ll> #define dlpque priority_queue<ll, lvector, greater<ll>> #define P pair<ll, ll> #define ALL(a) a.begin(), a.end...
#include <bits/stdc++.h> using namespace std; #define ll long long #define lvector vector<ll> #define cvector vector<char> #define svector vector<string> #define lque queue<ll> #define lpque priority_queue<ll> #define dlpque priority_queue<ll, lvector, greater<ll>> #define P pair<ll, ll> #define ALL(a) a.begin(), a.end...
[["+", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
266
import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long mod = 1000000007; long[] ans = new long[n]; if (n > 3) { ans[2] = 1; ans[3] = 1;...
import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long mod = 1000000007; long[] ans = new long[n]; if (n >= 4) { ans[2] = 1; ans[3] = 1...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["-", 75, 57, 15, 15, 0, 16, 31, 16, 12, 499], ["+", 75, 57, 15, 15, 0, 16, 31, 16, 12, 499], ["-", 75, 57, 15, 15, 0, 16, 12, 16, 12, 49...
3
181
#include <bits/stdc++.h> #include <iostream> #define ll long long using namespace std; const ll num = 1e9 + 7; ll mod(ll n) { return (n % num + num) % num; } ll add(ll x, ll y) { return mod(mod(x) + mod(y)); } ll mult(ll x, ll y) { return mod(mod(x) * mod(y)); } ll sub(ll x, ll y) { return mod(mod(x) - mod(y)); } ll pt...
#include <bits/stdc++.h> #include <iostream> #define ll long long using namespace std; const ll num = 1e9 + 7; ll mod(ll n) { return (n % num + num) % num; } ll add(ll x, ll y) { return mod(mod(x) + mod(y)); } ll mult(ll x, ll y) { return mod(mod(x) * mod(y)); } ll sub(ll x, ll y) { return mod(mod(x) - mod(y)); } ll pt...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 1, 0, 11, 12, 2, 63, 22], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 64, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
354
S = int(input()) mod = 10**9+7 memo = [-1]*(S+1) def redis(s): if memo[s] != -1: return memo[s] else: if s < 3: memo[s] = 0 return 0 elif s < 6: memo[s] = 1 return 1 else: tmp = 0 for num in range(s-2): tmp += redis(num)%mod memo[s] = tmp retur...
S = int(input()) mod = 10**9+7 memo = [-1]*(S+1) memo[0] = 1 def redis(s): if memo[s] != -1: return memo[s] else: if s < 3: memo[s] = 0 return 0 elif s < 6: memo[s] = 1 return 1 else: tmp = 0 for num in range(s-2): tmp += redis(num)%mod memo[s] = tmp...
[["+", 0, 656, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 0, 656, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 31, 206, 206, 612], ["+", 0, 656, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
115
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, N) for (int i = 0; i < int(N); ++i) #define rep1(i, N) for (int i = 1; i < int(N); ++i) #define all(a) (a).begin(), (a).end() #define bit(k) (1LL << (k)) #define SUM(v) accumulate(all(v), 0LL) typedef pair<int, int> i_i; typedef pair<ll...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, N) for (int i = 0; i < int(N); ++i) #define rep1(i, N) for (int i = 1; i < int(N); ++i) #define all(a) (a).begin(), (a).end() #define bit(k) (1LL << (k)) #define SUM(v) accumulate(all(v), 0LL) typedef pair<int, int> i_i; typedef pair<ll...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
1,204
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for (int i = 0; i < n; ++i) typedef vector<int> vi; typedef pair<int, int> iPair; template <typename T> T inverse(T a, T m) { T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } asse...
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for (int i = 0; i < n; ++i) typedef vector<int> vi; typedef pair<int, int> iPair; template <typename T> T inverse(T a, T m) { T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } asse...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
2,138
INF=1000000000+7 s=int(input()) dp=[0]*(s+1); dp[0]=dp[1]=dp[2]=0 dp[3]=1 for i in range(4,s+1): temp=1 for j in range(3,i-2): temp+=dp[j]%INF; temp%=INF; dp[i]=temp print(dp[s])
INF=1000000000+7 s=int(input()) dp=[0]*(2000+1); dp[0]=dp[1]=dp[2]=0 dp[3]=1 for i in range(4,s+1): temp=1 for j in range(3,i-2): temp+=dp[j]%INF; temp%=INF; dp[i]=temp print(dp[s])
[["-", 0, 662, 12, 657, 12, 23, 0, 657, 31, 22], ["+", 0, 662, 12, 657, 12, 23, 0, 657, 31, 612]]
5
100
/* written by Pankaj Kumar. country:-INDIA */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<pair<ll, ll>> vpl; typedef vector<string> vs; typedef map<ll, ll> ml; typedef ...
/* written by Pankaj Kumar. country:-INDIA */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<pair<ll, ll>> vpl; typedef vector<string> vs; typedef map<ll, ll> ml; typedef ...
[["+", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
1
410
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef set<int> si; typedef set<ll> sll; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pvec(v) \ for (auto e : v) ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef set<int> si; typedef set<ll> sll; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pvec(v) \ for (auto e : v) ...
[["-", 0, 43, 49, 50, 49, 80, 81, 16, 31, 22], ["-", 0, 43, 49, 50, 49, 80, 81, 16, 17, 72], ["-", 0, 43, 49, 50, 49, 80, 81, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
1
356
MOD=10**9+7 def cmb(n,r): if n-r < r: r = n-r if r == 0: return 1 denominator = 1 numerator = 1 for i in range(r): numerator *= n-i numerator %= Q denominator *= i+1 denominator %= Q return numerator*pow(denominator,...
#import sys #input = sys.stdin.readline Q = 10**9+7 def cmb(n,r): if n-r < r: r = n-r if r == 0: return 1 denominator = 1 #分母 numerator = 1 #分子 for i in range(r): numerator *= n-i numerator %= Q denominator *= i+1 denomina...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22], ["-", 0, 656, 0, 57, 15, 666, 0, 557, 0, 654], ["+", 0, 656, 0, 57, 15, 666, 0, 557, 0, 654], ["-", 0, 656, 0, 57, 15, 666, 0, 557, 0, 655], ["...
5
147
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define irep(i, n) for (int i = (n); i >= 0; i--) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1 << 25; const int MOD = 1e9 + 7; ll dp[1000]; int main() { int s; cin >> s; dp[0] = 1; for (int i = 3; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define irep(i, n) for (int i = (n); i >= 0; i--) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1 << 25; const int MOD = 1e9 + 7; int dp[2050]; int main() { int s; cin >> s; dp[0] = 1; for (int i = 3;...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
134
#include <cstring> #include <iostream> using namespace std; const int MOD = 1e9 + 7; int bino[2001][2001]; int main() { memset(bino, 0, sizeof bino); bino[0][0] = 1; for (int i = 1; i <= 2000; ++i) { bino[i][0] = bino[i][i] = 1; for (int j = 1; j < i; ++j) { bino[i][j] = (bino[i - 1][j - 1] + bi...
#include <cstring> #include <iostream> using namespace std; const int MOD = 1e9 + 7; int bino[2001][2001]; int main() { memset(bino, 0, sizeof bino); bino[0][0] = 1; for (int i = 1; i <= 2000; ++i) { bino[i][0] = bino[i][i] = 1; for (int j = 1; j < i; ++j) { bino[i][j] = (bino[i - 1][j - 1] + bi...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
200
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(0,S-2): dp[i]+=dp[j] dp[i]%=MOD print(dp[S])
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(0,i-2): dp[i]+=dp[j] dp[i]%=MOD print(dp[S])
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22]]
5
78
#include <algorithm> #include <cmath> #include <iostream> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <utility> #include <vector> #define INF 1000000000000 const long long MOD = 1000000007; using namespace std; t...
#include <algorithm> #include <cmath> #include <iostream> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <utility> #include <vector> #define INF 1000000000000 const long long MOD = 1000000007; using namespace std; t...
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 22]]
1
220
S = int(input()) i = 0 ans = 0 mod = 10 ** 9 + 7 def comb(n, k): de = 1 nu = 1 for i in range(k): de *= (n - i) % mod nu *= (i + 1) % mod nu = pow(nu, -1, mod) return de * nu while 1: S -= 3 if S <= 0: if S == 0: S += 1 print(ans) exit() ans += comb(S+i, i) ans = ans ...
S = int(input()) i = 0 ans = 0 mod = 10 ** 9 + 7 def comb(n, k): de = 1 nu = 1 for i in range(k): de *= (n - i) % mod nu *= (i + 1) % mod nu = pow(nu, -1, mod) return de * nu while 1: S -= 3 if S <= 0: if S == 0: ans += 1 print(ans) exit() ans += comb(S+i, i) ans = an...
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22]]
5
120
#include <bits/stdc++.h> using namespace std; const int N = 2e2 + 2, Mod = 1e9 + 7; long long int dp[N]; int s; long long calc(long long sum) { // cout<<1; if (sum == s) return 1; if (sum > s) return 0; long long &ret = dp[sum]; if (ret != -1) return ret; ret = 0; bool z = 0, n = 0; for (int...
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 2, Mod = 1e9 + 7; long long int dp[N]; int s; long long calc(long long sum) { // cout<<1; if (sum == s) return 1; if (sum > s) return 0; long long &ret = dp[sum]; if (ret != -1) return ret; ret = 0; bool z = 0, n = 0; for (int...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13]]
1
156
#include <iostream> #include <vector> typedef long long ll; const ll m = 1e9 + 7; int main(int argc, char **argv) { int S; std::cin >> S; std::vector<ll> A(S + 1, 0); A[3] = 1; for (int i = 4; i < S + 1; i++) { A[i] = A[i - 3] + A[i - 1]; A[i] %= m; } std::cout << A[S] << std::endl; }
#include <iostream> #include <vector> typedef long long ll; const ll m = 1e9 + 7; int main(int argc, char **argv) { int S; std::cin >> S; std::vector<ll> A(2001, 0); A[3] = 1; for (int i = 4; i < S + 1; i++) { A[i] = A[i - 3] + A[i - 1]; A[i] %= m; } std::cout << A[S] << std::endl; }
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
118
#include <bits/stdc++.h> using namespace std; int main() { int mod = 1e9 + 7; int n; cin >> n; long long int dp[n + 1]; dp[1] = 0; dp[2] = 0; dp[3] = 1; dp[4] = 1; dp[5] = 1; dp[6] = 2; for (int i = 7; i <= n; i++) dp[i] = (dp[i - 3] * 2 + dp[i - 4] + dp[i - 5]) % mod; cout << dp[n]; retu...
#include <bits/stdc++.h> using namespace std; int main() { int mod = 1e9 + 7; int n; cin >> n; long long int dp[n + 7]; dp[1] = 0; dp[2] = 0; dp[3] = 1; dp[4] = 1; dp[5] = 1; dp[6] = 2; for (int i = 7; i <= n; i++) dp[i] = (dp[i - 3] * 2 + dp[i - 4] + dp[i - 5]) % mod; cout << dp[n]; retu...
[["-", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13]]
1
134
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i) #define rreps(i, n) for (int i = ((int)(n)); i > 0; --i) #define ALL(x) (x).begin(), (x).end() #defi...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i) #define rreps(i, n) for (int i = ((int)(n)); i > 0; --i) #define ALL(x) (x).begin(), (x).end() #defi...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13]]
1
424
#include <bits/stdc++.h> using namespace std; #define int long long #define flash \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.t...
#include <bits/stdc++.h> using namespace std; #define int long long #define flash \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.t...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
289
#include <bits/stdc++.h> using namespace std; #define int long long #define ACC \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.ti...
#include <bits/stdc++.h> using namespace std; #define int long long #define ACC \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.ti...
[["+", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 35]]
1
199
/*jai_ganeshdeva*/ #include <bits/stdc++.h> using namespace std; #define pb push_back #define pu push // adds the value to the last of the queue #define lld long long int #define ins insert /// used in set to insert the values #define adv advance /// used to increment the iterator #define mp make_pair #define fi fir...
/*jai_ganeshdeva*/ #include <bits/stdc++.h> using namespace std; #define pb push_back #define pu push // adds the value to the last of the queue #define lld long long int #define ins insert /// used in set to insert the values #define adv advance /// used to increment the iterator #define mp make_pair #define fi fir...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
578
#include <bits/stdc++.h> #include <iostream> #include <string> #define ll long long int #define ld long double #define pb push_back #define endl "\n" #define mp make_pair #define sz(v) (int)(v.size()) #define len(s) (int)(s.length()) #define M (ll)(1e9 + 7) #define all(v) v.begin(), v.end() #define fr(a, b, c) for (ll ...
#include <bits/stdc++.h> #include <iostream> #include <string> #define ll long long int #define ld long double #define pb push_back #define endl "\n" #define mp make_pair #define sz(v) (int)(v.size()) #define len(s) (int)(s.length()) #define M (ll)(1e9 + 7) #define all(v) v.begin(), v.end() #define fr(a, b, c) for (ll ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
473
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) ...
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) ...
[["-", 15, 16, 31, 16, 31, 16, 12, 16, 31, 13], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 31, 13], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
389
#include <bits/stdc++.h> #define int long long #define double long double const int INF = 2147483647; const int MOD = 1000000007; const int mod = 998244353; const double eps = 1e-18; using namespace std; int C[4001][4001]; int H(int n, int k) { return C[n + k - 1][k]; } signed main() { ios_base::sync_with_stdi...
#include <bits/stdc++.h> #define int long long #define double long double const int INF = 2147483647; const int MOD = 1000000007; const int mod = 998244353; const double eps = 1e-18; using namespace std; int C[4001][4001]; int H(int n, int k) { return C[n + k - 1][k]; } signed main() { ios_base::sync_with_stdi...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
273
import sys sys.setrecursionlimit(10**9) def mi(): return map(int,input().split()) def ii(): return int(input()) def isp(): return input().split() def deb(text): print("-------\n{}\n-------".format(text)) INF=10**20 class Counting(): def __init__(self,maxim,mod): maxim += 1 self.mod = mod ...
import sys sys.setrecursionlimit(10**9) def mi(): return map(int,input().split()) def ii(): return int(input()) def isp(): return input().split() def deb(text): print("-------\n{}\n-------".format(text)) INF=10**20 class Counting(): def __init__(self,maxim,mod): maxim += 1 self.mod = mod ...
[["-", 0, 14, 8, 196, 0, 52, 15, 666, 667, 47], ["+", 0, 14, 8, 196, 0, 52, 15, 666, 667, 20]]
5
390
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; const int MOD = 1000000007; if (s <= 2) { cout << 0 << endl; return 0; } else if (s <= 5) { cout << 2 << endl; return 0; } int ans[s + 1]; for (int i = 0; i < s + 1; i++) ans[i] = 0; ans[3] = 1; ans[4]...
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; const int MOD = 1000000007; if (s <= 2) { cout << 0 << endl; return 0; } else if (s <= 5) { cout << 1 << endl; return 0; } int ans[s + 1]; for (int i = 0; i < s + 1; i++) ans[i] = 0; ans[3] = 1; ans[4]...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
185
// xtwakioi! xtwddYnoi(双重含义)! #include <bits/stdc++.h> #define ri register #define int long long #define E (n + 1) using namespace std; const int N = 1000010, Mod = 1e9 + 7; inline int read() { int s = 0, w = 1; ri char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getch...
// xtwakioi! xtwddYnoi(双重含义)! #include <bits/stdc++.h> #define ri register #define int long long #define E (n + 1) using namespace std; const int N = 1000010, Mod = 1e9 + 7; inline int read() { int s = 0, w = 1; ri char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getch...
[["-", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
1
276
/* Arthor : Ender_zzm E-mail zzm_ender_wiggin@outlook.com Blog oi.ender-zzm.pro */ #include <bits/stdc++.h> using namespace std; inline int Isdigit(char c) { if (c < '0' || c > '9') return 0; return 1; } inline int readint() { register int x = 0, flag = 1; register char ch; while (!Isdigit(ch = getchar()...
/* Arthor : Ender_zzm E-mail zzm_ender_wiggin@outlook.com Blog oi.ender-zzm.pro */ #include <bits/stdc++.h> using namespace std; inline int Isdigit(char c) { if (c < '0' || c > '9') return 0; return 1; } inline int readint() { register int x = 0, flag = 1; register char ch; while (!Isdigit(ch = getchar()...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
655
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): S = int(input()) MOD = 10 ** 9 + 7 if S <= 3: print(0) exit() dp = [1] * (S + 1) dp[0] = 0 dp[1] = 0 dp[2] = 0 for i in range(3, S + 1): for j in range(i - 3, 1, -1): ...
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): S = int(input()) MOD = 10 ** 9 + 7 if S <= 2: print(0) exit() dp = [1] * (S + 1) dp[0] = 0 dp[1] = 0 dp[2] = 0 for i in range(3, S + 1): for j in range(i - 3, 1, -1): ...
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612]]
5
139
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; template <ll MOD> struct ModInt { ll value; ModInt() : value(0) {} ModInt(const ll &v) : value(v % MOD) { if (value < 0) value += MOD; } ModInt<MOD> &operator=(const ModInt &o) { value = o.value; ret...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; template <ll MOD> struct ModInt { ll value; ModInt() : value(0) {} ModInt(const ll &v) : value(v % MOD) { if (value < 0) value += MOD; } ModInt<MOD> &operator=(const ModInt &o) { value = o.value; ret...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
1
961
class Combination: # 計算量は O(n_max + log(mod)) def __init__(self, n_max, mod=10**9+7): self.mod = mod f = 1 self.fac = fac = [f] for i in range(1, n_max+1): # 階乗(= n_max !)の逆元を生成 f = f * i % mod ...
class Combination: # 計算量は O(n_max + log(mod)) def __init__(self, n_max, mod=10**9+7): self.mod = mod f = 1 self.fac = fac = [f] for i in range(1, n_max+1): # 階乗(= n_max !)の逆元を生成 f = f * i % mod ...
[["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
388
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template <class T> void debug(T itr1, T itr2) { auto now = itr1; while (now < itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i, from, to) for (ll i = (ll)from; i < (ll)to; i++) #define al...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template <class T> void debug(T itr1, T itr2) { auto now = itr1; while (now < itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i, from, to) for (ll i = (ll)from; i < (ll)to; i++) #define al...
[["-", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
447
import sys import re import random import math import copy from heapq import heappush, heappop, heapify from functools import cmp_to_key from bisect import bisect_left, bisect_right from collections import defaultdict, deque, Counter # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = la...
import sys import re import random import math import copy from heapq import heappush, heappop, heapify from functools import cmp_to_key from bisect import bisect_left, bisect_right from collections import defaultdict, deque, Counter # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = la...
[["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612]]
5
370
S = int(input()) MOD = 10**9+7 fact = [1] for i in range(1, S+1): fact.append(fact[-1]*i % MOD) ifact = [None]*(S+1) ifact[-1] = pow(fact[-1], MOD-2, MOD) for i in range(S, 0, -1): ifact[i-1] = ifact[i]*i % MOD def comb(n, k): if n <= 0: return 0 return (fact[n]*ifact[n-k]*ifact[k]) % MOD ans = ...
S = int(input()) MOD = 10**9+7 fact = [1] for i in range(1, S+1): fact.append(fact[-1]*i % MOD) ifact = [None]*(S+1) ifact[-1] = pow(fact[-1], MOD-2, MOD) for i in range(S, 0, -1): ifact[i-1] = ifact[i]*i % MOD def comb(n, k): if n < 0: return 0 return (fact[n]*ifact[n-k]*ifact[k]) % MOD ans = 0...
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
188
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } using ll = long long; using lb = long double; using P = ...
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } using ll = long long; using lb = long double; using P = ...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 20]]
1
388