buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define forn(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define fr first #define sc second typedef long long ll; typedef pair<int, int> pii; void solve() { in...
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define forn(i, n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define fr first #define sc second typedef long long ll; typedef pair<int, int> pii; void solve() { in...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
253
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; using LL = long long; int main() { LL n, k; cin >> n >> k; if (n >= k) { LL t = n / k; n -= t * k; printf("%lld\n", min(abs(n - k), k)); } else { printf("%lld\n", min(abs(n - k), n)); } retur...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; using LL = long long; int main() { LL n, k; cin >> n >> k; if (n >= k) { LL t = n / k; n -= t * k; printf("%lld\n", min(abs(n - k), n)); } else { printf("%lld\n", min(abs(n - k), n)); } retur...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
102
#!/usr/bin/env python3 import collections import itertools as it import math import numpy as np # = input() # = int(input()) N, K = map(int, input().split()) # = list(map(int, input().split())) # = [int(input()) for i in range(N)] # # c = collections.Counter() if N >= K: seimin = N - (N//K) * K print(min(...
#!/usr/bin/env python3 import collections import itertools as it import math import numpy as np # = input() # = int(input()) N, K = map(int, input().split()) # = list(map(int, input().split())) # = [int(input()) for i in range(N)] # # c = collections.Counter() if N >= K: seimin = N - (N//K) * K print(min(...
[["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
78
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; n -= (n / k) * k; cout << min(n, k - n) << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; int main() { ios::sync_with_stdio(false); cin.tie(NULL); ll n, k; cin >> n >> k; n -= (n / k) * k; cout << min(n, k - n) << '\n'; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
76
#include <bits/stdc++.h> using namespace std; int n, k; int main() { scanf("%d%d", &n, &k); printf("%d", min(n % k, k - n % k)); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, k; int main() { scanf("%lld%lld", &n, &k); printf("%lld", min(n % k, k - n % k)); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
53
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define REP(i, n) for (i = 0; i < n; i++) #define MAX 1000000 #define MOD 1000000007 long long fac[MAX], finv[MAX], inv[MAX]; // prototype declaration int i_in(); long long ll_in(); double d_in(); char c_in(); void s_in...
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define REP(i, n) for (i = 0; i < n; i++) #define MAX 1000000 #define MOD 1000000007 long long fac[MAX], finv[MAX], inv[MAX]; // prototype declaration int i_in(); long long ll_in(); double d_in(); char c_in(); void s_in...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
0
1,331
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> typedef int ll; #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #define clr(a, h) memset(a, (h), sizeof(a)) #define mem(a, h) memset(a, (h), sizeof(a)) #define F first #define S sec...
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> typedef long long ll; #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #define clr(a, h) memset(a, (h), sizeof(a)) #define mem(a, h) memset(a, (h), sizeof(a)) #define F first #define...
[["-", 36, 36, 36, 36, 0, 30, 0, 134, 39, 40], ["+", 36, 36, 0, 30, 0, 134, 39, 86, 0, 96]]
1
283
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; cout << min(n % k, k - n % k); return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { long long n, k; cin >> n >> k; cout << min(n % k, k - n % k); return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
43
N,K = map(int,input().split()) if K == 1: ans = 0 else: if N >= K: N -= (N//K)*K ans = min(N,abs(N-K)) else: min(N,abs(N-K)) print(ans)
N,K = map(int,input().split()) if K == 1: ans = 0 else: if N >= K: N -= (N//K)*K ans = min(N,abs(N-K)) else: ans = min(N,abs(N-K)) print(ans)
[["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32]]
5
70
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) using ll = long long; int main() { ll n, k, x; cin >> n >> k; n = n % k; bool flag = true; while (flag) { x = max(n, k) - min(n, k); x < n ? n = x : flag = false; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) using ll = long long; int main() { ll n, k, x; cin >> n >> k; n = n % k; bool flag = true; while (flag) { x = max(n, k) - min(n, k); x < n ? n = x : flag = false; } cout << n; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 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, 0, 1, 0, 35]]
1
84
package main import "fmt" func main(){ var n,m int fmt.Scan(&n,&m) a := n - (n/m)*m if a < m/2 { fmt.Println(a) } else { fmt.Println(m-a) } }
package main import "fmt" func main(){ var n,m int fmt.Scan(&n,&m) a := n - (n/m)*m if a*2 <= m { fmt.Println(a) } else { fmt.Println(m-a) } }
[["-", 0, 435, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 0, 435, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 435, 8, 196, 0, 57, 15, 16, 12, 22]]
7
72
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { /* static Set<Integer> primes = new HashSet<>(); static Set<Pair> ans = new HashSet<>(); static int max = (int)Math.sqrt(1000000000); static { boolean prime[] = new boolean[max+1]; Arrays.fill(prime,true)...
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { /* static Set<Integer> primes = new HashSet<>(); static Set<Pair> ans = new HashSet<>(); static int max = (int)Math.sqrt(1000000000); static { boolean prime[] = new boolean[max+1]; Arrays.fill(prime,true)...
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
3
507
n, k = map(int, input().split()) if n > k: print(min(n % k, n % (n - k))) elif n == k: print(0) elif n < k: print(min(n, k - n))
n, k = map(int, input().split()) if n > k: print(min(n % k, abs(n % k - k))) elif n == k: print(0) elif n < k: print(min(n, k - n))
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 109], ["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 109], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 12, 22]]
5
63
n, k = map(int, input().split()) x = n%k ans = min(x,n-x) print(ans)
n, k = map(int, input().split()) x = n%k ans = min(x,k-x) print(ans)
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22]]
5
35
n, k = map(int, input().split()) if n == 0: ans = n elif n == 1 or k == 1: ans = 0 else: ans = min(n % k, k - n % k) print(ans)
n, k = map(int, input().split()) if n == 0: ans = n elif k == 1: ans = 0 else: ans = min(n % k, k - n % k) print(ans)
[["-", 0, 57, 75, 665, 15, 679, 31, 666, 0, 22], ["-", 0, 57, 75, 665, 15, 679, 31, 666, 667, 60], ["-", 0, 57, 75, 665, 15, 679, 31, 666, 0, 612], ["-", 0, 656, 0, 57, 75, 665, 15, 679, 17, 354]]
5
56
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) #define SIZE 200005 #define INF 1000000005LL #define MOD 1000000007 using namespace std; typedef long long int ll; typedef pair<int, int> P; int main() { int N, K; cin >> N >> K; int m; int M; int ans; m = N / K; M = m +...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) #define SIZE 200005 #define INF 1000000005LL #define MOD 1000000007 using namespace std; typedef long long int ll; typedef pair<int, int> P; int main() { ll N, K; cin >> N >> K; ll m; ll M; ll ans; m = N / K; M = m + 1; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
104
#include <algorithm> #include <cmath> #include <cstdio> using namespace std; int n, k, t; int main() { scanf("%d%d", &n, &k); printf("%d\n", min(n % k, abs(n % k - k))); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> using namespace std; long long n, k, t; int main() { scanf("%lld%lld", &n, &k); printf("%lld\n", min(n % k, abs(n % k - k))); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
63
#include <bits/stdc++.h> using namespace std; int main() { long long N, K; cin >> N >> K; if (N < K / 2) { cout << N; } else if (N < K) { cout << K - N; } else { if (N % K < K / 2) { cout << N % K; } else { cout << K - N % K; } } }
#include <bits/stdc++.h> using namespace std; int main() { long long N, K; cin >> N >> K; if (N <= K / 2) { cout << N; } else if (N <= K) { cout << K - N; } else { if (N % K <= K / 2) { cout << N % K; } else { cout << K - N % K; } } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
85
import sys input = sys.stdin.readline n, k = map(int, input().split()) ans = n%k if ans < abs(ans-k): ans = abs(ans-k) print(ans)
import sys input = sys.stdin.readline n, k = map(int, input().split()) ans = n%k if ans > abs(ans-k): ans = abs(ans-k) print(ans)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47]]
5
52
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vd = vector<double>; using vvd = vector<vd>; using vc = vector<char>; using vb = vector<bool>; using vl = vector<ll>; #define rep(i, x, n) for (int i = x; i < n; i++) #define all(x) x.begin(), x.end...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vd = vector<double>; using vvd = vector<vd>; using vc = vector<char>; using vb = vector<bool>; using vl = vector<ll>; #define rep(i, x, n) for (int i = x; i < n; i++) #define all(x) x.begin(), x.end...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22]]
1
128
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, k; cin >> n >> k; /*if(n < k) cout << n ; else { cout << n - x*k; }*/ ll x = n / k; ll ka = n - x * k; cout << min(ka, abs(n - k)); ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, k; cin >> n >> k; ll x = n / k; ll ka = n - x * k; cout << min(ka, abs(ka - k)); return 0; }
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22]]
1
84
#include <stdio.h> int main(void) { int N, K, ans; scanf("%d %d", &N, &K); if ((N % K) < K - (N % K)) printf("%d", N % K); else printf("%d", K - (N % K)); return 0; }
#include <stdio.h> int main(void) { long long N, K, ans; scanf("%lld %lld", &N, &K); if ((N % K) < K - (N % K)) printf("%lld", N % K); else printf("%lld", K - (N % K)); return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
75
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; a %= b; cout << min(a, abs(a - b)); }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; a %= b; cout << min(a, abs(a - b)); }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
41
#include <bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; cout << min(n % k, k - n % k) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, k; int main() { cin >> n >> k; cout << min(n % k, k - n % k) << endl; return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
43
#include <bits/stdc++.h> using namespace std; long long n, m; int main() { cin >> n >> m; n %= m; long long ans = max(n, -(n - m)); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m; int main() { cin >> n >> m; n %= m; long long ans = min(n, -(n - m)); cout << ans << endl; return 0; }
[["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22]]
1
53
#include <bits/stdc++.h> #define pi pair<int, int> #define pb push_back #define int long long using namespace std; const int maxn = 1e5 + 1; int a[maxn], p[maxn]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; int ans = n; for (int i = 0; i < 10; i++) {...
#include <bits/stdc++.h> #define pi pair<int, int> #define pb push_back #define int long long using namespace std; const int maxn = 1e5 + 1; int a[maxn], p[maxn]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; n %= k; int ans = n; for (int i = 0; i < ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
119
#include <bits/stdc++.h> #ifdef NON_SUBMIT #define TEST(n) (n) #define tout cerr #else #define TEST(n) ((void)0) #define tout cin #endif using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); TEST(freopen("input.txt", "r", stdin)); TEST(freopen("output.txt", "w", stdo...
#include <bits/stdc++.h> #ifdef NON_SUBMIT #define TEST(n) (n) #define tout cerr #else #define TEST(n) ((void)0) #define tout cin #endif using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); TEST(freopen("input.txt", "r", stdin)); TEST(freopen("output.txt", "w", stdo...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
133
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #ifdef on_linux #include <sys/resource.h> #endif #ifdef dobby_is_a_free_elf #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 0; #endif using namespace std; using namespace __gnu_pbds; #de...
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #ifdef on_linux #include <sys/resource.h> #endif #ifdef dobby_is_a_free_elf #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) #else #define trace(...) 0; #endif using namespace std; using namespace __gnu_pbds; #de...
[["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 12, 13]]
1
572
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, x, n) for (int i = x; i < (n); i++) #define ALL(n) begin(n), end(n) #define MOD 1000000007 typedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; template <class T> void print(T x) { cou...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define FOR(i, x, n) for (int i = x; i < (n); i++) #define ALL(n) begin(n), end(n) #define MOD 1000000007 typedef long long ll; typedef unsigned int ui; typedef unsigned long long ull; template <class T> void print(T x) { cou...
[["+", 0, 30, 0, 14, 8, 9, 0, 9, 0, 45], ["+", 0, 30, 0, 14, 8, 9, 0, 9, 0, 46], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72]]
1
431
/* Hey there stalker.... █▀▀▄░░░░░░░░░░░▄▀▀█ ░█░░░▀▄░▄▄▄▄▄░▄▀░░░█ ░░▀▄░░░▀░░░░░▀░░░▄▀ ░░░░▌░▄▄░░░▄▄░▐▀▀ ░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█ ░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█ ▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█ █░░░▀▄░█░░░█░▄▀░░░░█▀▀▀ ░▀▄░░▀░░▀▀▀░░▀░░░▄█▀ ░░░█░░░░░░░░░░░▄▀▄░▀▄ ░░░█░░░░░░░░░▄▀█░░█░░█ ░░░█░░░░░░░░░░░█▄█░░▄▀ ░░░█░░░░░░░░░░░████▀ ░░░▀▄▄▀▀▄...
/* Hey there stalker.... █▀▀▄░░░░░░░░░░░▄▀▀█ ░█░░░▀▄░▄▄▄▄▄░▄▀░░░█ ░░▀▄░░░▀░░░░░▀░░░▄▀ ░░░░▌░▄▄░░░▄▄░▐▀▀ ░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█ ░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█ ▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█ █░░░▀▄░█░░░█░▄▀░░░░█▀▀▀ ░▀▄░░▀░░▀▀▀░░▀░░░▄█▀ ░░░█░░░░░░░░░░░▄▀▄░▀▄ ░░░█░░░░░░░░░▄▀█░░█░░█ ░░░█░░░░░░░░░░░█▄█░░▄▀ ░░░█░░░░░░░░░░░████▀ ░░░▀▄▄▀▀▄...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 8, 9, 0, 43, 39, 344, 3, 347, 0, 22], ["-", 0, 77, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 77...
1
392
def main(): k = int(input()) hp = [i for i in range(k+4)] r, w = 1, 10 while w < k: n = hp[r] r += 1 nm = n % 10 val = n * 10 + nm if nm != 0: hp[w] = val - 1 w += 1 hp[w] = val w += 1 if nm != 9: ...
def main(): k = int(input()) hp = [i for i in range(k+4)] r, w = 1, 10 while w <= k: n = hp[r] r += 1 nm = n % 10 val = n * 10 + nm if nm != 0: hp[w] = val - 1 w += 1 hp[w] = val w += 1 if nm != 9: ...
[["-", 0, 14, 8, 196, 0, 52, 15, 666, 667, 18], ["+", 0, 14, 8, 196, 0, 52, 15, 666, 667, 19]]
5
111
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e5 + 10; const ll mod = 1e9 + 7; int main() { int k; cin >> k; deque<int> d; if (k < 10) { cout << k; return 0; } for (int i = 1; i < 10; i++) d.push_back(i); k -= 9; bool ok = 0; while (true) { int temp...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e5 + 10; const ll mod = 1e9 + 7; int main() { ll k; cin >> k; deque<ll> d; if (k < 10) { cout << k; return 0; } for (ll i = 1; i < 10; i++) d.push_back(i); k -= 9; bool ok = 0; while (true) { ll temp = d...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 14, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 7, 10, 43, 39, 78], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52,...
1
196
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; void swap(int a, int b) { int tmp = a; a = b; b = tmp; } int runrun(ll a) { queue<ll> Q; for (ll i = 1; i < 10; i++) { Q.push(i); } ll count = 1; while (1) { ll x = Q.front(); Q.pop(); if (a ...
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; void swap(int a, int b) { int tmp = a; a = b; b = tmp; } ll runrun(ll a) { queue<ll> Q; for (ll i = 1; i < 10; i++) { Q.push(i); } ll count = 1; while (1) { ll x = Q.front(); Q.pop(); if (a =...
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78]]
1
219
#include <bits/stdc++.h> #define rep(i, start, end) for (long long i = start; i < end; ++i) #define repreverse(i, start, end) for (long long i = start; i >= end; --i) #define all(x) (x).begin(), (x).end() #define len(x) ((long long)(x).size()) #define lcm(a, b) ((a) / __gcd((a), (b)) * (b)) using namespace std; using l...
#include <bits/stdc++.h> #define rep(i, start, end) for (long long i = start; i < end; ++i) #define repreverse(i, start, end) for (long long i = start; i >= end; --i) #define all(x) (x).begin(), (x).end() #define len(x) ((long long)(x).size()) #define lcm(a, b) ((a) / __gcd((a), (b)) * (b)) using namespace std; using l...
[["-", 3, 4, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 12, 13], ["-", 0, 2, 3, 4, 0, 16, 12, 16, 12, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 12, 13]]
1
807
k = int(input()) L = [] def lunlun(d,v,L): L.append(v) if d == 4: return for i in range(-1,2): t = v%10 + i #print(v) if 0 <= t <=9: lunlun(d+1,v*10+t,L) #lunlun(1,1,L) for v in range(1,10): lunlun(1,v,L) print(sorted(L)[k-1])
k = int(input()) L = [] def lunlun(d,v,L): L.append(v) if d == 10: return for i in range(-1,2): t = v%10 + i #print(v) if 0 <= t <=9: lunlun(d+1,v*10+t,L) #lunlun(1,1,L) for v in range(1,10): lunlun(1,v,L) print(sorted(L)[k-1])
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612]]
5
105
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef complex<double> point; // 2D point only typedef long long ll; typedef unsigned long long ull; typedef long double ldob; typedef pair<int, int> ii; typedef pair...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef complex<double> point; // 2D point only typedef long long ll; typedef unsigned long long ull; typedef long double ldob; typedef pair<int, int> ii; typedef pair...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
435
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int k; cin >> k; queue<int> que; for (int i = 1; i < 10; i++) { que.push(i); } int count = 0; while (1) { int x = que.front(); count++; if (count == k) { cout << x << endl; return 0; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int k; cin >> k; queue<ll> que; for (int i = 1; i < 10; i++) { que.push(i); } int count = 0; while (1) { ll x = que.front(); count++; if (count == k) { cout << x << endl; return 0; } qu...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78]]
1
168
#include <algorithm> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long int int main(void) { ios::sync_with_stdio(false); cin.tie(0); queue...
#include <algorithm> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long int int main(void) { ios::sync_with_stdio(false); cin.tie(0); queue...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
226
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int k; cin >> k; if (k <= 12) { cout << k << endl; return 0; } queue<ll> que; vector<ll> lun; rep(i, 12)...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int k; cin >> k; if (k <= 12) { cout << k << endl; return 0; } queue<ll> que; vector<ll> lun; rep(i, 12)...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
362
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> ii; typedef vector<vector<ll>> vvll; typedef vector<pair<ll, ll>> vii; typedef long double ld; typedef vector<ld> vld; typedef vector<vector<ld>> vvld; typedef vector<bool> vbl; typedef vector<vbl> mbl; #de...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef pair<ll, ll> ii; typedef vector<vector<ll>> vvll; typedef vector<pair<ll, ll>> vii; typedef long double ld; typedef vector<ld> vld; typedef vector<vector<ld>> vvld; typedef vector<bool> vbl; typedef vector<vbl> mbl; #de...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
286
k = int(input()) cand = [[1,2,3,4,5,6,7,8,9]] for i in range(9): tmp = [] for val in cand[-1]: if val % 10 != 0: tmp.append(val*10 + (val%10 - 1)) tmp.append(val*10 + (val % 10)) if val % 10 != 9: tmp.append(val*10 + (val%10 + 1)) cand.append(tmp) ans = [] for j in range(len(cand)): for...
k = int(input()) cand = [[1,2,3,4,5,6,7,8,9]] for i in range(9): tmp = [] for val in cand[-1]: if val % 10 != 0: tmp.append(val*10 + (val%10 - 1)) tmp.append(val*10 + (val % 10)) if val % 10 != 9: tmp.append(val*10 + (val%10 + 1)) cand.append(tmp) ans = [] for j in range(len(cand)): for...
[["-", 0, 7, 8, 196, 0, 7, 12, 206, 206, 22], ["+", 0, 7, 8, 196, 0, 7, 12, 206, 206, 22]]
5
162
import queue k = int(input) q = queue.Queue() for i in range(1,10): q.put(i) for i in range(k): x = q.get() if not x%10 == 0: q.put(10*x+(x%10)-1) q.put(10*x+(x%10)) if not x%10 == 9: q.put(10*x+(x%10)+1) print(x)
import queue k = int(input()) q = queue.Queue() for i in range(1,10): q.put(i) for i in range(k): x = q.get() if not x%10 == 0: q.put(10*x+(x%10)-1) q.put(10*x+(x%10)) if not x%10 == 9: q.put(10*x+(x%10)+1) print(x)
[["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
112
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long temp; queue<int> Q; for (int i = 1; i <= 9; i++) { Q.emplace(i); } for (long long i = 1; i <= N; i++) { temp = Q.front(); // cout<<temp<<endl; if (temp % 10 != 0) { Q.emplace(temp * 10 + temp...
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; long long temp; queue<long long> Q; for (int i = 1; i <= 9; i++) { Q.emplace(i); } for (long long i = 1; i <= N; i++) { temp = Q.front(); // cout<<temp<<endl; if (temp % 10 != 0) { Q.emplace(temp * 10 ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96]]
1
162
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <map> #include <queue> #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { ll K; cin >> K; queue<ll> que; for (ll i = 1; i < 10; i++) { que.push(i); } ll ans...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #include <cmath> #include <iostream> #include <map> #include <queue> #define ll long long #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { ll K; cin >> K; queue<ll> que; for (ll i = 1; i < 10; i++) { que.push(i); } ll ans...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
177
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int k; cin >> k; queue<ll> q; for (ll i = 1; i < 10; i++) q.push(i); int c = 0; while (!q.empty()) { c++; ll x = q.front(); q.pop(); if (c == k) { cout << x << endl; return 0; } if (x % ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int k; cin >> k; queue<ll> q; for (ll i = 1; i < 10; i++) q.push(i); int c = 0; while (!q.empty()) { c++; ll x = q.front(); q.pop(); if (c == k) { cout << x << endl; return 0; } if (x % ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
168
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e16; const ll mod = 1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a,...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e16; const ll mod = 1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a,...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33]]
1
638
const int LG = 21; const int FN = 400005; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long INFLL = 1e18; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; #define forn(i, n) for (int(i) = 0; (i) ...
const int LG = 21; const int FN = 400005; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long INFLL = 1e18; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; #define forn(i, n) for (int(i) = 0; (i) ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
1,080
import sys # from collections import defaultdict # from collections import Counter from queue import Queue # sys.setrecursionlimit(2000000) def main(): K = int(input()) queue = Queue() for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, ]: queue.put(i) for i in range(1, K+1): lunlun = queue.get() ...
import sys # from collections import defaultdict # from collections import Counter from queue import Queue # sys.setrecursionlimit(2000000) def main(): K = int(input()) queue = Queue() for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, ]: queue.put(i) for i in range(1, K+1): lunlun = queue.get() ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
207
import sys sys.setrecursionlimit(500000) K = int(input()) ans_list = [] def dfs(A): if len(A)!=0 and int("".join(A))<=10**6: ans_list.append(int("".join(A))) elif len(A)!=0 and int("".join(A))>10**6: return if len(A)==0: for i in range(1, 10, 1): A.append(str(i)) ...
import sys sys.setrecursionlimit(500000) K = int(input()) ans_list = [] def dfs(A): if len(A)!=0 and int("".join(A))<=10**10: ans_list.append(int("".join(A))) elif len(A)!=0 and int("".join(A))>10**10: return if len(A)==0: for i in range(1, 10, 1): A.append(str(i)) ...
[["-", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612], ["+", 0, 57, 15, 679, 12, 666, 0, 657, 12, 612], ["-", 75, 665, 15, 679, 12, 666, 0, 657, 12, 612], ["+", 75, 665, 15, 679, 12, 666, 0, 657, 12, 612]]
5
194
/*** author: yuji9511 ***/ #include <bits/stdc++.h> using namespace std; using ll = long long; using lpair = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = 1e18; #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 printa(x, n) ...
/*** author: yuji9511 ***/ #include <bits/stdc++.h> using namespace std; using ll = long long; using lpair = pair<ll, ll>; const ll MOD = 1e9 + 7; const ll INF = 1e18; #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 printa(x, n) ...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22]]
1
172
#include <bits/stdc++.h> #define ll long long #define ii pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define ff first #define ss second #define pi 3.14159265 #define oo 1000000007 #define loo 0x7fffffffffffffff #defi...
#include <bits/stdc++.h> #define ll long long #define ii pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple #define ff first #define ss second #define pi 3.14159265 #define oo 1000000007 #define loo 0x7fffffffffffffff #defi...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
575
from collections import deque K = int(input()) q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) for i in range(K): runrun = q.popleft() rem = runrun % 10 if rem == 0: q.append(runrun * 10) q.append(runrun * 10 + rem + 1) elif rem == 9: q.append(runrun * 10 + rem - 1) q.append(run...
from collections import deque K = int(input()) q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) for i in range(K): runrun = q.popleft() rem = runrun % 10 if rem == 0: q.append(runrun * 10) q.append(runrun * 10 + rem + 1) elif rem == 9: q.append(runrun * 10 + rem - 1) q.append(run...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
144
#include <bits/stdc++.h> using namespace std; queue<long long> q; vector<long long> ans; long long n, m, i, j, k, l, p, o, s; int main() { for (i = 1; i <= 9; i++) q.push(i); while (ans.size() < 111111) { n = q.front(); ans.push_back(n); q.pop(); m = n % 10; if (m > 0) q.push(n * 10 + ...
#include <bits/stdc++.h> using namespace std; queue<long long> q; vector<long long> ans; long long n, m, i, j, k, l, p, o, s; int main() { for (i = 1; i <= 9; i++) q.push(i); while (ans.size() < 111111) { n = q.front(); ans.push_back(n); q.pop(); m = n % 10; if (m > 0) q.push(n * 10 + ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
196
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL << 62 #define inf 1000000007 ll k, cnt; vector<ll> ans; void dep(ll sum, ll keta, ll nowke) { if (keta == nowke) { ans.push_back(sum); return; } ll now = sum % 10; if (now >= 1) { dep(sum * 10 + now - 1, keta, nowke...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL << 62 #define inf 1000000007 ll k, cnt; vector<ll> ans; void dep(ll sum, ll keta, ll nowke) { if (keta == nowke) { ans.push_back(sum); return; } ll now = sum % 10; if (now >= 1) { dep(sum * 10 + now - 1, keta, nowke...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
214
#include <bits/stdc++.h> #define repl(i, l, r) for (int i = l; i < r; ++i) #define rep(i, n) repl(i, 0, n) #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; ...
#include <bits/stdc++.h> #define repl(i, l, r) for (int i = l; i < r; ++i) #define rep(i, n) repl(i, 0, n) #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; ...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
312
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { int k; cin >> k; queue<ll> q; rep(i, 9) q.push(i + 1); ll ans; rep(i, k) { ans = q.front(); q.pop(); if (ans % 10 != 0) q.push(10 * ans + ans % 10 - 1); ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { int k; cin >> k; queue<ll> q; rep(i, 9) q.push(i + 1); ll ans; rep(i, k) { ans = q.front(); q.pop(); if (ans % 10 != 0) q.push(10 * ans + ans % 10 - 1); ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
142
# https://atcoder.jp/contests/abc161/tasks/abc161_d import sys # sys.setrecursionlimit(100000) import heapq def input(): return sys.stdin.readline().strip() def input_int(): return int(input()) def input_int_list(): return [int(i) for i in input().split()] def main(): n = int(input()) if n ...
# https://atcoder.jp/contests/abc161/tasks/abc161_d import sys # sys.setrecursionlimit(100000) import heapq def input(): return sys.stdin.readline().strip() def input_int(): return int(input()) def input_int_list(): return [int(i) for i in input().split()] def main(): n = int(input()) if n ...
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38]]
5
229
K = int(input()) a = [] def DFS(n): if n > 3234566667: return a.append(n) l = n % 10 if l == 0: DFS(10 * n) DFS(10 * n + 1) elif l == 9: DFS(10 * n) DFS(10 * n + 8) else: DFS(10 * n + l) DFS(10 * n + l + 1) DFS(10 * n + l - 1) for...
K = int(input()) a = [] def DFS(n): if n > 3234566667: return a.append(n) l = n % 10 if l == 0: DFS(10 * n) DFS(10 * n + 1) elif l == 9: DFS(10 * n + 9) DFS(10 * n + 8) else: DFS(10 * n + l) DFS(10 * n + l + 1) DFS(10 * n + l - 1) ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
132
from collections import deque K = int(input()) que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) for i in range(K): num = que.popleft() if i == K-1: print(num) break if num%10 == 0: que.append(num*10 + num%10) que.append(num*10 + num%10 + 1) elif num%10 == 9: que.append(nu...
from collections import deque K = int(input()) que = deque([1, 2, 3, 4, 5, 6, 7, 8, 9]) for i in range(K): num = que.popleft() if i == K-1: print(num) break if num%10 == 0: que.append(num*10 + num%10) que.append(num*10 + num%10 + 1) elif num%10 == 9: que.append(nu...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
171
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; ll x = 1e9 + 7; int main() { int k; cin >> k; vector<ll> x(k + 5); int i = 1, j = 1; while (j < k) { if (j < 10) { x[j] = j; j++; } else { i...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; ll x = 1e9 + 7; int main() { int k; cin >> k; vector<ll> x(k + 5); int i = 1, j = 1; while (j <= k) { if (j < 10) { x[j] = j; j++; } else { ...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19]]
1
292
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, s, n) for (int i = (s); i < (n); i++) #define all(v) v.begin(), v.end() #define outve(v) \ for (auto i : v) ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, s, n) for (int i = (s); i < (n); i++) #define all(v) v.begin(), v.end() #define outve(v) \ for (auto i : v) ...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
658
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int K; cin >> K; if (K < 10) { cout << K << endl; return 0; } queue<int> q; rep(i, 9) { q.push(i + 1); } ll num; rep(i, K) { num = q.fro...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int K; cin >> K; if (K < 10) { cout << K << endl; return 0; } queue<ll> q; rep(i, 9) { q.push(i + 1); } ll num; rep(i, K) { num = q.fron...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
182
#include <assert.h> #include <stdio.h> typedef long long int lld; void table(int prev[], int new[]) { for (int i = 0; i <= 9; i++) { if (prev == NULL) { new[i] = 1; } else { new[i] = 0; for (int j = -1; j <= 1; j++) { if (i + j < 0 || i + j > 9) { continue; } ...
#include <assert.h> #include <stdio.h> typedef long long int lld; void table(int prev[], int new[]) { for (int i = 0; i <= 9; i++) { if (prev == NULL) { new[i] = 1; } else { new[i] = 0; for (int j = -1; j <= 1; j++) { if (i + j < 0 || i + j > 9) { continue; } ...
[["-", 0, 57, 15, 23, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 12, 13]]
0
361
#!/usr/bin/env python3 from heapq import * a = [*range(1, 10)] heapify(a) i = 0 k = int(input()) c = 0 while True: t = str(heappop(a)) i += 1 if i == k: break if t[-1] != "0": heappush(a, int(t + str(int(t[-1]) - 1))) heappush(a, int(t + t[-1])) if t[0] != "9": heappush(...
#!/usr/bin/env python3 from heapq import * a = [*range(1, 10)] heapify(a) i = 0 k = int(input()) c = 0 while True: t = str(heappop(a)) i += 1 if i == k: break if t[-1] != "0": heappush(a, int(t + str(int(t[-1]) - 1))) heappush(a, int(t + t[-1])) if t[-1] != "9": heappush...
[["-", 8, 196, 0, 57, 15, 666, 0, 206, 206, 612], ["+", 0, 57, 15, 666, 0, 206, 206, 664, 17, 33], ["+", 0, 57, 15, 666, 0, 206, 206, 664, 28, 612]]
5
141
#include <bits/stdc++.h> using namespace std; int k, i = -1; vector<long long> vec = {}; void dfs(long long x, int a) { vec.push_back(x); if (x > 100000000) return; if (x == 0) { for (int j = 1; j < 10; j++) { dfs(j, j); } } else { if (a != 0 && a != 9) { dfs(10 * x + a - 1, a - 1); ...
#include <bits/stdc++.h> using namespace std; int k, i = -1; vector<long long> vec = {}; void dfs(long long x, int a) { vec.push_back(x); if (x > 1000000000) return; if (x == 0) { for (int j = 1; j < 10; j++) { dfs(j, j); } } else { if (a != 0 && a != 9) { dfs(10 * x + a - 1, a - 1);...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
238
#define LOCAL #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <ran...
#define LOCAL #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <ran...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22]]
1
1,049
from collections import deque k = int(input()) if k < 10: print(k) # exit() q = deque() lun = [] for i in range(1, 10): q.append(i) lun.append(i) cnt = 9 while cnt < k: x = q.popleft() if x % 10 == 0: nx = 10 * x q.append(nx) lun.append(nx) nx = 10 * x + 1 ...
from collections import deque k = int(input()) if k < 10: print(k) exit() q = deque() lun = [] for i in range(1, 10): q.append(i) lun.append(i) cnt = 9 while cnt < k: x = q.popleft() if x % 10 == 0: nx = 10 * x q.append(nx) lun.append(nx) nx = 10 * x + 1 ...
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
247
from collections import deque K = int(input()) Q = deque([i for i in range(1,10)]) for _ in range(K-1): q = Q.popleft() if q%10 != 0: Q.append(q*10+q%10-1) Q.append(q*10+q%10) if q%9 != 0: Q.append(q*10+q%10+1) print(Q.popleft())
from collections import deque K = int(input()) Q = deque([i for i in range(1,10)]) for _ in range(K-1): q = Q.popleft() if q%10 != 0: Q.append(q*10+q%10-1) Q.append(q*10+q%10) if q%10 != 9: Q.append(q*10+q%10+1) print(Q.popleft())
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
108
k = int(input()) A = [i for i in range(1, 10)] while k: if k <= len(A): print(A[k-1]) exit() k -= len(A) old = [] old, A = A, old for x in old: for i in range(-1, 2): d = (x % 10) + i if d < 0 and d > 9: continue nx = (x * 10...
k = int(input()) A = [i for i in range(1, 10)] while k: if k <= len(A): print(A[k-1]) exit() k -= len(A) old = [] old, A = A, old for x in old: for i in range(-1, 2): d = (x % 10) + i if d < 0 or d > 9: continue nx = (x * 10)...
[["-", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 354]]
5
112
/*************************************************\ In the name of almighty ALLAH MD.Faysal Hasan Comilla Univesity \*************************************************/ #include <bits/stdc++.h> using namespace std; #define ikarus_101 ...
/*************************************************\ In the name of almighty ALLAH MD.Faysal Hasan Comilla Univesity \*************************************************/ #include <bits/stdc++.h> using namespace std; #define ikarus_101 ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
539
from collections import deque n = int(input()) q = deque(range(1, 10)) for _ in range(n - 1): x = q.popleft() r = x % 10 y = 10 * x if r == 0: q.extend([y, y+1, y+9]) elif r == 9: q.extend([y, y+8, y+9]) else: q.extend([y+r-1, y+r, y+r+1]) print(q.popleft())
from collections import deque n = int(input()) q = deque(range(1, 10)) for _ in range(n - 1): x = q.popleft() r = x % 10 y = 10 * x if r == 0: q.extend([y, y+1]) elif r == 9: q.extend([y+8, y+9]) else: q.extend([y+r-1, y+r, y+r+1]) print(q.popleft())
[["-", 0, 1, 0, 652, 3, 4, 0, 634, 0, 21], ["-", 0, 652, 3, 4, 0, 634, 0, 657, 31, 22], ["-", 0, 652, 3, 4, 0, 634, 0, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 634, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 634, 0, 22]]
5
124
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int k; cin >> k; queue<ll> que; for (int i = 1; i < 10; i++) que.push(i); for (int i = 0; i < k - 1; i++) { ll n = que.front(); que.pop(); for (int j = -1; j < 2; j++) { ll m = (n % 10) + j; if (m >= ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int k; cin >> k; queue<ll> que; for (int i = 1; i < 10; i++) que.push(i); for (int i = 0; i < k - 1; i++) { ll n = que.front(); que.pop(); for (int j = -1; j < 2; j++) { ll m = (n % 10) + j; if (m >= ...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
144
k = int(input()) cur = [[1]*10 for i in range(11)] if k <= 9: print(k) exit() c = 9 i = 0 while c < k: i += 1 for j in range(10): cur[i][j] = cur[i-1][j] if j != 0: cur[i][j] += cur[i-1][j-1] if j != 9: cur[i][j] += cur[i-1][j+1] if sum(cur[i]) >= k: break else: c += sum(cur[...
k = int(input()) cur = [[1]*10 for i in range(11)] if k <= 9: print(k) exit() c = 9 i = 0 while c < k: i += 1 for j in range(10): cur[i][j] = cur[i-1][j] if j != 0: cur[i][j] += cur[i-1][j-1] if j != 9: cur[i][j] += cur[i-1][j+1] if c+sum(cur[i][1:]) >= k: break else: c += su...
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 31, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 72], ["+", 12, 652, 3, 4, 0, 206, 51, 206, 0, 73], ["+", 0, 657, 12, 652, 3, 4, 0, 206, 0, 70], ["+", 12, 652, 3, 4, 0, 206, 206, 663, 0, 612], ["+", 12, 652, 3, 4, 0, 206, 206, 663, 0, 102]]
5
243
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve() { int n, k; cin >> n >> k; cout << min(n % k, k - n % k) << "\n"; return; }; }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); Solution solution; solution.solve(); return 0; }
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve() { long long n, k; cin >> n >> k; cout << min(n % k, k - n % k) << "\n"; return; }; }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); Solution solution; solution.solve(); return 0; }
[["-", 8, 123, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
84
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K; cin >> N >> K; cout << min(N % K, N - N % K) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K; cin >> N >> K; cout << min(N % K, K - N % K) << endl; }
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22]]
1
42
#include <bits/stdc++.h> #define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i) #define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i) using namespace std; typedef long long ll; const int mod = 998244353; int read() { int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch =...
#include <bits/stdc++.h> #define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i) #define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i) using namespace std; typedef long long ll; const int mod = 998244353; int read() { int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch =...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 23, 0, 24], ["+", 0, 43, 49, 50, 51, 23, 0, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 23, 0, 16, 17, 85], ["+", 0, 43, 49, 50, 51, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 23, 0, 25]]
1
304
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> vec; signed Lunlun(int n, int A) { vec.push_back(A); if (n == 10) { return 0; } if (A % 10 != 0 && A % 10 != 9) { Lunlun(n + 1, A * 10 + A % 10 + 1); Lunlun(n + 1, A * 10 + A % 10 - 1); Lunlun(n + 1, A * 10 + A % 10)...
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> vec; signed Lunlun(int n, int A) { vec.push_back(A); if (n == 10) { return 0; } if (A % 10 != 0 && A % 10 != 9) { Lunlun(n + 1, A * 10 + A % 10 + 1); Lunlun(n + 1, A * 10 + A % 10 - 1); Lunlun(n + 1, A * 10 + A % 10)...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 48]]
1
244
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Queue<Integer> que = new ArrayDeque<>(); int k = sc.nextInt(); int num = 0; for (int i = 1; i <= 9; i++) { que.add(i); } while (k > 0) { int i = que.poll(); ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Queue<Long> que = new ArrayDeque<>(); long k = sc.nextLong(); long num = 0; for (long i = 1; i <= 9; i++) { que.add(i); } while (k > 0) { long i = que.poll(); ...
[["-", 8, 196, 0, 503, 39, 513, 0, 237, 0, 78], ["+", 8, 196, 0, 503, 39, 513, 0, 237, 0, 78], ["-", 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, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["-", 8, 196, 0, 7, 502, 503, ...
3
177
package main import ( "fmt" "sort" ) var Lunluns map[int]bool func main() { var K int fmt.Scan(&K) Lunluns = make(map[int]bool) for i := 1; i <= 10; i++ { genLunlun(i) } keys := []int{} for k, _ := range Lunluns { keys = append(keys, k) } sort.Ints(keys) fmt.Println(keys[K-1]) } func genLunlun(n int...
package main import ( "fmt" "sort" ) var Lunluns map[int]bool func main() { var K int fmt.Scan(&K) Lunluns = make(map[int]bool) for i := 1; i <= 10; i++ { genLunlun(i) } keys := []int{} for k, _ := range Lunluns { keys = append(keys, k) } sort.Ints(keys) fmt.Println(keys[K-1]) } func genLunlun(n int...
[["-", 0, 435, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 0, 435, 8, 196, 0, 57, 15, 16, 12, 433], ["+", 0, 435, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 435, 8, 196, 0, 57, 15, 16, 12, 433]]
7
192
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr long long MOD = 1000000007; long long power(long long x, long long n) { long long res = 1; while (n > 0) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } vector<ll> ans; void dfs(ll n) { ans.push_back(n); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr long long MOD = 1000000007; long long power(long long x, long long n) { long long res = 1; while (n > 0) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } vector<ll> ans; void dfs(ll n) { ans.push_back(n); ...
[["-", 51, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 51, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
271
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define reprev(i, n) for (int i = n - 1; i >= 0; i--) using ll = long long; using namespace std; using P = pair<int, int>; int main() { int K; cin >> K; queue<ll> q; rep(i, 9) q.push(i + 1); while (true) { int now = q.front(); q.p...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define reprev(i, n) for (int i = n - 1; i >= 0; i--) using ll = long long; using namespace std; using P = pair<int, int>; int main() { int K; cin >> K; queue<ll> q; rep(i, 9) q.push(i + 1); while (true) { ll now = q.front(); q.po...
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78]]
1
169
from collections import deque K = int(input()) que = deque() que.extend([i for i in range(1,10)]) for k in range(K-2): out = que.popleft() div = out%10 if div==0: que.extend([out*10,out*10+1]) elif out%10==9: que.extend([out*10+8,out*10+9]) else: que.extend([out*10-1+div,out...
from collections import deque K = int(input()) que = deque() que.extend([i for i in range(1,10)]) for k in range(K-1): out = que.popleft() div = out%10 if div==0: que.extend([out*10,out*10+1]) elif out%10==9: que.extend([out*10+8,out*10+9]) else: que.extend([out*10-1+div,out...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
140
#include <bits/stdc++.h> using namespace std; int main() { int k, cnt = 0; cin >> k; queue<int> q; for (int i = 1; i <= 9; i++) q.push(i); int ans; while (cnt < k) { ans = q.front(); q.pop(); int x = ans * 10 + ans % 10; if (x % 10 != 0) q.push(x - 1); q.push(x); if (x % ...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int k, cnt = 0; cin >> k; queue<int> q; for (int i = 1; i <= 9; i++) q.push(i); int ans; while (cnt < k) { ans = q.front(); q.pop(); int x = ans * 10 + ans % 10; if (x % 10 != 0) q.push(x - 1); ...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 156]]
1
136
#include <algorithm> #include <functional> #include <iostream> #include <string> using namespace std; #include <math.h> #include <queue> #include <vector> int main() { int k; queue<int> que; cin >> k; que.push(1); que.push(2); que.push(3); que.push(4); que.push(5); que.push(6); que.push(7); q...
#include <algorithm> #include <functional> #include <iostream> #include <string> using namespace std; #include <math.h> #include <queue> #include <vector> int main() { int k; queue<long long> que; cin >> k; que.push(1); que.push(2); que.push(3); que.push(4); que.push(5); que.push(6); que.push(7...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 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
207
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #define rep(i, n) for (long long i = 0; i < (n); ++i) #define rep2(i, n, m) for (long long i = n; i <= m; i++) #define ALL(a) (a).begin(), (a).end() using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 1e18;...
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #define rep(i, n) for (long long i = 0; i < (n); ++i) #define rep2(i, n, m) for (long long i = n; i <= m; i++) #define ALL(a) (a).begin(), (a).end() using namespace std; using ll = long long; using P = pair<int, int>; const ll INF = 1e18;...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18]]
1
255
N = int(input()) R=[["1","2","3","4","5","6","7","8","9"]] count=9 for i in range(N): if count>=N: break else: temp=[] for r in R[i]: if r[-1]=="9": temp.append(str(r)+str(int(r[-1])-1)) temp.append(str(r)+str(int(r[-1]))) elif r[-1]=="0": temp.append(str(r)+str(int(r...
N = int(input()) R=[["1","2","3","4","5","6","7","8","9"]] count=9 temp=[] for i in range(N): if count>=N: break else: temp=[] for r in R[i]: if r[-1]=="9": temp.append(str(r)+str(int(r[-1])-1)) temp.append(str(r)+str(int(r[-1]))) elif r[-1]=="0": temp.append(str(r)+s...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73]]
5
296
def join(i1,i2) return (i1.to_s + i2.to_s).to_i end K = gets.chomp.to_i queue = [1,2,3,4,5,6,7,8,9] ix = 9 while ix < K f = queue.first if f % 10 > 0 ix += 1 queue.push(join(f,f%10-1)) end if ix != K ix += 1 queue.push(join(f,f)) end if f % 10 < 9 && ix != K ix += 1 queue.push(join(f,f%10+1)) ...
def join(i1,i2) return (i1.to_s + i2.to_s).to_i end K = gets.chomp.to_i queue = [1,2,3,4,5,6,7,8,9] ix = 9 while ix < K f = queue.first if f % 10 > 0 ix += 1 queue.push(join(f,f%10-1)) end if ix != K ix += 1 queue.push(join(f,f%10)) end if f % 10 < 9 && ix != K ix += 1 queue.push(join(f,f%10+1)...
[["+", 3, 4, 0, 652, 3, 4, 0, 738, 17, 109], ["+", 3, 4, 0, 652, 3, 4, 0, 738, 12, 612]]
4
154
import java.util.ArrayDeque; import java.util.Deque; import java.util.Queue; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int K = sc.nextInt(); Deque<Long> queue = new ArrayDeque<>(); for (int i = 1; i < 10; i++) { queue...
import java.util.ArrayDeque; import java.util.Deque; import java.util.Queue; import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int K = sc.nextInt(); Deque<Long> queue = new ArrayDeque<>(); for (int i = 1; i < 10; i++) { queue...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499]]
3
204
K = 12 table = [1, 2, 3, 4, 5, 6, 7, 8, 9] for i in table: if len(table) > K: break x = i % 10 for j in range(max(0, x - 1), min(x + 2, 10)): table.append(i * 10 + j) print(table[K-1])
K = int(input()) table = [1, 2, 3, 4, 5, 6, 7, 8, 9] for i in table: if len(table) > K: break x = i % 10 for j in range(max(0, x - 1), min(x + 2, 10)): table.append(i * 10 + j) print(table[K-1])
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
86
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = 1; i < (int)(n); i++) #define dunk(n) cout << n << endl #define all(a) (a).begin(), (a).end() typedef pair<int, int> P; typedef long long ll; vector<ll> lun; void d...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = 1; i < (int)(n); i++) #define dunk(n) cout << n << endl #define all(a) (a).begin(), (a).end() typedef pair<int, int> P; typedef long long ll; vector<ll> lun; void d...
[["-", 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, 78], ["-", 8, 9, 0, 43, 39, 344, 3, 347, 0, 47], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35]]
1
186
#include <stdio.h> typedef long long ll; ll dp[100001][10]; inline bool chk(int x) { return 0 <= x && x < 10; } void sol(int i, int j, int K) { printf("%d", j); if (i == 1) return; for (int l = -1; l <= 1; l++) { if (chk(j + l)) { if (K >= dp[i - 1][j + l]) return sol(i - 1, j + l, K); ...
#include <stdio.h> typedef long long ll; ll dp[100001][10]; inline bool chk(int x) { return 0 <= x && x < 10; } void sol(int i, int j, int K) { printf("%d", j); if (i == 1) return; for (int l = -1; l <= 1; l++) { if (chk(j + l)) { if (K <= dp[i - 1][j + l]) return sol(i - 1, j + l, K); ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
349
k = int(input()) l = [1,2,3,4,5,6,7,8,9] c = 0 while k>len(l): f = str(l[c]) if f[-1]!=0: l.append(int(f)*10 + int(f[-1])-1) l.append(int(f)*10 + int(f[-1])) if f[-1]!=9: l.append(int(f)*10 + int(f[-1])+1) c += 1 print(l[k-1])
k = int(input()) l = [1,2,3,4,5,6,7,8,9] c = 0 while k>len(l): f = str(l[c]) if int(f[-1])!=0: l.append(int(f)*10 + int(f[-1])-1) l.append(int(f)*10 + int(f[-1])) if int(f[-1])!=9: l.append(int(f)*10 + int(f[-1])+1) c += 1 print(l[k-1])
[["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]]
5
143
#include <algorithm> // sort #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <unistd.h> #include <vector> #define pii pair<int, int> #define REP(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef long long ll; static const ll INF = 100000000000000...
#include <algorithm> // sort #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <unistd.h> #include <vector> #define pii pair<int, int> #define REP(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef long long ll; static const ll INF = 100000000000000...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78]]
1
226
x = int(input()) runrun=[[1,2,3,4,5,6,7,8,9],[]] count=9 keta=2 end=False ans=-1 if x<=9: print(x) end=True while True: if end: break for ini in runrun[keta-2]: if ini%10==0: runrun[keta-1].append(ini*10) count+=1 if count==x: end=...
x = int(input()) runrun=[[1,2,3,4,5,6,7,8,9],[]] count=9 keta=2 end=False ans=-1 if x<=9: ans=x end=True while True: if end: break for ini in runrun[keta-2]: if ini%10==0: runrun[keta-1].append(ini*10) count+=1 if count==x: end=Tru...
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
360
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a; for (int i = 1; i <= 9; i++) a.push_back(i); while (1) { if (k <= a.size()) { cout << a[k - 1] << endl; return 0; } k -= a.size(); vector<long long> old; swap(a, old); for ...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a; for (int i = 1; i <= 9; i++) a.push_back(i); while (1) { if (k <= a.size()) { cout << a[k - 1] << endl; return 0; } k -= a.size(); vector<long long> old; swap(a, old); for ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
168
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a; for (int i = 1; i <= 9; i++) a.push_back(i); while (1) { if (k <= a.size()) { cout << a[k - 1] << endl; return (0); } k -= a.size(); vector<long long> old; swap(a, old); fo...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a; // push_back使う時はi=0から入っていくのに注意 for (int i = 1; i <= 9; i++) a.push_back(i); while (1) { // 新しく作った配列aのサイズが、減っていくk以上になるようにしていく if (k <= a.size()) { cout << a[k - 1] << endl; // 出力したらプログラム終...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96]]
1
166
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a; for (int i = 1; i <= 9; i++) a.push_back(i); while (1) { if (k <= a.size()) { cout << a[k - 1] << endl; return (0); } k -= a.size(); vector<long long> old; swap(a, old); fo...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<long long> a; for (int i = 1; i <= 9; i++) a.push_back(i); while (1) { if (k <= a.size()) { cout << a[k - 1] << endl; return (0); } k -= a.size(); vector<long long> old; swap(a, old); fo...
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96]]
1
166
from collections import deque k=int(input()) d=deque(range(1,10)) for i in range(k): x=d.popleft() if x % 10 != 0: d.append(10*x + x%10 -1) d.append(10*x + 10%10) if x%10 != 9: d.append(10*x + x%10 +1) print(x)
from collections import deque k=int(input()) d=deque(range(1,10)) for i in range(k): x=d.popleft() if x % 10 != 0: d.append(10*x + x%10 -1) d.append(10*x + x%10) if x%10 != 9: d.append(10*x + x%10 +1) print(x)
[["-", 0, 652, 3, 4, 0, 657, 12, 657, 31, 612], ["+", 0, 652, 3, 4, 0, 657, 12, 657, 31, 22]]
5
96
def dfs(r): global l if len(r) == 11: return l.append(int(r)) for i in range(-1, 2): tmp = int(r[-1]) + i if 0 <= tmp <= 9: dfs(r + str(tmp)) k = int(input()) l = [] for i in range(1, 10): dfs(str(i)) print(sorted(l)[k])
def dfs(r): global l if len(r) == 11: return l.append(int(r)) for i in range(-1, 2): tmp = int(r[-1]) + i if 0 <= tmp <= 9: dfs(r + str(tmp)) k = int(input()) l = [] for i in range(1, 10): dfs(str(i)) print(sorted(l)[k - 1])
[["+", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
104
cur = [] def recur(n): if n > 10 ** 9: return cur.append(n) for i in range(10): if abs(n % 10 - i) <= 1: recur(10 * n + i) for i in range(1, 10): recur(i) cur.sort() n = int(input()) print((cur[n - 1]))
cur = [] def recur(n): if n > 10 ** 10: return cur.append(n) for i in range(10): if abs(n % 10 - i) <= 1: recur(10 * n + i) for i in range(1, 10): recur(i) cur.sort() n = int(input()) print((cur[n - 1]))
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
90