func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long T, n, k; cin >> T; for (int i = 0; i < T; i++) { cin >> n >> k; cout << k * 2 << n ; } }
#include <bits/stdc++.h> using namespace std; template <class C> void mini(C& a4, C b4) { a4 = min(a4, b4); } template <class C> void maxi(C& a4, C b4) { a4 = max(a4, b4); } template <class T1, class T2> ostream& operator<<(ostream& rout, pair<T1, T2> pair) { return rout << ( << pair.fir...
#include bits/stdc++.h #include <cstring> using namespace std; typedef long long ll; #define FastIO cin.sync_with_stdio(false), cin.tie(nullptr) #define pb push_back #define fs first #define sc second #define mkp make_pair #define endl n // IO #define multitest signed __T; cin >> __T; whi...
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::set; using std::swap; using std::vector; void TaskA() { vector<char> first; vector<char> second; char a; int f, s; for (int i = 0; i < 4; i++) { cin >> a; first.push_back(a); if (a =...
#include <bits/stdc++.h> template <typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First& first, Rest&... rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } template <typename T> void MACRO_VEC_ROW_Init(int n, T& t) ...
#include<bits/stdc++.h> typedef long long int ll; #define io ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define fr(i,l,r) for(ll i=l;i<r;i++) #define lop ll t;cin>>t;while(t--) #define maxi 1000 #define mod 1000000007 #define f first #define s second ll dp[maxi]; using namespace std; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, sum = 0; cin >> n >> k; pair<int, int> p[n]; for (int i = 0; i < n; i++) { cin >> p[i].first; p[i].second = i + 1; } sort(p, p + n); for (int i = 0; i < n; i++) { k -= p[sum].first; if (k >= 0) ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 59; struct State { char c[MAX_N][MAX_N]; }; int H, W; vector<pair<int, int>> solve(State S) { vector<pair<int, int>> D; for (int t = 1; t <= 100000; t++) { bool flag = false; if (H % 2 == 0) { for (int i = 1; i <...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)2 * 1e9; const long long MOD = (long long)1e9 + 7; const long long P = 239; const long long MAX_N = 100000; const long long ABC = 26; const long double pi = 3.1415926535897932384626; const long double eps = 1e-6; int main()...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1000006, maxm = 1005; const long long mod = 1000000007; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long powermod(long long a, long long b) { a = a; long long ans = 1; while (b) { if ...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > e; vector<long long> val; vector<long long> mp, mn; vector<int> deg; vector<bool> vis; pair<long long, long long> dfs(int x) { vis[x] = true; long long mx = 0, mi = 0; for (int to : e[x]) { if (!vis[to]) { auto p ...
#include <bits/stdc++.h> using namespace std; long long N, x, y, awal, centre, nb, a; bool visited[100005]; vector<long long> adj[100005]; vector<int> ans; void dfs(int x) { int s = adj[x].size(); visited[x] = 1; bool cek = 1; for (int i = 0; i < s; i++) { nb = adj[x][i]; if (!vi...
#include <bits/stdc++.h> using namespace std; const int N = 100100; const long long INF = 1000 * 1000 * 1000LL * 1000 * 1000; vector<pair<int, int> > adj1[N]; vector<pair<long long, pair<int, int> > > e; set<pair<long long, int> > s; long long d[N]; int p[N], par[N], sz[N], flag(1); void Dijkstra() { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; map<int, int> mp; vector<int> l(n), a(n); for (int i = 0; i < n; i++) cin >> l[i]; vector<int> r(n); for (int i = 0; i < n; i++) { cin ...
#include <bits/stdc++.h> using namespace std; void solve(); int main(int argc, char const *argv[]) { solve(); } void solve() { map<int, int> arr; cin >> arr[0] >> arr[1] >> arr[2] >> arr[3]; int total = arr[0] + arr[1] + arr[2] + arr[3]; for (int st = 0; st < 4; st++) if (arr[st]) { ...
#include <bits/stdc++.h> using namespace std; enum { EMPTY, LINE, INF }; int Type(int a, int b, int c) { if (a == 0 && b == 0) if (c == 0) return INF; else return EMPTY; return LINE; } void Exit(int ans) { printf( %d n , ans); exit(0); } int main() { int a1,...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long i, j, x, n, m, l, r; cin >> n >> m; vector<long long> v; for (i = 0; i < n; i++) { cin >> x; v.push_back(x); } for (i = 0; i < m; i++) { cin >> l >> r >> x; long long...
#include <bits/stdc++.h> int main() { int n, a, b; while (scanf( %d%d%d , &n, &a, &b) != EOF) { int c[202] = {0}; int t = 1, i, j, k; if (b >= 0) { for (int i = 1; i <= n; i++) c[i] = i; for (int j = n + 1; j <= 2 * n; j++) c[j] = c[j - n]; printf( %d n , c[a + (b % n...
#include <bits/stdc++.h> using namespace std; map<pair<long long, long long>, long long> cost; map<long long, int> vis; map<long long, int> freq; int main() { int q; cin >> q; while (q--) { int e; long long v, u; cin >> e >> v >> u; long long tv = v; long long tu = u;...
#include <iostream> #include <vector> using namespace std; int l[200005], r[200005]; vector<int> e[200005]; long long int dp[2][200005]; void dfs(int u, int fa) { dp[0][u] = dp[1][u] = 0; for (auto v : e[u]) { if (v == fa) continue; dfs(v, u); dp[0][u] += m...
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve(std::istream& in, std::ostream& out) { int w, h; in >> w >> h; vector<string> m(h); for (string& s : m) in >> s; for (int i = 0; i < 2 * w; ++i) { for (int j = 0; j < 2 * h; ++j) out << m[j...
#include <bits/stdc++.h> using namespace std; long double eps = 1e-9, pi = acos(-1.0); struct vec { long double i, x, y; } vectors[100005]; long double cala(const vec& v) { long double ang = acos(v.x / sqrt(v.x * v.x + v.y * v.y)); ang = v.y > -eps ? ang : 2 * pi - ang; return ang; } bool ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; if (n <= 30) cout << NO n ; else { cout << YES n ; if (n == 36 || n == 40 || n == 44) cout << 6 10 15 << n - 31 << n ; else ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; vector<int> p; long long dp1[555555]; long long dp2[555555]; long long fp(long long x) { long long ret = 1; long long mul = 2; while (x) { if (x & 1) { ret *= mul; ret %= mod; } mul *= mul; ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; int sum[4000005]; int cover[4000005]; int n, m; void up(int rt) { if (cover[rt << 1] == cover[rt << 1 | 1] && cover[rt << 1] != -1 && cover[rt << 1]) cover[rt] = cover[rt << 1]; else ...
#include <bits/stdc++.h> using namespace std; string arr[12] = { C , C# , D , D# , E , F , F# , G , G# , A , B , H }, a, b, c; int ok(int a1, int a2, int a3) { int dis1, dis2; if (a2 > a1) dis1 = a2 - a1; else dis1 = 12 - a1 + a2; if (a3 > a2...
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& out, const vector<T>& v) { out << [ ; for (auto vi : v) out << vi << , ; out << ] n ; return out; } const int MAX_N = 1024; const int MOD = 1e9 + 7; struct RSQ { static const int len = ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); class domino { public: int data[4]; bool IsEqual(domino b) { for (long long move = 0; move <= 3; move++) { bool f = true; for (long long i = 0; i <= 3; i++) if (data[i] != b.data[(i + move) % 4])...
#include <bits/stdc++.h> using namespace std; const int dx[] = {-1, -2, -2, -1, 1, 2, 2, 1}; const int dy[] = {-2, -1, 1, 2, 2, 1, -1, -2}; set<pair<int, pair<int, int> > > heap; vector<vector<int> > now; int main() { int n, m; cin >> n >> m; if (n >= 10 && m >= 10) { cout << (m * n + 1) /...
#include <bits/stdc++.h> using namespace std; struct node { int x, y; node(int a, int b) { x = a, y = b; } }; int d1[1010][1010]; int main() { int n, t; queue<node> Q; for (int i = 0; i <= 1000; i++) { for (int j = 0; j <= 1000; j++) { d1[i][j] = 5000; } } int a...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d %d , &n, &k); bool first = 1; for (int i = n; i >= n - k + 1; --i) { if (first) { printf( %d , i); first = !first; } else printf( %d , i); } for (int i = 1; i <= n - k; ++i) { ...
#include <bits/stdc++.h> using namespace std; int main() { size_t rnn; cin >> rnn; size_t rnsize = 2 * rnn; size_t rncnt = rnsize; vector<long> rnvec(rnsize); while (rncnt--) cin >> rnvec[rncnt]; sort(rnvec.begin(), rnvec.end()); long rnsum_fin = 999999; long rnsum = 0; for (...
#include <bits/stdc++.h> using namespace std; int n, ntot, ieven, rs[6], ord[6 + 1], iord[6 + 1]; vector<int> xs; inline int imake(int i) { return i > 0 ? ord[i] : -ord[-i]; } void iextend_even(int p, vector<int> &vi) { vector<int> vr[2], vg; vr[1] = vi; for (int i = (int)vi.size() - 1; i >= 0; i-...
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { int n, i; scanf( %d , &n); if (n % 4 != 0) printf( NO n ); else { printf( YES n ); int sum1 = 0, sum2 = 0; for (i = 0; i < n / 2; i++) { printf( %d , 2 * (i + 1));...
#include <bits/stdc++.h> using namespace std; const int N_ = 105; int N, M, X, Y; int len(int x) { for (int l = 1, v = 7;; l++) { if (v >= x) return l; v *= 7; } } set<long long> S; bool chk[100]; void dfs(int i, long long p, long long q) { if (p >= N || q >= M) return; if (i...
#include <bits/stdc++.h> using namespace std; const int N = 85; long long fibo[N + 5]; long long dp[N + 5][3][3]; long long arr[N + 5]; void pre() { fibo[0] = 1, fibo[1] = 2; for (int i = 2; i <= N; i++) { fibo[i] = fibo[i - 1] + fibo[i - 2]; } } long long solve(int idx, int cur1, int ...
#include <bits/stdc++.h> using namespace std; const int N = 100100; const long long MOD = 100030001, H = 47; map<int, long long> d[N]; vector<int> adj[N]; set<pair<long long, int> > s; vector<pair<int, pair<long long, int> > > nei[N]; long long r[N], l[N], num[N], ch[N], h[3 * N], n, sz, ans, o = 10, c ...
#include <bits/stdc++.h> using namespace std; struct MinCostFlow { struct Edge { int t; int f; int c; Edge *next, *rev; Edge(int _t, int _f, int _c, Edge* _next) : t(_t), f(_f), c(_c), next(_next) {} }; vector<Edge*> E; int addV() { E.push_back((Edge*)0)...
#include <bits/stdc++.h> using namespace std; int n, m; int k; bool debug = false; char mp[170][170]; int l[170], r[170]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { scanf( %s , mp[i]); l[i] = m; r[i] = -1; for (int j = 0; j < m; j++) if (mp[i][j] == ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<long long> cnt(26); string s; for (int ss = 0; ss < (int)n; ss++) { cin >> s; for (int i = 0; i < (int)s.size(); i++) s[i] -= a ; ...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > v; map<long long, long long> m; int qpow(long long a, long long b, long long m) { long long c = 1; while (b) { if (b & 1) c = c * a % m; b >>= 1; a = a * a % m; } return c; } int main() { ...
#include <bits/stdc++.h> int inp() { char c = getchar(); int neg = 1; while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum * neg; } int n, p; ...
#include <bits/stdc++.h> using namespace std; long long int sum, max_lev; vector<pair<long long int, long long int>> level[5010]; vector<long long int> adj[5010]; vector<pair<long long int, long long int>> store[5010]; vector<pair<pair<long long int, long long int>, long long int>> v; long long int vis[50...
#include <bits/stdc++.h> using namespace std; const int maxn = 4000010, maxm = 2010; long long s[maxn], f[maxn], P[maxm], Q[maxm]; int a, b, c, p[maxm], vis[maxm], mu[maxm]; void inc(long long &a, long long b) { a += b; if (a > (1ll << 30)) a -= (1ll << 30); } int main() { scanf( %d%d%d , &a, ...
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; while (a--) { int b, c; cin >> b >> c; int arr1[b], arr2[c]; set<int> check; for (int j = 0; j < b; j++) { cin >> arr1[j]; check.insert(arr1[j]); } int x = -1; for ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > g[110]; int seen[110][110]; int c[110]; int ans; void dfs(int s, int end, int color) { if (s == end && c[color] == 0) { c[color] = 1; ans++; return; } for (int i = 0; i < (int)g[s].size(); i++) { if ((c...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, t, m = 0; cin >> n; vector<int> s; for (int i = 0; i < n; i++) { cin >> t; s.push_back(t); } sort(s.begin(), s.end()); while (true) { t = -1; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; char a[20][20], ans[20]; int n, m; bool isValid() { for (int i = 2; i <= n; i++) { int c = 0; for (int j = 1; j <= m; j++) c += (ans[j] != a[i][j]); if (c > 1) return false; } return true; } void fun() { cin >> n >> m; for (...
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> bool umax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { int n, x = 500; s...
#include <bits/stdc++.h> using namespace std; char s[100005]; int n, k, cnt[20]; bool a[20][20], mark[1 << 17], tmp[1 << 17]; inline void work(int x, int y) { memset(tmp, 0, sizeof(tmp)); for (int i = 1, j, t; i <= n;) { while (i <= n && s[i] - a != x) i++; j = i + 1; t = 0; ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; } int n, K, C[1003][1003], fac[1003]; int dp[1003][1003][2][2], ans[1003]; int main() { scanf( %d%d , &n, &K); for (int i = 1; i <= n; i++) { C[i][0] = C[i...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 10; const long long inf = 1e15; const int mod = 1e6; void faster() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const long long N = 3000 * 200; int mark[N]; int main() { faster(); int n; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 5; const long long mod = 99999997; long long a[maxn], k, n; void dfs(long long l, long long r) { if (l + 1 >= r || !k) return; long long mid = (l + r) / 2; k -= 2; swap(a[mid - 1], a[mid]); dfs(l, mid); dfs(mid, r)...
#include <bits/stdc++.h> using namespace std; template <class T> inline void smax(T &x, T y) { x = max((x), (y)); } template <class T> inline void smin(T &x, T y) { x = min((x), (y)); } inline void scanInt(int &x) { register char c = getchar(); x = 0; bool neg = false; while (c <...
#include <bits/stdc++.h> using namespace std; struct event { int x[3], id; event() { x[0] = x[1] = x[2] = id = 0; } event(int xx, int yy, int zz, int idd) { x[0] = xx; x[1] = yy; x[2] = zz; id = idd; } }; int vc = 0; bool operator<(const event &a, const event &b) { ...
#include <bits/stdc++.h> using namespace std; vector<multiset<int> > G; vector<int> d; void dfs(int u, vector<int> &ans) { while (!G[u].empty()) { int v = *G[u].begin(); G[u].erase(G[u].begin()); G[v].erase(G[v].find(u)); dfs(v, ans); } ans.push_back(u); } int main() { ...
#include <bits/stdc++.h> using namespace std; int main() { long long int arr[30] = {0}; unsigned long long sum = 0; long long int a, b, n; cin >> n; for (int i = 0; i < n; i++) { int j = 0; cin >> a; while (a != 0) { b = a % 10; arr[j] += b; arr[j + 1] +...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { int n; cin >> n; long long int x = 2; double d; long long int p; for (long long int i = 1; i <= n; i++) { long long int B = i * (i + 1) * (i + 1) - x / i; cout << B << n ; x = i * (i + 1...
#include <bits/stdc++.h> using namespace std; string grid[8]; int get_weight(char c) { switch (c) { case q : return 9; case r : return 5; case b : case n : return 3; case p : return 1; default: return 0; } } int main() { ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; char s[21][100100]; int n, m, ans = 1e9, all, inv, a[100100], bit[1100000], w[1100000], f[1100000]; int power(int a, int k) { int ret = 1; while (k) { if (k & 1) ret = 1ll * ret * a % mod; a = 1ll * a * a % mod; ...
#include <bits/stdc++.h> using namespace std; const int lim = 1e5 + 5; int main(int argc, char const *argv[]) { int n; cin >> n; std::vector<int> v(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } int mn = INT_MAX, ind1, ind2; for (int i = 0; i < n - 1; ++i) { int dif = abs...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl n const int DIM = 1E5+7; int A[DIM]; int cnt[2][DIM]; int solve() { int n; cin>>n; for(int i = 1;i<=n;++i){ cin>>A[i]; ++cnt[i%2][A[i]]; } sort(A+1,A+1+n); int flag =...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; string s, t; int lenX, lenY; long long dp[5009][5009]; inline long long go(int x, int y) { if (x < 0 || y < 0) return 0LL; long long &ret = dp[x][y]; if (ret != -1) return ret; ret = 0; if (y > 0) ret = go(x, y ...
#include <bits/stdc++.h> using namespace std; int main(void) { const int MAXOPER = 1e5 + 123; const int MAXN = 1e5 + 123; vector<long long> V; long long sz = 0; static long long sz_after[MAXOPER]; static int oper_tip[MAXOPER]; static int oper_l[MAXOPER]; static int oper_c[MAXOPER]; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m, count = 0; cin >> n >> m; string arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < (m - 1); i++) { if (arr[n - 1][i] != R ) co...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; template <typename T> using V = std::vector<T>; struct debugger { template <typename T> debugger &operator,(const T &v) { cerr << v << ; return *this; } } dbg; using namespace std; const double pi = acos...
#include <bits/stdc++.h> using namespace std; int z[150005]; long long tir[150005]; int find(int a) { if (a != z[a]) { z[a] = find(z[a]); } return z[a]; } void mix(int a, int b) { z[find(a)] = find(b); } int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i+...
#include <bits/stdc++.h> using namespace std; using vi = vector<long long>; template <typename T> std::istream& operator>>(std::istream& input, std::pair<T, T>& data) { input >> data.first >> data.second; return input; } template <typename T> std::istream& operator>>(std::istream& input, std::vect...
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, t; cin >> n >> t; string s; cin >> s; while (t--) { for (long long j = 1; j < n; j++) { if (s[j - 1] == B && s[j] == G ) { swap(s[j ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; void print(int base) { if (base == 4) cout << 4 * 3 = 12 n12 * 2 = 24 n24 * 1 = 24 << endl; if (base == 5) cout << 5 * 4 = 20 n3 + 2 = 5 n5 - 1 = 4 n20 + 4 = 24 << endl; if (base == 6) cout << 4 * 3 = 12 n12 * 2 = 2...
#include <bits/stdc++.h> using namespace std; int arr[105]; int main() { int n; cin >> n; int pos = 0; int neg = 0; int z = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] > 0) pos++; else if (arr[i] < 0) neg++; else z++; } ...
#include <bits/stdc++.h> using namespace std; int a[500][500]; int d[500][500]; long long int ans[500]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int num; cin >> num; a[i][j] = num; d[i][j] = num; } } ...
#include <bits/stdc++.h> using namespace std; struct trie { int s, x[2], w[30]; } t[50005 * 30]; int N, S, a[50005], p[50005]; long long M; void ins(int x) { for (int i = 30 - 1, c, p = 1; c = (x >> i) & 1, i >= 0; i--) { if (!t[p].x[c]) t[p].x[c] = ++S; p = t[p].x[c], t[p].s++; fo...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int ma[maxn]; int en[maxn]; int add = 0; int main() { std::ios::sync_with_stdio(false); int n, d; cin >> n >> d; int sum = 0; int mx = -40000000; int op = 0; for (int i = 0; i < n; i++) { int in; ...
#include <bits/stdc++.h> using namespace std; int main() { vector<vector<int> > field; int x, y; cin >> x >> y; field.resize(x); for (int i = 0; i < x; ++i) field[i].resize(y); for (int i = 0; i < x; ++i) for (int j = 0; j < y; ++j) field[i][j] = 0; int x0, y0; cin >> x0 >> y0;...
#include <bits/stdc++.h> using namespace std; long long n, a[+100500 * 2], ans; int main() { cin >> n; for (int i = 1; i <= n; i++) { scanf( %I64d , &a[i]); } for (int i = 1; i <= n; i++) { ans += abs(a[i] - a[i - 1]); } printf( %I64d , ans); return 0; ; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; string str; getline(cin, str); bool isok = true; for (int i = 0; i < n; i++) { getline(cin, str); int x = 0; for (int j = 0; j < st...
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b; cin >> a >> b; vector<string> A; for (long long i = 0; i < a; i++) { string res = ; for (long long j = 0; j < b; j++) { if (i % 4 == 0 || i % 4 == 2) { res += # ; } else if (i % 4 ==...
#include <bits/stdc++.h> using namespace std; long long pow(long long a, long long b) { if (b == 0) { return 1; } if (b % 2 == 0) { return pow((a % 1000000007) * (a % 1000000007), b / 2) % 1000000007; } else { return (a % 1000000007) * (pow((a % 1000000007) * (a % 1000...
#include <bits/stdc++.h> const long long P = 1000000007; long long N, oldA, oldB, oldC, oldD = 1, newA, newB, newC, newD; int main() { std::cin >> N; for (int i = 1; i <= N; ++i) { newA = (oldB + oldC + oldD) % P; newB = (oldA + oldC + oldD) % P; newC = (oldA + oldB + oldD) % P; ne...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; long long a[N][26]; int b[N]; long long ans[28]; char s[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; cin >> (s +...
#pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization ( O3 ) #pragma GCC optimization ( unroll-loops ) #include<bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define F first #define S second #define lb lower_bound #define ub...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) using namespace std; template <typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; } template <typename T> T gcd(T a,...
#include <bits/stdc++.h> using namespace std; int solve(string second, char cur) { if (second.size() == 1) { return !(second[0] == cur); } int n = second.size(); int check = 0; for (int i = 0; i < n / 2; i++) { check += (second[i] == cur); } int check2 = 0; for (int i = n...
#include <bits/stdc++.h> using namespace std; long long INF = 0x7FFFFFFFFFFFFFFF; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; } long long ask(vector<long long>& v) { cout << ?...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool smin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template <typename T> inline bool smax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const long long N = (long long)1e6 + 10; long long n, ar[N], m, bl[N...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const int CS = 22; int cmax[N][CS], cmin[N][CS], ans[N]; int lt[CS]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) { scanf( %d , &cmax[i][0]); cmax[i][0] *= 100; } for (int i = 1...
#include <bits/stdc++.h> using namespace std; bool check(string s) { for (int i = 0; i < s.size() / 2; i++) if (s[i] != s[s.size() - 1 - i]) return 0; return 1; } int main() { int jopa; string s; cin >> s; int p = 0; char a = s[0]; for (int i = 0; i < s.size(); i++) i...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { string s; cin >> s; int k = 0, c = 0; for (int i = s.size() - 1; i >= 0; i--) { if (s[i] == b ) c++; else { k += c; c *= 2; k %= MOD; c %= MOD; } } ...
#include <bits/stdc++.h> long long t1[100], t2[100], n, k, m, i, j, mod[10], o, s; int main() { scanf( %I64d %I64d %I64d , &n, &k, &m); t1[0] = 1; for (i = 0; i < 10; i++) mod[i] = i % k; for (i = 1; i <= n; i++) { for (j = 0; j < 10; j++) { if (j == 0 && (i == n || i == 1)) continue; ...
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; long long nu[n]; for (long long i = 0; i < n; ++i) { char a; cin >> a; nu[i] = a - 0 ; } long long f[10]; for (long long i = 0; i < 9; ++i) cin >> f[i + 1]; for (long long i = 0; i...
#include <bits/stdc++.h> using namespace std; int const maxn = 100100; long long a[maxn]; set<long long> s; int main() { int n, k; long long x1, x2, x3, x4; while (~scanf( %d%d , &n, &k)) { for (int i = 0; i < n; ++i) { scanf( %I64d.%I64d.%I64d.%I64d , &x1, &x2, &x3, &x4); a[...
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; vector<long long> vec(n, 0); for (long long i = 0; i < n; i++) cin >> vec[i]; long long mn = 10e9 + 1, mx = -1, count = 0; for (long long i = 1; i < n; i++) { if (vec[i] == -1 && vec[i - 1] != -1) { ...
#include <bits/stdc++.h> #define ll long long #define f(i, n) for (i = 0; i < n; ++i) #define all(n) n.begin(), n.end() #define P long(1e9 + 7) #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) using namespace std; ll solve(vector<vector<ll>>& dp, ve...
#include <bits/stdc++.h> template <typename T> void rd(T& x) { long long f = 0, c; while ((c = getchar()) < 48 || 57 < c) f ^= !(c ^ 45); x = (c & 15); while (47 < (c = getchar()) && c < 58) x = x * 10 + (c & 15); if (f) x = -x; } template <typename T> inline void pt(T x) { if (x < 0) ...
#include <bits/stdc++.h> using namespace std; string arr[55], arr2[55]; vector<pair<int, int> > hasil; int i, j, n, t, tc, r, x, y, k, c; void tuker_lr(int x, int y) { arr[x][y] = U ; arr[x + 1][y] = D ; arr[x][y + 1] = U ; arr[x + 1][y + 1] = D ; } void tuker_ud(int x, int y) { ar...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j; cin >> n >> m; for (i = 1; i <= n; i++) { int c = i / 2; if (i % 2 != 0) { for (j = 0; j < m; j++) { cout << # ; } cout << endl; } else if (c % 2 == 0) { cout << # ; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, b = 0; int t; for (int i = 0; i < 3; ++i) { cin >> t; a += t; } a = (a + 4) / 5; for (int i = 0; i < 3; ++i) { cin >> t; b += t; } b = (b + 9) / 10; cin >> n; if (a + b > n) ...
#include <bits/stdc++.h> using namespace std; struct name { int l, r; } bl[200001]; bool cmp(name n, name m) { if (n.r == m.r) return n.l < m.l; return n.r < m.r; } int main() { int n, x, w, ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &x, &w); b...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e5 + 5; long long qpow(long long a, long long b, long long r) { long long ans = 1, buff = a % r; while (b) { if (b & 1) ans = (ans * buff) % r; buff = (buff * buff) % r; b >>= 1; } return a...