text
stringlengths
59
71.4k
#include <bits/stdc++.h> int S(int x) { return x & 1 ? -(x + 1) / 2 : x / 2; } int main() { int q; scanf( %d , &q); while (q--) { int l, r; scanf( %d%d , &l, &r); printf( %d n , S(r) - S(l - 1)); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c...
#include <bits/stdc++.h> using namespace std; bool vis[100005]; int main() { int n; while (cin >> n) { int i, tag = 0, num = 0; for (i = 5;; i += 5) { int x = i; while (x % 5 == 0 && x) { num++; x /= 5; } if (num == n) { tag = 1; ...
#include <bits/stdc++.h> using namespace std; string s; int n, i, j, k, mx = 0, sum = 0, vis[5005], letter[26], check[26][5005][26], ok; double ans = 0; int main() { cin >> s; n = s.length(); s = s + s; for (i = 0; i < n; i++) { letter[s[i] - a ]++; for (j = i; j < i + n; j++) { ...
#include <bits/stdc++.h> using namespace std; map<string, string> mp; string get_type(string s) { if (mp.count(s)) return mp[s]; int n = s.size(); if (s[0] == & && s[n - 1] == * ) return get_type(s.substr(1, n - 2)); if (s[0] == & ) { string ret = get_type(s.substr(1, n - 1)); int ...
#include <bits/stdc++.h> using namespace std; void read(long long &x) { x = 0; char c = getchar(); int f = 1; while (!(c >= 0 && c <= 9 )) { if (c == - ) f = -1; c = getchar(); } while ((c >= 0 && c <= 9 )) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); ...
// (C) 2001-2016 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 doc...
module LCD_TEST ( // Host Side iCLK,iRST_N, // LCD Side LCD_DATA,LCD_RW,LCD_EN,LCD_RS ); // Host Side input iCLK,iRST_N; // LCD Side output [7:0] LCD_DATA; output LCD_RW,LCD_EN,LCD_RS; // Internal Wires/Registers reg [5:0] LUT_INDEX; reg [8:0] LUT_DATA; reg [5:0] mLCD_ST; reg [17:0] mDLY...
// Copyright (C) 2020-2021 The SymbiFlow Authors. // // Use of this source code is governed by a ISC-style // license that can be found in the LICENSE file or at // https://opensource.org/licenses/ISC // // SPDX-License-Identifier:ISC module \$__QLF_FACTOR_BRAM36_TDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA,...
`timescale 1 ns / 1 ps module axis_variant # ( parameter integer AXIS_TDATA_WIDTH = 32 ) ( // System signals input wire aclk, input wire aresetn, input wire cfg_flag, input wire [AXIS_TDATA_WIDTH-1:0] cfg_data0, input wire [AXIS...
#include <bits/stdc++.h> using namespace std; const int maxn = 2710; const double eps = 1e-9; const double pi = 3.1415926536; int dp[maxn][maxn]; string s; int main(int argc, char const *argv[]) { dp[0][0] = 1; for (int i = 1; i <= 100; i++) { for (int j = 0; j <= (i - 1) * 26; j++) { ...
#include <bits/stdc++.h> using namespace std; int main() { long int var; scanf( %ld , &var); if (var >= 0) cout << var; else { int a, b; a = var % 10; var /= 10; b = var % 10; var /= 10; if (a > b) var = var * 10 + a; else var = var * 1...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 09:47:33 01/18/2017 // Design Name: // Module Name: right_barrel_shifter // Project Name: // Target Devices: // Tool versions: // Description: // // Depende...
//TODO: Allow burst size = 1 //TODO: Add timeout counter to clear out FIFO module wb_stream_reader_ctrl #(parameter WB_AW = 32, parameter WB_DW = 32, parameter FIFO_AW = 0, parameter MAX_BURST_LEN = 0) (//Stream data output input wb_clk_i, input wb_rst_i, output [WB_AW-1:0] wbm_adr_o...
// This module defines a simple implementation of the Digital Phase Lock Loop // (DPLL) described in Texas Instruments's SDLA005B application node module dpll (rst, clk_in, clk_ref, clk_out, clk_out_8x); input wire rst; input wire clk_in; input wire clk_ref; output wire clk_out; output wire clk_out_8x; reg [7:0] k_c...
#include <bits/stdc++.h> using namespace std; inline long long in() { int32_t x; scanf( %d , &x); return x; } inline string getStr() { char ch[1000000]; scanf( %s , ch); return ch; } const long long MOD = 1e9 + 7; const long long base = 29; const long long MAX_N = 3e5 + 1; inli...
// AGrises.v // This file was auto-generated as a prototype implementation of a module // created in component editor. It ties off all outputs to ground and // ignores all inputs. It needs to be edited to make it do something // useful. // // This file will not be automatically regenerated. You should check...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t--){ int n; cin >> n; if((n / 2020 > 0) && ((n % 2020) <= (n / 2020))){ cout << YES n ; }else{ cout << NO 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...
////////////////////////////////////////////////////////////////////- // Design unit: vm (All In One) // : // File name : vm.v // : // Description: RTL Design of Vending Machine // : // Limitations: None // : // System : Verilog // : // Author : 1. Wan Ahm...
//----------------------------------------------------------------------------- // // (c) Copyright 2009-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 ...
module alt_vipitc131_common_frame_counter #(parameter NUMBER_OF_COLOUR_PLANES = 0, COLOUR_PLANES_ARE_IN_PARALLEL = 0, LOG2_NUMBER_OF_COLOUR_PLANES = 0, CONVERT_SEQ_TO_PAR = 0, TOTALS_MINUS_ONE = 0) ( input wire rst, input wire clk, input wire sclr, //...
module SDRAM_test( input reset_n, // Module reset. inout [15:0] dram_dq, // SDRAM Data bus 16 Bits output [11:0] dram_addr, // SDRAM Address bus 12 Bits output dram_ldqm, // SDRAM Low-byte Data Mask output ...
#include <bits/stdc++.h> using namespace std; int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> string toString(T x) { ostringstream sout; sout << x; return sout.str(); } vector<string> form(string a, char s) { a += s; vector<st...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
// megafunction wizard: %RAM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: ram16x512.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ==============================...
#include <bits/stdc++.h> using namespace std; int mm[110][110]; int tmp[110][110]; void draw(int a, int b, int v) { for (int lx = 0; lx < a; lx++) for (int ly = 0; ly < b; ly++) tmp[lx][ly] += v; return; } void prt(int a, int b) { for (int lx = 0; lx < a; lx++) { for (int ly = 0; ly ...
/* * 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> int a[2005]; int n, k; int main() { scanf( %d , &k); k += 2; int len = 0; a[len++] = -1; int res; while (k > 1000000) { k++; a[len++] = 1000000; k -= 1000000; } a[len++] = k; printf( %d n , len); for (int i = 0; i < len; i++) print...
/** * 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() { ios_base::sync_with_stdio(false); cin.tie(nullptr); vector<bool> possible(1010); possible[0] = true; for (int i = 0; i < 1000; ++i) { if (!possible[i]) continue; else { possible[i + 3] = true; possible...
#include <bits/stdc++.h> using namespace std; vector<long long> adj[500005]; vector<pair<long long, long long>> vc[500005]; string s; bool ans[500005], hv[500005]; long long level[500005], sz[500005], heavy[500005], cnt[500005], col[500005]; void dfs(long long u, long long p, long long l = 1) { sz[u] ...
#include <bits/stdc++.h> using namespace std; int n, m, i, j, kol, tmp, flag[1000]; char s[1000][1000]; int main() { cin >> n >> m; for (i = 1; i <= n; i++) { cin >> s[i]; } for (j = 0; j < m; j++) { tmp = 0; for (i = 1; i <= n - 1; i++) if ((s[i][j] > s[i + 1][j]) && (...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N]; int sum[11]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); sum[a[i]]++; } while (1) { int i, aa[11]; memset(aa, 0, sizeof(aa)); for (i = 1; i < 1...
#include <bits/stdc++.h> using namespace std; set<long long> num; void f(int x, int a, int b, long long now) { if (x == 0) { num.insert(now); return; } if (a) f(x - 1, a - 1, b, now * 10 + 4); if (b) f(x - 1, a, b - 1, now * 10 + 7); } void init() { int i; for (i = 1; i <= ...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; int ans = n; for (int i = 0; i < n / 2; i++) { string temp1 = s.substr(0, i + 1); string temp2 = s.substr(i + 1, i + 1); if (temp1 == temp2) ans = min(ans, n - i); } co...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_SHARED_CODE integer i = 0; always @ (posedge clk) begin if (`OVL_RESET_SIGNAL != 1'b0) begin if (start_event == 1'b1) begin i <= num_cks; end else if (i ...
// Quartus Prime Verilog Template // Single port RAM with single read/write address and initial contents // specified with an initial block module phyIniCommand0_and #(parameter DATA_WIDTH=16, parameter ADDR_WIDTH=4) ( input [(DATA_WIDTH-1):0] data, input [(ADDR_WIDTH-1):0] addr, input we, clk, ...
//MODULE REFERENCE `define tenv_clock tenv_clock `define tenv_descstd_device tenv_descstd_device `define tenv_usbhost tenv_usbhost `define tenv_usbdev tenv_usbdev module tenv_test; //IFACE reg start=0; //LOCAL localparam block_name="tenv_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...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Mon Sep 16 05:33:22 2019 // Host : varun-laptop running 64-bit Service Pac...
#include <bits/stdc++.h> using namespace std; const int MAXN = 70 + 10; int n, dist[MAXN * MAXN * MAXN], u[3]; char arr[MAXN][MAXN]; int a[MAXN * MAXN * MAXN], b[MAXN * MAXN * MAXN]; struct node { int v[3] = {-1, -1, -1}; int A = -1, B = -1; node(int v1 = -1, int v2 = -1, int v3 = -1, int A_ = -...
#include <bits/stdc++.h> using namespace std; long long f[55][2][2], K, d; int a[55], n; long long C(int l, int r, int x, int y) { if (l > r) return 1; long long& F = f[l][x][y]; if (~F) return F; F = 0; for (int i = 0; i <= 1; ++i) for (int j = 0; j <= 1; ++j) if (a[l] - !i &&...
//reads ram and displays on vga monitor module vga_sram(CLOCK_PX ,rst,VGA_R, VGA_G, VGA_B,VGA_HS, VGA_VS,VGA_SYNC, VGA_BLANK,FB_ADDR,fb_data,we_nIN); input CLOCK_PX,rst; //reg [7:0]fb_data_reg; input we_nIN; input [7:0] fb_data; output VGA_BLANK, VGA_SYNC, VGA_HS, VGA_VS; output [7:0] VGA_R, VGA_G, VGA_B; output...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, ans; int a[105]; while (cin >> n >> m >> k) { ans = 1000000; for (int i = 0; i < n; i++) { cin >> a[i]; } m--; for (int i = 1; m - i >= 0; i++) { if (a[m - i] <= k && a[m - i]) { ...
#include <bits/stdc++.h> using namespace std; int main() { int x; string s1, s2; int cnt = 0; cin >> x >> ws; for (int i = x; i; i--) { cin >> s1; cin >> s2; if (s2.compare( soft ) == 0) cnt++; } if (x - cnt > cnt) cnt = x - cnt; for (int i = 0; i < 100; ++i) { ...
#include <bits/stdc++.h> using namespace std; char s[200010]; int n, m, head[200010], o = 0, x[2], id[200010], sz[200010], cnt = 0, tree[800010], tag[800010]; bool isnt_rt[200010]; vector<vector<int> > w; struct edge { int to, link; } e[200010]; struct seg { int x, l, r...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Wed May 7 21:01:31 2014 // Host : macbook running 64-bit Arch Linux // ...
//***************************************************************************** // (c) Copyright 2008 - 2012 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property /...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int M = 1e9 + 7; long long a[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a, b, x, y, z; cin >> a >> b >> x >> y >> z; cout << max(0ll, y - (a - 2 * x)) + max(0ll, ...
//----------------------------------------------------------------------------- // // (c) Copyright 2009-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 ...
#include <bits/stdc++.h> using namespace std; vector<int> ans; int n, r, fr[101][101]; int main() { cin >> n; for (int i = 0; i < n; i++) { scanf( %d , &r); for (int x, j = 0; j < r; j++) { scanf( %d , &x); fr[i][x]++; } } for (int i = 1; i <= 100; i++) { ...
#include <bits/stdc++.h> using namespace std; int n, m, x, y, u, v, a[1010], b[1010][1010]; vector<int> vv; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; ++i) { scanf( %d%d , &x, &y); a[y]++; b[x][y]++; } for (int i = 0; i < m; ++i) { scanf( %d%d , &x, &y); ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2016 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 // //...
/* 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...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 20:43:18 02/23/2016 // Design Name: DebugUnit // Module Name: C:/Users/Juanjo/Documents/Juanjo/Facu/Arquitectura/Trabajo Final/finalArquitectura/TestDatapathPart1/Pip...
//====================================================================== // // Design Name: PRESENT Block Cipher // Module Name: PRESENT_ENCRYPT_SBOX // Language: Verilog-2001 // // Description: Substitution Box (s-box) of Present Encryption // // Dependencies: none // // Designer: Saied H. Khayat // Date...
//---------------------------------------------------------------------------- // Copyright (C) 2009 , Olivier Girard // // 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 must re...
#include <bits/stdc++.h> using namespace std; vector<int> adj[300005]; int indeg[300005]; queue<int> q; int dp[300005][26], ma = 1; string s; int n, m, x, y, cnt = 0; bool co = 1; int main() { cin >> n >> m; cin >> s; for (int i = 0; i < m; i++) { cin >> x >> y; x--; y--;...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while ((t--)) { int n; cin >> n; int arr[n]; int diff[n - 1]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int ctr = 0; int m...
#include <bits/stdc++.h> const int MAXN = 210; const int mod = 1e9 + 7; void reduce(int& x) { x += x >> 31 & mod; } int mul(int x, int y) { return (long long)x * y % mod; } void fma(int& x, int y, int z) { x = ((long long)y * z + x) % mod; } struct vec { int x, y; vec() { x = y = 0; } vec(int a,...
#include <bits/stdc++.h> using namespace std; const int INF = 0x0FFFFFFF; const long long INFLL = 0x0FFFFFFFFFFFFFFFll; const int MAXN = 300005; int n, m, x, y; vector<int> g[MAXN]; int ans[MAXN]; int getenemies(int i) { int c = 0; for (size_t j = 0; j < g[i].size(); j++) if (ans[g[i][j]] ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 11; int a[N], b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a[i] >> b[i]; } vector<int> v; for (int p = 1; p <= 2...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long MOD2 = 998244353; double eps = 1e-12; using namespace std; template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << ( << p.first << , << p.second << ) ; } ...
/* * 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...
////////////////////////////////////////////////////////////////////// //// //// //// ROM //// //// //// //// Author(s): ...
`timescale 1ns / 1ps /*********************************************************************************************************************** * * * ANTIKERNEL v0.1 ...
#include <bits/stdc++.h> using namespace std; class Solution { int n, x[2]; vector<pair<long long, int>> A; public: void run() { cin >> n >> x[0] >> x[1]; for (int i = 0; i < n; ++i) { int c; cin >> c; A.emplace_back(c, i); } sort(A.begin(), A.end())...
#include <bits/stdc++.h> using namespace std; int N; vector<pair<int, int> > v; vector<int> query; int ans; struct SEG { SEG(int l, int r, int sum) : l(l), r(r), sum(sum) {} int l, r; int sum; }; vector<SEG> seg; void init(int idx, int s, int e) { if (s == e) return; seg[idx].l = s...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long int MXN = 1e18; struct node { double x, y; } p, p1, p2, p3, p4; double ji(node a, node b, node c) { return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y); } bool jug(node a) { if ((ji(p1, p2, a) * ji(...
#include <bits/stdc++.h> using namespace std; long long n, l, r, K, p; bool check(long long x) { long long t = K % (n + x); if (t == 0) t = n + x; if (t > min(p * 2, p + x)) return 0; if (t < p + max(0LL, x - n + p - 1)) return 0; return 1; } signed main() { scanf( %lld%lld%lld%lld , &...
/* Code for Setting up ADF4158 PLL Module By Hsiang-Yi Chung February, 2016 */ module PLL_ADF4158( input clk, input reset_n, output reg writeData, output reg loadEnable, output pll_clk ); localparam s0 = 2'b00; localparam s1 = 2'b01; localparam s2 = 2'b10; localparam s3 = 2'b11; localparam num_regis...
/* Bank of GPRs. */ module GpReg( clk, isRd1, isWr1, isQw1, idReg1, dataLo1, dataHi1, isRd2, isWr2, isQw2, idReg2, dataLo2, dataHi2, isRd3, isWr3, isQw3, idReg3, dataLo3, dataHi3 ); input clk; //clock input isRd1; //Is Read input isRd2; //Is Read input isRd3; //Is Read input isWr1; //Is...
/** * 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 1 ns / 1 ps module axis_level_cross # ( parameter integer AXIS_TDATA_WIDTH = 32, parameter integer CROSS_MASK = 8192, parameter ALWAYS_READY = "TRUE" ) ( // System signals input wire aclk, input wire aresetn, input wire signed[AXIS_TDATA_WIDTH-1...
(** * ImpCEvalFun: Evaluation Function for Imp *) (* $Date: 2013-07-01 18:48:47 -0400 (Mon, 01 Jul 2013) $ *) (* #################################### *) (** ** Evaluation Function *) Require Import Imp. (** Here's a first try at an evaluation function for commands, omitting [WHILE]. *) Fixpoint ceval_step1 (st...
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e5 + 5; const long long inf = 1e18; int n, k, nr, st[Nmax], A[Nmax], nextBigger[Nmax]; long long dp[Nmax], old[Nmax]; struct Ec { int a; long long b; long long operator()(int x) { return (long long)a * x + b; } }; Ec interv[Nmax...
/*------------------------------------------------------------------------------ * 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...
module \$reduce_or (A, Y); parameter A_SIGNED = 0; parameter A_WIDTH = 0; parameter Y_WIDTH = 0; input [A_WIDTH-1:0] A; output [Y_WIDTH-1:0] Y; function integer min; input integer a, b; begin if (a < b) min = a; else min ...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const long long INFL = 1e18 + 123; const double PI = atan2(0, -1); mt19937 tw(960172); long long rnd(long long x, long long y) { static uniform_int_distribution<long long> d; return d(tw) % (y - x + 1) + x; } const int MAXN =...
/** * 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...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int main() { int num, r; cin >> num >> r; vector<pair<int, int>> arr(num + 1); vector<bool> visited(r + 2, 0); for (int i = 1; i <= num; ++i) { cin >> arr[i].first >> arr[i].second; for (int j = arr[i].first; j <=...
// // Generated by Bluespec Compiler, version 2021.07 (build 4cac6eb) // // // Ports: // Name I/O size props // result_valid O 1 // result_value O 64 reg // CLK I 1 clock // RST_N I 1 reset //...
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000 + 7; const double EPS = 1e-9; int bit_count(int first) { return first == 0 ? 0 : 1 + bit_count(first & (first - 1)); } inline int low_bit(int first) { return first & -first; } inline int sign(double first) { return fi...
#include <bits/stdc++.h> using namespace std; using ll = long long; using db = long double; using str = string; using pi = pair<int, int>; template <class T> using V = vector<T>; template <class T, size_t SZ> using AR = array<T, SZ>; using vi = V<int>; using vb = V<bool>; using vpi = V<pi>; co...
/** * 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) 2008 Xilinx, Inc. All rights reserved. // // XILINX CONFIDENTIAL PROPERTY // This document contains proprietary information which is // protected by copyright. All rights are reserved. This notice ...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e13; void solve() { long long n; cin >> n; vector<pair<long long, long long> > a(n); for (long long i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); long long cnt = 1, a...
/* Copyright (c) 2021 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 N = 1e5 + 5; const int M = 1e5 + 5; long long mod_exp(long long cur, long long power) { long long res = 1; while (power > 0) { if (power % 2 == 0) { cur = (cur * cur) % 1000000007; } else { res = (res * cur) % 1000000007...
#include <bits/stdc++.h> using namespace std; struct node { int co, key; } num[1010]; int seven; char str[1010 * 100]; int init; bool cmp(node x, node y) { return x.co < y.co; } int main() { scanf( %d , &init); scanf( %s , str); seven = 1; int cnt = 1; int length = strlen(str); ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 10; const int MOD = 1e9 + 7; bool mark[N]; vector<int> ps, corporator[N]; int primeMul[N], primeCnt[N], nthPower[N], b[N], n, k; int _sum(int, int); int _mul(int, int); int _pow(int, int); void _push(int&, int); int main() { cin...
#include <bits/stdc++.h> using namespace std; long long n, x, k, lb, ub, ans = -1; void init() { long long l, r; scanf( %lld%lld%lld%lld , &n, &l, &r, &k); x = (r >= l ? r - l + 1 : r + n - l + 1) % n; } void solve() { for (long long i = k, j, r; i; i = j) { j = k / (k / i + 1); r ...
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, l; cin >> a >> b >> c >> l; long long int Total = (l + 1) * (l + 2) * (l + 3) / 6; for (long long int la = 0; la <= l; la++) { long long int mini = min(a - b - c + la, l - la); if (mini < 0) continue; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int logsize = 18; int n, m, q, rt = 1, t, sc, vis[100005], dfn[100005], low[100005], sid[100005], sz[100005], dep[100005], pr[100005][logsize], w[100005], mod = 1e9 + 7; stack<int> s; vector<int> g[100005], ng[100005]; int inl...
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 10; int n; int a[N], indexes[N], parent[N], rrank[N], ccount[N]; bool used[N]; int get_set(int v) { if (v == parent[v]) return v; return parent[v] = get_set(parent[v]); } void create_set(int v) { parent[v] = v; rrank[v]...
#include <bits/stdc++.h> using namespace std; long long num(string str) { long long out = 0; for (int i = 0; i < str.length(); i++) { out *= 26; out += str.at(i) - A + 1; } return out; } string pb26(long long n) { string reverse = ; while (n > 0) { int d = (n - 1) %...
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, m = 0, k = 0, arr[101], seg[100001][3]; long long sum = 0; cin >> n >> m >> k; for (int i = 0; i < m; i++) cin >> seg[i][0] >> seg[i][1] >> seg[i][2]; for (int i = 0; i < k; i++) cin >> arr[i]; for (int i = 0; i < k; i++) ...