text
stringlengths
59
71.4k
module SmallFilters2nd_tb (); parameter K0_SHIFT = 6; ///< K0 filter term = 2^-K0_SHIFT parameter K1_SHIFT = 6; ///< K1 filter term = 2^-K1_SHIFT parameter WIDTH = 16; ///< Width of data path parameter CLAMP = 1; ///< Set to 1 to clamp the accumulators parameter FREQ_RATE = ; reg clk; reg rst; reg en; reg signe...
module vcache(/*AUTOARG*/ // Outputs rgb, hsync, vsync, wb_cyc_o, wb_adr_o, wb_stb_o, wb_we_o, wb_sel_o, wb_dat_o, // Inputs wb_clk_i, wb_rst_i, vga_clk, wb_ack_i, wb_err_i, wb_rty_i, wb_dat_i ); input wire wb_clk_i; input wire wb_rst_i; input wire vga_clk; output [7:0] rgb; o...
//***************************************************************************** // (c) Copyright 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 // laws....
/* * 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 (c) 2015-2018 The Ultiparc Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> g; vector<int> c; int root, n; vector<int> dfs(int u) { vector<int> combine; for (int v : g[u]) { vector<int> child = dfs(v); for (int z : child) combine.emplace_back(z); } if (c[u] > combine.size()) { cout << ...
#include <bits/stdc++.h> using namespace std; const int nmax = 3e5 + 42; int n, m; struct edge { int u, v, c; }; edge inp[nmax]; edge make_edge(int u, int v, int c) { edge x; x.u = u; x.v = v; x.c = c; return x; } bool cmp(edge a, edge b) { return a.c < b.c; } int ans[nmax], ...
`timescale 1ns / 1ps // Documented Verilog UART // Copyright (C) 2010 Timothy Goddard () // Distributed under the MIT licence. // // 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 re...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1; i < 100000; i++) { n *= 3; m *= 2; if (n > m) { cout << i << endl; return 0; } } }
// // 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 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 Platform ( clk_clk, hex0_2_export, hex3_5_export, hps_io_hps_io_emac1_inst_TX_CLK, hps_io_hps_io_emac1_inst_TXD0, hps_io_hps_io_emac1_inst_TXD1, hps_io_hps_io_emac1_inst_TXD2, hps_io_hps_io_emac1_inst_TXD3, hps_io_hps_io_emac1_inst_RXD0, hps_io_hps_io_emac1_inst_MDIO, hps_io_hps_io_emac1_inst_MDC, h...
/* * 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 module ddr3_fb_t; // ins reg clk; parameter TCLK = 20; initial clk = 0; always #(TCLK/2) clk = ~clk; reg rst; wire mig_ready = 1'b1; reg [31:0] mig_rd_data; reg [6:0] mig_rd_count; wire [29:0] mig_cmd_byte_addr; wire [8:0] x_lcdc_fb; wire [6:0] y_lcdc_fb; wire in_hsync_lcdc_fb; wire in_vsync_l...
/* Copyright (c) 2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100001; const int MOD = 1e9 + 7; mt19937 rnd(100); int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, x; vector<vector<int> > a; cin >> n >> m; a.assign(n, vector<int>(m)); for (...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int ans[30][5] = { {1, 0, 0, 1, 0}, {1, 1, 0, 2, 0}, {2, 0, 0, 1, 1}, {2, 1, 0, 1, 2}, {1, 1, 0, 1, 1}, {2, 1, 0, 2, 1}, {2, 2, 0, 2, 2}, {1, 2, 0, 2, 1}, {1, 1, 0, 1, 1}, {1, 2, 0, 1, 2}, {1, 0, 1, 2, 0}, {1, 1, 1, 3, 0}, {2...
#include <bits/stdc++.h> using namespace std; void run_case() { string A, B, C, D; cin >> A; cin >> B; C = (A + B); sort(C.begin(), C.end()); cin >> D; sort(D.begin(), D.end()); if (C == D) cout << YES n ; else cout << NO n ; } int main() { ios_base::sync_wi...
//----------------------------------------------------------------- // AltOR32 // Alternative Lightweight OpenRisc // V2.0 // Ultra-Embedded.com // Copyright 2011 - 2013 // // Email: // // ...
#include <bits/stdc++.h> using namespace std; int n, w[1000999]; int arr[1009999]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &w[i]); arr[w[i]]++; } for (int i = 0; i < 1000099; i++) { arr[i + 1] += arr[i] / 2; arr[i] = arr[i] % 2; } i...
#include <bits/stdc++.h> using namespace std; void _R(int &x) { scanf( %d , &x); } void _R(long long &x) { scanf( %lld , &x); } void _R(double &x) { scanf( %lf , &x); } void _R(char &x) { scanf( %c , &x); } void _R(char *x) { scanf( %s , x); } void R() {} template <class T, class... U> void R(T &head...
#include <bits/stdc++.h> using namespace std; string A, B; bool is_divisor(const string &a, const string &b) { int sa = a.size(), sb = b.size(); for (int i = 0; i < sb; i += sa) { if (b.substr(i, sa) != a) return false; } return true; } int process(const string &a, const string &b) { ...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 1; int accept() { int b[N] = {0}; int d[N] = {0}; int n; cin >> n; int mx, check; for (int i = 0; i < n; i++) cin >> b[i]; sort(b, b + n); for (int i = 1; i < n; i++) { if (b[i] == b[i - 1]) { cout << ...
// ============================================================================ // Copyright (c) 2010 // ============================================================================ // // Permission: // // // // Disclaimer: // // This VHDL/Verilog or C/C++ source code is intended as a design reference ...
#include <bits/stdc++.h> using namespace std; const long long N = 400010; inline long long read() { long long s = 0, w = 1; register char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s <...
////////////////////////////////////////////////////////////////// // // // Wrapper for SRAM buffer module // // // // This file is part of the Amber project ...
//Legal Notice: (C)2013 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; std::vector<int> v[100005]; int dist[100005]; void dfs(int s, int par) { if (par != -1) dist[s] = dist[par] + 1; for (int i = 0; i < v[s].size(); i++) { if (par != v[s][i]) dfs(v[s][i], s); } } int main() { ios_base::sync_with_stdio(0); ...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, k; cin >> a >> b >> c >> k; if (k >= a + b + c - 3) { cout << a * b * c << endl; } else { long long res = 1; for (int x1 = 0; x1 < a; x1++) { long long help = (-k + x1) / (-2); for (int n ...
#include<iostream> #include<math.h> #include<bits/stdc++.h> #include <string> #include <vector> using namespace std; #define pi (2*acos(0.0)) #define ll long long int #define ull unsigned long long int #define lp(i , start , n) for(int i = start ; i < n; i++) int main(){ ios::sync_wi...
#include <bits/stdc++.h> using namespace std; int main() { int a[4]; for (int i = 0; i < 4; i++) cin >> a[i]; int sumtotal = a[0] + a[1] + a[2] + a[3]; if (sumtotal % 2 != 0) { cout << NO ; return 0; } for (int i = 0; i < 4; i++) { if (a[i] == sumtotal - a[i]) { co...
#include <bits/stdc++.h> using namespace std; vector<int> adj[202]; int height[202], best[202][3]; int N; int getHeight(int ind, int parent) { if (height[ind] != -1) return height[ind]; int ret = 1; for (int i = 0; i < (int)adj[ind].size(); i++) { if (adj[ind][i] == parent) continue; r...
// ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // // Revision Control Information // // $RCSfile: altera_tse_pcs.v,v $ // $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/RTL/Top_level_modules/altera_tse...
#include <bits/stdc++.h> using namespace std; const long long N = 201; const long long K = 201; const long long X = 201; long long dp[N][X]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, k, x; cin >> n >> k >> x; vector<long long> picBeaut...
#include <bits/stdc++.h> using namespace std; struct query { long long int l; long long int r; long long int i; }; query Q[200001]; long long int arr[200001]; long long int f[1000001]; long long int ans[200001]; long long int cnt; bool compare(query a, query b) { if ((a.l / 448) != (b....
// https://coredocs.s3.amazonaws.com/Libero/12_0_0/Tool/sf2_mlg.pdf module AND2 ( input A, B, output Y ); assign Y = A & B; endmodule module AND3 ( input A, B, C, output Y ); assign Y = A & B & C; endmodule module AND4 ( input A, B, C, D, output Y ); assign Y = A & B & C & D; endmodule module CFG1 ( outpu...
`timescale 1ns / 1ps `include "hal/WcaPortDefs.h" //grab register addresses. // Name: WcaPortController.v // // Copyright(c) 2013 Loctronix Corporation // http://www.loctronix.com // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public Licens...
/** * 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 double pi = acos(-1); const int INF = 1e9; const double inf = 1e15; const double eps = 1e-9; const long long MOD = 1e9 + 7; long long toNum(string s) { stringstream ss(s); long long ret; ss >> ret; return ret; } string toString(long l...
#include <bits/stdc++.h> using namespace std; const int N = 1004; int n, p, q, f[N][54][54], vc = 1000000000, ns[N][30], nt[N][30]; char c[N], s[N], t[N]; bool check1(int i, char x, int j) { if (i + 1 < j) return false; for (int k = 1; k < j; k++) { if (s[i + k - j + 1] != s[k]) return false; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; if (n % m == 0) cout << YES << endl; else cout << NO << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T-- > 0) { int N; cin >> N; struct MM { int min, max; }; MM data[129]; for (int i = 0; i <= 128; ++i) { if (i >= 63 && i < 63 + N) data[i] = {i - 62, i - 62}; ...
// The MLAB // -------- // In addition to Logic Array Blocks (LABs) that contain ten Adaptive Logic // Modules (ALMs, see alm_sim.v), the Cyclone V/10GX also contain // Memory/Logic Array Blocks (MLABs) that can act as either ten ALMs, or utilise // the memory the ALM uses to store the look-up table data for general us...
`include "alink_define.v" module alink_slave( // system clock and reset input clk , input rst , // wishbone interface signals input ALINK_CYC_I ,//NC input ALINK_STB_I , input ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long long int gcd(long long int a, long long int b) { if (!b) return a; else return gcd(b, a % b); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { i...
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265359; template <typename T> T abs(T x) { return x > 0 ? x : -x; } template <typename T> T sqr(T x) { return x * x; } const long long mod = 1000000007; struct matr { int maxn; int n; long long a[1 << 7][...
#include<iostream> using namespace std; int main() { int t; cin>>t; while(t--) { int Xa,Ya,Xb,Yb,Xf,Yf,sum; cin>>Xa>>Ya>>Xb>>Yb>>Xf>>Yf; sum=abs(Xa-Xb)+abs(Ya-Yb); if(Xa==Xb&&Xb==Xf) { if(Ya<Yf&&Yb>Yf||Ya>Yf&&Yb<Yf) sum+=2; ...
// Chuck Benz, Hollis, NH Copyright (c)2002 // // The information and description contained herein is the // property of Chuck Benz. // // Permission is granted for any reuse of this information // and description as long as this copyright notice is // preserved. Modifications may be made as long as this // notice i...
#include <bits/stdc++.h> using namespace std; int GEN_SIZE = 6; vector<int> v, adj[50005]; int match[50005], match2[50005], vis[50005], ans[50005]; int V, Vleft; int conv(vector<int> v, int s) { int ans = 0; for (int i = 0; i < v.size(); i++) { ans *= s; ans += v[i]; } return ans...
#include <bits/stdc++.h> using namespace std; int main() { long long n, a[100001]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; cout << 1 << << n << endl; cout << 0 << ; for (int i = 1; i < n; i++) cout << (n * (n - 1 - a[i])) << ; cout << endl; cout << 1 << << 1 ...
#include <bits/stdc++.h> const int mod = 1000000007; const int gmod = 3; const int inf = 1039074182; const double eps = 1e-9; const long long llinf = 2LL * inf * inf; template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) { if (b < x) x = b; } template <typename T1, typename T2> inli...
#include <bits/stdc++.h> using namespace std; using INT = long long; using pii = pair<int, int>; using pi3 = pair<int, pii>; int n, m; int nxt[100010]; int a[100010], b[100010]; set<pii> A, B; set<pi3> ans; int calc_max(int u, set<pair<int, int> > &st) { auto it = st.upper_bound({m - 1 - u, 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; const long double EPS = 1e-9; long double Dis(long long a, long long Y, long long b, long long YY) { return sqrt((long double)(b - a) * (b - a) + (Y - YY) * (Y - YY)); } struct PT { long long ID; long double len, Y; PT(long long _ID, long double _Y...
/** * 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 dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; double PI = 3.1415926535897932384626433832795; const long long oo = (long long)1e9 + 1; const double eps = 1e-9; const long long mod = 1000000007; string s; long long nb, ns, nc, pb, ps, pc, R; int main...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = (int)2 * 1e5 + 10; void solve() { long long n, m; cin >> n >> m; vector<long long> arr(n); for (long long i = 0; i < n; i += 1) { cin >> arr[i]; } sort((arr).begin(), (arr).end()); long long su...
#include <bits/stdc++.h> using namespace std; const int maxn = 5000 + 100; int x[maxn][maxn], p[maxn], tx[maxn]; int n; int ask(int i, int j) { cout << ? << i << << j << endl; int r; cin >> r; return r; } void answer(int k) { cout << ! << endl; cout << k << endl; for (...
Require Import Coq.Classes.RelationClasses. Require Import Coq.Reals.Rdefinitions. Require Import ExtLib.Structures.Applicative. Require Import ExtLib.Structures.Functor. Require Import ExtLib.Data.Fun. Require Import ExtLib.Tactics. Require Import ChargeCore.Logics.ILogic. Require Import ChargeCore.Logics.ILEmbed. Req...
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long N = 1e5 + 10; const long long INF = 1e9 + 7; vector<long long> fact(N), ifact(N); long long gcd(long long x, long long y) { if (y % x == 0) return x; return gcd(y % x, x); } long long inv(long long x) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, c, d, a, b, i; cin >> n >> a >> b; c = b, d = c; for (i = 2; i <= n; i++) { cin >> a >> b; c = max(c, d - a + b); d = d - a + b; } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int get_inv(int x) { return (x == 1) ? 1 : (mod - (long long)(mod / x) * get_inv(mod % x) % mod); } const int MaxN = 200010, MaxT = 1 << 19; struct tree_node { int k, sum; int lazy; tree_node() { k = lazy = 1; } } T[...
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846; void solve() { long long n, m, a, b, k, x, y, queries; string s; cin >> n >> s; s = G + s; long long i = 1; while (i <= n) { if (s[i] == 8 ) break; i++; } if (i + 10 <= n) c...
/******************************************************************************* * Module: resync_data * Date:2015-12-22 * Author: Andrey Filippov * Description: Resynchronize data between clock domains. No over/underruns * are checker, start with half FIFO full. Async reset sets * specifies output values regar...
/** * 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; vector<int> Neighbors[2000000]; bool Visited[2000000]; bool Leaf[2000000]; char Color[500001]; queue<int> Queue; void bfs(int i) { Visited[i] = true; Queue.push(i); while (Queue.empty() == false) { int u = Queue.front(); Queue.pop(); ...
`timescale 1ns/1ps module test(); reg clock, reset; sopc sopc( .clock(clock), .reset(reset) ); always #1 clock = ~clock; initial begin $dumpfile("dump.vcd"); $dumpvars; $dumpvars(0, sopc.cpu.register.storage[1]); $dumpvars(0, sopc.cpu.register.sto...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `include "std_ovl_defines.h" `module ovl_frame (clock, reset, enable, start_event, test_expr, fire); parameter severity_level = `OVL_SEVERITY_DEFAULT; parameter min_cks = 0; p...
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T& num) { bool start = false, neg = false; char c; num = 0; while ((c = getchar()) != EOF) { if (c == - ) start = neg = true; else if (c >= 0 && c <= 9 ) { start = true; num = ...
//Legal Notice: (C)2011 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; long long n = 0, k[10000001], a, b, c; void nhap() { cin >> a >> b >> c; } void solve() { k[n] = a + b + c; n++; k[n] = a * b * c; n++; k[n] = (a + b) * c; n++; k[n] = a * (b + c); n++; k[n] = a + b * c; n++; k[n] = a * b ...
#include <bits/stdc++.h> using namespace std; double dist(double x1, double y1, double x2, double y2) { double dx = x1 - x2; double dy = y1 - y2; return sqrt(dx * dx + dy * dy); } double catet(double a, int b) { double z = a * a - b * b; if (z < 1e-12) z = 0; return sqrt(z); } int ma...
#include <bits/stdc++.h> int main() { int i = 0, j = 0, l, k; char a[100], s[100], shift; scanf( %c , &shift); scanf( %s , a); l = strlen(a); for (k = 0; k < l; k++) { if (shift == R && i <= l && a[i] == w ) { a[i] = q ; i++; } else if (shift == R && i <= l &&...
/////////////////////////////////////////////////////////////////////////////// // // Module: hash_calculation.v // Project: ngnp // Description: calculates the 4 bit hash value // /////////////////////////////////////////////////////////////////////////////// `timescale 1ns/1ps module hash_calculation( input core...
#include <bits/stdc++.h> using namespace std; int n, a[4], leaf; vector<int> son[5140]; void no() { puts( NO ); exit(0); } void init() { scanf( %d , &n); for (int i = 0; i < 4; i++) scanf( %d , &a[i]); for (int i = 2; i <= n; i++) { int pi; scanf( %d , &pi); son[pi].pus...
//***************************************************-- // // COPYRIGHT (C) 2011, VIPcore Group, Fudan UniYVERsity // // THIS FILE MAY NOT BE MODIFIED OR REDISTRIBUTED WITHOUT THE ...
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 7; const int inf = 1e9 + 7; int T, n, dp[N][N], cnt[N], qzs[N][26], qzt[N][26]; char s[N], t[N]; void Min(int &x, int y) { if (x > y) x = y; } void Main() { fill(cnt, cnt + 26, 0); scanf( %d , &n); for (int i = 0, iE = n; ...
//Legal Notice: (C)2011 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated do...
//********************************************************************** // Reset // ______ _______ ______ _______ _______ // (_____ \(_______)/ _____|_______|_______) // _____) )_____ ( (____ _____ _ // | __ /| ___) \____ \| ___) | | // | | \ \| |_____ _____) ) |_____ | | // |_| |_|_______|____...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<vector<int>> g(n); for (int i = 0; i < n - 1; ++i) { int x, y; cin >> x >> y; --x; --y; g[x].push_back(y); g[y].push_back(x)...
#include <bits/stdc++.h> using namespace std; inline long long labs(long long a) { return a < 0 ? (-a) : a; } template <typename T> inline T sqr(T x) { return x * x; } void ImportMem(); string ToStr(int smpl, int sz) { ostringstream oss; oss << smpl; string test = oss.str(); while (tes...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long mdin(long long a, long long m) { long long r1 = m, r2 = a, t1 = 0, t2 = 1; while (r2 > 0) { long long q = r1 / r2; long long r = r1 % r2; r1 = r2; r2 = r; long long t = (t1 - q * t2) % m; t1 = t2; t2 = t; }...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21:57:50 08/25/2009 // Design Name: // Module Name: mcu_cmd // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: ...
#include <bits/stdc++.h> using namespace std; mt19937_64 rnd; const long long maxn = 1e6 + 10; const long long mod = 998244353; const long long base = 500; long long gt[maxn]; long long gtv[maxn]; long long mu(long long a, long long n) { if (n == 0) return 1; if (n == 1) return a; long long ...
/**************************************** Logic - Logic Calcration Circuit Make : 2011/01/20 Update : 2011/01/26 ****************************************/ `default_nettype none module logic_n #( parameter N = 32 ) ( //Control input [4:0] iCONTROL_CMD, //iDATA input [N-1:0] iDATA_0, input [N-...
#include <bits/stdc++.h> using namespace std; int n, a[200000]; bool st[200000][2]; long long memo[200000][2]; long long solve(int node, int rev) { if (node < 0 || node >= n) return 0; if (st[node][rev]) return 0x3f3f3f3f3f3f3f3fll; if (node == 0) return 0; long long& val = memo[node][rev]; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int i, arr[n]; for (i = 0; i < n; i++) cin >> arr[i]; int ap{0}, bp{n}, asize{arr[0]}, bsize{}, moves{1}, left = n - 1; bool a = 1; while (left != 0) { ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } const int N = 101000; int n, val[N];...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (k >= 2 * n) { cout << 0; return 0; } long long q = k / 2, z; if (k <= n) z = k - 1; else z = n; if (k & 1) { long long ans = min(q - 1, z - q - 1); ans++;...
`define ADDER_WIDTH 011 `define DUMMY_WIDTH 128 `define 2_LEVEL_ADDER module adder_tree_top ( clk, isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0, isum0_1_0_1, isum0_1_1_0, isum0_1_1_1, sum, ); input clk; input [`ADDER_WIDTH+0-1:0] isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0,...
#include <bits/stdc++.h> using namespace std; const int MAXPOW = 20; const int MAXA = 1048577; const int MAXN = 100009; const int MAXM = 100009; const int INF = 1e9 + 7; struct Node { Node(int val) : val(val) {} int val; }; struct MinIntervalTree { MinIntervalTree(int n, int val) { N...
module ps2 ( input Rx, input CLKOUT, output reg Rx_error, output [7:0] DATA, output reg DONE ); reg [8:0] regis; reg [7:0] regis0; reg [3:0] i; reg [3:0] j; //reg [1:0] k; reg init; //reg DoIt; //reg NoDoIt; //reg MakeIt=(DoIt && ~NoDoIt); initia...
#include <bits/stdc++.h> using namespace std; long long n, ans; long long f(long long x) { return 3 * x * (x + 1) / 2 - x; } int main() { ios_base::sync_with_stdio(false); cin >> n; ans = 0; for (long long i = 1; f(i) <= n; i++) { if ((n + i) % 3 == 0) { ans++; } } co...
#include <bits/stdc++.h> using namespace std; const int maxn = 300001; const int logn = 20; bool s[maxn][logn]; int nxt[maxn][logn]; int f[maxn][logn]; int a[maxn]; int tmp[maxn]; int n, q; int main() { scanf( %d%d , &n, &q); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a, b, i, c = 0; a = 8 * n; b = 9 * n; c = b - a; cout << b << << a << endl; }
//----------------------------------------------------------------- // // The original verilog code provided by Clifford E. Cummings, // Sunburst Design, Inc. // // Email: <> // Web: www.sunburst-design.com // //---------------------------------------------------------------- module small_async_fifo ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, tmp, ans = 0, mx = -1; cin >> n; for (int i = 0; i < n && cin >> tmp; ++i) mx = max(tmp, mx); cout << (mx > 25 ? mx - 25 : 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...