buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <bits/stdc++.h> using namespace std; const static long long INF = 1LL << 55LL; #define int long long struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost){}; }; struct state { int now; long long cost; int bitsIn, bitsOut; bool operator<(const state &s) const { return (cost > s.cos...
#include <bits/stdc++.h> using namespace std; const static long long INF = 1LL << 55LL; #define int long long struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost){}; }; struct state { int now; long long cost; int bitsIn, bitsOut; bool operator<(const state &s) const { return (cost > s.cos...
[["+", 0, 11, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 23, 0, 16, 12, 23, 0, 25], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
678
4
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int X[100001]; struct Square { P d[300001]; int n, m; void init(int _n) { m = (int)sqrt(_n); n = m * m; if (_n > n) n += m; for (int i = 0; i < _n; i++) d[i] = P(X[i], i); for (int i = _n; i < n; i++) ...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; int X[100001]; struct Square { P d[300001]; int n, m; void init(int _n) { m = (int)sqrt(_n); n = m * m; while (_n > n) n += m; for (int i = 0; i < _n; i++) d[i] = P(X[i], i); for (int i = _n; i < n; i++) ...
[["-", 8, 123, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 8, 123, 0, 14, 8, 9, 0, 52, 0, 89]]
1
867
2
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(10) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef...
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (k); i < (n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) #define D10 fixed << setprecision(10) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
849
4
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" > "D:...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
846
2
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) (v).begin(), (v).end() // weight vector of each character // A-Z(26) and a-z(26) struct weight { vector<int> val; // constructors weight() : val(52, 0) {} weight(int ini) : val(52, ini) {} weight(vector<int> ini) : val(ini)...
#include <bits/stdc++.h> using namespace std; #define int long long #define all(v) (v).begin(), (v).end() // weight vector of each character // A-Z(26) and a-z(26) struct weight { vector<int> val; // constructors weight() : val(52, 0) {} weight(int ini) : val(52, ini) {} weight(vector<int> ini) : val(ini)...
[["-", 0, 30, 0, 43, 49, 50, 51, 5, 0, 6], ["+", 0, 30, 0, 43, 49, 50, 51, 5, 0, 6]]
1
1,236
2
#include <cstring> #include <iostream> using namespace std; int main() { while (1) { int n, y = 0, Max = 0, flag = 0; char s[100][51], q[100][51]; cin >> n; if (n == 0) break; for (int i = 0; i < n; i++) { cin >> s[i]; y = 0; for (int x = 0; x < 51; x++) { if (y == ...
#include <cstring> #include <iostream> using namespace std; int main() { while (1) { int n, y = 0, Max = 0, flag = 0; char s[100][51] = {}, q[100][51] = {}; cin >> n; if (n == 0) break; for (int i = 0; i < n; i++) { cin >> s[i]; y = 0; for (int x = 0; x < 51; x++) { ...
[["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
1
359
6
/// // File: 2700.cpp // Author: ymiyamoto // // Created on Sun Nov 26 02:25:16 2017 // #include <cstdint> #include <iostream> #include <string> #include <vector> using namespace std; int32_t main() { while (true) { uint32_t n; cin >> n; if (n == 0) break; uint32_t max_len = 0; vector<st...
/// // File: 2700.cpp // Author: ymiyamoto // // Created on Sun Nov 26 02:25:16 2017 // #include <cstdint> #include <iostream> #include <string> #include <vector> using namespace std; int32_t main() { while (true) { uint32_t n; cin >> n; if (n == 0) break; uint32_t max_len = 0; vector<st...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
377
2
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using msi = map<string, int>; using mii = map<int, int>; using pii = pair<int, int>; using vlai = valarray<int>; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) #define range(i, ...
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using msi = map<string, int>; using mii = map<int, int>; using pii = pair<int, int>; using vlai = valarray<int>; using ll = long long; #define rep(i, n) for (int i = 0; i < n; i++) #define range(i, ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
343
2
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <...
[["+", 0, 30, 0, 43, 49, 50, 51, 91, 17, 33], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
469
3
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) int main(void) { while (1) { int n; cin >> n; if (n == 0) break; string s[n]; REP(i, n) { cin >> s[i]; } string news[n]; int maxlen = 0; for (int i...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) int main(void) { while (1) { int n; cin >> n; if (n == 0) break; string s[n]; REP(i, n) { cin >> s[i]; } string news[n]; int maxlen = 0; for (int i...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
441
2
def a2c(name): c = name[0] boin=['a','i','u','e','o'] for i, b in enumerate(name[:-1]): if b in boin: c += name[i+1] return c while True: n = int(input()) if n == 0: break names = [] length = -1 for i in range(n): tmp = a2c(input()) #print tmp names.append(tmp) length = max(length, len...
def a2c(name): c = name[0] boin=['a','i','u','e','o'] for i, b in enumerate(name[:-1]): if b in boin: c += name[i+1] return c while True: n = int(input()) if n == 0: break names = [] length = -1 for i in range(n): tmp = a2c(input()) #print tmp names.append(tmp) length = max(length, len...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 79]]
5
204
4
# coding: utf-8 import sys def coding(s): t = '' flag = True for i in s: if flag: t += i flag = False if i == 'a' or i == 'i' or i == 'u' or i == 'e' or i == 'o': flag = True; return t def pre_possible(ls): flag = False for i in range(len(ls...
# coding: utf-8 import sys def coding(s): t = '' flag = True for i in s: if flag: t += i flag = False if i == 'a' or i == 'i' or i == 'u' or i == 'e' or i == 'o': flag = True; return t def pre_possible(ls): flag = False for i in range(len(ls...
[["+", 0, 7, 8, 196, 0, 57, 15, 681, 0, 372], ["+", 8, 196, 0, 57, 15, 681, 28, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 681, 28, 23, 0, 25]]
5
361
3
#include <bits/stdc++.h> using namespace std; struct Pos { int x, y, z; Pos(int x, int y, int z) : x(x), y(y), z(z) {} }; const int dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; const int dy[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int H, N; vector<vector<Pos>> drops; bool find(Pos p, const vector<Pos> &blocks) { for (...
#include <bits/stdc++.h> using namespace std; struct Pos { int x, y, z; Pos(int x, int y, int z) : x(x), y(y), z(z) {} }; const int dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; const int dy[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int H, N; vector<vector<Pos>> drops; bool find(Pos p, const vector<Pos> &blocks) { for (...
[["+", 0, 7, 15, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 7, 15, 16, 12, 16, 12, 16, 17, 48]]
1
811
2
#include <bits/stdc++.h> using namespace std; using VI = vector<int>; using VVI = vector<VI>; using PII = pair<int, int>; using LL = long long; using VL = vector<LL>; using VVL = vector<VL>; using PLL = pair<LL, LL>; using VS = vector<string>; #define ALL(a) begin((a)), end((a)) #define RALL(a) (a).rbegin(), (a).rend...
#include <bits/stdc++.h> using namespace std; using VI = vector<int>; using VVI = vector<VI>; using PII = pair<int, int>; using LL = long long; using VL = vector<LL>; using VVL = vector<VL>; using PLL = pair<LL, LL>; using VS = vector<string>; #define ALL(a) begin((a)), end((a)) #define RALL(a) (a).rbegin(), (a).rend...
[["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 16, 31, 22]]
1
1,244
4
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) using namesp...
#include <algorithm> #include <iomanip> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) using namesp...
[["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13]]
1
721
4
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (int)(k); i < (int)(n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<string> vs; typedef ...
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (int)(k); i < (int)(n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<string> vs; typedef ...
[["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
1
1,092
2
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int P = sc.nextInt(); int Q = sc.nextInt(); Q /= gcd(P, Q); int ans = 1; for (int i = 2; i * i <= Q; i++) { if (Q % i == 0) { while (Q % i == 0) { ...
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int P = sc.nextInt(); int Q = sc.nextInt(); Q /= gcd(P, Q); int ans = 1; for (int i = 2; i * i <= Q; i++) { if (Q % i == 0) { while (Q % i == 0) { ...
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 17, 108], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 498, 0, 195, 8, 196, 0, 1, 0, 35]]
3
151
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #def...
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #def...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
184
2
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> #include <functional> #define int long long #define inf 1000000007 #define pa pai...
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <string> #include <vector> // #include <boost/multiprecision/cpp_int.hpp> #include <functional> #define int long long #define inf 1000000007 #define pa pai...
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 17, 108]]
1
869
2
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int p, q; cin >> p >> q; int r = gcd(q, p); p /= r; q /= r; int ans = 1; for (int i = 2; i * i <= q; i++) { if (q % i...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int p, q; cin >> p >> q; int r = gcd(q, p); p /= r; q /= r; int ans = 1; for (int i = 2; i * i <= q; i++) { if (q % i...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
134
4
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
358
2
#include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 0 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; ...
#include "bits/stdc++.h" using namespace std; #define int long long #define DBG 0 #define dump(o) \ if (DBG) { \ cerr << #o << " " << o << endl; ...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148]]
1
153
3
#include <bits/stdc++.h> using namespace std; int main() { int a, b, s = 0; cin >> a >> b; while (--a) s += s / (b - 1) + 1; cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, s = 0; cin >> a >> b; while (--a) s += s / (b - 1) + 1; cout << s << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
50
3
#include <iostream> using namespace std; int main() { int a, b, s = 0; cin >> a >> b; while (--a) s += s / (b - 1) + 1; cout << s << endl; }
#include <iostream> using namespace std; int main() { long int a, b, s = 0; cin >> a >> b; while (--a) s += s / (b - 1) + 1; cout << s << endl; }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
50
1
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; n--, k--; if (!n) { cout << "0" << endl; return 0; } int ans = 1, plus; for (int i = 1; i < n; i++) { plus = ans / k + 1; ans += plus; } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; n--, k--; if (!n) { cout << "0" << endl; return 0; } long long ans = 1, plus; for (int i = 1; i < n; i++) { plus = ans / k + 1; ans += plus; } cout << ans << endl; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
93
3
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define rep(i, n) repl(i, 0, n) #define each(itr, v) for (auto itr : v) #define pb(s) push_back(s) #define all(x) (...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define repr(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define rep(i, n) repl(i, 0, n) #define each(itr, v) for (auto itr : v) #define pb(s) push_back(s) #define all(x) (...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
238
2
#include <bits/stdc++.h> using namespace std; #define for_(i, a, b) for (int i = (a); i < (b); ++i) int main() { int N, K; cin >> N >> K; int ans = 1; for_(i, 0, N - 1) ans += (ans / (K - 1) + (ans % (K - 1) ? 1 : 0)); cout << ans - 1 << endl; }
#include <bits/stdc++.h> using namespace std; #define for_(i, a, b) for (int i = (a); i < (b); ++i) int main() { int N, K; cin >> N >> K; long long ans = 1; for_(i, 0, N - 1) ans += (ans / (K - 1) + (ans % (K - 1) ? 1 : 0)); cout << ans - 1 << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
82
3
#include <cmath> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int num = 0; for (int i = 0; i < n - 1; i++) { num += 1 + num / (k - 1); } cout << num << endl; return 0; }
#include <cmath> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; long long num = 0; for (int i = 0; i < n - 1; i++) { num += 1 + num / (k - 1); } cout << num << endl; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
69
3
#include <iostream> using namespace std; int ans(int pos, int k, int step) { if (step == 1) return pos; int nextpos = pos + (pos + k - 1) / (k - 1); return ans(nextpos, k, step - 1); } int main() { int n, k; cin >> n >> k; cout << ans(0, k, n) << endl; return 0; }
#include <iostream> using namespace std; long long int ans(long long int pos, int k, int step) { if (step == 1) return pos; long long int nextpos = pos + (pos + k - 1) / (k - 1); return ans(nextpos, k, step - 1); } int main() { int n, k; cin >> n >> k; cout << ans(0, k, n) << endl; return 0; }
[["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
93
6
#include <bits/stdc++.h> using namespace std; long long int dfs(int pos, int n, int k) { if (n == 1) return pos; long long lb = 0, ub = 1e18 + 1; while (ub - lb > 1) { long long int mid = (ub + lb) / 2; if (pos >= mid - (mid / k + 1)) { lb = mid; } else { ub = mid; } } if (lb ...
#include <bits/stdc++.h> using namespace std; long long int dfs(long long int pos, int n, int k) { if (n == 1) return pos; long long lb = 0, ub = 1e18 + 1; while (ub - lb > 1) { long long int mid = (ub + lb) / 2; if (pos >= mid - (mid / k + 1)) { lb = mid; } else { ub = mid; } }...
[["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96]]
1
211
2
#include <cmath> #include <iostream> using namespace std; using ll = long long; int main() { ll N, k, now = 0; cin >> N >> k; ll step; ll mod, div; ll tmp; for (;;) { N--; if (N == 0) break; div = now / k; step = div + 1; tmp = step * k; mod = now % k; while (now + step...
#include <cmath> #include <iostream> using namespace std; using ll = long long; int main() { ll N, k, now = 0; cin >> N >> k; ll step; ll mod, div; ll tmp; for (;;) { N--; if (N == 0) break; div = now / k; step = div + 1; tmp = step * k; mod = now % k; while (now + step...
[["-", 12, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 12, 22]]
1
133
2
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define out(S) cout << (S) << endl; #define ShowAll(collection) \ for (auto i : collection) { \ out(i); ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define out(S) cout << (S) << endl; #define ShowAll(collection) \ for (auto i : collection) { \ out(i); ...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-", 51, 218, 49, 185, 54, 55, 0, 56, 39, 40], ["+", 51, 218, 49, 185, 54, 55, 0, 56, 39, 78], ["-", 51, 218, 49, 185, 0, 351, 0, 77, 39, 40], ["+", 51, 218, 49, 185, 0, 351, 0, 77, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51,...
1
245
8
#include <algorithm> #include <iostream> #include <queue> #include <string> using namespace std; string str; int main() { cin >> str; queue<string> que; que.push(str); bool ret = (str == "ABC"); while (!ret && !que.empty()) { string s1 = que.front(); que.pop(); vector<int> v1(s1.size(), 0); fo...
#include <algorithm> #include <iostream> #include <queue> #include <string> using namespace std; string str; int main() { cin >> str; queue<string> que; que.push(str); bool ret = (str == "ABC"); while (!ret && !que.empty()) { string s1 = que.front(); que.pop(); vector<int> v1(s1.size(), 0); fo...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
382
2
#include "bits/stdc++.h" #define REP(i, n) for (ll i = 0; i < n; ++i) #define RREP(i, n) for (ll i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (ll i = m; i < n; ++i) #define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i) #define ALL(v) (v).begin(), (v).end() #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()); #defin...
#include "bits/stdc++.h" #define REP(i, n) for (ll i = 0; i < n; ++i) #define RREP(i, n) for (ll i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (ll i = m; i < n; ++i) #define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i) #define ALL(v) (v).begin(), (v).end() #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()); #defin...
[["-", 15, 339, 51, 16, 31, 2, 63, 118, 17, 131], ["-", 15, 339, 51, 16, 31, 2, 63, 118, 119, 120], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 5, 0, 62], ["+", 0, 57, 15, 339, 51, 16, 12, 5, 0, 6]...
1
537
8
#include <bits/stdc++.h> using namespace std; bool dfs(string s) { if (s == "ABC") return true; string t = regex_replace(s, regex("ABC"), "A"); if (t.size() != s.size() && regex_replace(t, regex("A"), "ABC") == s) { if (dfs(t)) return true; } t = regex_replace(s, regex("ABC"), "B"); if (t.si...
#include <bits/stdc++.h> using namespace std; bool dfs(string s) { if (s == "ABC") return true; string t = regex_replace(s, regex("ABC"), "A"); if (t.size() != s.size() && regex_replace(t, regex("A"), "ABC") == s) { if (dfs(t)) return true; } t = regex_replace(s, regex("ABC"), "B"); if (t.si...
[["-", 3, 4, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 3, 4, 0, 2, 3, 4, 0, 5, 0, 6]]
1
250
4
#!/usr/bin/python if __name__ == "__main__": S = input() c = ['A','B','C'] while True: if len(S) <= 3: print("Yes" if S == "ABC" else "No") break T = S.strip().split("ABC") P = ''.join(T) cnt = 0 for x in c: if x in P: cnt += 1 else: S = x.join(T) if len(t) == 1 or cnt ...
#!/usr/bin/python if __name__ == "__main__": S = input() c = ['A','B','C'] while True: if len(S) <= 3: print("Yes" if S == "ABC" else "No") break T = S.strip().split("ABC") P = ''.join(T) cnt = 0 for x in c: if x in P: cnt += 1 else: S = x.join(T) if len(T) == 1 or cnt ...
[["-", 15, 679, 31, 666, 0, 652, 3, 4, 0, 22], ["+", 15, 679, 31, 666, 0, 652, 3, 4, 0, 22]]
5
124
2
#!/usr/bin/env python S = input() while S != 'ABC': S2 = "" i = 0 while True: if i >= len(S): break if S[i:min(len(S), i + 3)] == "ABC": S2 += "X" i += 2 else: S2 += S[i] i += 1 a_flag = 'A' in S2 b_flag = 'B' in S2 c_flag = 'C' in S2 if not 'X' in S2: print("NO") exit() if a_flag + b_f...
#!/usr/bin/env python S = input() while S != 'ABC': S2 = "" i = 0 while True: if i >= len(S): break if S[i:min(len(S), i + 3)] == "ABC": S2 += "X" i += 2 else: S2 += S[i] i += 1 a_flag = 'A' in S2 b_flag = 'B' in S2 c_flag = 'C' in S2 if not 'X' in S2: print("No") exit() if a_flag + b_f...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
193
6
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF()...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF()...
[["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 147], ["+", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94]]
5
285
6
l=[int(input()) for _ in range(int(input()))] s=[] isno=False for i in l: if i=="A": s.append(1) else: try: _=s.pop() except: print("NO") isno=True break if not isno and not s:print("YES") elif not isno and s:print("NO")
l=[input() for _ in range(int(input()))] s=[] isno=False for i in l: if i=="A": s.append(1) else: try: _=s.pop() except: print("NO") isno=True break if not isno and not s:print("YES") elif not isno and s:print("NO")
[["-", 0, 1, 0, 662, 12, 658, 8, 652, 63, 22], ["-", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["-", 8, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
95
3
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++...
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++...
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 341, 342, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 341, 342, 0, 2, 3, 4, 0, 16, 12, 13]]
1
333
6
#include <iostream> using namespace std; int a[10000], n, m, t, p; int main() { cin >> n >> m >> t; for (int i = 0; i < n; i++) { cin >> p; a[p - m]++; a[p + m]--; } for (int i = 1; i < t; i++) a[p] += a[p - 1]; int cnt = 0; for (int i = 0; i < t; i++) { if (a[i] == 0) cnt++; } ...
#include <iostream> using namespace std; int a[100000], n, m, t, p; int main() { cin >> n >> m >> t; for (int i = 0; i < n; i++) { cin >> p; a[p - m]++; a[p + m]--; } for (int i = 1; i < t; i++) a[i] += a[i - 1]; int cnt = 0; for (int i = 0; i < t; i++) { if (a[i] == 0) cnt++; } ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 8, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22]]
1
138
6
#include <bits/stdc++.h> using namespace std; int n, m, t, a[109]; int main() { cin >> n >> m >> t; a[0] = -1, a[n + 1] = t + 1; for (int i = 1; i <= n; i++) cin >> a[i]; int ret = 0; for (int i = 0; i <= n; i++) ret += max(a[i + 1] - a[i] - 2 * m, 0); cout << ret << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, t, a[109]; int main() { cin >> n >> m >> t; a[0] = -m, a[n + 1] = t + m; for (int i = 1; i <= n; i++) cin >> a[i]; int ret = 0; for (int i = 0; i <= n; i++) ret += max(a[i + 1] - a[i] - 2 * m, 0); cout << ret << endl; return 0; }
[["-", 8, 9, 0, 1, 0, 34, 31, 11, 12, 13], ["+", 0, 1, 0, 34, 31, 11, 12, 91, 17, 33], ["+", 0, 1, 0, 34, 31, 11, 12, 91, 28, 22], ["-", 0, 1, 0, 34, 12, 11, 12, 16, 12, 13], ["+", 0, 1, 0, 34, 12, 11, 12, 16, 12, 22]]
1
122
5
#include <iostream> using namespace std; int main() { int a, b, c, n, t[10001] = {0}, p = 0, i, j; for (cin >> n >> a >> b, i = 0; n--;) { for (cin >> c, j = c - a; j <= c && j <= b;) if (!(t[j++]++)) p--; } cout << b + p << endl; }
#include <iostream> using namespace std; int main() { int a, b, c, n, t[10001] = {0}, p = 0, i, j; for (cin >> n >> a >> b, i = 0; n--;) { for (cin >> c, j = c - a; j <= c + a - 1 && j < b;) if (!(t[j++]++)) p--; } cout << b + p << endl; }
[["+", 15, 16, 31, 16, 12, 16, 31, 16, 17, 72], ["+", 15, 16, 31, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 7, 15, 16, 31, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 19], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 18]]
1
102
6
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // ranker using namespace std; #define REPS(i, a, n) for (int i = (a); i <...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // ranker using namespace std; #define REPS(i, a, n) for (int i = (a); i <...
[["+", 0, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
914
7
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #defin...
[["-", 341, 342, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 341, 342, 0, 2, 3, 4, 0, 16, 12, 13]]
1
233
2
// // main.cpp // Delivery to a Luxurious House // // Created by x15071xx on 2017/06/19. // Copyright ?? 2017??´ AIT. All rights reserved. // #include <iostream> #include <vector> using namespace std; int main(int argc, const char *argv[]) { int n, m, t, taroSc[10000] = {0}, time = 0; vector<int> cometime; ...
// // main.cpp // Delivery to a Luxurious House // // Created by x15071xx on 2017/06/19. // Copyright ?? 2017??´ AIT. All rights reserved. // #include <iostream> #include <vector> using namespace std; int main(int argc, const char *argv[]) { int n, m, t, taroSc[100000] = {0}, time = 0; vector<int> cometime; ...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
184
4
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define REAP(i, a, n) for (int i = (a); i < (n); i++) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define fr first #define sc second #define pb push_back #define All(v) v.begin(), v.end() typedef long lo...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) #define REAP(i, a, n) for (int i = (a); i < (n); i++) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define fr first #define sc second #define pb push_back #define All(v) v.begin(), v.end() typedef long lo...
[["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 98], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 18], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
1
155
4
# coding: utf-8 # Your code here! a = list(map(int,input().split())) b = list(map(int,input().split())) k = [0]*a[2] pp = 0 su = 0 for i in b: for j in range(a[2]): if j >= i - a[1] + 1 and j <= i + a[1] : k[j] += 1 for i in range(a[2]): if k[i] == 0: su += 1 ...
# coding: utf-8 # Your code here! a = list(map(int,input().split())) b = list(map(int,input().split())) k = [0]*a[2] pp = 0 su = 0 for i in b: for j in range(a[2]): if j >= i - a[1] and j <= i + a[1] - 1: k[j] += 1 for i in range(a[2]): if k[i] == 0: su += 1 ...
[["-", 0, 57, 15, 679, 31, 666, 0, 657, 17, 72], ["-", 0, 57, 15, 679, 31, 666, 0, 657, 12, 612], ["+", 0, 57, 15, 679, 12, 666, 0, 657, 17, 33], ["+", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612]]
5
121
4
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // const ll mod = 1000000007; int N, M, K; int D[20]; int v[105][105]; int inv[105]; int dist[1 << 17]; bool chmin(int &a, int b) { if ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) // const ll mod = 1000000007; int N, M, K; int D[20]; int v[105][105]; int inv[105]; int dist[1 << 17]; bool chmin(int &a, int b) { if ...
[["-", 0, 7, 15, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 23, 0, 16, 12, 22], ["-", 341, 342, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 3, 4, 0, 16, 31, 23, 0, 16, 12, 22], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7...
1
423
8
#include "algorithm" #include "bitset" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "unordered_map" #include "unordered_set" ...
#include "algorithm" #include "bitset" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "unordered_map" #include "unordered_set" ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 22]]
1
584
2
#include <bits/stdc++.h> using namespace std; #define int long long string s; int n; int used[300][300]; int dp[300][300]; int dfs(int p, int d) { if (used[p][d]) return dp[p][d]; used[p][d] = 1; int res = -(1LL << 55LL), op = 0; int j; for (j = p - 1; j >= 0; j--) if (s[j] == '+' || s[j] == '-') ...
#include <bits/stdc++.h> using namespace std; #define int long long string s; int n; int used[300][300]; int dp[300][300]; int dfs(int p, int d) { if (used[p][d]) return dp[p][d]; used[p][d] = 1; int res = -(1LL << 55LL), op = 0; int j; for (j = p - 1; j >= 0; j--) if (s[j] == '+' || s[j] == '-') ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 98], ["-", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 22]]
1
414
4
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; #define F first #define S second int INF = 1e9; string s; P dp[222][222], init = P(INF, -INF); P dfs(int l, int r) { if (l == r) return P(s[l] - '0', s[l] - '0'); if (dp[l][r] != init) return dp[l][r]; P res = init; if (s[l] == '('...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; #define F first #define S second int INF = 1e9; string s; P dp[222][222], init = P(INF, -INF); P dfs(int l, int r) { if (l == r) return P(s[l] - '0', s[l] - '0'); if (dp[l][r] != init) return dp[l][r]; P res = init; if (s[l] == '('...
[["-", 12, 2, 3, 4, 0, 16, 12, 118, 119, 120], ["+", 12, 2, 3, 4, 0, 16, 12, 118, 119, 120]]
1
416
4
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<int, P> P1; typedef pair<P, P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i, x) for (int i = 0; i < x; i++)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<int, P> P1; typedef pair<P, P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i, x) for (int i = 0; i < x; i++)...
[["-", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["+", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0...
1
1,093
9
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) for (int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; const int INF = 100000000; using namespace std; int main() { int h, w; cin >> w >> h; char m[100][...
#include <bits/stdc++.h> #define range(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, b) for (int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define debug(x) cout << "debug " << x << endl; const int INF = 100000000; using namespace std; int main() { int h, w; cin >> w >> h; char m[100][...
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
359
2
#include <algorithm> #include <cmath> #include <queue> #include <stack> #include <stdio.h> #include <vector> using namespace std; struct Info { Info() { num_E = num_W = 0; } int num_E, num_W; }; int main() { int N, M, total_W = 0, total_E = 0; scanf("%d %d", &N, &M); Info info[N + 1]; char buf[N + 1]; ...
#include <algorithm> #include <cmath> #include <queue> #include <stack> #include <stdio.h> #include <vector> using namespace std; struct Info { Info() { num_E = num_W = 0; } int num_E, num_W; }; int main() { int N, M, total_W = 0, total_E = 0; scanf("%d %d", &N, &M); Info info[N + 1]; char buf[N + 1]; ...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22]]
1
305
4
#include <bits/stdc++.h> using namespace std; #define int long long int lcm(int x, int y) { return x / __gcd(x, y) * y; } int mpow(int n, int x) { int res = 1LL; for (int i = 0; i < x; i++) res *= n; return res; } int mod_pow(int x, int n, int mod) { int res = 1; while (n > 0) { if (n & 1) (res ...
#include <bits/stdc++.h> using namespace std; #define int long long int lcm(int x, int y) { return x / __gcd(x, y) * y; } int mpow(int n, int x) { int res = 1LL; for (int i = 0; i < x; i++) res *= n; return res; } int mod_pow(int x, int n, int mod) { int res = 1; while (n > 0) { if (n & 1) (res ...
[["-", 0, 338, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21]]
1
640
5
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
472
2
#include <bits/stdc++.h> #define int long long #define N 100010 using namespace std; const int INF = 1LL << 55; const int mod = (1e9) + 7; const double EPS = 1e-8; const double PI = 6.0 * asin(0.5); template <class T> T Max(T &a, T b) { return a = max(a, b); } template <class T> T Min(T &a, T b) { return a = min(a, b);...
#include <bits/stdc++.h> #define int long long #define N 100010 using namespace std; const int INF = 1LL << 55; const int mod = (1e9) + 7; const double EPS = 1e-8; const double PI = 6.0 * asin(0.5); template <class T> T Max(T &a, T b) { return a = max(a, b); } template <class T> T Min(T &a, T b) { return a = min(a, b);...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
1
439
4
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (int)(k); i < (int)(n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<string> vs; typedef ...
#include <bits/stdc++.h> using namespace std; #define FOR(i, k, n) for (int i = (int)(k); i < (int)(n); i++) #define REP(i, n) FOR(i, 0, n) #define ALL(a) a.begin(), a.end() #define MS(m, v) memset(m, v, sizeof(m)) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<string> vs; typedef ...
[["-", 64, 9, 0, 37, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 37, 0, 2, 3, 4, 0, 13]]
1
457
4
#include <bits/stdc++.h> using namespace std; #define int long long #define MAX 114514 vector<int> G[MAX]; int dpA[MAX], dpB[MAX], dpC[MAX]; bool used[MAX]; signed main() { int N, A, B, C; cin >> N >> A >> B >> C; int a[A], b[B], c[C]; for (int i = 0; i < A; i++) cin >> a[i]; for (int i = 0; i < B; i++) ...
#include <bits/stdc++.h> using namespace std; #define int long long #define MAX 114514 vector<int> G[MAX]; int dpA[MAX], dpB[MAX], dpC[MAX]; bool used[MAX]; signed main() { int N, A, B, C; cin >> N >> A >> B >> C; int a[A], b[B], c[C]; for (int i = 0; i < A; i++) cin >> a[i]; for (int i = 0; i < B; i++) ...
[["-", 0, 52, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 52, 8, 9, 0, 57, 64, 116, 0, 117]]
1
1,481
6
#include <bits/stdc++.h> #define INF 1000000 using namespace std; typedef long long ll; typedef pair<int, int> P; int a[3], n, m; int type[10009]; vector<int> G[10005]; int dist[4][10005]; int bfs(int s) { for (int i = 3; i < 4; i++) { queue<int> que; for (int j = 0; j < n + 3; j++) { dist[i][j] = INF...
#include <bits/stdc++.h> #define INF 1000000 using namespace std; typedef long long ll; typedef pair<int, int> P; int a[3], n, m; int type[10009]; vector<int> G[10005]; int dist[4][10005]; int bfs(int s) { for (int i = 3; i < 4; i++) { queue<int> que; for (int j = 0; j < n + 3; j++) { dist[i][j] = INF...
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
1
893
2
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(), (v).end() #define rep(i, n) for (int i = 0; i < (n); i++) #defi...
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(), (v).end() #define rep(i, n) for (int i = 0; i < (n); i++) #defi...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
670
4
#include <bits/stdc++.h> using namespace std; int n, d; string s; int main() { cin >> n; bool ok = true; while (n--) { if (s == "A") d++; else d--; if (d < 0) ok = false; } if (d != 0) ok = false; cout << (ok ? "YES" : "NO") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, d; string s; int main() { cin >> n; bool ok = true; while (n--) { cin >> s; if (s == "A") d++; else d--; if (d < 0) ok = false; } if (d != 0) ok = false; cout << (ok ? "YES" : "NO") << endl; return 0; }
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
90
4
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define PI 3.1415926535897932384626433832795028841971 #define INF 1000000000 #define EPS 1e-10 #define MOD 1000000 using namespace std; typedef long long ll; typedef pair<double, double> P; typedef pair<double, P> PQ; int n; int cnt; string str; i...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define PI 3.1415926535897932384626433832795028841971 #define INF 1000000000 #define EPS 1e-10 #define MOD 1000000 using namespace std; typedef long long ll; typedef pair<double, double> P; typedef pair<double, P> PQ; int n; int cnt; string str; i...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
137
2
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> VI; typedef vector<VI> VVI; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const int INF = numeric_limits<int>::max() / 2; const int NEG_INF = numeric_limits<int>::min() / 2; int m...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> VI; typedef vector<VI> VVI; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const int INF = numeric_limits<int>::max() / 2; const int NEG_INF = numeric_limits<int>::min() / 2; int m...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
192
4
#include <bits/stdc++.h> using namespace std; int main() { int n, f = 0, c = 0; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s == "A") c++; else c--; f |= (c < 0); } if (f || !c) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, f = 0, c = 0; cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; if (s == "A") c++; else c--; f |= (c < 0); } if (f || c) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
[["-", 0, 57, 15, 339, 51, 16, 12, 91, 17, 111]]
1
100
1
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) #define PB push_back #define MP make_pair #define ALL(a) (a).begin(), (a).end() #define ll long long using namespace std; int main() { int n; int c = 0; bool f = true; REP(i, n) { string s; cin >> s; if (s == "A") c++; ...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) #define PB push_back #define MP make_pair #define ALL(a) (a).begin(), (a).end() #define ll long long using namespace std; int main() { int n; int c = 0; bool f = true; cin >> n; REP(i, n) { string s; cin >> s; if (s == "A") ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
127
4
// // main.cpp // A-un Breathing // // Created by x15071xx on 2017/06/14. // Copyright ?? 2017??´ AIT. All rights reserved. // #include <iostream> using namespace std; int main(int argc, const char *argv[]) { int n; cin >> n; int count = 0; for (int i = 0; i < n; i++) { string aun; cin >> aun; ...
// // main.cpp // A-un Breathing // // Created by x15071xx on 2017/06/14. // Copyright ?? 2017??´ AIT. All rights reserved. // #include <iostream> using namespace std; int main(int argc, const char *argv[]) { int n; cin >> n; int count = 0; for (int i = 0; i < n; i++) { string aun; cin >> aun; ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
131
6
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; int counta = 0; bool aunOK = true; for (int i = 0; i < n; i++) { string aun; cin >> aun; if (aun == "A") counta++; else { counta--; if (counta < 0) { aunOK = false; } ...
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; int counta = 0; bool aunOK = true; for (int i = 0; i < n; i++) { string aun; cin >> aun; if (aun == "A") counta++; else { counta--; if (counta < 0) { aunOK = false; } ...
[["-", 0, 57, 64, 1, 0, 11, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 6], ["-", 75, 76, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 11, 12, 5, 0, 6]]
1
119
4
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> using namespace std; const int MAX = 1000; #define hoge(i, n) for (int i = 0; i < n; i++) int main() { int N, s[MAX]; string S[MAX]; cin >> N; hoge(i, N) { cin >> S[i]; if (S[i] == "A") { s[i] = 1; } else { ...
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> using namespace std; const int MAX = 1000; #define hoge(i, n) for (int i = 0; i < n; i++) int main() { int N, s[MAX]; string S[MAX]; cin >> N; hoge(i, N) { cin >> S[i]; if (S[i] == "A") { s[i] = 1; } else { ...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
155
4
#include "algorithm" #include "climits" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "queue" #include "random" #include "set" #include "stack" #include "string" using namespace std; const long long int MOD = 1000000007; const long double EPS = 0.00000001; const ...
#include "algorithm" #include "climits" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "queue" #include "random" #include "set" #include "stack" #include "string" using namespace std; const long long int MOD = 1000000007; const long double EPS = 0.00000001; const ...
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 44]]
1
202
3
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; int c = 0; bool flag = true; for (int i = 0; i < n; i++) { char input; cin >> input; if (input == 'A') c++; else c--; if (c < 0) flag = false; } if (flag && c == 0) cout << "YES" << ...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; int c = 0; bool flag = true; for (int i = 0; i < n; i++) { string input; cin >> input; if (input[0] == 'A') c++; else c--; if (c < 0) flag = false; } if (flag && c == 0) cout << "YES...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 13], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73]]
1
106
5
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n; cin >> n; int c1 = 0, c2 = 0; rep(i, n) { string s; cin >> s; if (s == "A") c1++; else c2++; if (c1 < c2) { cout << "No" << endl; goto g; } } if ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n; cin >> n; int c1 = 0, c2 = 0; rep(i, n) { string s; cin >> s; if (s == "A") c1++; else c2++; if (c1 < c2) { cout << "NO" << endl; goto g; } } if ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
111
22
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if (!(p)) #define until(p) while (!(p)) using ll = long long; using P = std::tuple<int, int>; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0,...
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if (!(p)) #define until(p) while (!(p)) using ll = long long; using P = std::tuple<int, int>; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0,...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 98]]
1
242
2
#include <cstdio> using namespace std; int n; char s[100][10]; int main() { scanf("%d", &n); int acounter = 0; bool ans = true; for (int i = 0; i < n; i++) { scanf("%s", s[i]); if (s[i][0] == 'A') acounter++; else { if (acounter > 0) acounter--; else ans = false; ...
#include <cstdio> using namespace std; int n; char s[100][10]; int main() { scanf("%d", &n); int acounter = 0; bool ans = true; for (int i = 0; i < n; i++) { scanf("%s", s[i]); if (s[i][0] == 'A') acounter++; else { if (acounter > 0) acounter--; else ans = false; ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
131
4
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } tem...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } tem...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
1,040
2
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <typeinfo> #include <vector> #define syos...
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <typeinfo> #include <vector> #define syos...
[["-", 75, 76, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 75, 76, 0, 1, 0, 2, 63, 118, 28, 22], ["-", 0, 2, 3, 4, 0, 83, 0, 16, 31, 22], ["-", 0, 2, 3, 4, 0, 83, 0, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 83, 0, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 83, 0, 16, 12, 22]]
1
603
6
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef pair<P, P> L; int N; vector<bitset<40>> G; double const EPS = 1e-10; namespace std { bool operator<(const P &a, const P &b) { return fabs(real(a) - real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b); } } // namespace std bool equal...
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef pair<P, P> L; int N; vector<bitset<40>> G; double const EPS = 1e-10; namespace std { bool operator<(const P &a, const P &b) { return fabs(real(a) - real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b); } } // namespace std bool equal...
[["-", 15, 339, 51, 2, 3, 4, 0, 16, 17, 33], ["-", 15, 339, 51, 2, 3, 4, 0, 16, 12, 13]]
1
1,497
2
// AOJ 2686: Unfair Game // 2018.2.27 #include <stdio.h> int s[100002], N; int a[5]; //#define getchar_unlocked() getchar() int in() { int n = 0; int c = getchar_unlocked(); do n = 10 * n + (c & 0xf), c = getchar_unlocked(); while (c >= '0'); return n; } long long nim(long long x) { long long t = 0...
// AOJ 2686: Unfair Game // 2018.2.27 #include <stdio.h> int s[100002], N; int a[5]; //#define getchar_unlocked() getchar() int in() { int n = 0; int c = getchar_unlocked(); do n = 10 * n + (c & 0xf), c = getchar_unlocked(); while (c >= '0'); return n; } long long nim(long long x) { long long t = 0...
[["+", 0, 57, 15, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 57, 15, 23, 0, 16, 17, 98]]
0
378
4
#include <bits/stdc++.h> using namespace std; int N, A, B, K; int s[100000]; int cnt = 0; bool solve() { int f = 0; for (int i = 0; i < N; i++) f ^= s[i] % (K + 1); if (A == B || cnt == N) return (f > 0); if (A > B) return true; if (cnt < N - 1) return false; f ^= s[N - 1]; return (s[N...
#include <bits/stdc++.h> using namespace std; int N, A, B, K; int s[100000]; int cnt = 0; bool solve() { int f = 0; for (int i = 0; i < N; i++) f ^= s[i] % (K + 1); if (A == B || cnt == N) return (f > 0); if (A > B) return true; if (cnt < N - 1) return false; f ^= s[N - 1] % (K + 1); r...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25]]
1
216
6
#include <bits/stdc++.h> using namespace std; #define int long long typedef vector<int> vint; typedef pair<int, int> pint; typedef vector<pint> vpint; #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, f, n) for (int i = (f); i < (n); i++) #define all(v) (v).begin(), (v).end() #define each(it, v) ...
#include <bits/stdc++.h> using namespace std; #define int long long typedef vector<int> vint; typedef pair<int, int> pint; typedef vector<pint> vpint; #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, f, n) for (int i = (f); i < (n); i++) #define all(v) (v).begin(), (v).end() #define each(it, v) ...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
591
7
#include <algorithm> #include <set> #include <stdio.h> #include <string> using namespace std; char in[20][20]; char ret[20]; int used[20]; int t[20]; int n; int m; set<pair<pair<int, int>, string>> S; int calc(int a, string b, int c) { if (S.count(make_pair(make_pair(a, c), b))) return 0; S.insert(make_pair(mak...
#include <algorithm> #include <set> #include <stdio.h> #include <string> using namespace std; char in[20][20]; char ret[20]; int used[20]; int t[20]; int n; int m; set<pair<pair<int, int>, string>> S; int calc(int a, string b, int c) { if (S.count(make_pair(make_pair(a, c), b))) return 0; S.insert(make_pair(mak...
[["+", 15, 339, 51, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 69, 341, 342, 0, 16, 12, 103, 0, 104], ["+", 51, 69, 341, 342, 0, 16, 12, 103, 0, 125]]
1
617
4
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, n) repl(i, 0, n) #define all(x) (x).begin(), (x).end() #define dbg(x) cout << #x "=...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, n) repl(i, 0, n) #define all(x) (x).begin(), (x).end() #define dbg(x) cout << #x "=...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
444
4
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { while (true) { int d = sc.nextInt(); int e = sc.nextInt(); double min = 10000000; if (d == 0 ...
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { while (true) { int d = sc.nextInt(); int e = sc.nextInt(); double min = 10000000; if (d == 0 ...
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
3
178
4
// cpp_range (generic range class, very small equivalent of boost::irange) // (C) @cielavenir under Boost Software License. // note: end position is exclusive. #include <iterator> template <typename T> class range { public: struct iterator { const T a, b; T p; const long long d; // because T might be uns...
// cpp_range (generic range class, very small equivalent of boost::irange) // (C) @cielavenir under Boost Software License. // note: end position is exclusive. #include <iterator> template <typename T> class range { public: struct iterator { const T a, b; T p; const long long d; // because T might be uns...
[["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 12, 13]]
1
832
2
#include <bits/stdc++.h> using namespace std; int main() { int d, e; while (cin >> d >> e) { double ans = 10000; for (int i = 0; i < d; i++) ans = min(ans, abs(e - sqrt(i * i + (d - i) * (d - i)))); cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int d, e; while (cin >> d >> e, d) { double ans = 10000; for (int i = 0; i < d; i++) ans = min(ans, abs(e - sqrt(i * i + (d - i) * (d - i)))); cout << ans << endl; } return 0; }
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
86
2
#include <bits/stdc++.h> using namespace std; int main() { int d; int x, y; int e; double cost; while (cin >> d >> e, d && e) { cost = 1000000; for (x = 0; x < 100; x++) { y = d - x; if (fabs(e - sqrt(x * x + y * y)) < cost) cost = fabs(e - sqrt(x * x + y * y)); } p...
#include <bits/stdc++.h> using namespace std; int main() { int d; int x, y; int e; double cost; while (cin >> d >> e, d && e) { cost = 1000000; for (x = 0; x <= d; x++) { y = d - x; if (fabs(e - sqrt(x * x + y * y)) < cost) cost = fabs(e - sqrt(x * x + y * y)); } pr...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
116
4
#include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) begin(r), end(r) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout << #x << ": " << x << endl #define fcout(n) cout << fixed << setprecision((...
#include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) #define fi first #define se second #define all(r) begin(r), end(r) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout << #x << ": " << x << endl #define fcout(n) cout << fixed << setprecision((...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
1
393
4
#include <bits/stdc++.h> using namespace std; int main() { int a, b; double m; while (cin >> a >> b, a != 0 && b != 0) { m == 1e5; for (int i = 0; i <= a / 2; i++) { int j = a - i; m = min(m, abs(sqrt(i * i + j * j) - b)); } printf("%.8f\n", m); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; double m; while (cin >> a >> b, a != 0 && b != 0) { m = 1e5; for (int i = 0; i <= a / 2; i++) { int j = a - i; m = min(m, abs(sqrt(i * i + j * j) - b)); } printf("%.10f\n", m); } return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
103
4
#include <bits/stdc++.h> using namespace std; struct node { int value; node *left, *right; }; node *build() { if (getchar() == ')') return NULL; // skip ( node *res = new node(); if (res->left = build()) getchar(); // skip ) scanf("[%d](", &res->value); if (res->right = build()) getchar(); /...
#include <bits/stdc++.h> using namespace std; struct node { int value; node *left, *right; }; node *build() { if (getchar() == ')') return NULL; // skip ( node *res = new node(); if (res->left = build()) getchar(); // skip ) scanf("[%d](", &res->value); if (res->right = build()) getchar(); /...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 350, 0, 228], ["+", 8, 9, 0, 43, 49, 50, 51, 350, 39, 78], ["+", 0, 43, 49, 50, 51, 350, 3, 4, 0, 24], ["+", 0, 43, 49, 50, 51, 350, 3, 4, 0, 25]]
1
280
5
#include "bits/stdc++.h" using namespace std; // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2741&lang=jp // references : http://suikaba.hatenablog.com/entry/2017/05/23/194505 const int INF = 1e9; int dp[51][51][51][51][2][2]; int a[51]; int b[51]; int n, m; int calc_score(int a1, int b1, int a2, int b2, ...
#include "bits/stdc++.h" using namespace std; // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2741&lang=jp // references : http://suikaba.hatenablog.com/entry/2017/05/23/194505 const int INF = 1e9; int dp[51][51][51][51][2][2]; int a[51]; int b[51]; int n, m; int calc_score(int a1, int b1, int a2, int b2, ...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22]]
1
685
2
#include <iostream> #define inf 1000000000 using namespace std; int n, m; int a[55], b[55]; int dp[55][55][55][55][2][2][2]; int dfs(int i, int j, int k, int l, int t, int p, int c) { if (dp[i][j][k][l][t][p][c] != -inf) return dp[i][j][k][l][t][p][c]; int ret, sum; if (t == 0) { ret = -inf; if (j...
#include <iostream> #define inf 1000000000 using namespace std; int n, m; int a[55], b[55]; int dp[55][55][55][55][2][2][2]; int dfs(int i, int j, int k, int l, int t, int p, int c) { if (dp[i][j][k][l][t][p][c] != -inf) return dp[i][j][k][l][t][p][c]; int ret, sum; if (t == 0) { ret = -inf; if (j...
[["+", 3, 4, 0, 23, 0, 41, 15, 23, 0, 24], ["+", 3, 4, 0, 23, 0, 41, 15, 23, 0, 25], ["-", 3, 4, 0, 16, 12, 2, 3, 4, 0, 13], ["+", 3, 4, 0, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 12, 2, 3, 4, 0, 23, 0, 24]]
1
816
6
#include <bits/stdc++.h> using namespace std; double eps = 0.0000001; struct P { double x, y; }; struct L { P p1, p2; double x() { return p2.x - p1.x; } double y() { return p2.y - p1.y; } }; double prod(L l1, L l2) { return l1.x() * l2.y() - l1.y() * l2.x(); } pair<double, double> interP(L l1, L l2) { double ...
#include <bits/stdc++.h> using namespace std; double eps = 0.0000001; struct P { double x, y; }; struct L { P p1, p2; double x() { return p2.x - p1.x; } double y() { return p2.y - p1.y; } }; double prod(L l1, L l2) { return l1.x() * l2.y() - l1.y() * l2.x(); } pair<double, double> interP(L l1, L l2) { double ...
[["-", 51, 83, 0, 16, 12, 16, 12, 118, 119, 120], ["+", 51, 83, 0, 16, 12, 16, 12, 118, 119, 120]]
1
842
2
#include <stdio.h> int main() { int w0, r0, c, r, i; while (1) { scanf("%d%d%d%d", &r0, &w0, &c, &r); if (r0 == 0 && w0 == 0 && c == 0 && r == 0) break; // printf("%d %d %d %d\n",r0,w0,c,r); // printf("%f\n",(double)r0/w0); if (c * w0 <= r0) { printf("0\n"); } else { ...
#include <stdio.h> int main() { int w0, r0, c, r, i; while (1) { scanf("%d%d%d%d", &r0, &w0, &c, &r); if (r0 == 0 && w0 == 0 && c == 0 && r == 0) break; // printf("%d %d %d %d\n",r0,w0,c,r); // printf("%f\n",(double)r0/w0); if (c * w0 <= r0) { printf("0\n"); } else { ...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 31, 22], ["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13]]
0
133
3
#include <stdio.h> int main() { int i, w0, r0, c, r; while (1) { scanf("%d%d%d%d", &r0, &w0, &c, &r); if (r0 == 0 && w0 == 0 && c == 0 && r == 0) break; for (i = 0; i <= 100; i++) { // printf("%d\n",i); if ((r0 + r * i) >= (c * w0)) { printf("%d\n", i); break; ...
#include <stdio.h> int main() { int i, w0, r0, c, r; while (1) { scanf("%d%d%d%d", &r0, &w0, &c, &r); if (r0 == 0 && w0 == 0 && c == 0 && r == 0) break; for (i = 0;; i++) { // printf("%d\n",i); if ((r0 + r * i) >= (c * w0)) { printf("%d\n", i); break; } }...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]]
0
113
3
#include <bits/stdc++.h> using namespace std; int main() { int r0, w, c, r; while (1) { cin >> r0 >> w >> c >> r; if (r0 + w + c + r == 0) return 0; if (double(r0) / w >= c) { cout << 0 << endl; continue; } cout << ceil(double(c * w - r) / r0) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int r0, w, c, r; while (1) { cin >> r0 >> w >> c >> r; if (r0 + w + c + r == 0) return 0; if (double(r0) / w >= c) { cout << 0 << endl; continue; } cout << ceil(double(c * w - r0) / r) << endl; } }
[["-", 0, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
91
4
#include <bits/stdc++.h> using namespace std; int main() { int R0, W0, C, R; while (cin >> R0 >> W0 >> C >> R, R0) { cout << (C * W0 - R0 + R - 1) / R << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int R0, W0, C, R; while (cin >> R0 >> W0 >> C >> R, R0) { cout << max(0, (C * W0 - R0 + R - 1) / R) << endl; } }
[["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21], ["+", 12, 2, 3, 4, 0, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25]]
1
55
5
#include <bits/stdc++.h> using namespace std; #define int long long #define Rep(i, N) for (int i = 0; i < N; i++) signed main() { int A, B, C, D; while (cin >> A >> B >> C >> D, A || B || C || D) { cout << max(0LL, (B * C - A - 1) / D + 1) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define Rep(i, N) for (int i = 0; i < N; i++) signed main() { int A, B, C, D; while (cin >> A >> B >> C >> D, A || B || C || D) { cout << max(0LL, (B * C - A + D - 1) / D) << endl; } return 0; }
[["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
1
80
4
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <time.h> #include <v...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <time.h> #include <v...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
180
2
#include <iostream> using namespace std; #define REP(i, a, n) for (int i = a; i < n; i++) int main() { int R0, W0, C, R; while (cin >> R0 >> W0 >> C >> R, R0 || W0 || C || R) { REP(i, 0, 101) { if (R0 + i * R >= W0 * C) { cout << i << endl; break; } } } return 0; }
#include <iostream> using namespace std; #define REP(i, a, n) for (int i = a; i < n; i++) int main() { int R0, W0, C, R; while (cin >> R0 >> W0 >> C >> R, R0 || W0 || C || R) { REP(i, 0, 10001) { if (R0 + i * R >= W0 * C) { cout << i << endl; break; } } } return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
89
2