buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <stdio.h> int main() { int n, i, j, k; int l[101]; // 整数の入力 scanf("%d", &n); // スペース区切りの整数の入力 for (i = 0; i < n * 2; i++) { scanf("%d", &l[i]); } //並び替え大きい順 for (i = 0; i < n * 2; i++) { for (j = i + 1; j < n * 2; j++) { if (l[i] < l[j]) { k = l[i]; l[i] = l[j];...
#include <stdio.h> int main() { int n, i, j, k; int l[201]; // 整数の入力 scanf("%d", &n); // スペース区切りの整数の入力 for (i = 0; i < n * 2; i++) { scanf("%d", &l[i]); } //並び替え大きい順 for (i = 0; i < n * 2; i++) { for (j = i + 1; j < n * 2; j++) { if (l[i] < l[j]) { k = l[i]; l[i] = l[j];...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["-", 0, 7, 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, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-",...
1
229
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespac...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespac...
[["-", 0, 30, 0, 14, 8, 9, 0, 171, 0, 184], ["-", 0, 30, 0, 14, 8, 9, 0, 171, 141, 22], ["-", 8, 9, 0, 171, 0, 1, 0, 2, 63, 22], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 2...
1
243
class Scanner: def readint(self): return int(input()) def readstring(self): return input().rstrip() def readline(self): return list(map(int, input().split())) def reads(self): return list(input().split()) def newmat(self, n, x): return [[x for i in range(n)] for j in range(n)] sc = Scanner() n = sc...
class Scanner: def readint(self): return int(input()) def readstring(self): return input().rstrip() def readline(self): return list(map(int, input().split())) def reads(self): return list(input().split()) def newmat(self, n, x): return [[x for i in range(n)] for j in range(n)] sc = Scanner() n = sc...
[["-", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 206, 206, 663, 0, 102], ["-", 0, 652, 3, 4, 0, 206, 206, 663, 0, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 65...
5
144
#include <bits/stdc++.h> using namespace std; int ar[200]; int main() { #ifndef ONLINE_JUDGE freopen("t.in", "r", stdin); #endif int n; scanf("%d", &n); for (int i = 0; i < 2 * n; ++i) scanf("%d", &ar[i]); stable_sort(ar, ar + 2 * n, greater<int>()); int ans = 0; for (int i = 1; i < 2 * n; i += 2...
#include <bits/stdc++.h> using namespace std; int ar[300]; int main() { int n; scanf("%d", &n); for (int i = 0; i < 2 * n; ++i) scanf("%d", &ar[i]); stable_sort(ar, ar + 2 * n, greater<int>()); int ans = 0; for (int i = 1; i < 2 * n; i += 2) ans += ar[i]; printf("%d\n", ans); return 0; }
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 171, 0, 184], ["-", 0, 30, 0, 14, 8, 9, 0, 171, 141, 22], ["-", 8, 9, 0, 171, 0, 1, 0, 2, 63, 22], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4,...
1
136
#include <algorithm> #include <bitset> #include <cfloat> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define rep(i, a, b) for (int ...
#include <algorithm> #include <bitset> #include <cfloat> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define rep(i, a, b) for (int ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 146], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 147], ["+", 8, 9, 0, 171, 0, 1, 0, 2, 63, 22], ["+", 0, 171, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 171, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 171, 0, 1, 0, 2, 3, 4,...
1
527
#include <algorithm> #include <iostream> #include <string> #define int long long using namespace std; const int MOD = 1e9 + 7; int n; int a[100]; signed main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int res = 0; for (int i = 0; i < n; i += 2) res += a[i]; cout << res <<...
#include <algorithm> #include <iostream> #include <string> #define int long long using namespace std; const int MOD = 1e9 + 7; int n; int a[1000]; signed main() { cin >> n; for (int i = 0; i < 2 * n; i++) cin >> a[i]; sort(a, a + 2 * n); int res = 0; for (int i = 0; i < 2 * n; i += 2) res += a[i]; c...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 31, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 48], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 48]]
1
108
#include <algorithm> #include <iostream> using namespace std; int main() { int a[100]; int n; cin >> n; n = n * 2; for (int i = 0; i < 100; i++) { a[i] = 0; } for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int ans = 0; for (int i = 0; i < n; i++) { ans += a[2 * i]; } ...
#include <algorithm> #include <iostream> using namespace std; int main() { int a[300]; int n; cin >> n; n = n * 2; for (int i = 0; i < 300; i++) { a[i] = 0; } for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); int ans = 0; n = n / 2; for (int i = 0; i < n; i++) { ans += a[...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 1...
1
127
#include <stdio.h> int main(void) { int N; int L[2 * N]; int i, j, tmp; int sum; scanf("%d", &N); for (i = 0; i < 2 * N; i++) { scanf("%d", &L[i]); } for (i = 0; i < 2 * N - 1; i++) { for (j = i + 1; j < 2 * N; j++) { if (L[i] > L[j]) { tmp = L[i]; L[i] = L[j]; L[j...
#include <stdio.h> int main(void) { int N; int L[200] = {0}; int i, j, tmp; int sum; scanf("%d", &N); N *= 2; for (i = 0; i < N; i++) { scanf("%d", &L[i]); } for (i = 0; i < N; i++) { for (j = i + 1; j < N; j++) { if (L[i] > L[j]) { tmp = L[i]; L[i] = L[j]; L[j] ...
[["-", 8, 9, 0, 43, 49, 80, 81, 16, 31, 13], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 17, 48], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, ...
0
189
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef vector<int> vi; typedef long int li; typedef unsigned long lo...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef vector<int> vi; typedef long int li; typedef unsigned long lo...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 18], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 47], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 0, 70], ["-", 0, 14, 8, ...
1
123
#include <bits/stdc++.h> using namespace std; #define fi first #define se second const int N = 101; int n; int a[2 * N]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE ios_base::sync_with_stdio(0); cin >> n; for (int i = 0; i < 2 ...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second const int N = 101; int n; int a[2 * N]; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); // #endif // ONLINE_JUDGE ios_base::sync_with_stdio(0); cin >> n...
[["-", 0, 30, 0, 14, 8, 9, 0, 171, 0, 184], ["-", 0, 30, 0, 14, 8, 9, 0, 171, 141, 22], ["-", 8, 9, 0, 171, 0, 1, 0, 2, 63, 22], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 2...
1
148
#include <stdio.h> #define NUM_MAX (100) int main(void) { int num; int length[100] = {}; int i, j; int temp; int sum = 0; scanf("%d", &num); for (i = 0; i < num * 2; i++) { scanf("%d", &length[i]); } printf("\n"); for (i = 0; i < num * 2; i++) { for (j = i + 1; j < num * 2; j++) { ...
#include <stdio.h> int main(void) { int num; int length[200] = {}; int i, j; int temp; int sum = 0; scanf("%d", &num); for (i = 0; i < num * 2; i++) { scanf("%d", &length[i]); } for (i = 0; i < num * 2; i++) { for (j = i + 1; j < num * 2; j++) { if (length[i] < length[j]) { t...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["-", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2,...
0
204
import java.util.*; class Main { void main(String[] args) { Scanner sc = new Scanner(System.in); int yousosu = sc.nextInt(); int[] l = new int[yousosu]; for (int i = 0; i < l.length; i++) { l[i] = sc.nextInt(); } Arrays.sort(l); int ans = 0; for (int j = 0; j < l.length - 1;...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n * 2]; for (int i = 0; i < l.length; i++) { l[i] = sc.nextInt(); } Arrays.sort(l); int ans = 0; for (int j = 0; j <...
[["+", 36, 36, 0, 493, 0, 235, 0, 494, 0, 259], ["+", 0, 235, 8, 498, 0, 195, 0, 494, 0, 259], ["+", 0, 235, 8, 498, 0, 195, 0, 494, 0, 115], ["-", 0, 195, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 503, 49, 200, 141, 22], ["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 22], ["+", 49, 200, 51, 227, 497, 5...
3
141
import java.util.*; class Main { void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n * 2]; for (int i = 0; i < l.length; i++) { l[i] = sc.nextInt(); } Arrays.sort(l); int ans = 0; for (int i = 0; i < l.length; i += 2) { ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] l = new int[n * 2]; for (int i = 0; i < l.length; i++) { l[i] = sc.nextInt(); } sc.close(); Arrays.sort(l); int ans = 0; for...
[["+", 36, 36, 0, 493, 0, 235, 0, 494, 0, 259], ["+", 0, 235, 8, 498, 0, 195, 0, 494, 0, 259], ["+", 0, 235, 8, 498, 0, 195, 0, 494, 0, 115], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 500, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 0, 131], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24],...
3
142
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; int main() { int N; vector<int> L; int tmp = 0, ret = 0; cin >> N; for ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; int main() { int N; vector<int> L; int tmp, ret = 0; cin >> N; for (int...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9,...
1
128
#include <algorithm> #include <stdio.h> using namespace std; int main(void) { int n, N; int L[100]; int i, j, tmp; long long sum = 0; scanf("%d", &n); N = 2 * n; for (i = 0; i < N; i++) scanf("%d", &L[i]); sort(L, L + N); for (i = 0; i < N; i++) if (!(i % 2)) sum += L[i]; printf("...
#include <algorithm> #include <stdio.h> using namespace std; int main(void) { int n, N; int L[200]; long long sum = 0; scanf("%d", &n); N = 2 * n; for (int i = 0; i < N; i++) scanf("%d", &L[i]); sort(L, L + N); for (int i = 0; i < N; i++) if (!(i % 2)) sum += L[i]; printf("%lld\n", ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40]]
1
132
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, l[110]; cin >> n; for (i = 0; i < 2 * n; i++) { cin >> l[i]; } sort(l, l + n + n); long long sum = 0; for (i = 0; i < 2 * n; i += 2) { sum += min(l[i], l[i + 1]); } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, n, l[1000]; cin >> n; for (i = 0; i < 2 * n; i++) { cin >> l[i]; } j = n * 2; sort(l, l + j); long long sum = 0; for (i = 0; i < 2 * n; i += 2) { sum += min(l[i], l[i + 1]); } cout << sum << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 30, 0, 14, 8, 9,...
1
114
// scanf 等でエラーを出さないように追加 #define _CRT_SECURE_NO_WARNINGS 1 #include <algorithm> #include <iostream> #include <limits.h> #include <math.h> #include <memory> #include <numeric> #include <set> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #include <fun...
// scanf 等でエラーを出さないように追加 #define _CRT_SECURE_NO_WARNINGS 1 #include <algorithm> #include <iostream> #include <limits.h> #include <math.h> #include <memory> #include <numeric> #include <set> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #include <fun...
[["-", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 44], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25], ["-", 0, 7...
1
190
function main(input) { var ans = 0; input = input.split("\n"); var n = input[0]; var skewers = input[1].split(" "); for (var i = 0; i < skewers.length; i++) { skewers[i] = parseInt(skewers[i]); } skewers.sort(); for (var i = 0; i < n; i++) { ans += parseInt(skewers[2 * i]); } console.log(ans...
function main(input) { var ans = 0; input = input.split("\n"); var n = input[0]; var skewers = input[1].split(" "); for (var i = 0; i < skewers.length; i++) { skewers[i] = parseInt(skewers[i]); } skewers.sort(function(a, b) { return a - b }); for (var i = 0; i < n; i++) { ans += skewers[2 * i]; ...
[["+", 0, 1, 0, 2, 3, 3, 0, 63, 0, 63], ["+", 0, 2, 3, 3, 0, 63, 54, 495, 0, 24], ["+", 0, 2, 3, 3, 0, 63, 54, 495, 0, 22], ["+", 0, 2, 3, 3, 0, 63, 54, 495, 0, 21], ["+", 0, 2, 3, 3, 0, 63, 8, 556, 0, 45], ["+", 3, 3, 0, 63, 8, 556, 0, 37, 0, 38], ["+", 0, 63, 8, 556, 0, 37, 0, 16, 31, 22], ["+", 0, 63, 8, 556, 0, 37,...
2
139
#include <bits/stdc++.h> typedef long long LL; // Attention!! using namespace std; #define fillchar(a, x) memset(a, x, sizeof(a)) #define MP make_pair #define PB push_back #define endl '\n' const int M = 1000000007; int main() { ios_base::sync_with_stdio(0); cout.precision(15); cout.setf(ios::fixed); LL n,...
#include <bits/stdc++.h> typedef long long LL; // Attention!! using namespace std; #define fillchar(a, x) memset(a, x, sizeof(a)) #define MP make_pair #define PB push_back #define endl '\n' const int M = 1000000007; int main() { ios_base::sync_with_stdio(0); cout.precision(15); cout.setf(ios::fixed); LL n,...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["...
1
175
#include <cstdio> #include <iostream> using namespace std; long long solve(long long N, long long X) { // fprintf(stderr,"solve(%lld,%lld)\n",N,X); long long ret = X + (N - X) / X * 2 * X; long long r = (N - X) % X; if (r) ret += X + solve(X, r); return ret; } int main() { long long N, X; cin >> N >...
#include <cstdio> #include <iostream> using namespace std; long long solve(long long N, long long X) { // fprintf(stderr,"solve(%lld,%lld)\n",N,X); long long ret = X + (N - X) / X * 2 * X; long long r = (N - X) % X; if (r) ret += X + solve(X, r); return ret; } int main() { long long N, X; cin >> N >...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+...
1
104
#include "algorithm" #include "bitset" #include "cassert" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "un...
#include "algorithm" #include "bitset" #include "cassert" #include "climits" #include "cmath" #include "cstdio" #include "functional" #include "iomanip" #include "iostream" #include "list" #include "map" #include "numeric" #include "queue" #include "random" #include "set" #include "stack" #include "string" #include "un...
[["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 14, 8, 9, 0, 1, 0, 11...
1
191
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): ...
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): ...
[["+", 36, 36, 36, 36, 0, 656, 0, 14, 0, 669], ["+", 36, 36, 36, 36, 0, 656, 0, 14, 141, 22], ["+", 36, 36, 0, 656, 0, 14, 54, 54, 0, 24], ["+", 36, 36, 0, 656, 0, 14, 54, 54, 0, 22], ["+", 36, 36, 0, 656, 0, 14, 54, 54, 0, 21], ["+", 36, 36, 0, 656, 0, 14, 54, 54, 0, 25], ["+", 36, 36, 36, 36, 0, 656, 0, 14, 0, 102], ...
5
293
#include <bits/stdc++.h> #include <unordered_map> typedef long long ll; #define rep(i, m, n) for (ll i = (m); i < (n); i++) #define rrep(i, m, n) for (ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x, y) cout << (x) << " " << (y) << endl; #define printa(x, n) ...
#include <bits/stdc++.h> #include <unordered_map> typedef long long ll; #define rep(i, m, n) for (ll i = (m); i < (n); i++) #define rrep(i, m, n) for (ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x, y) cout << (x) << " " << (y) << endl; #define printa(x, n) ...
[["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9...
1
186
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, x, ans; ll len(ll y, ll s) { ll k = x / y, r = x % y; if (!r) return s + (2 * k - 1) * y; else return len(y - r, s + 2 * k * y + r + x); } int main() { cin >> n >> x; if (2 * x == n) ans = (n / 2) * 3; else if (2 * x < ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll len(ll y, ll x, ll s) { ll k = x / y, r = x % y; if (!r) return s + (2 * k - 1) * y; else return len(r, y - r, s + 2 * k * y + 2 * r); } int main() { ll n, x, ans; cin >> n >> x; if (2 * x == n) ans = (n / 2) * 3; else if...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 35], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["+", 0, 30, 0, 14, 49, 53, 54, 55, 0, 21], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 49, 22], ["+", 7...
1
224
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n;...
#include <algorithm> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n;...
[["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13],...
1
1,117
/* , \ / , / \ )\__/( / \ / \ (_\ /_) / \ ____/_____\__\@ @/___/_____\____ | |\../| | | \VV/ | | ------hoi------- | |_________________________________| | /\ / \\ \ /\ ...
/* , \ / , / \ )\__/( / \ / \ (_\ /_) / \ ____/_____\__\@ @/___/_____\____ | |\../| | | \VV/ | | ------hoi------- | |_________________________________| | /\ / \\ \ /\ ...
[["+", 8, 9, 0, 1, 0, 16, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["+", 0, 16, 12, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 16, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31,...
1
146
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <st...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <st...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["+", 8, 9, 0, 57, 64, 37, 0, 91, 17, 33], ["+", 8, 9, 0, 57, 64, 37, 0, 91, 28, 22], ["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, ...
1
195
import sys sys.setrecursionlimit(100000) from math import floor n,x=map(int,input().split()) ans=0 def f(x,y): if y%x==0: return y//x*2-x return 2*x*(y//x)+f(y%x,x) print(n+f(min(x,n-x),max(x,n-x)))
import sys sys.setrecursionlimit(100000) from math import floor n,x=map(int,input().split()) ans=0 def f(x,y): if y%x==0: return (y//x-1)*2*x+x return 2*x*(y//x)+f(y%x,x) print(n+f(min(x,n-x),max(x,n-x)))
[["+", 0, 657, 31, 657, 31, 657, 31, 23, 0, 24], ["+", 31, 657, 31, 657, 31, 23, 0, 657, 17, 33], ["+", 31, 657, 31, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 657, 31, 657, 31, 657, 31, 23, 0, 25], ["-", 0, 57, 64, 196, 0, 37, 0, 657, 17, 33], ["+", 64, 196, 0, 37, 0, 657, 31, 657, 17, 48], ["+", 64, 196, 0, 37, 0, 657, ...
5
98
#include <algorithm> #include <functional> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) #define repR(i, n) for (int i...
#include <algorithm> #include <functional> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) #define repR(i, n) for (int i...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 13], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 48], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 52, 15...
1
181
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repe(i, n) rep(i, (n) + 1) #define per(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define pere(i, n) rep(i, (n) + 1) #define all(x) (x).begin(), (x).end() #define SP << " " << #define RET return 0 #define MOD 10...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repe(i, n) rep(i, (n) + 1) #define per(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define pere(i, n) rep(i, (n) + 1) #define all(x) (x).begin(), (x).end() #define SP << " " << #define RET return 0 #define MOD 10...
[["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64,...
1
175
#include <algorithm> #include <complex> #include <ctype.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define FOR(i, a, b) ...
#include <algorithm> #include <complex> #include <ctype.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; #define FOR(i, a, b) ...
[["-", 75, 76, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 75, 76, 0, 57, 64, 9, 0, 43, 39, 78], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 57, 64, 9, 0, 43, 49, 50, 0, 32], ["+", 75, 76, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 0, 57, 64, 9, 0, 37, 0, 16, 31, 22], ["+", 0, 57, 64, 9, 0, 37, 0, 16, 17, 48], ["+", 0, 57, 64,...
1
300
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORE(i, a, b) for (int i = (a); i <= (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define repe(i, n) for (int i = 0; i <= (n); ++i) #define ALL(v) (v).begin(), (v).end() #defin...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORE(i, a, b) for (int i = (a); i <= (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define repe(i, n) for (int i = 0; i <= (n); ++i) #define ALL(v) (v).begin(), (v).end() #defin...
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["...
1
188
#include <bits/stdc++.h> #include <unordered_set> using namespace std; #define ll long long #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define repeat(i, s, n) for (int(i) = s; (i) < (n); (i)++) #define revrep(i, n) for (int(i) = (n)-1; i >= 0; i--) ll f(ll a, ll b) { a = min(a, b); b = max(a, b); if (a...
#include <bits/stdc++.h> #include <unordered_set> using namespace std; #define ll long long #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define repeat(i, s, n) for (int(i) = s; (i) < (n); (i)++) #define revrep(i, n) for (int(i) = (n)-1; i >= 0; i--) ll f(ll aa, ll bb) { ll a = min(aa, bb); ll b = max(aa, ...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 49, 22], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 16, 31...
1
181
/** SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAj...
/** SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAj...
[["-", 0, 1, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 16, 12, 16, 12, 23, 0, 24], ["-", 0, 1, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 12, 16, 12, 23, 0, 16, 12, 2, 63, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 23, 0, 16, 12, 2, 3, 4, 0, 21], ["+", 12, 23, 0, 16, 12, 2, 3, 4, 0, 25]]
1
309
#include <bits/stdc++.h> using namespace std; const int N = 5e5; #define C getchar() - 48 int read() { int s = 0, t = 1, k = C; for (; k < 0 || 9 < k; k = C) if (k == -3) t = -1; for (; 0 <= k && k <= 9; k = C) s = (s << 1) + (s << 3) + k; return s * t; } int n, A, x, y; void in() { cin >> A >...
#include <bits/stdc++.h> using namespace std; #define ll long long const ll N = 5e5; #define C getchar() - 48 ll read() { ll s = 0, t = 1, k = C; for (; k < 0 || 9 < k; k = C) if (k == -3) t = -1; for (; 0 <= k && k <= 9; k = C) s = (s << 1) + (s << 3) + k; return s * t; } ll n, A, x, y; void in...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 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, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-...
1
192
#include <bits/stdc++.h> #include <ext/pb_ds/priority_queue.hpp> #define priority_queue __gnu_pbds::priority_queue typedef long long LL; typedef long double LD; typedef unsigned long long ul; #define ri register int #define pb push_back #define fi first #define se second #define mid ((l + r) >> 1) #define ls (i << 1) #...
#include <bits/stdc++.h> #include <ext/pb_ds/priority_queue.hpp> #define priority_queue __gnu_pbds::priority_queue typedef long long LL; typedef long double LD; typedef unsigned long long ul; #define ri register int #define pb push_back #define fi first #define se second #define mid ((l + r) >> 1) #define ls (i << 1) #...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 16, 31, 16, 12, 16, 12, 2, 63, 22], ["+", 31, 16, 12, 16, 12, 2, 3, 4, 0, 24], ["+", 31, 16, 12, 16, 12, 2, 3, 4, 0, 22], ["+", 31, 16, 12, 16, 12, 2, 3, 4, 0, 21], ["+", 31, 16, 12, 16, 12, 2, 3, 4, 0, 25]]
1
355
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; typedef ...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; typedef ...
[["+", 75, 76, 0, 57, 75, 76, 0, 57, 0, 121], ["+", 0, 57, 75, 76, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12...
1
618
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define MOD 1000000007 typedef long long ll; using namespace std; int main() { ll n, x; cin >> n >> x; ll a = x, b = n - x; if (a < b) swap(a, b); ll ans = a +...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define MOD 1000000007 typedef long long ll; using namespace std; int main() { ll n, x; cin >> n >> x; ll a = x, b = n - x; if (a < b) swap(a, b); ll ans = a +...
[["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+",...
1
127
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll ...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using ll ...
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 109], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, ...
1
3,844
#include <bits/stdc++.h> typedef long long i64; using std::cin; using std::cout; using std::endl; i64 f(i64 a, i64 b) { if (b < a) std::swap(a, b); if (a == 1) return 2 * b - 1; if (a) return 2 * a * (b / a) + f(b % a, a); return 0; } int main() { i64 n, x; cin >> n >> x; cout << n + f(x, n...
#include <bits/stdc++.h> typedef long long i64; using std::cin; using std::cout; using std::endl; i64 f(i64 a, i64 b) { if (b < a) std::swap(a, b); if (b % a == 0) return (b / a * 2 - 1) * a; if (a) return 2 * a * (b / a) + f(b % a, a); return 0; } int main() { i64 n, x; cin >> n >> x; cout...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 64, 37, 0, 16, 31, 16, 31, 13], ["-", 0, 57, 64, 37, 0, 16, 31, 16, 17, 48], ["+", 0, 57, 64, 37, 0, 16, 31, 23, 0, 24], ...
1
123
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <th...
#include <algorithm> #include <cassert> #include <chrono> #include <cmath> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <th...
[["-", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["+", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["-", 0, 57, 64, 9, 0, 37, 0, 16, 31, 22], ["-", 0, 57, 64, 9, 0, 37, 0, 16, 17, 72], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 8, 9, 0, 4...
1
195
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; #define REP(i, a, b) for (i = a; i < b; i++) #define REP1(i, b, a) for (i = b - 1; i >= a; i--) #define output(x) cout << x << endl...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; #define REP(i, a, b) for (i = a; i < b; i++) #define REP1(i, b, a) for (i = b - 1; i >= a; i--) #define output(x) cout << x << endl...
[["+", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]...
1
383
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; typedef long long ll; typedef double lf; typedef long double Lf; t...
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; typedef long long ll; typedef double lf; typedef long double Lf; t...
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 12, 16, 12, 23, 0, 16, 12, 2, 63, 22], ["+", 12, 23, 0, 16...
1
130
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<double> vd; typedef vector<long long> vll; typedef vector<string> vs; typedef vector<bool> vb; typedef pair<int, int> pii; struct cww { cww() { ios::sync_with_stdio(false); cin.ti...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<double> vd; typedef vector<long long> vll; typedef vector<string> vs; typedef vector<bool> vb; typedef pair<int, int> pii; struct cww { cww() { ios::sync_with_stdio(false); cin.ti...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-", 0, 42, 0, 53, 54, 55, 0, 56, 39, 40], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 37, 0, 16, 31, 16, 31, 13], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 31, 13], ["+", 8, 9, 0, 37, 0, 16, 12, 23, 0, 24], ["-", 8, 9, 0, 37, 0...
1
485
#include <cstdio> #define ll long long #define rg register int #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) #define rep(a, b, c) for (rg a = b; a <= c; ++a) inline ll read() { ll x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0'...
#include <cstdio> #define ll long long #define rg register int #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) #define rep(a, b, c) for (rg a = b; a <= c; ++a) inline ll read() { ll x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0'...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["-", 64, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, ...
1
247
#include <bits/stdc++.h> using namespace std; int dfs(int a, int b) { int ans = 0; if (a % b != 0) { ans += (a / b) * 2 * b; ans += dfs(b, a % b); } else { ans += ((a / b) * 2 * b) - b; } // cout<<"a"<<a<<"b"<<b<<"ans"<<ans<<"\n"; return ans; } int main() { int n, x; cin >> n >> x; int ans...
#include <bits/stdc++.h> using namespace std; long long dfs(long long a, long long b) { long long ans = 0; if (a % b != 0) { ans += (a / b) * 2 * b; ans += dfs(b, a % b); } else { ans += ((a / b) * 2 * b) - b; } // cout<<"a"<<a<<"b"<<b<<"ans"<<ans<<"\n"; return ans; } int main() { long long n,...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
129
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define i_7 (ll)(1E9 + 7) #define i_5 (ll)(1E9 + 5) ll mod(ll a) { ll c = a % i_7; if (c >= 0) return c; else return c + i_7; } typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; ll inf = (ll)1E12; // 10^12 #define rep(i, l, r) for (l...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define i_7 (ll)(1E9 + 7) #define i_5 (ll)(1E9 + 5) ll mod(ll a) { ll c = a % i_7; if (c >= 0) return c; else return c + i_7; } typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; ll inf = (ll)1E12; // 10^12 #define rep(i, l, r) for (l...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 38], ["+", 0, 14, 8...
1
243
#include <bits/stdc++.h> using namespace std; int main() { long long n, x; scanf("%lld %lld", &n, &x); long long ans = n; /*if (n % x == 0) { cout << 3 * x << endl; return 0; } */ n -= x; while (true) { if (n % x == 0) { ans += 2 * x * (n / x) - x; break; } else {...
#include <bits/stdc++.h> using namespace std; int main() { long long n, x; scanf("%lld %lld", &n, &x); long long ans = n; n -= x; while (true) { if (n % x == 0) { ans += 2 * x * (n / x) - x; break; } else { ans += 2 * x * (n / x); } long long res = n % x; n = x; x =...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 52, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0...
1
113
#include <bits/stdc++.h> #define N 100020 #define ll long long using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') ch == '-' && (f = 0) || (ch = getchar()); while (ch <= '9' && ch >= '0') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); retur...
#include <bits/stdc++.h> #define N 100020 #define ll long long using namespace std; inline ll read() { ll x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') ch == '-' && (f = 0) || (ch = getchar()); while (ch <= '9' && ch >= '0') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return ...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, ...
1
226
// waz #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)((x).size())) typedef pair<int, int> PII; typedef vector<int> VI; typedef long long int64; typedef unsigned int uint; typedef uns...
// waz #include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)((x).size())) typedef pair<int, int> PII; typedef vector<int> VI; typedef long long int64; typedef unsigned int uint; typedef uns...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 31, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 57, 75, 76, 0, 9...
1
353
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef pair<P, int> T; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 #define LLINF 1000000000000000 #define sz(x) ((int)(x).size()) #define f...
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef pair<P, int> T; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 #define LLINF 1000000000000000 #define sz(x) ((int)(x).size()) #define f...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]...
1
299
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
[["+", 0, 57, 15, 679, 31, 666, 0, 657, 31, 22], ["+", 0, 57, 15, 679, 31, 666, 0, 657, 17, 109], ["+", 0, 57, 15, 679, 31, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 667, 60], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 612], ["+", 698, 14, 8, 196, 0, 57, 15, 679, 17, 355], ["-", 8, 196, 0, 57, 15, 66...
5
362
#include <algorithm> #include <iostream> using namespace std; using ll = long long; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll calc(ll a, ll b) { if (a < b) return calc(b, a); if (a == 1) return 2 * b - 1; return 2 * b + calc(a - b, b); } int main() { ll n,...
#include <algorithm> #include <iostream> using namespace std; using ll = long long; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll calc(ll a, ll b) { if (a > b) return calc(b, a); if (a == 1) return 2 * b - 1; return 2 * (b / a) * a + calc(b % a, a); } int main()...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 17, 85], ["+", 31, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 23, 0, 25], ["+", 8, 9, 0, 37, 0, 16, 31, 16, 17, 48], ["+"...
1
169
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" #include <random> #include <unordered_map> #include <unordered_set> //#include <opencv2/core.hpp> //#include <opencv2/highgui.hpp> //#include <opencv2/imgproc.hpp> using namespace std; //呪文 #define DUMPOUT cerr #define dump(...) ...
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" #include <random> #include <unordered_map> #include <unordered_set> //#include <opencv2/core.hpp> //#include <opencv2/highgui.hpp> //#include <opencv2/imgproc.hpp> using namespace std; //呪文 #define DUMPOUT cerr #define dump(...) ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 91, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 91, 28, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 16, 12, 23, 0, 16, 12, 13]]
1
1,495
#include <bits/stdc++.h> using namespace std; long long n, x; long long g(long long a, long long b) { if (b == 0) return -a; if (b == 1) return 2 * a - 1; return 2 * (a / b * b) + g(b, a % b); } long long f(long long a, long long b) { if (a % 2 == 1) return 3 * (n - 1); return n + g(n - b, b); ...
#include <bits/stdc++.h> using namespace std; long long n, x; long long g(long long a, long long b) { if (b == 0) return -a; if (b == 1) return 2 * a - 1; return 2 * (a / b * b) + g(b, a % b); } long long f(long long a, long long b) { // if(a % 2 == 1) return 3*(n-1); return a + g(a - b, b); } int...
[["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["...
1
139
/////////////////////////////////////////////////////////////// //__________________________________________________________// // \\\\\\\\\\\---------------------------------------------// // // __ __ // // // \\\\\\\\ |. \ / .| ///////// // // ////...
/////////////////////////////////////////////////////////////// //__________________________________________________________// // \\\\\\\\\\\---------------------------------------------// // // __ __ // // // \\\\\\\\ |. \ / .| ///////// // // ////...
[["-", 0, 30, 0, 14, 8, 9, 0, 171, 0, 184], ["-", 0, 30, 0, 14, 8, 9, 0, 171, 141, 22], ["-", 8, 9, 0, 171, 0, 1, 0, 2, 63, 22], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 0, 171, 0, 1, 0, 2, 3, 4, 0, 2...
1
315
#include <bits/stdc++.h> using namespace std; int n, x; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } inline void init() { scanf("%d%d", &n, &x); } inline void work() { printf("%d\n", 3 * (n - gcd(n, x))); } int main() { init(); work(); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, x; long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } inline void init() { scanf("%lld%lld", &n, &x); } inline void work() { printf("%lld\n", 3 * (n - gcd(n, x))); } int main() { init(); work(); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0,...
1
102
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { long long n, x; scanf("%lld%lld", &n, &x); if (__gcd(n, x) != 1) { printf("%lld", x * 3 * ((n - __gcd(n, x)) / x)); return 0; } printf("%lld", (n - 1) * 3); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; int main() { long long n, x; scanf("%lld%lld", &n, &x); if (__gcd(n, x) != 1) { printf("%lld", __gcd(n, x) * 3 * (n / __gcd(n, x) - 1)); return 0; } printf("%lld", (n - 1) * 3); return 0; }
[["+", 3, 4, 0, 16, 31, 16, 31, 2, 63, 22], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 23, 0...
1
97
#include <iostream> using namespace std; int main() { int64_t N, x; cin >> N >> x; int64_t ans = N; N = N - x; int d = 0; while (x >= 1LL) { ans += 2 * x * (N / x); int64_t t = N; if (d) ans -= x; N = x; x = t % x; d = 1 - d; } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { int64_t N, x; cin >> N >> x; int64_t ans = N; N = N - x; int d = 0; while (x >= 1LL) { ans += 2 * x * (N / x); int64_t t = N; if ((N % x == 0)) ans -= x; N = x; x = t % x; d = 1 - d; } cout << ans << endl; retu...
[["-", 0, 52, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 23, 0, 24], ["+", 15, 339, 51, 23, 0, 16, 31, 16, 31, 22], ["+", 15, 339, 51, 23, 0, 16, 31, 16, 17, 109], ["+", 15, 339, 51, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 23, 0, 16, 12, 13...
1
97
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 10; const int mod = 1e9 + 7; int a[500]; int main() { ll n, x; cin >> n >> x; x = max(x, n - x); x++; cout << 3 * x << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e6 + 10; const int mod = 1e9 + 7; int a[500]; int main() { ll n, x; cin >> n >> x; x = __gcd(n, x); x = n - x; cout << 3 * x << endl; return 0; }
[["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 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], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17...
1
75
/*+lmake * STD = c++14 * DEFINE += MDEBUG */ #include <bits/stdc++.h> using namespace std; using LL = long long; #ifdef MDEBUG #define debug(args...) \ { \ dbg, args; ...
/*+lmake * STD = c++14 * DEFINE += MDEBUG */ #include <bits/stdc++.h> using namespace std; using LL = long long; #ifdef MDEBUG #define debug(args...) \ { \ dbg, args; ...
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 52, 15, 339, 51, 16, 31, 16, 17, 79], ["-", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 79], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 1...
1
228
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL n; LL x; int main() { scanf("%lld%lld", &n, &x); LL ans = n; LL at = x; LL kan = n - x; while (x != 0) { LL tmp = kan / x; ans += tmp * 2LL * x; kan %= x; x = kan; if (x == 0) break; tmp = at / x; ans...
#include <bits/stdc++.h> using namespace std; typedef long long LL; LL n; LL x; int main() { scanf("%lld%lld", &n, &x); LL ans = n; LL at = x; LL kan = n - x; while (x != 0) { LL tmp = kan / x; ans += tmp * 2LL * x; kan %= x; if (kan == 0) ans -= x; x = kan; if (x == 0) ...
[["+", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, ...
1
131
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) long long func(long long a, long long b) { if (a > b) swap(a, b); cout << a << " " << b << endl; /* if(a != b){ ans += 2 * a; return func(b - a, a); }else{ ans += a; return 0; } */ if...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < n; i++) long long func(long long a, long long b) { if (a > b) swap(a, b); /* if(a != b){ ans += 2 * a; return func(b - a, a); }else{ ans += a; return 0; } */ if (b % a == 0) return 2 * a * ...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-",...
1
146
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // Your code here! BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] num = line.split(" "); ...
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // Your code here! BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] num = line.split(" "); ...
[["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 500, 22], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
3
207
#include <iostream> using namespace std; int gcd(int a, int b) { if (a == 0 || b == 0) return a + b; else if (a >= b) return gcd(a % b, b); else return gcd(a, b % a); } int main() { int n, x; cin >> n >> x; cout << 3 * (n - gcd(n, x)); }
#include <iostream> #define LLI long long int using namespace std; LLI gcd(LLI a, LLI b) { if (a == 0 || b == 0) return a + b; else if (a >= b) return gcd(a % b, b); else return gcd(a, b % a); } int main() { LLI n, x; cin >> n >> x; cout << 3 * (n - gcd(n, x)); }
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 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, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-...
1
92
#include <iostream> using namespace std; long long solve(long long x, long long n) { long long ans; if (n % x == 0) return n * 2 - x; ans = n / x * x * 2 + solve(n % x, x); return ans; } int main() { long long n, x; long long ans; cin >> n >> x; ans = solve(x, n - x) - n; cout << ans << endl; ...
#include <bits/stdc++.h> using namespace std; long long john(long long x, long long n) { long long ans; if (n % x == 0) return n * 2 - x; ans = n / x * x * 2 + john(n % x, x); return ans; } int main() { long long n, x; long long ans; cin >> n >> x; ans = john(x, n - x) + n; cout << ans << endl; ...
[["-", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["+", 36, 36, 36, 36, 0, 30, 0, 135, 136, 137], ["-", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["+", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 2, 63, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 2, 63, 22], ["+"...
1
105
#include <algorithm> #include <cstdio> using ll = long long; ll N, X; // f(3,2) = 2*2*1+f(2,1) // f(2,1) = 2*1*2+f(1,0) // f(1,0) = 0 ll f(ll a, ll b) { return b ? 2 * b * (a / b) + f(b, a % b) : -1; } int main() { scanf("%lld%lld", &N, &X); ll a = N - X, b = X; if (a < b) std::swap(a, b); printf("%ll...
#include <algorithm> #include <cstdio> using ll = long long; ll N, X; // f(3,2) = 2*2*1+f(2,1) // f(2,1) = 2*1*2+f(1,0) // f(1,0) = 0 ll f(ll a, ll b) { return a % b ? 2 * b * (a / b) + f(b, a % b) : ((a / b) * 2 - 1) * b; } int main() { scanf("%lld%lld", &N, &X); ll a = N - X, b = X; if (a < b) std::s...
[["+", 8, 9, 0, 37, 0, 41, 15, 16, 31, 22], ["+", 8, 9, 0, 37, 0, 41, 15, 16, 17, 109], ["-", 0, 14, 8, 9, 0, 37, 0, 41, 75, 13], ["+", 0, 37, 0, 41, 75, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 16...
1
118
#include <bits/stdc++.h> using namespace std; long long ans = 0; void brute(int a, int b) { if (b == 0) return; ans += a / b * 2 * b; if (a % b == 0) ans -= b; brute(b, a % b); } int main() { int x, n; cin >> x >> n; brute(max(x, n - x), min(x, n - x)); cout << ans + n; }
#include <bits/stdc++.h> using namespace std; long long ans = 0; void brute(long long a, long long b) { if (b == 0) return; ans += a / b * 2 * b; if (a % b == 0) ans -= b; brute(b, a % b); } int main() { long long x, n; cin >> n >> x; brute(max(x, n - x), min(x, n - x)); cout << ans + n; }
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9,...
1
106
#include <cstdio> using namespace std; long long ans; long long dfs(int a, int b) { if (b % a == 0) { return b / a * a * 3 - a; } return dfs(b % a, a) + b / a * a * 3 + b % a; } int main() { int n, x; scanf("%d%d", &n, &x); printf("%lld", dfs(x, n - x)); }
#include <cstdio> using namespace std; long long ans; long long dfs(long long a, long long b) { if (b % a == 0) { return b / a * a * 3; } return dfs(b % a, a) + b / a * a * 3; } int main() { long long n, x; scanf("%lld%lld", &n, &x); printf("%lld", dfs(x, n - x)); }
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["-", 0, 57, 64, 9, 0, 37, 0, 16, 17, 33], ["-", 0, 57, 64, 9, 0, 37, 0, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 72], ["-", 8, 9, 0, 37, 0, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 37, 0, 16, 12, 16, 17, 109], ["-", 8, 9, 0,...
1
105
#include <bits/stdc++.h> using namespace std; int n, x; long long ans = 0; void dfs(int x, int y) { if (x > y) swap(x, y); int r = y / x; ans += 2LL * r * x; if (y % x == 0) { ans -= x; return; } dfs(y % x, x); } int main() { scanf("%d%d", &n, &x); ans = n; dfs(x, n - x); cout << ans; ...
#include <bits/stdc++.h> using namespace std; long long ans = 0, n, x; void dfs(long long x, long long y) { if (x > y) swap(x, y); long long r = y / x; ans += 2LL * r * x; if (y % x == 0) { ans -= x; return; } dfs(y % x, x); } int main() { scanf("%lld%lld", &n, &x); ans = n; dfs(x, n - x);...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 35], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 4...
1
120
N, X = list(map(int, input().split())) ans = N N, X = X, N - X while N and X: if X > N: d, m = divmod(X, N) if m == 0: ans += (d * 2 - 1) * N else: ans += d * 2 * N N, X = N, m else: d, m = divmod(N, X) ans += (d * 2 - 1) * X + m * 2 N, X = m, X - m print(ans)
N, X = list(map(int, input().split())) ans = N N, X = X, N - X while N and X: if X > N: d, m = divmod(X, N) if m == 0: ans += (d * 2 - 1) * N else: ans += d * 2 * N N, X = N, m else: d, m = divmod(N, X) if m == 0: ans += (d * 2 - 1) * X else: ans += d * 2 * X + m...
[["+", 0, 57, 75, 76, 8, 196, 0, 57, 0, 121], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 75, 76, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 57, 75, 76, 8, 196, 0, 57, 0, 102], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 48], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12,...
5
123
#include <cctype> #include <cstdio> #include <cstring> #include <iostream> #define int long long using namespace std; inline int read() { int x = 0, w = 0; char c = getchar(); while (!isdigit(c)) w |= c == '-', c = getchar(); while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return...
#include <cctype> #include <cstdio> #include <cstring> #include <iostream> #define int long long using namespace std; inline int read() { int x = 0, w = 0; char c = getchar(); while (!isdigit(c)) w |= c == '-', c = getchar(); while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 16, 12,...
1
194
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() typedef long long ll; ll get(ll n, ll m) { if (n == m) return n; if (n > m) swap(n, m); return 2 * n + get(n, m - n); } int main() { ios::sync...
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() typedef long long ll; ll get(ll n, ll m) { if (n == m) return n; if (n > m) swap(n, m); // m-n*z <= n // m <= n * (z+1) // m / n <= z+1 ll ...
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 49, 50, 51, 16, 31, 16, 31, 23, 0, 24], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 31, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 51...
1
123
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAXN 10001 ll n, x, ans; void solve(ll nn, ll xx) { xx = xx < (nn - xx) ? xx : (nn - xx); // printf("nn %lld xx %lld ans %lld\n", nn, xx, ans); if (nn % xx == 0) { ans += (nn / xx - 1) * xx * 3; printf("%lld\n", ans); } else {...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define MAXN 10001 ll n, x, ans; void solve(ll nn, ll xx) { xx = xx < (nn - xx) ? xx : (nn - xx); // printf("nn %lld xx %lld ans %lld\n", nn, xx, ans); if (nn % xx == 0) { ans += (nn / xx - 1) * xx * 3; printf("%lld\n", ans); } else {...
[["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 17, 85], ["+", 12, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 25], ["+",...
1
210
#include <bits/stdc++.h> using namespace std; #define ll long long ll rec(ll a, ll b) { if (a == b) return a; if (a < b) return rec(b, a); return 2 * b + rec(b, a - b); } int main() { ll n, x; cin >> n >> x; cout << n + rec(x, n - x) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long ll rec(ll a, ll b) { if (b == 0) return 0; if (a < b) return rec(b, a); return b * (a / b) + rec(b, a % b); } int main() { ll n, x; cin >> n >> x; cout << 3 * rec(x, n - x) << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13], ["-", 8, 9, 0, 37, 0, 16, 31, 16, 31, 13], ["+", 8, 9, ...
1
92
/////////////////////////////////////////////////////////////////////////////// #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #in...
/////////////////////////////////////////////////////////////////////////////// #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #in...
[["+", 12, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 64, 9, 0, 1, 0, 11, 12, 23, 0, 25], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 0, 35], ["-", 0, 7, 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, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-...
1
4,946
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double PI = 3.14159265359; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, x; cin >> n >> x; cout << 5 * x + 2 * ((n - x) / x); return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double PI = 3.14159265359; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, x; cin >> n >> x; // cout<<5*x+2*((n-x)/x); cout << 3ll * (n - __gcd(n, x)); return 0; }
[["-", 0, 1, 0, 16, 12, 16, 31, 16, 31, 13], ["-", 0, 1, 0, 16, 12, 16, 31, 16, 17, 48], ["-", 0, 1, 0, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 72], ["-", 0, 1, 0, 16, 12, 16, 12, 16, 31, 13], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 31, 13], ["-", 12, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 12, 16, ...
1
73
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, x; cin >> n >> x; int64_t ans = x + (n - x); int64_t a = x, b = (n - x); while (a) { int64_t tmp = b % a; if (a > b) swap(a, b); ans += 2 * a * (b / a); if (tmp == 0) ans -= a; b = a; a = tmp; } c...
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, x; cin >> n >> x; int64_t ans = x + (n - x); int64_t a = x, b = (n - x); while (a) { if (a > b) swap(a, b); int64_t tmp = b % a; ans += 2 * a * (b / a); if (tmp == 0) ans -= a; b = a; a = tmp; } c...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 0, 35], ["+", 0, 52, 8, 9, 0...
1
112
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k, ans = 0, z; cin >> n >> k; ans += n; ll x = max(k, n - k), y = min(k, n - k); while (y) { ans += (x / y) * y + y; z = x % y; x = y; y = z; } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k, ans = 0, z; cin >> n >> k; ans += n; ll x = max(k, n - k), y = min(k, n - k); while (y) { ans += (x / y) * 2 * y - (x % y == 0 ? y : 0); z = x % y; x = y; y = z; } cout << ans << "\n"; }
[["+", 0, 11, 12, 16, 31, 16, 31, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 1, 0, 11, 12, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 12,...
1
101
#include <algorithm> #include <cstring> #include <iostream> #include <unordered_set> using namespace std; long long n, x; long long work(long long h, long long w) { if (w % h == 0) return 2 * w; return 2 * h * (w / h) + 3 * (w % h) + work(h - w % h, w % h); } int main() { scanf("%lld%lld", &n, &x); if (x *...
#include <algorithm> #include <cstring> #include <iostream> #include <unordered_set> using namespace std; long long n, x; long long work(long long h, long long w) { if (w < h) { return h + w + work(w, h - w); } if (w % h == 0) return 2 * w; return 2 * h * (w / h) + 3 * (w % h) + work(h - w % h, w % h);...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 64, 9, 0, 37, 0, 16, 31, 16, 31, 22], ["+", 64, 9, 0, 37, 0, 16, 31, 16, 17, 72], ["+", 64, 9, 0, ...
1
179
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, init, n) for (int i = init; i < (n); i++) using namespace std; using ll = long long int; using P = pair<int, int>; using T = tuple<int, int, int>; using edge = struct { int to, cost; }; const int MOD = 1e9 + 7; const int iINF = 1...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, init, n) for (int i = init; i < (n); i++) using namespace std; using ll = long long int; using P = pair<int, int>; using T = tuple<int, int, int>; using edge = struct { int to, cost; }; const int MOD = 1e9 + 7; const int iINF = 1...
[["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 31, 2, 3, 4, 0, 16, 12, 16, 17, 48], ["+", 0, 16, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, ...
1
284
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_s...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_s...
[["-", 0, 30, 0, 14, 8, 9, 0, 82, 0, 170], ["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 79], ["+", ...
1
177
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; ll ans = 0; ll gcd(ll x, ll y) { if (y == 0) { return x; } else { int z = gcd(y, x % y); ans += 2 * (x / y) * y; return z; } } int main() { ll n, x; cin >> n >> x; x = min(x, n - x); ll g = gcd(n - x, x); ...
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; ll ans = 0; ll gcd(ll x, ll y) { if (y == 0) { return x; } else { ans += 2 * (x / y) * y; ll z = gcd(y, x % y); return z; } } int main() { ll n, x; cin >> n >> x; x = min(x, n - x); ll g = gcd(n - x, x); ...
[["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["-", 75, 76, 0, 9, 0, 43, 49, 50, 49, 22], ["-", 75, 76, 0, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["-", 49, 50, 51, 2,...
1
124
#include <stdio.h> long long n, x, a, b, c, ans; int main() { scanf("%lld%lld", &n, &x); if (x < n - x) { ans = n; a = n - x; b = x; } else { ans = x; a = x; b = n - x; } while (true) { if (a % b == 0) { ans += (2 * a / b - 1) * b; break; } else { ans += 2 * (...
#include <stdio.h> long long n, x, a, b, c, ans; int main() { scanf("%lld%lld", &n, &x); ans = n; if (x < n - x) { a = n - x; b = x; } else { a = x; b = n - x; } while (true) { if (a % b == 0) { ans += (2 * a / b - 1) * b; break; } else { ans += 2 * (a / b) * b; ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["-", 8, 9, 0, 57, 64, 9, 0, 1...
1
147
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define mp make_pair #define FOR(i, a, b)...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; #define mp make_pair #define FOR(i, a, b)...
[["-", 64, 37, 0, 16, 31, 16, 12, 23, 0, 24], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 85], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["-", 64, 37, 0, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8...
1
326
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; #define ll long long #define REP(a, b, c) for (int a = b; a <= c; a++) #define re register #define file(a) ...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; #define ll long long #define REP(a, b, c) for (int a = b; a <= c; a++) #define re register #define file(a) ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 49, 50, 51, 16, 31, 16, 31, 23, 0, 24], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["-", 31, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 51...
1
219
#include <bits/stdc++.h> #include <iostream> using namespace std; long long fun(long long a, long long b) { if (a % b == 0) return 2 * a - b; int c = (int)a / (int)b; return 2 * c * b + fun(b, a % b); }; int main() { cout << setprecision(3) << fixed; long long a, b; cin >> a >> b; cout << a + fun(ma...
#include <bits/stdc++.h> #include <iostream> using namespace std; long long fun(long long a, long long b) { if (a % b == 0) return 2 * a - b; long long c = (long)a / (long)b; return 2 * c * b + fun(b, a % b); }; int main() { cout << setprecision(3) << fixed; long long a, b; cin >> a >> b; cout << a ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 49, 50, 51, 16, 31, 74, 39, 77, 39, 40], ["+", 51, 16, 31, 74, 39, 77, 39, 86, 0, 96], ["-", 49, 50, 51, 16, 12, 74, 39, 77, 39, 40], ["+", 51, 16, 12, 74, 39, 77, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, ...
1
131
#include <cstdio> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { if (!b) return a; return gcd(b, a % b); } int main() { ll a, b; scanf("%lld%lld", &a, &b); printf("%lld\n", 3LL * (a / gcd(a, b) - 1LL)); return 0; }
#include <cstdio> using namespace std; typedef long long ll; ll gcd(ll a, ll b) { if (!b) return a; return gcd(b, a % b); } int main() { ll a, b; scanf("%lld%lld", &a, &b); printf("%lld\n", 3LL * gcd(a, b) * (a / gcd(a, b) - 1LL)); return 0; }
[["+", 3, 4, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 25], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24]]
1
90
#include <bits/stdc++.h> #define endl '\n' using namespace std; template <class T, class T2> inline void chkmax(T &x, const T2 &y) { if (x < y) x = y; } template <class T, class T2> inline void chkmin(T &x, const T2 &y) { if (x > y) x = y; } const int MAXN = (1 << 20); int64_t n, x; void read() { cin >> ...
#include <bits/stdc++.h> #define endl '\n' using namespace std; template <class T, class T2> inline void chkmax(T &x, const T2 &y) { if (x < y) x = y; } template <class T, class T2> inline void chkmin(T &x, const T2 &y) { if (x > y) x = y; } const int MAXN = (1 << 20); int64_t n, x; void read() { cin >> ...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13], ["+", 8, 9, 0, 57, 64, 37, 0, 91, 17, 33], ["+", 0, 57, 64, 37, 0, 91, 28, 23, 0, 24], ["+", 64, 37, 0, 91, 28, 23, 0, 16, 31, 22], ["+", 64, 37, 0, 91, 28, 23, 0, 16, 17, 72], ["+", 64, 37, 0, 91, 28, 23, 0, 16, 12, 22], ["+", 0, 57, 64, 37, 0, 91, 28, 23, 0, 25], ["-", 0, 1,...
1
221
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef pair<int, int> Pi; typedef vector<ll> Vec...
[["+", 51, 218, 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, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 49, ...
1
1,295
#include <bits/stdc++.h> using namespace std; inline int rd() { int x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * f; } int ma...
#include <bits/stdc++.h> using namespace std; inline int rd() { int x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * f; } int ma...
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 31, 16, 12, 16, 12, 23, 0, 16, 12, 13], ["+", 12, 16, 12, 23, 0, 16, 12, 2, 63, 22], ["+", 12, 23, 0, 16, 12, 2, 3, 4, 0, 24], ["+", 12, 23, 0, 16,...
1
139
#include <bits/stdc++.h> typedef long long ll; ll ans = 0; void gcd(ll a, ll b) { if (!b) return; ans += a / b * b << 1; gcd(b, a % b); } int main() { ll n, x; scanf("%lld%lld", &n, &x); ll y = n - x; if (y > x) { std::swap(x, y); } gcd(x, y); ans += n - 1; printf("%lld\n", ans); ret...
#include <bits/stdc++.h> typedef long long ll; ll ans = 0; void gcd(ll a, ll b) { if (!b) { ans -= a; return; } ans += a / b * b << 1; gcd(b, a % b); } int main() { ll n, x; scanf("%lld%lld", &n, &x); ll y = n - x; if (y > x) { std::swap(x, y); } gcd(x, y); ans += n; printf("%lld...
[["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 9, 0, 1, 0, 11, 12,...
1
123
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #define REP(_i, _a, _n) for (int _i = _a; _i <= _n; ++_i) #define PER(_i, _a, _n) f...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #define REP(_i, _a, _n) for (int _i = _a; _i <= _n; ++_i) #define PER(_i, _a, _n) f...
[["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13], ["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["-", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 14, 8,...
1
410
#include <bits/stdc++.h> using namespace std; long long int n, x, y, ans; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> x; while (n >= 2 && x >= 1) { x = max(x, n - x); y = n - x; ans += 3 * (x / y) * y; x %= y; n -= y; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; long long int n, x, y, ans; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> x; while (n >= 2 && x >= 1) { x = max(x, n - x); y = n - x; ans += 3 * (x / y) * y; n -= (x / y) * y; x %= y; } cout << ans; return 0;...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 85], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 1, ...
1
106
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; ll f(ll a, ll b) { cout << a << " " << b << endl; if (b == 0) return -a; return 2 * (a / b) * b + f(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.ti...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; ll f(ll a, ll b) { if (b == 0) return -a; return 2 * (a / b) * b + f(b, a % b); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << setprecision(3...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-",...
1
138
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef vector<int> vi; typedef vector<pi> vpi; #define F0R(i, n) for (int i = 0; i < (n); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define sz (int)size #define ub upper_bound #define lb lower_bound #define...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pi; typedef vector<ll> vi; typedef vector<pi> vpi; #define F0R(i, n) for (ll i = 0; i < (n); i++) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define sz (ll) size #define ub upper_bound #define lb lower_bound #define pb p...
[["-", 0, 134, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 134, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], [...
1
175
#include <iostream> int rec(int a, int b) { if (b == 0) return -a; return (a / b) * 2 * b + rec(b, a % b); } int main() { int n, x; std::cin >> n >> x; std::cout << n + rec(std::min(n - x, x), std::max(n - x, x)) << std::endl; return 0; }
#include <iostream> long long rec(long long a, long long b) { if (b == 0) return -a; return (a / b) * 2 * b + rec(b, a % b); } int main() { long long n, x; std::cin >> n >> x; std::cout << n + rec(std::min(n - x, x), std::max(n - x, x)) << std::endl; return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 49, 53, 54, 55, 0, 56, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
100
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define LOOP(i, x, n) for (int i = x; i < n; i++) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define MP make_pair #define FIR first #define SEC second #define int long long using namespace std; const int MOD = 1000000007; const int I...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define LOOP(i, x, n) for (int i = x; i < n; i++) #define ALL(v) (v).begin(), (v).end() #define PB push_back #define MP make_pair #define FIR first #define SEC second #define int long long using namespace std; const int MOD = 1000000007; const int I...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 1, 0, 2, 63, 22], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 57, 64, 1, 0, 2, 3...
1
166
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i) #define R0F(i, a) ROF(i, 0, a) using ll = long long; using ld = long double; ll INF = LLONG_MAX; using vi = vector<int>; using vll ...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i) #define R0F(i, a) ROF(i, 0, a) using ll = long long; using ld = long double; ll INF = LLONG_MAX; using vi = vector<int>; using vll ...
[["+", 0, 37, 0, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 37, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 31, 13], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 37, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 31, 22], [...
1
649
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, X; cin >> N >> X; ll res = N; ll a = min(N - X, X), b = max(X, N - X); while (true) { if (b % a == 0) { res += a * 3; break; } else { res += 2 * a * (b / a); ll t = a; a = b %= a; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, X; cin >> N >> X; ll res = N; ll a = min(N - X, X), b = max(X, N - X); while (true) { if (b % a == 0) { res += 2 * a * (b / a - 1) + a; break; } else { res += 2 * a * (b / a); ll t = a; ...
[["+", 0, 11, 12, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 48], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 17, 85], ["+", 31, 16, 12, 23, 0, 16, 31, 16, 12, 22], [...
1
117