text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <typename TYPE> void readint(TYPE &x) { x = 0; int f = 1; char c; for (c = getchar(); !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; x *= f; } void err(istream_iterat...
#include <bits/stdc++.h> using namespace std; const int maxn = 50000 + 10; struct query { int type, x, y; } qu[maxn]; int n, fa[maxn]; long long val[maxn], sz[maxn]; vector<int> v[maxn]; bool mark[maxn], have[maxn]; long long d[maxn]; int dfs(int x) { sz[x] = 1; int ret = 0; for (aut...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, ans; struct Node { int val, p, cnt; int pre, nxt; } a[N]; struct Comp { bool operator()(const pair<int, int> &x, const pair<int, int> &y) { return x.first == y.first ? x.second < y.second : x.first > y.first; }...
#include <bits/stdc++.h> using namespace std; int n, m, k; long long c[1010][1010]; const int mod = 1e9 + 7; void pre() { for (int i = 0; i <= 1005; i++) { c[i][0] = c[i][i] = 1; } for (int i = 1; i <= 1005; i++) { for (int j = 0; j <= i; j++) { c[i][j] = (c[i - 1][j] + c[i - 1...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; set<int> st; for (int i = 0; i < n; i++) { cin >> a[i]; st.insert(a[i]); } set<int>::iterator it = st.begin(); it++; if (it == st.end()) cout << NO ; else cout << (*...
#include <bits/stdc++.h> using namespace std; int n, m, a[100005], b[100005]; int l[100005], r[100005]; using pii = pair<int, int>; using ppi = pair<pii, int>; int tr[100005 * 2]; int get(int k) { int res = 0; for (; k; k -= k & -k) res += tr[k]; return res; } void update(int k) { for ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int MAX = 200200; int head[MAX], nxt[MAX * 2], to[MAX * 2], dpthMx[MAX], dpthMn[MAX], Ecnt, n; int ch[MAX], sz; void dfs(int cur, int par) { for (int i = head[cur]; ~i; i = nxt[i]) if (to[i] != par) { dfs(to[i], cur); dpthMn[cur] = ...
#include <bits/stdc++.h> int main() { long n(0); scanf( %ld , &n); std::map<long, long> solutions; bool possible(1); for (int k = 0; k < n; k++) { long number(0), participant(0); scanf( %ld %ld , &number, &participant); if (solutions.find(participant) != solutions.end()) { ...
#include <bits/stdc++.h> using namespace std; long long n, m; int s, p, i, j, k, z; string s1, s2; int const md = 1000000; stack<char> st; int a[5]; int main() { int k1 = 0, k2 = 0, k3 = 0; cin >> k1 >> k2; for (i = 1; i <= k1; i++) { cin >> k3; n = n * k2 + k3; } cin >> ...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Sun Sep 22 03:32:35 2019 // Host : varun-laptop running 64-bit Service Pac...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int Q, n, m, ans[600005], a[505][505]; char S[505]; struct O { int p, q, x, y, i; } o[600005], O[600005]; bitset<505> f[505][505], g[505][505]; void go(int l, int r, int p, int q) { if (p > q) return; int mi = l + r >> 1, L, R, t; for (int i = ...
#include <bits/stdc++.h> using namespace std; long long n, m, k, l; int main() { cin >> n >> m >> k >> l; long long x = m * ((k + l) / m + ((k + l) % m == 0 ? 0 : 1)); if (x <= n) cout << x / m << endl; else cout << -1 << endl; return 0; }
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long mult(long long a, long long b, long long p = 1000000007) { long long ans = ((a % p) * (b % p)) % p; return (ans + p) % p; } long long add(long long a, long long b, long long p = 1000000007) { long long ans = (a % p + b % p) % p; return (ans...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in ...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios::sync_with_stdio(0); solve(); return 0; } pair<pair<double, double>, pair<double, double> > rects[100]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> rects[i].first.first >> rect...
#include <bits/stdc++.h> using namespace std; const int maxN = 100 + 100; int a1, a2, b1, b2; int main() { cin >> a1 >> a2 >> b1 >> b2; if ((b2 >= a1 - 1 && b2 <= 2 * (a1 + 1)) || (b1 >= a2 - 1 && b1 <= 2 * (a2 + 1))) cout << YES << endl; else cout << NO << endl; return 0...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; pair<int, int> p[maxn]; int a[maxn]; int b[maxn]; int n, k, cnt; bool F(int a, int b) { return a > b; } void solve() { scanf( %d %d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , a + i); for (int i = 1; i <= n; i++)...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t ope...
/////////////////////////////////////////////////////////////////////////////// // $Id: unencoded_cam_lut_sm.v 5697 2009-06-17 22:32:11Z tyabe $ // // Module: unencoded_cam_lut_sm.v // Project: NF2.1 // Author: Jad Naous <> // Description: controls an unencoded muli-match cam and provides a LUT. // Matches data and pr...
#include <bits/stdc++.h> using namespace std; const int64_t Nmax = 2e5 + 10; const int64_t mod = 1000000007; vector<int64_t> prime; int64_t is_power_of_two(int64_t a) { return a && (!(a & (a - 1))); } int64_t isperfectsquare(int64_t a) { double b = sqrt(a); return (b - ceil(b) == 0); } int64_t p...
#include <bits/stdc++.h> using namespace std; void Rd(int &res) { res = 0; char p; while (p = getchar(), p < 0 ) ; do { res = (res << 1) + (res << 3) + (p ^ 48); } while (p = getchar(), p >= 0 ); } void Pt(long long x) { if (x == 0) return; Pt(x / 10); putchar(x % 1...
//***************************************************************************** // (c) Copyright 2008-2009 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Fri Jan 13 17:34:06 2017 // Host : KLight-PC running 64-bit major release (bu...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int n, k; const int N = 1e7 + 100; bool a[N]; int main() { cin >> n >> k; vector<long long> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; a[v[i]] = 1; } int q; cin >> q; for (int test = 0; test < q; test++) { long l...
#include <bits/stdc++.h> using namespace std; int ni() { int a; scanf( %d , &a); return a; } double nf() { double a; scanf( %lf , &a); return a; } char sbuf[100005]; string ns() { scanf( %s , sbuf); return sbuf; } long long nll() { long long a; scanf( %lld , &a)...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 5010; vector<int> G[maxn]; int d[maxn][maxn][2]; void check(int &a, int b) { if (a > b) a = b; } int dfs(int u, int fa) { int num = G[u].size(), tot = 0, now = 0; d[u][0][0] = 0; d[u][0][1] = 0; ...
//--------------------------------------------------------------------- // // Company: UNSW // Original Author: Lingkan Gong // Project Name: XDRS Demo // // Create Date: 17/07/2012 // Design Name: lpfilter // //--------------------------------------------------------------------- `timescale 1ns/1ns module lpf...
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0; char zf = 1; char ch; while (ch != - && !isdigit(ch)) ch = getchar(); if (ch == - ) zf = -1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * zf; } ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2013 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 // Very simple test for interface pathclearing module t (/*AUTOARG*/ // Inputs clk ); input ...
#include <bits/stdc++.h> const long double PI = acos(-1.0); using namespace std; int n, m; long long dp[505][505]; int a[505]; long long cal(int l, int r) { if (l >= r) return 1; long long &ret = dp[l][r]; if (ret != -1) return ret; ret = 0; int mn = n + 1, idx = 0; for (int i = l; i...
#include <bits/stdc++.h> long long gcd(long long A, long long B) { return A > B ? gcd(B, A) : A ? gcd(B % A, A) : B; } long long lcm(long long A, long long B) { return A / gcd(A, B) * B; } long long pow(long long A, long long B, long long P) { if (!B) return 1 % P; if (B == 1) return A % P; long...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; struct point { int x; int y; }; struct vec { int x; int y; }; point r_array[12], b_array[12]; int root[12]{}, ocupied[12]{}; int r, b; double cross(point a, point b, point c) { vec v1 = {c.x - a.x, c.y - a.y}; vec v2 = {b.x - a.x, b...
#include<bits/stdc++.h> using namespace std; const int N=1e5+77,B=330; int n,q,a[N],t[N],b[N],l[N],r[N],m,g[N]; int nx(int x){return max(1,a[x]-t[b[x]]); } int jp(int x){if(t[b[x]]>=B)return nx(x); return g[x]; } void reb(int x) { for(int i=l[x]; i<=r[x]; i++) { int j=nx(i); if(j<l[x]) ...
// ---------------------------------------------------------------------- // Copyright (c) 2015, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> using namespace std; void cppio() { ios_base::sync_with_stdio(0); cin.tie(0); } const int maxn = int(2e5) + 10; int n; int a[maxn]; int p, q; long long first, second; int gcd(int a, int b) { if (!b) { first = 1, second = 0; return a; } int q = a...
#include <bits/stdc++.h> using namespace std; int main() { int b, k; cin >> b >> k; int ans = 0; for (int i = 1; i <= k; i++) { int x; cin >> x; if (i != k) ans = (ans + b * x % 2) % 2; else ans = (ans + x % 2) % 2; } if (ans % 2 == 0) { cout << ...
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long p, long long mod) { long long ret = 1; while (p) { if (p & 1) ret = (ret * a) % mod; a = (a * a) % mod; p /= 2; } return ret; } long long power(long long a, long long p) { long long ret = ...
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, i, j, k, d; cin >> n >> m; vector<int> arr(101, 0); for (i = 0; i < m; i++) { int no; cin >> no; arr[no]++; } for (d = m; d >= 1...
#include <bits/stdc++.h> using namespace std; int n, m, k; string A[505]; bool a[505][505]; int star[505][505]; int col[505][505]; int main() { cin >> n >> m >> k; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = A[i][j] == 1 ; ...
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int flag1; flag1 = 0; int flag2 = 0; for (int i = 0; i < n; i++) { if (s[i] == I ) { flag1++; } if (s[i] == A ) { flag2++; } } if (flag1 =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: // Design Name: // Module Name: ACA_I_N32_Q8 // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << setprecision(20); auto solve = [&]() -> string { long long int n, k, a, b; cin >> n >> k >> a >> b; long long int remG = a; long long int remB = b; str...
#include <bits/stdc++.h> using namespace std; struct ppp { int x1, x2, y1, y2; void make_pair(int x1_, int x2_, int y1_, int y2_) { x1 = x1_; x2 = x2_; y1 = y1_; y2 = y2_; } } a[120]; long long ans; int n, m, i, j, k, x, y, l, r, P[220], tot, Pn, u, d; char c[1010][1010];...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) { return (a.first > b.first); } bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } long long int power(long ...
#include <bits/stdc++.h> using namespace std; int main() { int n, res; cin >> n; res = n / 5; if (n % 5 != 0) res++; cout << res; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; long long n, d; while (t--) { cin >> n >> d; long long arr[n]; for (long long i = 0; i < n; i++) cin >> arr[i]; int count = 0; int i = 1; while (i < n && d > 0 && d >= i) { i...
#include <bits/stdc++.h> using namespace std; const long long N = 2e6 + 5, Mod = 1e9 + 7, Lg = 27, P = 727, Sq = 350; const long long Inf = 3e18 + 10; long long ans; long long gcd(long long x, long long y) { if (x > y) swap(y, x); if (!x) return y; return gcd(x, y % x); } void solve(long long ...
#include <bits/stdc++.h> using namespace std; const int inf = 2000000000; const long double eps = 1e-07; int n; int a[200000]; int d[200000]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %d , &a[i]); d[0] = -inf; for (int i = 1; i <= n; ++i) d[i] = inf; for (int i =...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long power(long long a, long long b) { if (b == 1) return a; if (b == 0) return 1; long long ans = power(a, b / 2); ans = (ans * ans); if (b & 1)...
#include <bits/stdc++.h> using namespace std; int infinity = 10000000; int railway[401][401]; int calculatedistance(int start, int end, bool bus) { bool visitedtown[401]; int distance[401]; queue<int> myQueue; for (int i = 1; i <= 400; i++) visitedtown[i] = false; for (int i = 1; i <= 400; i...
//Legal Notice: (C)2016 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; inline int two(int n) { return 1 << n; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &= ~two(b); } inline int last_bit(int n) { return n & (-n); } template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>...
#include <bits/stdc++.h> int _min(int a, int b) { if (a < b) return a; return b; } int _max(int a, int b) { if (a > b) return a; return b; } int main() { int i, j, k; int n; int x1, y1, x2, y2, x3, y3, res; scanf( %d %d , &x1, &y1); scanf( %d %d , &x2, &y2); scanf( %d %...
#include <bits/stdc++.h> int a[100100]; int f[100100][3]; int s[100100]; char tmp[100100]; int n; void maximize(int &x, const int &y) { if (x < y) x = y; } void swap(int &a, int &b) { int sw; sw = a; a = b; b = sw; } void init(void) { scanf( %d , &n); int i; for (i = ...
// (c) Copyright 1995-2015 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int maxn = 502; int n, k; int a[maxn], b[maxn], c[maxn]; bool check(int l, int r) { if (l == r) return true; for (int i = l + 1; i <= r; ++i) if (a[i] != a[l]) return true; return false; } bool print(int p, int r, int dir) { printf(...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/25 10:03:53 // Design Name: // Module Name: _4bit_down_counter_with_synch_load_enable_clear_tb // Project Name: // Target Devices: // Tool Versions: // Descr...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, x, y, n, ans, t; cin >> t; while (t--) { ans = LLONG_MAX; cin >> a >> b >> x >> y >> n; if (n >= (a - x + b - y)) cout << x * y << n ; else { if ((a - n) >= x) ans = (a - n)...
#include <bits/stdc++.h> using namespace std; bool sign[30010]; int num[2]; int value[30010]; int start[3][2] = {{0, 1}, {0, 2}, {1, 2}}; int n; bool Legal(int pos) { if (pos == n - 1) return true; int d = value[pos + 1] - value[pos]; for (int i = pos + 2; i < n; i++) { if (value[i] - va...
#include <bits/stdc++.h> using namespace std; long long bigmod(long long n, long long pow, long long m) { long long ret = 1; while (pow) { if (pow % 2) { ret *= n; ret %= m; } n *= n; n %= m; pow /= 2; } return ret; } long long arr[3 * 100009]; int...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; long long deg[123456]; long long N, S, i, s, e; long long cnt; long double ans; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> S; for (i = 1; i < N; i++) { cin >> s >> e; deg...
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10; const int mod = 998244353; int f[N][N], g[N][N]; int mn[N][N], indl[N], indr[N]; bool bz[N][N]; int a[1000001]; int n, m; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= m; i++) scanf( %d , &a[i]); int x = m; ...
#include <bits/stdc++.h> using namespace std; long long arr[1010], brr[1010]; int main() { long long n, i, j, x, y, ans; cin >> n; for (i = 1; i <= n; i++) cin >> arr[i]; for (i = 1; i <= n; i++) cin >> brr[i]; ans = 0; for (i = 1; i <= n; i++) { x = arr[i]; y = brr[i]; a...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:45:55 04/23/2017 // Design Name: // Module Name: decrypt_tb // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: //...
#include <bits/stdc++.h> using namespace std; long double optN(long long m, int k) { long double ret = 1; m *= k; long long nowC = k; for (int i = 1; i <= k; ++i) { if (m < nowC * i) { ret += m / i; return ret; } ret += nowC; m -= nowC * i; if (m / (i + ...
`timescale 1 ns / 1 ps module axi_axis_reader # ( parameter integer AXI_DATA_WIDTH = 32, parameter integer AXI_ADDR_WIDTH = 16 ) ( // System signals input wire aclk, input wire aresetn, // Slave side input wire [AXI_ADDR_WIDTH-1:0] s_axi_awaddr, // AXI4-Lit...
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; int main() { int n; cin >> n; long long int a; cin >> a; while (1) { if (a % 2 == 0) a /= 2; else if (a % 3 == 0) a /= 3; else break; } bool f = 1; for (int i = 0; i < ...
#include <bits/stdc++.h> using namespace std; const int N = 1000000; int aa[N + 1]; int main() { int n; cin >> n; long long ans = 0; for (int i = 0; i <= n; i++) aa[i] = i; int n_ = n; for (int h = 20; n_ > 0;) { while (h >= 0 && (n_ & 1 << h) == 0) h--; int m = n_ - ((1 << h...
#include <bits/stdc++.h> using namespace std; int getint() { unsigned int c; int x = 0; while (((c = getchar()) - 0 ) >= 10) { if (c == - ) return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - 0 ); } while (((c = getchar()) - 0 ) < 10); return x...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2019 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] cr...
#include <bits/stdc++.h> using namespace std; int main() { int n, s; while (cin >> n >> s) { int ans = s; for (int i = 0; i < n; ++i) { int f, t; cin >> f >> t; if (ans < f + t) { ans = f + t; } } cout << ans << endl; } return 0; } ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <iostream> #include <algorithm> #include <string.h> #include <queue> #include <vector> #define INF 987654321 using namespace std; int main() { int t; scanf( %d ,&t); while(t--){ int a,b,flag=0; scanf( %d %d ,&a,&b); if(a==b)printf( YES n );...
#include <bits/stdc++.h> using namespace std; long long int x[100005]; int main() { int n; long long mn, mx, md, re, ans; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %I64d , &x[i]); sort(x, x + n); mn = x[n - 1]; mx = x[0] + x[n - 1]; while (mn <= mx) { re = 0; ...
module top; parameter real rpar = 2.0; real rvar; real rarr [1:0]; real rout, rtmp; wire real wrarr [1:0]; wire real wrbslv, wrpslv, wruplv, wrdolv; wire real wrbstr, wrpstr, wruptr, wrdotr; wire real wrpbs = rpar[0]; wire real wrpps = rpar[0:0]; wire real wrpup = rpar[0+:1]; wire real wrpdo = rp...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 7; long long l[N], r[N]; long long a[N]; bool used[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; string second; cin >> second; for (long long i = 0; i < n; ++i) cin >> a...
#include <bits/stdc++.h> using namespace std; inline int getidx(const vector<int>& ar, int x) { return lower_bound(ar.begin(), ar.end(), x) - ar.begin(); } inline long long GCD(long long a, long long b) { long long n; if (a < b) swap(a, b); while (b != 0) { n = a % b; a = b; b ...
#include <bits/stdc++.h> using namespace std; inline int ni() { int a; scanf( %d , &a); return a; } inline double nf() { double a; scanf( %lf , &a); return a; } template <class T> void out(T a, T b) { bool first = true; for (T i = a; i != b; i++) { if (!first) printf(...
#include <bits/stdc++.h> int main() { int n, a[102], sum1 = 0, sum2 = 0; int s, t; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); scanf( %d %d , &s, &t); if (s == t) { printf( 0 n ); } else { int i; if (s > t) { s ^= t; t ^= s; s ...
/* Copyright (c) 2014 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; bool visited[2][maxn]; int d[2][maxn]; string s[2]; int main() { int n, k; cin >> n >> k; cin >> s[0] >> s[1]; int dx[3] = {0, 0, 1}; int dy[3] = {1, -1, k}; queue<pair<bool, int>> q; q.push(make_pair(0, 0)); ...
#include <bits/stdc++.h> using namespace std; char ans[1010][1010]; int len[1010]; void upd(int n, int c) { ans[n][len[n]++] = c; } char all[1 << 21]; int main() { int n, k, l; scanf( %d%d%d , &n, &l, &k); scanf( %s , all); sort(all, all + strlen(all)); int cur = 0; int beg = 1; ...
#include <bits/stdc++.h> using namespace std; int n, k, c[1001], i, x, a, b; int main() { cin >> n >> k; for (int x, i = 1; i <= n; ++i) { cin >> x; c[x]++; } for (i = 1; i <= k; ++i) { a = a + c[i] / 2 * 2; b = b + c[i] % 2; } cout << a + (b + 1) / 2; }
#include <bits/stdc++.h> using namespace std; const int MAXM = 111111; vector<int> v[MAXM]; int n, m, lim, x, lower, upper; inline bool check(int score) { for (int i = 1; i <= m; ++i) for (int j = score - 1; j < (int)v[i].size(); ++j) { int k = j - score + 1; if (v[i][j] - v[i][k] - ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; const int inf = 0x3f3f3f3f; int deep[maxn], fa[maxn][32]; vector<int> edge[maxn]; int flag[maxn]; void dfs(int u) { flag[u] = 1; for (auto i : edge[u]) { int t = i; if (flag[t]) continue; deep[t] = deep[u] + 1...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 2; long long n, a[maxn], k, ans[maxn]; long long Check(long long m) { long long res = 0, l, r, mid; for (int i = 1; i <= n; i++) { l = 1; r = a[i]; while (l <= r) { mid = (l + r) / 2; if (a[i] - 3 * mi...