text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a; map<int, int> mp; int mx = 0; for (int i = 0; i < n; i++) { cin >> a; mp[a]++; } for (auto it : mp) { mx = max(mx, it.second); } cout << n - mx; }
`define ADDER_WIDTH 005 `define DUMMY_WIDTH 128 `define 3_LEVEL_ADDER module adder_tree_top ( clk, isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0, isum0_1_0_1, isum0_1_1_0, isum0_1_1_1, sum, ); input clk; input [`ADDER_WIDTH+0-1:0] isum0_0_0_0, isum0_0_0_1, isum0_0_1_0, isum0_0_1_1, isum0_1_0_0,...
#include <bits/stdc++.h> using namespace std; const int MN = 100000 + 1; int N; char buf[2000]; int main() { scanf( %d , &N); for (int i = 0; i < N; i++) { int a, b; scanf( %s%d%d , buf, &a, &b); if (a >= 2400 && b > a) { puts( YES ); return 0; } } puts(...
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1.0); const long long LINF = (long long)1e18 + 5; const int INF = (int)1e9 + 5; template <class T> T sqr(T x) { return x * x; } template <class T> T abs(T x) { return x < 0 ? -x : x; } template <class T> long long...
#include <bits/stdc++.h> using namespace std; const int step[2] = {-1, 1}, mn = 101000; int n, m, xs, ys, kx, ky, x, y, fx, fy, cnt; long long ans; string st; set<int> T[mn]; void fix(int x, int y, int& fx, int& fy) { if (x == 1) fx = 1; else if (x == n) fx = 0; if (y == 1) f...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 4) { cout << NO n ; return 0; } cout << YES n ; if (n >= 4 && !(n & 1)) { int ones = 0; for (int i = 5; i < n; i += 2) { printf( %d - %d = 1 n , i + 1, i); ones++; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 05/22/2015 09:35:04 AM // Design Name: // Module Name: pwm // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revisi...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { while (b) { swap(a %= b, b); } return a; } long long n, m, x, y, a, b, g; double dist1(long long curstep) { long long l1 = a / g * curstep; long long l2 = b / g * curstep; long long x1 = max(1...
/** * 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...
/* * These source files contain a hardware description of a network * automatically generated by CONNECT (CONfigurable NEtwork Creation Tool). * * This product includes a hardware design developed by Carnegie Mellon * University. * * Copyright (c) 2012 by Michael K. Papamichael, Carnegie Mellon University * * ...
`timescale 1ns/1ns module inport_basic_tb(); reg clka; reg rsta; reg [1:0] diff_pair_din; reg [47:0] channel_din; wire request_dout; wire x_hit_dout; wire y_hit_dout; wire [3:0] x_addr_dout; wire [3:0] y_addr_dout; wire [39:0] payload_dout; // clk generator always begin #(10) ...
#include <bits/stdc++.h> using namespace std; long long dp[1020][600], mod = (1000000007); long long solve(int n, int m, int k) { if (n < 2 * k - 1 or m < 2 * k - 1) return 0; if (n <= 0 or m <= 0) return !k; if (!k) return 1; if (n == 2 * k - 1) { if (dp[m][k] != -1) return dp[m][k]; ...
/** * 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...
// bsg_rp_clk_gen_coarse_delay_element // // (o is inverting on even start_tap_p // worst_o is non-inverting) // // o contains controllably delayed signal // worst_o contains worst-case delayed signal (for delay matching) // // // we use sed to substitute parameters because the netlist reader // does not...
// ============================================================================= // COPYRIGHT NOTICE // Copyright 2000-2002 (c) Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // This confidential and proprietary software may be used only as authorised by // a licensing agreement...
#include <bits/stdc++.h> using namespace std; vector<long long> v[3000]; long long h[200000], pw[200000]; string st, st1, st2; long l1, l2, l, ans, fl, g1[20000], g2[20000]; long long gethash(long a, long b) { return (h[b + 1] - h[a]) * pw[st.size() - b + 1]; } int main() { cin >> st; cin >>...
/** * 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; set<pair<int, int> > V; int p[102345]; int main() { int n, m, x, y; scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { scanf( %d%d , &x, &y); V.insert(make_pair(x, y)); V.insert(make_pair(y, x)); } for (int i = 0; i < n; i++)...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2013 Xilinx Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // // ____ ___ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Versi...
// // 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) // ...
// -------------------------------------------------------------------------------- //| Avalon Streaming Timing Adapter // -------------------------------------------------------------------------------- `timescale 1ns / 100ps module master_0_timing_adt ( // Interface: clk input clk...
//Legal Notice: (C)2017 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...
/** * 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 a[n]; vector<pair<int, int>> v; set<int> s; for (int i = 0; i < n; i++) { cin >> a[i]; v.push_back(make_pair(a[i], i)); s.insert(a[i]); } int m = s.size(); sort(v.begin(), v.end()); ...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( -O3 ) int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int a1, a2, k1, k2, n; cin >> a1 >> a2 >> k1 >> k2 >> n; if (k1 > k2) { swap(a1, a2); swap(k1, k2); } if (n <= a1 ...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5; vector<vector<pair<long long, long long> > > dis(maxn); long long flag[maxn]; long long c1, c2; bool ok; void dfs(long long index, long long p) { flag[index] = p; for (long long i = 0; i < dis[index].size(); i++) { ...
#include <bits/stdc++.h> using namespace std; int n, start, x; pair<int, int> ask(int v) { printf( ? %d n , v); fflush(stdout); int value, nxt; scanf( %d %d , &value, &nxt); return pair<int, int>(value, nxt); } const int RANDOM_Q = 1000; int main() { srand(time(NULL)); scanf( %d ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, p[N]; void solve(int n) { if ((n & 1) && (n - 1) % 4) { puts( -1 ); return; } if (!(n & 1) && n % 4) { puts( -1 ); return; } if (n & 1) p[(n + 1) >> 1] = (n + 1) >> 1; for (int i = (1); i ...
module wasca ( abus_slave_0_abus_address, abus_slave_0_abus_chipselect, abus_slave_0_abus_read, abus_slave_0_abus_write, abus_slave_0_abus_waitrequest, abus_slave_0_abus_interrupt, abus_slave_0_abus_addressdata, abus_slave_0_abus_direction, abus_slave_0_abus_muxing, abus_slave_0_abus_disableout, abus_slave_...
// /** // * This Verilog HDL file is used for simulation and synthesis in // * the chaining DMA design example. It could be used by the software // * application (Root Port) to retrieve the DMA Performance counter values // * and performs single DWORD read and write to the Endpoint memory by // * bypassing the DMA...
#include <bits/stdc++.h> using namespace std; template <typename T> inline int Chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; } template <typename T> inline int Chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; } template <typename T> inline T read() { T sum = 0, fl = 1; char ch = get...
#include <bits/stdc++.h> using namespace std; void sove() {} int main() { int n; cin >> n; int nums[n]; for (int i = 0; i < n; ++i) { cin >> nums[i]; } for (int i = 0; i < n / 2; i += 2) { int temp = nums[i]; nums[i] = nums[n - i - 1]; nums[n - i - 1] = temp; } ...
#include <bits/stdc++.h> using namespace std; namespace Dango { const int MAXN = 200005, INF = 0x3f3f3f3f; struct Edge { int from, to, dis, id; bool operator<(const Edge b) const { return dis < b.dis; } } e[MAXN]; struct tree { int l, r, data; bool tag; } t[MAXN << 2]; int n, m; int he...
// (C) 2001-2015 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated doc...
/* Copyright (c) 2019 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; vector<long long> blame(1002, 0); vector<bool> visited(1002, false); long long dfs(long long u) { if (visited[u]) return u; visited[u] = true; return dfs(blame[u]); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);...
#include <bits/stdc++.h> using namespace std; template <typename T> T scani(T &n) { n = 0; bool negative = false; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) negative = true; c = getchar(); } while (c >= 0 && c <= 9 ) { n = n * 10 + c - 48; c =...
#include <bits/stdc++.h> using namespace std; const int N = 300005; int n, k, i, a, b, da, db, u, v, head[N], Next[N * 2], adj[N * 2], j, dp[N], ans, dd, t; void Push(int u, int v) { Next[++k] = head[u]; head[u] = k; adj[k] = v; } void dfs(int i, int fa) { int j, mxx = 0; dp[i] = 0...
#include <bits/stdc++.h> using namespace std; int v1, v2, v3, vm; inline long long readll() { int sign = 1; char c; for (c = getchar(); !isdigit(c); c = getchar()) if (c == - ) sign = -sign; long long res = c - 0 ; for (c = getchar(); isdigit(c); c = getchar()) res = res * 10 + c - 0 ...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: sfifo_66x128.v // Megafunction Name(s): // scfifo // ============================================================ // *******************...
/* * Copyright (c) 2001 Uwe Bonnes * * 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) * any la...
#include <bits/stdc++.h> using namespace std; const int MAXN = 110; const int MOD = 1e9 + 7; long long n, k, dp[MAXN][MAXN][MAXN], local[MAXN][MAXN]; vector<int> adj[MAXN]; void add(long long& v, long long u) { v = (v + u) % MOD; } void dfs(int v, int par = -1) { dp[v][1][0] = dp[v][0][1] = 1; for...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; char s[maxn]; int vis[maxn]; pair<char, int> sta[maxn]; int main() { scanf( %s , s); int o = -1; for (int i = 0; s[i]; i++) { if (s[i] == 0 && o >= 0 && sta[o].first == 1 ) { vis[sta[o].second] = 1; ...
// // 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 main() { int t; cin >> t; while (t--) { string s; cin >> s; int ans = -1; for (int i = 0; i < s.size(); i++) { if (s[i] == R ) { ans = i + 1; break; } } if (ans == -1) { cou...
#include <bits/stdc++.h> using namespace std; int main() { int tc, cs = 1; scanf( %lld , &tc); while (tc--) { long long a, b, c, d; scanf( %lld %lld , &a, &b); scanf( %lld %lld , &c, &d); if ((b - a) % (c + d) == 0) cout << (b - a) / (c + d) << endl; else co...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); multiset<int> s; s.insert(0); int q; cin >> q; while (q--) { char c; int x; cin >> c >> x; if (c == + ) { s.insert(x); } else if (c == - ) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2009 by Wilson Snyder. module t; //Several simulators don't support this. //typedef struct pack2; // Forward declaration typedef struct packed { // [3:0] bit b3; ...
/** * 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 n; int a[109]; int ans; int s; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); s += a[i]; ans = max(ans, a[i]); } for (;; ans++) { if (ans * n - s > s) { printf( %d , ans); ...
#include <bits/stdc++.h> using namespace std; void __print(long long x) { cerr << x; } void __print(long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __pr...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const long long mod = 1e9 + 7; const long long N = 1e5 + 5, K = 105; const int si = (1 << 20); const long long add = 1e4; const long long M = 100 + 5; const double INFdb = 1e10; int n; vector<int> v[N]; bool check[N]; int ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, x, y, k; cin >> n >> m; long long a[n], b[m]; cin >> x >> k >> y; for (long long i = 0; i < n; i++) cin >> a[i]; for (long long i = 0; i < m; i++) cin >> b[i]; vector<long long> adj[n]; long long z[n]; 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 law...
#include <bits/stdc++.h> using namespace std; int ans0[1000001]; int tail = 1; int a[1001]; int n, m; int ans = 0; int main() { int i, j, k; int id; int xx, yy; int temp; scanf( %d , &n); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { scanf( %d , &temp); ...
`include "bsg_nonsynth_dramsim3.svh" `ifndef dram_pkg `define dram_pkg bsg_nonsynth_dramsim3_hbm2_8gb_x128_pkg `endif module testbench (); // clock logic clk; bsg_nonsynth_clock_gen #(.cycle_time_p(`dram_pkg::tck_ps)) clkgen (.o(clk)); // reset logic reset; bsg_nonsynth_reset_gen #...
/** * 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...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: bg4_new.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ================================...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<pair<int, int>> v; int row[1010] = {0}, col[1010] = {0}; char g[1010][1010]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { cin >> g[i][j]; if (g[i][j] == * ) row[i]++...
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; if (s == monday && (t == thursday || t == wednesday || t == monday )) cout << YES ; else if (s == tuesday && (t == friday || t == thursday || t == tuesday )) cout << YES ; ...
/** * 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...
////////////////////////////////////////////////////////////////////////////////// // // Author : Praveen Kumar Pendyala // Create Date : 05/27/13 // Modify Date : 16/01/14 // Module Name : alu_puf // Project Name : PDL // Target Devices : Xilinx Vertix 5, XUPV5 110T // Tool v...
/* * 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 T> void _dbg(const char* _s, T _h) { cerr << _s << = << _h << n ; } template <typename T, typename... Ts> void _dbg(const char* _s, T _h, Ts... _t) { int _b = 0; while (((_b += *_s == ( ) -= *_s == ) ) != 0 || *_s != , ) c...
#include <bits/stdc++.h> using namespace std; int A[55]; int main() { int n; long long int m; cin >> n >> m; if (n == 1) { printf( %d n , 1); return 0; } long long int tot = 1LL << (n - 1); int l = 1; int r = n; for (int i = 1; i < n + 1; i++) { if (m > tot / ...
//***************************************************************************** // (c) Copyright 2008-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 // ...
`timescale 1ns / 1ps `include "bch_defs.vh" module tb_mult_m(); `include "bch.vh" parameter M = 8; integer i; integer j; reg [M-1:0] s1 = 0; reg [M-1:0] s2 = 0; reg [M-1:0] p1 = 0; reg [M-1:0] pd = 0; reg [M-1:0] p2d = 0; reg [M-1:0] p2 = 0; wire smm_out; wire smm_out1; reg serial_s2 = 0; wire [M-1:0]...
#include <bits/stdc++.h> using namespace std; struct mat { int num[4][4]; }; mat m1 = {{{1, 1, 1, 0}, {1, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}}, m2 = {{{1, 1, 0, 1}, {1, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}}; mat mult(mat &a, mat &b) { mat ret; for (int i = 0; i < 4; i++) for (int j ...
#include <bits/stdc++.h> using namespace std; const int INFint = 2147483647; const long long INF = 9223372036854775807ll; const long long MOD = 1000000007ll; char f[2020][2020]; int n, m; bool c(int x, int y, int d, int cnt) { int cur = 0; cerr << x << << y << endl; if (x > 0 && y > 0 && 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 "defines.v" `timescale 1ns/1ps module tb( ); wire injrd, injack; reg clk, rst; wire `control_w port0_co, port1_co, port2_co, port3_co, port4_co; brouter r( .clk(clk), .rst(rst), .port0_ci(144'h0), .port0_co(port1_co), .port1_ci(144'h0), .port1_c...
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int ret = 0, f = 1; while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) ret = ret * 10 + ch - 0 , ch = getchar(); return ret * f; } const...
#include <bits/stdc++.h> using namespace std; inline long long sqr(long long x) { return (x * x); } inline long long dist(pair<long long, long long> a, pair<long long, long long> b) { return sqr(a.first - b.first) + sqr(a.second - b.second); } int main() { vector<pair<long long...
#include <bits/stdc++.h> using namespace std; const long long int mxn = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; while (t--) { long long int i, j, k, n, m, x; cin >> n >> x >> k; vector<long long int> a(n); for (i = 0; i < n; i++...
#include <bits/stdc++.h> using namespace std; int main() { int k, l, m, n, d; int cont = 0; cin >> k >> l >> m >> n >> d; cont = d; if (k == 1 || l == 1 || m == 1 || n == 1) { cout << d << endl; } else { for (int i = 1; i <= d; i++) { if ((i % k != 0) && (i % l != 0) && (...
#include <bits/stdc++.h> using namespace std; int p, x, y; queue<int> q; int mmap[100000]; bool check(int s) { int i = s / 50 % 475; for (int j = 0; j < 25; ++j) { i = (i * 96 + 42) % 475; if (26 + i == p) return true; } mmap[s] = 1; return false; } int main() { cin >> ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; while (cin >> n >> m) { vector<int> f(n); vector<int> v[100005]; vector<int> b(m); vector<int> a(m); vector<int> used(100005, 0); for (int i = 0; i < n; i++) { cin >> f[i]; v[f[i]].push_b...
/* Copyright 2010 David Fritz, Brian Gordon, Wira Mulia 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, either version 3 of the License, or (at your option) any later version. ...
#include <bits/stdc++.h> using namespace std; char str1[200002], str2[200002]; const int K = 1024; int aw[200002]; int bw[200002]; char bit[1 << 16]; short cnt[200002 / K + 1][200002]; int main() { gets(str1); gets(str2); int l1 = strlen(str1), l2 = strlen(str2); for (int i = 0; i < l1; ...
#include <bits/stdc++.h> #pragma comment(linker, /stack:247474112 ) #pragma GCC optimize( Ofast ) using namespace std; const long long maxn = 2e5 + 10; long long mx[maxn], val[maxn], sum[maxn]; vector<long long> g[maxn]; long long pass[maxn]; bool ok = 0; long long ans = LLONG_MIN; void dfs(long lo...
#include <bits/stdc++.h> using namespace std; int n, m, x, y, ans; int p[100010], q[100010], mn[100010]; vector<int> t[100010], v[100010]; bool flag[100010]; inline int dist(int x, int y) { return abs(p[x] - q[y]); } int main() { scanf( %d%d%d%d , &n, &m, &x, &y); memset(mn, 63, sizeof(mn)); 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() { int n, k; scanf( %d %d , &n, &k); for (int i = 0; i < k; i++) { if (n % 10 == 0) { n /= 10; } else { n--; } } printf( %d n , n); }
/** # SmallBpf - 2-pole IIR Bandpass Filter # Small 2-Pole IIR band-pass filter, made using just adders and bit shifts. Set the frequency using the K0_SHIFT and K1_SHIFT parameters. It can be slowed down by strobing the `en` bit to run at a lower rate. By using power of two feedback terms, this filter is alsways st...
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; if (n == 1 && t == 10) { cout << -1 << endl; return 0; } if (t == 10) { for (int i = 1; i < n; i++) cout << 1; cout << 0 << endl; return 0; } if (n == 1) { cout << t <<...
/* * 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...
#include <bits/stdc++.h> using namespace std; template <typename Abel> struct BIT2D { vector<vector<Abel>> dat[4]; BIT2D(int h, int w) { for (int which = 0; which < 4; which++) dat[which].assign(h + 1, vector<Abel>(w + 1)); } inline void sub_add(int which, int a, int b, Abel x) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; int main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; while (t--) { string s; cin >> s; vector<int> r; for (string t : { twone , one , two }) { for (size_t pos =...
/** * 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-2022 F4PGA 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 // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed...
/** * 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 "elink_constants.vh" module erx_clocks (/*AUTOARG*/ // Outputs rx_lclk, rx_lclk_div4, rx_active, erx_nreset, erx_io_nreset, // Inputs sys_nreset, soft_reset, tx_active, sys_clk, rx_clkin ); //Frequency Settings (Mhz) parameter FREQ_RXCLK = 300; parameter FREQ_IDELAY =...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long i, x; vector<long long> v; for (i = 0; i < n; i++) { cin >> x; v.push_back(x); } long long ans = 0; for...
#include <bits/stdc++.h> using namespace std; const int N = 3e6 + 7; long long int a[N], b[N], c[N], tree[N], lazy[N], cnt, sum, s2, mx; vector<long long int> v, u; vector<pair<long long int, long long int>> vp; map<long long int, long long int> mp; bool vis[111111]; pair<long long int, long long int> 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...
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; void pre() {} void solve() { long long k, b, n; cin >> k >> b >> n; long long arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; map<long long,...
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979; const double PI2 = 6.28318530717958; const double PId2 = 1.570796326794895; inline long long pw(long long n, int p) { long long ans = 1; for (int i = 0; i < p; i++) ans *= n; return ans; } inline vector<int> Read...