text
stringlengths
59
71.4k
/** * 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 Takashi Toyoshima <>. // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. module RAMSpartan3StarterKit( // Clock Sources CLK50MHZ, SOCKET, // Fast, Asynchronous SRAM SRAM_A, SRAM_WE_X, SRAM_OE_X,...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/24 11:30:30 // Design Name: // Module Name: rca_dataflow_tb // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // ...
module step_id(inst, ena_, cond_dout, rdy_nop_, rdy_cpf_, rdy_cpt_, rdy_ld_, rdy_st_, rdy_clr_, rdy_im_, rdy_tce_, rdy_ts_, rdy_add_, rdy_sub_); input[7:0] inst; input ena_; input cond_dout; output rdy_nop_, rdy_cpf_, rdy_cpt_, rdy_ld_, rdy_st_, rdy_clr_, rdy_im_, rdy_tce_, rdy_ts_, rdy_add_, rdy_su...
#include <bits/stdc++.h> using namespace std; int main() { int n, q; scanf( %d , &n); bool grid[n + 1][n + 1], ans = false; string s; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf( %d , &grid[i][j]); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 23:44:46 06/13/2016 // Design Name: // Module Name: LZD_8bit // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
#include <bits/stdc++.h> using namespace std; const long long INF = 1111111111; const long long MOD = 1e9 + 7; int pref[5001][5001]; int nxt[5001][5001]; int dp(int i, int j) { int x; if (i > 0) { x = pref[i][j] - pref[i - 1][j]; } else { x = pref[0][j]; } x %= MOD; if (x...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:46:04 07/12/2015 // Design Name: // Module Name: Data_Ram // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 5; const int mod = (int)1e9 + 7; const int logN = 17; const int inf = 1e9; const int N = 1e6 + 5; int way[N][2], size[N], all[N][30][2], n, m, a[N], S = 1; void insert(int x) { int node = 1; for (int i = 29; i >= 0; i--)...
//lpm_divide CBX_SINGLE_OUTPUT_FILE="ON" LPM_DREPRESENTATION="UNSIGNED" LPM_HINT="MAXIMIZE_SPEED=5,LPM_REMAINDERPOSITIVE=TRUE" LPM_NREPRESENTATION="UNSIGNED" LPM_TYPE="LPM_DIVIDE" LPM_WIDTHD=25 LPM_WIDTHN=64 denom numer quotient remain //VERSION_BEGIN 16.0 cbx_mgl 2016:07:21:01:49:21:SJ cbx_stratixii 2016:07:21:01:48:1...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; ; const int inf = 1e9 + 5; const int mod = 1e9 + 7; const int logN = 17; int x, y, n, m, a[N], b[N], w[N], p[N], score[N]; vector<int> v[N]; long long ans[N], upsum[N], downsum[N]; bool cmp(int x, int y) { return score[x] < score[y...
#include <bits/stdc++.h> using namespace std; const int N = 1500010; int n, cnt, ans; int a[N], bug[N], v[N]; map<pair<int, int>, int> vis; bool check(int i) { if (!(i & 1)) { if (i < n) return a[i - 1] < a[i] && a[i + 1] < a[i]; else return a[i - 1] < a[i]; } else if (i ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000000 + 7; const long long int N = 10000000 + 6; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b; cin >> a >> b; vector<pair<int, int> > bb, aa; for (int i = 1; i < 1000; i++) { ...
#include <bits/stdc++.h> using namespace std; string str; int make(int star, int en) { if (en - star >= 7) return -1e7; if (en - star >= 1 && str[star] == 0 ) return -1e7; if (str[star] == 0 && str[en] != 0 ) return -1e7; int sum = 0; for (int i = star; i <= en; i++) { sum = sum * 10...
//Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2015.2.1 (lin64) Build Wed Aug 5 13:06:02 MDT 2015 //Date : Wed Aug 17 16:30:57 2016 //Host : HomeMegaUbuntu running 64-bit Ubuntu 16.04.1 L...
module memif( input wire clk, input wire reset, // Avalon Slave input wire [1:0] s_address, input wire s_write, input wire s_read, input wire [31:0] s_writedata, output reg [31:0] s_readdata, output wire s_waitrequest, // 36 bit Avalon Master output wire [17:0] m_address, output reg m_write, output reg m...
#include <bits/stdc++.h> using namespace std; int main() { long n, sum = 1e6; cin >> n; long a[n]; for (long i = 0; i < n; cin >> a[i++]) ; long opt; for (long i = 1; i <= 1000; ++i) { long s = 0; for (long j = 0; j < n; ++j) { if (i != a[j]) s += abs(i - a[j]) - 1;...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; long long n, k, dp[N], sum, pos, s1, s2, deep[N], mndp[N], ans, ss, ss1; vector<pair<long long, long long> > g[N]; void dfs(long long x, long long p) { dp[x] = 0; for (long long i = 0; i < g[x].size(); ++i) { long long y ...
//----------------------------------------------------------------- // RISC-V Top // V0.6 // Ultra-Embedded.com // Copyright 2014-2019 // // // // License: BSD //--------------------------...
module top; reg pass; wire [2:-1] vec; assign vec = 4'bxxxx; initial begin pass = 1'b1; force vec[1'bx] = 1'b1; if (vec !== 4'bxxx) begin $display("Failed vec[1'bx], expected 4'bxxxx, got %b", vec); pass = 1'b0; end release vec[1'bx]; force vec[1'bx:0] = 1'b1; if (vec...
// bsg_fifo_tracker // // MBT 7/7/16 // `include "bsg_defines.v" module bsg_fifo_tracker #(parameter `BSG_INV_PARAM(els_p ) , ptr_width_lp = `BSG_SAFE_CLOG2(els_p) ) (input clk_i , input reset_i , input enq_i , input deq_i , output [...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 123; const int MINN = 1e3 + 123; const int mod = 1e9 + 7; const int INF = 1e9 + 1; pair<int, int> a[MINN]; bool cmp(pair<int, int> a, pair<int, int> b) { if (a.first < b.first) return 1; if (a.first == b.first) if (a.second...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Anton Potocnik // // Create Date: 07.01.2017 22:50:51 // Design Name: // Module Name: frequency_counter // Project Name: // Target Devices: // Tool Versions: // Description: Reciprotia...
// ---------------------------------------------------------------------- // Copyright (c) 2016, 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:...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:16:18 05/22/2016 // Design Name: // Module Name: MUX_DECO_FF // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: /...
module mux16 #( parameter W = 1 ) ( sel, i1111, i1110, i1101, i1100, i1011, i1010, i1001, i1000, i0111, i0110, i0101, i0100, i0011, i0010, i0001, i0000, o ); input [3:0] sel; input [W-1:0] i1111, i1110, i1101, i1100, i1011, ...
#include <bits/stdc++.h> using namespace std; const int Z = 3 * (int)1e3 + 111; const int N = 3 * (int)1e5 + 111; const int INF = (int)1e9 + 111; const int MOD = (int)1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; double l, d, v, g, r; cin >> l >> ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_io_ddr_impctl_pullup.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 redistrib...
/* * 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...
// part of NeoGS project (c) 2007-2008 NedoPC // // mem512b is 512 bytes synchronous memory, which maps directly to the EAB memory block of ACEX1K. // rdaddr is read address, dataout is the data read. Data is read with 1-clock latency, i.e. it // appears after the positive clock edge, which locked rdaddr. // wrad...
/* * 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 n, m, k, a[1003][1003], row[1003], col[1003]; int main() { scanf( %d%d%d , &n, &m, &k); int i, j; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) scanf( %d , &a[i][j]); for (i = 0; i <= n; i++) row[i] = i; for (i = 0; i <= m; i++) col[i...
/* Copyright (c) 2016-2017 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, distri...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `include "std_ovl_defines.h" `module ovl_code_distance (clock, reset, enable, test_expr1, test_expr2, fire); parameter severity_level = `OVL_SEVERITY_DEFAULT; parameter min = 1; ...
// ---------------------------------------------------------------------- // Copyright (c) 2016, 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 code() { long long n, k; cin >> n >> k; long long a[n]; for (long long i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); long long ans = 0; for (long long i = 0; i < n; i++) { if ((a[i] - a[0]) % k != 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; using ll = long long; const ll inf = 1e9 + 10; const ll inf_ll = 1e18 + 10; ll qry(ll t, ll i, ll j, ll k) { cout << t << << i << << j << << k << endl; ll r; cin >> r; return r; } int main() { ll n; cin >> n; ll b = 2; ...
#include <bits/stdc++.h> int p, v, n, s, t; int main(int argc, char** argv) { scanf( %d%d%d , &p, &v, &n); int aux = v; s = 0; t = 0; while (aux >= n) { int i; i = (aux / 50) % 475; for (int j = 0; j < 25; j++) { i = (i * 96 + 42) % 475; if (i + 26 == p) { ...
#include <bits/stdc++.h> using namespace std; int t, n, m, a[15], ans, b[10010]; char s[15][10010]; struct P { int val, id; } p[10010]; inline bool cmp(P x, P y) { return x.val < y.val; } int main() { scanf( %d , &t); while (t--) { scanf( %d%d , &n, &m); ans = 0; for (int i =...
/******************************************************************************* * 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n], b[n]; for (int i = 0; i < n; i++) scanf( %lld , a + i); for (int i = 0; i < n; i++) { scanf( %lld , b + i); } long long count = 0, index = 0; set<long long> s; for (int i = 0; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 22:53:19 10/26/2014 // Design Name: // Module Name: tb_uart // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3); if (a[0] + a[1] >= a[2] - 1) { cout << Yes n ; } else cout << No n ; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; if (t <= 203) { int dp[n * t + 1][301]; memset(dp, 0, sizeof(dp)); int ar[n * t]; int N = n * t; for (int ctr1 = 0; ctr1 < N; ctr1++) { if (ctr1 < n) cin >> ar[ctr1]; ...
`timescale 1ns / 100ps module uartlib( input UART_CLK, output reg UART_TX ); integer counter; initial UART_TX = 1; task write_byte; input [7:0] data; begin //start bit $display("write_byte: 0x%x (0b%b) [%c]", data, data, da...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, h, x, r = 0; cin >> n >> h; for (int i = 0; i < n; i++) { cin >> x; if (x > h) { r += 2; } else { r += 1; } } cout << r << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int dp[160][160]; int main() { int n; scanf( %d , &n); dp[1][1] = 1; dp[0][0] = 1; for (int i = 2; i <= n; i++) { for (int j = 0; j <= n; j++) { if (j == 0) dp[i][j] = dp[i - 2][j]; else dp[i][j] = (dp[i - ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:50:09 06/01/2015 // Design Name: mixColumnsAll // Module Name: F:/Projects/Xilinx/Rijndael/test_mixcolumnsall.v // Project Name: Rijndael // Target Devi...
#include <bits/stdc++.h> using namespace std; long long n, l, t, a[3000010], gx; double Ans; signed main() { scanf( %lld%lld%lld , &n, &l, &t); t *= 2; gx = t / l, t %= l; for (long long i = 1; i <= n; i++) scanf( %lld , &a[i + n]); for (long long i = 1; i <= n; i++) a[i] = a[i + n] - l; ...
// clockgen.v // clock generator module clockgen ( input clk, input reset, input [5:0]clkdiv, input shift, input stretch, output reg sync, output reg phase, output reg adcclk, output reg adcsync ); // --- main counter (phase register) -------------------- reg [5:0]counter; always @(posedge clk 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...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const double eps = 1e-12; int n, k, h; struct lemming { int w, v, id; bool operator<(const lemming &rhs) const { if (w != rhs.w) return w < rhs.w; return v < rhs.v; } } a[maxn]; vector<int> ans; int dcmp(doub...
/* This is a simple SPI slave to GPIO bridge. It has a clock input, a synchronous reset input, an SPI slave interface which is supposed to be hooked up to an SPI master and an 8-bit output register. The contents of the output register is updated by doing a one byte SPI transaction. A bit is registered every time t...
//***************************************************************************** // (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; int main() { int n; scanf( %d , &n); bool val = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int a; scanf( %d , &a); if (i == j) { val ^= a; } } } int q; scanf( %d , &q);...
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 10, mod = 1e9 + 9; const int maxn = 500010; const long double eps = 1e-5; const int EPS = 500 * 500; template <typename T> void read(T &x) { x = 0; char ch = getchar(); long long first = 1; while (!isdigit(ch)) { if (c...
//////////////////////////////////////////////////////////////////////////////////// // File: sram_wrapper.v // Author: B. Brown // About: Abstracts the Altera DE2 SRAM signals away with a basic RAM interface. //////////////////////////////////////////////////////////////////////////////////// module sram_wrapper (...
#include <bits/stdc++.h> using namespace std; const int maxn = 405; const int inf = 0x3f3f3f3f; int n, m; int a[maxn]; int f[maxn][maxn][maxn]; template <typename T> inline void minimize(T &target, const T &value) { if (target > value) { target = value; } } void divide(int a[], int f[]...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; string s; getline(cin, s); set<char> st; for (int i = 0; i < s.length(); i++) { if (s[i] == { || s[i] == } || s[i] == , || s[i] == ) { continue; } el...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int main() { fast(); long long n; cin >> n; if (n % 4 == 1) cout << 0 << << A << endl; else if (n % 4 == 0) cout << 1 << << A ...
/** * 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: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: bomb.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===============================...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: redDiskWin.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =========================...
/* * 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 int mod1 = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long int t; t = 1; for (long long int f = 0; f < t; f++) { int n; cin >> n; string A; cin >> A; int i; int x = n - ...
//Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2016.1 (lin64) Build Fri Apr 8 15:45:23 MDT 2016 //Date : Mon Jun 6 23:44:13 2016 //Host : edinburgh running 64-bit Ubuntu 15.04 //Command ...
/* * Milkymist VJ 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 ...
#include <bits/stdc++.h> using namespace std; unordered_set<int> si; int fff = 0; int fj = 2; void mmin(int &t) { for (int j = fj; 1;) { int fflag = 0; vector<int> pr; for (int i = 2; i < sqrt(j) + 1; i++) { if (j % i == 0) { if (si.find(i) == si.end() && si.find(j / i)...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.1 (win64) Build Mon Apr 27 19:22:08 MDT 2015 // Date : Tue Mar 29 14:16:28 2016 // Host : DESKTOP-5FTSDRT running 64-bit major releas...
#include <bits/stdc++.h> using namespace std; long long tree[4000005]; long long level[4000005]; long long num[1000005]; long long build(long long at, long long L, long long R) { if (L == R) { tree[at] = num[L]; level[at] = 1; return num[L]; } long long mid = (L + R) / 2, a, b, p...
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 100000 + 10; int _min(int a, int b) { if (a < b) return a; else return b; } int _max(int a, int b) { if (a > b) return a; else return b; } char s[1005]; int col[4] = {0}; int row[4] = {0}; 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 la...
`define MSBI 9 // Most significant Bit of DAC input // this is a delta-sigma digital to analog converter module dac (o, i, clock, reset); output o; // this is the average output that feeds low pass filter input [`MSBI:0] i; // dac input (excess 2**msbi) input clock; input reset; reg o; // for optimum ...
`timescale 1ns / 1ps module DMA_Controller #( parameter N = 6, parameter WIDTH = 16, parameter ADDR = 12, parameter M_WIDTH = 2*WIDTH+N-1 )( input clk, input start, // MATRIX MEMORY A output reg A_rd, output reg [ADDR-1:0] A_addr, input [N*WIDTH-1:0] A_dout, // MATRIX M...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: ff_jbi_sc3_1.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/...
#include <bits/stdc++.h> using namespace std; int main() { int i = 0, j = 0, cs = 0, in; int n; cin >> n; vector<int> v; int sum = 0, s = 0; for (int i = 1; i < n; i++) { cout << ? << i << << n << n ; int x; cin >> x; if (i > 1) { v.push_back(sum - x ...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; struct Segment { int left, right; } seg[N / 2 + 5]; map<int, bool> m; int a[N]; int n, ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); m.clear(); ans = 1; seg[ans].left = 1; ...
/** * Frame buffer * 800x480 ( / 16 = 24000) for hack screen of 512 x 256 * * Translate pixel positions to ram addresses then uses ram. */ module frame_buffer( input clk, // the system clock input [15:0] read_value, input [7:0] keyboard, // debug the current keypress on the vga...
#include <bits/stdc++.h> using namespace std; int main() { bool x = false; string s; cin >> s; string b; for (int i = 0; i < s.size(); i++) { if (s[i] == d && s[i + 1] == o && s[i + 2] == t && i != 0 && i + 2 < s.size() - 1) { b += . ; s[i + 1] = ; ...
#include <bits/stdc++.h> using namespace std; queue<pair<int, int> > L, R; int **M; int ori, n, m; bool play(pair<int, int> &p, int &ori) { for (int i = 0; i < 2; i++) { if (ori == 0) { if (M[p.first + 1][p.second] > 0) ori++; else { p = {p.first + 1, p.second}; ...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int MAX = 1000007; int n; long long a, b; vector<int> primes(int x) { vector<int> p; for (int i = 2; i * i <= x; ++i) if (x % i == 0) { p.push_back(i); while (x % i == 0) { x /= i; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { double a, b, c, d, k; cin >> a >> b >> c >> d >> k; double pen = a / c; double pencil = b / d; pen = ceil(pen); pencil = ceil(pencil); if ((pen + pencil) <= k) { do...
#include <bits/stdc++.h> using namespace std; int inpt1[300000], inpt2[300000]; int main() { priority_queue<int> q; int n, k, x, sm; scanf( %d %d , &n, &k); sm = 0; for (int i = 0; i < n; i++) scanf( %d , &inpt1[i]); for (int i = 0; i < n; i++) { scanf( %d , &x); sm += x; ...
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << { << p.first << , << p.second << } ; return os; } co...
#include <bits/stdc++.h> using namespace std; long long ar[500005 + 5]; int main() { long long i, j, k, n; cin >> n; if (n <= 2) cout << 1 << endl; else if (n == 3) cout << 2 << endl; else { long long lo = 1LL, hi = n, ans = 1LL; while (lo <= hi) { long long md ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int A[n + 1]; A[0] = 0; for (int i = 1; i < n + 1; i++) { cin >> A[i]; } int dollar = A[1]; int cou = 0; for (int i = 1; i < n; i++) { cou = cou + A[i] - A[i + 1]; if (cou < 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...
//############################################################################# //# Function: Generic counter # //############################################################################# //# Author: Andreas Olofsson # ...
/*********************************************************************************************************************** * Copyright (C) 2016 Andrew Zonenberg and contributors * * ...
`timescale 1 ns / 1 ps module gpio_debouncer # ( parameter integer DATA_WIDTH = 8, parameter integer CNTR_WIDTH = 22 ) ( input wire aclk, inout wire [DATA_WIDTH-1:0] gpio_data, output wire [DATA_WIDTH-1:0] deb_data, output wire [DATA_WIDTH-1:0] raw_data ); reg [DATA_WIDTH-1:0] int_...
#include <bits/stdc++.h> std::mt19937 rnd(time(0)); const int N = 200005; int n, m, a[N], c[N]; int v; int ans; int p[N << 1]; void updAns(int x) { if (v == x) { return; } for (int i = 0; i <= 2 * n; ++i) { p[i] = -1; } int now = n; p[now] = 0; for (int i = 1; i <= ...
// // 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...
/* * 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; int main() { int n, k; int i, j; cin >> n >> k; int arr[n]; for (i = 0; i < n; i++) cin >> arr[i]; int one, two; int m = 0; for (i = 0; i < k; i++) { one = 0, two = 0; for (j = i; j < n; j = j + k) { if (arr[j] == 1) ...
`default_nettype none `include "common.h" module execute_debugger( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //Debugger Port input wire iDEBUG_CTRL_REQ, input wire iDEBUG_CTRL_STOP, input wire iDEBUG_CTRL_START, output wire oDEBUG_CTRL_ACK, output wire [31:0] oDEBUG_REG_OUT_FLAG...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: ctu_bottom_rptr.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 a...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int o = 0, t = 0, to = 0; int n = s.length(); for (int i = 0; i < n; i++) { if (s.substr(i, 3) == one ) { o++; i++; } else if (...
#include <bits/stdc++.h> using namespace std; int t, n, a[5], ans[5], f1[19491001], cxk, f2[19491001]; int mod1 = 19260817, mod2 = 233317; string s; inline int Read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; struct Event { int t, L, R, on; Event(int t = 0, int L = 0, int R = 0, int on = 0) : t(t), L(L), R(R), on(on) {} bool operator<(const Event &rh) const { return t < rh.t; } } E[maxn * 2]; int V[maxn * 2], cnt; int Pre[...