text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const char elem[][4] = { H , He , Li , Be , B , C , N , O , F , Ne , Na , Mg , Al , Si , P , S , Cl , Ar , K , Ca , Sc , Ti , V , Cr , Mn , Fe , Co , Ni , Cu , Zn , Ga , Ge , As , Se , Br , Kr ,...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; long long n, k, sum; long long a[maxn]; long long goal[maxn]; long long max(long long x, long long y) { return x > y ? x : y; } long long cntmx = -9e18, cntmn = 9e18; void solve3() { long long m = k; for (register int i = n;...
`timescale 1ns / 1ps `include "def.v" module MMU(clk, reqType, ofs, lbid, addr, invalid, lbidw, lbTypew, basew, countw, we); input clk; // input [5:0] reqType; input [15:0] ofs; input [11:0] lbid; // output [15:0] addr; output invalid; // input [11:0] lbidw; input [5:0] lbTypew; input [15:0] basew; inpu...
// ============================================================== // File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.4 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // ============================================================== `timescale 1 ns / 1 ...
//---------------------------------------------------------------------------- //-- Asynchronous serial receiver Unit //------------------------------------------ //-- (C) BQ. December 2015. Written by Juan Gonzalez (Obijuan) //-- GPL license //---------------------------------------------------------------------------...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; struct edge { int x, y, w, p; edge() {} void input() { scanf( %d%d%d%d , &x, &y, &w, &p); } } E[N], EE[N]; int n; vector<int> G[N]; long long W[N], WW[N]; void dfs(int x, int y, int id, int mi) { if (id) { int tmp...
#include <bits/stdc++.h> using namespace std; constexpr long long INF = 2e18; constexpr long long MOD = 1e9 + 7; constexpr long long MAXN = 2e5 + 3; void solve() { long long n; cin >> n; map<long long, long long> m; long long ans = 0; for (long long i = 1; i <= n; ++i) { long long x;...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long int mypow(long long int a, int b) { if (b < 0) return 0; long long int ans = 1; for (; b; b >>= 1, a = a * a % mod) { if (b & 1) ans = ans * a % mod; } return ans; } void add(long long int &a, long...
#include <bits/stdc++.h> using namespace std; void Freopen() { freopen( title .in , r , stdin); freopen( title .out , w , stdout); } int read() { int g = 0, f = 1; char ch = getchar(); while (ch < 0 || 9 < ch) { if (ch == - )...
// (C) 1992-2015 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulati...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2012, Ameer M. Abdelhadi; . All rights reserved. // // // // Redistribution and use in source and binary forms, with or with...
/** * 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 fifo_ctr ( clk, rst_n, push, pop, empty, almost_empty, full, almost_full, error, cen, wen, oen, addr ); output [4:0] addr; input clk, rst_n, push, pop; output empty, almost_empty, full, almost_full, error, cen, wen, oen; wire \state_next[0] , N31, N32, N33, N34, N36, N37, N38, N39, N41, N42, ...
/* * 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...
/* Legal Notice: (C)2007 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 assoc...
/* 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...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); long long n, d; cin >> n >> d; vector<long long> delta(n); vector<long long> rs(n); for (int i = 0; i < n; ++i) cin >> delta[i]; rs[0] = delta[0]; for (int i = 1; i < n; ++i) rs...
module top; reg pass; reg result; reg [3:0] expr; initial begin pass = 1'b1; result = $isunknown(1'b0); if (result != 0) begin $display("FAILED: for 1'b0 expected 0, got %b", result); pass = 1'b0; end result = $isunknown(1'b1); if (result != 0) begin $display("FAILED...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int max_length = 1e6; int a_cnt[max_length]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; long long b = 0; long long ans = 0; int n = s.size(); for (i...
#include <bits/stdc++.h> using namespace std; struct edge { int to, cost; }; vector<edge> G[500005]; int q, n, k; long long f[500005], g[500005]; vector<long long> weights[500005]; void add_edge(int u, int v, int cost) { G[u].push_back((edge){v, cost}); G[v].push_back((edge){u, cost}); } ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: nuny_new2.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 la...
#include <bits/stdc++.h> const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; using namespace std; int q, op, pos, r, x, len, l; char ch[10], str[maxn]; int tr[26][maxn]; int lowbit(int x) { return x & (-x); } void update(int x, int y, int n, int p) { fo...
#include <bits/stdc++.h> using namespace std; #define ll long long #define MOD (ll)1000000007 #define pii pair<int,int> #define pll pair<ll,ll> #define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end()); ll GCD(ll a,ll b){return b?GCD(b,a%b):a;} ll power(ll a,ll b){ll ret=1;whi...
#include <bits/stdc++.h> using namespace std; int a[2001]; int main() { int n, b, s = 0, m, s1, i; scanf( %d%d , &n, &b); for (i = 0; i < n; i++) scanf( %d , &a[i]); for (i = 0; i < n; i++) { if (i == n - 1) s1 = b; else { m = *max_element(a + i, a + n); s1 = (b...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, root; vector<int> adj[N]; int dp[N][2], deg[N]; bool mark[N]; void dfs(int u, int pre) { for (int v : adj[u]) { if (v == pre) continue; dfs(v, u); } for (int p = 0, _n = (2); p < _n; p++) { int d = (d...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: // Design Name: // Module Name: GeAr_N20_R5_P5_with_recovery // Project Name: // Target Devices: // Tool versions: // Description: // // Depend...
////////////////////////////////////////////////////////////////// //// //// //// CRCAHB CORE BLOCK //// //// //// //// This file is part of the APB to I2C project //// //// http://www.opencores.org/cores/apbi2c/ //// //// //// //// Description //// //// Implementation of APB IP core according to //// ...
/* * 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; template <class T, class L> bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T &x, L y) { return x > y ? (x = y, 1) : 0; } const int maxn = 15e3 + 17, maxk = 1e3 + 17, mod = 1e9 + 7, base = 1e7 + 19, ...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; const long long mod = 1e9 + 7; const long long inf = 1e18 + 10; long long n, L, k; string s, ans[N]; int ptr; void doIt(int l, int r) { if (l + 1 == r) { while (ans[l].size() < L) ans[l] += s[ptr], ptr++; return; }...
#include <bits/stdc++.h> using namespace std; const double pp = 0.00000001; const int maxn = 100005; double ans, xo, da, mid; int ci, w, i, n, x[maxn], y[maxn]; bool pd(double k) { double ww, l = -1e9, r = 1e9; int i; for (i = 1; i <= n; i++) { if (k * k < (y[i] - k) * (y[i] - k)) { ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:167177216 ) int main() { double y1, y2, yw, xa, ya, r; cin >> y1 >> y2 >> yw >> xa >> ya >> r; double ll = 0, rr = xa; yw -= r; double yt = y1 + r + 1e-9; for (int i = 0; i < 300; ++i) { double xm = (ll + r...
#include <bits/stdc++.h> using namespace std; vector<int> adjc[100005]; vector<int> cadj[100005]; struct edge { int u, v, c; }; class dsu { public: dsu(vector<int> vert) : vert(vert) { n = vert.size(); par.resize(n); iota(par.begin(), par.end(), 0); } int root(int u) { ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( O3 ) #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast,unroll-loops,no-stack-protector,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) const long long mod = 1e9 + 7; const lo...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int h[4] = {0, 0, 1, -1}; int v[4] = {1, -1, 0, 0}; vector<vector<int> > adj; bool *visited; int num[501][501]; bool done = false; int sourceR, sourceC, destR, destC; void DFS(int vertix) { if (!done) { visited[vertix] = true; for (int i = ...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2013 Altera Corporation, San Jose, California, USA. * ...
//------------------------------------------------------------------------------ // YF32 -- A small SOC implementation based on mlite (32-bit RISC CPU) // @Taiwan //------------------------------------------------------------------------------ // // ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) int main() { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); long long n, p, d, w; cin >> n >> p >> w >> d; for (register int y = (0); y <= (w); ++y) { long long x = (p - y * d) / w; if (x < 0) ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int q, n, i, j, k, t; long long int a[3]; cin >> t; long long int area[5]; while (t--) { long long int a, b, x, y; ...
// megafunction wizard: %Shift register (RAM-based)% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altshift_taps // ============================================================ // File Name: Line_Buffer.v // Megafunction Name(s): // altshift_taps // // Simulation Library Files(s): // altera_mf // =======...
#include <bits/stdc++.h> using namespace std; char cc[10] = RGBYW ; int d[5][5]; int cnt(int x) { int res = 0; while (x) { res += x & 1; x >>= 1; } return res; } int main() { int(n); scanf( %d , &n); for (int i = 0; i < (n); ++i) { char s[10]; scanf( %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...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( avx2 ) using namespace std; void solve() { int q; cin >> q; unordered_map<string, string> map; while (q--) { string a, b; cin >> a >> b; if (map.find(a) != map.end()) { string s = map[a]; ma...
//====================================================================== // // mkmif_core.v // ------------ // The actual core module for the Master Key Memory (MKM) interface. // The interface is implemented to use the Microchip 23K640 serial // sram as external storage. The core acts as a SPI Master for the // extern...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; bool compare(const pair<int, int>& i, const pair<int, int>& j) { return i.first < j.first; } int ncr(int n, int k) { if (n < k) return 0; int C[n + 1][k + 1]; int i, j; for (i = 0; i <= n; i++) { for (j = 0; j <= min(i, k); j++) { i...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) { int a, b, x, y; cin >> a >> b >> x >> y; cout << max(max(((a - 1) - x) * b, ((b - 1) - y) * a), max((x)*b, (y)*a)) << ...
// MBT 2/28/2015 // // This module computes gray(x+1), // where x is a binary value. // // It has not been determined whether this beats // synthesis of (x+1) ^ ((x+1) >> 1). Synopsys has some // killer adder implementations. // However, it has a good shot, since it uses // mostly ands and not xors. // /* Since x and...
#include <bits/stdc++.h> using namespace std; vector<pair<long long, pair<long long, long long>>> v; long long a, b, w, cnt; long long parent[100005], sz[100005]; void init(long long n) { for (long long i = 1; i <= n; i++) parent[i] = i, sz[i] = 1; } long long root(long long x) { if (parent[x] == ...
/* * 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) 2016 C-L-G.FPGA1988.lichangbeiju. All rights reserved----------------- // // -- It to be define -- // -- ...
#include <bits/stdc++.h> using namespace std; struct edge { int x, y, z, id; } e[200005]; vector<int> to[200005]; int fa[200005], f[200005][18], deep[200005], g[200005][18], id[200005], ans[200005]; bool flag[200005]; int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); } void dfs(in...
#include <bits/stdc++.h> using namespace std; inline bool ig(char c) { return c >= 0 && c <= 9 ; } inline void read(int &oi) { char c; int f = 1, res = 0; while (c = getchar(), (!ig(c)) && c != - ) ; c == - ? f = -1 : res = (c ^ 48); while (c = getchar(), ig(c)) res = res * 10 + (c...
#include <bits/stdc++.h> using namespace std; int v[1000005]; int main() { int n, m, i, first, second, lastdif = -0x3f3f3f3f; cin >> n; for (i = 1; i <= n; ++i) cin >> v[i]; for (i = 2; i <= n; ++i) { if (v[i] - v[i - 1] != lastdif && lastdif != -0x3f3f3f3f) { cout << v[n]; r...
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t; cin >> t; while (t--) { long long a, b, c; cin >> a >> b >> c; if (a < c) cout << 1; else cout << -1; cout << ; if (c < a * b) cout << b; else cout << ...
// *************************************************************************** // *************************************************************************** // Copyright 2013(c) Analog Devices, Inc. // Author: Lars-Peter Clausen <> // // All rights reserved. // // Redistribution and use in source and binary forms, ...
#include <bits/stdc++.h> using namespace std; int main() { int x, y; string s, t; cin >> x >> y >> s >> t; int arr[y - x + 1]; int mx = -1, res; for (int i = 0; i < y - x + 1; i++) { int k = i; arr[i] = 0; for (int j = 0; j < x; j++, k++) { if (t[k] == s[j]) arr[i] ...
`include "bsg_defines.v" `include "config_defs.v" module config_snooper (input clk, // destination side clock from pins input reset, // destination side reset from pins input config_s config_i, // from IO pads output [data_max_bits_lp - 1 : 0] id_o, output [data_max_bits_lp - 1 : 0] data_o ); ...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; if (str[0] > 4 && str[0] != 9 ) str[0] = (char)( 9 - str[0] + 0 ); for (int x = 1; x < (int)str.length(); x++) if (str[x] > 4 ) str[x] = (char)( 9 - str[x] + 0 ); cout << str << endl; return 0; ...
#include <bits/stdc++.h> using namespace std; const int Inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int qwq = 1 << 19; int N, Q; int a[qwq]; struct Query { int r1, c1, r2, c2, id; Query(int r1, int c1, int r2, int c2, int id) : r1(r1), c1(c1), r2(r2), c2(c2), id(id)...
//----------------------------------------------------------------------------- // // (c) Copyright 2010-2011 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 ...
/** * 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...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:42:11 01/30/2016 // Design Name: instruction_decode // Module Name: /home/poche002/Desktop/ArqComp/Trabajo_final/arquitectura_tpf/instruction_decode_tb.v // Projec...
`include "src/rom.v" `include "src/serializer.v" `include "src/transmitter.v" `include "src/receiver.v" `include "src/comparator.v" `include "src/iserdes_sdr_ddr_test.v" `default_nettype none // ============================================================================ module top ( input wire clk, input wire rx...
#include <bits/stdc++.h> using namespace std; const int N = 50 + 5; const int oo = 1000000000; bool u[N][N]; int n, m; int ans = -1; int a[N][N], l[N][N]; int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; char s[N]; struct pis { int x, y; pis() {} pis(int x, int y) : x(x), y(y) {} } f[...
#include <bits/stdc++.h> using namespace std; int n, tt[1005]; vector<int> a[1005]; void dfs(int u) { if (tt[u] == 1) { printf( %d , u); return; } tt[u] = 1; for (int i = 0; i < a[u].size(); ++i) dfs(a[u][i]); } int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5, mod = 1e9 + 7, inf = 1e18; long long n, q, a[maxn], mx[2ll][maxn]; pair<long long, long long> dp[2ll][maxn]; void cal_mx0(long long x) { long long l = n - 1ll, sum = a[n]; for (long long i = n; i > 0; i--) { if (l == 0...
#include <bits/stdc++.h> using namespace std; void in(long long int &number) { bool negative = false; register int c; number = 0; c = getchar(); if (c == - ) { negative = true; c = getchar(); } for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48; 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 law...
module memory(address,in,out,write,clk); input [7:0] in; input clk,write; input [14:0] address; output [7:0] out; reg [7:0] mem [0:255]; reg [14:0] addreg; always @(negedge clk) begin if(write ==1'b0) begin mem[address] <= in; addreg <= address; end end assign out = mem[addreg]; endmodule module mem16(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 law...
//////////////////////////////////////////////////////////////////////////////// // // Filename: wbdblpriarb.v // // Project: Zip CPU -- a small, lightweight, RISC CPU soft core // // Purpose: This should almost be identical to the priority arbiter, save // for a simple diffence: it allows the arbitration of two // s...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:66777216 ) using namespace std; static unsigned rnd() { static int second = 124612741; second ^= second << 13; second ^= second >> 17; return second ^= second << 5; } inline int fpow(int a, int st, int mod) { int ans = 1; while (...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, lim = 1e7 + 10, key = 1010; int v[lim], r[lim], d[lim]; int main() { int n, m, q; scanf( %d%d%d , &n, &m, &q); for (long long i = 1, _b = (n); i <= _b; i++) for (long long j = 1, _b = (m); j <= _b; j++) scanf( %d , v + key ...
#include <bits/stdc++.h> const long long N = 2e5 + 7; const long long M = 2e4 + 5; const double eps = 1e-8; const long long mod = 1e9 + 7; const long long inf = 0x7fffffff; const double pi = 3.1415926; using namespace std; vector<long long> v[N], num; long long n; long long dfs(long long x, long lon...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2009 Altera Corporation, San Jose, California, USA. ...
// Benchmark "mult4" written by ABC on Tue Jan 13 21:29:40 2015 module mult4 ( a0, a1, a2, a3, b0, b1, b2, b3, z0, z1, z2, z3, z4, z5, z6, z7 ); input a0, a1, a2, a3, b0, b1, b2, b3; output z0, z1, z2, z3, z4, z5, z6, z7; wire n18, n19, n20, n21, n23, n24, n25, n26, n27, n28, n29, n30, n31, n32, n...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, *a, *b, times, i, day; while (cin >> n >> m) { a = new int[m]; b = new int[m]; times = 1; for (i = 0; i < m; i++) cin >> a[i] >> b[i]; for (i = 0; i < m - 1; i++) { if (b[i] != a[i + 1] - 1) break; ...
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int mx = 2e5 + 9; int game[2][mx]; int f_occ[2][mx]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); x--; game[x][i]++; } memset(f_occ, -1, ...
#include <bits/stdc++.h> using namespace std; void addmod(int &a, long long b) { a = (a + b); if (a >= 1000000007) a -= 1000000007; } void mulmod(int &a, long long b) { a = (a * b) % 1000000007; } int gi() { int a; scanf( %d , &a); return a; } long long gll() { long long a; sca...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define vi vector<int> #define pi pair<int,int> #define F first #define S second #define pb push_back #define mp make_pair #define FOR for(int i=a;i<b;++i) #define sq(a) (a)*(a) #define vll vector<long lon...
#include <bits/stdc++.h> using namespace std; int n, m, k, ans, x, y, sum, res, day1, day2, moun1, moun2, year1, year2; bool l; char a[100]; string s, s1, s2; vector<int> v; int main() { cin >> n; if (!(n & 1)) { cout << -1; return 0; } for (int i = 0; i < n; i++) printf( %d ,...
#include <bits/stdc++.h> using namespace std; const int N = 200010; const int oo = 1e9; int xm, ym, zm, n, m, k, xmn, xmx, ymn, ymx, zmn, zmx; struct point { int x, y, z, idx; bool operator<(const point &rhs) const { return x < rhs.x; } void print() { cout << x << << y << << z << endl; } ...
#include <bits/stdc++.h> using namespace std; bool prime[1000009]; vector<long long> pri; void SieveOfEratosthenes() { memset(prime, true, sizeof(prime)); for (long long p = 2; p * p <= 1000000; p++) { if (prime[p] == true) { for (long long i = p * p; i <= 1000000; i += p) prime[i] = false...
#include <bits/stdc++.h> using namespace std; const int N = 100010; long long int A[N]; vector<int> g[N]; long long int dfs(int x, int p) { A[x] = 1; for (int i = 0; i < g[x].size(); ++i) { int y = g[x][i]; if (y == p) continue; A[x] += dfs(y, x); } return A[x]; } long do...
#include <bits/stdc++.h> using namespace std; void fr(int &a, bool f = 0, char ch = getchar()) { for (a = 0; ch < 0 || ch > 9 ; ch = getchar()) ch == - ? f = 1 : 0; for (; ch >= 0 && ch <= 9 ; ch = getchar()) a = a * 10 + ch - 0 ; a = f ? -a : a; } int fr() { int a; return fr(a), a;...
#include <bits/stdc++.h> using namespace std; const int N = 400005; vector<int> adj[N]; vector<int> st; int cTime = 1; int in[N]; int low[N]; vector<vector<int>> comps; map<array<int, 2>, int> edgeToI; array<int, 2> res[N]; int edgeToIndex(int a, int b) { return edgeToI[{min(a, b), max(a, b)}]; } ...
module prefab_alu_rf; parameter sim_time = 750*2; // Num of Cycles * 2 reg [31:0] Pcin; reg [19:0] RSLCT; reg Clk, RESET, LOADPC, LOAD,IR_CU; wire [31:0] Rn,Rm,Rs,PCout,in; //RegisterFile(input [31:0] in,Pcin,input [19:0] RSLCT,input Clk, RESET, LOADPC, LOAD,IR_CU, output [31:0] Rn,Rm,Rs,PCout); RegisterFile RF(in,P...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: sync_pulse_synchronizer.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...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; int a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < (int)n; i++) cin >> a[i], b[i + 1] += b[i] + a[i]; int t = 0; for (int i = 0; i < (int)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...
#include <bits/stdc++.h> using namespace std; int mostFrequent(int arr[], int n) { sort(arr, arr + n); int max_count = 1, res = arr[0], curr_count = 1; for (int i = 1; i < n; i++) { if (arr[i] == arr[i - 1]) curr_count++; else { if (curr_count > max_count) { max_cou...
//---------------------------------------------------------------------------- //-- Memoria ROM de 16 x 4 //------------------------------------------ //-- (C) BQ. October 2015. Written by Juan Gonzalez (Obijuan) //-- GPL license //---------------------------------------------------------------------------- //-- La mem...
#include <bits/stdc++.h> using namespace std; void action() { string s; cin >> s; reverse(s.begin(), s.end()); long long c = 0, f = 0, j; for (long long i = 0; i < s.length(); i++) { if (s[i] == 1 ) { f++; } if (i % 2 == 0) c++; } if (f > 1) cout << c; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int digit[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; string n; cin >> n; int a = digit[(n[1] - 48)]; int b = digit[(n[0] - 48)]; cout << a * b; return 0; }...