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...
module LUT # (parameter SIZE=8) ( input wire [SIZE-1:0] A, input wire [1:0] B, output reg [SIZE+1:0] Result ); wire [SIZE+1:0] wD0, wD1, wD2, wD3; assign wD1 = {2'b0, A}; assign wD0 = wD1 ^ wD1; // Esto siempre es cero, de la longitud adecuada. assign wD2 = {1'b0, A, 1'b0}; assign wD3 = wD2 + wD1; always @ (A, B...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void ran() { srand(chrono::steady_clock::now().time_since_epoch().count()); } long long get_rand() { long long a = rand(); long long b = rand(); return a * (RAND_MAX...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:400000000 ) int n, t; int H; string s; int ok(int rest, int last) { int time = 0; for (int i = 0; i < (last + 1); i++) { time++; if (time > t) return 0; if (time + (last - i) * 2 <= t) return 1; if ...
/** * 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) 2019 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> int main() { int m, n, i, j, c; int coordenadas[3][2]; scanf( %d%d , &n, &m); char ciudad[n][m]; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { scanf( n%c , &ciudad[i][j]); } } c = 0; for (i = 0; i < n; i++) { for (j = 0; j < m; ...
#include <bits/stdc++.h> using namespace std; template <class A, class B> ostream& operator<<(ostream& o, pair<A, B>& p) { return o << ( << p.first << , << p.second << ) ; } template <class T> ostream& operator<<(ostream& o, const vector<T>& v) { o << { ; for (typeof((v).begin()) it = (v)...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:13:33 03/13/2014 // Design Name: // Module Name: alu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Rev...
/** * 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; string tostring(int x) { ostringstream o; o << x; return o.str(); } int toint(string s) { istringstream st(s); int i; st >> i; return i; } const int mod = 1e9 + 7; const int N = 1e6 + 10; const int inf = 2e9; const double eps = ...
/** * 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 n, m, ans; int num[1000010], flag[1000010]; int fa[1000010], vis[1000010]; int Find(int x) { return fa[x] = x == fa[x] ? x : Find(fa[x]); } void Union(int x, int y) { int fx = Find(x); int fy = Find(y); if (fx != fy) fa[fy] = fx; } int main()...
#include <bits/stdc++.h> using namespace std; const long long int N = 4e5 + 2, inf = 1e12 + 7; vector<pair<int, int> > vec[N]; pair<int, pair<int, int> > edg[N]; long long int n, dis[N], dis2[N], st[N], ed[N]; long long int T[2 * N], lzy[2 * N], tim; void dfs(int u, int pr) { st[u] = ++tim; for (a...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); f...
//////////////////////////////////////////////////////////////////////////////// // // // CDC (clock domain crossing) general purpose FIFO with gray counter // // ...
#include <bits/stdc++.h> using namespace std; int parent[100000], Size[100000]; void init(int n) { for (int i = 0; i < n; i++) { parent[i] = i; Size[i] = 1; } } int Find(int u) { if (u != parent[u]) parent[u] = Find(parent[u]); return parent[u]; } void Union(int u, int v) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> g[n + 1]; for (int i = 0; i < n - 1; ++i) { int a, b; cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } vector<vector<...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int a[n]; int b[n]; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == a ) { a[i] = 1; b[i] = 0; } else { a[i] = 0; b[i] = 1; } if (i) { ...
/* * Zet processor top level file * Copyright (c) 2008-2010 Zeus Gomez Marmolejo <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; ei...
#include<iostream> #include<string> using namespace std; int main() { int t; cin>>t; for(int i=0;i<t;i++) { int n; string r,b; cin>>n; cin>>r>>b; int counter1=0,counter2=0; for(int i=0;i<n;i++) { if(r[i]>b[i]) counter1++; else if(r[i]<b[i]) counter2...
#include <bits/stdc++.h> int main() { int vladik, valera; std::cin >> vladik >> valera; int vladik_rounds = sqrt(vladik); int valera_rounds = valera > vladik_rounds ? sqrt(valera - vladik_rounds) : 0; if (valera_rounds >= vladik_rounds) { std::cout << Vladik n ; } else { std::cout...
#include <bits/stdc++.h> using std ::vector; template <typename T> T max(T x, T y) { return (x > y) ? x : y; } template <typename T> T min(T x, T y) { return (x < y) ? x : y; } template <typename T> bool chkmax(T &x, T y) { return (x >= y) ? 0 : (x = y, 1); } template <typename T> bo...
#include <bits/stdc++.h> using namespace std; const int N = 1005; char a[N], b[N]; int lcp[N][N]; int f[N][N][12]; int main() { int l1, l2, n; scanf( %d%d%d , &l1, &l2, &n); scanf( %s%s , a + 1, b + 1); for (int i = (1); i <= (l1); i++) { for (int j = (1); j <= (l2); j++) { if ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf( %d%d , &n, &k); if ((n * (n - 1)) / 2 < k * n) { printf( -1 n ); return 0; } printf( %d n , n * k); for (int i = 0; i < n; ++i) { for (int j = i + 1, q = 0; q < k; ++q, ++j) { if (j == n) j ...
`timescale 1 us / 1 us `include "../source/RAM2.v" module testRAM; reg[15:0] addr; reg clk; reg rst; reg we; reg re; reg[15:0] wdata; wire[15:0] rdata; wire ready; RAM2 mem ( .rst (rst), .clk (clk), .we (we), .re (re), .addr (addr), .wdata (wdata), .rdata (rdata), .ready (ready) ...
/* Copyright (c) 2014-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, distri...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
// // Author: Steffen Reith () // // Creation Date: Sat May 6 16:32:24 GMT+2 2017 // Module Name: Board_Nexys4 - Behavioral // Project Name: J1Sc - A simple J1 implementation in Scala using Spinal HDL // // module Board_Nexys4 (nreset, clk100Mhz, extInt, ...
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y >= 1) { if (y % 2) res = (res * x) % p; x = ((x % p) * (x % p)) % p; y /= 2; } return res; } void solve() { ...
// megafunction wizard: %LPM_COUNTER% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_COUNTER // ============================================================ // File Name: cnt_64bit.v // Megafunction Name(s): // LPM_COUNTER // // Simulation Library Files(s): // lpm // ==================================...
#include <bits/stdc++.h> using namespace std; int main() { int n, h, a; vector<int> home, away; cin >> n; vector<int> cnt(100000, 0); vector<int> ans_home(n, 0); vector<int> ans_away(n, 0); for (int i = 0; i < n; i++) { cin >> h >> a; home.push_back(h); away.push_back(a...
#include <bits/stdc++.h> using namespace std; int o[100100]; int ans[6000100]; int main() { int i, j, n; int e = 0; long long x, y; long long m, tmp, st, ed, mid; scanf( %d %I64d , &n, &m); for (i = 1; i <= n; i++) scanf( %d , &o[i]); sort(o + 1, o + n + 1); o[0] = 0; o[n + 1...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } const int mod = 1e9 + 7; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) if (b & 1) { ...
#include <bits/stdc++.h> using namespace std; namespace { void Solve(int) { const set<string> bins = { AND , OR , XOR }; int n; cin >> n; vector<string> type(n); vector<int> lef(n, -1), rig(n, -1); for (int i = 0, __i = n; i < __i; ++i) { cin >> type[i] >> lef[i]; if (type[i]...
#include <bits/stdc++.h> using namespace std; vector<int> con[100005]; int coun[100005]; void serc(int x, int l) { coun[l]++; for (int i = 0; i < con[x].size(); i++) { serc(con[x][i], l + 1); } return; } int main() { int n; cin >> n; int a; for (int i = 2; i <= n; i++) ...
#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> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,s...
/** * 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...
/* * 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 ...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Ultra(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Sun Nov 20 02:51:02 2016 ///////////////////////////////////////////////////////////// module GDA_St_N16_M4_P8 ( in1, in2, res ); input [15:0] in1; input...
#include <bits/stdc++.h> using namespace std; int M = 1000000007; long long n, m; void solve() {} void test() { long long n; cin >> n; vector<int> a(n); int count[101] = { 0, }; for (long long i = 0; i < n; i++) { cin >> a[i]; count[a[i]]++; } bool flag = 1;...
#include <bits/stdc++.h> using namespace std; int main() { int a, t, f, k, y = 0, w, j = 0, x = 0; cin >> a >> t >> f >> k; w = t; for (;;) { if (x == 0) { if (j % 2 == 1) j++; if (j == k) break; if (w >= f) { x = f; w -= f; } else { ...
module main; reg clk, rst, done; wire [31:0] x; reg [3:0] a; reg [23:0] in, out; reg [2:0] a_fifo_cam_indices[3:0], lt_fifo_cam_indices[3:0]; // Debug signals to see 'em under signalscan // -- iverilog generates a warning here wire [2:0] db0_a_fifo_cam_indices = a_fifo_cam_indices[0]; //...
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; const int N = (int)2e5 + 7; const int MOD = (int)1e9 + 7; const int INF = (int)2e7; const long long BIG = 1e18; int a[N], b[N], c[N], d[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout....
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i; cin >> n; long long int a[n]; for (i = 0; i < n; i = i + 1) { cin >> a[i]; } long long int mn = a[n - 1]; long long int m[n]; for (i = n - 1; i >= 0; i--) { mn = min(mn, a[i]); m[i] = mn;...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2012 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk, model ); /*verilator no_inline_module*/ // So we'll get...
#include <bits/stdc++.h> using namespace std; int power(int x, int y, int p) { int res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } int main() { { ios_base::sync_with_stdio(0...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int n; int arr1[10]; int arr2[100005]; pair<int, int> diffs[600005]; int cnts[100005]; int main() { while (scanf( %d , arr1) == 1) { for (int i = 1; i < 6; ++i) { scanf( %d , arr1 + i); } scanf( %d , ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, k, l[N], r[N], f[2][N], q[N]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= k; ++i) scanf( %d%d , &l[i], &r[i]); f[0][0] = 0; for (int i = 1; i <= (n << 1); ++i) f[0][i] = 0x3f3f3f3f; for (int i = 1; i <=...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\Debounce_B.v // Created: 2014-09-08 14:12:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------------- // ---------------------------...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////////////// // Company: Digilent Inc. // Engineer: Andrew Skreen // // Create Date: 07/11/2012 // Module Name: spi_interface // Project Name: PmodGYRO_Demo // Target Devices: Nexys3 // Tool versions: ISE 14.1 /...
#include <bits/stdc++.h> long long f[2005][2005]; long long k[2005][2005]; long long C[4005][4005]; int main() { int n, m; scanf( %d %d , &n, &m); for (register int i = 0; i <= n; ++i) for (register int j = 0; j <= m; ++j) { if (i == 0) k[i][j] = 1; else if (j == 0) ...
#include <bits/stdc++.h> using namespace std; int main() { int n; double arr[105]; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %lf , &arr[i]); sort(arr, arr + n); reverse(arr, arr + n); double Max = 0; double prev = 0, a = 0, b = 1; for (int i = 0; i < n; i++) { a =...
#include <bits/stdc++.h> using namespace std; struct ms { string s; int id; }; bool operator<(const ms &a, const ms &b) { return a.s < b.s; } vector<ms> sv, msv[11]; string s; int n, lenmin = 11, lenmax = 0; bool used[10000] = {false}; int main(void) { int i; cin >> n; sv.reserve(n...
/* * PC speaker module without any codec * Copyright (C) 2010 Zeus Gomez Marmolejo <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; ...
#include <bits/stdc++.h> const int N = 200200; using namespace std; int n, k, s, t; int c[N]; int v[N]; vector<int> g; bool f(int x) { long long cnt = s + s; for (int i = 0; i + 1 < g.size(); i++) { if (g[i + 1] - g[i] > x) return false; int l = x - (g[i + 1] - g[i]); cnt -= min(...
/** * 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 l[10100]; int r[10100]; int per[100100]; int pr(int x) { if (x == per[x]) return x; return per[x] = pr(per[x]); } int main() { ios::sync_with_stdio(0); int n; cin >> n; int t = 0; for (int i = 1; i <= n; i++) { per[i] = i;...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; const long long inf = 1e18; int d, n, m, x[N], p[N], cur, r[N]; long long ans = inf, carry; pair<int, int> a[N]; int main() { ios_base::sync_with_stdio(0); cin >> d >> n >> m; for (int i = 1; i <= m...
(** * Extraction: Extracting OCaml from Coq *) (* ################################################################# *) (** * Basic Extraction *) (** In its simplest form, extracting an efficient program from one written in Coq is completely straightforward. First we say what language we want to extract into....
// ----------------------------------------------------------------------------- // (c) Copyright 2010 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...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 3; int n, m, i, j, k, l, r, s, t, d, u, ii, jj, x, y, z, lz[4 * N], h[N]; char c[100]; pair<pair<int, int>, pair<int, int> > first[4 * N]; void init(int root, int bas, int son) { if (bas == son) { if (h[bas] == 4) first[root...
#include <bits/stdc++.h> using namespace std; namespace solve { long long int a[200007], sum[200007], dpDown[200007], dpUp[200007]; vector<int> graph[200007]; void rec(int u, int p) { sum[u] = a[u]; for (int v : graph[u]) { if (v == p) continue; rec(v, u); dpDown[u] += dpDown[v] + su...
#include <bits/stdc++.h> using namespace std; int ans = 1e9; int f[1000010]; int main() { int n, i, j; scanf( %d , &n); for (i = 2; i <= n; i++) { if (!f[i]) { for (j = 2 * i; j <= n; j += i) { f[j] = i; } } f[i] = i - f[i] + 1; } for (i = f[n]; i ...
#include <bits/stdc++.h> using namespace std; int n, m; char s[4][12]; char t[12][25][12]; int num[12]; int main() { int i, j; int ans = 0, p = 0; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %s , s[i]); scanf( %d , &m); for (i = 0; i < m; i++) { scanf( %d , &num[i]); ...
module EX_MEM(input clk, input reset, input [1:0] WB_in, input [1:0] M_in, input [31:0] ALU_in, input [4:0] instruction_mux_in, input [31:0] RDdata2_in, input hold_i, output reg MemWrite, output reg MemRead, ...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's IC FSM //// //// //// //// This file is part of the OpenR...
#include <bits/stdc++.h> using namespace std; int a[100005], f[100005]; int main() { int n, i; long long k; map<int, int> cnt; scanf( %d , &n); cin >> k; k--; for (i = 0; i < n; ++i) scanf( %d , &a[i]), cnt[a[i]]++; sort(a, a + n); f[0] = 0; for (i = 1; i < n; ++i) f[i] = a...
#include <bits/stdc++.h> using namespace std; int main() { int n, q = 0, s = 0, t = 0; cin >> n; for (int k = 1; k <= n; k++) { cin >> q; if (q == 1) { if (t == 1) s++; else { t++; s++; } } else { if (t == 1) { t--...
/** * 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) 1995/2009 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 11....
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time uni...
#include <bits/stdc++.h> using namespace std; const int mm = 1e6 + 1; const int mx = 1 << 20; const int N = 3e5 + 10; int a[N], b[N]; int seg_t[mx * 2 + 10], tag[mx * 2 + 10]; void up(int o) { seg_t[o] = max(seg_t[o << 1], seg_t[o << 1 | 1]); } void down(int o) { if (tag[o] == 0) { return; ...
#include <bits/stdc++.h> const int MAX_N = 1e5 + 1; const long long int MOD = 1e9 + 7; const long long int INF = 1e9; using namespace std; void solve() { int n, max = 0, idx; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; if (v[i] > max) { max = v[i]...
`timescale 1ns / 1ps `include "Defintions.v" `define LOOP1 8'd8 `define LOOP2 8'd5 module ROM ( input wire[15:0] iAddress, output reg [27:0] oInstruction ); always @ ( iAddress ) begin case (iAddress) 0: oInstruction = { `NOP ,24'd4009 }; 1: oInstruction = { `STO , `R7,16'b0001 }; 2: o...
#include <bits/stdc++.h> using namespace std; int i, j, n; void solve() { int n; long long l; cin >> n >> l; long long a[n]; for (i = 0; i < n; i++) cin >> a[i]; ; sort(a, a + n); long long m = 2 * max(a[0], l - a[n - 1]); for (i = 0; i < n - 1; i++) { m = max(m, a[i + 1]...
/////////////////////////////////////////////////////////////////////////////// // // Project: Aurora Module Generator version 2.8 // // Date: $Date: 2007/09/28 12:50:34 $ // Tag: $Name: i+HEAD+134158 $ // File: $RCSfile: aurora_lane_gtp.ejava,v $ // Rev: $Revision: 1.2 $ // ...
#include <bits/stdc++.h> using namespace std; void solve() { int x{}; cin >> x; if (x % 3 == 0 || x % 7 == 0) { cout << YES << endl; return; } int ms{x / 3}; int ml{x / 7}; for (int i{0}; i <= ms; ++i) { for (int j{0}; j <= ml; ++j) { int chunks{3 * i + 7 * j}...
#include <bits/stdc++.h> using namespace std; const long long mxN = 52; vector<long long> adj[mxN]; signed main() { long long n; cin >> n; long long x = (n * (n - 1)) / 2; long long a[x - 1][2]; for (long long i = 0; i < x - 1; i++) { cin >> a[i][0] >> a[i][1]; adj[a[i][0]].push_...
(** * Episode 03: Lists *) (** This command asks Coq to infer ``easy'' type arguments. *) Set Implicit Arguments. (** As a result of running [Set Implicit Arguments], sometimes we will apply functions or constructors to fewer arguments than they are defined to take. When you see that, it simply indicates that Coq was...
#include <bits/stdc++.h> using namespace std; int a[100009]; int b[100009]; int main() { int n; cin >> n; map<int, int> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } for (int j = 0; j < n; j++) { cin >> b[j]; mp[b[j]]++; } int c = 0; for...
#include <bits/stdc++.h> using namespace std; bool containsr(int x21, int y21, int x22, int y22, int x11, int y11, int x12, int y12) { return x21 >= x11 && y21 >= y11 && x22 <= x12 && y22 <= y12; } int main() { int n; cin >> n; int found = 0; int x11 = -1, y11 = -1, x12 = -1...
`timescale 1ns/1ns // This assumes the DUT to has 1 master and 1 slave AXI IF. // // e.g. // @AxiMaster() // var M.a int[16] // // @AxiSlave() // var M.b int[16] // // @ThreadEntry() // def M.t() { ... } // // M.compile() // M.writeHdl("/tmp/a.v") module axi_tb; reg clk, rst; wire [31:0] ARADDR; wire ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long f[15], all[15]; long long n, k; int solve(int rem) { if (!rem) return 1; return solve(rem - 1) * 2; } long long solve(int i, string& str) { if (i == str.size()) return 1; long long ret = solve(i + 1, str); i...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int suma = 0, ans = 0, count = 0; for (int i = n - 1; i >= 0; i--) { if (suma + arr[i] <= k) suma = suma + arr[i]; ...
module fast_clock_domain( input clk, input rst, input [15:0] probe, output [15:0] sample_data, output sample_data_avail, input overflow, input acq_enable, input [7:0] clock_divisor, input [15:0] channel_enable, output stalled ); wire sample_tick; reg stalled_d, stalled_q;...
module memory_tb(); reg clk; reg rst; reg[3:0] rd_en, wr_en; reg[6:0] input_tag; reg[63:0] wr_mask; reg[2047:0] addresses; reg[8191:0] wr_data; wire ack; wire[6:0] output_tag; wire[2047:0] tracemon_addr; wire[8191:0] rd_data, tracemon_store_data; memory mem( rd_en, wr_en, addres...
#include <bits/stdc++.h> using namespace std; template <typename tp> inline void read(tp& x) { x = 0; char tmp; bool key = 0; for (tmp = getchar(); !isdigit(tmp); tmp = getchar()) key = (tmp == - ); for (; isdigit(tmp); tmp = getchar()) x = (x << 3) + (x << 1) + (tmp ^ 0 ); if (key) x = ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000; const int dx[4] = {1, 1, -1, -1}; const int dy[4] = {1, -1, -1, 1}; int n, m; int t[MAXN + 2][MAXN + 2]; int dp[4][MAXN + 2][MAXN + 2]; int sol; int main() { ios::sync_with_stdio(0); cin >> n >> m; for (int i = 1; i <= n;...
#include <bits/stdc++.h> using namespace std; const int N = 305000; const int INF = 105000; int main() { long long n, k; cin >> n >> k; long long g = (n / 2) / (k + 1); long long d = g * k; long long ost = n - d - g; cout << g << << d << << ost; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, cnt11 = 0, cnt12 = 0, cnt13 = 0, cnt14 = 0, cnt15 = 0, cnt16 = 0, cnt17 = 0, cnt18 = 0, cnt19 = 0; int cnt21 = 0, cnt22 = 0, cnt23 = 0, cnt24 = 0, cnt25 = 0, cnt26 = 0, cnt27 = 0, cnt28 = 0, cnt29 = 0; cin >> 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 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...
// megafunction wizard: %ALTLVDS% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altlvds_rx // ============================================================ // File Name: altera_tse_pma_lvds_rx.v // Megafunction Name(s): // altlvds_rx // // Simulation Library Files(s): // altera_mf // =========...
#include <bits/stdc++.h> using namespace std; int f[100005], b[100005], fn[100005], bn[100005], fm, bm; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %d , f + i); ++fn[f[i]]; fm = max(fm, f[i]); } for (int i = 0; i < m; ++i) { scanf(...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int i = -1, j = -1, k = -1, a[n]; for (int l = 0; l < n; l++) { cin >> a[l]; } for (int l = 1; l < n - 1; l++) { j = l; for (int m = j - ...
#include <bits/stdc++.h> using namespace std; const int MAXM = 500005; const int MAXN = 15; const int N = 12; int w[MAXN]; char query[MAXN]; char s[MAXN]; int n, m, q; int transform(char* s) { int ans = 0; for (int i = 0; i < n; i++) { ans = 2 * ans + (s[i] - 0 ); } return ans; ...
#include <bits/stdc++.h> using namespace std; const int up = 1e6 + 6; int n, m, k, pos; int cost[up], p[up], last[up]; int main() { scanf( %d , &n); scanf( %d , &m); scanf( %d , &k); for (int i = 1; i <= m; i++) { scanf( %d , &pos); p[pos] = 1; } if (p[0]) { printf( %...
/*+-------------------------------------------------------------------------- Copyright (c) 2015, Microsoft Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code ...