text
stringlengths
59
71.4k
/* This file is part of Fusion-Core-ISA. Fusion-Core-ISA 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. Fusion-Core-...
#include <bits/stdc++.h> using namespace std; const int limB = 1 << 20; const int limN = 20; bool usdA[limB][limN], usdB[limB][limN]; int ansA[limB][limN], ansB[limB][limN]; int ja(int n, int k); int jb(int n, int k); int ja(int n, int k) { if (k == 2) return n; if (usdA[n][k]) return ansA[n][k]...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * T...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2015 Xilinx, Inc. // // 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 // /...
#include <bits/stdc++.h> using namespace std; const long long N = 305; long long n, k; long long a[N][N], rows[N], cols[N]; long long sqr(long long x) { return x * x; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { ...
module mul_plain(a, b, p); parameter M = 6; parameter N = 6; input wire [M-1:0] a; input wire [N-1:0] b; output wire [M+N-1:0] p; assign p = a * b; endmodule module mul_signed_async (clk, rst, en, a, b, p); parameter M = 8; parameter N = 6; input wire signed clk, rst, en; ...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } inline long long Max(long long x, long long y) { return x > y ? x : y; } inline long...
/* * 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...
// // Prof. Taylor 7/24/2014 // <> // // Updated by Paul Gao 02/2019 // // DDR or center/edge-aligned SDR source synchronous input channel // // this implements: // incoming source-synchronous capture flops // async fifo to go from source-synchronous domain to core domain // outgoing token channel to go f...
/** * 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) 2002 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; struct P { int x, y, z; bool operator<(const P &a) const { return y > a.y; }; }; int a, b, c, d, i, k, n, m, e, dx[10] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[10] = {0, 1, 0, -1, 1, -1, 1, -1}; long long o[500101]; int l[500111...
#include <bits/stdc++.h> using namespace std; int a[123][123], b[123][123], f1[54][54][54][54], f2[54][54][54][54]; int n; void getans(int i1, int j1, int i2, int j2) { int i, j, t; printf( ? %d %d %d %d n , i1, j1, i2, j2); fflush(stdout); scanf( %d , &t); if (t == f1[i1][j1][i2][j2]) { ...
#include <bits/stdc++.h> using namespace std; int n, u, r; int a[35]; int b[35]; int k[35]; int p[35]; int op[35]; int tmpa[35]; int tmmmma[35]; long long dfs(int index, const int ta[]) { if (index == u) { long long res = 0; for (int i = (0); i < ((n)); ++i) res += (long long)ta[i] *...
#include <bits/stdc++.h> using namespace std; int n, x, y; int a[1000]; bool inrange(int v) { return (v >= x && v <= y); } int main() { ios ::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] = a[i - 1] + a[i]; } cin >> x >> y; for (int i = ...
#include <bits/stdc++.h> int k, x, y; using namespace std; int main() { scanf( %d , &k); x = 1000000 - k % 2000; y = (k + x - 2000 * x) / 2000; printf( 2000 n ); for (int i = 1; i <= 1998; i++) printf( 0 ); printf( %d %d n , y, x); }
#include <bits/stdc++.h> using namespace std; int N; long long M; int A[200002], B[200002]; map<int, int> MP; vector<pair<long long, long long> > ST; long long getover(pair<long long, long long> p, int i2) { if (p.second >= ST[i2].second) return 0; return (ST[i2].second - p.second) / (p.first - ST...
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-6; const long double pi = acos(-1.0); int dx[] = {0, 1, 0, -1, 1, 1, -1, -1, 0}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1, 0}; int aq[5][5]; int main() { int n; cin >> n; for (int i = 0; i < (int)(n); ++i) { int x, y...
#include <bits/stdc++.h> using namespace std; static int io_sync_off = []() { ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }(); long long Pow(long long a, long long b, long long mod) { long long res = 1; a %= mod; while (b) { if (b & 1) (res *= a) %= mod; (a *= a)...
// DESCRIPTION: Verilator: Verilog Test module // verilator lint_off WIDTH // verilator lint_off VARHIDDEN module t ( clk ); input clk; integer cyc=0; reg [63:0] crc; initial crc = 64'h1; chk chk (.clk (clk), .rst_l (1'b1), .expr (|crc) ); always @ (posedge clk) begin cyc...
// File: ./ex-target/Rectifier.v // Generated by MyHDL 1.0dev // Date: Mon Oct 5 14:11:09 2015 `timescale 1ns/10ps module Rectifier ( y, y_dx, x ); // Rectified linear unit (ReLU) and derivative model using fixbv type. // // :param y: return max(0, x) as fixbv // :param y_dx: return d/dx max(0, x) as f...
/** * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013, David M. Lloyd // // This file is part of the PBIBox suite. // // PBIBox is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as publ...
// (c) Copyright 1995-2017 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { vector<string> s(9); for (long long int i = 0; i < 9; i++) { cin >> s[i]; } s[0][0] = s[0][1]; s[1][3] = s[1]...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:47:47 10/02/2013 // Design Name: // Module Name: VGA_Control // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: /...
////////////////////////////////////////////////////////////////////// //// //// //// File_communication.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 law...
#include <bits/stdc++.h> using namespace std; const long long int inf = 1e9 + 7; const long long int inf2 = inf * inf; priority_queue<long long int, vector<long long int>, greater<long long int>> mnheap; priority_queue<long long int> mxheap; long long int gcd(long long int x, long long int y) { if...
#include <bits/stdc++.h> using namespace std; long long i, j, t, n, k, a, b; double v; string line; char s[4]; int main() { while (cin >> n >> a >> b) { if (b < 0) b = n + b; a = a + b; a = a % n; if (a == 0) a = n; else if (a < 0) a = n + a; cout << a...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, M = 1e5 + 5, P = 105; int n, m, p; long long d[N]; int h[M], t[M]; long long a[M], s[M]; long long f[P][M]; int q[M]; long long Y(int j, int k) { return f[j - 1][k] + s[k]; } int32_t main() { cin >> n >> m >> p; for (int i ...
#include <bits/stdc++.h> using namespace std; const int N = 205; int d[N], head[N], tot; int to[N * N], nex[N * N], vis[N * N]; vector<pair<int, int> > ans; void init() { tot = 0; memset(d, 0, sizeof(d)); memset(head, -1, sizeof(head)); ans.clear(); } void add(int u, int v, int w) { ...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen */ // Design of the 2-bit pipe module pipeline_buffer_2bit (in,out,clock,reset); // Output signal for the design module output [1:0] out; // Output data signal // Input signals for the design module input [1:0] in; // Input data signal in...
////////////////////////////////////////////////////////////////////// //// //// //// uart_tfifo.v //// //// //// //// ...
#include <bits/stdc++.h> int n, ust, x, y, mark[10]; int main() { scanf( %d , &n); scanf( %d , &ust); for (int i = 0; i < n; i++) { scanf( %d %d , &x, &y); mark[x] = 1; mark[y] = 1; mark[7 - x] = 1; mark[7 - y] = 1; if (!mark[7 - ust]) for (int j = 0; j < 7; j...
/* * 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...
/***************************************************************************** * File : processing_system7_bfm_v2_0_arb_hp2_3.v * * Date : 2012-11 * * Description : Module that arbitrates between RD/WR requests from 2 ports. * Used for modelling the Top_Interconnect switch. ************************...
`timescale 1 ns / 1 ps module emaxi_v1_0 # ( // Users to add parameters here // User parameters ends // Do not modify the parameters beyond this line // Parameters of Axi Master Bus Interface M00_AXI parameter C_M00_AXI_TARGET_SLAVE_BASE_ADDR = 32'h40000000, parameter integer C_M00_AXI_BURST_LEN = 1...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) const int maxn = 5e5 + 5; struct Point { char ty; int x, y; Point(char ch = 0 , int x = 0, int y = 0) : ty(ch), x(x), y(y) {} } chess[maxn]; int X0, Y0, n; bool solve1() { vector<pair<int, ...
#include <bits/stdc++.h> using namespace std; long long n, m, ans, c, d; int a[1005][1005], b[1005][1005]; string s[1003]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) { d = 0; for (int j = 0; j < m; j++) { if (s...
#include <bits/stdc++.h> using namespace std; int h, i, j, x, l, r, pa[200200], pb[200200]; bool ans; int main() { scanf( %d , &h); for (j = 0; j <= h; j++) { scanf( %d , &x); for (i = 1; i <= x; i++) { pa[r + i] = l; pb[r + i] = min(l + i - 1, r); if (pa[r + i] != pb...
#include <bits/stdc++.h> const long long Inf = 1e18; const long double eps = 1e-7; long long LINF = (long long)2e18; using namespace std; long long mod = 1e9 + 7; long long mod5 = 1e9 + 9; long long mod3 = 998244353; long long mod4 = 1000003; long long mod2 = 1e9 + 123; const int MAXN = 10100000; ...
module EdgeDelay(clk, sigIn, waitCnt, sigOut, diagOut); //module EdgeDelay(clk, sigIn, waitCnt, sigOut); /*** This module looks at a signal and uses a timer to delay edges. Once the timer reaches the given number of clock cycles (specified by an input), an output is forced high. Ted Golfinopoulos, 12 September 2012 *...
/* * 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...
module clkgen( input clkin, output clkout, output lock ); parameter INCLOCK_FREQ = 12000000; parameter OUTCLOCK_FREQ = 24000000; localparam r_bits = 4; localparam f_bits = 7; localparam q_bits = 3; localparam rfq = compute_divisors(INCLOCK_FREQ, OUTCLOCK_FREQ); localparam r = rfq[(q_...
#include <bits/stdc++.h> using namespace std; int const INF = 100000; int p[INF + 1]; int M[INF + 1]; int main() { memset(p, -1, sizeof(p)); memset(M, -1, sizeof(M)); set<pair<int, int> > S; int n, x, k; cin >> n; while (n--) { cin >> x >> k; if (p[k] < x) { p[k] = ...
#include <bits/stdc++.h> using namespace std; int X[] = {1, 0, -1, 0, 1, -1, -1, 1}; int Y[] = {0, 1, 0, -1, 1, 1, -1, -1}; void MN(long long int &a, long long int b) { if (a > b) a = b; } void MX(long long int &a, long long int b) { if (a < b) a = b; } void MN(int &a, int b) { if (a > b) a ...
//-------------------------------------------------------------------------------- // meta.v // // Copyright (C) 2011 Ian Davis // // 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; eith...
#include <bits/stdc++.h> using namespace std; int L01P08(vector<int>& arr, int n) { bool check = true; if (arr[0] - 15 > 0) { return 15; } else { for (int i = 0; i < n - 1; i++) { for (int j = 1; j < n; j++) { if (arr[i] + 15 < arr[i + 1]) { return arr[i] + 15; ...
// ------------------------------------------------------------- // // File Name: mealy_rtl\Stateflow_Mealy_example\Mealy_Subsystem.v // // Generated by MATLAB 8.3 and HDL Coder 3.4 // // // -- ------------------------------------------------------------- // -- Rate and Clocking Details // -- ----------------------...
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, long long int> > P; int n; bool compare_y(const pair<long long int, long long int>& p1, const pair<long long int, long long int>& p2) { if (p1.second != p2.second) return p1.second < p2.second; return p1.first < p2...
/** * 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() { string s; cin >> s; int hoa = 0; int thuong = 0; for (int i = 0; i < s.size(); i++) { if (s[i] >= 65 && s[i] <= 90) { hoa++; } else { thuong++; } } if (thuong >= hoa) { for (int i = 0; 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> char putnb[20]; using namespace std; const long long mod = 1e9 + 7; const long long mod2 = 1999999973; const int infs = 1e8; const long long inf = 1e18; const int N = 200000; long long A[N + 5]; long long dp[N + 5][2]; bool vis[N + 5][2]; bool solved[N + 5][2]; long long...
`include "macro.v" `include "machine/cpu/mips.v" `include "machine/memory/rom.v" `include "machine/memory/ram.v" module machine( input wire clock, input wire reset ); wire[`INST_ADDR_BUS] rom_addr; wire[`INST_DATA_BUS] rom...
#include <bits/stdc++.h> using namespace std; inline int read() { int res = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -f; ch = getchar(); } while (isdigit(ch)) { res = (res << 3) + (res << 1) + ch - 0 ; ch = getchar(); } return res ...
#include <bits/stdc++.h> using namespace std; void Braka() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { Braka(); int n, k, ans = 0; cin >> n >> k; while (n--) { set<char> st; string s; cin >> s; for (int i = 0; i < s.length(); i++) ...
#include <bits/stdc++.h> using namespace std; long long expo(long long a, long long b, long long m) { long long result = 1; while (b) { if (b & 1) { result = (result * a) % m; } b = (b >> 1) % m; a = (a * a) % m; } return result; } double expof(double a, int b) { ...
/*-------------------------------------------------------------------- ---- ---- ---- altera_virtual_jtag.vhd ---- ---- ---- ---- ...
`include "bsg_defines.v" `include "config_defs.v" module cfgtag #(parameter packet_ID_width_p = 4 ,parameter RELAY_NUM = 5) (input clk // destination side clock from pins ,input reset // destination side reset from pins ,input cfg_clk_i // from IO pads ...
module top (input [(`WIDTH):0] a, /* This comma gets deleted */ /*AUTOOUTPUT*/ /*AUTOINPUT*/ // Beginning of automatic inputs (from unused autoinst inputs) input b // To child of child.v // End of automatics ); child child(/*AUTOINST*/ // Inputs ...
/*********************************************************************************************************************** * Copyright (C) 2016 Andrew Zonenberg and contributors * * ...
/* Copyright (c) 2015 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,...
/* * 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 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Fri Oct 27 10:19:56 2017 // Host : Juice-Laptop running 64-bit major release ...
#include <bits/stdc++.h> int n, m, op, det; int dir[2]; long long mv[2]; int ans[1111111]; int main() { scanf( %d%d , &n, &m); dir[1] = 1; dir[0] = -1; mv[1] = mv[0] = 0LL; for (int i = 0; i < m; i++) { scanf( %d , &op); if (op == 1) { scanf( %d , &det); mv[1] +...
#include <bits/stdc++.h> using namespace std; int binarySearch(int arr[], int l, int r, int x) { while (l <= r) { int m = l + (r - l) / 2; if (arr[m] == x) return m; if (arr[m] < x) l = m + 1; else r = m - 1; } return -1; } bool isprime(int n) { if (n <= 1...
#include <bits/stdc++.h> using namespace std; using int64 = long long; int main() { string s; cin >> s; int v[26] = {}; for (auto &c : s) v[c - a ]++; deque<int> odd; for (int i = 0; i < 26; i++) { if (v[i] % 2 == 1) odd.emplace_back(i); } while (odd.size() >= 2) { int...
// 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 : Mon Jun 05 10:58:36 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int n, m; char s[25][25]; int c[25][25]; int chs[1 << 21]; int dp[1 << 21]; vector<int> hv; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %s , s[i]); } for (int i = 0; i < n; ++i) { for (int j = 0; j < m...
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; while(T--){ int X[210] = {}; int N, M; cin >> N >> M; for(int i = 0; i < N; i++){ for(int j = 0; j < M; j++){ int a; cin >> a; X[i+j] ^= a; ...
#include <bits/stdc++.h> using namespace std; long long int const lac = 100000; long long int modmul(long long int a, long long int b) { return ((a % 1000000007) * (b % 1000000007)) % 1000000007; } long long int modadd(long long int a, long long int b) { return (((a % 1000000007) + (b % 1000000007))) ...
#include <bits/stdc++.h> using namespace std; int main() { string s; char a[100010]; int k; cin >> s; k = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == a[k]) k--; else { k++; a[k] = s[i]; } } if (k == 0) cout << Yes ; else ...
/* * 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; void substr(int start, int end, char in[], char out[]) { for (int i = start; i < end; ++i) out[i - start] = in[i]; out[end - start] = 0 ; } int main() { int n, p, q; char s[100]; cin >> n >> p >> q; cin >> s; int pdivmax = n / p + 1, qd...
#include <bits/stdc++.h> using namespace std; const int N = 200 + 10; int main() { int n, arr[N]; char f; char ch[N]; scanf( %d , &n); cin >> ch; n = 2 * n; for (int i = 0; i < n; i++) arr[i] = ch[i] - 0 ; sort(arr, arr + n / 2); sort(arr + n / 2, arr + n); bool a = false,...
/** * 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 = 1000000000000000000; map<pair<long long, int>, long long> memo; long long solve(long long n, int x) { pair<long long, int> p = make_pair(n, x); if (memo.find(p) != memo.end()) return memo[p]; if (n == 0) return memo[p] = 0; if (...
#include <bits/stdc++.h> using namespace std; void go(int parent, int node, int depth, int& odd_count, int& even_count, vector<vector<int>>& tree) { int count = 0; for (int i = 0; i < tree[node].size(); i++) { if (tree[node][i] != parent) { count++; go(node, tree[node][i], de...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel 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 docum...
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:50000000 ) using namespace std; int tt[1000000], kix[1000000], num[1000000], degree[1000000], black[1000000], fix[1000000]; vector<int> q, g[1000000]; int pirveli, p, i, j, n, m, k, a, b; int par[100005][20]; long long ans[1000000]; void go(...
/* * 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; vector<long long> adj[100005]; long long sn[100005], an[100005], level[100005]; long long got = 1; void dfs(long long u, long long par, long long carry) { if (sn[u] != -1 && sn[u] < carry) got = 0; level[u] = level[par] + 1; if (sn[u] != -1) { an...
#include <bits/stdc++.h> using namespace std; map<long long int, int> mp; map<long long int, int> mpp; long long int a[100007]; long long int b[100007]; long long int bb[100007]; int main() { int m, p; scanf( %d %d , &m, &p); int i, j; for (i = 0; i < m; i++) scanf( %lld , a + i); for ...
// $Id: c_extractor.v 1534 2009-09-16 16:10:23Z dub $ /* Copyright (c) 2007-2009, Trustees of The Leland Stanford Junior University 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 so...
/** * 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) 2011 * All Rights Reserved * */ `timescale 1ns/1ps module pipelined_normal_top (CLK_100MHZ); parameter LOOP_LOG2 = 1; localparam [5:0] LOOP = (6'd1 << LOOP_LOG2); localparam [31:0] GOLDEN_NONCE_OFFSET = (32'd1 << (7 - LOOP_LOG2)) + 32'd1; input CLK_100MHZ; //// reg [255:0] state = 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 <bits/stdc++.h> using namespace std; int main() { int n; long long k; scanf( %d , &n); scanf( %I64d , &k); int a; scanf( %d , &a); int ans = a; int count = 0; if (k > n - 2) { for (int i = 1; i < n; ++i) { scanf( %d , &a); if (a > ans) ans = a; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; logic [7:0] arr [7:0]; logic [7:0] arri [7:0]; has_array am1 (.clk(clk), .arri(arr), ....
#include <bits/stdc++.h> using namespace std; int arr[1000001], dp[(1 << 22)], N; int main() { scanf( %d , &N); memset(dp, -1, sizeof dp); for (int i = 0; i < N; i++) { scanf( %d , &arr[i]); dp[arr[i]] = arr[i]; } for (int i = 0; i < (1 << 22); i++) { for (int j = 0; j < 22; ...
#include <bits/stdc++.h> using namespace std; int main() { long n; int k; cin >> n >> k; long l = 1, r = n; while (l < r) { long m = l + (r - l) / 2; long s = 0, v = m; while (v != 0) { s += v; v /= k; } if (s >= n) r = m; else ...
module MemoryUnit #( parameter DATA_WIDTH = 32, parameter MEMORY_ADDR_WIDTH = 13, parameter BIOS_ADDRESS_WIDTH = 8, parameter STORAGE_ADDR_WIDTH = 15, parameter INSTRUCTION_SIZE = 16 )( input allow_write_on_memory, slow_clock, fast_clock, input [(DATA_WIDTH -1):0] original_address, ...
/** * 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...
`begin_keywords "1364-2005" /* * Copyright (c) 2002 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 Lice...
#include <bits/stdc++.h> using namespace std; const long long int INF = 2e18; const long long int N = 2e5 + 5; 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) { i...
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323846; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long get(long long x, long long n) { long long l, r; if (x > n) return 0; long long acc = 0; if (x % 2 == 0) { ...