text
stringlengths
59
71.4k
//############################################################################# //# Purpose: Clock divider with 2 outputs # // Secondary clock must be multiple of first clock # //############################################################################# ...
#include <bits/stdc++.h> using namespace std; struct disjoint_set { vector<int> p; disjoint_set(int n) : p(n, -1) {} bool share(int a, int b) { return root(a) == root(b); } int sz(int u) { return -p[root(u)]; } int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); } bool merge(int u, in...
#include <bits/stdc++.h> using namespace std; const long long md = 1e9 + 7; const long long o5 = 716327852; const int N = 2e5 + 34; long long f[N], o[N]; long long ans, n, w, h; long long dp[N]; pair<long long, long long> a[N]; long long c(long long h, long long w) { return (((f[h + w] * o[h]) % m...
#include <bits/stdc++.h> using namespace std; typedef long double real; string Pair[26][26]; int cost[26][26][501], dp[26][26][501]; pair<int, int> parent[26][26][501]; int n, m; char flag[501][501]; pair<int, pair<int, int> > buffer[26 * 26]; bool used[26][26]; int main() { ios_base::sync_with_...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e4 + 9; long long a[maxn]; long long n; void solve() { cin >> n; long long sum = 0; for (long long i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum % n != 0) { cout << -1 n ; return; ...
#include <bits/stdc++.h> using namespace std; map<long long, int> mp; long long n, k, i, v[500005], val[500005], x, sum[500005], fr[500005], frec[500005], fr3[500005], nr, sum2[500005], bucket, val1, m, st, dr, s, stcur, drcur, sol[500005], fr2[500005], val2, b[500005]; struct wow { long long st...
/** * 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...
//***************************************************************************** // (c) Copyright 2009 - 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 /...
/* * 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; long long n, a[310]; long long fac[310], rev[310]; bool mmp[310][310]; long long mod = (long long)1e9 + 7; long long qmod(long long a, long long p) { long long ret = 1; while (p) { if (p & 1) ret = (ret * a) % mod; a = (a * a) % mod; p ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int> > A(n, vector<int>(m)), B(n, vector<int>(m)); for (int x = 0; x < n; x++) for (int y = 0; y < m; y++) cin >> A[x][y]; for (int x = 0;...
// cic_dec_2.v: CIC Decimator - single // 2016-07-17 E. Brombaugh module cic_dec_2 #( parameter NUM_STAGES = 4, // Stages of int / comb STG_GSZ = 8, // Bit growth per stage ISZ = 10, // Input word size OSZ = (ISZ + (NUM_STAGES * STG_GSZ)) // Output word size ) ( in...
#include <bits/stdc++.h> using namespace std; int tt(char p) { int s; if (p == > ) s = 8; else if (p == < ) s = 9; else if (p == + ) s = 10; else if (p == - ) s = 11; else if (p == . ) s = 12; else if (p == , ) s = 13; else if (p == [ ) ...
`timescale 1ns / 1ps // sonic_sensor.v ver 1.0 // Description by Kazushi Yamashina // Utsunomiya University // // _ _ _ _ //clk _| |__| |__ ........... __| |__| |_ // ___ //req __| |____________________________ // ____ ___ //...
/** * 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 maxn = 500000 + 5; long long a[maxn], tmp[maxn]; multiset<long long> save; vector<pair<long long, long long> > b; int main() { long long total = 0; long long n; scanf( %lld , &n); for (long long i = 0; i < n; i++) scanf( %lld , a ...
#include<set> #include<map> #include<stack> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<climits> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define LL long long using namespace std; LL read(){ bool f=0;LL x=0;char c=getchar();...
#include <bits/stdc++.h> using namespace std; bool exceed(long long x, long long y, long long m) { return x >= m / y + 1; } struct SegTree { int size; vector<pair<long long, long long> > seg; SegTree() {} SegTree(int size) { this->size = size; seg.resize(1 << (size + 1)); } pai...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:19:08 12/01/2010 // Design Name: // Module Name: sd_dma // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: /...
/* * 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 int M = 100000 + 10; int d[M]; long long int pred[M]; long long int a[M]; long long int dp[110][M]; long long int pres[M]; long long int dq[M]; long long int yk(int i, int k) { long long int val = dp[i][k] + pres[k]; return val; } int mai...
// megafunction wizard: %RAM: 2-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: fm_ram_1024w.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===========================...
#include <bits/stdc++.h> using namespace std; struct Edge { int v, next; } edge[100010]; int head[10]; int pos; void insert(int x, int y) { edge[pos].v = y; edge[pos].next = head[x]; head[x] = pos++; } int du[10]; int pp[100010]; int qq; int fa[10]; int find(int x) { if (fa[x...
#include <bits/stdc++.h> using namespace std; template <class T> void read(vector<T>& a) { for (auto& e : a) { cin >> e; } } template <class T> void print(vector<T>& a) { for (auto& e : a) { cout << e << ; } cout << n ; } void solve() { long long n, h; cin >>...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; const int oo = 0x3f3f3f3f; const int LIM = 2e5; int N, a[MAXN], num[MAXN], top, f[MAXN], ans[MAXN]; vector<int> S[MAXN]; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } namespace Graph { struct edge { int y, next; }...
#include <bits/stdc++.h> using namespace std; long long int n, a, k; char s[2000007], res[2000007]; bool vis[2000007]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; long long int maxn = -1; for (long long int i = 0; i < n; ++i) { cin >> s >> k; long long int ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:52:53 06/12/2014 // Design Name: // Module Name: seg7decimal // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: /...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 5e5 + 2; const int M = 1e5 + 2; const int inf = 2e9 + 2; const long long linf = 4e18 + 2; long long add(long long a, long long b) { a += b; return a >= mod ? a - mod : a; } long long sub(long long a, lon...
/* Simple external interrupt controller for MIPSfpga+ system * managed using AHB-Lite bus * Copyright(c) 2017 Stanislav Zhelnio * https://github.com/zhelnio/ahb_lite_eic */ `include "mfp_eic_core.vh" module mfp_ahb_lite_eic ( //ABB-Lite side input HCLK, input ...
#include <bits/stdc++.h> using namespace std; int main() { string x; cin >> x; int y; if (x.size() == 1) { y = x[0] - 0 ; if (!(y % 4)) cout << 4; else cout << 0; return 0; } y = x[x.size() - 1] - 0 + ((x[x.size() - 2] - 0 ) * 10); if (!(y % 4)...
//////////////////////////////////////////////////////////////////////////////// // Copyright (C) 1999-2008 Easics NV. // This source file may be used and distributed without restriction // provided that this copyright statement is not removed from the file // and that any derivative work contains the original copyrigh...
module IMPOR( output reg [2:0] out, output reg out_valid, output reg ready, input [2:0] in, input [2:0] mode, input in_valid, input clk, input rst_n ); reg sta; reg [2:0] sta10, sta11, sta12, sta13, sta14, sta15, sta16, sta17, sta18; wire [2:0] sta20, sta21, sta22, sta23, sta24, sta25, sta26,...
/** * 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(void) { cin.sync_with_stdio(false); long long k[3]; int t[3]; int n, i, j; for (i = 0; i < 3; i++) cin >> k[i]; for (i = 0; i < 3; i++) cin >> t[i]; cin >> n; vector<long long> a(n); vector<long long> b(n); for (i = 0; i ...
module projetoPessoal_TB; integer a; wire [1:0] ledVerde, ledVermelho; wire [6:0] display; reg clock; inicial i( a[3], a[2], a[1], a[0], ledVerde, ledVermelho, display, clock ); //Alterando clock always begin clock <= 0; #25; clock <= 1; #25; end initial begin $dis...
#include <bits/stdc++.h> using namespace std; char s1[100100], s2[100100]; long long ini; long long mod(long long a) { return ((a % 1000000007LL) + 1000000007LL) % 1000000007LL; } long long func(char* s, int t, bool som) { long long r = 0; long long ul = 0; long long soma = 0, ls = ini; ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:5000000000 ) const long long mod = 1000000007; long long Inf = (long long)2e9; long long LINF = (long long)1e18 + 1e17; using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; vector<long long> a(n); vector<...
/* * 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...
/* Distributed under the MIT license. Copyright (c) 2015 Dave McCoy () 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, mo...
#include <bits/stdc++.h> using namespace std; void getre() { int x = 0; printf( %d n , 1 / x); } void gettle() { int res = 1; while (1) res <<= 1; printf( %d n , res); } template <typename T, typename S> inline bool upmin(T &a, const S &b) { return a > b ? a = b, 1 : 0; } templ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; long long int a[200][3]; int main() { ios ::sync_with_stdio(false); cin.tie(0); ; long long int i, k, l, n, j; cin >> n; for (i = 0; i <= n - 1; i++) cin >> a[i][0] >> a[i][1]; cin >> j; for (i = 0; i <= n - 1; i++) if (j >= a[i][...
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; int id; Point() {} Point(long long a, long long b, int c) : x(a), y(b), id(c) {} Point operator-(Point b) { return Point(x - b.x, y - b.y, 0); } bool operator<(const Point &b) const { return (x != b.x) ? x < b...
// Copyright (c) 2014, Segiusz 'q3k' Bazanski <> // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright notice, // this l...
#include <bits/stdc++.h> using namespace std; struct node { long long int word, prefix; node *child[2]; node() { word = prefix = 0; child[0] = child[1] = NULL; } }; void insert(node *root, long long int x, long long int bit) { root->prefix += 1; if (bit < 0) { root->wor...
#include <bits/stdc++.h> using namespace std; struct Time { long long deno, num; inline long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); } inline void simplify() { long long g = gcd(abs(deno), abs(num)); deno /= g; num /= g; if (deno < 0) { ...
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1.0), eps = 1e-10; long double det(long double a11, long double a12, long double a21, long double a22) { return a11 * a22 - a12 * a21; } struct pt { long double x, y; pt(long double x, long double y) : x(x...
#include <bits/stdc++.h> int Abs(int x) { return x < 0 ? -x : x; } int main() { int i, N, ans = 0, sum = 0, c = 0, d = 0; double p; scanf( %d , &N); for (i = 0; i < 2 * N; i++) { scanf( %lf , &p); int t = ((int)(p * 1000 + 0.1)) % 1000; if (!t) c++; sum += t; } ans = ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2013 by Sean Moore. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] crc; reg [63:0] sum; ...
/* * Milkymist VJ SoC * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, p, x, y; int a[1010], b[1010]; int i, j; while (scanf( %d%d%d%d%d , &n, &k, &p, &x, &y) != EOF) { int sum = 0; for (i = 0; i < k; i++) { scanf( %d , &a[i]); sum += a[i]; } if (sum > 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...
#include <bits/stdc++.h> using namespace std; int vet[1010], dp[2][1010]; const int mod = 998244353; long long soma(long long x, long long y) { x += y; if (x >= mod) x -= mod; return x; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> vet[i]; } for (...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
(* begin hide *) Require Import Coq.Strings.String. Require Import Coq.Strings.Ascii. (* end hide *) (** Binary numbers are so ubiquitous in Computer Science that programming languages often have special notations for them. The most popular one is arguably hexadecimal notation. It is close to binary represe...
//Legal Notice: (C)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 do...
// -*- Mode: Verilog -*- // Filename : spi_testbench.v // Description : Testbench for testing SPI module // Author : Philip Tracton // Created On : Fri Jul 8 21:08:52 2016 // Last Modified By: Philip Tracton // Last Modified On: Fri Jul 8 21:08:52 2016 // Update C...
`include "config.inc" module gamma( input clock, input [4:0] gamma_config, input [7:0] in, output reg [7:0] out ); always @(posedge clock) begin case (gamma_config) `GAMMA_0_714290: begin case (in) `include "config/gamma_0_714290.v" ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { string s, t; cin >> s >> t; vector<int> each[26]; int n, m; n = s.length(); m = t.length(); for (int i = 0; i...
/*########################################################################### # Function: Single port memory wrapper # To run without hardware platform dependancy use: # `define TARGET_CLEAN" ############################################################################ */ module memory_sp(/*AU...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2014, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; vector<int> p, vg; set<pair<int, int> > done; bool cando(int i, int j) { return done.find(make_pair(min(i, j), max(i, j))) == done.end(); } int moves = 0; void doswap(int i, int j) { ++moves; ...
#include <bits/stdc++.h> using namespace std; vector<long long> a; vector<long long> dp(2001); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); int t = 1; long long n, k, x, temp; 2000000001LL; while (t--) { cin >> n >> k; for (int i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; long long nx2(long long n) { long long p = 1; if (n && !(n & (n - 1))) return n; while (p < n) p <<= 1; return p; } namespace Debug { void dout() { cerr << n ; } template <typename Head, typename... Tail> void dout(Head H, Tail... T) { ce...
//Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. //-------------------------------------------------------------------------------- //Tool Version: Vivado v.2014.2 (win64) Build 928826 Thu Jun 5 18:21:07 MDT 2014 //Date : Mon Jan 26 13:25:28 2015 //Host : Dtysky running 64-bit major release (buil...
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int a[n + 1], b[n + 1], i; a[0] = -1; b[0] = -1; for (i = 1; i <= n; i++) { cin >> a[i]; } for (i = 1; i <= n; i++) { cin >> b[i]; } if (a[1] == 0) { cout << NO ; retu...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:16777216 ) const double EPS = 1e-7; double iabs(const double a) { return (a < -EPS) ? -a : a; } double imin(const double a, const double b) { return (a - b > EPS) ? b : a; } double imax(const double a, const double b) { return (a ...
`include "bsg_mem_1rw_sync_macros.vh" module bsg_mem_1rw_sync #( parameter `BSG_INV_PARAM(width_p ) , parameter `BSG_INV_PARAM(els_p ) , parameter addr_width_lp = `BSG_SAFE_CLOG2(els_p) // whether to substitute a 1r1w ...
module tb_elink reg [1:0] elink_txrr_packet; wire elink_txo_lclk_p; wire elink_chip_resetb; reg elink_rxrr_wait; wire elink_txrd_wait; wire elink_rxwr_access; wire elink_cclk_p; reg elink_rxrd_wait; wire elink_cclk_n; wire elink_rxrr_access; reg ...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(time(0)); const long long inf = 0x3f3f3f3f3f3f3f3fLL; const long long N = 1e5 + 10; const long long MOD = 1e9 + 7; long long n, m, s; vector<vector<long long>> g(N); bool vis[N][2]; long long par[N][2], mark[N]; void dfs(long long u, long lon...
/** * 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...
/* * SBN machine with hardwired FSM control * (c) Volker Strumpen * * modified to halt execution * if result address is C all fff's * i.e. ff for fwidth=8 * by Martin Polak */ module sbn (clk, state, PC, a, b); parameter fwidth = 8; // field width of sbn operand parameter dwidth = 32; input ...
#include <bits/stdc++.h> using namespace std; const int maxN = 23; const int mod = 1000 * 1000 * 1000 + 7; int dp[2][1 << maxN]; int a[maxN]; int res[maxN][maxN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; dp[0][...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\velocityControlHdl\velocityControlHdl_Control_DQ_Currents.v // Created: 2014-08-25 21:11:09 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // -----------------------------------------------...
// megafunction wizard: %ALTDDIO_IN% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altddio_in // ============================================================ // File Name: rgmii_in1.v // Megafunction Name(s): // altddio_in // ============================================================ // ********...
// (C) 1992-2014 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...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1); const long long inf = 0x3f3f3f3f3f3f3f3f; const int INF = 0x3f3f3f3f; const int MAX = 2e5 + 10; const long long mod = 1e9 + 7; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } ch...
#include <bits/stdc++.h> using namespace std; bool debug = true; long long n, m, a, b; int main(int argc, char* argv[]) { cin >> n >> m >> a >> b; long long r = n % m; cout << min(r * b, (m - r) * a); while (clock() <= 300) { } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXI = numeric_limits<int>::max() / 2; const int MINI = numeric_limits<int>::min() / 2; const long long MAXL = numeric_limits<long long>::max() / 2; const long long MINL = numeric_limits<long long>::min() / 2; int cnt[2][2]; long long pro(long long 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> using namespace std; const long long maxn = 1e6 + 10; long long a[maxn], b[maxn], ans[maxn]; int32_t main() { long long n; cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b, b + n); if (b[0] == b[n - 1]) { if (b[0]...
#include <bits/stdc++.h> using namespace std; namespace io { const int SIZE = (1 << 21) + 1; char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr; inline void flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; }...
#include <bits/stdc++.h> using namespace std; const long long N = 100005; bool dp[501][501]; long long a[501], b[501]; signed main() { std::ios::sync_with_stdio(false); cin.tie(NULL); long long n, k; cin >> n >> k; for (long long i = 1; i < n + 1; i++) { cin >> a[i] >> b[i]; } ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 50005; const int MAXD = 55; const int MOD = 1e9 + 7; 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(); } wh...
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, pair<long long int, long long int> > > P; int level[1007]; double ans = 0; bool contains(pair<long long int, pair<long long int, long long int> > A, pair<long long int, pair<long long int, long long int> > B) { return...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2012, Ameer M. Abdelhadi; . All rights reserved. // // // // Redistribution and use in source and binary forms, with or with...
#include <bits/stdc++.h> using namespace std; int t; long long l[200002], c[200002]; long long minx, maxx, miny, maxy; string s; bool check(long long l[], int n) { int Min = 0, Max = 0; int last = 0, first = 0; for (int i = 1; i <= n; i++) { if (l[i] < Min) { first = i; Min...
#include <bits/stdc++.h> using namespace std; long long f(long long n) { if (n < 10) return n; long long last_digit = n % 10; long long ret = n / 10 + 9; long long tmp = n; while (tmp >= 10) tmp = tmp / 10; if (tmp > last_digit) ret--; return ret; } int main() { long long i, j, k...
#include <bits/stdc++.h> using namespace std; mt19937 rnd; const int N = 1e5 + 10; long long a[N], pref[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, d, m; cin >> n >> d >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (i...
// $Header: $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2011 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ ...
#include <bits/stdc++.h> using namespace std; int a[200005], n, m, k, ans; queue<int> que; inline int gi() { register int x = 0, q = 1; register char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) q = -1, ch = getchar(); while (ch >= 0 && ch <= ...
`default_nettype none `timescale 1ns / 1ps module joypad_controller( input wire clock, input wire reset, input wire int_ack, output reg int_req, input wire [15:0] A, input wire [7:0] Di, output wire [7:0] Do, input wire rd_n, input wire wr_n, in...
#include <bits/stdc++.h> using namespace std; int k, n; long long ans, maxim, suma; map<string, int> f; deque<pair<string, int>> box[200001], b1, b2, b; vector<pair<int, int>> trouble; string s; int val; bool comp(pair<string, int> x, pair<string, int> y) { return x.second > y.second; } int ma...
/** * 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 INF = 1 << 30; const int N = 5e4 + 10; int y[N]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , y + i); } int low = 1, high = 1e9; while (low != high) { int mid = (low + high) / 2; ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2019 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", ...
module test(); // function with no lifetime, return-type, or port-list function f0; blah0; endfunction // f0 // empty port-list function f1(); blah1; endfunction // f1 // non-empty portlist function f2(stuff2); blah2; endfunction // f2 // test that ": func...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps / 1ps `include "gpio/gpio_core.v" `include "gpio/gpio.v" `include ...
/* * 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 mod = 1000000007; int n; int m; int a, b; long long fast_mod_pow(long long a, long long b) { long long res = 1; a %= mod; while (b) { if (b & 1) { res = (res * a) % mod; } a = (a * a) % mod; b >>= 1; ...