text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <class _Tp> _Tp gcd(_Tp a, _Tp b) { return (b == 0) ? (a) : (gcd(b, a % b)); } const long long Inf = 1000000000000000000ll; const int inf = 1000000000; char buf[1 << 25], *p1 = buf, *p2 = buf; inline int getc() { return p1 == p2 && (p2 = (p1...
#include <bits/stdc++.h> const int maxn = 5e5 + 5; int fa[maxn], t[maxn], n, m, k, v, u, ev, eu; int find(int n) { return n == fa[n] ? n : (fa[n] = find(fa[n])); } void merge(int u, int v) { ev = find(v); eu = find(u); if (ev != eu) { fa[ev] = eu; t[eu] += t[ev]; } } int main() {...
`include "rtl/verilog/or1200/or1200_defines.v" `include "rtl/verilog/bench_timescale.v" // // Top of OR1200 inside test bench // `define OR1200_TOP xess_top.i_xess_fpga.or1200_top module or1200_monitor2; wire [31:0] r0; wire [31:0] r1; wire [31:0] r2; wire [31:0] r3; wire [31:0] r4; wire [31:0] r5; wire [3...
// Include module declaration in a comment module foo # (parameter PAR_A = 1, PAR_B = 2 ) (/*AUTOARG*/ // Inputs a, b ); input a, b; endmodule: foo module top (/*AUTOARG*/ // Inputs a, b ); //begin: AUTOOUTPUTS /*AUTOOUTPUT*/ //begin: AUTOIN...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2020 by Yutetsu TAKATSUKASA module t ( clk ); input clk; int c = 0; t2 #(0) i_0(.*); t2 #(-1) i_1(.*); // lo is -1, hi is 5 t2 #(-4) i_2(.*); // lo is -4, hi is...
#include <bits/stdc++.h> char ch; inline void read(int &x) { x = 0; ch = getchar(); while (ch <= 32) ch = getchar(); while (ch > 32) { x = x * 10 + ch - 48; ch = getchar(); }; }; const int dx[8] = {0, 1, 0, -1, -1, -1, 1, 1}; const int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1}; con...
module testbench(); reg tb_clk; reg [31:0] l_reg; reg [31:0] r_reg; wire [31:0] l_data; wire [31:0] r_data; assign l_data = l_reg; assign r_data = r_reg; wire LRCK, DAT, MCK, SCK; //i2s_tx #(.DATA_WIDTH(16), .MCLK_DIV(2), .FS(128)) iis_tx( i2s_tx #(.DATA_WIDTH(32)) iis_tx( .clk(tb_clk), .lef...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, m; int head[N], nxt[N * 2], to[N * 2], tot; int vis[N], stp[N]; int dp[N][20]; int dfn[N], low[N], dep = 0; int stk[N * 5], top = 0; int belong[N], block = 0; int odd[N], col[N]; void init() { memset(head, -1, sizeof(he...
/** * 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; pair<int, int> a[110]; int n, k; vector<int> ans; void solve() { cin >> n >> k; for (int i = (1); i <= (n); ++i) { int x; cin >> x; a[i].first = x; a[i].second = i; } sort(a + 1, a + 1 + n); int s = 0; for (int i = 1...
//====================================================================== // // mulacc_test.v // ------------- // Test implementation of a slice of the mult function. Just to see // what a naive implementation would require. Note that we have a big // API just to allow us to build the functionality in a FPGA. // // // C...
// 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:33:49 2017 // Host : KLight-PC running 64-bit major release (bu...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int MAXN = 2000 + 5; int dp[MAXN][MAXN] = {0}; int previous[MAXN] = {0}; void calculatePrevious(const string &s, const string &p) { int sSize = s.length(); int pSize = p.length(); for (int i = 0; i < sSize; ++i) {...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, x, y, a, b; cout << YES n ; cin >> n; while (n--) { cin >> x >> y >> a >> b; cout << (abs(2 * (x % 2)) + abs(y % 2)) + 1 << endl; } return 0; }
//***************************************************************************** // DISCLAIMER OF LIABILITY // // This file contains proprietary and confidential information of // Xilinx, Inc. ("Xilinx"), that is distributed under a license // from Xilinx, and may be used, copied and/or disclosed only // pursuant to the...
// // Copyright 2011 Ettus Research LLC // // 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, either version 3 of the License, or // (at your option) any later version. // // This program is dis...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_temp_diode.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and...
/** * 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...
/** * 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(int argc, char **argv) { int n, k, value = 0; vector<pair<int, int>> set; cin >> n >> k; for (int i = 0; i < n; ++i) { int x, y; cin >> x >> y; set.push_back({x, y}); } for (int i = 0; i < n; ++i) { value += set[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 law...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const long long inf = 1e18; int ntest; int n, m, k; string s; int cnt[55]; bool ok[maxn]; void read_input() { cin >> n >> m >> k; cin >> s; } void solve() { fill(cnt, cnt + 26, 0); for (int i = 0; i < k; ++i) +...
#include <bits/stdc++.h> using namespace std; mt19937 myrand(time(0)); bool isprime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i += 6) { if (n % i == 0 || n % (i + 2) == 0) return false; ...
//***************************************************************************** // (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 // ...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 7; const int MX = 1e9 + 7; const long long int INF = 1e18 + 9LL; int n, m, k; long long int value[N]; pair<long long int, pair<int, int> > edge[N]; int pt[N]; int rep[N]; int res = 0; int Find(int a) { if (rep[a] == a) return a;...
#include <bits/stdc++.h> int main() { int t, l, r, d, m, n, i; scanf( %d , &t); for (i = 0; i < t; i++) { scanf( %d %d %d , &l, &r, &d); if (l > d || r < d) { printf( %d n , d); } else { m = (r / d) + 1; n = d * m; printf( %d n , n); } } retu...
#include <bits/stdc++.h> using namespace std; int main() { double m, n; long long int r, a, b, c, d, dist, sim; cin >> r >> a >> b >> c >> d; dist = (c - a) * (c - a) + (d - b) * (d - b); m = sqrt(dist); m = m / 2; c = m / r; m = m / r; if (m == c) cout << c; else ...
#include <bits/stdc++.h> int main() { int HPY, ATKY, DEFY, HPM, ATKM, DEFM, h, a, d; while (scanf( %d %d %d , &HPY, &ATKY, &DEFY) == 3) { scanf( %d %d %d , &HPM, &ATKM, &DEFM); scanf( %d %d %d , &h, &a, &d); int mini = 1000000000; for (int i = ATKY; i <= 301; i++) for (int j = ...
`timescale 1ns / 1ns module DriveTFT18( input wire clk, input wire rsth, output wire SCL, output wire WRX, output wire RESX, output wire CSX, inout wire SDA, output wire UART_TX, output wire [6:0] LED ); wire [24:0] w_mcs_gpo; wire [31:0] w_rdata; wire w_req = w...
#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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:53:35 05/15/2014 // Design Name: // Module Name: Timer // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenc...
/* * 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; long long pow(long long b, long long e, long long m) { long long t = 1; for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0; return t; } template <class T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; } template <...
#include <bits/stdc++.h> using namespace std; long long int mod(long long int x) { return (((x) % 1000000007) + 1000000007) % 1000000007; } long long int mod1(long long int x, long long int m) { return (((x) % m) + m) % m; } long long int solve() { long long int n, k; cin >> n >> k; long...
#include <bits/stdc++.h> using namespace std; long long s[100001]; int main() { int n, c = 1; long long sum = 0; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; sort(s, s + n); sum += s[0]; for (int i = 1; i < n; i++) { if (sum <= s[i]) { c++; sum += s[i]; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, q, r, c; cin >> n >> q; vector<vector<int>> a(2, vector<int>(n, 1)); vector<string> pass(q); set<pair<pair<int, int>, pair<int, int>>> count; for (int o = 0; o < q; o++) { cin >> r >> c; r--; c--; a[r][...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (lin64) Build Wed Dec 14 22:35:42 MST 2016 // Date : Sat Jan 21 17:57:15 2017 // Host : natu-OMEN-by-HP-Laptop running 64-bit Ubunt...
#include <bits/stdc++.h> using namespace std; struct coord { int c, f, v; }; coord var, pos; int n, m, i, x, cont, h; int pasos[1001][1001]; bool ya[1001][1001], e; char mapa[1001][1001]; queue<coord> cola; stack<coord> pila; int main() { scanf( %d%d , &n, &m); for (i = 0; i < n; i++) ...
#include <bits/stdc++.h> using namespace std; int n, m; char s[5001], t[5001]; int dp[5001][5001]; int main() { while (cin >> n >> m) { for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < m; i++) { cin >> t[i]; } for (int i = 0; i < m + 1; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, t; cin >> n >> t; if (n == 1 && t == 10) { cout << -1 ; return 0; } if (t != 10) cout << t; else cout << 1 ; for (int i = 1; i < ...
#include <bits/stdc++.h> void Get(int &T) { char C; bool F = 0; for (; C = getchar(), C < 0 || C > 9 ;) if (C == - ) F = 1; for (T = C - 0 ; C = getchar(), C >= 0 && C <= 9 ; T = T * 10 + C - 0 ) ; F && (T = -T); } void Get(long long &T) { char C; bool F = 0; f...
/* Distributed under the MIT license. Copyright (c) 2011 Dave McCoy () 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, mo...
#include <bits/stdc++.h> using namespace std; vector<set<int> > newadj(212345); int visit[212345]; vector<vector<int> > adj(212345); vector<int> vec, vecans; set<int> seti; int cnt = 0; int pos[212345]; int dfs(int cur) { cnt++; visit[cur] = 1; set<int>::iterator it; for (it = newadj[c...
#include <bits/stdc++.h> using namespace std; string s = FESTIVAL ; long long dp[1010][10]; int a[1010]; int main(void) { int i, j, k; dp[0][0] = 1; for ((i) = 0; (i) < (int)(1000); (i)++) for ((j) = 0; (j) < (int)(8); (j)++) for ((k) = 0; (k) < (int)(8); (k)++) if (j <= k...
#include <bits/stdc++.h> using namespace std; int p, q, r, s, t, u; int a[25]; int b[25]; int dp[25][25]; int n; int c[25]; int sgn(int x) { if (x > 0) return 1; else if (x < 0) return -1; else return 0; } int main() { int i, j; int n, k, a, b; cin >> n >> k...
/** * 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 t, n, k; void solve() { scanf( %d%d , &n, &k); if (n < k) { printf( NO n ); return; } if ((n - (k - 1)) % 2 == 1) { printf( YES n ); for (int i = 1; i <= k - 1; ++i) printf( 1 ); printf( %d n , n - (k - 1)); } els...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 5; const int inf = ~0U >> 1; template <class U, class V> struct MCMF { static const int N = 8000, M = 7001010; int h[N], ing[N], pre[N], to[M], ne[M], e, s, t, n; U cap[M]; V dis[N], cost[M]; void ini(int _n = N) { fil...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const int M = 7; int n, p, k; int s[N + 1][M + 1]; long long dp[N + 1][1 << M + 1]; pair<int, int> a[N + 1]; long long go(int idx, int mask) { if (idx > n) { if (mask == ((1 << p) - 1)) { return 0; } else { ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse2 ) using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> vo...
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; bool compare(int c, int d) { return a[c - 1] < a[d - 1]; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = i + 1; } sort(b, b + n, compare); cout << (n + 1) / 2 << endl; ...
/* * 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; template <typename T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; do { x = 10 * x + ch - 0 ; } while (isdigit(ch = getchar())); } const int N = 3e6 + 111; const int INF = 1e9; int n, q, D[N], res...
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; vector<int> aa(200); vector<int> bb(200); int n, k; int count(int i, int j) { for (int h = i; h < n; h++) { bb[...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int flag = 0; if (s.length() < 7) { cout << NO n ; return 0; } for (int i = 0; i <= s.length() - 7; i++) { flag = 0; for (int j = i; j < i + 7; j++) { if (s[i] == s[j]) c...
/** * 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...
module VIDEO_OUT ( pixel_clock, reset, vga_red_data, vga_green_data, vga_blue_data, h_synch, v_synch, blank, VGA_HSYNCH, VGA_VSYNCH, VGA_OUT_RED, VGA_OUT_GREEN, VGA_OUT_BLUE ); input pixel_clock; input reset; input vga_red_data; input vga_green_data; input vga_blue_data; input h_synch; input v_sy...
// // This is an up-down counter with initial and max values. // Even for counters that start at max value, it can be useful // to specify an even greater max. This is useful in case where you want to // be able to change the max value after hardware design time, // for example for credit counters between chips. The //...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int m, x, y, a, b; cin >> x >> y >> a >> b; m = abs(x - a) + abs(y - b); if (x != a && y != b) m = m + 2; cout << m << n ; } }
#include <bits/stdc++.h> using namespace std; int n, depth = 0; string loc[500]; string comm; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> comm; if (comm == cd ) { cin >> comm; int pos = 0; if (comm[0] == / ) { depth = 0; pos = 1...
// // Copyright 2011-2012 Ettus Research LLC // // 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, either version 3 of the License, or // (at your option) any later version. // // This program i...
#include <bits/stdc++.h> #pragma gcc optimize( Ofast ) using namespace std; using ll = long long; const int N = 1e6 + 2; int n, cnt, f[N], vis[N]; int qt, q[N]; vector<int> v; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; if (n & 1) return cout << -1 n , 0; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int a[MAXN], op[MAXN], op1[MAXN], op2[MAXN]; int n, m; vector<long long> sum[MAXN * 4]; set<int> col[MAXN]; vector<int> e[MAXN * 4]; void get(int o, int l, int r, int x, int y) { if (x <= l && r <= y) { e[o].push_back(x);...
#include <bits/stdc++.h> int aa[120][5], kk[5]; int solve(int *bb, int n) { int k, sum1, sum2, j, bad; sum1 = sum2 = 0; for (j = 0; j < 5; j++) { if (aa[0][j] != -1) sum1 += (bb[j] + 1) * (250 - aa[0][j]) * 2; if (aa[1][j] != -1) sum2 += (bb[j] + 1) * (250 - aa[1][j]) * 2; } if (sum1...
/** * 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...
// Copyright (c) 2014 CERN // Maciej Suminski <> // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // any late...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n / 2 * 3; }
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2009 Xilinx, Inc. // This design is confidential and proprietary of Xilinx, All Rights Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ /...
/** * 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() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n; cin >> n; vector<long long> v(n); set<long long> s; for (long long x = 0; x < n; x++) { ...
#include <bits/stdc++.h> using namespace std; const uint64_t seed = std::chrono::system_clock::now().time_since_epoch().count(); mt19937_64 rnd(seed); const int MOD = 998244353; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; set<pair<long l...
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int maxn = 1500 + 5; int count(vector<int>& rec, vector<int>& temp, int l, int h) { if (h - l < 1) r...
module alt_vipitc131_IS2Vid_control #(parameter USE_CONTROL = 1, NO_OF_MODES_INT = 1, USED_WORDS_WIDTH = 15) ( input wire rst, input wire clk, // From mode registers input wire av_write_ack, input wire mode_change, input wire [NO_OF_MODES_INT-1:0] m...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, l; cin >> n >> l; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); double maxy = INT_MIN * 1.0; for (int i = 0; i < n - 1; i++) { ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Case Western Reserve University // Engineer: Matt McConnell // // Create Date: 00:35:00 01/25/2017 // Project Name: EECS301 Digital Design // Design Name: Lab #2 Project // Module Name: ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 9; int pre[MAX], suf[MAX], a[MAX]; long long ans = 0, cnt = 0; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i], pre[i] = (i > 0 ? pre[i - 1] + a[i] : a[i]); int sum = pre[n - 1] / 3; if (pre[n -...
#include <bits/stdc++.h> using namespace std; struct Line { long long a, b; int id; Line(long long a, long long b, int id) : a(a), b(b), id(id) {} bool before(const Line &A, const Line B) { long long p1 = A.b - b, p2 = B.b - b; long long q1 = a - A.a, q2 = a - B.a; if (q1 < 0) { ...
#include <bits/stdc++.h> using namespace std; int maxn = 1000000000; int main(int argc, char const *argv[]) { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if (a > b) a = a + b, b = a - b, a = a - b; int side = max(2 * a, b); cout << side * side << endl; } ...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...
/** * 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> int main() { using namespace std; ios_base::sync_with_stdio(false), cin.tie(nullptr); int tt; cin >> tt; while (tt--) { int N; cin >> N; string s; cin >> s; auto solve = [&](void) -> void { for (int i = 0; i < N - 10; ++i) { ...
#include <bits/stdc++.h> using namespace std; inline void read(int& x) { char c = getchar(); x = 0; while (c < 0 || c > 9 ) c = getchar(); while (c <= 9 && c >= 0 ) x = x * 10 + c - 48, c = getchar(); return; } inline void write(int x) { if (!x) { putchar( 0 ); putchar(...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; map<int, int> v[N]; int rec(int node, int w) { auto it = v[node].lower_bound(w); if (it == v[node].begin()) { return 1; } it--; return (*it).second + 1; } int32_t main() { ios::sync_with_stdio(0); cin.tie(...
//----------------------------------------------------------------------------- // Title :Block level wrapper //----------------------------------------------------------------------------- // File : xgbaser_gt_same_quad_wrapper.v ...
/** * 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; void doRoutine() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; } signed main() { doRoutine(); vector<long long int> a(6); long long i...
#include <bits/stdc++.h> using namespace std; template <class T> void printArray(vector<T> arr) { for (T a : arr) cout << a << ; cout << n ; } void printVerdict(bool verdict) { cout << (verdict ? YES : NO ) << n ; } vector<long long> findPrime(long long n) { vector<long long> ret; ...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, , ); ...
module top ( input wire i_clk, input wire i_rst, input wire i_ce, input wire i_d1, input wire i_d2, output wire [14:0] io ); // BUFGs wire clk; BUFG bufg_1 (.I(i_clk), .O(clk)); genvar sa, e, i, sr, inv; generate begin // SRTYPE for (sa = 0; sa < 2...
#include <bits/stdc++.h> using namespace std; const int N = 1000050; int a[N]; int main() { int n, k; cin >> n >> k; if (n == 1 && k == 10) cout << -1 << endl; else { if (k == 10) { cout << 1 ; for (int i = 1; i < n; i++) cout << 0 ; cout << endl; } ...
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int a; std::cin >> a; int d[6]; for (int i = 0; i < 6; ++i) d[i] = a >> i & 1; std::cout << (d[0] << 4 | d[1] << 1 | d[2] << 3 | d[3] << 2 | d[4] | d[5] << 5) << ...
/** * 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 (c) 1998-2000 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, N = 1e5; int cnt[200], seq[200][17], fac[20], inv[20], ifac[20], popcnt[N], ln[N][17], tmp[N][17], ans[N], finalans[N], w[N], n, K, c; int qmod1(const int &x) { return x >= mod ? x - mod : x; } int qmod2(const int &x) { return x + ...
/* * 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...
`default_nettype none module execute_flag_register( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //Control input wire iCTRL_HOLD, //PFLAGR input wire iPFLAGR_VALID, input wire [4:0] iPFLAGR, //Prev input wire iPREV_INST_VALID, input wire iPREV_BUSY, input wire iPREV_FLAG_WRIT...
// (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 ...