text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int MAXN = 20; int a[MAXN]; int main() { int k; scanf( %d , &k); for (int i = 1; i <= 12; i++) { scanf( %d , &a[i]); } sort(a + 1, a + 13); int tot = 0, ans = 0; for (int i = 12; i >= 1; i--) { if (tot >= k) { br...
/** * 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...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: seven_new2.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =========================...
#include <bits/stdc++.h> using namespace std; int main() { int tux; cin >> tux; int foo = 0, bar = 0, baz = 0, quz = 1; for (int i = 1; i <= tux; i++) { int pur; cin >> pur; foo += pur; bar = bar + 1; if (foo * quz > baz * bar) { baz = foo; quz = bar; ...
/////////////////// // File Name: VGA Tutorial // Author : Da Cheng // Course : EE201 /////////////////// // timing diagram for the horizontal synch signal (HS) // 0 655 752 800 (pixels) // -------------------------|______|----------------- // timing diagram for the vertica...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return a ? gcd(b % a, a) : b; } template <typename T> T lcm(T a, T b) { return (a / gcd(a, b)) * b; } string int_to_str_easy(long long n) { return n ? : int_to_str_easy(n / 10) + (char)( 0 + n % 10); ...
/** * 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> void sc(int &x) { scanf( %d , &x); } void sc(int &x, int &y) { scanf( %d%d , &x, &y); } void sc(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); } void sc(long long &x) { scanf( %lld , &x); } void sc(long long &x, long long &y) { scanf( %lld%lld , &x, &y); } void sc(long long ...
#include <bits/stdc++.h> const int inf = 0x7f7f7f7f; inline void gettime() { ; } inline int read() { static char c; static int x; int flag = 1; while (c = getchar(), !isdigit(c)) if (c == - ) flag = -1; x = c - 0 ; while (c = getchar(), isdigit(c)) x = (x << 1) + (x << 3) + c - 0 ...
#include <bits/stdc++.h> using namespace std; const int NR = 4e6 + 5; int n; long long P = 51123987; char s[NR]; int d[NR]; long long f[NR], g[NR]; int main() { scanf( %d , &n); scanf( %s , s + 1); for (int i = n; i >= 1; i--) { s[i * 2] = s[i]; s[i * 2 - 1] = # ; } s[n ...
#include <bits/stdc++.h> using namespace std; const int bignumlen = 2200; const int Blen = 8; const long long base = 100000000; struct bignum { int len; long long data[bignumlen]; long long &operator[](int x) { return (data[x]); } const long long &operator[](int x) const { return (data[x]); } ...
#include <bits/stdc++.h> using namespace std; int N; string A; string B; int main() { ios_base::sync_with_stdio(NULL); cout.tie(NULL); cin.tie(NULL); cin >> N; cin >> A >> B; int answer = 0; for (int i = 0; i < N - 1; ++i) { if (A[i] == B[i]) continue; if (A[i + 1] == B...
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018 // Date : Sun Sep 22 03:32:36 2019 // Host : varun-laptop running 64-bit Service Pac...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 16:10:35 12/16/2015 // Design Name: uart2_tx // Module Name: H:/Firmware/font5_base_new/font5_base/font5-firmware/uart2_tb.v // Project Name: font5_base // Target De...
/** * Module: arbiter * * Description: * A look ahead, round-robing parametrized arbiter. * * <> request * each bit is controlled by an actor and each actor can 'request' ownership * of the shared resource by bring high its request bit. * * <> grant * when an actor has been given ownership of shared reso...
/** * 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; int main() { long long int sasha_chiz, masha_chiz, coconut_price, sasha_buy_co, masha_buy_co, sum_buy_co, given_chiz = 0; cin >> sasha_chiz >> masha_chiz >> coconut_price; sasha_buy_co = sasha_chiz / coconut_price; masha_buy_co = masha_chiz / coc...
#include <bits/stdc++.h> using namespace std; bool reach(int from[3], int to[3], vector<vector<string>> &works) { if (works[from[0]][from[1]][from[2]] == 0 ) return false; if (from[0] == to[0] && from[1] == to[1] && from[2] == to[2]) return true; for (int d = 0; d < 3; ++d) if (from[d] < to[d]) {...
#include <bits/stdc++.h> using namespace std; bool v[6]; int a[100009][6], maxx = -1, t; long long m = 1e9 + 7; struct pi { long long ah[60][60]; }; pi multi(pi x, pi y) { pi z; for (int i = 1; i <= t; i++) { for (int j = 1; j <= t; j++) { z.ah[i][j] = 0; for (int k = 1; ...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > numbersWithGrundy(1); int a[200001], grundyValues[200001]; bool isPrime[200001], isMoveValid[200001]; vector<string> players{ Alice , Bob }; void PreProcess(int n, int m) { vector<int> primes; for (int i = 2; i <= n; ++i) { is...
#include <bits/stdc++.h> using namespace std; using lint = long long int; lint liters(int l, vector<int> &arr) { lint sum = 0; for (int k : arr) sum += (lint)(k - l); return sum; } int main() { int n, m = 1000000010; lint s; vector<int> arr; cin >> n >> s; arr.resize(n); fo...
#include <bits/stdc++.h> using namespace std; const int mxN = 500, M = 1e9 + 7; int n, a[mxN]; long long dp[mxN][mxN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> a[i], --a[i]; dp[0][0] = 1; for (int i = 1; i < n; ++i) dp[i][i] = dp[i ...
////////////////////////////////////////////////////////////////////// // File: CRC32.v // Date: Thu Nov 27 13:56:49 2003 // // Copyright (C) 1999-2003 Easics NV. ...
#include <bits/stdc++.h> using namespace std; int main() { string n; int k = 0; cin >> n; if (n[0] <= Z ) { for (int i = 0; i < n.size(); i++) { if (n[i] <= Z ) k++; } if (k == n.size()) { transform(n.begin(), n.end(), n.begin(), (int (*)(int))tolower); co...
// file: clk_dll.v // // (c) Copyright 2008 - 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 i...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { cin.tie(0), cout.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int n, l, r, now = 1; cin >> n; for (int i = 0; i < n; i++) { cin >> l >> r; if (now < l) {...
#include <bits/stdc++.h> using namespace std; int main() { int i, n; long long k, time, maks, tot, ar[10005], ans, temp, m; bool cek; scanf( %d %I64d %I64d , &n, &m, &k); for (i = 0; i < n; ++i) scanf( %I64d , &ar[i]); if ((n % 2) == 0) printf( 0 n ); else { ans = 0; ti...
#include <bits/stdc++.h> using namespace std; int main() { long long int a[1000000], b = 0, c = 0, d = 0; long long int n, i; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; d += a[i]; } d = d / n; for (i = 1; i <= n; i++) { b += a[i] - d; c += abs(b); } ...
#include <bits/stdc++.h> using namespace std; long long dp[100001]; bool seen[100001]; int n, q; vector<int> v, c; long long cal() { long long a, b; cin >> a >> b; for (int i = 0; i < 100001; i++) seen[i] = false; int c1, c2; c1 = c2 = -1; for (int i = 0; i < n; i++) { long lon...
/* * There are a number of problem that this example uncovers. * * It appears that the inverter connected to the ctl input of the * tranif gate is not getting the signal passed to it. It looks * like once the ctl signal is pulled into the island it can not * propagate the signal back out. The fix may be in the co...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << Black << endl; }
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t; reg [40:0] quad; initial quad = 41'ha_bbbb_cccc; reg [80:0] wide; initial wide = 81'habc_1234_5678_1234_5678; reg [31:0] str; initial str = "...
// 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...
#include <bits/stdc++.h> using namespace std; int main() { int casos; cin >> casos; while (casos > 0) { int a, b; cin >> a >> b; if (a > b) { int dif = a - b; b -= dif; a -= dif * 2; } else if (b > a) { int dif = b - a; a -= dif; b ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * 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 mine { long long qread() { long long ans = 0, f = 1; char c = getchar(); while (c < 0 or c > 9 ) { if (c == - ) f = -1; c = getchar(); } while ( 0 <= c and c <= 9 ) ans = ans * 10 + c - 0 , c = getchar(); return ans...
/* * 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...
//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...
//----------------------------------------------------------------------------- // (c) Copyright 2012 - 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 proper...
/** * 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...
// Verilog test fixture created from schematic B:\NICNAC16\dunc16.sch - Wed Sep 17 00:13:28 2014 `timescale 1ns / 1ps module dunc16_dunc16_sch_tb(); // Inputs reg CLK; reg RESET; // Output wire I_STA; wire I_LDA; wire I_JMP; wire I_ADD; wire I_BL; wire I_RET; wire I_BAN; wire EN_MD; wi...
/*! btcminer -- BTCMiner for ZTEX USB-FPGA Modules: HDL code: double hash miner Copyright (C) 2011 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 published by the Free Software Foundat...
/** * 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...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; vector<string> veg; bool comp(pair<int, int> p1, pair<int, int> p2) { return (p1.first < p2.first or ((p1.first == p2.first) and (p1.second < p2.second))); } int main() { int n, m, k, t, x, y; veg.push_back( Gra...
/** * 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; int n, m, p; set<int> ss; int idx[500500]; char str[500500], op[500500]; int main() { cin >> n >> m >> p; scanf( %s%s , str + 1, op + 1); stack<int> s; ss.insert(0); for (int i = 1; i <= n; i++) { ss.insert(i); if (str[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 la...
//================================================================================================== // Filename : RKOA_OPCHANGE.v // Created On : 2016-10-26 23:25:59 // Last Modified : 2016-11-01 17:10:58 // Revision : // Author : Jorge Esteban Sequeira Rojas // Company : Instituto Tec...
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; long long n, m, i, j, k = 200000; n = a.size(); m = b.size(); for (i = 1; i <= k; i++) { if (n - i >= 0 && m - i >= 0) { if (a[n - i] != b[m - i]) break; } else break; } ...
/** * 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; vector<long long> v; long long a[200011]; string s; int main() { long long n, k, i, x, res = 0, j; cin >> n >> k; for (i = 0; i < n; i++) cin >> a[i]; cin >> s; char C = A ; for (i = 0; i < n; i++) { x = k; if (s[i] == C) v.pus...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; using ull = uint64_t; inline void solve() {} int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int lucky = 0; for (auto const &c : s) lucky += c == 4 || c == 7 ; bool is_lucky = lucky > 0; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tc; cin >> tc; while (tc--) { int n; cin >> n; priority_queue<pair<int, int> > pq; for (int i = 0; i < n; i++) { int ai; cin >> ai; pq.push(pair...
#include <bits/stdc++.h> const long double pie = 3.1415926535; using namespace std; bool br1, br2, br; long long n, k, x, y, z, mini, maxi, l, ind, ini, sum, t, len, r, q, imini, w, m; string s, s1, s2; struct Point { long long X, Y; static long long getDir(Point a, Point b, Point c) { r...
#include <bits/stdc++.h> using namespace std; static const int INF = 500000000; template <class T> void debug(T a, T b) { for (; a != b; ++a) cerr << *a << ; cerr << endl; } string s[2005]; int n, K; int lcp[2005]; int prof[2005][2005]; struct uf { int par[2005]; vector<int> dp[20...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_65_256.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ===========================================...
/* * 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...
//Legal Notice: (C)2006 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...
/* * 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 main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; --n; int right, left, down, up; right = left = down = up = n / 4; n = n - up * 4; if (n != 0) { ++right; --n; } if (n != ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); std::ios::sync_with_stdio(false); string a; cin >> a; for (int i = 0; i < a.size(); i++) { if (((int)(a[i]) >= 48 && (int)(a[i]) <= 57) || ((int)(a[i]) >= 97 ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int fact(int n) { long long ans = n; for (int i = n - 1; i > 0; --i) { ans = (ans * i) % MOD; } return ans; } int pow2(int n) { long long ans = 1, b = 2; while (n > 0) { if (n % 2) { ans = (ans *...
#include <bits/stdc++.h> using namespace std; const int MaxN = 2e5 + 10; const int MOD = 1e9 + 7; const int INF = 1e9; int main() { int L, n, p, t; cin >> L >> n >> p >> t; if (n == 0) { cout << 0 << n ; exit(0); } vector<pair<int, int> > seg(n); for (int i = 0; i < n; ++...
#include <bits/stdc++.h> using namespace std; mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count()); const long long maxn = 3e5 + 10; struct E { long long to, nxt; } e[maxn * 2]; long long tot, head[maxn]; long long Add[maxn << 2], lz[maxn << 2]; void adde(long long u, long long 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 la...
/* -- ============================================================================ -- FILE NAME : uart.v -- DESCRIPTION : Universal Asynchronous Receiver and Transmitter -- ---------------------------------------------------------------------------- -- Revision Date Coding_by Comment -- 1.0.0 2011/06/27 s...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2010 Xilinx, Inc. // // 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 // // ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<string> G(n); for (int i = 0; i < n; i++) { cin >> G[i]; } vector<vector<pair<int, int>>> arr(27, vector<pair<int, int>>()); bool re...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double pi = acos(-1); const double EPS = 1e-9; long long binpowmod(long long a, long long b) { a %= MOD; long long ret = 1; while (b) { if (b & 1) ret = ret * a % MOD; a = a * a % MOD; b >>= 1; } ...
#include <bits/stdc++.h> using namespace std; inline void prnt(bool ok) { cout << (ok ? YES : NO ); } const int ppr = 257; const long long INF = 2e18; const int inf = 2e9; const int mod = 1e9 + 7; const int N = 3e6 + 123; const long double pi = 3.141592653589793238462643; const int dx[] = {1, 0, -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...
#include <bits/stdc++.h> using namespace std; int n, Q; int cnt_bad = 0; bool bad[2][100100]; int main() { scanf( %d%d , &n, &Q); memset(bad, 0, sizeof(bad)); for (int i = 0; i < Q; i++) { int x, y; scanf( %d%d , &x, &y); x--, y--; if (bad[x][y]) { bad[x][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...
/** * 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::Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2013 by Wilson Snyder. module t; `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); $stop; end while...
#include <bits/stdc++.h> using namespace std; double vp, vd, t, f, c; int main() { cin >> vp >> vd >> t >> f >> c; if (vp >= vd) { cout << 0 ; return 0; } int numberOfBojous = 0; double timeToHaveTheDragonBack = 0, overtakePosition = 0; double princessPosition = vp * t; wh...
#include <bits/stdc++.h> using namespace std; void FastIO() { ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(20); } int main() { FastIO(); int N; int A[200][200]; cin >> N; int Count = 0; int Cars[1000] = {0}; for (int i = 0; i < N; i++) { for (int j =...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 20; int n, x, i, f[N]; int main() { scanf( %d , &n); while (n--) scanf( %d , &x), f[x]++; for (i = N - 1; i >= 0; i--) if (f[i] & 1) return 0 * printf( Conan ); printf( Agasa ); }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using ii = pair<int, int>; using vii = vector<pair<int, int>>; void solve() { int n; cin >> n; int r = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; +...
module multipumped_memory(clk, wr, addr, d, q); parameter PORTS = 8; parameter WIDTH = 64; parameter DEPTH = 512; parameter LOG2_DEPTH = log2(DEPTH - 1); parameter LOG2_PORTS = log2(PORTS - 1); input clk; input [0:PORTS - 1] wr; input [PORTS * LOG2_DEPTH - 1:0] addr; input [PORTS * W...
`timescale 1ns / 1ps module M_uxa_mgia( input CLK_I_50MHZ, input RST_I, output CLK_O_25MHZ, output HSYNC_O, output VSYNC_O, output [2:0] RED_O, output [2:0] GRN_O, output [2:1] BLU_O, output [13:1] MGIA_ADR_O, input [15:0] MGIA_DAT_I, output MGIA_CYC_O, output MGIA_STB_O,...
#include <bits/stdc++.h> using namespace std; int const MAX_N = 600100; int const INT_INF = 1000000000; int my_rank[MAX_N], my_parent[MAX_N], diam_ancestor[MAX_N]; int d[MAX_N], och[MAX_N], nnew[MAX_N]; void make_set(int v) { my_parent[v] = v; diam_ancestor[v] = 0; my_rank[v] = 0; } int find...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; int e[maxn], ne[maxn], h[maxn], idx = 0; int sz[maxn]; int ans = 0; void add(int a, int b) { e[idx] = b, ne[idx] = h[a]; h[a] = idx++; } void dfs(int now, int fa) { sz[now] = 1; for (int i = h[now]; i != -1; i = ne[...
`timescale 1ns/1ps //THIS MODULE IS INSTANTIATED PER TX QUAD module tx_reset_sm ( input refclkdiv2, input rst_n, input tx_pll_lol_qd_s, output reg tx_pcs_rst_ch_c, //TX Lane Reset (mo...
#include <bits/stdc++.h> using namespace std; int memo[2700][2700]; string S; int N; int doit(int lo, int hi) { if (lo == hi) { return 1; } if (lo > hi) { return 0; } int &ret = memo[lo][hi]; if (ret != -1) return ret; ret = 0; if (S[lo] == S[hi]) { ret = max(...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; if (k % (n - 1) == 0) { cout << (k / (n - 1) * n) - 1 << endl; } else { cout << k / (n - 1) * n + k % (n - 1) << endl; } } }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int LG = 20; int n, a[N], u, v; long long dp[LG][N][2]; long long sdp[LG][N][2]; long long ans, ans2; vector<int> G[N]; bool mark[N]; int h[N]; void input(); void find_ans(); void dfs(int, int); int main() { inpu...
// $Id: c_rotator.v 1534 2009-09-16 16:10:23Z dub $ /* Copyright (c) 2007-2009, 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 of sour...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; string s1 = ; if (n % 2 == 0) { for (int i = 0; i < n; i++) { cout << s[i] << s[i + 1]; i++; if (i < n - 2) { cout << - ; } } } else { ...
/* * 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 double PI = 3.14159265358979323846264338327950288419716939937510582097494459230; struct debugger { static void call(const char *arg) {} template <typename T, typename... aT> static void call(const char *it, T a, aT... rest) { string b; ...
/* Copyright (c) 2014 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; long long mod = 1e9 + 7; long long a[1000005], b[1000005]; long long nine[100], t[100]; int main() { int n, k; t[0] = 1LL; for (int i = (1); i <= (10); i++) t[i] = (t[i - 1] * 10LL) % mod; nine[1] = 9LL; for (int i = (2); i <= (10); i++) nine[i...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll, ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; ll modpow(ll a, ll b, ll mod = (ll)(1e9 + 7)) { if (!b) return 1; a %= mod; return modpow(a * ...