text
stringlengths
59
71.4k
#include <bits/stdc++.h> template <class T> inline T gcd(T a, T b) { a = abs(a); b = abs(b); if (!b) return a; return __gcd(b, a % b); } template <class T> inline T lcm(T a, T b) { a = abs(a); b = abs(b); return (a / __gcd(a, b)) * b; } template <class T> inline T ncr(T n, T ...
#include <bits/stdc++.h> using namespace std; int n, m, f[50010]; struct node { int f[12], g[12], size; } a[50010]; struct cmp { bool operator()(node a, node b) { for (int i = 1; i <= m; i++) if (a.f[i] > b.g[i]) return 0; return 1; } }; multiset<node, cmp> q; inline void...
//================================================================================================== // Filename : musb_load_store_unit.v // Created On : 2014-09-29 20:35:18 // Last Modified : 2015-05-31 22:55:18 // Revision : 1.0 // Author : Angel Terrones // Company : Universidad Simón...
#include <bits/stdc++.h> using namespace std; int ans, a, b, c; int main() { cin >> a >> b >> c; ans = a; while (!(b >= ans + 1 && c >= ans + 2)) ans--; cout << 3 * ans + 3; return 0; }
// -*- Mode: Verilog -*- // Filename : wb_dsp_slave_regs.v // Description : Slave register interface for wishbone DSP // Author : Philip Tracton // Created On : Fri Nov 27 13:36:52 2015 // Last Modified By: Philip Tracton // Last Modified On: Fri Nov 27 13:36:52 201...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int INF = 1e9 + 10; int n, current; pair<int, int> best; int ans[N], block[N], sz[N]; vector<int> tree[N], tree_c[N]; int dfs1(int i, int parent) { sz[i] = 1; for (int k = 0; k < tree[i].size(); ++k) { int j = tree...
#include <bits/stdc++.h> using namespace std; const int dim = 52; char a[dim][dim]; int s[dim][dim]; int dp[dim][dim][dim][dim]; void compute(int i1, int j1, int i2, int j2) { if (dp[i1][j1][i2][j2] != 0x3f3f3f3f) return; int ans = max(i2 - i1 + 1, j2 - j1 + 1); if (s[i2][j2] - s[i1 - 1][j2] - s...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long p = 1234567, q = 123456, r = 1234, n; cin >> n; long long x = n; for (int a = 0; a <= n; a += 1234567) for (int b = 0; b <= n - a; b += 123456) { if ((n - a - b) % 123...
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int MM = 998244353; const long double PI = acos(-1); long long power(long long b, long long e, long long m) { if (e == 0) return 1; if (e & 1) return b * power(b * b % m, e / 2, m) % m; return power(b * b % m, e / 2, m);...
#include <bits/stdc++.h> using namespace std; using ii = pair<int, int>; using ll = long long; using li = pair<ll, int>; const int MAXK = 5000; struct jump { int node, prime, count; }; int n; vector<int> k; int fact_node[MAXK + 1]; vector<map<int, ii>> children; vector<int> primes; bool no...
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int inf = 1e9; using P = pair<int, int>; template <typename T> void printv(const vector<T> &v) { int sz = v.size(); for (int i = 0; i < sz; i++) { cout << v[i] << n [i == sz - 1]; } } using Graph = vector<...
/** * 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 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; pair<int, int> arr[5005]; vector<int> primes; int ans[5005]; int u[5005]; int n; void pre() { vector<char> bad(10005); for (int i = 2; i <= 10000; ++i) { if (!bad[i]) { primes.push_back(i); for (int j = i * i; j <= 10000; j += i) ...
#include <bits/stdc++.h> using namespace std; int n, m; int cnt[2][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { int x; cin >> x; cnt[0][x % 2]++; } for (int i = 1; i <= m; i++) { int x; ...
// // ICBLBC stack controller // // Copyright (c) 2014 Dominic Spill // // This file is part of Unambiguous Encapsulation. // // 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 2,...
////////////////////////////////////////////////////////////////////// //// //// //// actel_ujtag.v //// //// //// //// ...
// // Copyright (c) 1999 Steven Wilson () // // 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; template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; } template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; } const long long mod = 1e9 + 7, N = 2e5 + 5; inline long long msb(long lo...
#include <bits/stdc++.h> using namespace std; struct node { int x, y; } p[111]; int g[1111][1111]; int vis[1111]; int n; void dfs(int u) { vis[u] = 1; int i; for (i = 0; i < n; i++) { if (g[u][i] && !vis[i]) { dfs(i); } } } int main() { cin >> n; int i, ...
#include <bits/stdc++.h> using namespace std; const long long LL_MIN = std::numeric_limits<long long>::min(); const long long LL_MAX = std::numeric_limits<long long>::max(); template <class T, class R> ostream& operator<<(ostream& o, const pair<T, R>& p) { o << ( << p.first << , << p.second << ) ; ...
/******************************************************************************* * 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 ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21.02.2016 16:50:21 // Design Name: // Module Name: transmitter // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // R...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int g[4]; int i = 0; for (i = 0; i < 4; i++) { cin >> g[i]; } sort(g, g + 4); long long a = 0, b = 0, c = 0, k = 0; k = g[3]; a = g[0]; b = g[1]; c = g[2]...
// *************************************************************************** // *************************************************************************** // Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved. // // In this HDL repository, there are many different and unique modules, consisting // of...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's Store Buffer FIFO //// //// //// //// This file is part of the OpenR...
#include <bits/stdc++.h> using namespace std; inline int in() { int x; scanf( %d , &x); return x; } const int INF = 1e9 + 10; const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100; const int MN = 3e3 + 10; int n; vector<pair<int, int> > edges[MN]; int ans; int dp1[MN], d...
#include <bits/stdc++.h> using namespace std; using ll = long long; ll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; } ll nCr(ll n, ll r) { ll a = 1, b = 1; if (n < r) return 0; if (r == 0) return 1; if (n - r < r) r = n - r; while (r) { a *= n...
`include "../../../rtl/verilog/gfx/gfx_cuvz.v" module cuvz_bench(); parameter point_width = 16; reg clk_i; reg rst_i; reg ack_i; wire ack_o; reg write_i; reg [point_width-1:0] factor0_i; reg [point_width-1:0] factor1_i; reg [31:0] color0_i; ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_tsr.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/or // ...
/** * 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 law...
#include <bits/stdc++.h> using std::cin; using std::cout; using std::deque; using std::endl; using std::map; using std::max; using std::min; using std::multiset; using std::pair; using std::queue; using std::set; using std::sort; using std::stack; using std::string; using std::vector; in...
////////////////////////////////////////////////////////////////////// //// //// //// i2cSlave.v //// //// //// //// This file is part of the i2cSla...
#include <bits/stdc++.h> using namespace std; bool isPrime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } ...
#include <bits/stdc++.h> using namespace std; int d[3 * 1000001], v1[3 * 1000001], v2[3 * 1000001], a[1000001], i, n, tt, tt2, kq; void BFS1(int s, int k) { queue<int> q; if (v1[s] == 0) { q.push(s); v1[s] = k; } while (q.size() > 0) { int u = q.front(); q.pop(); ...
/* * 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...
// (C) 1992-2014 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 simulati...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2014, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
#include <bits/stdc++.h> using namespace std; int main() { int n, sticks; cin >> n; while (n--) { cin >> sticks; if (sticks % 2 == 0) cout << (sticks / 2) << endl; else cout << (1 + (sticks - 1) / 2) << endl; } }
/** * mux.v - Microcoded Accumulator CPU * Copyright (C) 2015 Orlando Arias, David Mascenik * * 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 * ...
module elink (/*AUTOARG*/ // Outputs elink_active, rxo_wr_wait_p, rxo_wr_wait_n, rxo_rd_wait_p, rxo_rd_wait_n, txo_lclk_p, txo_lclk_n, txo_frame_p, txo_frame_n, txo_data_p, txo_data_n, chipid, cclk_p, cclk_n, chip_nreset, mailbox_irq, rxwr_access, rxwr_packet, rxrd_access, rxrd_packet, rxrr_access, rx...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module sync_master ( input wire clk, // clo...
#include <bits/stdc++.h> using namespace std; int main() { cout << setprecision(10); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; if (x == 1) { cout << HARD n ; return 0; } } cout <...
/* * 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; bool sortbysec(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b) { if (a.first > b.first) return (a.first < b.first); else if (a.first == b.first) return (a.second > b.second); else r...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { int a[1010], b[1010]; int n; while (cin >> n) { for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; int ans = 0; for (int i = 0; i < n; i++) { int s = a[i]; while (s <= ans) s += b[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...
/** * 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 Header Begin ========================================== // // OpenSPARC T1 Processor File: cluster_header.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 an...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.length(); int a[n + 2][3]; for (int i = 0; i < n + 1; i++) for (int j = 0; j < 3; j++) a[i][j] = 0; for (int k = 0; k < s.length(); k++) { if (s[k] == . ) continue; else if (s[...
#include <bits/stdc++.h> using namespace std; int mediana(vector<int> &v) { if (int(v.size()) % 2 == 1) return v[int(v.size()) / 2]; return v[int(v.size()) / 2 - 1]; } bool esta(vector<int> &v, int x) { for (int i = 0; i < int(v.size()); i++) if (v[i] == x) return true; return false; } ...
#include <bits/stdc++.h> using namespace std; int main() { string k; cin >> k; int st = 0; while (st < (int)k.length() && k[st] == a && 1) { st++; } if (st == (int)k.length()) { k[k.length() - 1] = z ; cout << k << endl; return 0; } int se = st + 1; whi...
// modelling dma_access.v in both burst and one-shot modes module tb_dma1; integer i,j,k; tri1 iorq_n,mreq_n,rd_n,wr_n; reg clk,rst_n; wire busrq_n,busak_n; trireg [15:0] zaddr; tri [7:0] zdata; reg dma_req, dma_rnw; wire dma_busynready; wire mem_dma_bus; wire [15:0] mem_dma_addr; ...
#include <bits/stdc++.h> using namespace std; long long n, k, t = 0, a, e = 0; int main() { cin >> n >> k; for (long long i = 1; i <= n; i++) { cin >> a; if (i > 1 && t - (n - i) * a * (i - e - 1) < k) { cout << i << n ; e++; } else t += a * (i - 1 - e); } ...
#include <bits/stdc++.h> using namespace std; int main() { int ab, bc, ca, abc; int temp[4]; for (int i = 0; i < 4; i++) { cin >> temp[i]; } sort(temp, temp + 4); ab = temp[0]; bc = temp[1]; ca = temp[2]; abc = temp[3]; int a, b, c; a = abc - bc; b = ab - a; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, t; cin >> n >> m; string s[100 + 10]; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { t = s[i][0]; for (int j = 0; j < m; j++) { if (s[i][j] != t) { cout << NO...
#include <bits/stdc++.h> using namespace std; bool vis[10000001]; int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } int lcm(int a, int b) { return ((a * b) / gcd(a, b)); } int main() { int n; scanf( %d , &n); int sum = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; ...
// 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; parameter int SIZES [3:1] = '{10,20,30}; parameter int SUMS3 = SIZES[3]; parameter int ...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const int mod = 1e9 + 7; struct point { int x, y; inline friend long long operator*(point a, point b) { return 1ll * a.x * b.y - 1ll * a.y * b.x; } } p[N]; long long sx[N], sy[N], s[N], ans, sum, area; int n; inline l...
#include <bits/stdc++.h> using namespace std; int main() { int seq[60]; int yea[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; for (int i = 1; i <= 12; i++) { seq[i - 1] = yea[i - 1]; seq[12 + i - 1] = yea[i - 1]; seq[24 + i - 1] = yea[i - 1]; seq[36 + i - 1] = yea[i - 1...
#include <bits/stdc++.h> using namespace std; int calc(int n) { for (int i = 1; i <= 10; ++i) { int tmp = n - i, cnt = 0; for (; tmp; ++cnt, tmp /= 10) ; if (cnt == i) return n - i; } } char s[1000050], ss[1000050]; int ans[1000050], a[1000050], n, m; char f[4][1000050], re...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> a(10, 0), b(10, 0); string n; string num; cin >> n >> num; for (auto w : num) { a[w - 0 ]++; } int minimum = INT_MAX; for (auto w : n) b[w - 0 ]++; for (int i = 0; i < 10; i++) { if (i != 2 && i ...
#include <bits/stdc++.h> using namespace std; const int N = 5000 + 100; const int M = 30; int n; string s; string t; int mat[M][M][N]; int ones[N]; int ans; long double javab; set<char> g; bool mark[30]; int chand[30]; bool oomade[30]; int main() { cin >> s; n = s.size(); for (...
#include <bits/stdc++.h> using namespace std; long n, tim; string st; long lpos, calc1, calc2; long need, ans, calc; long l, r, has, bad; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> tim; cin >> st; lpos = -1; for (int i = 0; i < st.size(); i++) { if (st...
#include <bits/stdc++.h> using namespace std; long long get() { long long x = 0; char s = getchar(); while (s < 0 || s > 9 ) s = getchar(); while (s >= 0 && s <= 9 ) x = (x << 3) + (x << 1) + (s ^ 48), s = getchar(); return x; } long long Max(const long long x, const long long y)...
#include <bits/stdc++.h> using namespace std; int n, x; vector<int> v; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &x); int a = lower_bound(v.begin(), v.end(), x) - v.begin(); if (a == v.size()) v.push_back(x); else v[a] = x; } ...
#include <bits/stdc++.h> using namespace std; int co; bool query(int x, int y) { assert(++co <= 60); printf( 1 %d %d n , x, y); fflush(stdout); char st[5]; scanf( %s , st); return st[0] == N ; } int main() { int fst, scnd, n, k; scanf( %d %d , &n, &k); int l = 1, r = n; ...
/* * 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; string st; set<string> S; map<string, int> mp; map<string, string> mp2; int n, q; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { S.clear(); cin >> st; int len = st.length(); for (int fr = 0...
/* -------------------------------------------------------------------------- Pegasus - Copyright (C) 2012 Gregory Matthew James. This file is part of Pegasus. Pegasus is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software ...
/* * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:53:07 07/01/2014 // Design Name: // Module Name: cheat // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: //...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2016 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", ...
module testbench_FastMultiplier(); reg[31:0] mulcand; reg[31:0] muler; reg[31:0] mulcand_U; reg[31:0] muler_U; integer mulcand_S; integer muler_S; supply0 ZERO_BIT; supply1 SET_BIT; wire[63:0] expectProduct_U; wire[63:0] expectProduct_S; wire[63:0] product_U; wire[63:0] product_S; always @(*) begin mulcand_U...
/* * 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...
/** * 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 mux_if_unbal_4_1 #(parameter N=4, parameter W=1) (input [N*W-1:0] i, input [$clog2(N)-1:0] s, output reg [W-1:0] o); always @* if (s == 0) o <= i[0*W+:W]; else if (s == 1) o <= i[1*W+:W]; else if (s == 2) o <= i[2*W+:W]; else if (s == 3) o <= i[3*W+:W]; else o <= {W{1'bx}}; endmodule module ...
module test (); reg pass = 1'b1; reg d; real f = 0.0, z = 0.0, y = 1.0; always @(d) force f = z; initial begin // Verify the initial value. #1; if (f != 0.0) begin $display("Failed initial value, expected 0.0, got %f", f); pass = 1'b0; end // Verify that the force changed th...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; vector<vector<int> > T(n); for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; --a; --b; T[a].push_back(b); T[b].push_back(a); } vector<boo...
#include <bits/stdc++.h> using namespace std; long long int INF = 1e17; const long long fact_table = 800008; double Pi = 3.1415926535897932384626; priority_queue<long long> pql; priority_queue<pair<long long, long long> > pqp; priority_queue<long long, vector<long long>, greater<long long> > pqls; long ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int add(int a, int b) { a += b; return a >= mod ? a - mod : a; } const int MN = 1000011; int f[MN][2], n; inline void Main() { f[0][0] = f[0][1] = 1; scanf( %d , &n); for (register int i = (1), _c = (n); i <= _c;...
// DEFINES `define BITS 2 // Bit width of the operands module bm_dag1_log_mod(clock, reset_n, a_in, b_in, c_in, d_in, out0, out1); // SIGNAL DECLARATIONS input clock; input reset_n; input [`BITS-1:0] a_in; input [`BITS-1:0] b_in; input c_in; input d_in; output [`BITS-1:0] out0; output ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 100; pair<int, int> khar[maxn]; bool mk[10 * maxn]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; mk[a] = true; khar[i] = pair<int, int>(a, b); } sort(khar...
#include <bits/stdc++.h> using namespace std; int n; char a[1005], b[1005]; int minn, maxx; int main() { scanf( %d , &n); scanf( %s%s , a, b); sort(a, a + n); sort(b, b + n); for (int i = 0, j = 0; i < n; i++) { while (j < n && b[j] < a[i]) j++; if (j < n) j++; el...
/* * MBus Copyright 2015 Regents of the University of Michigan * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required ...
// // display.v -- 30x80 character display, with attributes // module display(clk, dsp_row, dsp_col, dsp_en, dsp_wr, dsp_wr_data, dsp_rd_data, hsync, vsync, r, g, b); input clk; input [4:0] dsp_row; input [6:0] dsp_col; input dsp_en; input dsp_wr; i...
#include <bits/stdc++.h> using namespace std; void Freopen() { freopen( title .in , r , stdin); freopen( title .out , w , stdout); } int read() { int g = 0, f = 1; char ch = getchar(); while (ch < 0 || 9 < ch) { if (ch == - )...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; char s[maxn], t[maxn]; int nxt[maxn]; void getNxt(int m) { int i = 1, j = 0; nxt[0] = 0; while (i < m) { if (t[i] == t[j]) nxt[i++] = ++j; else if (!j) i++; else j = nxt[j - 1]; }...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; std::vector<vector<int>> 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...
// megafunction wizard: %In-System Sources and Probes% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsource_probe // ============================================================ // File Name: hps_reset.v // Megafunction Name(s): // altsource_probe // // Simulation Library Files(s): // alter...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const long long int INF = 1e18 + 2; bool compareBysecond(pair<long long int, long long int> a, pair<long long int, long long int> b) { return a.second > b.second; } int log(long long int x) { int cnt = 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> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) using namespace std; const int MX = 2000006; char a[MX], b[MX]; char arb[MX], abr[MX], ba[MX]; int parb[MX], zabr[MX], zba[MX], pos[MX]; void compute_pi(int n, char s[], i...
#include <bits/stdc++.h> using namespace std; int n; int main() { scanf( %d , &n); long long ans = 0; int cur = 0; for (int i = 0; i < n; ++i) { int a; scanf( %d , &a); int p = min(cur, a / 2); a -= p * 2, cur -= p, ans += p; ans += a / 3, a %= 3; cur += a; ...
#include <bits/stdc++.h> using namespace std; long long n, m; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { cin >> n >> m; string x, y; cin.ignore(); getline(cin, x); getline(cin, y); int lenx = (int)x.length(), leny = (int)y.length(); i...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; long long a[3], b[3]; cin >> a[0] >> a[1] >> a[2]; cin >> b[0] >> b[1] >> b[2]; cout << max(0ll, a[0] - b[0] - b[2]) + max(0ll, a[1] - b[1] - b[0]) + max(0ll, a[2] - b[2] - b[1]) << ; ...