text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int pct(int x) { return __builtin_popcount(x); } int pct(long long x) { return __builtin_popcountll(x); } int bt(int x) { return 31 - __builtin_clz(x); } int bt(long long x) { return 63 - __builtin_clzll(x); } int cdiv(int a, int b) { return a / b + !(a < 0 || a...
#include <bits/stdc++.h> using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline int dcmp(long double x) { return x < -1e-12 ? -1 : (x > 1e-12); } template <class T> ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2e5 + 5; long long res = 0, mx = 0; long long sub[MAX_N]; int custo[MAX_N]; vector<vector<int> > g(MAX_N); void dfs(int node, int p = -1, int d = 0) { res += 1LL * d * custo[node]; sub[node] = custo[node]; for (auto to : g[node]) ...
/* I expected that p1=p2. But the generated output looks like: Icarus Verilog version 0.7 Copyright 1998-2003 Stephen Williams $Name: $ 0 p1=x p2=StX 5 p1=1 p2=StX 10 p1=0 p2=St0 15 p1=1 p2=St0 20 p1=0 p2=St0 ...
/* * 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 N = 1e5 + 5; inline int read() { int x = 0, w = 1; char ch = 0; while (ch < 0 || ch > 9 ) { ch = getchar(); if (ch == - ) w = -1; } while (ch <= 9 && ch >= 0 ) { x = (x << 1) + (x << 3) + ch - 0 ; ch = getc...
/* * 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 maxn = 1e6 + 2; int t, n, m, U, V, sum, ans1, ans2; bool kt[maxn], ch[maxn]; struct T { int c, id; }; vector<T> a[maxn]; vector<int> s[maxn]; void Enter() { cin >> m >> n; for (int i = 1; i <= m; i++) { a[i].clear(); s[i]....
//Legal Notice: (C)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 associate...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: LOG_Table.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ==================...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 4e5 + 10; vector<int> ans[N]; vector<int> v[N]; int tot; int vis[N]; int cnt = 0; void dfs(int x) { vis[x] = 1; ans[cnt++ / tot].push_back(x); for (auto &y : v[x]) { if (vis[y]) continue; ...
#include <bits/stdc++.h> using namespace std; const int MAX = 105; int main() { ios::sync_with_stdio(false); int n; cin >> n; int x; cin >> x; for (int i = 0; i < n; i++) { x = 7 - x; int a, b; cin >> a >> b; if (a == x || b == x || 7 - a == x || 7 - b == x) { ...
//Instruction decoder `include "verilog/mips_instr_defines.v" module decode ( input wire[31:0] instr_dec_i, input wire sign_ext_i, output wire[4:0] rt_dec_o, output wire[4:0] rs_dec_o, output wire[4:0] rd_dec_o, output wire[5:0] op_dec_o, ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops ) using namespace std; const int max_n = 100011, inf = 1000111222; const int mod = 1000000007; int n, m, fenv[333][333]; map<int, vector<pair<int, int>>> mp; pair<int, int> a[max_n]; int sum(int tt[], int r) { int result = 0; f...
`timescale 1ns / 1ps `define SIMULATION module peripheral_pwm_TB; reg clk; reg rst; reg reset; reg start; reg [15:0]d_in; reg cs; reg [1:0]addr; reg rd; reg wr; wire [15:0]d_out; reg micData; peripheral_pwm uut (.clk(clk) , .rst(reset) , .d_in(d_in) , .cs(cs) , .addr(addr) , ....
#include <bits/stdc++.h> using std::cin; using std::cout; using std::deque; using std::endl; using std::map; using std::max; using std::min; using std::multiset; using std::pair; using std::queue; using std::set; using std::sort; using std::stack; using std::string; using std::vector; in...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: Jorge Sequeira Rojas // // Create Date: 08/31/2016 04:06:16 PM // Design Name: Recursive Parameterized KOA // Module Name: RecursiveKOA // Project Name: FPU // Target Devices: Artix 7 // To...
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5; struct Ans { long long a, b, c; }; void solve() { long long a, b, c; cin >> a >> b >> c; long long ans = 1e9; auto x = Ans{a, b, c}; for (long long aa = 1; aa <= 2 * a; aa++) { for (long long bb = aa; bb <...
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a...
/* * Attributes: * REFCLOCK_SECOND_COUNTER: Number of clock_ref perioss in a second * By default it is set for 100MHz * * Ports: * clock_ref: (Input): Known Clock (For Example 100 MHz) * rst (Input): Reset * clock_input (Output): Clock To Measure * value (Output): Number of ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 7; const long long mod = 1e9 + 7; int a[N]; int main() { int n; cin >> n; for (int i = (1); i < (n + 1); ++i) scanf( %d , a + i); sort(a + 1, a + 1 + n); if (n == 0) { cout << YES n1 n1 n3 n3 n ; } else if (n == 1...
#include <bits/stdc++.h> using namespace std; string a, b; int ans = 0; vector<int> A, B; string cp(string s, int n) { string ans = s; for (int i = 1; i < n; i++) ans += s; return ans; } int main() { cin >> a >> b; for (int i = 1; i <= a.size(); i++) if (a.size() % i == 0 && cp(a...
#include <bits/stdc++.h> using namespace std; long long t, x, y, p, q; bool check(long long mid) { long long pp = p * mid; long long qq = q * mid; if (pp - x < 0 || qq - y < 0) return false; return (pp - x <= qq - y); } int main() { scanf( %lld , &t); while (t--) { scanf( %lld %l...
`timescale 1ns / 1ns `define HALT 10'b00_0000_0000 `define EXEC 3'b100 module opc5lstb(); reg [15:0] mem [ 65535:0 ]; reg clk, reset_b, interrupt_b, int_clk, m1, clken; wire [15:0] addr, data1; wire rnw, vda, vpa; wire ceb = 1'b0; wire oeb = !rnw; reg [15:0] data0 ; ...
#include <bits/stdc++.h> using namespace std; inline long long mod(long long n, long long m) { long long ret = n % m; if (ret < 0) ret += m; return ret; } long long gcd(long long a, long long b) { return (b == 0LL ? a : gcd(b, a % b)); } long long exp(long long a, long long b, long long m) {...
#include <bits/stdc++.h> using namespace std; int A[26]; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; for (int i = 0; i < n; i++) s[i] = tolower(s[i]); for (int i = 0; i < n; i++) { if (!A[s[i] - a ]) { A[s[i] - a ] = 1; ++cnt; } } ...
/* * 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...
module inflight_instr_counter (/*AUTOARG*/ // Outputs no_inflight_instr_flag, max_inflight_instr_flag, // Inputs clk, rst, retire_vgpr_1_en, retire_branch_en, retire_sgpr_en, issued_en ); // Inputs and outputs input clk,rst, retire_vgpr_1_en, retire_branch_en, retire_sgpr_en, issued_en; ...
/* This file is part of JT12. JT12 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. JT12 program is distribute...
/** * 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 t = 1; while (t--) { long long l, r, i, sum = 0; deque<long long> a; a.push_back(4); a.push_back(7); cin >> l >> r; for (i = l; i <= r;) { if (i <= a.front()) { sum += a.front(); i+...
/* * 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...
// Created by aadi // Never give up , Miracles never happen in real life. #include<bits/stdc++.h> using namespace std ; #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL); #define int long long int #define MIN LLONG_MIN #define MAX LLONG_MAX #define set1D(a,val,n) { for(int i=0;i<n;i...
/** * This is written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time uni...
module usb_packet_fifo ( input reset, input clock_in, input clock_out, input [15:0]ram_data_in, input write_enable, output reg [15:0]ram_data_out, output reg pkt_waiting, output reg have_space, input read_enable, input skip_packet ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a, b; if (n == 2) { cout << 2 << endl; } else cout << 1 << endl; return 0; }
//***************************************************************************** // (c) Copyright 2008-2009 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // ...
#include <bits/stdc++.h> using namespace std; long long int a, b; stack<long long int> st; bool dfs(long long int n) { if (n > b) { return false; } if (n == b) { return true; } bool a1, a2; a1 = dfs(n * 2); if (a1) { st.push(n * 2); return true; } a2 =...
#include <bits/stdc++.h> const int INF = 107374182; using namespace std; int n, k; int ans[100005][2]; struct sa { int ma, mi; } segTree[1000000]; void build(int l, int r, int root) { if (l == r) { if (l != n + 1) { scanf( %d , &segTree[root].ma); segTree[root].mi = segTree[r...
module latch_id_ex( input clock , input reset , input [ 5:0] stall , input [31:0] id_instruction , output reg [31:0] ex_instruction , input [ 7:0] id_operator , ou...
#include <bits/stdc++.h> using namespace std; int main() { long long int l, r; cin >> l >> r; if (r - l < 2) { printf( -1 ); return 0; } if (l & 1) l++; if (l + 2 > r) { printf( -1 ); return 0; } cout << l << << l + 1 << << l + 2 << endl; return 0;...
/** * 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> long long res; int max; const int N = 205; int f[N], tt[N], cnt, next[N]; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } void dfs(int u) { cnt++; f[u] =...
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ...
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a < b) return b; return a; } long long min(long long a, long long b) { if (a < b) return a; return b; } bool okay(vector<long long> &v, long long d, long long k) { long long sum = 0; priority_...
///////////////////////////////////////////////////////////// // Created by: Synopsys DC Ultra(TM) in wire load mode // Version : L-2016.03-SP3 // Date : Sun Nov 20 02:49:29 2016 ///////////////////////////////////////////////////////////// module ACA_I_N16_Q4 ( in1, in2, res ); input [15:0] in1; input [15...
#pragma comment(linker, /STACK:256777216 ) #define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <cstring> #include <vector> #include <queue> #include <bitset> #include <stack> #include <deque> #include <set> #include <unordered_set> #include...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ...
module TailLight( input reset, left, right, clk, output LC, LB, LA, RA, RB, RC ); parameter ST_IDLE = 3'b000; parameter ST_L1 = 3'b001; parameter ST_L2 = 3'b010; parameter ST_L3 = 3'b011; parameter ST_R1 = 3'b100; parameter ST_R2 = 3'b101; parameter ST_R3 = 3'b110; reg [2:0] state, next_state; always @(posedge 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; long long head[200010], cnt; class littlestar { public: long long to, nxt; void add(long long u, long long v) { to = v; nxt = head[u]; head[u] = cnt; } } star[400010]; long long n, f[200010], g[200010], h[200010]; void dfs(long l...
#include <bits/stdc++.h> using namespace std; void solve() { int n, d = 0; long long x, amount; char sign; int quantity; cin >> n >> amount; for (int i = 0; i < n; i++) { cin >> sign >> quantity; if (sign == + ) amount += quantity; else if (amount < quantity) ...
// DEFINES `define BITS 2 // Bit width of the operands module bm_if_collapse(clock, reset_n, a_in, b_in, c_in, d_in, out0, out2, out1); // SIGNAL DECLARATIONS input clock; input reset_n; input [`BITS-1:0] a_in; input [`BITS-1:0] b_in; input c_in; input d_in; output [`BITS-1:0] out0; o...
#include <bits/stdc++.h> int main() { int i, j, k, l, y, m, n; char s[101], t[101]; scanf( %d , &y); for (i = y + 1;; i++) { n = i; j = n % 10; n = n / 10; k = n % 10; n = n / 10; l = n % 10; n = n / 10; if (n != l && n != k && n != j && l != k && l != j...
module TrafficLight( input x, clock, clear, output reg [1:0] MainStreet, SideStreet ); localparam S0 = 3'd0; localparam S1 = 3'd1; localparam S2 = 3'd2; localparam S3 = 3'd3; localparam S4 = 3'd4; localparam RED = 2'd0; localparam YELLOW = 2'd1; localparam GREEN = 2'd2; reg [2:0] state, next_state; always @(posedg...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <typename T> void etch(T V) { for (auto x : V) cout << x << ; cout << n ; } vector<string> vec_splitter(string s) { s += , ; vector<string> res; while (!s.empty()) { ...
module main; reg enable, bar_a, bar_b, val_in; reg [7:0] scon; reg val; //(* ivl_synthesis_on *) always @(val_in or bar_a or bar_b or scon[7:6] or enable) begin if (scon[7:6]==2'b10) begin val = 1'b1; end else if (enable) begin val = val_in; end else begin val = !bar_b & bar_a; end...
#include <bits/stdc++.h> using namespace std; const int __ = 1000000; bool pri[__ + 5]; int num[__ + 5]; void era() { int x = (int)sqrt(__ + 0.01); for (int i = 2; i <= x; i++) if (!pri[i]) { num[++num[0]] = i; for (int j = i * i; j <= __; j += i) pri[j] = true; } for (...
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<long long int, long long int> > v; long long int n, x, c = 0; cin >> n; for (int i = 0; i < n; i++) { long long int a, b; cin >> a >> b; v.push_back(make_pair(a, b)); } sort(v.begin(), v.end()); long...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010 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 distribut...
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ...
// 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 : Wed Mar 01 09:52:03 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); vector<vector<int>> sum_points(n + m), diff_points(n + m); vector<int> x(k), y(k); for (int i = 0; i < k; ++i) { scanf( %d%d , &x[i], &y[i]); sum_points[x[i] + y[i]].push_back(i); ...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 3; long long n, ans, sz[N], up[N], down[N]; vector<long long> q[N]; void dfs1(long long v, long long p) { sz[v] = 1; for (auto i : q[v]) { if (i != p) { dfs1(i, v); sz[v] += sz[i]; down[v] += down[i] ...
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f; using namespace std; int yh() { int ret = 0; bool f = 0; char c = getchar(); while (!isdigit(c)) { if (c == EOF) return -1; if (c == - ) f = 1; c = getchar(); } while (isdigit(c)) ret = (ret << 3) + (ret << 1) + (c ^ 4...
#include <bits/stdc++.h> const int inf = 1e9 + 7; const int mod = 1e9 + 7; using namespace std; int main() { long long N; cin >> N; long long cnt = 1; long long now = 10; while (now <= N) { now *= 10; cnt++; } long long ans = (cnt - 1) * 9; long long n = cnt - 1; ...
/*! btcminer -- BTCMiner for ZTEX USB-FPGA Modules: HDL code for ZTEX USB-FPGA Module 1.15b (one double hash pipe) Copyright (C) 2011-2012 ZTEX GmbH http://www.ztex.de This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as ...
module autolisp_top (/*AUTOARG*/); /* autolisp_inst AUTO_TEMPLATE ( .\(.*\)A (\1_@"(eval tense)"_A), .\(.*\)B (\1_@"(eval tense)"_B), ); */ /* AUTO_LISP(setq tense "is") */ autolisp_inst AUTOLISP_INST_I0 (/*AUTOINST*/ // Outputs .result (resu...
(** Extraction : tests of optimizations of pattern matching *) (** First, a few basic tests *) Definition test1 b := match b with | true => true | false => false end. Extraction test1. (** should be seen as the identity *) Definition test2 b := match b with | true => false | false => false end. Ext...
/* * 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 N = 10000; const long double pi = acos(-1.0); int n, sum[2020]; long long bin[2020], f[2020][2020]; char s[2020]; int read() { int x = 0, f = 1; char ch = getchar(); while ((ch < 0 ) || (ch > 9 )) { if (ch == - ) f = -1; ch...
module IDEX_Reg ( input clk, input flush, input stall, input [5-1:0] EX_ctrl_i, output [5-1:0] EX_ctrl_o, input [2-1:0] MEM_ctrl_i, output [2-1:0] MEM_ctrl_o, input [2-1:0] WB_ctrl_i, output [2-1:0] WB_ctrl_o, input [32-1:0] Rs_data_i, output [32-1:0] Rs_data_o, input [32-1:0] Rt_data_i, o...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; if (n & 1) cout << ((n / 2) + 1) << n ; else cout << (n / 2) << n ; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; whi...
#include <bits/stdc++.h> using namespace std; char str[100050]; char a[5000], b[5000]; int len1, len2, len3; bool pp(int s1, int s2) { while (s2 <= len2) { if (str[s1] != a[s2]) return false; s1++, s2++; } return true; } bool pp2(int s1, int s2) { while (s2 <= len3) { if ...
#include <bits/stdc++.h> int main() { char a[21]; char b[21]; int s1[21]; int s2[21]; int lena; int lenb; while (scanf( %s%s , &a, &b) != EOF) { lena = strlen(a); for (int i = 0; i < lena; i += 2) { if (a[i] == [ && a[i + 1] == ] ) s1[i / 2] = 2; el...
#include <bits/stdc++.h> #define ll long long #define mod 1000000007 using namespace std; ll dp[10][200001]; string s = abcdefghijklmnopqrstuvwxyz ; ll findgcd(ll a, ll b) { if (b == 0) { return a; } return findgcd(b, a % b); } bool ispalindrome(string s) { int n...
/* * Milkymist 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 in ...
#include <bits/stdc++.h> int len, p; char s[111111], buf[111111]; void add(char ch) { buf[len++] = ch; } void out() { printf( < ); for (int i = 0; i < len; i++) printf( %c , buf[i]); printf( > n ); len = 0; } int main() { gets(s); len = p = 0; for (p = 0; s[p]; p++) { if (s...
#include <bits/stdc++.h> const int p = 998244353; const int inv2 = 499122177; const int MAXN = 140000; inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) { if (ch == - ) f = -1; ch = getchar(); } do x = (x * 10 + ch - 48) % p, ch ...
#include <bits/stdc++.h> using namespace std; inline void Fail() { printf( 0 ); exit(0); } const int maxn = 100005; int n, l, r, mn, id, ans, from, to, cnt, clen, mxdep, mid; vector<pair<int, int> > edge[maxn]; pair<int, pair<int, int> > cur[maxn]; vector<int> beauty; int sz[maxn], u[maxn], v[...
#include <bits/stdc++.h> using namespace std; int n, m, d[1002], s[1002], t, f, sum, k; int main() { cin >> m >> k; for (int i = 2; i <= m + 1; i++) { cin >> d[i]; } for (int i = 1; i <= m; i++) { cin >> s[i]; } for (int i = 1; i <= m; i++) { f += s[i]; t = max(t, s...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;...
#include <bits/stdc++.h> using namespace std; string a, b, c, d; int pref[123456]; int main() { int n, k; cin >> n >> k; string s; cin >> s; s = . + s; for (int i = 1; i < s.length(); i++) { pref[i] = pref[i - 1]; if (s[i] == 0 ) pref[i]++; } int ans = INT_MAX; ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: bw_io_hstl_pad.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it an...
/* Copyright 2005-2006, Technologic Systems * All Rights Reserved. * * Author(s): Jesse Off <> */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License v2 as published by * the Free Software Foundation. * * This program...
#include <bits/stdc++.h> using namespace std; int main() { long long n; int m; cin >> n >> m; long long cnt = 0; if (m == 1) { cout << n * n << endl; return 0; } if (m < n) { for (int i = 1; i <= m; i++) for (int j = 1; j <= m; j++) if ((i * i + j * j)...
/* Copyright (c) 2014-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; while ((a = a % b) != 0) { swap(a, b); } return b; } long long mpow(long long x, long long y, long long m) { long long res = 1; while (y > 0) { ...
/** * 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 flag = 0; char s[6][6]; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) cin >> s[i][j]; for (int i = 0; i < 4; i++) { if (flag) break; for (int j = 0; j < 4; j++) { if (s[i][j] == x && s[i][j + 1] == ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, d, a, b; cin >> n >> d >> a >> b; vector<pair<long long, int> > v(n); for (int i = 0; i < n; i++) { long long x, y; cin >> x >> y; v[i].first = x * a + y * b; v[i].second = i + 1; } sort(v.begin()...
#include <bits/stdc++.h> struct Edge { int u, v; int w; }; struct RowEdges { int sum; std::vector<Edge> vs; RowEdges() : sum(0) {} Edge &back() { return vs.back(); } Edge &front() { return vs.front(); } Edge &operator[](int i) { return vs[i]; } int size() { return (int)vs.size(...
//------------------------------------------------------------------------------ // Title : 10/100/1G Ethernet FIFO // Version : 1.2 // Project : Tri-Mode Ethernet MAC //------------------------------------------------------------------------------ // File : ten_100_1g_eth_fifo.v // Author : Xilinx...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9; const long long MAXN = 2e5 + 1; void faster() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int prs[1000]; void solve() { int n, k; cin >> n >> k; unsigned long long a[n]; set<int> m...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:167177216 ) using namespace std; const long long MOD = 1000000000 + 7; int main() { ios::sync_with_stdio(false); string s; cin >> s; long long bcount = 0; long long ans = 0; for (int i = s.size() - 1; i >= 0; --i) { if (s[i] ...
#include <bits/stdc++.h> using namespace std; const int inf = (1 << 29); int n, k; string str[2505][4], rhy[2505]; int sch[4]; string sub(string s, int k) { string res = ; int t = k; for (int i = s.size() - 1; i >= 0; --i) { res = s[i] + res; if (s[i] == a || s[i] == e || s[i] ...