text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 9; int a[N], n; double ans(double x) { double arr[N]; for (int i = 0; i < n; i++) arr[i] = a[i] - x; double neg = 0; double pos = 0; double ans = 0; for (int i = 0; i < n; i++) { if (neg > 0) neg = 0; if (pos <...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
// annotshy #include <bits/stdc++.h> #define Task CF #define pb push_back #define MOD 1000000007 #define F first #define S second #define int long long using namespace std; const int maxn = 2005; int n, m, w; int a[maxn][maxn]; int dx[5] = {1, 0, -1, 0}; int dy[5] = {0, 1, 0, -1}...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2015 *) (* \VV/ **************************************************************) (* // * Th...
module interrupt_controller ( input wire iClock, input wire iReset, input wire iMcuWe, input wire [3:0] iMcuRegSelect, //control register select comes from cpu input wire [7:0] iMcuWriteData, //what does the cpu want to write output wire[7:0] oInterruptEnableRegister, output wire[7:0] oI...
/** * bsg_wormhole_router_adapter_out.v * * packet = {payload, length, cord} */ `include "bsg_defines.v" `include "bsg_noc_links.vh" `include "bsg_wormhole_router.vh" module bsg_wormhole_router_adapter_out #(parameter `BSG_INV_PARAM(max_payload_width_p ) , parameter `BSG_INV_PARAM(len_width_p ) ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long m = 0, a = 1, b = 1, ans = 0; while (m <= n) { m = a + b; a = b; b = m; ans++; } cout << ans - 1; return 0; }
//***************************************************************************** // (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 maxN = 2e5 + 7; int N, M, head[maxN], cnt; struct Eddge { int nex, to, id; Eddge(int a = -1, int b = 0, int c = 0) : nex(a), to(b), id(c) {} } edge[maxN << 1]; inline void addEddge(int u, int v, int id) { edge[cnt] = Eddge(head[u], v, id); ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2019 by Driss Hafdi. // SPDX-License-Identifier: CC0-1.0 `begin_keywords "VAMS-2.3" module t (/*AUTOARG*/); // Just get errors on bad keywords (for code coverage) int above; ...
/* * Copyright (c) 2008 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; either version 3, or (at your option) an...
#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; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } long long gcd(long...
/* Text Mode Memory Screen Memory is 16kB, and is organized into 128-bit cells. Also has a 2kB fixed font. */ module ModTxtMemW(clock, reset, pixCellIx, cellData, fontGlyph, fontData, busAddr, busData, busOE, busWR, busOK); /* verilator lint_off UNUSED */ input clock; input reset; input[13:0] pixCellIx; outpu...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 1, INF = 1e17, MOD = 1e9 + 7; long long n; string s, t = UDRL ; map<char, long long> m; int32_t main() { ios_base::sync_with_stdio(0); cin >> n >> s; for (long long i = 0; i < n; ++i) { m[s[i]]++; } cout <<...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int mx = 0; for (int i = 0; i < n; i++) { cin >> a[i]; mx = max(a[i], mx); } int cnt = 0; int maxcnt = 0; for (int i = 0; i < n; i++) { if (a[i] == mx) cnt++; els...
`timescale 1ns / 1ps module UDM_nxnB #(parameter W=2) ( input wire [W-1:0] in1, input wire [W-1:0] in2, output wire [2*W-1:0] res ); wire [W/2-1:0] L_in1; wire [W/2-1:0] R_in1; wire [W/2-1:0] L_in2; wire [W/2-1:0] R_in2; generate if (W==2) begin : SmallBLOCK wire [2:0] temp_...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vt; int a[110000]; int n; void solve() { vt v; vt::iterator it; for (int i = 0; i < n; i++) { it = upper_bound(v.begin(), v.end(), a[i]); if (it == v.end()) v.push_back(a[i]); else *it = a[i]; }...
#include <bits/stdc++.h> using namespace std; const int p = 1000003; const int n = 10; int inv[1000005], a[15][15], ans[15]; int read() { char c = getchar(); int x = 0, f = 1; while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { ...
/** * 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::sync_with_stdio(false); int t; cin >> t; while (t--) { int n; cin >> n; string a, b; a += M , b += M ; string tmp1, tmp2; cin >> tmp1 >> tmp2; a += tmp1, b += tmp2; for (int i = (1); i <...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, m, ans = 0; scanf( %I64d%I64d%I64d , &a, &b, &m); if (a >= m || b >= m) printf( 0 n ); else if (a <= 0 && b <= 0) printf( -1 n ); else { if (a < 0 || b < 0) { if (a > b) swap(a, b); ans =...
// (C) 2001-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 doc...
module testmuxpv(); # (parameter WIDTH = 32) ( input wire [2:0] /* synopsys enum cur_info */ sel, input wire [WIDTH-1:0] a, output reg [WIDTH-1:0] out ); endmodule module top_test(); /*AUTOWIRE*/ // Beginning of automatic wires (for undeclared instantiated-module outputs) wir...
#include <bits/stdc++.h> using namespace std; const int N = 14, M = 1 << N; int n, p[M]; char s[N][N]; vector<long long> f[M][N]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) scanf( %s , s[i]); for (int i = 1; i < 1 << n; ++i) { p[i] = p[i >> 1] + (i & 1); for (int j = 0...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 0) { cout << O-|-OOOO << endl; return 0; } while (n != 0) { int k = n % 10; if (k >= 5) { cout << -O| ; k -= 5; } else cout << O-| ; int i = 0; ...
// (C) 2001-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 doc...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int K = 1048576; int n; long long t[2][2 * K]; vector<int> g[N]; int T[N]; long long h[N], x[N], dp[N]; long long total; void build() { for (int i = 0; i < 2 * K; i++) t[0][i] = t[1][i] = 0; } void upd(int id, long lo...
module mem2serial #(parameter AW = 8) ( output reg read_clock_enable, input [47:0] read_data, input read_empty, // high is input is empty input reset, // active low input clock, input uart_ready, output reg [7:0] uart_data, output reg uart_clock_enable); parameter idle = 0, write_data = 1, wait_writ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const long long inf = 2e9; int32_t main() { cin.tie(0)->sync_with_stdio(0); long long n, m; string s, t; cin >> n >> m >> s >> t; vector<long long> pi(m, 0), nxt(m, 0); for (long long i = 1; i < m; i++) { { t[i] = char( 0 + (t[i]...
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; long long int mx = 0; for (long long int i = 0; i < a.size(); i++) { long long int g = (a[i] - 0 ); mx = max(mx, g); } for (long long int i = 0; i < b.size(); i++) { long long int g = (b...
/** * 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; #define ll long long typedef pair<ll, ll> pll; typedef pair<ll, int> pli; typedef pair<int, ll> pil; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<char>...
/** * 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...
// synthesis VERILOG_INPUT_VERSION SYSTEMVERILOG_2005 // // This file is part of multiexp-a5gx. // // multiexp-a5gx 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 ...
#include <bits/stdc++.h> using namespace std; inline long long qr() { long long x = 0, f = 1; char ch; while (!isdigit(ch = getchar())) if (ch == - ) f = -1; for (; isdigit(ch); x = x * 10 + ch - 48, ch = getchar()) ; return x * f; } const int N = 100010; int n, k, a[N], res; ...
#include <bits/stdc++.h> using namespace std; int v[7], x[7]; int main() { for (int i = 0; i < 6; ++i) scanf( %d , &v[i]); int ans = -1; for (int i = 0; i <= 100000; ++i) { x[1] = v[1] - v[2] + v[3] - v[4] + 2 * i; if (x[1] % 2 || x[1] < 0) continue; x[2] = v[2] + v[4] - v[0] - 2 * i...
#include <bits/stdc++.h> using namespace std; const int maxs = 405; const int inf = 1e9 + 7; int dp[maxs][maxs]; string s, t, x, y; int slen, tlen; int nxt[maxs][26]; int g(int x) { return x + 1; } int f(int a, int b) { if (a == -1 && b == -1) return 0; if (a < -1 || b < -1) return inf; in...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int N = 3e5 + 100; const double PI = acos(-1.0); void fre() { freopen( /Users/luras/Desktop/in.txt , r , stdin); freopen( /Users/luras/Desktop/out.txt , w , stdout); } int n, m, i, j, ans, 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...
`timescale 1ns / 10ps module test (); reg [3:0] a_in; reg [3:0] b_in; reg [3:0] s_in; reg M_in,Ci_inverse_in; wire [3:0] Y_out; wire P_out,Q_out,Co_inverse_out,AequalsB_out; ALU alu(a_in,b_in,s_in,M_in,Ci_inverse_in,P_out,Q_out,Co_inverse_out,Y_out,AequalsB_out); integer i,j,k,l,m; initial begin ...
#include <bits/stdc++.h> using namespace std; char a[100005]; int b[100005]; map<pair<int, int>, int> maps; int main() { int nx, ny, x, y, x1, y1, n; scanf( %d%d%d%d , &nx, &ny, &x, &y); scanf( %s , a); for (int i = 0; i < 100005; i++) b[i] = 0; b[0] = 1; maps[make_pair(x, y)] = 1; ...
#include<bits/stdc++.h> #define maxn 20010 using namespace std; int n, m, a[maxn]; int lg[maxn], mx[maxn][21], f[maxn][35][21], s[35], t[35]; int mxx(int x,int y){return x+a[x]>y+a[y]?x:y;} int qry(int x,int y){return mxx(mx[x][lg[y-x+1]],mx[y-(1<<lg[y-x+1])+1][lg[y-x+1]]);} int main() { lg[0]...
#include <bits/stdc++.h> const int maxn = 300 + 10; char st[maxn][maxn]; int n, m, p; int main() { scanf( %d%d%d , &n, &m, &p); for (int i = 1; i <= n; i++) scanf( %s , st[i] + 1); for (int k = 1; k <= n; k++) { for (int i = 1 + k; i + k <= n; i++) for (int j = 1 + k; j + k <= m; j++) ...
/* Copyright (c) 2016 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,...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/unisims/IOBUF.v,v 1.11 2009/08/21 23:55:43 harikr Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // All Right Reserved. //////////////////////////////////////////////////...
/** * 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 N = 600000 + 7; using namespace std; char o[] = { I , E , A , O , U , Y }; bool mark[N]; long long sum[N]; long double ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for (int i = 0; i < (((int)s.size())); i++) ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; set<int> a, b; set<int> pre; char str[10]; int main() { int n; cin >> n; long long ans = 1; a.insert(0); b.insert(1e9 + 5); for (int i = 0; i < n; ++i) { int x; scanf( %s%d , str, &x); if (str[1]...
#include <bits/stdc++.h> using namespace std; int main() { int n = 0, a = 0; cin >> n; int* arr = new int[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (int j = 0; j < n; j++) { cout << arr[j] << ; } return 0; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: IIT Roorkee // Engineers: Rohith Asrk, Nitin Sethi, Sri Vathsa, Shashwat Kumar // // Create Date: 13:34:17 04/08/2017 // Design Name: // Module Name: Insertion // Project Name: FPGA Implementat...
#include <bits/stdc++.h> using namespace std; struct vec { long long x, y; }; bool operator==(const vec& a, const vec& b) { return a.x == b.x and a.y == b.y; } bool operator!=(const vec& a, const vec& b) { return not(a == b); } bool operator<(const vec& a, const vec& b) { return make_pair(a.x,...
#include <bits/stdc++.h> using namespace std; int n, k, d, t; int a[1000005], b[1000005], c[1000005]; char ch[1000005], ans[1000005]; void mul(int* a, int* b) { for (int i = 0; i < n; ++i) { c[i] = b[a[i]]; } for (int i = 0; i < n; ++i) { a[i] = c[i]; } } int main() { scanf...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Mon Feb 13 12:43:53 2017 // Host : WK117 running 64-bit major release (build ...
#include <bits/stdc++.h> using namespace std; int n, k, tot, len[(int)(3e3 + 4)]; pair<int, int> bound[(int)(3e3 + 4)]; string s; vector<int> poz, ans[3000004]; void fail(); int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> k; cin >> s; for (int i = s.size() -...
// -*- verilog -*- // Copyright (c) 2012 Ben Reynwar // Released under MIT License (see LICENSE.txt) // This module updates the read_data immediately upon getting // a delete signal (using assign). module buffer_BB #( parameter WIDTH = 32, parameter MEM_SIZE = 64 ) ( input wire clk...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 2e5 + 5; const long long INF = (1LL << 62); const long double pi = 3.14159265359; void SRAND() { auto duration = std::chrono::system_clock::now().time_since_epoch(); auto millis = std::chrono::du...
//----------------------------------------------------------------------------- // Copyright 2017 Damien Pretet ThotIP // Copyright 2018 Julius Baxter // // 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...
#include <bits/stdc++.h> using namespace std; int const N = 100000; long long a[N + 1]; long long f[N * 3]; inline int lc(int root) { return root << 1; } inline int rc(int root) { return (root << 1) | 1; } void build(int root, int l, int r) { f[root] = -1; if (l == r) { f[root] = a[l]; ...
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 1000 + 10; vector<int> vec[N]; vector<int> d[2]; bool mark[N]; void dfs(int v, int hh) { mark[v] = true; d[hh].push_back(v); for (int u : vec[v]) if (!mark[u]) dfs(u, 1 - hh); } int main() { int o; cin >> o; ...
#include <bits/stdc++.h> using namespace std; const unsigned int MOD = 1000000007; void solve() { string s; cin >> s; string t; cin >> t; vector<char> v; bool check1 = false; bool check2 = false; bool check3 = false; for (int i = 0; i < s.length(); i++) { if (s[i] == a )...
`timescale 1ns / 1ps `default_nettype none `include "clk_gen.v" `include "monopix_core.v" `include "utils/bus_to_ip.v" `include "utils/cdc_syncfifo.v" `include "utils/generic_fifo.v" `include "utils/cdc_pulse_sync.v" `include "utils/reset_gen.v" `include "utils/CG_MOD_pos.v" `include "spi/spi_core.v" `include "s...
//---------------------------------------------------------------------------- //-- Memoria ROM genérica //------------------------------------------ //-- (C) BQ. October 2015. Written by Juan Gonzalez (Obijuan) //-- GPL license //---------------------------------------------------------------------------- //-- Memoria...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int n, m; int a[200000]; char tmp[200000]; int b[200000]; int bi; int c[200000]; int ci; int d[200000]; vector<int> dab; void calc() { int i, j; int cnt = 0; d[0] = -((1 << 30) - 1); ci = 0; for (i ...
#include <bits/stdc++.h> using namespace std; ifstream fin( test.in ); struct intr { int l, r, id; }; intr q[200005]; int p, n, qq; long long sol; int a[200005]; long long rez[200005]; int mp[5 * 200005]; bool cmp(intr &q1, intr &q2) { return (q1.r / p < q2.r / p || (q1.r / p == q2.r / p &...
`timescale 1ns/1ps module tb; `include "useful_tasks.v" // some helper tasks reg rst_async_n; // asynchronous reset wire r1,r2; wire g1,g2; wire d1,d2; wire a1,a2,r0; wire [7:0] dataout; two_phase_event_gen U_PORT1_EVENT_GEN ( .run(rst_async_n), ...
#include <bits/stdc++.h> using namespace std; const int N = 700 + 5; int n, m, d[N], cnt[N][N]; bitset<N> adj[N]; long long ans; int main() { scanf( %d%d , &n, &m); for (int i = 0, u, v; i < m; i++) { scanf( %d%d , &u, &v); d[--u]++, d[--v]++; adj[u][v] = adj[v][u] = true; } ...
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_8_b2s_incr_cmd.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module ax...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sun Jan 22 23:57:55 2017 // Host : TheMosass-PC running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e6 + 3; const int INFI = 1e9 * 2; const long long LINFI = 1e17; const double pi = acos(-1.0); const double s2 = sqrt(2.0); const int N = 222; const int M = 11; const int move[8][2] = {1, 0, -1, 0, 0, 1, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; ...
/* * Copyright (c) 1998 Purdea Andrei () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
module quadrature_decoder( direction_o, count_pulse_o, error_o, clk, enable_i, reset_i, quadA_i, quadB_i, quadA, quadA_old, quadB, quadB_old ); output direction_o, count_pulse_o, error_o, quadA, quadA_old, quadB, quadB_old; input clk, enable_i, reset_i, quadA_i, quadB_i; wire clk_i, enable_i, re...
// Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2013.4 (lin64) Build 353583 Mon Dec 9 17:26:26 MST 2013 // Date : Sat Mar 15 16:19:54 2014 // Host : macbook running 64-bit Arc...
//############################################################################# //# Purpose: MIO Receiver IO # //############################################################################# //# Author: Andreas Olofsson # ...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 200100; const long long INF = 2000000100; const long long MOD = 998244353; long long N, S[MAXN], P[MAXN]; long long B[MAXN]; void update(int ind, long long v) { for (int i = ind; i <= N; i += (i & -i)) { B[i] += v; } } ...
#include <bits/stdc++.h> using namespace std; long long rate[2000002]; int n, k; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> rate[i]; long long p = 0, c; int del = 0; vector<int> vec; for (int i = 1; i <= n; i++) { if (i - del > 1) c = (-rate[i - 1] * ((n...
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define pb push_back #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define faster() ios_base::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL); typedef lon...
#include <bits/stdc++.h> using namespace std; bitset<22500> a, b, c, e; int n, m, k; char s[100010]; int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 0; i < n; i++) { scanf( %s , s); for (int j = 0; j < m; j++) { if (s[j] != # ) a[i * m + j] = 1; if (s[j] == E ) e[i...
#include <bits/stdc++.h> int product(long long a) { int maxi = 0, mini = 9, x, ans; long long temp = a; while (temp) { x = temp % 10; if (x < mini) mini = x; if (x > maxi) maxi = x; temp /= 10; } if (mini == 0) return 0; ans = mini * maxi; return ans; } using na...
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, k1, k2; cin >> n1 >> n2 >> k1 >> k2; if (n1 > n2) cout << First << endl; else if (n1 == n2) cout << Second << endl; else cout << Second << endl; return 0; }
module premuat1_32( enable, inverse, i_0, i_1, i_2, i_3, i_4, i_5, i_6, i_7, i_8, i_9, i_10, i_11, i_12, ...
/** * 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; template <typename T> void read(T &x) { x = 0; T f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; x *= f; } int max(int x, int y) { return x > ...
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; int INF = 2000000000; long long INFF = 8000000000000000000LL; double PI = acos(-1); int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1}; int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1}; inline string IntToString(int a) { char x[100]; sprintf(x, %...
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, prnt[N]; long long k; long long sum = 0; vector<int> g[N]; int sz[N]; void DFS(int node, int prnt) { sz[node] = 1; for (int i = 0; i < (int)g[node].size(); i++) { if (g[node][i] == prnt) continue; DFS(g[node][...
//Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2017.2 (win64) Build Thu Jun 15 18:39:09 MDT 2017 //Date : Tue Sep 19 00:28:00 2017 //Host : DarkCube running 64-bit major release (build 92...
Require Import VPHL.PrImp. (* Require Import Sf.Maps. *) Print aeval. (* aeval = *) (* fix aeval (a : aexp) (st : state) {struct a} : nat := *) (* match a with *) (* | ANum n => n *) (* | AId x => fst st x *) (* | APlus a1 a2 => (aeval a1 st + aeval a2 st)%nat *) (* | AMinus a1 a2 => (aeval a1 st - aeval a...
#include <bits/stdc++.h> using namespace std; const int N = 105; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ...
#include <bits/stdc++.h> using namespace std; long long int spf[100001]; void sieve(); set<long long int> factors(long long int x); void getZarr(string str, long long int Z[]); int n; vector<int> ans; vector<bool> vis; vector<int> mas; vector<int> del; vector<int> koll; vector<vector<int>> edges...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 7; long long n, k, a, b, q; long long arr[MAXN]; void read() { cin >> n >> k >> a >> b >> q; } long long acnt[MAXN << 2], asum[MAXN << 2], bcnt[MAXN << 2], bsum[MAXN << 2]; long long getacnt(long long v, long long tl, long long tr,...
/** * 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() { int n, p = 1000000000; cin >> n; int k[n], i; for (i = 0; i < n; i++) { cin >> k[i]; } i = 0; int j = 0, sum = 0; while (n--) { sum = 0; while (k[i]--) { cin >> j; sum = sum + j * 5 + 15; ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long MAXN = 1e5 + 100; long long F[MAXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); F[0] = 1; F[1] = 1; for (long long i = 2; i < MAXN; i++) F[i] = (F[i - 1] + F[i - 2]...
// A zero value MCD should be allowed, but does it process the arguments? module top; integer mcd, test; initial begin test = 0; // Skipped, but function is called. #1; $display($stime); mcd = 0; $fstrobe(mcd, "The $fstrobe(%d, ...) ran.", mcd); $fdisplay(mcd, "The result for $fdisplay(...
// DESCRIPTION: Verilator: Verilog Test module // // A test of the export parameter used with modport // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2013 by Jeremy Bennett. // SPDX-License-Identifier: CC0-1.0 interface test_if; // Pre-declare function extern function my...
#include <bits/stdc++.h> using namespace std; const long long int INF = 1e18; int32_t main() { long long int n; cin >> n; if (n % 2 != 0) { cout << 0 << n ; return 0; ; } long long int k = pow(2, n / 2); cout << k << n ; return 0; ; }
#include <bits/stdc++.h> using namespace std; char board[8][8]; int main() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) scanf( %c , &board[i][j]); } int minA = 100, minB = 100; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (board[i][j] == W ) {...