Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
9 values
p03170
/*********************************************************** *This code By @1353055672(Ligen) * *[Warning]You're not excepted to understand this code! * *CSP-S 2019 RP++ * ***********************************************************/ // #pragma GCC optimize(3) #define ADD_STACK \ int size = 512 << 20; \ char *pp = (char *)malloc(size) + size; \ __asm__("movl %0, %%esp\n" ::"r"(pp)) #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> #define ll long long #define ull unsigned long long #define mn 200020 #define Max(x, y) (((x) > (y)) ? (x) : (y)) #define Min(x, y) (((x) < (y)) ? (x) : (y)) #define Abs(x) (((x) < (0)) ? (-(x)) : (x)) #define infll (ll)(1e18) #define infint (1 << 30) #define mod (int)(1e9 + 7) #define FOR(a, b, c) for (register int a = b; a <= c; ++a) #define FORD(a, b, c) for (register int a = b; a >= c; --a) using namespace std; // char buf[1<<20],*p1=buf,*p2=buf; // #define getchar() // (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++) inline ll read() { ll x = 0, f = 1; char c; for (c = getchar(); c < '0' || c > '9'; f = ((c == '-') ? -1 : f), c = getchar()) ; for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar()) ; return x * f; } template <typename T> inline void write(T a) { if (a == 0) { putchar('0'); return; } if (a < 0) putchar('-'), a = -a; char c1[120]; int h = 0; while (a) c1[++h] = a % 10 + '0', a /= 10; FORD(i, h, 1) putchar(c1[i]); } inline void write_() { return; } template <typename T, typename... Args> inline void write_(T a, Args... b) { write(a); putchar(' '); write_(b...); } inline void writeln() { putchar('\n'); return; } template <typename T, typename... Args> inline void writeln(T a, Args... b) { write(a); putchar(' '); writeln(b...); } // need c++11 // inline void write(ll a){ // if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int // h=0; while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]); //} // inline void write_(ll a){write(a);putchar(' ');} // inline void writeln(ll a){write(a);putchar('\n');} inline ll gcd(ll a, ll b) { return a == 0 ? b : gcd(b % a, a); } inline ll lcm(ll a, ll b) { return 1ll * a / gcd(a, b) * b; } inline ll Pow(ll n, ll a) { ll b = 1; while (a) { if (a & 1) b = 1ll * b * n % mod; n = 1ll * n * n % mod; a >>= 1; } return b; } //---------------------Head Files--------------------------// int n, m, a[120]; bool v[100020], vv; signed main() { #ifndef ONLINE_JUDGE // freopen("0.in","r",stdin); // freopen("0.out","w",stdout); double be = clock(); #endif n = read(), m = read(); FOR(i, 1, n) a[i] = read(), v[a[i]] = 1; FOR(i, 1, m) if (!v[i]) { vv = 1; FOR(j, 1, n) if (i - a[j] >= 0) vv &= v[i - a[j]]; if (!vv) v[i] = 1; } if (v[m]) puts("First"); else puts("Second"); #ifndef ONLINE_JUDGE double en = clock(); printf("Time: %.0lfms\n", en - be); fclose(stdin); fclose(stdout); #endif return 0; }
/*********************************************************** *This code By @1353055672(Ligen) * *[Warning]You're not excepted to understand this code! * *CSP-S 2019 RP++ * ***********************************************************/ // #pragma GCC optimize(3) #define ADD_STACK \ int size = 512 << 20; \ char *pp = (char *)malloc(size) + size; \ __asm__("movl %0, %%esp\n" ::"r"(pp)) #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <ctime> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> #define ll long long #define ull unsigned long long #define mn 200020 #define Max(x, y) (((x) > (y)) ? (x) : (y)) #define Min(x, y) (((x) < (y)) ? (x) : (y)) #define Abs(x) (((x) < (0)) ? (-(x)) : (x)) #define infll (ll)(1e18) #define infint (1 << 30) #define mod (int)(1e9 + 7) #define FOR(a, b, c) for (register int a = b; a <= c; ++a) #define FORD(a, b, c) for (register int a = b; a >= c; --a) using namespace std; // char buf[1<<20],*p1=buf,*p2=buf; // #define getchar() // (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++) inline ll read() { ll x = 0, f = 1; char c; for (c = getchar(); c < '0' || c > '9'; f = ((c == '-') ? -1 : f), c = getchar()) ; for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = getchar()) ; return x * f; } template <typename T> inline void write(T a) { if (a == 0) { putchar('0'); return; } if (a < 0) putchar('-'), a = -a; char c1[120]; int h = 0; while (a) c1[++h] = a % 10 + '0', a /= 10; FORD(i, h, 1) putchar(c1[i]); } inline void write_() { return; } template <typename T, typename... Args> inline void write_(T a, Args... b) { write(a); putchar(' '); write_(b...); } inline void writeln() { putchar('\n'); return; } template <typename T, typename... Args> inline void writeln(T a, Args... b) { write(a); putchar(' '); writeln(b...); } // need c++11 // inline void write(ll a){ // if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int // h=0; while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]); //} // inline void write_(ll a){write(a);putchar(' ');} // inline void writeln(ll a){write(a);putchar('\n');} inline ll gcd(ll a, ll b) { return a == 0 ? b : gcd(b % a, a); } inline ll lcm(ll a, ll b) { return 1ll * a / gcd(a, b) * b; } inline ll Pow(ll n, ll a) { ll b = 1; while (a) { if (a & 1) b = 1ll * b * n % mod; n = 1ll * n * n % mod; a >>= 1; } return b; } //---------------------Head Files--------------------------// int n, m, a[120]; bool v[100020], vv; signed main() { #ifdef LOCAL_LIGEN // freopen("0.in","r",stdin); // freopen("0.out","w",stdout); double be = clock(); #endif n = read(), m = read(); FOR(i, 1, n) a[i] = read(), v[a[i]] = 1; FOR(i, 1, m) if (!v[i]) { vv = 1; FOR(j, 1, n) if (i - a[j] >= 0) vv &= v[i - a[j]]; if (!vv) v[i] = 1; } // FOR(i,0,m)writeln(i,v[i]); if (v[m]) puts("First"); else puts("Second"); #ifdef LOCAL_LIGEN double en = clock(); printf("Time: %.0lfms\n", en - be); fclose(stdin); fclose(stdout); #endif return 0; }
[]
978,997
978,996
u379604713
cpp
p03170
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define f first #define s second #define MM INT_MAX / 5 #define MIM INT_MIN / 2 int di[] = {1, -1, 0, 0}; int dj[] = {0, 0, 1, -1}; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define v vector #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define beg(x) x.begin() #define en(x) x.end() #define all(x) beg(x), en(x) #define resz resize #define MAX (int)1e5 + 1 bool dp[MAX]; int N; int K; int main() { cin >> N >> K; vector<int> stones(N); for (int i = 0; i < N; i++) cin >> stones[i]; dp[0] = false; for (int i = 1; i <= N; i++) { bool res = false; for (int stone : stones) { if (i - stone >= 0 && !dp[i - stone]) res = true; } dp[i] = res; } if (dp[K]) cout << "First"; else cout << "Second"; }
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define f first #define s second #define MM INT_MAX / 5 #define MIM INT_MIN / 2 int di[] = {1, -1, 0, 0}; int dj[] = {0, 0, 1, -1}; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define v vector #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define beg(x) x.begin() #define en(x) x.end() #define all(x) beg(x), en(x) #define resz resize #define MAX (int)1e5 + 1 bool dp[MAX]; int N; int K; int main() { cin >> N >> K; vector<int> stones(N); for (int i = 0; i < N; i++) cin >> stones[i]; dp[0] = false; for (int i = 1; i <= K; i++) { bool res = false; for (int stone : stones) { if (i - stone >= 0 && !dp[i - stone]) res = true; } dp[i] = res; } if (dp[K]) cout << "First"; else cout << "Second"; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
978,998
978,999
u879680955
cpp
p03170
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define f first #define s second #define MM INT_MAX / 5 #define MIM INT_MIN / 2 int di[] = {1, -1, 0, 0}; int dj[] = {0, 0, 1, -1}; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define v vector #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define beg(x) x.begin() #define en(x) x.end() #define all(x) beg(x), en(x) #define resz resize #define MAX (int)1e5 + 1 bool dp[MAX]; int N; int K; int main() { cin >> N >> K; vector<int> stones(N); for (int i = 0; i < N; i++) cin >> stones[i]; dp[0] = false; for (int i = 1; i <= N; i++) { bool res = false; for (int stone : stones) { if (i - stone >= 0 && !dp[i - stone]) res = true; } dp[i] = res; } if (dp[N]) cout << "First"; else cout << "Second"; }
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define f first #define s second #define MM INT_MAX / 5 #define MIM INT_MIN / 2 int di[] = {1, -1, 0, 0}; int dj[] = {0, 0, 1, -1}; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define v vector #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define beg(x) x.begin() #define en(x) x.end() #define all(x) beg(x), en(x) #define resz resize #define MAX (int)1e5 + 1 bool dp[MAX]; int N; int K; int main() { cin >> N >> K; vector<int> stones(N); for (int i = 0; i < N; i++) cin >> stones[i]; dp[0] = false; for (int i = 1; i <= K; i++) { bool res = false; for (int stone : stones) { if (i - stone >= 0 && !dp[i - stone]) res = true; } dp[i] = res; } if (dp[K]) cout << "First"; else cout << "Second"; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
979,000
978,999
u879680955
cpp
p03170
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; vector<int> coins(n); for (int i = 0; i < n; i++) cin >> coins[i]; vector<int> dp(k + 1, false); for (int i = 1; i <= k; i++) { for (auto x : coins) { if (i - x >= 0) { dp[i] = !dp[i - x]; } } } if (dp[k]) cout << "First" << endl; else cout << "Second" << endl; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; vector<int> coins(n); for (int i = 0; i < n; i++) cin >> coins[i]; vector<int> dp(k + 1, false); for (int i = 1; i <= k; i++) { for (auto x : coins) { if (i - x >= 0) { dp[i] |= !dp[i - x]; } } } if (dp[k]) cout << "First" << endl; else cout << "Second" << endl; return 0; }
[ "assignment.value.change" ]
979,003
979,004
u586135939
cpp
p03170
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; bool dp[10100]; int main() { int N, K; cin >> N >> K; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a[i]; } sort(a.begin(), a.end()); for (int i = 0; i < 10100; i++) { dp[i] = false; } dp[0] = false; for (int i = 0; i <= K + 10; i++) { for (int j = 0; j < N; j++) { if (i >= a[j]) { dp[i] |= !dp[i - a[j]]; } } } // if (dp[K] == false) { cout << "Second" << endl; } else { cout << "First" << endl; } return 0; }
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; bool dp[101000]; int main() { int N, K; cin >> N >> K; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a[i]; } sort(a.begin(), a.end()); for (int i = 0; i < 101000; i++) { dp[i] = false; } dp[0] = false; for (int i = 0; i <= K + 10; i++) { for (int j = 0; j < N; j++) { if (i >= a[j]) { dp[i] |= !dp[i - a[j]]; } } } // if (dp[K] == false) { cout << "Second" << endl; } else { cout << "First" << endl; } return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
979,009
979,010
u904123392
cpp
p03170
#include <bits/stdc++.h> using namespace std; int dp[1000009], arr[109]; int main() { memset(dp, 0, sizeof(dp)); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); for (int i = 1; i <= n; i++) dp[arr[i]] = 1; dp[0] = 0; for (int i = 1; i <= k; i++) { for (int j = 0; j < n; j++) { if (i >= arr[j]) { if (!dp[i - arr[j]]) dp[i] = 1; } } } if (dp[k] == 1) cout << "first\n"; else cout << "Second" << endl; }
#include <bits/stdc++.h> using namespace std; int dp[1000009], arr[109]; int main() { memset(dp, 0, sizeof(dp)); int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); for (int i = 1; i <= n; i++) dp[arr[i]] = 1; dp[0] = 0; for (int i = 1; i <= k; i++) { for (int j = 0; j < n; j++) { if (i >= arr[j]) { if (!dp[i - arr[j]]) dp[i] = 1; } } } if (dp[k] == 1) cout << "First\n"; else cout << "Second" << endl; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
979,013
979,014
u099812604
cpp
p03170
#pragma GCC optimize("03") #include <bits/stdc++.h> using namespace std; int n, k, a[105], dp[100005]; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 0; i <= k; ++i) { if (dp[i] == 0) for (int j = 1; j <= n; ++j) dp[i + a[j]] = 1; } cout << (dp[k] ? "First\n" : "Second\n"); return 0; }
#pragma GCC optimize("03") #include <bits/stdc++.h> using namespace std; int n, k, a[100005], dp[200005]; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 0; i <= k; ++i) { if (dp[i] == 0) for (int j = 1; j <= n; ++j) dp[i + a[j]] = 1; } cout << (dp[k] ? "First\n" : "Second\n"); return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
979,019
979,020
u127754559
cpp
p03170
#pragma GCC optimize("03") #include <bits/stdc++.h> using namespace std; int n, k, a[105], dp[100005]; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i <= k; ++i) { if (dp[i] == 0) for (int j = 0; j < n; ++j) dp[i + a[j]] = 1; } cout << (dp[k] ? "First\n" : "Second\n"); return 0; }
#pragma GCC optimize("03") #include <bits/stdc++.h> using namespace std; int n, k, a[100005], dp[200005]; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 0; i <= k; ++i) { if (dp[i] == 0) for (int j = 1; j <= n; ++j) dp[i + a[j]] = 1; } cout << (dp[k] ? "First\n" : "Second\n"); return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "co...
979,021
979,020
u127754559
cpp
p03170
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)((x).size()) #define debug(x) cout << #x << ":" << x << " "; #define debugg(x) cout << #x << ":" << x << ' ' << "\n"; #define endl "\n" #define L(X) ((X) << 1) #define R(X) (((X) << 1) | 1) #define M(X, Y) (((X) + (Y)) >> 1) using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int MAXN = 1e5 + 5; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long int LLINF = 0x3f3f3f3f3f3f3f3f; const double EPS = 1e-9; const double PI = acos(-1); template <typename T> T max_self(T &a, T b) { if (a < b) a = b; return a; } template <typename T> T min_self(T &a, T b) { if (a > b) a = b; return a; } template <typename T> T add(T x, T y) { return ((x % MOD) + (y % MOD)) % MOD; } template <typename T> T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD; } template <typename T> T sub(T x, T y) { return add(x, -y + MOD); } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> vector<T> read(vector<T> &v, int n) { v.resize(n); for (auto &x : v) cin >> x; } template <typename T> void trav(vector<T> &v) { for (int i = 0; i < (int)v.size(); ++i) { cout << v[i]; if (i != (int)v.size() - 1) cout << ' '; } } int lg2(long long x) { return 64 - __builtin_clzll(x) - 1; } int lg2(int x) { return 32 - __builtin_clzll(x) - 1; } int n, k, a[MAXN]; bool dp[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[i]; } dp[0] = false; for (int i = 0; i <= k; ++i) { if (dp[i] == false) { for (int j = 0; j < n; ++j) { if (i + a[j] < n) dp[i + a[j]] = true; } } } string ans = "First"; if (!dp[k]) ans = "Second"; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)((x).size()) #define debug(x) cout << #x << ":" << x << " "; #define debugg(x) cout << #x << ":" << x << ' ' << "\n"; #define endl "\n" #define L(X) ((X) << 1) #define R(X) (((X) << 1) | 1) #define M(X, Y) (((X) + (Y)) >> 1) using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int MAXN = 1e5 + 5; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long int LLINF = 0x3f3f3f3f3f3f3f3f; const double EPS = 1e-9; const double PI = acos(-1); template <typename T> T max_self(T &a, T b) { if (a < b) a = b; return a; } template <typename T> T min_self(T &a, T b) { if (a > b) a = b; return a; } template <typename T> T add(T x, T y) { return ((x % MOD) + (y % MOD)) % MOD; } template <typename T> T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD; } template <typename T> T sub(T x, T y) { return add(x, -y + MOD); } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> vector<T> read(vector<T> &v, int n) { v.resize(n); for (auto &x : v) cin >> x; } template <typename T> void trav(vector<T> &v) { for (int i = 0; i < (int)v.size(); ++i) { cout << v[i]; if (i != (int)v.size() - 1) cout << ' '; } } int lg2(long long x) { return 64 - __builtin_clzll(x) - 1; } int lg2(int x) { return 32 - __builtin_clzll(x) - 1; } int n, k, a[MAXN]; bool dp[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[i]; } dp[0] = false; for (int i = 0; i <= k; ++i) { if (dp[i] == false) { for (int j = 0; j < n; ++j) { if (i + a[j] <= k) dp[i + a[j]] = true; } } } string ans = "First"; if (!dp[k]) ans = "Second"; cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change" ]
979,022
979,023
u455493734
cpp
p03170
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; #define rep(i, n) for (ll i = 0; i < n; i++) #define all(i) i.begin(), i.end() template <class T, class U> bool cmax(T &a, U b) { if (a < b) { a = b; return true; } else return false; } template <class T, class U> bool cmin(T &a, U b) { if (a > b) { a = b; return true; } else return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, k; cin >> n >> k; vi a(n); rep(i, n) { cin >> a[i]; } vector<bool> dp(k + 1); rep(i, k + 1) { rep(j, n) { if (i - a[j] >= 0 && dp[i - a[j]] == 0) { dp[i] = 1; } } } if (dp[k]) puts("FIrst"); else puts("Second"); }
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; #define rep(i, n) for (ll i = 0; i < n; i++) #define all(i) i.begin(), i.end() template <class T, class U> bool cmax(T &a, U b) { if (a < b) { a = b; return true; } else return false; } template <class T, class U> bool cmin(T &a, U b) { if (a > b) { a = b; return true; } else return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, k; cin >> n >> k; vi a(n); rep(i, n) { cin >> a[i]; } vector<bool> dp(k + 1); rep(i, k + 1) { rep(j, n) { if (i - a[j] >= 0 && dp[i - a[j]] == 0) { dp[i] = 1; } } } if (dp[k]) puts("First"); else puts("Second"); }
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
979,024
979,025
u366644013
cpp
p03170
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; #define fi first #define se second #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define siz(v) (ll)(v).size() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repi(i, x, n) for (ll i = x; i < (ll)(n); i++) typedef pair<int, int> P; typedef pair<ll, ll> PL; const ll mod = 1000000007; const ll INF = 1000000099; vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1}; // cin.tie(0); // ios::sync_with_stdio(false); int dp[100010] = {}; // 0==lose signed main() { int n; cin >> n; ll k; cin >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; rep(i, k + 1) { rep(j, n) { dp[i + a[j]] = max(1 - dp[i], dp[i + a[j]]); } } if (dp[k] == 1) { cout << "First" << endl; } else { cout << "Second" << endl; } }
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = double; #define fi first #define se second #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define siz(v) (ll)(v).size() #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repi(i, x, n) for (ll i = x; i < (ll)(n); i++) typedef pair<int, int> P; typedef pair<ll, ll> PL; const ll mod = 1000000007; const ll INF = 1000000099; vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1}; // cin.tie(0); // ios::sync_with_stdio(false); int dp[500010] = {}; // 0==lose signed main() { int n; cin >> n; ll k; cin >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; rep(i, k + 1) { rep(j, n) { dp[i + a[j]] = max(1 - dp[i], dp[i + a[j]]); } } if (dp[k] == 1) { cout << "First" << endl; } else { cout << "Second" << endl; } }
[ "literal.number.change", "variable_declaration.array_dimensions.change" ]
979,026
979,027
u317711717
cpp
p03170
#include <bits/stdc++.h> #include <iostream> #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); using namespace std; //#define mod 1e9+7 // was not working // const int mod=1e9+7; //works kool vector<int> S(100001); int main() { fast; int N, K; cin >> N >> K; vector<bool> dp(101, false); for (int i = 0; i < N; i++) cin >> S[i]; for (int i = 0; i <= K; i++) { for (int j = 0; j < N; j++) { // cout<<i<<" "<<i-j<<endl; if (i - S[j] >= 0 && dp[i - S[j]] == 0) dp[i] = 1; } } // out<<dp[K]<<endl; if (dp[K]) cout << "First"; else cout << "Second"; return 0; }
#include <bits/stdc++.h> #include <iostream> #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); using namespace std; //#define mod 1e9+7 // was not working // const int mod=1e9+7; //works kool vector<int> S(100); int main() { fast; int N, K; cin >> N >> K; vector<bool> dp(100001, false); for (int i = 0; i < N; i++) cin >> S[i]; for (int i = 0; i <= K; i++) { for (int j = 0; j < N; j++) { // cout<<i<<" "<<i-j<<endl; if (i - S[j] >= 0 && dp[i - S[j]] == 0) dp[i] = 1; } } // out<<dp[K]<<endl; if (dp[K]) cout << "First"; else cout << "Second"; return 0; }
[ "literal.number.change", "call.arguments.change" ]
979,028
979,029
u174636610
cpp
p03170
#include <bits/stdc++.h> using namespace std; #define _USE_MATH_DEFINES #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // DON'T USE THESE MACROS DURING ICPC PRACTICE #define For(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i <= b; i++) #define Down(i, n) for (int i = n - 1; i >= 0; i--) #define DOWN(i, a, b) for (int i = b; i >= a; i--) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef complex<ld> pt; typedef vector<pt> pol; typedef vector<int> vi; const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const ll MOD = 1e9 + 7; const ld EPS = 1e-10; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(10); int n, k; cin >> n >> k; int a[n]; For(i, n) { cin >> a[i]; } bool lose[k + 1]; For(i, k + 1) { lose[i] = true; For(j, n) { if (i - a[j] >= 0) { lose[i] &= !lose[i]; } } } cout << (lose[k] ? "Second" : "First") << nl; return 0; }
#include <bits/stdc++.h> using namespace std; #define _USE_MATH_DEFINES #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // DON'T USE THESE MACROS DURING ICPC PRACTICE #define For(i, n) for (int i = 0; i < n; i++) #define FOR(i, a, b) for (int i = a; i <= b; i++) #define Down(i, n) for (int i = n - 1; i >= 0; i--) #define DOWN(i, a, b) for (int i = b; i >= a; i--) typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef complex<ld> pt; typedef vector<pt> pol; typedef vector<int> vi; const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll INFLL = 0x3f3f3f3f3f3f3f3f; const ll MOD = 1e9 + 7; const ld EPS = 1e-10; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(10); int n, k; cin >> n >> k; int a[n]; For(i, n) { cin >> a[i]; } bool lose[k + 1]; For(i, k + 1) { lose[i] = true; For(j, n) { if (i - a[j] >= 0) { lose[i] &= !lose[i - a[j]]; } } } cout << (lose[k] ? "Second" : "First") << nl; return 0; }
[ "assignment.change" ]
979,032
979,033
u645327277
cpp
p03170
///╔══╗ ///╚╗╔╝ ///╔╝╚(¯`v´¯) ///╚══╝`.¸.´farzin #include <bits/stdc++.h> #define int int64_t #define pb push_back #define ibsws ios_base::sync_with_stdio #define gcd __gcd #define s second #define f first typedef std::pair<int, int> pii; using namespace std; const int N = 1e5 + 1e2, inf = 1e15; int n, k, x; bool dp[N]; bool mark[N]; vector<int> a; int32_t main() { ibsws(true == false); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> x; a.pb(x); dp[x] = true; } for (int i = 0; i < k + 5; i++) { if (dp[i]) { continue; } for (int j = 0; j < a.size(); j++) { if (i < a[j]) { continue; } if (dp[i - a[j]] == false) { dp[i] = true; break; } } } cout << (dp[k] ? "First" : "second"); }
///╔══╗ ///╚╗╔╝ ///╔╝╚(¯`v´¯) ///╚══╝`.¸.´farzin #include <bits/stdc++.h> #define int int64_t #define pb push_back #define ibsws ios_base::sync_with_stdio #define gcd __gcd #define s second #define f first typedef std::pair<int, int> pii; using namespace std; const int N = 1e5 + 1e2, inf = 1e15; int n, k, x; bool dp[N]; bool mark[N]; vector<int> a; int32_t main() { ibsws(true == false); cin >> n >> k; for (int i = 0; i < n; i++) { cin >> x; a.pb(x); dp[x] = true; } for (int i = 0; i < k + 5; i++) { if (dp[i]) { continue; } for (int j = 0; j < a.size(); j++) { if (i < a[j]) { continue; } if (dp[i - a[j]] == false) { dp[i] = true; break; } } } cout << (dp[k] ? "First" : "Second"); }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
979,034
979,035
u624848802
cpp
p03170
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> v(n + 1); v[0] = 0; for (int i = 1; i <= n; i++) { cin >> v[i]; } vector<int> dp(k + 1); for (int j = 1; j <= k; j++) { for (int i = 1; i <= n; i++) { if (j >= v[i] && dp[j - v[i]] == 0) { dp[j] = true; } } } if (dp[n] == 1) cout << "First" << endl; else cout << "Second" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> v(n + 1); v[0] = 0; for (int i = 1; i <= n; i++) { cin >> v[i]; } vector<int> dp(k + 1); for (int j = 1; j <= k; j++) { for (int i = 1; i <= n; i++) { if (j >= v[i] && dp[j - v[i]] == 0) { dp[j] = true; } } } if (dp[k] == 1) cout << "First" << endl; else cout << "Second" << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
979,036
979,037
u673058289
cpp
p03170
#include <iostream> using namespace std; int arr[100 + 5]; bool dp[100000 + 5]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; for (int stones = 0; stones <= k; stones++) { for (auto x : arr) { if (stones >= x and !dp[stones - x]) { dp[stones] = true; } } } cout << (dp[k] ? "First" : "Second") << endl; return 0; }
#include <iostream> using namespace std; int arr[100 + 5]; bool dp[100000 + 5]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; for (int stones = 0; stones <= k; stones++) { for (int x : arr) { if (x > 0 and stones >= x and !dp[stones - x]) { dp[stones] = true; } } } cout << (dp[k] ? "First" : "Second") << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
979,038
979,039
u421564321
cpp
p03170
/* _________________________________________________________________________________________________ | | | Author : Aditya Ahuja | | Date : Thu, 20th Jun 2019 | |_________________________________________________________________________________________________| */ #include <bits/stdc++.h> using namespace std; // #define int long long #define pb push_back #define F first #define S second #define rep(i, a, b) for (int i = a; i < b; i++) #define all(a) (a).begin(), (a).end() #define ret(x) \ { \ cout << (x) << endl; \ return; \ } #define sz(x) (int)x.size() #define type(x) typeid(x).name() typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<vector<int>> vii; #define wa(x) cout << (#x) << " -------- " << (x) << endl #define pvi(v) \ { \ for (auto it : v) \ cout << it << " "; \ cout << endl; \ } #define line1 printf("---------------------------\n") // #define wa // // #define line1 // // #define pvi // // #define printf // void solve(); signed main() { // ios_base::sync_with_stdio(false); cin.tie(NULL); ////cout << fixed << setprecision(10); int t = 1; // cin>>t; while (t--) solve(); return 0; } //___________________________________________________________________________________________________ void solve() { int n, k; cin >> n >> k; vi a(n); rep(i, 0, n) cin >> a[i]; vi dp(n + 1, 0); rep(i, 1, k + 1) { rep(j, 0, n) { if (i >= a[j] && dp[i - a[j]] == 0) dp[i] = 1; } } cout << (dp[k] ? "First" : "Second") << endl; }
/* _________________________________________________________________________________________________ | | | Author : Aditya Ahuja | | Date : Thu, 20th Jun 2019 | |_________________________________________________________________________________________________| */ #include <bits/stdc++.h> using namespace std; // #define int long long #define pb push_back #define F first #define S second #define rep(i, a, b) for (int i = a; i < b; i++) #define all(a) (a).begin(), (a).end() #define ret(x) \ { \ cout << (x) << endl; \ return; \ } #define sz(x) (int)x.size() #define type(x) typeid(x).name() typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<vector<int>> vii; #define wa(x) cout << (#x) << " -------- " << (x) << endl #define pvi(v) \ { \ for (auto it : v) \ cout << it << " "; \ cout << endl; \ } #define line1 printf("---------------------------\n") // #define wa // // #define line1 // // #define pvi // // #define printf // void solve(); signed main() { // ios_base::sync_with_stdio(false); cin.tie(NULL); ////cout << fixed << setprecision(10); int t = 1; // cin>>t; while (t--) solve(); return 0; } //___________________________________________________________________________________________________ void solve() { int n, k; cin >> n >> k; vi a(n); rep(i, 0, n) cin >> a[i]; vi dp(k + 1, 0); rep(i, 1, k + 1) { rep(j, 0, n) { if (i >= a[j] && !dp[i - a[j]]) dp[i] = 1; } } cout << (dp[k] ? "First" : "Second") << endl; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.unary.add", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
979,040
979,041
u765321936
cpp
p03170
#include <bits/stdc++.h> #include <chrono> #include <cstdio> #include <random> using namespace std; #define DRACARYS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cin.exceptions(cin.failbit); \ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rep(i, n) for (int i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define repD(i, a, n) for (int i = a; i >= (n); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) memset(a, 0, sizeof(a)) #define fst first #define snd second #define mp make_pair #define pb push_back #define PI 3.14159265 const long long int MAXN = 1e5 + 10; const long long int MINN = 1e5 + 10; const long long int inf = 1e18 + 7; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef vector<int> vi; typedef stack<int> st; int n, k, a[105], dp[MAXN]; int main() { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); DRACARYS cin >> n >> k; repA(i, 1, n) cin >> a[i]; repA(i, 0, k) repA(j, 1, n) if (!dp[i]) dp[i + a[j]] = 1; if (dp[k]) cout << "First" << endl; else cout << "Second" << endl; return 0; }
#include <bits/stdc++.h> #include <chrono> #include <cstdio> #include <random> using namespace std; #define DRACARYS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cin.exceptions(cin.failbit); \ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rep(i, n) for (int i = 0; i < (n); ++i) #define repA(i, a, n) for (int i = a; i <= (n); ++i) #define repD(i, a, n) for (int i = a; i >= (n); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define fill(a) memset(a, 0, sizeof(a)) #define fst first #define snd second #define mp make_pair #define pb push_back #define PI 3.14159265 const long long int MAXN = 2e5 + 10; const long long int MINN = 1e5 + 10; const long long int inf = 1e18 + 7; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef vector<int> vi; typedef stack<int> st; int n, k, a[105], dp[MAXN]; int main() { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); DRACARYS cin >> n >> k; repA(i, 1, n) cin >> a[i]; repA(i, 0, k) repA(j, 1, n) if (!dp[i]) dp[i + a[j]] = 1; if (dp[k]) cout << "First" << endl; else cout << "Second" << endl; return 0; }
[ "literal.number.change", "expression.operation.binary.change" ]
979,042
979,043
u907096720
cpp
p03170
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; bool dp[MAXN]; int main() { #ifdef BLAT freopen("input", "r", stdin); #endif int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; for (int i = 1; i <= k; ++i) { for (auto &x : v) { if (i >= x) dp[i] |= (~dp[i - x]); } } cout << (dp[k] ? "First" : "Second"); }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; bool dp[MAXN]; int main() { #ifdef BLAT freopen("input", "r", stdin); #endif int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; for (int i = 1; i <= k; ++i) { for (auto &x : v) { if (i >= x) dp[i] |= (!dp[i - x]); } } cout << (dp[k] ? "First" : "Second"); }
[ "assignment.value.change" ]
979,046
979,047
u745428834
cpp
p03170
#include <bits/stdc++.h> using namespace std; #define X first #define Y second typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; #define debug(x) cerr << #x << " = " << (x) << endl; template <typename T> ostream &operator<<(ostream &o, vector<T> &v) { for (auto &x : v) o << x << ' '; return o; } int n, k; int arr[110]; int memo[100100]; int dp(int k) { int &res = memo[k]; if (res != -1) return res; if (k == 0) return res = 0; for (int i = 0; i < n; i++) { if (arr[i] <= k) { if (dp(k) == 0) return res = 1; } } return res = 0; } int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; memset(memo, -1, sizeof memo); if (dp(k)) cout << "First" << endl; else cout << "Second" << endl; }
#include <bits/stdc++.h> using namespace std; #define X first #define Y second typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; #define debug(x) cerr << #x << " = " << (x) << endl; template <typename T> ostream &operator<<(ostream &o, vector<T> &v) { for (auto &x : v) o << x << ' '; return o; } int n, k; int arr[110]; int memo[100100]; int dp(int k) { int &res = memo[k]; if (res != -1) return res; if (k == 0) return res = 0; for (int i = 0; i < n; i++) { if (arr[i] <= k) { if (dp(k - arr[i]) == 0) return res = 1; } } return res = 0; } int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; memset(memo, -1, sizeof memo); if (dp(k)) cout << "First" << endl; else cout << "Second" << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
979,050
979,051
u115464345
cpp
p03170
#include <iomanip> #include <iostream> using namespace std; const long long MAXN = 3001; int dp[MAXN]; int arr[MAXN]; int main() { int n, k; cin >> n >> k; int mine = 1000000000; for (int i = 0; i < n; i++) { cin >> arr[i]; mine = min(arr[i], mine); } for (int i = mine; i <= k; i++) { for (int j = 0; j < n; j++) { if (i - arr[j] >= 0) { if (!dp[i - arr[j]]) { dp[i] = 1; } } } } if (dp[k]) { cout << "First"; } else { cout << "Second"; } }
#include <iomanip> #include <iostream> using namespace std; const long long MAXN = 100010; int dp[MAXN]; int arr[MAXN]; int main() { int n, k; cin >> n >> k; int mine = 1000000000; for (int i = 0; i < n; i++) { cin >> arr[i]; mine = min(arr[i], mine); } for (int i = mine; i <= k; i++) { for (int j = 0; j < n; j++) { if (i - arr[j] >= 0) { if (!dp[i - arr[j]]) { dp[i] = 1; } } } } if (dp[k]) { cout << "First"; } else { cout << "Second"; } }
[ "literal.number.change", "variable_declaration.value.change" ]
979,070
979,071
u487618988
cpp
p03170
#include <bits/stdc++.h> #define pb push_back #define ers erase #define ins insert #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " = " << x << endl #define kill(x) return cout << x, 0; #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; const ld Pi = 3.14159265359; const ll MOD = 1000 * 1000 * 1000 + 7; const ll MAXN = 2e5 + 10; const ll INF = 1e18; ll dp[MAXN], a[MAXN], k, n; int main() { IOS; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 0; i < a[1]; i++) { dp[i] = 0; } for (int i = a[1]; i <= k; i++) { for (int j = 1; j <= n; j++) { if (i >= a[i] && dp[i - a[j]] == 0) { dp[i] = 1; } } } if (dp[k] == 0) { kill("Second"); } kill("First"); return 0; } /* ,---, ___ ,--, ' .' \ ,--.'|_ ,--.'| ,--, / ; '. | | :,' | | : ,--.'| ,---. ,---, : : \ : : ' : : : ' .--.--. | |, ' ,'\ ,-+-. / | : | /\ \ .;__,' / ,--.--. | ' | ,--.--. / / ' `--'_ / / | ,--.'|' | | : ' ;. : | | | / \ ' | | / \ | : /`./ ,' ,'| . ; ,. :| | ,"' | | | ;/ \ \:__,'| : .--. .-. || | : .--. .-. | | : ;_ ' | | ' | |: :| | / | | ' : | \ \ ,' ' : |__ \__\/: . .' : |__ \__\/: . . \ \ `. | | : ' | .; :| | | | | | | ' '--' | | '.'| ," .--.; || | '.'| ," .--.; | `----. \' : |_| : || | | |/ | : : ; : ;/ / ,. |; : ;/ / ,. | / /`--' /| | '.'\ \ / | | |--' | | ,' | , /; : .' \ , /; : .' \'--'. / ; : ;`----' | |/ `--'' ---`-' | , .-./---`-' | , .-./ `--'---' | , / '---' `--`---' `--`---' ---`-' */
#include <bits/stdc++.h> #define pb push_back #define ers erase #define ins insert #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " = " << x << endl #define kill(x) return cout << x, 0; #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vl; const ld Pi = 3.14159265359; const ll MOD = 1000 * 1000 * 1000 + 7; const ll MAXN = 2e5 + 10; const ll INF = 1e18; ll dp[MAXN], a[MAXN], k, n; int main() { IOS; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 0; i < a[1]; i++) { dp[i] = 0; } for (int i = a[1]; i <= k; i++) { for (int j = 1; j <= n; j++) { if (i >= a[j] && dp[i - a[j]] == 0) { dp[i] = 1; } } } if (dp[k] == 0) { kill("Second"); } kill("First"); return 0; } /* ,---, ___ ,--, ' .' \ ,--.'|_ ,--.'| ,--, / ; '. | | :,' | | : ,--.'| ,---. ,---, : : \ : : ' : : : ' .--.--. | |, ' ,'\ ,-+-. / | : | /\ \ .;__,' / ,--.--. | ' | ,--.--. / / ' `--'_ / / | ,--.'|' | | : ' ;. : | | | / \ ' | | / \ | : /`./ ,' ,'| . ; ,. :| | ,"' | | | ;/ \ \:__,'| : .--. .-. || | : .--. .-. | | : ;_ ' | | ' | |: :| | / | | ' : | \ \ ,' ' : |__ \__\/: . .' : |__ \__\/: . . \ \ `. | | : ' | .; :| | | | | | | ' '--' | | '.'| ," .--.; || | '.'| ," .--.; | `----. \' : |_| : || | | |/ | : : ; : ;/ / ,. |; : ;/ / ,. | / /`--' /| | '.'\ \ / | | |--' | | ,' | , /; : .' \ , /; : .' \'--'. / ; : ;`----' | |/ `--'' ---`-' | , .-./---`-' | , .-./ `--'---' | , / '---' `--`---' `--`---' ---`-' */
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
979,074
979,075
u349705898
cpp
p03170
#include <bits/stdc++.h> using namespace std; int dp[100005]; int a[3000], n, k, mn; bool calc(int m) { if (dp[m] != -1) return dp[m]; dp[m] = 0; // if(m < mn) return 0; for (int i = 0; i < n; ++i) { if (a[i] <= m && !calc(m - a[i])) { dp[m] = 1; // break; } } return dp[m]; } int main() { ios::sync_with_stdio(0); cin.tie(0); memset(dp, -1, sizeof(dp)); cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[i]; mn = min(mn, a[i]); } cout << (calc(k) ? "first" : "second") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int dp[100005]; int a[3000], n, k, mn; bool calc(int m) { if (dp[m] != -1) return dp[m]; dp[m] = 0; // if(m < mn) return 0; for (int i = 0; i < n; ++i) { if (a[i] <= m && !calc(m - a[i])) { dp[m] = 1; // break; } } return dp[m]; } int main() { ios::sync_with_stdio(0); cin.tie(0); memset(dp, -1, sizeof(dp)); cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a[i]; mn = min(mn, a[i]); } cout << (calc(k) ? "First" : "Second") << endl; return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
979,076
979,077
u279627039
cpp
p03170
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i]; vector<int> dp(k + 1); dp[0] = false; for (int i = 1; i <= k; i++) { dp[i] = false; for (int j = 0; j < n; j++) { if (i - x[j] >= 0 && dp[i - x[j]] == false) dp[i] = true; } } if (dp[k] == true) cout << "first"; else cout << "second"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i]; vector<int> dp(k + 1, 0); dp[0] = false; for (int i = 1; i <= k; i++) { dp[i] = false; for (int j = 0; j < n; j++) { if (i - x[j] >= 0 && dp[i - x[j]] == false) dp[i] = true; } } if (dp[k] == true) cout << "First"; else cout << "Second"; return 0; }
[ "call.arguments.add", "literal.string.change", "literal.string.case.change", "io.output.change" ]
979,078
979,079
u971084072
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<long double>> dp(n + 1, vector<long double>(n + 1, 0.0)); vector<long double> v(n, 0.0); for (int i = 0; i < n; i++) cin >> v[i]; dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1 - v[i - 1]); else dp[i][j] = dp[i - 1][j - 1] * v[i - 1] + dp[i - 1][j] * (1 - v[i - 1]); } } // for(int i=0; i<=n; i++) // { // for(int j=0; j<=n; j++) // { // cout<<dp[i][j]<<" "; // } // cout<<endl; // } long double ans = 0.0; for (int j = (n + 1) / 2; j <= n; j++) ans += dp[n][j]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<long double>> dp(n + 1, vector<long double>(n + 1, 0.0)); vector<long double> v(n, 0.0); for (int i = 0; i < n; i++) cin >> v[i]; dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1 - v[i - 1]); else dp[i][j] = dp[i - 1][j - 1] * v[i - 1] + dp[i - 1][j] * (1 - v[i - 1]); } } // for(int i=0; i<=n; i++) // { // for(int j=0; j<=n; j++) // { // cout<<dp[i][j]<<" "; // } // cout<<endl; // } long double ans = 0.0; for (int j = (n + 1) / 2; j <= n; j++) ans += dp[n][j]; cout << setprecision(10) << ans << endl; return 0; }
[ "io.output.change" ]
979,092
979,093
u719635221
cpp
p03168
#pragma comment(linker, "/STACK:16777216") #include <algorithm> #include <bitset> #include <cmath> #include <ctime> #include <iostream> #include <locale> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define speed \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ll long long #define eps 1e-8 #define inf INT_MAX #define mod 1000000007 using namespace std; vector<double> v; int n; double ar[3000][3000]; double req(int p = 0, int c = 0) { if (p == n) { if (c > n / 2) return 1; return 0; } if (ar[p][c] < 0) return ar[p][c]; double res = (1 - v[p]) * req(p + 1, c) + v[p] * req(p + 1, c + 1); ar[p][c] = res; return res; } int main() { speed; for (int i = 0; i < 3000; ++i) for (int j = 0; j < 3000; ++j) ar[i][j] = -1; cin >> n; v.resize(n); for (int i = 0; i < n; ++i) cin >> v[i]; cout.precision(10); cout << fixed << req(); }
#pragma comment(linker, "/STACK:16777216") #include <algorithm> #include <bitset> #include <cmath> #include <ctime> #include <iostream> #include <locale> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define speed \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ll long long #define eps 1e-8 #define inf INT_MAX #define mod 1000000007 using namespace std; vector<double> v; int n; double ar[3000][3000]; double req(int p = 0, int c = 0) { if (p == n) { if (c > n / 2) return 1; return 0; } if (ar[p][c] >= 0) return ar[p][c]; double res = (1 - v[p]) * req(p + 1, c) + v[p] * req(p + 1, c + 1); ar[p][c] = res; return res; } int main() { speed; for (int i = 0; i < 3000; ++i) for (int j = 0; j < 3000; ++j) ar[i][j] = -1; cin >> n; v.resize(n); for (int i = 0; i < n; ++i) cin >> v[i]; cout.precision(10); cout << fixed << req(); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
979,107
979,108
u330326085
cpp
p03168
// -_- #include <bits/stdc++.h> #define int long long #define read(a) \ int a; \ cin >> a; #define readarr(a, n) \ int a[(n) + 1] = {}; \ fori(i, 1, (n)) { cin >> a[i]; } #define readmat(a, n, m) \ int a[n + 1][m + 1] = {}; \ fori(i, 1, n) { fori(j, 1, m) cin >> a[i][j]; } #define pb push_back #define fi first #define se second #define rz resize #define fori(i, a, b) for (int i = a; i <= b; i++) #define ford(i, a, b) for (int i = a; i >= b; i--) #define mod 1000000007 #define sort1(v) sort(v.begin(), v.end()) using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int>> vpi; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); read(n); double p[n + 1]; fori(i, 1, n) cin >> p[i]; double dp[n + 1][n + 1]; dp[1][0] = 1 - p[1]; dp[1][1] = p[1]; fori(i, 2, n) { fori(j, 0, i) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1 - p[i]); else if (j == i) dp[i][j] = dp[i - 1][i - 1] * p[i]; else dp[i][j] = (dp[i - 1][j] * (1 - p[i])) + (dp[i - 1][j - 1] * p[i]); } } double ans = 0; fori(i, (n + 1) / 2, n) ans += dp[n][i]; cout << ans; return 0; }
// -_- #include <bits/stdc++.h> #define int long long #define read(a) \ int a; \ cin >> a; #define readarr(a, n) \ int a[(n) + 1] = {}; \ fori(i, 1, (n)) { cin >> a[i]; } #define readmat(a, n, m) \ int a[n + 1][m + 1] = {}; \ fori(i, 1, n) { fori(j, 1, m) cin >> a[i][j]; } #define pb push_back #define fi first #define se second #define rz resize #define fori(i, a, b) for (int i = a; i <= b; i++) #define ford(i, a, b) for (int i = a; i >= b; i--) #define mod 1000000007 #define sort1(v) sort(v.begin(), v.end()) using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int>> vpi; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); read(n); double p[n + 1]; fori(i, 1, n) cin >> p[i]; double dp[n + 1][n + 1]; dp[1][0] = 1 - p[1]; dp[1][1] = p[1]; fori(i, 2, n) { fori(j, 0, i) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1 - p[i]); else if (j == i) dp[i][j] = dp[i - 1][i - 1] * p[i]; else dp[i][j] = (dp[i - 1][j] * (1 - p[i])) + (dp[i - 1][j - 1] * p[i]); } } double ans = 0; fori(i, (n + 1) / 2, n) ans += dp[n][i]; cout << setprecision(10) << ans; return 0; }
[ "io.output.change" ]
979,115
979,116
u706567482
cpp
p03168
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ff first #define ss second int main() { ios::sync_with_stdio(0); int N; cin >> N; long double coins[N + 1]; for (int i = 1; i < N + 1; i++) { cin >> coins[i]; } long double probability[N + 1][N + 1]; for (int i = 0; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { probability[i][j] = 0; } } probability[0][0] = 1; for (int i = 1; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { if (j == 0) { probability[i][j] = probability[i - 1][j] * (1 - coins[i]); } else { probability[i][j] = probability[i - 1][j] * (1 - coins[i]); probability[i][j] += probability[i - 1][j - 1] * coins[i]; } } } long double answer = 0; for (int i = (N + 1) / 2; i < N + 1; i++) { answer += probability[N][i]; } cout << answer << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ff first #define ss second int main() { ios::sync_with_stdio(0); int N; cin >> N; long double coins[N + 1]; for (int i = 1; i < N + 1; i++) { cin >> coins[i]; } long double probability[N + 1][N + 1]; for (int i = 0; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { probability[i][j] = 0; } } probability[0][0] = 1; for (int i = 1; i < N + 1; i++) { for (int j = 0; j < N + 1; j++) { if (j == 0) { probability[i][j] = probability[i - 1][j] * (1 - coins[i]); } else { probability[i][j] = probability[i - 1][j] * (1 - coins[i]); probability[i][j] += probability[i - 1][j - 1] * coins[i]; } } } long double answer = 0; for (int i = (N + 1) / 2; i < N + 1; i++) { answer += probability[N][i]; } cout << setprecision(10) << answer << endl; return 0; }
[ "io.output.change" ]
979,117
979,118
u489235481
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define inf (pow(10, 18)) #define ll long long int #define mod 1000000007 #define ntq(z) \ long long int z; \ cin >> z; \ for (long long int i = 0; i < z; i++) #define fi(x9, y9) for (long long int i = x9; i < y9; i++) #define fj(x9, y9) for (long long int j = x9; j < y9; j++) #define fk(x9, y9) for (long long int k = x9; k < y9; k++) #define f(z9) for (long long int i = 0; i < z9; i++) #define endl "\n" #define sz(a) int((a).size()) #define pb push_back #define all(c) (c).begin(), (c).end() #define tr(c, i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) #define present(c, x) ((c).find(x) != (c).end()) #define cpresent(c, x) (find(all(c), x) != (c).end()) #define stoi(s, n) \ stringstream str(s); \ str >> n; #define get_vi(v, n) \ vi v(n); \ f(n) { cin >> v[i]; } typedef vector<ll> vi; typedef vector<pair<ll, ll>> vp; typedef vector<vi> vvi; typedef pair<ll, ll> ii; void printprecise(double l, ll precision) { std::cout << std::fixed; std::cout << std::setprecision(precision); std::cout << l; } ll ncr(ll n, ll k) { ll C[n + 1][k + 1]; ll i, j; for (i = 0; i <= n; i++) { for (j = 0; j <= min(i, k); j++) { if (j == 0 || j == i) C[i][j] = 1; else C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; } } return C[n][k]; } ll power_wm(ll x, ll y, ll p) { ll res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x) % p; // y must be even now y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } ll power(ll x, ll y) { ll res = 1; // Initialize result while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x); // y must be even now y = y >> 1; // y = y/2 x = (x * x); } return res; } ll root(ll x, vi &roots) { if (roots[x] != x) roots[x] = root(roots[x], roots); return roots[x]; } void unoin(ll p, ll q, vi &roots, vi &rank) { ll rp = root(p, roots); ll rq = root(q, roots); if (rank[rq] < rank[rp]) { roots[rq] = rp; } else if (rank[rp] > rank[rq]) { roots[rp] = rq; } else { roots[rp] = rq; rank[rq]++; } } ll dig_sum(ll n) { ll s = 0; while (n) { s += n % 10; n /= 10; } return s; } ll gcd(ll a, ll b) { if (a < b) { a = a + b; b = a - b; a = a - b; } if (b == 0) return a; return gcd(b, a % b); } ll toD(ll x, ll y, ll m) { return x * m + y % m; } pair<ll, ll> twoD(ll p, ll m) { return (make_pair(p / m, p % m)); } vi dist; vvi g; void dfs(ll p) { if (dist[p] != -1) { return; } dist[p] = 0; ll maxd = -1; f(g[p].size()) { dfs(g[p][i]); maxd = max(maxd, dist[g[p][i]]); } dist[p] = maxd + 1; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<double> p(n + 1); fi(1, n + 1) { cin >> p[i]; } vector<vector<double>> dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1; fi(1, n + 1) { fj(0, i + 1) { dp[i][j] = (1 - p[i]) * dp[i - 1][j]; if (j > 0) { dp[i][j] += p[i] * dp[i - 1][j - 1]; } } } double ans = 0; fi((n + 1) / 2, n + 1) { ans += dp[n][i]; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; #define inf (pow(10, 18)) #define ll long long int #define mod 1000000007 #define ntq(z) \ long long int z; \ cin >> z; \ for (long long int i = 0; i < z; i++) #define fi(x9, y9) for (long long int i = x9; i < y9; i++) #define fj(x9, y9) for (long long int j = x9; j < y9; j++) #define fk(x9, y9) for (long long int k = x9; k < y9; k++) #define f(z9) for (long long int i = 0; i < z9; i++) #define endl "\n" #define sz(a) int((a).size()) #define pb push_back #define all(c) (c).begin(), (c).end() #define tr(c, i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) #define present(c, x) ((c).find(x) != (c).end()) #define cpresent(c, x) (find(all(c), x) != (c).end()) #define stoi(s, n) \ stringstream str(s); \ str >> n; #define get_vi(v, n) \ vi v(n); \ f(n) { cin >> v[i]; } typedef vector<ll> vi; typedef vector<pair<ll, ll>> vp; typedef vector<vi> vvi; typedef pair<ll, ll> ii; void printprecise(double l, ll precision) { std::cout << std::fixed; std::cout << std::setprecision(precision); std::cout << l; } ll ncr(ll n, ll k) { ll C[n + 1][k + 1]; ll i, j; for (i = 0; i <= n; i++) { for (j = 0; j <= min(i, k); j++) { if (j == 0 || j == i) C[i][j] = 1; else C[i][j] = C[i - 1][j - 1] + C[i - 1][j]; } } return C[n][k]; } ll power_wm(ll x, ll y, ll p) { ll res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x) % p; // y must be even now y = y >> 1; // y = y/2 x = (x * x) % p; } return res; } ll power(ll x, ll y) { ll res = 1; // Initialize result while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res * x); // y must be even now y = y >> 1; // y = y/2 x = (x * x); } return res; } ll root(ll x, vi &roots) { if (roots[x] != x) roots[x] = root(roots[x], roots); return roots[x]; } void unoin(ll p, ll q, vi &roots, vi &rank) { ll rp = root(p, roots); ll rq = root(q, roots); if (rank[rq] < rank[rp]) { roots[rq] = rp; } else if (rank[rp] > rank[rq]) { roots[rp] = rq; } else { roots[rp] = rq; rank[rq]++; } } ll dig_sum(ll n) { ll s = 0; while (n) { s += n % 10; n /= 10; } return s; } ll gcd(ll a, ll b) { if (a < b) { a = a + b; b = a - b; a = a - b; } if (b == 0) return a; return gcd(b, a % b); } ll toD(ll x, ll y, ll m) { return x * m + y % m; } pair<ll, ll> twoD(ll p, ll m) { return (make_pair(p / m, p % m)); } vi dist; vvi g; void dfs(ll p) { if (dist[p] != -1) { return; } dist[p] = 0; ll maxd = -1; f(g[p].size()) { dfs(g[p][i]); maxd = max(maxd, dist[g[p][i]]); } dist[p] = maxd + 1; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<double> p(n + 1); fi(1, n + 1) { cin >> p[i]; } vector<vector<double>> dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1; fi(1, n + 1) { fj(0, i + 1) { dp[i][j] = (1 - p[i]) * dp[i - 1][j]; if (j > 0) { dp[i][j] += p[i] * dp[i - 1][j - 1]; } } } double ans = 0; fi((n + 1) / 2, n + 1) { ans += dp[n][i]; } printprecise(ans, 10); return 0; }
[ "call.arguments.add" ]
979,119
979,120
u319172750
cpp
p03168
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long #define MX 3005 using namespace std; int main() { int N; long double p[MX]; long double d[2][MX], ans; cin >> N; rep(i, N) cin >> p[i]; d[0][0] = 1; rep(i, N) d[0][i + 1] = 0; for (int i = 1; i < N + 1; i++) { d[i % 2][0] = (1 - p[N - i]) * d[(i - 1) % 2][0]; for (int j = 1; j < N + 1; j++) { d[i % 2][j] = p[N - i] * d[(i - 1) % 2][j - 1] + (1 - p[N - i]) * d[(i - 1) % 2][j]; } } ans = 0; for (int i = (N + 1) / 2; i <= N; i++) { ans += d[N % 2][i]; // cout<<d[N%2][i]<<endl; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long #define MX 3005 using namespace std; int main() { int N; long double p[MX]; long double d[2][MX], ans; cin >> N; rep(i, N) cin >> p[i]; d[0][0] = 1; rep(i, N) d[0][i + 1] = 0; for (int i = 1; i < N + 1; i++) { d[i % 2][0] = (1 - p[N - i]) * d[(i - 1) % 2][0]; for (int j = 1; j < N + 1; j++) { d[i % 2][j] = p[N - i] * d[(i - 1) % 2][j - 1] + (1 - p[N - i]) * d[(i - 1) % 2][j]; } } ans = 0; for (int i = (N + 1) / 2; i <= N; i++) { ans += d[N % 2][i]; // cout<<d[N%2][i]<<endl; } cout << setprecision(10) << ans << endl; return 0; }
[ "io.output.change" ]
979,121
979,122
u445015174
cpp
p03168
#include <assert.h> #include <bits/stdc++.h> #define int long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define F first #define S second #define sz(x) (int)x.size() #define endl '\n' #define hell 1000000007 #define mem(x) memset(x, 0, sizeof(x)); #define what_is(x) cout << #x << " is " << x << flush << endl; #define rep(i, a, b) for (int i = a; i < b; i++) using namespace std; const int maxn = 200010; int n; long double x, dp[maxn]; void solve() { cin >> n; dp[0] = 1; rep(coins, 0, n) { cin >> x; for (int i = coins + 1; i >= 0; i--) dp[i] = (i == 0 ? 0 : x * dp[i - 1]) + (1 - x) * dp[i]; } long double ans = 0; rep(heads, 1, n + 1) { int tails = n - heads; if (heads > tails) ans += dp[heads]; } cout << ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; while (t--) solve(); return 0; }
#include <assert.h> #include <bits/stdc++.h> #define int long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define F first #define S second #define sz(x) (int)x.size() #define endl '\n' #define hell 1000000007 #define mem(x) memset(x, 0, sizeof(x)); #define what_is(x) cout << #x << " is " << x << flush << endl; #define rep(i, a, b) for (int i = a; i < b; i++) using namespace std; const int maxn = 200010; int n; long double x, dp[maxn]; void solve() { cin >> n; dp[0] = 1; rep(coins, 0, n) { cin >> x; for (int i = coins + 1; i >= 0; i--) dp[i] = (i == 0 ? 0 : x * dp[i - 1]) + (1 - x) * dp[i]; } long double ans = 0; rep(heads, 1, n + 1) { int tails = n - heads; if (heads > tails) ans += dp[heads]; } cout << setprecision(10) << ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin>>t; while (t--) solve(); return 0; }
[ "io.output.change" ]
979,123
979,124
u722378116
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { double prob[n + 5]; for (int i = 1; i <= n; ++i) cin >> prob[i]; double dp[n + 5][n + 5]; memset(dp, 0, sizeof(dp)); dp[1][0] = prob[1]; dp[1][1] = 1 - prob[1]; for (int i = 1; i < n; ++i) { for (int j = 0; j <= i; ++j) { dp[i + 1][j] += dp[i][j] * prob[i]; dp[i + 1][j + 1] += dp[i][j] * (1 - prob[i]); } } // for (int i = 1; i <= n; ++i) { // for (int j = 0; j <= i; ++j) { // printf(" %2.3lf", dp[i][j] ); // } // printf("\n"); // } double ans = 0; for (int i = 0; i <= n / 2; ++i) ans += dp[n][i]; printf("%.10lf\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { double prob[n + 5]; for (int i = 1; i <= n; ++i) cin >> prob[i]; double dp[n + 5][n + 5]; memset(dp, 0, sizeof(dp)); dp[1][0] = prob[1]; dp[1][1] = 1 - prob[1]; for (int i = 1; i < n; ++i) { for (int j = 0; j <= i; ++j) { dp[i + 1][j] += dp[i][j] * prob[i + 1]; dp[i + 1][j + 1] += dp[i][j] * (1 - prob[i + 1]); // printf(" %.5lf", dp[i][j] ); } // cout << '\n'; } // for (int i = 1; i <= n; ++i) { // for (int j = 0; j <= i; ++j) { // printf(" %2.3lf", dp[i][j] ); // } // printf("\n"); // } double ans = 0; for (int i = 0; i <= n / 2; ++i) ans += dp[n][i]; // for (int i = 0; i <= n; ++i) printf(" %.5lf", dp[n][i] ); cout << //'\n'; printf("%.10lf\n", ans); } return 0; }
[ "assignment.change" ]
979,132
979,133
u516708338
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { double prob[n + 5]; for (int i = 1; i <= n; ++i) cin >> prob[i]; double dp[n + 5][n + 5]; memset(dp, 0, sizeof(dp)); dp[1][0] = prob[1]; dp[1][1] = 1 - prob[1]; for (int i = 1; i < n; ++i) { for (int j = 0; j <= i; ++j) { dp[i + 1][j] += dp[i][j] * prob[i]; dp[i + 1][j + 1] += dp[i][j] * (1 - prob[i]); } } // for (int i = 1; i <= n; ++i) { // for (int j = 0; j <= i; ++j) { // printf(" %2.3lf", dp[i][j] ); // } // printf("\n"); // } double ans = 0; for (int i = 0; i <= n / 2; ++i) ans += dp[n][i]; printf("%.10lf\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { double prob[n + 5]; for (int i = 1; i <= n; ++i) cin >> prob[i]; double dp[n + 5][n + 5]; memset(dp, 0, sizeof(dp)); dp[1][0] = prob[1]; dp[1][1] = 1 - prob[1]; for (int i = 1; i < n; ++i) { for (int j = 0; j <= i; ++j) { dp[i + 1][j] += dp[i][j] * prob[i + 1]; dp[i + 1][j + 1] += dp[i][j] * (1 - prob[i + 1]); // printf(" %.5lf", dp[i][j] ); } // cout << '\n'; } // for (int i = 1; i <= n; ++i) { // for (int j = 0; j <= i; ++j) { // printf(" %2.3lf", dp[i][j] ); // } // printf("\n"); // } double ans = 0; for (int i = 0; i <= n / 2; ++i) ans += dp[n][i]; // for (int i = 0; i <= n; ++i) printf(" %.5lf", dp[n][i] ); cout << //'\n'; printf("%.10lf\n", ans); } return 0; }
[ "assignment.change" ]
979,132
979,134
u516708338
cpp
p03168
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse2") /* |||||||||||||||||||||||||||||||||||||||||||||||| | ||| | |||| |||| | | | | | | | | | | | | | | | | | | | | | | | | ||||||| | | ||||||| ||| ||| ||||| | | | | | | | | | | | | | ||| | | | || |||| | | |||||||||||||||||||||||||||||||||||||||||||||||| */ using namespace std; //#include "testlib.h" #define ff first #define ss second #define mp make_pair #define all(v) v.begin(), v.end() #define int long long #define ll long long #define M 1000000007 #define inputarr(a, n) \ for (int i = 0; i < n; ++i) \ cin >> a[i] #define GCD(m, n) __gcd(m, n) #define LCM(m, n) m *(n / GCD(m, n)) #define mii map<ll, ll> #define msi map<string, ll> #define mis map<ll int, string> #define rep(a, b) for (ll i = a; i < b; i++) #define rep0(n) for (ll i = 0; i < n; i++) #define repi(i, a, b) for (ll i = a; i < b; i++) #define pb push_back #define vi vector<ll> #define mp make_pair #define vs vector<string> #define ppb pop_back #define endl '\n' #define asdf \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define r0 return 0; #define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); --i) #define FORE(it, c) \ for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) #define inputoutput \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define input freopen("input.txt", "r", stdin); #define Set(a, s) 4(a, s, sizeof(a)) #define FOR repi #define pii pair<int, int> #define REVERSE(v) reverse(ALL(v)) #define display(x) \ trav(a, x) cout << a << " "; \ cout << endl #define debug cerr << "bhau" << endl #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { std::cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); std::cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } //#define float long double ll max(ll a, ll b) { return (a > b) ? a : b; } int min(int a, int b) { return (a < b) ? a : b; } #define float double int solve() { int n; cin >> n; vector<float> p(n); inputarr(p, n); float dp[n + 1][n + 1]; dp[0][0] = 1; rep(1, n + 1) { dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]); repi(j, 1, n + 1) { if (j > i) { dp[i][j] = 0; continue; } dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]); dp[i][j] += dp[i - 1][j - 1] * p[i - 1]; } } // rep0(n+1){repi(j,0,n+1) cout<<dp[j][i]<<" ";cout<<endl;} int mi = n / 2; float ans = 0; for (int i = mi + 1; i <= n; i++) // cout<<dp[n][i]<<" ";// ans += dp[n][i]; cout << fixed << setprecision(10) << ans; r0 } signed main() { asdf inputoutput int t = 1; // cin>>t; while (t--) { solve(); } }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse2") /* |||||||||||||||||||||||||||||||||||||||||||||||| | ||| | |||| |||| | | | | | | | | | | | | | | | | | | | | | | | | ||||||| | | ||||||| ||| ||| ||||| | | | | | | | | | | | | | ||| | | | || |||| | | |||||||||||||||||||||||||||||||||||||||||||||||| */ using namespace std; //#include "testlib.h" #define ff first #define ss second #define mp make_pair #define all(v) v.begin(), v.end() #define int long long #define ll long long #define M 1000000007 #define inputarr(a, n) \ for (int i = 0; i < n; ++i) \ cin >> a[i] #define GCD(m, n) __gcd(m, n) #define LCM(m, n) m *(n / GCD(m, n)) #define mii map<ll, ll> #define msi map<string, ll> #define mis map<ll int, string> #define rep(a, b) for (ll i = a; i < b; i++) #define rep0(n) for (ll i = 0; i < n; i++) #define repi(i, a, b) for (ll i = a; i < b; i++) #define pb push_back #define vi vector<ll> #define mp make_pair #define vs vector<string> #define ppb pop_back #define endl '\n' #define asdf \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define r0 return 0; #define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); --i) #define FORE(it, c) \ for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) #define inputoutput \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define input freopen("input.txt", "r", stdin); #define Set(a, s) 4(a, s, sizeof(a)) #define FOR repi #define pii pair<int, int> #define REVERSE(v) reverse(ALL(v)) #define display(x) \ trav(a, x) cout << a << " "; \ cout << endl #define debug cerr << "bhau" << endl #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { std::cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); std::cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } //#define float long double ll max(ll a, ll b) { return (a > b) ? a : b; } int min(int a, int b) { return (a < b) ? a : b; } #define float double int solve() { int n; cin >> n; vector<float> p(n); inputarr(p, n); float dp[n + 1][n + 1]; dp[0][0] = 1; rep(1, n + 1) { dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]); repi(j, 1, n + 1) { if (j > i) { dp[i][j] = 0; continue; } dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]); dp[i][j] += dp[i - 1][j - 1] * p[i - 1]; } } // rep0(n+1){repi(j,0,n+1) cout<<dp[j][i]<<" ";cout<<endl;} int mi = n / 2; float ans = 0; for (int i = mi + 1; i <= n; i++) // cout<<dp[n][i]<<" ";// ans += dp[n][i]; cout << fixed << setprecision(10) << ans; r0 } signed main() { asdf // inputoutput int t = 1; // cin>>t; while (t--) { solve(); } }
[]
979,137
979,138
u980932400
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { int n, m; cin >> n; double a[n + 1]; for (int i = 0; i < n; i++) cin >> a[i + 1]; double dp[n + 1][n + 1]; memset(dp, 0, sizeof(dp)); dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = dp[i - 1][j] * (1.0 - a[i]); if (j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1] * a[i]; } } double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i]; cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { int n, m; cin >> n; double a[n + 1]; for (int i = 0; i < n; i++) cin >> a[i + 1]; double dp[n + 1][n + 1]; memset(dp, 0, sizeof(dp)); dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = dp[i - 1][j] * (1.0 - a[i]); if (j - 1 >= 0) dp[i][j] += dp[i - 1][j - 1] * a[i]; } } double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i]; cout << setprecision(12) << ans << endl; } return 0; }
[ "io.output.change" ]
979,146
979,147
u306083047
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double p[n + 1]; for (int i = 1; i <= n; i++) cin >> p[i]; double dp[n + 1][n + 1]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i][0] = dp[i - 1][0] * (1 - p[i]); dp[0][i] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } double ans = 0; // for (int i=0;i<=n;i++){ // for (int j=0;j<=n;j++){ // cout<<dp[i][j]<<" "; // } // cout<<"\n"; // } for (int i = n; i > (n / 2); i--) { ans += dp[n][i]; } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double p[n + 1]; for (int i = 1; i <= n; i++) cin >> p[i]; double dp[n + 1][n + 1]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i][0] = dp[i - 1][0] * (1 - p[i]); dp[0][i] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } double ans = 0; // for (int i=0;i<=n;i++){ // for (int j=0;j<=n;j++){ // cout<<dp[i][j]<<" "; // } // cout<<"\n"; // } for (int i = n; i > (n / 2); i--) { ans += dp[n][i]; } cout << setprecision(11) << ans; }
[ "io.output.change" ]
979,148
979,149
u547420959
cpp
p03168
// https://atcoder.jp/contests/dp/tasks/dp_h #include <algorithm> #include <array> #include <iomanip> #include <iostream> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main(int argc, char *argv[]) { long long n; cin >> n; vector<double> dp(n + 1); dp[0] = 1.0; for (long long i = 0; i < n; i++) { double p; cin >> p; for (long long j = n; j >= 1; j--) { dp[j] += dp[j - 1] * p; dp[j - 1] *= 1.0 - p; } } double prob = 0.0; for (long long i = (n + 1) / 2; i < n + 1; i++) { prob += dp[i]; } cout << prob << endl; }
// https://atcoder.jp/contests/dp/tasks/dp_h #include <algorithm> #include <array> #include <iomanip> #include <iostream> #include <queue> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main(int argc, char *argv[]) { long long n; cin >> n; vector<double> dp(n + 1); dp[0] = 1.0; for (long long i = 0; i < n; i++) { double p; cin >> p; for (long long j = n; j >= 1; j--) { dp[j] += dp[j - 1] * p; dp[j - 1] *= 1.0 - p; } } double prob = 0.0; for (long long i = (n + 1) / 2; i < n + 1; i++) { prob += dp[i]; } cout << setprecision(10) << prob << endl; }
[ "io.output.change" ]
979,152
979,153
u184819501
cpp
p03168
#include <algorithm> #include <assert.h> #include <climits> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, s, n) for (int i = s, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; template <typename T> T gcd(T a, T b) { if (a < b) gcd(b, a); if (b == 1) return 1; T r; while ((r = a % b)) { a = b; b = r; } return b; } #define MOD (1'000'000'000 + 7) bool _less(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } double dp[3000][3000]; int main() { int N; cin >> N; vector<double> p(N); REP(i, 1, N + 1) { cin >> p[i]; } dp[0][0] = 1.0; REP(i, 1, N + 1) { dp[i][0] = dp[i - 1][0] * (1 - p[i]); REP(j, 1, i + 1) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } double sum = 0.0; REP(i, N / 2 + 1, N + 1) { sum += dp[N][i]; } cout << setprecision(10) << sum << endl; }
#include <algorithm> #include <assert.h> #include <climits> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define REP(i, s, n) for (int i = s, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; template <typename T> T gcd(T a, T b) { if (a < b) gcd(b, a); if (b == 1) return 1; T r; while ((r = a % b)) { a = b; b = r; } return b; } #define MOD (1'000'000'000 + 7) bool _less(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } double dp[3000][3000]; int main() { int N; cin >> N; vector<double> p(N + 1); REP(i, 1, N + 1) { cin >> p[i]; } dp[0][0] = 1.0; REP(i, 1, N + 1) { dp[i][0] = dp[i - 1][0] * (1 - p[i]); REP(j, 1, i + 1) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } double sum = 0.0; REP(i, N / 2 + 1, N + 1) { sum += dp[N][i]; } cout << setprecision(10) << sum << endl; }
[ "assignment.change" ]
979,158
979,159
u535347736
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double prob[n + 1]; prob[0] = 0.0; for (int i = 1; i <= n; i++) cin >> prob[i]; double dp[n + 1][n + 1]; memset(dp, 0.0, sizeof(dp)); dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - prob[i]); else dp[i][j] = dp[i - 1][j - 1] * prob[i] + dp[i - 1][j] * (1.0 - prob[i]); } } double ans = 0.0; for (int i = (n) / 2 + 1; i <= n; i++) { ans += dp[n][i]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double prob[n + 1]; prob[0] = 0.0; for (int i = 1; i <= n; i++) cin >> prob[i]; double dp[n + 1][n + 1]; memset(dp, 0.0, sizeof(dp)); dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - prob[i]); else dp[i][j] = dp[i - 1][j - 1] * prob[i] + dp[i - 1][j] * (1.0 - prob[i]); } } double ans = 0.0; for (int i = (n) / 2 + 1; i <= n; i++) { ans += dp[n][i]; } cout << setprecision(10) << ans << endl; }
[ "io.output.change" ]
979,171
979,172
u369697879
cpp
p03168
// length of the longest path in a directed acyclic graph #include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e9 + 5; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /* #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif*/ // dp[i][j] = probability of having j heads with i coins int n; cin >> n; vector<double> p(n + 1, 0); for (int i = 1; i <= n; i++) cin >> p[i]; double dp[n + 1][n + 1]; memset(dp, 0.0, sizeof(dp)); dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j) dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); else dp[i][j] = dp[i - 1][j] * (1 - p[i]); } } double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i]; cout << ans; }
// length of the longest path in a directed acyclic graph #include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e9 + 5; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif*/ // dp[i][j] = probability of having j heads with i coins int n; cin >> n; vector<double> p(n + 1, 0); for (int i = 1; i <= n; i++) cin >> p[i]; double dp[n + 1][n + 1]; memset(dp, 0.0, sizeof(dp)); dp[0][0] = 1.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j) dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); else dp[i][j] = dp[i - 1][j] * (1 - p[i]); } } double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i]; cout << setprecision(10) << ans; }
[ "io.output.change" ]
979,175
979,176
u319343724
cpp
p03168
// Program.cpp // Author : Aaryan Srivastava #include <bits/stdc++.h> #include <chrono> #include <random> #define pb push_back #define popb pop_back #define ull unsigned long long #define beg begin #define mp make_pair #define pii pair<int, int> #define piii pair<pii, int> #define rep(i, n) for (int(i) = 0; i < (n); i++) #define repA(i, x, y) for (int i = (x); i <= (y); i++) #define repD(i, x, y) for (int i = (x); i >= (y); i--) #define all(c) (c).begin(), (c).end() #define ff first #define ss second #define fill(a, val) memset(a, val, sizeof(a)) #define Randomize \ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) using ll = long long; #define int ll const int N = 1e5 + 5; const int mod = 1e9 + 7; const int inf = 1e18; const int SZ = 101; const double eps = 1e-9; using namespace std; #ifdef AaryanS #define mycout cout #define mycerr cerr #endif #ifndef AaryanS #define mycout \ if (false) \ cout #define mycerr \ if (false) \ cerr #define AaryanS 0 #endif template <typename T> void max_self(T &a, T b) { a = max(a, b); } #define debug(x) mycerr << #x << " " << x << endl; void solve() { int n; cin >> n; std::vector<double> p(n + 1); repA(i, 1, n) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0)); dp[1][1] = p[1]; dp[1][0] = (1 - p[1]); repA(coins_tossed, 1, n) { repA(num_heads, 0, coins_tossed) { if (coins_tossed == 1) { cout << dp[coins_tossed][num_heads] << " "; continue; } dp[coins_tossed][num_heads] = (1 - p[coins_tossed]) * dp[coins_tossed - 1][num_heads]; if (num_heads) dp[coins_tossed][num_heads] += p[coins_tossed] * dp[coins_tossed - 1][num_heads - 1]; cout << dp[coins_tossed][num_heads] << " "; } cout << endl; } double ans = 0.0; repA(i, (n + 1) / 2, n) { ans += dp[n][i]; } cout << std::fixed << setprecision(10) << ans; } int32_t main(int32_t argc, char *argv[]) { double t1 = clock(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int TC = 1, tt = 0; // cin >> TC ; while (tt++ < TC) { // cout << "Case " << t << ":\n" ; solve(); } mycerr << "Time : " << 1000 * (clock() - t1) / CLOCKS_PER_SEC << " ms\n"; return 0; }
// Program.cpp // Author : Aaryan Srivastava #include <bits/stdc++.h> #include <chrono> #include <random> #define pb push_back #define popb pop_back #define ull unsigned long long #define beg begin #define mp make_pair #define pii pair<int, int> #define piii pair<pii, int> #define rep(i, n) for (int(i) = 0; i < (n); i++) #define repA(i, x, y) for (int i = (x); i <= (y); i++) #define repD(i, x, y) for (int i = (x); i >= (y); i--) #define all(c) (c).begin(), (c).end() #define ff first #define ss second #define fill(a, val) memset(a, val, sizeof(a)) #define Randomize \ mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) using ll = long long; #define int ll const int N = 1e5 + 5; const int mod = 1e9 + 7; const int inf = 1e18; const int SZ = 101; const double eps = 1e-9; using namespace std; #ifdef AaryanS #define mycout cout #define mycerr cerr #endif #ifndef AaryanS #define mycout \ if (false) \ cout #define mycerr \ if (false) \ cerr #define AaryanS 0 #endif template <typename T> void max_self(T &a, T b) { a = max(a, b); } #define debug(x) mycerr << #x << " " << x << endl; void solve() { int n; cin >> n; std::vector<double> p(n + 1); repA(i, 1, n) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0)); dp[1][1] = p[1]; dp[1][0] = (1 - p[1]); repA(coins_tossed, 1, n) { repA(num_heads, 0, coins_tossed) { if (coins_tossed == 1) { mycout << dp[coins_tossed][num_heads] << " "; continue; } dp[coins_tossed][num_heads] = (1 - p[coins_tossed]) * dp[coins_tossed - 1][num_heads]; if (num_heads) dp[coins_tossed][num_heads] += p[coins_tossed] * dp[coins_tossed - 1][num_heads - 1]; mycout << dp[coins_tossed][num_heads] << " "; } mycout << endl; } double ans = 0.0; repA(i, (n + 1) / 2, n) { ans += dp[n][i]; } cout << std::fixed << setprecision(15) << ans; } int32_t main(int32_t argc, char *argv[]) { double t1 = clock(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int TC = 1, tt = 0; // cin >> TC ; while (tt++ < TC) { // cout << "Case " << t << ":\n" ; solve(); } mycerr << "Time : " << 1000 * (clock() - t1) / CLOCKS_PER_SEC << " ms\n"; return 0; }
[ "identifier.change", "expression.operation.binary.change", "literal.number.change", "io.output.change" ]
979,185
979,186
u774189121
cpp
p03168
#include <iomanip> #include <iostream> using namespace std; double dp[1500][3000]; double prob[2999]; int main() { long long n; cin >> n; for (int i = 0; i < n; i++) { cin >> prob[i]; } dp[0][0] = 1 - prob[0]; dp[0][1] = prob[0]; for (int i = 0; i < (n + 1) / 2; i++) { // cout<<i<<endl; for (int j = 0; j <= i * 2; j++) { dp[i + 1][j + 2] += (dp[i][j] * prob[i * 2 + 1] * prob[i * 2 + 2]); dp[i + 1][j + 1] += (dp[i][j] * prob[i * 2 + 1] * (1 - prob[i * 2 + 2]) + dp[i][j] * (1 - prob[i * 2 + 1]) * prob[i * 2 + 2]); dp[i + 1][j] += (dp[i][j] * (1 - prob[i * 2 + 1]) * (1 - prob[i * 2 + 2])); } } double ans = 0; for (int j = (n + 1) / 2; j <= n; j++) { // cout<<dp[(n+1)/2-1][j]<<" "<<j<<endl; ans += dp[(n + 1) / 2 - 1][j]; } cout << setprecision(9) << ans << endl; }
#include <iomanip> #include <iostream> using namespace std; double dp[1500][3000]; double prob[2999]; int main() { long long n; cin >> n; for (int i = 0; i < n; i++) { cin >> prob[i]; } dp[0][0] = 1 - prob[0]; dp[0][1] = prob[0]; for (int i = 0; i < (n + 1) / 2 - 1; i++) { // cout<<i<<endl; for (int j = 0; j <= i * 2 + 1; j++) { dp[i + 1][j + 2] += (dp[i][j] * prob[i * 2 + 1] * prob[i * 2 + 2]); dp[i + 1][j + 1] += (dp[i][j] * prob[i * 2 + 1] * (1 - prob[i * 2 + 2]) + dp[i][j] * (1 - prob[i * 2 + 1]) * prob[i * 2 + 2]); dp[i + 1][j] += (dp[i][j] * (1 - prob[i * 2 + 1]) * (1 - prob[i * 2 + 2])); } } double ans = 0; for (int j = (n + 1) / 2; j <= n; j++) { // cout<<dp[(n+1)/2-1][j]<<" "<<j<<endl; ans += dp[(n + 1) / 2 - 1][j]; } cout << setprecision(9) << ans << endl; }
[ "control_flow.loop.for.condition.change", "misc.off_by_one" ]
979,187
979,188
u132035173
cpp
p03168
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) 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; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 #define BIT_FLAG_0 (1 << 0) // 0000 0000 0000 0001 #define BIT_FLAG_1 (1 << 1) // 0000 0000 0000 0010 #define BIT_FLAG_2 (1 << 2) // 0000 0000 0000 0100 #define BIT_FLAG_3 (1 << 3) // 0000 0000 0000 1000 #define BIT_FLAG_4 (1 << 4) // 0000 0000 0001 0000 #define BIT_FLAG_5 (1 << 5) // 0000 0000 0010 0000 #define BIT_FLAG_6 (1 << 6) // 0000 0000 0100 0000 #define BIT_FLAG_7 (1 << 7) // 0000 0000 1000 0000 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INTINF = 1 << 30; const int MAX = 510000; 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[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll n) : par(n, -1) {} void init(ll n) { par.assign(n, -1); } ll root(ll x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(ll x, ll y) { return root(x) == root(y); } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } ll size(ll x) { return -par[root(x)]; } }; template <typename T> vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) { const T INF = numeric_limits<T>::max(); using P = pair<T, int>; int n = G.size(); vector<T> d(n, INF); vector<int> b(n, -1); priority_queue<P, vector<P>, greater<P>> q; d[s] = 0; q.emplace(d[s], s); while (!q.empty()) { P p = q.top(); q.pop(); int v = p.second; if (d[v] < p.first) continue; for (auto &e : G[v]) { int u = e.first; T c = e.second; if (d[u] > d[v] + c) { d[u] = d[v] + c; b[u] = v; q.emplace(d[u], u); } } } return d; } int64_t power(int64_t x, int64_t n, int64_t mod) { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } vector<int> sieve_of_eratosthenes(int n) { vector<int> primes(n); for (int i = 2; i < n; ++i) primes[i] = i; for (int i = 2; i * i < n; ++i) if (primes[i]) for (int j = i * i; j < n; j += i) primes[j] = 0; return primes; } struct Dice { int s[6]; int &top() { return s[0]; } int &south() { return s[1]; } int &east() { return s[2]; } int &west() { return s[3]; } int &north() { return s[4]; } int &bottom() { return s[5]; } void roll(char c) { // the view from above // N // W E // S string b("EWNSRL"); int v[6][4] = {{0, 3, 5, 2}, {0, 2, 5, 3}, {0, 1, 5, 4}, {0, 4, 5, 1}, {1, 2, 4, 3}, {1, 3, 4, 2}}; for (int k = 0; k < 6; k++) { if (b[k] != c) continue; int t = s[v[k][0]]; s[v[k][0]] = s[v[k][1]]; s[v[k][1]] = s[v[k][2]]; s[v[k][2]] = s[v[k][3]]; s[v[k][3]] = t; } } using ll = long long; ll hash() { ll res = 0; for (int i = 0; i < 6; i++) res = res * 256 + s[i]; return res; } bool operator==(const Dice &d) const { for (int i = 0; i < 6; i++) if (s[i] != d.s[i]) return 0; return 1; } }; vector<Dice> makeDices(Dice d) { vector<Dice> res; for (int i = 0; i < 6; i++) { Dice t(d); if (i == 1) t.roll('N'); if (i == 2) t.roll('S'); if (i == 3) t.roll('S'), t.roll('S'); if (i == 4) t.roll('L'); if (i == 5) t.roll('R'); for (int k = 0; k < 4; k++) { res.push_back(t); t.roll('E'); } } return res; } std::vector<ll> divisor(ll n) // nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } // 多次元 vector 生成 template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } using Graph = vector<vector<int>>; // 深さ優先探索 vector<bool> seen; void gdfs(const Graph &G, int v) { seen[v] = true; // v を訪問済にする // v から行ける各頂点 next_v について for (auto next_v : G[v]) { if (seen[next_v]) continue; // next_v が探索済だったらスルー gdfs(G, next_v); // 再帰的に探索 } } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N; vector<double> p; int dp[3100][3100]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> N; p.resize(N); rep(i, N) cin >> p[i]; dp[0][0] = 1.0; rep(i, N) { rep(j, i + 1) { dp[i + 1][j + 1] += dp[i][j] * p[i]; dp[i + 1][j] += dp[i][j] * (1.0 - p[i]); } } double ans = 0.0; REP(j, (N + 1) / 2, N + 1) ans += dp[N][j]; cout << fixed << setprecision(10) << ans << endl; }
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) 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; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 #define BIT_FLAG_0 (1 << 0) // 0000 0000 0000 0001 #define BIT_FLAG_1 (1 << 1) // 0000 0000 0000 0010 #define BIT_FLAG_2 (1 << 2) // 0000 0000 0000 0100 #define BIT_FLAG_3 (1 << 3) // 0000 0000 0000 1000 #define BIT_FLAG_4 (1 << 4) // 0000 0000 0001 0000 #define BIT_FLAG_5 (1 << 5) // 0000 0000 0010 0000 #define BIT_FLAG_6 (1 << 6) // 0000 0000 0100 0000 #define BIT_FLAG_7 (1 << 7) // 0000 0000 1000 0000 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INTINF = 1 << 30; const int MAX = 510000; 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[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll n) : par(n, -1) {} void init(ll n) { par.assign(n, -1); } ll root(ll x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(ll x, ll y) { return root(x) == root(y); } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } ll size(ll x) { return -par[root(x)]; } }; template <typename T> vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) { const T INF = numeric_limits<T>::max(); using P = pair<T, int>; int n = G.size(); vector<T> d(n, INF); vector<int> b(n, -1); priority_queue<P, vector<P>, greater<P>> q; d[s] = 0; q.emplace(d[s], s); while (!q.empty()) { P p = q.top(); q.pop(); int v = p.second; if (d[v] < p.first) continue; for (auto &e : G[v]) { int u = e.first; T c = e.second; if (d[u] > d[v] + c) { d[u] = d[v] + c; b[u] = v; q.emplace(d[u], u); } } } return d; } int64_t power(int64_t x, int64_t n, int64_t mod) { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } vector<int> sieve_of_eratosthenes(int n) { vector<int> primes(n); for (int i = 2; i < n; ++i) primes[i] = i; for (int i = 2; i * i < n; ++i) if (primes[i]) for (int j = i * i; j < n; j += i) primes[j] = 0; return primes; } struct Dice { int s[6]; int &top() { return s[0]; } int &south() { return s[1]; } int &east() { return s[2]; } int &west() { return s[3]; } int &north() { return s[4]; } int &bottom() { return s[5]; } void roll(char c) { // the view from above // N // W E // S string b("EWNSRL"); int v[6][4] = {{0, 3, 5, 2}, {0, 2, 5, 3}, {0, 1, 5, 4}, {0, 4, 5, 1}, {1, 2, 4, 3}, {1, 3, 4, 2}}; for (int k = 0; k < 6; k++) { if (b[k] != c) continue; int t = s[v[k][0]]; s[v[k][0]] = s[v[k][1]]; s[v[k][1]] = s[v[k][2]]; s[v[k][2]] = s[v[k][3]]; s[v[k][3]] = t; } } using ll = long long; ll hash() { ll res = 0; for (int i = 0; i < 6; i++) res = res * 256 + s[i]; return res; } bool operator==(const Dice &d) const { for (int i = 0; i < 6; i++) if (s[i] != d.s[i]) return 0; return 1; } }; vector<Dice> makeDices(Dice d) { vector<Dice> res; for (int i = 0; i < 6; i++) { Dice t(d); if (i == 1) t.roll('N'); if (i == 2) t.roll('S'); if (i == 3) t.roll('S'), t.roll('S'); if (i == 4) t.roll('L'); if (i == 5) t.roll('R'); for (int k = 0; k < 4; k++) { res.push_back(t); t.roll('E'); } } return res; } std::vector<ll> divisor(ll n) // nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } // 多次元 vector 生成 template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } using Graph = vector<vector<int>>; // 深さ優先探索 vector<bool> seen; void gdfs(const Graph &G, int v) { seen[v] = true; // v を訪問済にする // v から行ける各頂点 next_v について for (auto next_v : G[v]) { if (seen[next_v]) continue; // next_v が探索済だったらスルー gdfs(G, next_v); // 再帰的に探索 } } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N; vector<double> p; double dp[3100][3100]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> N; p.resize(N); rep(i, N) cin >> p[i]; dp[0][0] = 1.0; rep(i, N) { rep(j, i + 1) { dp[i + 1][j + 1] += dp[i][j] * p[i]; dp[i + 1][j] += dp[i][j] * (1.0 - p[i]); } } double ans = 0.0; REP(j, (N + 1) / 2, N + 1) ans += dp[N][j]; cout << fixed << setprecision(10) << ans << endl; }
[ "variable_declaration.type.primitive.change" ]
979,192
979,193
u135572611
cpp
p03170
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[n], i = 0; for (i = 0; i < n; ++i) { cin >> a[i]; } int dp[k + 1] = {0}; dp[0] = -1; for (i = 0; i <= k; i++) { if (dp[i] == -1) { for (int j = 0; j < n; j++) { if (i + a[j] <= k) dp[i + a[j]] = 1; } } else if (dp[i] == 0) { int z = 1; for (int j = 0; j < n; j++) { if (i - a[j] < 0) break; if (dp[i - a[j]] == -1) { z = 0; break; } } if (z == 0) dp[i] = 1; else { dp[i] = -1; for (int j = 0; j < n; j++) { if (i + a[j] <= k) dp[i + a[j]] = 1; } } } } // for(i=0;i<=k;i++) cout<<dp[i]<<" "; if (dp[k] == -1) cout << "second" << endl; else cout << "first" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[n], i = 0; for (i = 0; i < n; ++i) { cin >> a[i]; } int dp[k + 1] = {0}; dp[0] = -1; for (i = 0; i <= k; i++) { if (dp[i] == -1) { for (int j = 0; j < n; j++) { if (i + a[j] <= k) dp[i + a[j]] = 1; } } else if (dp[i] == 0) { int z = 1; for (int j = 0; j < n; j++) { if (i - a[j] < 0) break; if (dp[i - a[j]] == -1) { z = 0; break; } } if (z == 0) dp[i] = 1; else { dp[i] = -1; for (int j = 0; j < n; j++) { if (i + a[j] <= k) dp[i + a[j]] = 1; } } } } // for(i=0;i<=k;i++) cout<<dp[i]<<" "; if (dp[k] == -1) cout << "Second" << endl; else cout << "First" << endl; return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
979,198
979,199
u164786106
cpp
p03170
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 9; const int K = 1e5 + 9; int n, k; int a[N]; bool dp[K]; // 石の個数が k 個なら first は必ず負ける int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; fill(&dp[0], &dp[K], true); for (int s = 0; s <= k; s++) { for (int i = 1; i <= n; i++) { if (dp[s]) dp[s + a[i]] = false; } } cout << (dp[k] ? "Second" : "First") << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 9; const int K = 1e6; int n, k; int a[N]; bool dp[K]; // 石の個数が k 個なら first は必ず負ける int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; fill(&dp[0], &dp[K], true); for (int s = 0; s <= k; s++) { for (int i = 1; i <= n; i++) { if (dp[s]) dp[s + a[i]] = false; } } cout << (dp[k] ? "Second" : "First") << endl; }
[ "literal.number.change", "variable_declaration.value.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
979,204
979,205
u194268736
cpp
p03170
#include <fstream> #include <iostream> #include <vector> // directions using namespace std; #define bit(x, i) (x & (1 << i)) // select the bit of position i of x #define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x #define hBit(msb, n) \ asm("bsrl %1,%0" \ : "=r"(msb) \ : "r"(n)) // get the highest bit of x, maybe the fastest #define max(a, b) (a < b ? b : a) #define min(a, b) (a > b ? b : a) #define abs(x) \ (x < 0 ? (-x) : x) // big bug here if "-x" is not surrounded by "()" #define IN(i, l, r) (l < i && i < r) // the next for are for checking bound #define LINR(i, l, r) (l <= i && i <= r) #define LIN(i, l, r) (l <= i && i < r) #define INR(i, l, r) (l < i && i <= r) #define wez2(n, m) \ int(n), (m); \ scanf("%d %d", &(n), &(m)) #define wez3(n, m, k) \ int(n), (m), (k); \ scanf("%d %d %d", &(n), &(m), &(k)) #define TESTS wez(testow) while (testow--) // for multilple cases problems #define whileZ \ int T; \ getI(T); \ while (T--) // the same as above #define getS(x) scanf("%s", x) // get a char* string #define clr(a, x) memset(a, x, sizeof(a)) // set elements of array to some value #define char2Int(c) (c - '0') #define lastEle(vec) vec[vec.size() - 1] #define SZ(x) ((int)((x).size())) #define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b #define REMIN(a, b) (a) = min((a), (b)); #define FOREACH(i, t) \ for (typeof(t.begin()) i = t.begin(); i != t.end(); \ i++) // traverse an STL data structure #define ALL(c) (c).begin(), (c).end() // handy for function like "sort()" #define PRESENT(c, x) ((c).find(x) != (c).end()) #define CPRESENT(c, x) (find(ALL(c), x) != (c).end()) #define ll \ long long // data types used often, but you don't want to type them time by // time #define ull unsigned long long #define us unsigned short #define IOS \ ios_base::sync_with_stdio(0); // to synchronize the input of cin and scanf #define INF 1001001001 #define PI 3.1415926535897932384626 // for map, pair #define mp make_pair #define fi first #define se second #define DBG(vari) cerr << #vari << " = " << (vari) << endl; #define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ') #define printV(a) printA(a, 0, a.size() - 1) #define ui unsigned int // for vectors #define pb push_back typedef int elem_t; typedef vector<int> vi; typedef vector<long> vl; typedef vector<pair<int, int>> vpi; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<vpi> vvpi; typedef pair<int, int> ii; #define F(i, L, R) for (int i = L; i < R; i++) // next four are for "for loops" #define FE(i, L, R) for (int i = L; i <= R; i++) #define FF(i, L, R) for (int i = L; i > R; i--) #define FFE(i, L, R) for (int i = L; i >= R; i--) #define getI(a) \ scanf("%d", &a) // next three are handy ways to get ints, it's also force you // to use '&' sign #define getII(a, b) scanf("%d%d", &a, &b) #define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c) #define wez(n) \ int(n); \ scanf( \ "%d", \ &(n)) // handy if the input is right after the definition of a variable/ namespace EU { void prows(vi row) { for (int col : row) { printf("%5d", col); } printf("\n"); } void pm(vvi matrix) { for (auto r : matrix) { prows(r); } printf("\n"); } } // namespace EU #define maxN 100000 // class Stones { // public: // dp[i] TRUE if first player wins if there are i stones remaining int main() { int n, k; cin >> n >> k; vi a(n); F(i, 0, n) cin >> a[i]; vector<bool> dp(k + 1); FE(stones, 0, k) { for (int x : a) if (stones >= x && !dp[stones - x]) { dp[stones] = true; } } puts(dp[k] ? "FIRST" : "SECOND"); } // };
#include <fstream> #include <iostream> #include <vector> // directions using namespace std; #define bit(x, i) (x & (1 << i)) // select the bit of position i of x #define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x #define hBit(msb, n) \ asm("bsrl %1,%0" \ : "=r"(msb) \ : "r"(n)) // get the highest bit of x, maybe the fastest #define max(a, b) (a < b ? b : a) #define min(a, b) (a > b ? b : a) #define abs(x) \ (x < 0 ? (-x) : x) // big bug here if "-x" is not surrounded by "()" #define IN(i, l, r) (l < i && i < r) // the next for are for checking bound #define LINR(i, l, r) (l <= i && i <= r) #define LIN(i, l, r) (l <= i && i < r) #define INR(i, l, r) (l < i && i <= r) #define wez2(n, m) \ int(n), (m); \ scanf("%d %d", &(n), &(m)) #define wez3(n, m, k) \ int(n), (m), (k); \ scanf("%d %d %d", &(n), &(m), &(k)) #define TESTS wez(testow) while (testow--) // for multilple cases problems #define whileZ \ int T; \ getI(T); \ while (T--) // the same as above #define getS(x) scanf("%s", x) // get a char* string #define clr(a, x) memset(a, x, sizeof(a)) // set elements of array to some value #define char2Int(c) (c - '0') #define lastEle(vec) vec[vec.size() - 1] #define SZ(x) ((int)((x).size())) #define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b #define REMIN(a, b) (a) = min((a), (b)); #define FOREACH(i, t) \ for (typeof(t.begin()) i = t.begin(); i != t.end(); \ i++) // traverse an STL data structure #define ALL(c) (c).begin(), (c).end() // handy for function like "sort()" #define PRESENT(c, x) ((c).find(x) != (c).end()) #define CPRESENT(c, x) (find(ALL(c), x) != (c).end()) #define ll \ long long // data types used often, but you don't want to type them time by // time #define ull unsigned long long #define us unsigned short #define IOS \ ios_base::sync_with_stdio(0); // to synchronize the input of cin and scanf #define INF 1001001001 #define PI 3.1415926535897932384626 // for map, pair #define mp make_pair #define fi first #define se second #define DBG(vari) cerr << #vari << " = " << (vari) << endl; #define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ') #define printV(a) printA(a, 0, a.size() - 1) #define ui unsigned int // for vectors #define pb push_back typedef int elem_t; typedef vector<int> vi; typedef vector<long> vl; typedef vector<pair<int, int>> vpi; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<vpi> vvpi; typedef pair<int, int> ii; #define F(i, L, R) for (int i = L; i < R; i++) // next four are for "for loops" #define FE(i, L, R) for (int i = L; i <= R; i++) #define FF(i, L, R) for (int i = L; i > R; i--) #define FFE(i, L, R) for (int i = L; i >= R; i--) #define getI(a) \ scanf("%d", &a) // next three are handy ways to get ints, it's also force you // to use '&' sign #define getII(a, b) scanf("%d%d", &a, &b) #define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c) #define wez(n) \ int(n); \ scanf( \ "%d", \ &(n)) // handy if the input is right after the definition of a variable/ namespace EU { void prows(vi row) { for (int col : row) { printf("%5d", col); } printf("\n"); } void pm(vvi matrix) { for (auto r : matrix) { prows(r); } printf("\n"); } } // namespace EU #define maxN 100000 // class Stones { // public: // dp[i] TRUE if first player wins if there are i stones remaining int main() { int n, k; cin >> n >> k; vi a(n); F(i, 0, n) cin >> a[i]; vector<bool> dp(k + 1); FE(stones, 0, k) { for (int x : a) if (stones >= x && !dp[stones - x]) { dp[stones] = true; } } puts(dp[k] ? "First" : "Second"); } // };
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "io.output.change" ]
979,208
979,209
u593802447
cpp
p03170
#include <fstream> #include <iostream> #include <vector> // directions using namespace std; #define bit(x, i) (x & (1 << i)) // select the bit of position i of x #define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x #define hBit(msb, n) \ asm("bsrl %1,%0" \ : "=r"(msb) \ : "r"(n)) // get the highest bit of x, maybe the fastest #define max(a, b) (a < b ? b : a) #define min(a, b) (a > b ? b : a) #define abs(x) \ (x < 0 ? (-x) : x) // big bug here if "-x" is not surrounded by "()" #define IN(i, l, r) (l < i && i < r) // the next for are for checking bound #define LINR(i, l, r) (l <= i && i <= r) #define LIN(i, l, r) (l <= i && i < r) #define INR(i, l, r) (l < i && i <= r) #define wez2(n, m) \ int(n), (m); \ scanf("%d %d", &(n), &(m)) #define wez3(n, m, k) \ int(n), (m), (k); \ scanf("%d %d %d", &(n), &(m), &(k)) #define TESTS wez(testow) while (testow--) // for multilple cases problems #define whileZ \ int T; \ getI(T); \ while (T--) // the same as above #define getS(x) scanf("%s", x) // get a char* string #define clr(a, x) memset(a, x, sizeof(a)) // set elements of array to some value #define char2Int(c) (c - '0') #define lastEle(vec) vec[vec.size() - 1] #define SZ(x) ((int)((x).size())) #define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b #define REMIN(a, b) (a) = min((a), (b)); #define FOREACH(i, t) \ for (typeof(t.begin()) i = t.begin(); i != t.end(); \ i++) // traverse an STL data structure #define ALL(c) (c).begin(), (c).end() // handy for function like "sort()" #define PRESENT(c, x) ((c).find(x) != (c).end()) #define CPRESENT(c, x) (find(ALL(c), x) != (c).end()) #define ll \ long long // data types used often, but you don't want to type them time by // time #define ull unsigned long long #define us unsigned short #define IOS \ ios_base::sync_with_stdio(0); // to synchronize the input of cin and scanf #define INF 1001001001 #define PI 3.1415926535897932384626 // for map, pair #define mp make_pair #define fi first #define se second #define DBG(vari) cerr << #vari << " = " << (vari) << endl; #define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ') #define printV(a) printA(a, 0, a.size() - 1) #define ui unsigned int // for vectors #define pb push_back typedef int elem_t; typedef vector<int> vi; typedef vector<long> vl; typedef vector<pair<int, int>> vpi; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<vpi> vvpi; typedef pair<int, int> ii; #define F(i, L, R) for (int i = L; i < R; i++) // next four are for "for loops" #define FE(i, L, R) for (int i = L; i <= R; i++) #define FF(i, L, R) for (int i = L; i > R; i--) #define FFE(i, L, R) for (int i = L; i >= R; i--) #define getI(a) \ scanf("%d", &a) // next three are handy ways to get ints, it's also force you // to use '&' sign #define getII(a, b) scanf("%d%d", &a, &b) #define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c) #define wez(n) \ int(n); \ scanf( \ "%d", \ &(n)) // handy if the input is right after the definition of a variable/ namespace EU { void prows(vi row) { for (int col : row) { printf("%5d", col); } printf("\n"); } void pm(vvi matrix) { for (auto r : matrix) { prows(r); } printf("\n"); } } // namespace EU #define maxN 100000 // class Stones { // public: // dp[i] TRUE if first player wins if there are i stones remaining int main() { int n, k; cin >> n >> k; vi a(n); F(i, 0, n) cin >> a[i]; vector<bool> dp(k + 1); FE(stones, 0, k) { for (int x : a) if (stones >= x && !dp[stones - x]) { dp[stones] = true; } } cout << dp[k] ? "FIRST" : "SECOND"; } // };
#include <fstream> #include <iostream> #include <vector> // directions using namespace std; #define bit(x, i) (x & (1 << i)) // select the bit of position i of x #define lowbit(x) ((x) & ((x) ^ ((x)-1))) // get the lowest bit of x #define hBit(msb, n) \ asm("bsrl %1,%0" \ : "=r"(msb) \ : "r"(n)) // get the highest bit of x, maybe the fastest #define max(a, b) (a < b ? b : a) #define min(a, b) (a > b ? b : a) #define abs(x) \ (x < 0 ? (-x) : x) // big bug here if "-x" is not surrounded by "()" #define IN(i, l, r) (l < i && i < r) // the next for are for checking bound #define LINR(i, l, r) (l <= i && i <= r) #define LIN(i, l, r) (l <= i && i < r) #define INR(i, l, r) (l < i && i <= r) #define wez2(n, m) \ int(n), (m); \ scanf("%d %d", &(n), &(m)) #define wez3(n, m, k) \ int(n), (m), (k); \ scanf("%d %d %d", &(n), &(m), &(k)) #define TESTS wez(testow) while (testow--) // for multilple cases problems #define whileZ \ int T; \ getI(T); \ while (T--) // the same as above #define getS(x) scanf("%s", x) // get a char* string #define clr(a, x) memset(a, x, sizeof(a)) // set elements of array to some value #define char2Int(c) (c - '0') #define lastEle(vec) vec[vec.size() - 1] #define SZ(x) ((int)((x).size())) #define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b #define REMIN(a, b) (a) = min((a), (b)); #define FOREACH(i, t) \ for (typeof(t.begin()) i = t.begin(); i != t.end(); \ i++) // traverse an STL data structure #define ALL(c) (c).begin(), (c).end() // handy for function like "sort()" #define PRESENT(c, x) ((c).find(x) != (c).end()) #define CPRESENT(c, x) (find(ALL(c), x) != (c).end()) #define ll \ long long // data types used often, but you don't want to type them time by // time #define ull unsigned long long #define us unsigned short #define IOS \ ios_base::sync_with_stdio(0); // to synchronize the input of cin and scanf #define INF 1001001001 #define PI 3.1415926535897932384626 // for map, pair #define mp make_pair #define fi first #define se second #define DBG(vari) cerr << #vari << " = " << (vari) << endl; #define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ') #define printV(a) printA(a, 0, a.size() - 1) #define ui unsigned int // for vectors #define pb push_back typedef int elem_t; typedef vector<int> vi; typedef vector<long> vl; typedef vector<pair<int, int>> vpi; typedef vector<vl> vvl; typedef vector<vi> vvi; typedef vector<vpi> vvpi; typedef pair<int, int> ii; #define F(i, L, R) for (int i = L; i < R; i++) // next four are for "for loops" #define FE(i, L, R) for (int i = L; i <= R; i++) #define FF(i, L, R) for (int i = L; i > R; i--) #define FFE(i, L, R) for (int i = L; i >= R; i--) #define getI(a) \ scanf("%d", &a) // next three are handy ways to get ints, it's also force you // to use '&' sign #define getII(a, b) scanf("%d%d", &a, &b) #define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c) #define wez(n) \ int(n); \ scanf( \ "%d", \ &(n)) // handy if the input is right after the definition of a variable/ namespace EU { void prows(vi row) { for (int col : row) { printf("%5d", col); } printf("\n"); } void pm(vvi matrix) { for (auto r : matrix) { prows(r); } printf("\n"); } } // namespace EU #define maxN 100000 // class Stones { // public: // dp[i] TRUE if first player wins if there are i stones remaining int main() { int n, k; cin >> n >> k; vi a(n); F(i, 0, n) cin >> a[i]; vector<bool> dp(k + 1); FE(stones, 0, k) { for (int x : a) if (stones >= x && !dp[stones - x]) { dp[stones] = true; } } puts(dp[k] ? "First" : "Second"); } // };
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
979,210
979,209
u593802447
cpp
p03170
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define MAXN ((int)2e5 + 5) #define MOD ((int)1e9 + 7) #define ll long long #define _ << " " << #define TRACE(x) cout << #x << " = " << x << endl; #define pb push_back #define MP make_pair #define pi pair<int, int> #define vi vector<int> #define vii vector<pi> #define all(x) x.begin(), x.end() int n, m, t, k; int d[MAXN]; int dp[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; ++i) cin >> d[i]; for (int i = 0; i <= k; ++i) dp[i] = -1; dp[0] = 1; for (int i = 1; i <= k; ++i) { bool flag = false; for (int j = 0; j < n; ++j) if (i >= d[j] && dp[i - d[j]] == 0) { flag = 1; break; } if (flag) dp[i] = 1; else dp[i] = 0; } if (dp[k] == 0) cout << "First\n"; else cout << "Second\n"; // for (int i = 0; i <= k; ++i) // { // cout << i _ dp[i] << endl; // } return 0; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define MAXN ((int)2e5 + 5) #define MOD ((int)1e9 + 7) #define ll long long #define _ << " " << #define TRACE(x) cout << #x << " = " << x << endl; #define pb push_back #define MP make_pair #define pi pair<int, int> #define vi vector<int> #define vii vector<pi> #define all(x) x.begin(), x.end() int n, m, t, k; int d[MAXN]; int dp[MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; for (int i = 0; i < n; ++i) cin >> d[i]; for (int i = 0; i <= k; ++i) dp[i] = -1; dp[0] = 1; for (int i = 1; i <= k; ++i) { bool flag = false; for (int j = 0; j < n; ++j) if (i >= d[j] && dp[i - d[j]] == 1) { flag = 1; break; } if (flag) dp[i] = 0; else dp[i] = 1; } if (dp[k] == 0) cout << "First\n"; else cout << "Second\n"; // for (int i = 0; i <= k; ++i) // { // cout << i _ dp[i] << endl; // } return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change", "assignment.value.change" ]
979,243
979,244
u224073013
cpp
p03170
#include <bits/stdc++.h> using namespace std; int arr[105]; bool asd[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int z, x; cin >> z >> x; for (int q = 1; q <= z; q++) { cin >> arr[q]; } for (int q = 0; q <= x; q++) { for (int w = 1; w <= z; w++) { if (q - arr[w] >= 0) { if (!asd[q - arr[w]]) asd[q - arr[w]] = true; } } } if (asd[x]) cout << "First" << endl; else cout << "Second" << endl; }
#include <bits/stdc++.h> using namespace std; int arr[105]; bool asd[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int z, x; cin >> z >> x; for (int q = 1; q <= z; q++) { cin >> arr[q]; } for (int q = 0; q <= x; q++) { for (int w = 1; w <= z; w++) { if (q - arr[w] >= 0) { if (!asd[q - arr[w]]) asd[q] = true; } } } if (asd[x]) cout << "First" << endl; else cout << "Second" << endl; }
[ "expression.operation.binary.remove" ]
979,260
979,261
u019077264
cpp
p03170
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; int modd = 1e9 + 7; int main() { int n, k; cin >> n >> k; int ans[k + 1]; for (int i = 0; i <= k; i++) ans[i] = 0; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int key; for (int i = 1; i < n; i++) { key = arr[i]; int j = i - 1; for (; j >= 0; j--) { if (arr[j] > arr[j + 1]) arr[j + 1] = arr[j]; else { break; } } arr[j + 1] = key; } int r; for (int i = 1; i <= k; i++) { for (int j = 0; j < n; j++) { r = arr[j]; if (i < r) break; if (arr[i - r] == 0) { arr[i] = 1; break; } } } if (ans[k] == 1) cout << "First" << endl; else cout << "Second" << endl; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <string> #include <vector> using namespace std; int modd = 1e9 + 7; int main() { int n, k; cin >> n >> k; int ans[k + 1]; for (int i = 0; i <= k; i++) ans[i] = 0; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; int key; for (int i = 1; i < n; i++) { key = arr[i]; int j = i - 1; for (; j >= 0; j--) { if (arr[j] > arr[j + 1]) arr[j + 1] = arr[j]; else { break; } } arr[j + 1] = key; } int r; for (int i = 1; i <= k; i++) { for (int j = 0; j < n; j++) { r = arr[j]; if (i < r) break; if (ans[i - r] == 0) { ans[i] = 1; break; } } } if (ans[k] == 1) cout << "First" << endl; else cout << "Second" << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change", "assignment.variable.change" ]
979,262
979,263
u297798194
cpp
p03170
#include "algorithm" #include "bitset" #include "cmath" #include "complex" #include "deque" #include "fstream" #include "iomanip" #include "iostream" #include "iterator" #include "list" #include "map" #include "numeric" #include "queue" #include "set" #include "stack" #include "string" #include "unordered_map" #include "unordered_set" #include "vector" #include <cassert> #include <cstdio> #include <ctime> using namespace std; //#define f(i,n) for(int i=0; i<n;i++) //#define rf(i, n) for(int i=n-1;i>=0;i--) //#define forn(i, j, n) for(int i=j; i<n; i++) //#define ff(i, j, n) f(i, n)f(j, n) #define pb push_back #define maxi(a, b) a = max(a, b); #define mini(a, b) a = min(a, b); #define endl '\n' #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sqr(x) ((x) * (x)) #define SZ(a) ((int)(a.size())) #define watch(x) cout << (#x) << " = " << x << endl; // typedef long long ll; typedef long double ld; #define int long long #define double ld typedef map<int, int> mii; typedef pair<int, int> pii; typedef pair<string, int> psi; typedef pair<int, string> pis; typedef vector<int> vi; typedef vector<double> vd; typedef vector<pii> vpii; typedef vector<char> vc; template <class T> void show(const vector<T> &a) { for (T x : a) cout << x << " "; cout << endl; } const int sze = 3e5 + 50, oo = 1e18 + 500, mod1 = 1e9 + 7, mod = 998244353; const double eps = 1e-9, PI = 2 * acos(0.0); vi vertices[sze]; vi visit(sze, 0); vc used(sze, false); vi arr(sze, 0); int n, m, k; int A, B; int cnt = 0; // int dp[10010][110]; // int dpe[10010][10][110]; bool dp[sze]; bool did[110]; vi a(110); bool rec(int k) { if (did[k]) return dp[k]; did[k] = true; for (int i = 0; i < n; i++) { if (k - a[i] >= 0 && !rec(k - a[i])) { dp[k] = true; break; } } return dp[k]; } signed main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); /*string s; cin >> s >> m; n = SZ(s); for (int i = 1; i <= 9; i++) { dp[1][i % m] ++; } for (int i = 2; i < n; i++) { for (int j = 0; j < m; j++) { for (int z = 0; z <= 9; z++) { dp[i][(j + z) % m] = (dp[i - 1][j] + dp[i][(j + z) % m]) % mod; } } } int ans = 0; for (int i = 1; i < n; i++) { ans = (ans + dp[i][0]) % mod; } for (int i = 1; i <= s[0] - '0'; i++) { dpe[0][i][i % m]++; } for (int i = 1; i < n; i++) { for (int j = 0; j <= 9; j++) { for (int z = 0; z < m; z++) { if (j == s[i - 1] - '0') { for (int a = 0; a <= s[i] - '0'; a++) { dpe[i][a][(z + a) % m] = (dpe[i][a][(z + a) % m] + dpe[i-1][j][z]) % mod; } } else { for (int a = 0; a <= 9; a++) { dpe[i][a][(z + a) % m] = (dpe[i][a][(z + a) % m] + dpe[i - 1][j][z]) % mod; } } } } } for (int i = 0; i <= 9; i ++) { ans = (ans + dpe[n - 1][i][0]) % mod; } cout << ans;*/ cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } rec(k) ? cout << "First" : cout << "Second"; return 0; }
#include "algorithm" #include "bitset" #include "cmath" #include "complex" #include "deque" #include "fstream" #include "iomanip" #include "iostream" #include "iterator" #include "list" #include "map" #include "numeric" #include "queue" #include "set" #include "stack" #include "string" #include "unordered_map" #include "unordered_set" #include "vector" #include <cassert> #include <cstdio> #include <ctime> using namespace std; //#define f(i,n) for(int i=0; i<n;i++) //#define rf(i, n) for(int i=n-1;i>=0;i--) //#define forn(i, j, n) for(int i=j; i<n; i++) //#define ff(i, j, n) f(i, n)f(j, n) #define pb push_back #define maxi(a, b) a = max(a, b); #define mini(a, b) a = min(a, b); #define endl '\n' #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sqr(x) ((x) * (x)) #define SZ(a) ((int)(a.size())) #define watch(x) cout << (#x) << " = " << x << endl; // typedef long long ll; typedef long double ld; #define int long long #define double ld typedef map<int, int> mii; typedef pair<int, int> pii; typedef pair<string, int> psi; typedef pair<int, string> pis; typedef vector<int> vi; typedef vector<double> vd; typedef vector<pii> vpii; typedef vector<char> vc; template <class T> void show(const vector<T> &a) { for (T x : a) cout << x << " "; cout << endl; } const int sze = 3e5 + 50, oo = 1e18 + 500, mod1 = 1e9 + 7, mod = 998244353; const double eps = 1e-9, PI = 2 * acos(0.0); vi vertices[sze]; vi visit(sze, 0); vc used(sze, false); vi arr(sze, 0); int n, m, k; int A, B; int cnt = 0; // int dp[10010][110]; // int dpe[10010][10][110]; bool dp[sze]; bool did[sze]; vi a(110); bool rec(int k) { if (did[k]) return dp[k]; did[k] = true; for (int i = 0; i < n; i++) { if (k - a[i] >= 0 && !rec(k - a[i])) { dp[k] = true; break; } } return dp[k]; } signed main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); /*string s; cin >> s >> m; n = SZ(s); for (int i = 1; i <= 9; i++) { dp[1][i % m] ++; } for (int i = 2; i < n; i++) { for (int j = 0; j < m; j++) { for (int z = 0; z <= 9; z++) { dp[i][(j + z) % m] = (dp[i - 1][j] + dp[i][(j + z) % m]) % mod; } } } int ans = 0; for (int i = 1; i < n; i++) { ans = (ans + dp[i][0]) % mod; } for (int i = 1; i <= s[0] - '0'; i++) { dpe[0][i][i % m]++; } for (int i = 1; i < n; i++) { for (int j = 0; j <= 9; j++) { for (int z = 0; z < m; z++) { if (j == s[i - 1] - '0') { for (int a = 0; a <= s[i] - '0'; a++) { dpe[i][a][(z + a) % m] = (dpe[i][a][(z + a) % m] + dpe[i-1][j][z]) % mod; } } else { for (int a = 0; a <= 9; a++) { dpe[i][a][(z + a) % m] = (dpe[i][a][(z + a) % m] + dpe[i - 1][j][z]) % mod; } } } } } for (int i = 0; i <= 9; i ++) { ans = (ans + dpe[n - 1][i][0]) % mod; } cout << ans;*/ cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } rec(k) ? cout << "First" : cout << "Second"; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "variable_declaration.array_dimensions.change" ]
979,266
979,267
u957962914
cpp
p03170
/* ---------- STL Libraries ---------- */ // IO library #include <cstdio> #include <fstream> #include <iomanip> #include <ios> #include <iostream> // algorithm library #include <algorithm> #include <cmath> #include <numeric> #include <random> // container library #include <array> #include <bitset> #include <deque> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <unordered_map> #include <vector> /* ---------- Namespace ---------- */ using namespace std; /* ---------- Type ---------- */ using ll = long long; #define int ll #define P pair<ll, ll> /* ---------- Constants */ const ll MOD = 1e9 + 7; const int INF = 1LL << 55; /* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */ signed main() { int N, K; cin >> N >> K; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; sort(A, A + N); int dp[K + 1]; fill(dp, dp + K + 1, 0); for (int i = 0; i < A[0]; i++) { dp[i] = -1; } for (int i = A[0]; i <= K; i++) { bool lose = true; for (int j = 0; j < N; j++) { if (i - A[j] >= 0 && dp[i - A[j]] == -1) { dp[i] = 1; lose = false; break; } } if (lose) A[i] = -1; } cout << (dp[K] == 1 ? "First" : "Second") << endl; return 0; }
/* ---------- STL Libraries ---------- */ // IO library #include <cstdio> #include <fstream> #include <iomanip> #include <ios> #include <iostream> // algorithm library #include <algorithm> #include <cmath> #include <numeric> #include <random> // container library #include <array> #include <bitset> #include <deque> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <unordered_map> #include <vector> /* ---------- Namespace ---------- */ using namespace std; /* ---------- Type ---------- */ using ll = long long; #define int ll #define P pair<ll, ll> /* ---------- Constants */ const ll MOD = 1e9 + 7; const int INF = 1LL << 55; /* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */ signed main() { int N, K; cin >> N >> K; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; sort(A, A + N); int dp[K + 1]; fill(dp, dp + K + 1, 0); for (int i = 0; i < A[0]; i++) { dp[i] = -1; } for (int i = A[0]; i <= K; i++) { bool lose = true; for (int j = 0; j < N; j++) { if (i - A[j] >= 0 && dp[i - A[j]] == -1) { dp[i] = 1; lose = false; break; } } if (lose) dp[i] = -1; } cout << (dp[K] == 1 ? "First" : "Second") << endl; return 0; }
[ "assignment.variable.change", "identifier.change" ]
979,268
979,269
u853132965
cpp
p03170
#include <bits/stdc++.h> using namespace std; long long n, k, dp[200000], a[200000]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) { if (i - a[i] >= 0 && dp[i - a[j]] == 0) { dp[i] = 1; break; } } } if (dp[k] == 1) cout << "First"; else cout << "Second"; }
#include <bits/stdc++.h> using namespace std; long long n, k, dp[200000], a[200000]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) { if (i - a[j] >= 0 && dp[i - a[j]] == 0) { dp[i] = 1; break; } } } if (dp[k] == 1) cout << "First"; else cout << "Second"; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
979,270
979,271
u007564980
cpp
p03170
#include <bits/stdc++.h> using namespace std; long long n, k, dp[200000], a[200000]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) { if (i - a[i] >= 0 && dp[i - a[j]] == 0) dp[i] = 1; } } if (dp[k] == 1) cout << "First"; else cout << "Second"; }
#include <bits/stdc++.h> using namespace std; long long n, k, dp[200000], a[200000]; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= k; i++) { for (int j = 1; j <= n; j++) { if (i - a[j] >= 0 && dp[i - a[j]] == 0) { dp[i] = 1; break; } } } if (dp[k] == 1) cout << "First"; else cout << "Second"; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
979,272
979,271
u007564980
cpp
p03170
#include <iostream> using namespace std; int state[100002]; int a[100002]; int main() { int n, k; cin >> n >> k; int i; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 0; i <= k; i++) if (state[i] == 0) { int j; for (j = 1; j <= n; j++) if (i + a[j] <= k) state[i + a[j]] = 1; } cout << (!state[k] ? "SECOND" : "FIRST"); return 0; }
#include <iostream> using namespace std; int state[100002]; int a[100002]; int main() { int n, k; cin >> n >> k; int i; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 0; i <= k; i++) if (state[i] == 0) { int j; for (j = 1; j <= n; j++) if (i + a[j] <= k) state[i + a[j]] = 1; } cout << (!state[k] ? "Second" : "First"); return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
979,277
979,278
u359313068
cpp
p03170
#include <iostream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector<bool> dp(K + 1); for (int i = 1; i <= K; ++i) { for (int j = 0; j < N; ++j) { if (i >= A[j] && !dp[i - A[j]]) { dp[i] = true; } } } cout << (dp[N] ? "First\n" : "Second\n"); return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector<bool> dp(K + 1); for (int i = 1; i <= K; ++i) { for (int j = 0; j < N; ++j) { if (i >= A[j] && !dp[i - A[j]]) { dp[i] = true; } } } cout << (dp[K] ? "First\n" : "Second\n"); return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.loop.for.condition.change", "io.output.change" ]
979,283
979,284
u837745858
cpp
p03170
#include <bits/stdc++.h> #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(c) c.begin(), c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << (x) << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using namespace std; template <class S, class T> ostream &operator<<(ostream &o, const pair<S, T> &p) { return o << "(" << p.fs << "," << p.sc << ")"; } template <class T> ostream &operator<<(ostream &o, const vector<T> &vc) { o << "{"; for (const T &v : vc) o << v << ","; o << "}"; return o; } using ll = long long; template <class T> using V = vector<T>; template <class T> using VV = vector<vector<T>>; int main() { int N, X; cin >> N >> X; V<int> a(N); rep(i, N) cin >> a[i]; V<bool> Awin(X + 1); rep(x, X + 1) { rep(i, N) if (x >= a[i] && !Awin[x + a[i]]) Awin[x] = 1; } if (Awin[X]) puts("First"); else puts("Second"); }
#include <bits/stdc++.h> #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(c) c.begin(), c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << (x) << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using namespace std; template <class S, class T> ostream &operator<<(ostream &o, const pair<S, T> &p) { return o << "(" << p.fs << "," << p.sc << ")"; } template <class T> ostream &operator<<(ostream &o, const vector<T> &vc) { o << "{"; for (const T &v : vc) o << v << ","; o << "}"; return o; } using ll = long long; template <class T> using V = vector<T>; template <class T> using VV = vector<vector<T>>; int main() { int N, X; cin >> N >> X; V<int> a(N); rep(i, N) cin >> a[i]; V<bool> Awin(X + 1); rep(x, X + 1) { rep(i, N) if (x >= a[i] && !Awin[x - a[i]]) Awin[x] = 1; } if (Awin[X]) puts("First"); else puts("Second"); }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
979,287
979,288
u309470177
cpp
p03170
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define mp make_pair using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 1LL << 30; const ll LINF = 1LL << 61; const double eps = 1e-5; const ll MOD = 1e9 + 7; int main() { int n, k; cin >> n >> k; vector<int> a(n + 10), g(k + 10); for (int i = 0; i < n; i++) cin >> a[i]; g[0] = 0; for (int i = 1; i <= k; i++) { vector<int> s; for (int j = 0; j < n; j++) { if (a[j] > i) continue; s.push_back(g[i - a[j]]); } sort(all(s)); s.erase(unique(all(s)), s.end()); bool f = false; if (s.size() >= 1 && s[0] > 0) { g[i] = 0; break; } for (int j = 1; j < s.size(); j++) { if (s[j] > s[j - 1] + 1) { g[i] = s[j - 1] + 1; f = true; break; } } if (s.size() == 1) { g[i] = 1; } else if (s.size() > 1 && f == false) { g[i] = s[s.size() - 1] + 1; } } if (g[k] == 0) { cout << "Second" << endl; } else { cout << "First" << endl; } }
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define mp make_pair using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 1LL << 30; const ll LINF = 1LL << 61; const double eps = 1e-5; const ll MOD = 1e9 + 7; int main() { int n, k; cin >> n >> k; vector<int> a(n + 10), g(k + 10); for (int i = 0; i < n; i++) cin >> a[i]; g[0] = 0; for (int i = 1; i <= k; i++) { vector<int> s; for (int j = 0; j < n; j++) { if (a[j] > i) continue; s.push_back(g[i - a[j]]); } sort(all(s)); s.erase(unique(all(s)), s.end()); bool f = false; if (s.size() >= 1 && s[0] > 0) { g[i] = 0; continue; } for (int j = 1; j < s.size(); j++) { if (s[j] > s[j - 1] + 1) { g[i] = s[j - 1] + 1; f = true; break; } } if (s.size() == 1) { g[i] = 1; } else if (s.size() > 1 && f == false) { g[i] = s[s.size() - 1] + 1; } } if (g[k] == 0) { cout << "Second" << endl; } else { cout << "First" << endl; } }
[ "control_flow.break.remove", "control_flow.continue.add" ]
979,289
979,290
u924339359
cpp
p03171
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) using P = pair<int, int>; const int INF = 1000100100; /* 大文字を小文字に変換 */ char tolower(char c) { return (c + 0x20); } /* 小文字を大文字に変換 */ char toupr(char c) { return (c - 0x20); } // if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A'; /* string s = "abcdefg" s.substr(4) "efg" s.substr(0,3) "abc" s.substr(2,4) "cdef" // イテレータ要素のインデックス distance(A.begin(), itr); */ const int MAX_N = 3010; int n; int a[MAX_N]; int dp[MAX_N][MAX_N]; void init() { rep(i, MAX_N) rep(j, MAX_N) dp[i][j] = 0; } int f(int l, int r) { if (dp[l][r]) return dp[l][r]; if (l == r) { dp[l][r] = a[l]; } else { dp[l][r] = max(a[l] - f(l + 1, r), a[r] - f(l, r - 1)); } return dp[l][r]; } int main() { cin >> n; rep(i, n) cin >> a[i]; init(); f(0, n - 1); cout << dp[0][n - 1] << endl; }
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) using P = pair<int, int>; const int INF = 1000100100; /* 大文字を小文字に変換 */ char tolower(char c) { return (c + 0x20); } /* 小文字を大文字に変換 */ char toupr(char c) { return (c - 0x20); } // if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A'; /* string s = "abcdefg" s.substr(4) "efg" s.substr(0,3) "abc" s.substr(2,4) "cdef" // イテレータ要素のインデックス distance(A.begin(), itr); */ const int MAX_N = 3010; int n; ll a[MAX_N]; ll dp[MAX_N][MAX_N]; void init() { rep(i, MAX_N) rep(j, MAX_N) dp[i][j] = 0; } ll f(int l, int r) { if (dp[l][r]) return dp[l][r]; if (l == r) { dp[l][r] = a[l]; } else { dp[l][r] = max(a[l] - f(l + 1, r), a[r] - f(l, r - 1)); } return dp[l][r]; } int main() { cin >> n; rep(i, n) cin >> a[i]; init(); f(0, n - 1); cout << dp[0][n - 1] << endl; }
[ "variable_declaration.type.change" ]
979,295
979,296
u171059364
cpp
p03171
#include <bits/stdc++.h> #define eps 1e-3 #define pi acos(-1.0) #define inf 0x3f #define INF 0x3f3f3f3f #define pb push_back #define debug1 cout << "&&"; #define debug2 cout << "**"; #define ms(a, x) memset(a, x, sizeof(a)) #define for0(i, n) for (int i = 0; i < n; ++i) #define for1(i, n) for (int i = 1; i <= n; ++i) using namespace std; typedef double db; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<long long, int> pli; typedef pair<long long, long long> pll; const int mod = 1e9 + 7; const int N = 3e3 + 10; const int M = 1e6 + 10; /*=================================================================================*/ int n, a[N], dp[N][N]; int main() { cin >> n; for1(i, n) scanf("%d", &a[i]); for (int i = n; i; --i) for (int j = i; j <= n; ++j) { dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]); } cout << dp[1][n] << endl; }
#include <bits/stdc++.h> #define eps 1e-3 #define pi acos(-1.0) #define inf 0x3f #define INF 0x3f3f3f3f #define pb push_back #define debug1 cout << "&&"; #define debug2 cout << "**"; #define ms(a, x) memset(a, x, sizeof(a)) #define for0(i, n) for (int i = 0; i < n; ++i) #define for1(i, n) for (int i = 1; i <= n; ++i) using namespace std; typedef double db; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<long long, int> pli; typedef pair<long long, long long> pll; const int mod = 1e9 + 7; const int N = 3e3 + 10; const int M = 1e6 + 10; /*=================================================================================*/ int n, a[N]; ll dp[N][N]; int main() { cin >> n; for1(i, n) scanf("%d", &a[i]); for (int i = n; i; --i) for (int j = i; j <= n; ++j) { dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]); } cout << dp[1][n] << endl; }
[]
979,299
979,300
u089230684
cpp
p03171
#include <bits/stdc++.h> using namespace std; int N, a[3010], dp[3010][3010]; int f(int x, int y) { if (x > y) return 0; if (dp[x][y] != -1) return dp[x][y]; dp[x][y] = max(a[x] - f(x + 1, y), a[y] - f(x, y - 1)); return dp[x][y]; } int main() { cin >> N; for (int i = 1; i <= N; i++) cin >> a[i]; memset(dp, -1, sizeof(dp)); cout << f(1, N) << endl; }
#include <bits/stdc++.h> using namespace std; int N; long long a[3010], dp[3010][3010]; long long f(int x, int y) { if (x > y) return 0; if (dp[x][y] != -1) return dp[x][y]; dp[x][y] = max(a[x] - f(x + 1, y), a[y] - f(x, y - 1)); return dp[x][y]; } int main() { cin >> N; for (int i = 1; i <= N; i++) cin >> a[i]; memset(dp, -1, sizeof(dp)); cout << f(1, N) << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,301
979,302
u089230684
cpp
p03171
#include <bits/stdc++.h> //#define int long long #define endl '\n' #define mod 1000000007 #define inf 1e18 #define PI 3.14159265358979323846264338327950L #define w(x) \ int x; \ cin >> x; \ while (x--) using namespace std; bool sieve[2000006]; void sieve_make() { memset(sieve, true, sizeof(sieve)); sieve[0] = sieve[1] = false; for (int i = 2; i * i < 2000006; i++) { if (sieve[i]) { for (int j = i * i; j < 2000006; j += i) sieve[j] = false; } } } int max(int a, int b) { if (a > b) return a; return b; } int min(int a, int b) { if (a < b) return a; return b; } int modexp(int a, int b, int c) { if (a == 0) return 0; if (b == 0) return 1; int ans; if (b % 2 == 0) { int small = modexp(a, b / 2, c); ans = (small * small) % c; } else { int small = modexp(a, b - 1, c); ans = (a % c); ans = (small * ans) % c; } return (ans + c) % c; } bool sign(int x) { if (x > 0) return true; return false; } int kadane(int *a, int n) { int loc = a[0], glo = a[0]; for (int i = 1; i < n; i++) { loc = max(a[i], loc + a[i]); glo = max(glo, loc); } return glo; } int dp[3001][3001]; int solve(vector<int> &a, int i, int j) { if (i > j) return 0; if (dp[i][j] != -1) return dp[i][j]; int a1 = a[i] + min(solve(a, i + 2, j), solve(a, i + 1, j - 1)); int a2 = a[j] + min(solve(a, i + 1, j - 1), solve(a, i, j - 2)); return dp[i][j] = max(a1, a2); } int32_t main() { ios::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); memset(dp, -1, sizeof dp); int n; cin >> n; vector<int> a(n); int s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } int x = solve(a, 0, a.size() - 1); cerr << x; int y = s - x; cout << x - y << endl; }
#include <bits/stdc++.h> #define int long long #define endl '\n' #define mod 1000000007 #define inf 1e18 #define PI 3.14159265358979323846264338327950L #define w(x) \ int x; \ cin >> x; \ while (x--) using namespace std; bool sieve[2000006]; void sieve_make() { memset(sieve, true, sizeof(sieve)); sieve[0] = sieve[1] = false; for (int i = 2; i * i < 2000006; i++) { if (sieve[i]) { for (int j = i * i; j < 2000006; j += i) sieve[j] = false; } } } int max(int a, int b) { if (a > b) return a; return b; } int min(int a, int b) { if (a < b) return a; return b; } int modexp(int a, int b, int c) { if (a == 0) return 0; if (b == 0) return 1; int ans; if (b % 2 == 0) { int small = modexp(a, b / 2, c); ans = (small * small) % c; } else { int small = modexp(a, b - 1, c); ans = (a % c); ans = (small * ans) % c; } return (ans + c) % c; } bool sign(int x) { if (x > 0) return true; return false; } int kadane(int *a, int n) { int loc = a[0], glo = a[0]; for (int i = 1; i < n; i++) { loc = max(a[i], loc + a[i]); glo = max(glo, loc); } return glo; } int dp[3001][3001]; int solve(vector<int> &a, int i, int j) { if (i > j) return 0; if (dp[i][j] != -1) return dp[i][j]; int a1 = a[i] + min(solve(a, i + 2, j), solve(a, i + 1, j - 1)); int a2 = a[j] + min(solve(a, i + 1, j - 1), solve(a, i, j - 2)); return dp[i][j] = max(a1, a2); } int32_t main() { ios::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); memset(dp, -1, sizeof dp); int n; cin >> n; vector<int> a(n); int s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } int x = solve(a, 0, a.size() - 1); cerr << x; int y = s - x; cout << x - y << endl; }
[]
979,309
979,310
u929734172
cpp
p03171
#include <bits/stdc++.h> #include <iostream> using namespace std; // X+Y = C and Y=C-X. // Therefore X-Y = 2X - C. So A tries to maximise X and B tries to maximize X as // C=(sum of A[i]) is constant // State // dp[i][j][k]: The number of points A has // when the queue to choose from is (A[i]....A[j]) where player k starts //first // Initialization // dp[i][i] = A[i] // Transitions // if(i+N-1-j %2 == 0) dp[i][j] = max(dp[i+1][j]+A[i], dp[i][j-1]+A[j]) // else dp[i][j] = min(dp[i+1][j]+A[i], dp[i][j-1]+A[j]) // Order of evaluation // Diagonally or Length of substring wise // Answer // dp[0][N-1] int dp[3005][3005][2]; int A[3005]; int main() { int N; int C = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; dp[i][i][0] = A[i]; dp[i][i][1] = 0; C = C + A[i]; } for (int rMinusl = 1; rMinusl < N; rMinusl++) { for (int l = 0; l < N; l++) { int r = l + rMinusl; if (r < N) { dp[l][r][0] = max(dp[l + 1][r][1] + A[l], dp[l][r - 1][1] + A[r]); dp[l][r][1] = min(dp[l + 1][r][0], dp[l][r - 1][0]); } } } cout << 2 * dp[0][N - 1][0] - C << endl; }
#include <bits/stdc++.h> #include <iostream> using namespace std; // X+Y = C and Y=C-X. // Therefore X-Y = 2X - C. So A tries to maximise X and B tries to maximize X as // C=(sum of A[i]) is constant // State // dp[i][j][k]: The number of points A has // when the queue to choose from is (A[i]....A[j]) where player k starts //first // Initialization // dp[i][i] = A[i] // Transitions // if(i+N-1-j %2 == 0) dp[i][j] = max(dp[i+1][j]+A[i], dp[i][j-1]+A[j]) // else dp[i][j] = min(dp[i+1][j]+A[i], dp[i][j-1]+A[j]) // Order of evaluation // Diagonally or Length of substring wise // Answer // dp[0][N-1] long long dp[3005][3005][2]; int A[3005]; int main() { int N; long long C = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> A[i]; dp[i][i][0] = A[i]; dp[i][i][1] = 0; C = C + A[i]; } for (int rMinusl = 1; rMinusl < N; rMinusl++) { for (int l = 0; l < N; l++) { int r = l + rMinusl; if (r < N) { dp[l][r][0] = max(dp[l + 1][r][1] + A[l], dp[l][r - 1][1] + A[r]); dp[l][r][1] = min(dp[l + 1][r][0], dp[l][r - 1][0]); } } } cout << 2 * dp[0][N - 1][0] - C << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,313
979,314
u463134004
cpp
p03171
#include <bits/stdc++.h> using namespace std; int dp[3001][3001]; int a[3001], n; int fun(int s, int e, bool turn) { if (s > e) return 0; int &ret = dp[s][e]; if (~ret) return ret; if (!turn) { return ret = max(a[s] + fun(s + 1, e, !turn), a[e] + fun(s, e - 1, !turn)); } return ret = min(-a[s] + fun(s + 1, e, !turn), -a[e] + fun(s, e - 1, !turn)); } int main() { memset(dp, -1, sizeof dp); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } cout << fun(0, n - 1, 0) << endl; }
#include <bits/stdc++.h> using namespace std; long long dp[3001][3001]; int a[3001], n; long long fun(int s, int e, bool turn) { if (s > e) return 0; long long &ret = dp[s][e]; if (~ret) return ret; if (!turn) { return ret = max(a[s] + fun(s + 1, e, !turn), a[e] + fun(s, e - 1, !turn)); } return ret = min(-a[s] + fun(s + 1, e, !turn), -a[e] + fun(s, e - 1, !turn)); } int main() { memset(dp, -1, sizeof dp); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } cout << fun(0, n - 1, 0) << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,315
979,316
u839354257
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define pb push_back #define mk make_pair #define pii pair<int, int> #define vi vector<int> #define all(x) (x).begin(), (x).end() #define umap unordered_map #define uset unordered_set #define mod 1000000007 #define imax INT_MAX #define imin INT_MIN #define exp 1e9 #define sz(x) (int((x).size())) #define int long long int looktable[4000][4000]; int optimal(int arr[], int i, int j) { if (i == j) return arr[i]; if (i + 1 == j) return max(arr[i], arr[j]); if (looktable[i][j] == 0) { int left = arr[i] + min(optimal(arr, i + 2, j), optimal(arr, i + 1, j - 1)); int right = arr[j] + min(optimal(arr, i + 1, j), optimal(arr, i, j - 2)); looktable[i][j] = max(left, right); } return looktable[i][j]; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n], su = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; su += arr[i]; } memset(looktable, 0, sizeof(looktable)); int x = optimal(arr, 0, n - 1); int y = su - x; cout << x - y; return 0; }
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define pb push_back #define mk make_pair #define pii pair<int, int> #define vi vector<int> #define all(x) (x).begin(), (x).end() #define umap unordered_map #define uset unordered_set #define mod 1000000007 #define imax INT_MAX #define imin INT_MIN #define exp 1e9 #define sz(x) (int((x).size())) #define int long long int looktable[4000][4000]; int optimal(int arr[], int i, int j) { if (i == j) return arr[i]; if (i + 1 == j) return max(arr[i], arr[j]); if (looktable[i][j] == 0) { int left = arr[i] + min(optimal(arr, i + 2, j), optimal(arr, i + 1, j - 1)); int right = arr[j] + min(optimal(arr, i + 1, j - 1), optimal(arr, i, j - 2)); looktable[i][j] = max(left, right); } return looktable[i][j]; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n], su = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; su += arr[i]; } memset(looktable, 0, sizeof(looktable)); int x = optimal(arr, 0, n - 1); // cout<<x<<" "; int y = su - x; // cout<<y<<" "; cout << x - y; return 0; }
[ "assignment.change" ]
979,319
979,320
u157659681
cpp
p03171
#pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; using PII = pair<int, int>; using PLL = pair<LL, LL>; using VI = vector<int>; using VVI = vector<vector<int>>; const int INF = 1e9; const int MXN = 3e3 + 5; const int MXV = 0; const double EPS = 1e-9; const int MOD = 1e9 + 7; #define MP make_pair #define PB push_back #define F first #define S second #define FOR(i, L, R) for (int i = L; i < (int)R; ++i) #define FORD(i, L, R) for (int i = L; i > (int)R; --i) #define IOS \ cin.tie(nullptr); \ cout.tie(nullptr); \ ios_base::sync_with_stdio(false); vector<LL> v; LL dp[MXN][MXN]; int main() { int n; cin >> n; v.resize(n); FOR(i, 1, n + 1) { cin >> v[i]; } FORD(i, n, 0) FOR(j, i, n + 1) { dp[i][j] = max(v[i] - dp[i + 1][j], v[j] - dp[i][j - 1]); } cout << dp[1][n] << '\n'; }
#pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; using PII = pair<int, int>; using PLL = pair<LL, LL>; using VI = vector<int>; using VVI = vector<vector<int>>; const int INF = 1e9; const int MXN = 3e3 + 5; const int MXV = 0; const double EPS = 1e-9; const int MOD = 1e9 + 7; #define MP make_pair #define PB push_back #define F first #define S second #define FOR(i, L, R) for (int i = L; i < (int)R; ++i) #define FORD(i, L, R) for (int i = L; i > (int)R; --i) #define IOS \ cin.tie(nullptr); \ cout.tie(nullptr); \ ios_base::sync_with_stdio(false); vector<LL> v; LL dp[MXN][MXN]; int main() { IOS; int n; cin >> n; v.resize(n + 5); FOR(i, 1, n + 1) { cin >> v[i]; } FORD(i, n, 0) FOR(j, i, n + 1) { dp[i][j] = max(v[i] - dp[i + 1][j], v[j] - dp[i][j - 1]); } cout << dp[1][n] << '\n'; }
[ "expression.operation.binary.add" ]
979,331
979,332
u863370423
cpp
p03171
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << a[0]; return 0; } vector<vector<int>> dp(n, vector<int>(n, 0)); for (int k = 0; k < n; k++) { for (int j = k, i = 0; i < n && j < n; i++, j++) { if (i == j) dp[i][j] = a[i]; else if (j - i == 1) dp[i][j] = max(a[i], a[j]); else dp[i][j] = max(min(dp[i + 2][j], dp[i + 1][j - 1]) + a[i], min(dp[i + 1][j - 1], dp[i][j - 2]) + a[j]); } } if (dp[1][n - 1] < dp[0][n - 2]) cout << dp[0][n - 1] - dp[1][n - 1]; else cout << dp[0][n - 1] - dp[0][n - 2]; return 0; }
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int n; cin >> n; vector<long long int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << a[0]; return 0; } vector<vector<long long int>> dp(n, vector<long long int>(n, 0)); for (int k = 0; k < n; k++) { for (int j = k, i = 0; i < n && j < n; i++, j++) { if (i == j) dp[i][j] = a[i]; else if (j - i == 1) dp[i][j] = max(a[i], a[j]); else dp[i][j] = max(min(dp[i + 2][j], dp[i + 1][j - 1]) + a[i], min(dp[i + 1][j - 1], dp[i][j - 2]) + a[j]); } } if (dp[1][n - 1] < dp[0][n - 2]) cout << dp[0][n - 1] - dp[1][n - 1]; else cout << dp[0][n - 1] - dp[0][n - 2]; return 0; }
[ "variable_declaration.type.widen.change" ]
979,341
979,342
u314936326
cpp
p03171
#include <bits/stdc++.h> #define llu unsigned long long #define ll long long #define INF 0x3f3f3f3f #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define endl "\n" #define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower); #define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper); using namespace std; // scan vector template <typename T> inline istream &operator>>(istream &in, vector<T> &a) { for (auto &x : a) in >> x; return in; } // print vector template <typename T> inline ostream &operator<<(ostream &out, vector<T> &a) { for (auto &x : a) out << x << " "; return out; } // scan pair template <typename T, typename U> inline istream &operator>>(istream &in, pair<T, U> &a) { in >> a.first >> a.second; return in; } int n, k; vector<ll> a; vector<vector<ll>> dp; vector<vector<bool>> visited; ll solve(int first, int last) { if (first > last) return 0; if (visited[first][last]) return dp[first][last]; visited[first][last] = true; if (first == last) return dp[first][last] = a[first]; ll case1 = max(a[first] + solve(first + 2, last), a[first] + solve(first + 1, last - 1)); ll case2 = max(a[last] + solve(first, last - 2), a[last] + solve(first + 1, last - 1)); dp[first][last] = max(case1, case2); return dp[first][last]; } int main() { #ifdef SANS freopen("ongoingin.txt", "r", stdin); freopen("ongoingout.txt", "w", stdout); #endif fast int t = 1; // cin>>t; while (t--) { cin >> n; dp.resize(n, vector<ll>(n, -1)); a.resize(n); cin >> a; visited.resize(n, vector<bool>(n, 0)); ll total = 0; for (auto &i : a) { // cin>>i; total += i; } ll X = solve(0, n - 1); // cout<<X<<" "<<total<<endl; cout << (X - (total - X)); } #ifdef SANS cout << "\nTime Elapsed:" << 1.0 * clock() / CLOCKS_PER_SEC << "sec\n"; #endif }
#include <bits/stdc++.h> #define llu unsigned long long #define ll long long #define INF 0x3f3f3f3f #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define endl "\n" #define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower); #define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper); using namespace std; // scan vector template <typename T> inline istream &operator>>(istream &in, vector<T> &a) { for (auto &x : a) in >> x; return in; } // print vector template <typename T> inline ostream &operator<<(ostream &out, vector<T> &a) { for (auto &x : a) out << x << " "; return out; } // scan pair template <typename T, typename U> inline istream &operator>>(istream &in, pair<T, U> &a) { in >> a.first >> a.second; return in; } int n, k; vector<ll> a; vector<vector<ll>> dp; vector<vector<bool>> visited; ll solve(int first, int last) { if (first > last) return 0; if (visited[first][last]) return dp[first][last]; visited[first][last] = true; if (first == last) return dp[first][last] = a[first]; ll case1 = min(a[first] + solve(first + 2, last), a[first] + solve(first + 1, last - 1)); ll case2 = min(a[last] + solve(first, last - 2), a[last] + solve(first + 1, last - 1)); dp[first][last] = max(case1, case2); return dp[first][last]; } int main() { #ifdef SANS freopen("ongoingin.txt", "r", stdin); freopen("ongoingout.txt", "w", stdout); #endif fast int t = 1; // cin>>t; while (t--) { cin >> n; dp.resize(n, vector<ll>(n, -1)); a.resize(n); cin >> a; visited.resize(n, vector<bool>(n, 0)); ll total = 0; for (auto &i : a) { // cin>>i; total += i; } ll X = solve(0, n - 1); // cout<<X<<" "<<total<<endl; cout << (X - (total - X)); } #ifdef SANS cout << "\nTime Elapsed:" << 1.0 * clock() / CLOCKS_PER_SEC << "sec\n"; #endif }
[ "misc.opposites", "identifier.change", "call.function.change" ]
979,343
979,344
u714283722
cpp
p03171
#include <bits/stdc++.h> #define ll long long using namespace std; int n; int a[3005]; ll dp[3005][3005]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (dp[i] == dp[j]) dp[i][j] = a[i]; else dp[i][j] = max(a[i] - dp[i - 1][j], a[j] - dp[i][j - 1]); } } cout << dp[0][n - 1] << endl; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; int n; int a[3005]; ll dp[3005][3005]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (dp[i] == dp[j]) dp[i][j] = a[i]; else dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]); } } cout << dp[0][n - 1] << endl; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
979,347
979,348
u500482384
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int, int> #define sorted(a_1) sort(a_1.begin(), a_1.end()) #define rsorted(a_1) sort(a_1.rbegin(), a_1.rend()) #define t1(a_1) cout << a_1 << endl; #define t2(a_1) \ for (auto it_test : a_1) \ cout << it_test << " "; #define MOD 1000000007 ll dp[3001][3001]; ll maxValue(vector<int> &arr, int n, int i, int j) { if (i == j) { t1(i) return arr[i]; } if (dp[i][j] > -1) return dp[i][j]; dp[i][j] = max(arr[i] - maxValue(arr, n, i + 1, j), arr[j] - maxValue(arr, n, i, j - 1)); return dp[i][j]; } void solve() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } memset(dp, -1, sizeof(dp)); ll ans = maxValue(arr, n, 0, n - 1); // dp[0][0] = 0; // for(int i=1;i<=n;i++){ // for(int j=n-1;j>=0;j--){ // if(i<j) // dp[i][j] = max(arr[i-1] - dp[i-1][j],arr[j]-dp[i][j+1]); // if(i==j){ // dp[i][j] = arr[i-1]; // break; // } // } // } t1(ans) } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int, int> #define sorted(a_1) sort(a_1.begin(), a_1.end()) #define rsorted(a_1) sort(a_1.rbegin(), a_1.rend()) #define t1(a_1) cout << a_1 << endl; #define t2(a_1) \ for (auto it_test : a_1) \ cout << it_test << " "; #define MOD 1000000007 ll dp[3001][3001]; ll maxValue(vector<int> &arr, int n, int i, int j) { if (i == j) { // t1(i) return arr[i]; } if (dp[i][j] > -1) return dp[i][j]; dp[i][j] = max(arr[i] - maxValue(arr, n, i + 1, j), arr[j] - maxValue(arr, n, i, j - 1)); return dp[i][j]; } void solve() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } memset(dp, -1, sizeof(dp)); ll ans = maxValue(arr, n, 0, n - 1); // dp[0][0] = 0; // for(int i=1;i<=n;i++){ // for(int j=n-1;j>=0;j--){ // if(i<j) // dp[i][j] = max(arr[i-1] - dp[i-1][j],arr[j]-dp[i][j+1]); // if(i==j){ // dp[i][j] = arr[i-1]; // break; // } // } // } t1(ans) } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { solve(); } return 0; }
[ "call.remove" ]
979,349
979,350
u806983635
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define ll long long ll v[3004] = {0}; int dp[3005][3005]; ll solve(ll i, ll j) { if (i > j) return 0; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = max(v[i] + min(solve(i + 2, j), solve(i + 1, j - 1)), v[j] + min(solve(i + 1, j - 1), solve(i, j - 2))); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(dp, -1, sizeof(dp)); ll n; cin >> n; ll sum = 0; for (ll i = 0; i < n; i++) cin >> v[i], sum += v[i]; ll res = solve(0, n - 1); ll dif = sum - res; cout << res - dif; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long ll v[3004]; ll dp[3005][3005]; ll solve(ll i, ll j) { if (i > j) return 0; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = max(v[i] + min(solve(i + 2, j), solve(i + 1, j - 1)), v[j] + min(solve(i + 1, j - 1), solve(i, j - 2))); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(dp, -1, sizeof(dp)); ll n; cin >> n; ll sum = 0; for (ll i = 0; i < n; i++) cin >> v[i], sum += v[i]; ll res = solve(0, n - 1); ll dif = sum - res; cout << res - dif; return 0; }
[ "variable_declaration.type.change" ]
979,351
979,352
u093437522
cpp
p03171
#include <bits/stdc++.h> using namespace std; //#define kk //#define int long long #define FOR(i, n) for (int i = 1; i <= n; i++) #define ff first #define ss second #define ll int #define inf 1000000000 #define pb push_back #define mod 1000000007 const long long INF = 1e18 + 5; typedef pair<int, int> pi; int arr[3001]; int dp[3001][3001]; int get(int i, int j) { if (i > j) return 0; if (i == j) return arr[i]; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = max(arr[i] - get(i + 1, j), arr[j] - get(i, j - 1)); } void solve() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> arr[i]; } memset(dp, -1, sizeof dp); cout << get(1, n) << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(10); #ifdef kk freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int T = 1; // cin>>T; while (T--) { solve(); } }
#include <bits/stdc++.h> using namespace std; //#define kk #define int long long #define FOR(i, n) for (int i = 1; i <= n; i++) #define ff first #define ss second #define ll int #define inf 1000000000 #define pb push_back #define mod 1000000007 const long long INF = 1e18 + 5; typedef pair<int, int> pi; int arr[3001]; int dp[3001][3001]; int get(int i, int j) { if (i > j) return 0; if (i == j) return arr[i]; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = max(arr[i] - get(i + 1, j), arr[j] - get(i, j - 1)); } void solve() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> arr[i]; } memset(dp, -1, sizeof dp); cout << get(1, n) << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(10); #ifdef kk freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int T = 1; // cin>>T; while (T--) { solve(); } }
[]
979,353
979,354
u842610029
cpp
p03171
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace std; using namespace __gnu_pbds; typedef long long ll; //#define int long long int typedef complex<long double> cd; const long double pi = acos(-1); typedef double db; typedef long double ldb; typedef pair<int, int> pii; typedef pair<db, db> pdd; typedef vector<int> vi; typedef vector<vector<int>> matrix; #define m1 make_pair #define pb push_back #define flush fflush(stdout) #define IOS \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define reset(x, v) memset(x, v, sizeof(x)) #define fi first #define se second #define endl "\n" #define debug(x) (cerr << #x << ": " << x << "\n") #define setbits(x) __builtin_popcount(x) #define setbitsll(x) __builtin_popcountll(x) #define all(x) x.begin(), x.end() #define pii pair<int, int> inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } inline int power(ll a, ll n, ll m) { if (n == 0) return 1; ll p = power(a, n / 2, m); p = (p % m * p % m) % m; if (n % 2) return (p % m * a % m) % m; else return p; } const double EPS = 1e-9; const ll MOD = 998244353; const ll hell = 1000000007; const int INF = 1e8; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; auto seed = chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng(seed); double startTime; double getCurrentTime() { return ((double)clock() - startTime) / CLOCKS_PER_SEC; } const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; const int N = 100005; int dp[3005][3005][2]; void solve() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int l = 1; l <= n; l++) { for (int i = 0; i <= n - l; i++) { int j = i + l - 1; if (i == j) { dp[i][j][0] = a[i]; dp[i][j][1] = -a[i]; continue; } dp[i][j][0] = max(a[i] + dp[i + 1][j][1], a[j] + dp[i][j - 1][1]); dp[i][j][1] = min(-a[i] + dp[i + 1][j][0], -a[j] + dp[i][j - 1][0]); } } cout << dp[0][n - 1][0] << endl; } int32_t main() { IOS; int t; t = 1; // cin>>t; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functional> using namespace std; using namespace __gnu_pbds; typedef long long ll; #define int long long int typedef complex<long double> cd; const long double pi = acos(-1); typedef double db; typedef long double ldb; typedef pair<int, int> pii; typedef pair<db, db> pdd; typedef vector<int> vi; typedef vector<vector<int>> matrix; #define m1 make_pair #define pb push_back #define flush fflush(stdout) #define IOS \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define reset(x, v) memset(x, v, sizeof(x)) #define fi first #define se second #define endl "\n" #define debug(x) (cerr << #x << ": " << x << "\n") #define setbits(x) __builtin_popcount(x) #define setbitsll(x) __builtin_popcountll(x) #define all(x) x.begin(), x.end() #define pii pair<int, int> inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } inline int power(ll a, ll n, ll m) { if (n == 0) return 1; ll p = power(a, n / 2, m); p = (p % m * p % m) % m; if (n % 2) return (p % m * a % m) % m; else return p; } const double EPS = 1e-9; const ll MOD = 998244353; const ll hell = 1000000007; const int INF = 1e8; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; auto seed = chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng(seed); double startTime; double getCurrentTime() { return ((double)clock() - startTime) / CLOCKS_PER_SEC; } const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; const int N = 100005; int dp[3005][3005][2]; void solve() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int l = 1; l <= n; l++) { for (int i = 0; i <= n - l; i++) { int j = i + l - 1; if (i == j) { dp[i][j][0] = a[i]; dp[i][j][1] = -a[i]; continue; } dp[i][j][0] = max(a[i] + dp[i + 1][j][1], a[j] + dp[i][j - 1][1]); dp[i][j][1] = min(-a[i] + dp[i + 1][j][0], -a[j] + dp[i][j - 1][0]); } } cout << dp[0][n - 1][0] << endl; } int32_t main() { IOS; int t; t = 1; // cin>>t; while (t--) { solve(); } return 0; }
[]
979,355
979,356
u314476982
cpp
p03171
#include <bits/stdc++.h> using namespace std; int n; long long dp[4096][4096]; int a[4096], vis[4096][4096]; long long calc(int l, int r, int turn) { auto &y = dp[l][r]; if (vis[l][r]) return y; vis[l][r] = 1; if (l == r) return y = (turn == 0 ? a[l] : -a[l]); if (turn == 0) { return max(a[l] + calc(l + 1, r, 1), a[r] + calc(l, r - 1, 1)); } else { return min(calc(l + 1, r, 0) - a[l], calc(l, r - 1, 0) - a[r]); } } int main() { memset(dp, -1, sizeof(dp)); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } cout << calc(1, n, 0) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; long long dp[4096][4096]; int a[4096], vis[4096][4096]; long long calc(int l, int r, int turn) { auto &y = dp[l][r]; if (vis[l][r]) return y; vis[l][r] = 1; if (l == r) return y = (turn == 0 ? a[l] : -a[l]); if (turn == 0) { return y = max(a[l] + calc(l + 1, r, 1), a[r] + calc(l, r - 1, 1)); } else { return y = min(calc(l + 1, r, 0) - a[l], calc(l, r - 1, 0) - a[r]); } } int main() { memset(dp, -1, sizeof(dp)); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } cout << calc(1, n, 0) << endl; return 0; }
[ "assignment.change" ]
979,357
979,358
u863749525
cpp
p03171
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for (int i = a; i <= b; i++) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)x.size() #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; int n, x; vector<ll> a; ll dp[3001][3001][2]; int calc(int l, int r, int t) { if (dp[l][r][t] != -1) return dp[l][r][t]; if (l == r) return dp[l][r][t] = (t ? a[l] : -a[l]); if (t) { if (a[l] + (dp[l + 1][r][0] = calc(l + 1, r, 0)) > a[r] + (dp[l][r - 1][0] = calc(l, r - 1, 0))) { return dp[l][r][t] = a[l] + dp[l + 1][r][0]; } else return dp[l][r][t] = a[r] + dp[l][r - 1][0]; } else { if (-a[l] + (dp[l + 1][r][1] = calc(l + 1, r, 1)) < -a[r] + (dp[l][r - 1][1] = calc(l, r - 1, 1))) { return dp[l][r][t] = -a[l] + dp[l + 1][r][1]; } else return dp[l][r][t] = -a[r] + dp[l][r - 1][1]; } } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); cin.sync_with_stdio(0); cin.tie(); cin.exceptions(cin.failbit); cin >> n; rep(i, 1, n) { cin >> x; a.pb(x); } rep(i, 0, n - 1) { rep(j, i, n - 1) { dp[i][j][0] = -1; dp[i][j][1] = -1; } } cout << calc(0, n - 1, 1); }
#include "bits/stdc++.h" using namespace std; #define rep(i, a, b) for (int i = a; i <= b; i++) #define trav(a, x) for (auto &a : x) #define all(x) begin(x), end(x) #define sz(x) (int)x.size() #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; ll n, x; vector<ll> a; ll dp[3001][3001][2]; ll calc(int l, int r, int t) { if (dp[l][r][t] != -1) return dp[l][r][t]; if (l == r) return dp[l][r][t] = (t ? a[l] : -a[l]); if (t) { if (a[l] + (dp[l + 1][r][0] = calc(l + 1, r, 0)) > a[r] + (dp[l][r - 1][0] = calc(l, r - 1, 0))) { return dp[l][r][t] = a[l] + dp[l + 1][r][0]; } else return dp[l][r][t] = a[r] + dp[l][r - 1][0]; } else { if (-a[l] + (dp[l + 1][r][1] = calc(l + 1, r, 1)) < -a[r] + (dp[l][r - 1][1] = calc(l, r - 1, 1))) { return dp[l][r][t] = -a[l] + dp[l + 1][r][1]; } else return dp[l][r][t] = -a[r] + dp[l][r - 1][1]; } } int main() { // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); cin.sync_with_stdio(0); cin.tie(); cin.exceptions(cin.failbit); cin >> n; rep(i, 1, n) { cin >> x; a.pb(x); } rep(i, 0, n - 1) { rep(j, i, n - 1) { dp[i][j][0] = -1; dp[i][j][1] = -1; } } cout << calc(0, n - 1, 1); }
[ "variable_declaration.type.change" ]
979,361
979,362
u028221335
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define w(t) \ int t; \ cin >> t; \ while (t--) #define pb push_back #define mk make_pair #define u_s unordered_set #define endl "\n" #define prDouble(x) cout << fixed << setprecision(10) << x #define ll long long int #define ipair pair<int, int> #define all(x) (x).begin(), (x).end() const int mod = pow(10, 9) + 7; bool compare(pair<int, int> p1, pair<int, int> p2) { return p1.second < p2.first; } void open_file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } /* ll C(ll n,ll k){ if(k>n)return 0; ll ans=1; if(k>n-k) k=n-k; for(ll i=1;i<=k;i++) ans*=(n-i+1),ans/=i; return ans; } unsigned long long fact(long long a) { unsigned long long res=1; for(long long i=a;i>0;i--) res*=i; return res; } unsigned long long comb(long long a,long long b) { if((a-b)<b) b=a-b; if(a<=19) return fact(a)/(fact(a-b)*fact(b)); if(a==b||b==0) return 1; if(b==1) return a; return comb(a-1,b-1)+comb(a-1,b); } */ ll dp[3005][3005]; ll game(vector<int> &A, int i, int j, int player) { if (i > j) return 0; if (dp[i][j] != -1) return dp[i][j]; if (player == 1) { return dp[i][j] = max(A[i] + game(A, i + 1, j, 2), A[j] + game(A, i, j - 1, 2)); } else return dp[i][j] = min(game(A, i + 1, j, 1), game(A, i, j - 1, 2)); } void solve() { memset(dp, -1, sizeof dp); int n; cin >> n; ll sum = 0; vector<int> A(n); for (int i = 0; i < n; i++) cin >> A[i], sum += A[i]; ll X = game(A, 0, n - 1, 1); ll Y = sum - X; cout << X - Y; } int main() { // open_file(); fast_io(); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define w(t) \ int t; \ cin >> t; \ while (t--) #define pb push_back #define mk make_pair #define u_s unordered_set #define endl "\n" #define prDouble(x) cout << fixed << setprecision(10) << x #define ll long long int #define ipair pair<int, int> #define all(x) (x).begin(), (x).end() const int mod = pow(10, 9) + 7; bool compare(pair<int, int> p1, pair<int, int> p2) { return p1.second < p2.first; } void open_file() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } /* ll C(ll n,ll k){ if(k>n)return 0; ll ans=1; if(k>n-k) k=n-k; for(ll i=1;i<=k;i++) ans*=(n-i+1),ans/=i; return ans; } unsigned long long fact(long long a) { unsigned long long res=1; for(long long i=a;i>0;i--) res*=i; return res; } unsigned long long comb(long long a,long long b) { if((a-b)<b) b=a-b; if(a<=19) return fact(a)/(fact(a-b)*fact(b)); if(a==b||b==0) return 1; if(b==1) return a; return comb(a-1,b-1)+comb(a-1,b); } */ ll dp[3005][3005]; ll game(vector<int> &A, int i, int j, int player) { if (i > j) return 0; if (dp[i][j] != -1) return dp[i][j]; if (player == 1) { return dp[i][j] = max(A[i] + game(A, i + 1, j, 2), A[j] + game(A, i, j - 1, 2)); } else return dp[i][j] = min(game(A, i + 1, j, 1), game(A, i, j - 1, 1)); } void solve() { memset(dp, -1, sizeof dp); int n; cin >> n; ll sum = 0; vector<int> A(n); for (int i = 0; i < n; i++) cin >> A[i], sum += A[i]; ll X = game(A, 0, n - 1, 1); ll Y = sum - X; cout << X - Y; } int main() { // open_file(); fast_io(); solve(); return 0; }
[ "literal.number.change", "assignment.value.change", "call.arguments.change", "function.return_value.change" ]
979,369
979,370
u294187638
cpp
p03171
#include <iostream> using namespace std; long long int dp[3000][3000][2]; int main() { long long int n, s = 0; cin >> n; long long int a[n], i; for (i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } for (i = 0; i < n; i++) { dp[i][i][0] = a[i]; dp[i][i][1] = 0; } for (long long int rminusl = 1; rminusl < n; rminusl++) { for (long long int l = 1; l < n - rminusl; l++) { long long int r = l + rminusl; dp[l][r][0] = max(a[l] + dp[l + 1][r][1], a[r] + dp[l][r - 1][1]); dp[l][r][1] = min(dp[l + 1][r][0], dp[l][r - 1][0]); } } long long int x = 2 * dp[0][n - 1][0] - s; cout << x << endl; return 0; }
#include <iostream> using namespace std; long long int dp[3000][3000][2]; int main() { long long int n, s = 0; cin >> n; long long int a[n], i; for (i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } for (i = 0; i < n; i++) { dp[i][i][0] = a[i]; dp[i][i][1] = 0; } for (long long int rminusl = 1; rminusl < n; rminusl++) { for (long long int l = 0; l < n - rminusl; l++) { long long int r = l + rminusl; dp[l][r][0] = max(a[l] + dp[l + 1][r][1], a[r] + dp[l][r - 1][1]); dp[l][r][1] = min(dp[l + 1][r][0], dp[l][r - 1][0]); } } long long int x = 2 * dp[0][n - 1][0] - s; cout << x << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
979,371
979,372
u636182200
cpp
p03171
#include <bits/stdc++.h> #define ll long long using namespace std; ll dp[3005][3005]; int solve(ll arr[], int i, int j) { if (j < i) return 0; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = max(arr[i] + min(solve(arr, i + 2, j), solve(arr, i + 1, j - 1)), arr[j] + min(solve(arr, i + 1, j - 1), solve(arr, i, j - 2))); } int main() { int n; cin >> n; memset(dp, -1, sizeof dp); ll arr[n]; ll sum = 0; for (int i = 0; i < n; i++) cin >> arr[i], sum += arr[i]; cout << 2 * solve(arr, 0, n - 1) - sum; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; ll dp[3005][3005]; ll solve(ll arr[], int i, int j) { if (j < i) return 0; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = max(arr[i] + min(solve(arr, i + 2, j), solve(arr, i + 1, j - 1)), arr[j] + min(solve(arr, i + 1, j - 1), solve(arr, i, j - 2))); } int main() { int n; cin >> n; memset(dp, -1, sizeof dp); ll arr[n]; ll sum = 0; for (int i = 0; i < n; i++) cin >> arr[i], sum += arr[i]; // cout<<solve(arr,0,n-1)<<endl; cout << 2 * solve(arr, 0, n - 1) - sum; return 0; }
[]
979,373
979,374
u746113754
cpp
p03171
#include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; #include <algorithm> #include <iomanip> #include <map> #include <math.h> #include <queue> #include <set> #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) const ll INF = 1000000007; double dp[3001][3001]; int flag[3001][3001]; vector<int> a(3001); int f(int l, int r) { if (flag[l][r]) return dp[l][r]; flag[l][r] = 1; if (l == r) return dp[l][r] = a[l]; return dp[l][r] = max(a[l] - f(l + 1, r), a[r] - f(l, r - 1)); } int main() { int n; cin >> n; rep(i, n) cin >> a[i]; int ans = f(0, n - 1); cout << ans; return 0; }
#include <iostream> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; #include <algorithm> #include <iomanip> #include <map> #include <math.h> #include <queue> #include <set> #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) const ll INF = 1000000007; ll dp[3001][3001]; int flag[3001][3001]; vector<ll> a(3001); ll f(int l, int r) { if (flag[l][r]) return dp[l][r]; flag[l][r] = 1; if (l == r) return dp[l][r] = a[l]; return dp[l][r] = max(a[l] - f(l + 1, r), a[r] - f(l, r - 1)); } int main() { int n; cin >> n; rep(i, n) cin >> a[i]; ll ans = (f(0, n - 1)); cout << ans; return 0; }
[ "variable_declaration.type.change" ]
979,379
979,380
u872982453
cpp
p03171
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3005; int a[N]; ll memo[N][N][3]; bool vis[N][N][3]; ll dp(int l, int r, int t) { if (vis[l][r][t]) return memo[l][r][t]; if (l > r) return 0LL; ll ans = 0; if (t == 0) { ans = max(a[l] + dp(l + 1, r, 1), a[r] + dp(l, r - 1, 1)); } else { ans = min(-a[l] + dp(l + 1, r, 0), -a[r] + dp(l, r - 1, 0)); } vis[l][r][t] = true; return memo[l][r][3] = ans; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << dp(0, n - 1, 0) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3005; int a[N]; ll memo[N][N][3]; bool vis[N][N][3]; ll dp(int l, int r, int t) { if (vis[l][r][t]) return memo[l][r][t]; if (l > r) return 0LL; ll ans; if (t == 0) { ans = max(a[l] + dp(l + 1, r, 1), a[r] + dp(l, r - 1, 1)); } else { ans = min(-a[l] + dp(l + 1, r, 0), -a[r] + dp(l, r - 1, 0)); } vis[l][r][t] = true; return memo[l][r][t] = ans; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << dp(0, n - 1, 0) << "\n"; return 0; }
[ "assignment.variable.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "function.return_value.change" ]
979,383
979,384
u671909055
cpp
p03171
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3005; int a[N]; ll memo[N][N][3]; bool vis[N][N][3]; ll dp(int l, int r, int t) { if (vis[l][r][t]) return memo[l][r][t]; if (l > r) return 0LL; ll ans; if (t == 0) { ans = max(a[l] + dp(l + 1, r, 1), a[r] + dp(l, r - 1, 1)); } else { ans = min(-a[l] + dp(l + 1, r, 0), -a[r] + dp(l, r - 1, 0)); } vis[l][r][t] = true; return memo[l][r][3] = ans; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << dp(0, n - 1, 0) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3005; int a[N]; ll memo[N][N][3]; bool vis[N][N][3]; ll dp(int l, int r, int t) { if (vis[l][r][t]) return memo[l][r][t]; if (l > r) return 0LL; ll ans; if (t == 0) { ans = max(a[l] + dp(l + 1, r, 1), a[r] + dp(l, r - 1, 1)); } else { ans = min(-a[l] + dp(l + 1, r, 0), -a[r] + dp(l, r - 1, 0)); } vis[l][r][t] = true; return memo[l][r][t] = ans; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << dp(0, n - 1, 0) << "\n"; return 0; }
[ "assignment.variable.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "function.return_value.change" ]
979,385
979,384
u671909055
cpp
p03171
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3005; ll a[N]; ll memo[N][N][3]; bool vis[N][N][3]; ll dp(int l, int r, int t) { if (vis[l][r][t]) return memo[l][r][t]; if (l > r) return 0; ll ans; if (t == 0) { ans = max(a[l] + dp(l + 1, r, 1), a[r] + dp(l, r - 1, 1)); } else { ans = min(-a[l] + dp(l + 1, r, 0), -a[r] + dp(l, r - 1, 0)); } vis[l][r][t] = true; return memo[l][r][3] = ans; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << dp(0, n - 1, 0) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3005; int a[N]; ll memo[N][N][3]; bool vis[N][N][3]; ll dp(int l, int r, int t) { if (vis[l][r][t]) return memo[l][r][t]; if (l > r) return 0LL; ll ans; if (t == 0) { ans = max(a[l] + dp(l + 1, r, 1), a[r] + dp(l, r - 1, 1)); } else { ans = min(-a[l] + dp(l + 1, r, 0), -a[r] + dp(l, r - 1, 0)); } vis[l][r][t] = true; return memo[l][r][t] = ans; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << dp(0, n - 1, 0) << "\n"; return 0; }
[ "variable_declaration.type.change", "literal.number.type.widen.change", "assignment.variable.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "function.return_value.change" ]
979,386
979,384
u671909055
cpp
p03171
#include <bits/stdc++.h> using namespace std; long long dp[3005][3005]; long long calc(long long a[], int l, int r) { if (l > r) return 0; if (dp[l][r] != -1) return dp[l][r]; return dp[l][r] = max(a[l] + min(calc(a, l + 2, r), calc(a, l + 1, r - 1)), a[r] + min(calc(a, l + 1, r - 1), calc(a, l, r - 2))); } int main() { int n; cin >> n; long long a[n], s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } memset(dp, -1, sizeof(dp)); cout << s - 2 * calc(a, 0, n - 1) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long dp[3005][3005]; long long calc(long long a[], int l, int r) { if (l > r) return 0; if (dp[l][r] != -1) return dp[l][r]; return dp[l][r] = max(a[l] + min(calc(a, l + 2, r), calc(a, l + 1, r - 1)), a[r] + min(calc(a, l + 1, r - 1), calc(a, l, r - 2))); } int main() { int n; cin >> n; long long a[n], s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } memset(dp, -1, sizeof(dp)); cout << 2 * calc(a, 0, n - 1) - s << endl; return 0; }
[ "expression.operation.binary.remove" ]
979,387
979,388
u912221417
cpp
p03171
#include <bits/stdc++.h> using namespace std; long long dp[3005][3005]; long long calc(long long a[], int l, int r) { if (l > r) return 0; if (dp[l][r] != -1) return dp[l][r]; return dp[l][r] = max(a[l] + min(calc(a, l + 2, r), calc(a, l + 1, r - 1)), a[r] + min(calc(a, l + 1, r - 1), calc(a, l, r - 2))); } int main() { int n; cin >> n; long long a[n], s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } memset(dp, -1, sizeof(dp)); cout << abs(s - 2 * calc(a, 0, n - 1)) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long dp[3005][3005]; long long calc(long long a[], int l, int r) { if (l > r) return 0; if (dp[l][r] != -1) return dp[l][r]; return dp[l][r] = max(a[l] + min(calc(a, l + 2, r), calc(a, l + 1, r - 1)), a[r] + min(calc(a, l + 1, r - 1), calc(a, l, r - 2))); } int main() { int n; cin >> n; long long a[n], s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } memset(dp, -1, sizeof(dp)); cout << 2 * calc(a, 0, n - 1) - s << endl; return 0; }
[ "call.remove", "io.output.change" ]
979,389
979,388
u912221417
cpp
p03171
#include <bits/stdc++.h> using namespace std; int dp[3001][3001][2]; int solve(vector<int> &arr, int i, int j, int turn) { if (i > j) return 0; if (dp[i][j][turn] != -1) return dp[i][j][turn]; if (turn == 1) { return dp[i][j][turn] = max(arr[i] + solve(arr, i + 1, j, 0), arr[j] + solve(arr, i, j - 1, 0)); } else return dp[i][j][turn] = min(solve(arr, i + 1, j, 1), solve(arr, i, j - 1, 1)); } int main() { int n; cin >> n; vector<int> arr(n + 1); memset(dp, -1, sizeof dp); long long sum = 0; for (int i = 1; i <= n; i++) { cin >> arr[i]; sum += arr[i]; } long long x = solve(arr, 1, n, 1); long long y = sum - x; cout << x - y; return 0; }
#include <bits/stdc++.h> using namespace std; long long dp[3001][3001][2]; long long solve(vector<int> &arr, int i, int j, int turn) { if (i > j) return 0; if (dp[i][j][turn] != -1) return dp[i][j][turn]; if (turn == 1) { return dp[i][j][turn] = max(arr[i] + solve(arr, i + 1, j, 0), arr[j] + solve(arr, i, j - 1, 0)); } else return dp[i][j][turn] = min(solve(arr, i + 1, j, 1), solve(arr, i, j - 1, 1)); } int main() { int n; cin >> n; vector<int> arr(n + 1); memset(dp, -1, sizeof dp); long long sum = 0; for (int i = 1; i <= n; i++) { cin >> arr[i]; sum += arr[i]; } long long x = solve(arr, 1, n, 1); long long y = sum - x; cout << x - y; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,392
979,393
u495505677
cpp
p03171
#include <bits/stdc++.h> #define ll long long #define endl "\n" #define vi vector<int> #define vvi vector<vector<int>> #define FASTIO \ ios_base::sync_with_stdio(NULL); \ cin.tie(NULL); #define FOR(i, n) for (int i = 0; i < n; i++) #define FORE(i, a, b) for (int i = a; i <= b; i++) #define pb push_back #define MOD 1000000007 using namespace std; void init() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } // code from below ll dp[3001][3001]; void solve() { ll n; cin >> n; vector<ll> arr(n); FOR(i, n) cin >> arr[i]; // dp[i][j] stores the x-y value if both players play optimally, considering // subarr from i to j of arr thus we have n^2 sub array thus dp is of n^2 size for (int L = n - 1; L >= 0; L--) { for (int R = L; R < n; R++) { if (L == R) dp[L][R] = arr[R]; else { dp[L][R] = max(arr[L] - dp[L + 1][R], arr[R] - dp[L][R - 1]); } } } cout << dp[0][n - 1] << endl; } int main() { int t = 1; cin >> t; // cin.ignore(numeric_limits<streamsize>::max(),'\n'); while (t--) solve(); }
#include <bits/stdc++.h> #define ll long long #define endl "\n" #define vi vector<int> #define vvi vector<vector<int>> #define FASTIO \ ios_base::sync_with_stdio(NULL); \ cin.tie(NULL); #define FOR(i, n) for (int i = 0; i < n; i++) #define FORE(i, a, b) for (int i = a; i <= b; i++) #define pb push_back #define MOD 1000000007 using namespace std; void init() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } // code from below ll dp[3001][3001]; void solve() { ll n; cin >> n; vector<ll> arr(n); FOR(i, n) cin >> arr[i]; // dp[i][j] stores the x-y value if both players play optimally, considering // subarr from i to j of arr thus we have n^2 sub array thus dp is of n^2 size for (int L = n - 1; L >= 0; L--) { for (int R = L; R < n; R++) { if (L == R) dp[L][R] = arr[R]; else { dp[L][R] = max(arr[L] - dp[L + 1][R], arr[R] - dp[L][R - 1]); } } } cout << dp[0][n - 1] << endl; } int main() { int t = 1; // cin>>t; // cin.ignore(numeric_limits<streamsize>::max(),'\n'); while (t--) solve(); }
[]
979,394
979,395
u372662491
cpp
p03171
// #pragma GCC optimize "trapv" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define vvi vector<vector<int>> #define vvll vector<vector<ll>> #define map map<ll, ll> #define umap unordered_map<ll, ll> #define endl "\n" #define set set<ll> #define setC set<char> #define all(x) x.begin(), x.end() #define fast \ ios::sync_with_stdio(0); \ cin.tie(0); #define fastcout \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define testcases \ int tt = 1; \ cin >> tt; \ for (int i = 1; i <= tt; ++i) #define codejam cout << "Case #" << i << ": "; #define FOR(i, a, n) for (int i = a; i <= n; ++i) #define FORback(i, a, n) for (int i = n; i >= a; --i) #define ll long long int const ll INF = 1e13 + 7; const ll mod = 1e9 + 7; vvll dp; ll doSome(vll &arr, int i, int j) { if (i == j) { return dp[i][j] = arr[i]; } if (j == i + 1) { return dp[i][j] = max(arr[i], arr[j]); } if (dp[i][j] != -1) return dp[i][j]; // 1 2 3 ll a = arr[i] + min(doSome(arr, i + 2, j), doSome(arr, i + 1, j - 1)); ll b = arr[j] + min(doSome(arr, i + 1, j - 1), doSome(arr, i, j - 2)); return dp[i][j] = max(a, b); } void solv() { ll n; cin >> n; vll arr(n); FOR(i, 0, n - 1) { cin >> arr[i]; } dp.assign(n + 1, vll(n + 1, -1)); ll sum = accumulate(all(arr), 0LL); ll val = doSome(arr, 0, n - 1); cout << abs(2 * val - sum) << endl; } int main() { fast; // testcases{ // codejam ; solv(); // } }
// #pragma GCC optimize "trapv" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define vll vector<ll> #define vpll vector<pair<ll, ll>> #define vvi vector<vector<int>> #define vvll vector<vector<ll>> #define map map<ll, ll> #define umap unordered_map<ll, ll> #define endl "\n" #define set set<ll> #define setC set<char> #define all(x) x.begin(), x.end() #define fast \ ios::sync_with_stdio(0); \ cin.tie(0); #define fastcout \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define testcases \ int tt = 1; \ cin >> tt; \ for (int i = 1; i <= tt; ++i) #define codejam cout << "Case #" << i << ": "; #define FOR(i, a, n) for (int i = a; i <= n; ++i) #define FORback(i, a, n) for (int i = n; i >= a; --i) #define ll long long int const ll INF = 1e13 + 7; const ll mod = 1e9 + 7; vvll dp; ll doSome(vll &arr, int i, int j) { if (i == j) { return dp[i][j] = arr[i]; } if (j == i + 1) { return dp[i][j] = max(arr[i], arr[j]); } if (dp[i][j] != -1) return dp[i][j]; // 1 2 3 ll a = arr[i] + min(doSome(arr, i + 2, j), doSome(arr, i + 1, j - 1)); ll b = arr[j] + min(doSome(arr, i + 1, j - 1), doSome(arr, i, j - 2)); return dp[i][j] = max(a, b); } void solv() { ll n; cin >> n; vll arr(n); FOR(i, 0, n - 1) { cin >> arr[i]; } dp.assign(n + 1, vll(n + 1, -1)); ll sum = accumulate(all(arr), 0LL); ll val = doSome(arr, 0, n - 1); cout << 2 * val - sum << endl; } int main() { fast; // testcases{ // codejam ; solv(); // } }
[ "call.remove", "call.arguments.change" ]
979,400
979,401
u703699388
cpp
p03171
#include <bits/stdc++.h> #define ll long long #define PB push_back #define MP make_pair #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define FOR(i, l, h) for (int i = (int)(l); i <= (int)(h); ++i) #define FORD(i, h, l) for (int i = (int)(h); i >= (int)(l); --i) //#define max(a,b) a>b?a:b //#define min(a,b) a>b?b:a ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define dump(x) cerr << #x << " = " << (x) << endl #define ALL(t) (t).begin(), (t).end() using namespace std; #define error(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ err(_it, args); \ } void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } int sum() { return 0; } template <typename T, typename... Args> T sum(T a, Args... args) { return a + sum(args...); } const int nax = 3003; ll dp[nax][nax][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; std::vector<ll> a(n); ll sum = 0; REP(i, n) { cin >> a[i]; sum += a[i]; } REP(i, n) { dp[i][i][0] = a[i]; dp[i][i][1] = 0; } for (int ad = 0; ad < n; ad++) { for (int i = 0; i < n - ad; i++) { int j = i + ad; dp[i][j][0] = max(dp[i + 1][j][1] + a[i], dp[i][j - 1][1] + a[j]); dp[i][j][1] = min(dp[i + 1][j][0], dp[i][j - 1][0]); } } std::cout << (2 * dp[0][n - 1][0]) - sum << "\n"; return 0; }
#include <bits/stdc++.h> #define ll long long #define PB push_back #define MP make_pair #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define FOR(i, l, h) for (int i = (int)(l); i <= (int)(h); ++i) #define FORD(i, h, l) for (int i = (int)(h); i >= (int)(l); --i) //#define max(a,b) a>b?a:b //#define min(a,b) a>b?b:a ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } #define dump(x) cerr << #x << " = " << (x) << endl #define ALL(t) (t).begin(), (t).end() using namespace std; #define error(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ err(_it, args); \ } void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } int sum() { return 0; } template <typename T, typename... Args> T sum(T a, Args... args) { return a + sum(args...); } const int nax = 3003; ll dp[nax][nax][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin >> n; std::vector<ll> a(n); ll sum = 0; REP(i, n) { cin >> a[i]; sum += a[i]; } REP(i, n) { dp[i][i][0] = a[i]; dp[i][i][1] = 0; } for (ll ad = 1; ad < n; ad++) { for (ll i = 0; i < n - ad; i++) { ll j = i + ad; dp[i][j][0] = max(dp[i + 1][j][1] + a[i], dp[i][j - 1][1] + a[j]); dp[i][j][1] = min(dp[i + 1][j][0], dp[i][j - 1][0]); } } // REP(i,n){REP(j,n){cout<<dp[i][j][0]<<" ";}cout << "\n";} std::cout << (2 * dp[0][n - 1][0]) - sum << "\n"; return 0; }
[ "variable_declaration.type.change", "control_flow.loop.for.initializer.change", "literal.number.change", "variable_declaration.value.change", "expression.off_by_one" ]
979,402
979,403
u172654033
cpp
p03171
#include <bits/stdc++.h> #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define mp make_pair #define pb push_back #define forN(i, n) for (int i = 1; i <= n; ++i) #define endl "\n" typedef long long ll; using namespace std; const ll INF = 1e18; const int N = 3005; int n, A[N], DP[N][N]; /* ll taro = max(calc(i+1,j)+A[i],calc(i,j-1)+A[j]); ll jaro = min(calc(i+1,j)+A[i],calc(i,j-1)+A[j]); */ int calc(int i, int j) { if (i == j) return A[i]; if (DP[i][j] != -1) return DP[i][j]; ll left = A[i] - calc(i + 1, j); ll right = A[j] - calc(i, j - 1); return DP[i][j] = max(left, right); } int main() { fastIO; cin >> n; forN(i, n) cin >> A[i]; memset(DP, -1, sizeof DP); cout << calc(1, n); }
#include <bits/stdc++.h> #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define mp make_pair #define pb push_back #define forN(i, n) for (int i = 1; i <= n; ++i) #define endl "\n" typedef long long ll; using namespace std; const ll INF = 1e18; const int N = 3005; ll n, A[N], DP[N][N]; /* ll taro = max(calc(i+1,j)+A[i],calc(i,j-1)+A[j]); ll jaro = min(calc(i+1,j)+A[i],calc(i,j-1)+A[j]); */ ll calc(int i, int j) { if (i == j) return A[i]; if (DP[i][j] != -1) return DP[i][j]; ll left = A[i] - calc(i + 1, j); ll right = A[j] - calc(i, j - 1); return DP[i][j] = max(left, right); } int main() { fastIO; cin >> n; forN(i, n) cin >> A[i]; memset(DP, -1, sizeof DP); cout << calc(1, n); }
[ "variable_declaration.type.change" ]
979,404
979,405
u092350256
cpp
p03171
#include <bits/stdc++.h> #define int long long #define double long double #define endl '\n' #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " int32_t main() { IOS; int n; cin >> n; vector<int> arr(n); for (int &i : arr) cin >> i; vector<vector<int>> dp(n + 2, vector<int>(n + 2, 0)); for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (i == j) { dp[i][j] = arr[i]; } else { dp[i][j] = max(arr[i] + dp[i + 1][j], arr[j] + (j > 0 ? dp[i][j - 1] : 0)); } } } cout << dp[0][n - 1] << endl; return 0; }
#include <bits/stdc++.h> #define int long long #define double long double #define endl '\n' #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " int32_t main() { IOS; int n; cin >> n; vector<int> arr(n); for (int &i : arr) cin >> i; vector<vector<int>> dp(n + 2, vector<int>(n + 2, 0)); for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (i == j) { dp[i][j] = arr[i]; } else { dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - (j > 0 ? dp[i][j - 1] : 0)); } } } cout << dp[0][n - 1] << endl; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
979,406
979,407
u287226050
cpp
p03171
#include <bits/stdc++.h> #define endl '\n' #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " signed main() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } vector<vector<int>> dp(n + 2, vector<int>(n + 2, 0)); for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (i == j) dp[i][j] = arr[i]; else dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]); } } cout << dp[0][n - 1] << endl; return 0; }
#include <bits/stdc++.h> #define int long long #define endl '\n' #define IOS \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " signed main() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } vector<vector<int>> dp(n + 2, vector<int>(n + 2, 0)); for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (i == j) dp[i][j] = arr[i]; else dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]); } } cout << dp[0][n - 1] << endl; return 0; }
[]
979,408
979,409
u287226050
cpp
p03171
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N; vector<int> a(N); vector<vector<int>> dp(N, vector<int>(N, 0)); for (int i = 0; i < N; ++i) { cin >> a[i]; dp[i][i] = a[i]; } for (int L = N - 2; L >= 0; --L) for (int R = L + 1; R < N; ++R) dp[L][R] = max(a[L] - dp[L + 1][R], a[R] - dp[L][R - 1]); cout << dp[0][N - 1]; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N; vector<int> a(N); vector<vector<long long>> dp(N, vector<long long>(N, 0)); for (int i = 0; i < N; ++i) { cin >> a[i]; dp[i][i] = a[i]; } for (int L = N - 2; L >= 0; --L) for (int R = L + 1; R < N; ++R) dp[L][R] = max(a[L] - dp[L + 1][R], a[R] - dp[L][R - 1]); cout << dp[0][N - 1]; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,410
979,411
u934482833
cpp
p03171
#include <bits/stdc++.h> using namespace std; int n, x; vector<int> V; int dp[3010][3010]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; V.push_back(x); } for (int L = n - 1; L >= 0; L--) { for (int R = L; R < n; R++) { if (L == R) dp[L][R] = V[L]; else { dp[L][R] = max(V[R] - dp[L][R - 1], V[L] - dp[L + 1][R]); } } } cout << dp[0][n - 1]; }
#include <bits/stdc++.h> using namespace std; int n, x; vector<int> V; long long dp[3010][3010]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; V.push_back(x); } for (int L = n - 1; L >= 0; L--) { for (int R = L; R < n; R++) { if (L == R) dp[L][R] = V[L]; else { dp[L][R] = max(V[R] - dp[L][R - 1], V[L] - dp[L + 1][R]); } } } cout << dp[0][n - 1]; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,414
979,415
u026200720
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e16 + 7; int mod = 998244353; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int dp[3005][3005]; signed main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i]; for (int i = 1; i <= N; i++) { for (int j = 0; i + j <= N; j++) { int k = i + j; if ((N - i) % 2 == 0) { dp[j][k] = max(dp[j + 1][k] + a[j], dp[j][k - 1] + a[k - 1]); } else { dp[j][k] = min(dp[j + 1][k] - a[j], dp[j][k - 1] + a[k - 1]); } } } cout << dp[0][N] << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e16 + 7; int mod = 998244353; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int dp[3005][3005]; signed main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i]; for (int i = 1; i <= N; i++) { for (int j = 0; i + j <= N; j++) { int k = i + j; if ((N - i) % 2 == 0) { dp[j][k] = max(dp[j + 1][k] + a[j], dp[j][k - 1] + a[k - 1]); } else { dp[j][k] = min(dp[j + 1][k] - a[j], dp[j][k - 1] - a[k - 1]); } } } cout << dp[0][N] << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
979,425
979,426
u237390401
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define AC ios::sync_with_stdio(0), cin.tie(0); #define ll long long int int dp[3015][3015]; int a[3015]; int main() { AC int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { dp[i][i] = 0; } for (int k = 1; k <= n; k++) { for (int j = 0; j + k <= n; j++) { int r = j + k; if (k % 2 == n % 2) dp[j][r] = max(dp[j + 1][r] + a[j], dp[j][r - 1] + a[r - 1]); else dp[j][r] = min(dp[j + 1][r] - a[j], dp[j][r - 1] - a[r - 1]); } } cout << dp[0][n] << endl; }
#include <bits/stdc++.h> using namespace std; #define AC ios::sync_with_stdio(0), cin.tie(0); #define ll long long int ll dp[3015][3015]; ll a[3015]; int main() { AC int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { dp[i][i] = 0; } for (int k = 1; k <= n; k++) { for (int j = 0; j + k <= n; j++) { int r = j + k; if (k % 2 == n % 2) dp[j][r] = max(dp[j + 1][r] + a[j], dp[j][r - 1] + a[r - 1]); else dp[j][r] = min(dp[j + 1][r] - a[j], dp[j][r - 1] - a[r - 1]); } } cout << dp[0][n] << endl; }
[ "variable_declaration.type.change" ]
979,429
979,430
u723744542
cpp
p03171
#include "bits/stdc++.h" using namespace std; #define endl "\n" typedef long long int ll; inline void fastio() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } inline void setPrecision(int n) { cout.precision(n); } // DEBUG #define dbg(x) cerr << (#x) << ": " << x << endl #define dbgV(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << it << " "; \ cerr << endl; #define dbgS(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << it << " "; \ cerr << endl; #define dbgM(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << "[" << it.f << ", " << it.s << "] "; \ cerr << endl; #define dbg2D(x) \ cerr << (#x) << ": \n"; \ for (auto y : x) { \ for (auto it : y) \ cerr << it << " "; \ cerr << endl; \ } \ cerr << endl; #define dbgA(x, n) \ cerr << (#x) << ": "; \ for (int i = 0; i < n; ++i) \ cerr << x[i] << " "; \ cerr << endl; #define dbgVP(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << "[" << it.f << ", " << it.s << "] "; \ cerr << endl; ll INF = 1e10; int MOD = 1e9 + 7; int n; vector<int> a; vector<ll> pre; int dp[3001][3001][2]; ll calcts(int l, int r, int chance) { if (l > r) return 0; if (l == r) return (n % 2 == 1) ? a[l] : 0; ll seg = pre[r + 1] - pre[l]; if (dp[l][r][chance] > 0) return dp[l][r][chance]; if (chance == 0) { ll cr = calcts(l, r - 1, 1) + a[r]; ll cl = calcts(l + 1, r, 1) + a[l]; ll jiroR = seg - cr; ll jiroL = seg - cl; dp[l][r][chance] = (cr - jiroR > cl - jiroL) ? cr : cl; } else { ll taroR = calcts(l, r - 1, 0); ll cr = seg - taroR; ll taroL = calcts(l + 1, r, 0); ll cl = seg - taroL; dp[l][r][chance] = (taroR - cr > taroL - cl) ? taroL : taroR; } return dp[l][r][chance]; } int main() { #ifndef ONLINE_JUDGE freopen("debug.txt", "w", stderr); #endif fastio(); cin >> n; a.resize(n); pre.resize(n + 1); for (int i = 0; i < n; ++i) { cin >> a[i]; pre[i + 1] = pre[i] + a[i]; } memset(dp, -1, sizeof(dp)); ll ts = calcts(0, n - 1, 0); dbg(ts); cout << (2 * ts - pre[n]); return 0; }
#include "bits/stdc++.h" using namespace std; #define endl "\n" typedef long long int ll; inline void fastio() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } inline void setPrecision(int n) { cout.precision(n); } // DEBUG #define dbg(x) cerr << (#x) << ": " << x << endl #define dbgV(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << it << " "; \ cerr << endl; #define dbgS(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << it << " "; \ cerr << endl; #define dbgM(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << "[" << it.f << ", " << it.s << "] "; \ cerr << endl; #define dbg2D(x) \ cerr << (#x) << ": \n"; \ for (auto y : x) { \ for (auto it : y) \ cerr << it << " "; \ cerr << endl; \ } \ cerr << endl; #define dbgA(x, n) \ cerr << (#x) << ": "; \ for (int i = 0; i < n; ++i) \ cerr << x[i] << " "; \ cerr << endl; #define dbgVP(x) \ cerr << (#x) << ": "; \ for (auto it : x) \ cerr << "[" << it.f << ", " << it.s << "] "; \ cerr << endl; ll INF = 1e10; int MOD = 1e9 + 7; int n; vector<int> a; vector<ll> pre; ll dp[3001][3001][2]; ll calcts(int l, int r, int chance) { if (l > r) return 0; if (l == r) return (n % 2 == 1) ? a[l] : 0; ll seg = pre[r + 1] - pre[l]; if (dp[l][r][chance] > 0) return dp[l][r][chance]; if (chance == 0) { ll cr = calcts(l, r - 1, 1) + a[r]; ll cl = calcts(l + 1, r, 1) + a[l]; ll jiroR = seg - cr; ll jiroL = seg - cl; dp[l][r][chance] = (cr - jiroR > cl - jiroL) ? cr : cl; } else { ll taroR = calcts(l, r - 1, 0); ll cr = seg - taroR; ll taroL = calcts(l + 1, r, 0); ll cl = seg - taroL; dp[l][r][chance] = (taroR - cr > taroL - cl) ? taroL : taroR; } return dp[l][r][chance]; } int main() { #ifndef ONLINE_JUDGE freopen("debug.txt", "w", stderr); #endif fastio(); cin >> n; a.resize(n); pre.resize(n + 1); for (int i = 0; i < n; ++i) { cin >> a[i]; pre[i + 1] = pre[i] + a[i]; } memset(dp, -1, sizeof(dp)); ll ts = calcts(0, n - 1, 0); dbg(ts); cout << (2 * ts - pre[n]); return 0; }
[ "variable_declaration.type.change" ]
979,435
979,436
u478784503
cpp
p03171
#include <bits/stdc++.h> #include <deque> #include <string> #include <vector> #define rep(i, N) for (int i = 0; i < (N); ++i) using namespace std; using ll = long long; using P = pair<int, int>; ll INF = 1e18; int N; vector<vector<ll>> dp; vector<ll> a(N); int rec(int l = 0, int r = N) { if (l == r) return 0; ll &ret = dp[l][r]; if (ret != INF) return ret; if ((N - (r - l)) % 2 == 0) { //%の計算順序は意外と早い ret = max(a[l] + rec(l + 1, r), a[r - 1] + rec(l, r - 1)); } else { ret = min(rec(l + 1, r) - a[l], rec(l, r - 1) - a[r - 1]); } return ret; } int main() { cin >> N; a.assign(N, 0); // grobal scope の vectorはすべてこれで初期化しよう rep(i, N) cin >> a[i]; dp.assign(N + 1, vector<ll>(N + 1, INF)); ll ans = rec(0, N); cout << ans << endl; }
#include <bits/stdc++.h> #include <deque> #include <string> #include <vector> #define rep(i, N) for (int i = 0; i < (N); ++i) using namespace std; using ll = long long; using P = pair<int, int>; ll INF = 1e18; int N; vector<vector<ll>> dp; vector<ll> a(N); ll rec(int l = 0, int r = N) { if (l == r) return 0; ll &ret = dp[l][r]; if (ret != INF) return ret; if ((N - (r - l)) % 2 == 0) { //%の計算順序は意外と早い ret = max(a[l] + rec(l + 1, r), a[r - 1] + rec(l, r - 1)); } else { ret = min(rec(l + 1, r) - a[l], rec(l, r - 1) - a[r - 1]); } return ret; } int main() { cin >> N; a.assign(N, 0); // grobal scope の vectorはすべてこれで初期化しよう rep(i, N) cin >> a[i]; dp.assign(N + 1, vector<ll>(N + 1, INF)); ll ans = rec(0, N); cout << ans << endl; }
[]
979,447
979,448
u563170985
cpp
p03171
#include <bits/stdc++.h> using namespace std; #define MAX 3005 int dp[MAX][MAX]; int main() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; for (int R = n - 1; R >= 0; R--) { for (int L = R; L < n; L++) { if (L == R) dp[R][L] = arr[L]; else dp[R][L] = max(arr[R] - dp[R + 1][L], arr[L] - dp[R][L - 1]); } } cout << dp[0][n - 1] << endl; }
#include <bits/stdc++.h> using namespace std; #define MAX 3005 long long dp[MAX][MAX]; int main() { long long n; cin >> n; vector<long long> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; for (int R = n - 1; R >= 0; R--) { for (int L = R; L < n; L++) { if (L == R) dp[R][L] = arr[L]; else dp[R][L] = max(arr[R] - dp[R + 1][L], arr[L] - dp[R][L - 1]); } } cout << dp[0][n - 1] << endl; }
[ "variable_declaration.type.primitive.change", "variable_declaration.type.widen.change" ]
979,449
979,450
u301410695
cpp
p03171
#include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair<lo, lo> PII; #define fi first #define se second #define mp make_pair #define int long long #define pb push_back #define fio() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define FOR for (int i = 1; i <= n; i++) #define mid ((start + end) / 2) #define ort ((bas + son) / 2) const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 1000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 3005; const lo mod = 1000000007; int n, m, b[li], a[li], k, flag, t, dp[li][li][4]; int cev; string s; vector<int> v; inline int f(int l, int r, int kim) { int cevv = 0; if (kim == 0) cevv = -inf; else cevv = inf; if (l > r) return 0; if (~dp[l][r][kim]) return dp[l][r][kim]; if (kim == 0) { cevv = max(cevv, f(l + 1, r, !kim) + a[l]); cevv = max(cevv, f(l, r - 1, !kim) + a[r]); } else { cevv = min(cevv, f(l + 1, r, !kim) - a[l]); cevv = min(cevv, f(l, r - 1, !kim) - a[r]); } return dp[l][r][kim] = cevv; } main(void) { memset(dp, -1, sizeof(dp)); scanf("%lld", &n); FOR { scanf("%lld", &a[i]); } printf("%lld\n", f(1, n, 0)); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair<lo, lo> PII; #define fi first #define se second #define mp make_pair #define int long long #define pb push_back #define fio() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define FOR for (int i = 1; i <= n; i++) #define mid ((start + end) / 2) #define ort ((bas + son) / 2) const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 100000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 3005; const lo mod = 1000000007; int n, m, b[li], a[li], k, flag, t, dp[li][li][4]; int cev; string s; vector<int> v; inline int f(int l, int r, int kim) { int cevv = 0; if (kim == 0) cevv = -inf; else cevv = inf; if (l > r) return 0; if (~dp[l][r][kim]) return dp[l][r][kim]; if (kim == 0) { cevv = max(cevv, f(l + 1, r, !kim) + a[l]); cevv = max(cevv, f(l, r - 1, !kim) + a[r]); } else { cevv = min(cevv, f(l + 1, r, !kim) - a[l]); cevv = min(cevv, f(l, r - 1, !kim) - a[r]); } return dp[l][r][kim] = cevv; } main(void) { memset(dp, -1, sizeof(dp)); scanf("%lld", &n); FOR { scanf("%lld", &a[i]); } printf("%lld\n", f(1, n, 0)); return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
979,451
979,452
u773605784
cpp
p03171
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int point(int64_t l, int64_t r, vector<int64_t> D, int64_t n, vector<int64_t> A, int64_t mm) { if (D[l * n + r] != mm) { return D[l * n + r]; } else { if ((r - l + 1) % 2 == n % 2) { D[l * n + r] = max(point(l, r - 1, D, n, A, mm) + A[r], point(l + 1, r, D, n, A, mm) + A[l]); } else { D[l * n + r] = min(point(l, r - 1, D, n, A, mm) - A[r], point(l + 1, r, D, n, A, mm) - A[l]); } return D[l * n + r]; } } int main() { int64_t n; cin >> n; vector<int64_t> A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int64_t mm = pow(10, 14); int64_t f = 1; if (n % 2 == 0) { f = -1; } vector<int64_t> D(pow(n, 2), mm); for (int i = 0; i < n; i++) { D[i * n + i] = f * A[i]; } cout << point(0, n - 1, D, n, A, mm) << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int64_t point(int64_t l, int64_t r, vector<int64_t> &D, int64_t n, vector<int64_t> &A, int64_t mm) { if (D[l * n + r] != mm) { return D[l * n + r]; } else { if ((r - l + 1) % 2 == n % 2) { D[l * n + r] = max(point(l, r - 1, D, n, A, mm) + A[r], point(l + 1, r, D, n, A, mm) + A[l]); } else { D[l * n + r] = min(point(l, r - 1, D, n, A, mm) - A[r], point(l + 1, r, D, n, A, mm) - A[l]); } return D[l * n + r]; } } int main() { int64_t n; cin >> n; vector<int64_t> A(n); for (int i = 0; i < n; i++) { cin >> A[i]; } int64_t mm = pow(10, 14); int64_t f = 1; if (n % 2 == 0) { f = -1; } vector<int64_t> D(pow(n, 2), mm); for (int i = 0; i < n; i++) { D[i * n + i] = f * A[i]; } cout << point(0, n - 1, D, n, A, mm) << endl; }
[ "function.return_type.change" ]
979,453
979,454
u325227960
cpp