text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int n, i; scanf( %i , &n); int a = n / 3, b = n - a; for (i = 1; i <= b; i++) printf( 1 %i n , i); for (i = 1; i <= a; i++) printf( 4 %i n , i * 2); return 0; }
// file: clk_gen.v // // (c) Copyright 2008 - 2013 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. // // DISCLAIMER // This disclaimer is not a l...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); map<int, int> mp; int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n, k, tmp = 1, mx = 0; cin >> n >> k; while (tmp <= k + 1) { int pos, x; cout << ? << ; f...
/** * 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() { string s; cin >> s; s += 0 ; int c = 1; char sc = s[0]; bool xd = false; string res = ; for (int i = 1; i < s.size(); i++) { if (sc != s[i]) { if (c == 1) { res += sc; xd = false; ...
#include<bits/stdc++.h> using namespace std; using ll = long long int; using vi = vector<int>; #define f(n) for(int i = 0; i < n; i++) #define fj(n) for(int j = 0; j < n; j++) #define fk(n) for(int k = 0; k < n; k++) #define ci(n) cin >> n; #define ic(n) int n; cin >> n; #define lc(n) int n; cin...
//================================================================================================== // Filename : submidRecursiveKOA2.v // Created On : 2016-10-28 08:46:44 // Last Modified : 2016-10-28 08:59:25 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Institu...
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5; int n, x, k; int a[NMAX + 2]; long long ans; int ndiv(int f, int l) { return l / x - (f - 1) / x; } pair<int, int> bs(int arg) { pair<int, int> last; int st = arg, dr = n; last.first = last.second = -1; while (st <= dr) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n + 1]; if (n % 2 == 0) cout << n * n / 2 << endl; else cout << ((n * n) + 1) / 2 << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i % 2 != 0 && j % 2 != 0...
#include <bits/stdc++.h> using namespace std; map<string, int> c; int main() { int l1, l2, f, ans = 0; string s1, s2; cin >> s1 >> s2; l1 = s1.length(); l2 = s2.length(); for (int i = 1; i <= min(l1, l2); i++) if (l1 % i == 0 && l2 % i == 0) { f = 0; c.clear(); ...
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { int n, k; cin >> n >> k; vector<int> v(n); int itr = 1; for (int& x : v) { cin >> x; } set<int> bag{0}, tmp; map<int, vector<int>> pep; for (int i = 0; i < n && b...
#include <bits/stdc++.h> using namespace std; int main() { string s1; int count = 0; cin >> s1; char c = s1[0]; for (int i = 0; i < s1.length(); i++) { if (s1[i] == c) count++; else if (s1[i] > c) { count = 1; c = s1[i]; } } cout << string(count,...
#include <bits/stdc++.h> using namespace std; const int N = 160; const int mod = 1e9 + 7; int n, m, f[N][N][2][2], ans; void inc(int& a, int b) { if (a += b, a >= mod) a -= mod; } int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= m; ++i) for (int j = i; j <= m; ++j) { f[i...
#include <bits/stdc++.h> int n, up, s; int a[20], ans[5][5], s1[5], s2[5], s3, s4, idx[1 << 16], cnt[1 << 16]; bool ans_u, vis[1 << 16]; void dfs(int sta) { if (sta == up) { if (ans_u) return; printf( %d n , s); for (int i = 0, j; i < n; ++i) { for (j = 0; j < n; ++j) { i...
#include <bits/stdc++.h> using namespace std; int main() { int n, m(0), a(0), b(0), c(0), x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (i % 3 == 0) a += x; else if (i % 3 == 1) b += x; else c += x; } m = max(max(a, b), c); if (m == a...
/* * 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 INF = 1 << 25; const long long LL_INF = 1ll << 61; int main() { int n; scanf( %d , &n); vector<int> count(3, 0); for (int i = 0; i < n; i++) { int num; scanf( %d , &num); count[num]++; } if (count[1] == 0) { ...
#include <bits/stdc++.h> using namespace std; const int mx[8] = {-1, 1, -1, 1, -2, 2, -2, 2}; const int my[8] = {-2, -2, 2, 2, -1, -1, 1, 1}; const int MAXN = 1100; const int MAXM = 1100; int N, M; const int MAXV = MAXN * MAXM; int V; int source[2]; int target[2]; int dist[2][MAXV]; int nxt[2][M...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:500000000 ) using namespace std; int A[222]; bool used[222]; int main() { int n, k, i; cin >> n >> k; for (i = 0; i < 2 * n + 1; i++) cin >> A[i]; int N = 2 * n + 1; memset(used, false, sizeof(used)); while (k) { for (i = 1...
// // Handles flow control for a bsg_wormhole packet. Given a length of // wormhole packet and a begin transaction signal, this module tracks which // flits are header flits and which are data flits. // // A bsg_wormhole packet is assumed to be laid out as: // ----------------------------------------------------...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int mod = 1e9 + 7; struct edge { int u, v, t, c, id; } e[N]; int n, m; vector<edge> s[N]; bool cmp(edge a, edge b) { return a.c < b.c; } struct TwoSat { static const int N = ::N << 1; int dfn[N], low[N], id[N], st[N...
#include <bits/stdc++.h> using namespace std; int n, a; vector<int> v1, v2; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a; v1.push_back(a); v2.push_back(a); } sort(v2.begin(), v2.end()); a = 0; for (int i = 0; i < n; i++) { a += v1[i] != v2[i]; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1002000, CAN = 34; int n, m, p, vis[MAXN], pr[MAXN], pcnt; char w1[MAXN], w2[MAXN]; vector<int> can[300]; int muln(int x, int y) { return 1LL * x * y % p; } int mo(int x) { while (x >= p) x -= p; while (x < 0) x += p; return 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 la...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int count = 0; int a[(int)(pow(2.0, (double)(n + 1)) - 2)]; int x = (int)pow(2.0, (double)(n + 1)) - 2; for (int i = 0; i < x; i++) { cin >> a[i]; } int y = (int)(pow(2.0, (double)(n + 1)) - pow(2.0, (d...
module incrementCounter (pcprev, newpc); //increments value from PC counter to next instruction input [31:0] pcprev; //setting up inputs and outputs reg [31:0] newpcreg; output [31:0] newpc; always@ (pcprev) begin //whenever pcprev changes, do the following assign newpcreg = pcprev + 1; //add 1 to pcprev and ass...
#include <bits/stdc++.h> using namespace std; long long n, k; long long calc(long long n, long long k) { map<long long, long long> l, r; l.clear(); r.clear(); long long cnt[2]; cnt[0] = cnt[1] = 0; if (k == 1) return n / 2; k--; l[n / 2] = 1; r[n / 2 + (n % 2)] = 1; while (...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int x1, x2, y1, y2; long long int k; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2 || y1 == y2) k = abs(x1 - x2) + abs(y1 - y2); else k = 2 + abs(x1 - x2) + abs(y...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2005 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; // verila...
`timescale 1ns / 1ps //////////////////////////////////// //Zachary Karpinski //Karpentium Processor // //program_memory.v // //A parameterized ROM, preloaded with programs // // rw enable function // d 0 nothing // 0 1 MDR <- Memory // 1 1 Memory <- MDR // // s_addr: The address size // s_word: The d...
/* * 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 mod = 1000000007LL; long long large = 2000000000000000000LL; bitset<20011> vis; vector<int> primes; void sieve(long long n) { vis.set(); vis[0] = 0; vis[1] = 0; for (long long i = 2; i <= n; i++) { if (vis[i]) primes.push_back((in...
#include <bits/stdc++.h> #define ll long long #define INF INT_MAX #define pii pair<int,int> using namespace std; const int maxn=1e3+10; const int mod=998244353; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll N,K; cin>>N>>K; vector<vector<ll>> p(maxn); ...
#include<iostream> #include<map> #include<cstring> #include<cmath> #include<algorithm> #include <queue> #include<map> using namespace std; typedef long long ll; inline ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a; } int main() { ll T,m1,m,k,a,b; cin>>T; while(T--){ int a[30]=...
// $Id: c_crossbar.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions o...
#include <iostream> #include <iomanip> #include <cstdio> #include <vector> #include <algorithm> #include <cmath> #include <cstring> #include <cassert> #include <string> #include <set> #include <map> #include <random> #include <bitset> #include <string> #include <unordered_set> #include <un...
/* * 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; const long long infinity = 1000000000000000000; const int inf = 1e9 + 5; bool do_debug = false; const int maxn = 3e5 + 5, maxjump = 19; int n_nodes, n_edges, nq; vector<int> adj[maxn]; int depth[maxn] = {0}; long long in...
#include <bits/stdc++.h> using namespace std; namespace io { char ibuf[(1 << 18)], *iS, *iT, obuf[(1 << 18)], *oS = obuf, *oT = oS + (1 << 18) - 1, c, qu[55]; int f, qr; inline void flush(void) { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; return; } inline char getch(void) { retur...
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long ans = 1; while (b > 0) { if (b & 1) { ans = (ans * a) % 1000000007; } a = (a * a) % 1000000007; b >>= 1; } return ans; } bool prime(long long n) { for (long lon...
#include <bits/stdc++.h> using namespace std; vector<vector<pair<int, int>>> G; int main() { int n, m; scanf( %d%d , &n, &m); G.resize(n + 1); for (int i = 1; i <= n; i++) G[i].push_back(make_pair(i, i)); for (int i = 0; i < m; i++) { int a, b; scanf( %d%d , &a, &b); G[a].pus...
/** * 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() { long long int n; cin >> n; long long d = 0; for (int i = 9; n > 0; i *= 10) { d += n; n -= i; } cout << d << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 1; vector<int> adj[N]; int numDiv[N]; int a[N]; bool cand[N]; int sz[N], dsu[N]; int f(int x) { if (x == dsu[x]) { return x; } return dsu[x] = f(dsu[x]); } void merge(int x, int y) { x = f(x), y = f(y); if (x...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Fri Apr 14 18:39:27 2017 // Host : LAPTOP-IQ9G3D1I running 64-bit major releas...
#include <bits/stdc++.h> using namespace std; const int maxn = 500500; bool x[maxn]; int p[maxn], num[maxn], tmp[110]; int main() { int n, q; long long ans = 0; scanf( %d%d , &n, &q); for (int i = 0; i < n; i++) scanf( %d , num + i + 1); for (int u = 0; u < q; u++) { int t, k, cnt = ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin >> n; vector<pair<int, int>> vp(n); for (int i = 0; i < n; i++) cin >> vp[i].first >> vp[i].second; sort(vp.begin(), vp.end()); long long res = 1; pai...
#include <bits/stdc++.h> using namespace std; const int N = 210000; int n, root, opt, Max[N << 6], lson[N << 6], rson[N << 6], lazy[N << 6]; void pushdown(int k, int l, int r) { if (!lazy[k]) return; if (l != r) { if (!lson[k]) lson[k] = ++opt; if (!rson[k]) rson[k] = ++opt; lazy[lson[...
// issue 1698 module sub_mod ( input [8+4-1:0][7:0] add_left, input [8-4-1:0][7:0] substract_left, input [8*4-1:0][7:0] multiply_left, input [8/4-1:0][7:0] divide_left input [7:0][8+4-1:0] add_right, input [7:0][8-4-1:0] substract_right, input [7:0][8*4-1:0] multiply_right, input [7:0][8/4-1:0...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int maxP = 0; int maxQ = 0; for (int i = 0; i < k; i++) { int p = 0; int q = 0; cin >> p; cin >> q; if (p < q) { cout << Happy Alex << endl; return 0; } } cou...
/** * 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-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Fri Oct 27 10:19:56 2017 // Host : Juice-Laptop running 64-bit major relea...
module helloworld #(parameter CLOCK_FREQ = 12000000, parameter BAUD_RATE = 115200) ( input ext_clock, output uart_tx_pin, output uart_tx_led, output uart_clock_led); wire reset; wire [47:0] write_data; /* ring buffer */ wire read_clock_enable; wire write_clock_enable; wire empty; wire overflow; /* mem2s...
`timescale 1ns / 1ps //Test ALU module TestALU; //Inputs reg [31:0] a; reg [31:0] b; reg [3:0] s; //Outputs wire [31:0] Z; wire le; wire eq; wire gt; wire ovf; //Unit under test ALU uut( .a(a), .b(b), .s(s), .Z(Z), ...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2011 by Wilson Snyder. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. `define is_near_real(a,b) ($abs((a)...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int N = 5005; void update(int &a, int b) { a += b; a %= MOD; } int add(int a, int b) { return (a + b) % MOD; } int multiply(int a, int b) { return (a * 1LL * b) % MOD; } int quick_power(int a, int n) { int res = 1...
#include <bits/stdc++.h> using namespace std; const int maxn = 60; vector<int> adj[maxn]; int n, m; void read() { scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int a, b; scanf( %d%d , &a, &b); a--, b--; adj[a].push_back(b); adj[b].push_back(a); } } bool vis...
//----------------------------------------------------- // Design Name : hw1_B // File Name : hw1_B.v // Function : Dedicated MUX-Based Transfer // Coder : hydai //----------------------------------------------------- module hw1_B ( input [15:0] data, input [15:0] control, input clk, input rst_n, ...
/*------------------------------------------------------------------------------ * 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...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int a[N]; long long ans[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } if (n == 1) { cout << 1 << << 1 << n ; cout << 0 << n ; cout << 1 << << 1 << n...
#include <bits/stdc++.h> using lint = long long; using ldouble = long double; void solve() { int n, d; std::cin >> n >> d; std::vector<int> vs(n, 1); int diff = n * (n - 1) / 2 - d; if (diff < 0) { std::cout << NO << std::endl; return; } int head = 1; for (int v = n -...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.2 (lin64) Build Fri Jun 26 16:35:25 MDT 2015 // Date : Fri Oct 16 15:22:50 2015 // Host : cascade.andrew.cmu.edu running 64-bit Red H...
#include <bits/stdc++.h> using namespace std; #define vec vector #define PB push_back #define MP make_pair #define MT make_tuple #define F first #define S second using ll = long long int; // watch out for overflows in your code using pii = pair<int,int>; //mt19937 rng(chrono::steady...
/** * 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 "defines.v" `include "HRbridge.v" `timescale 1ns/1ps /*module connectRouter_nobuffer #(parameter addr = 4'b0000) //No. 0 connect router, port 0 ( input `control_w port_l0_i, output `control_w port_l0_o, input `control_w FIFO_l0_i, output `control_w FIFO_l0_o, input bfull_...
/** * 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) 1999 Steven Wilson () // // 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) // ...
#include <bits/stdc++.h> using namespace std; int atoi(string s) { int sol = 0, st = 1; for (int i = 0; i < int(s.size()); i++) { sol += (s[i] - 48) * st; st *= 10; } return sol; } int main() { string a, b; cin >> a >> b; reverse(a.begin(), a.end()); cout << atoi(a) +...
#include <bits/stdc++.h> using namespace std; inline int absi(int a) { return (a > 0) ? a : -a; } const int md = 51123987; inline void add(int &a, int b) { a += b; if (a >= md) a -= md; } int a[155]; int tmp[4]; int nxt[155][4]; int dp[155][55][55][55]; int main(void) { int n, mx; sc...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 10; long long arr[MAX]; int cur[MAX], want[MAX]; int n; vector<vector<int> > adj(MAX); long long ans = 0; array<int, 2> dfs(int node, int par, long long Min) { array<int, 2> a, b; a[0] = 0, a[1] = 0; if (cur[node] != want[no...
/** * 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...
/* * 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 <typename T1, typename T2> inline T1 max(T1 a, T2 b) { return a < b ? b : a; } template <typename T1, typename T2> inline T1 min(T1 a, T2 b) { return a < b ? a : b; } const char lf = n ; namespace ae86 { const int bufl = 1 << 15; cha...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } int main() { ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; vector<vect...
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; cout << 7 + (3 * (k - 1)) << endl; cout << 1 << << 1 << endl; cout << 0 << << 1 << endl; cout << 0 << << 0 << endl; cout << 1 << << 0 << endl; cout << 2 << << 2 << endl; cout << 2 << ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: Case Western Reserve University // Engineer: Matt McConnell // // Create Date: 11:08:00 09/12/2017 // Project Name: EECS301 Digital Design // Design Name: Lab #4 Project // Module Name: ...
/** * 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; namespace IO { const int sz = 1 << 20; char a[sz + 5], b[sz + 5], *p1 = a, *p2 = a, *t = b, p[105]; inline char gc() { return getchar(); if (p1 == p2) p2 = (p1 = a) + fread(a, 1, sz, stdin); return *p1++; } template <class T> inline T read() { ...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long a[505], ar[505], num[505], b[505]; bool used[505]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); long long t; cin >> t; whil...
#include <bits/stdc++.h> using namespace std; const int max_n = 1e3 + 5; const int max_p = 1e3 + 5; const int max_k = 50 + 5; bool a[max_n], b[max_n]; int dp[2][max_p][max_k][max_k]; inline void check_max(int &x, int y) { x = max(x, y); } int main() { int n, p, k; scanf( %d%d%d , &n, &p, &k); ...
#include <bits/stdc++.h> using namespace std; const int L = 0, R = 10000; int n, vote, tot; vector<int> p[110000]; pair<int, int> x[110000]; long long sum[110000]; long long he[4 * 110000]; int num[4 * 110000]; long long ask(int root, int l, int r, int k) { if (k <= 0) return 0; else if ...
#include <bits/stdc++.h> using namespace std; int n, k, mx; int a[4000400], q[4000400], dis[2005]; bool vis[2005]; int head[2005], edgenum; struct Edge { int to, nxt; } edge[4000400]; inline void add(int u, int v) { edge[++edgenum].to = v; edge[edgenum].nxt = head[u]; head[u] = edgenum; ...
#include <bits/stdc++.h> using namespace std; int sum[101000 << 2], lsum[101000 << 2], rsum[101000 << 2], lazy[101000 << 2]; int L[105]; int ans[105]; int max(int a, int b) { return a > b ? a : b; } void pushup(int rt, int len) { sum[rt] = max(sum[rt << 1], sum[rt << 1 | 1]); sum[rt] = max(sum[rt], ...
/* * ClockDivider.v * * ___ _ _ _ _ ___ _ _ ___ * | __._ _ _| |_ ___ _| |_| |___ _| | . | \ |_ _| * | _>| ' ' | . / ._/ . / . / ._/ . | | || | * |___|_|_|_|___\___\___\___\___\___|_|_|_\_||_| * * * Created on : 19/06/2015 * Author : Ernesto Andres Rincon Cruz * Web : ww...
/** * 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 j, k, a, b, s, ss, l, m, n, t, d; long long e, i, c[221]; vector<long long> p[111], q[111], r, v; char w; map<long long, long long> y, z; long long too(long long i, long long j) { long long l = 0, d = 0; for (k = 0; k < q[i].size(); k++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; vector<int> vi(n); for (int i = 0; i < n; ++i) cin >> vi[i]; sort((vi).begin(), (vi).end()); if (n == 1) cout << 0; else if (a <= vi[0]) cout << llabs(vi[n - 2] - a); else if (a >= vi[n - ...
#include <bits/stdc++.h> using namespace std; const int MXN = 1e5 + 1; const int MAXN = 1e3 + 1; const long long INF = 1e16; const int MOD = 65000; const int MAX = 1e2; const double EPS = 1e-9; long long n; long long a, b, c, d, e, first, g, h; int main() { ios_base::sync_with_stdio(0); stri...
////////////////////////////////////////////////////////////////////// //// //// //// adbg_or1k_biu.v //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 5; int a[MAX], run[MAX], ans[MAX]; char s[MAX]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; scanf( %d , &n); scanf( %s , s); for (int i = 0; i < n; ++i) { if (s[i] == 0 ) a[i] = 0; ...
//================================================================================================== // Filename : musb_multiplier.v // Created On : 2014-10-11 21:23:59 // Last Modified : 2015-05-24 20:59:56 // Revision : 1.0 // Author : Angel Terrones // Company : Universidad Simón Bolí...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e7 + 10, maxl = 20, mod = 1e9 + 7, base = 737, inf = 2e18 + 13; int a, n, res[maxn], t[maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> a >> n; for (int i = 2; i < a + n; i++) if (!t[i]) ...
////////////////////////////////////////////////////////////////////// //// //// //// WISHBONE SD Card Controller IP Core //// //// //// //// sd_data_master.v ...
#include <bits/stdc++.h> using namespace std; int main() { map<pair<long long int, long long int>, long long int> m; long long int ans = 0; long long int n, count = 0; cin >> n; string s; for (int i = 1; i <= n; i++) { int l = 0, r = 0; cin >> s; for (int j = 0; j < s.lengt...
#include <bits/stdc++.h> using namespace std; int main() { int a[5][5], i, j, one[2], nr = 0, nc = 0; for (i = 0; i < 5; i++) { for (j = 0; j < 5; j++) { cin >> a[i][j]; if (a[i][j] == 1) { one[0] = i; one[1] = j; } } } if (one[0] == 0 || one[0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--){ string s; cin >> s; stack<char> a, b; int ans = 0; for (auto c: s){ if (c == ( || c == ) )...
/** * 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 <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <vector> #include <map> #include <set> #include <cmath> #include <queue> #include <algorithm> #include <numeric> using namespace std; typedef long long ll; const int N=1e6+5; const int M=1e3+5; const int ...