text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { short n, pos, l, r; cin >> n >> pos >> l >> r; if (1 == l && n == r) { cout << 0 ; return 0; } if (1 == l) { cout << abs(r - pos) + 1; return 0; } if (n == r) { cout << abs(pos - l) + 1; retur...
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; int a[MAX]; int main() { ios::sync_with_stdio(false); int n, k; cin >> n >> k; n = 2 * n + 1; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n - 1 && k; i++) if (a[i - 1] + 1 < a[i] && a[i] > a[i + ...
#include <bits/stdc++.h> using namespace std; struct node { int id; int no; } a[100001]; int n, tot = 1, minn = 2100000000; bool cmp(node a, node b) { if (a.no != b.no) return a.no < b.no; return a.id < b.id; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scan...
#include <bits/stdc++.h> using namespace std; const int limite = 100005; pair<int, int> maximo[limite]; void inserta(int pos, int val) { pair<int, int> valor(val, pos); for (; pos < limite; pos += pos & -pos) maximo[pos] = max(maximo[pos], valor); } int computamaximo(int pos) { pair<int, int> ma...
#include <bits/stdc++.h> using namespace std; const long long N = (long long)(2e5), MOD = 1e9 + 7; const long long INF = 1e17; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int cnt = 0; string copy; copy += s[0]; for (int i = 1; i < s.size(); i++) { ...
////////////////////////////////////////////////////////////////////// //// //// //// hostSlaveMuxBI.v //// //// //// //// This file is part of the usbhos...
#include <bits/stdc++.h> using namespace std; vector<int> adj[200005]; int sz[200005]; int n, k; long long int ans; void dfs(int u, int p) { for (int v : adj[u]) { if (v == p) continue; dfs(v, u); sz[u] += sz[v]; ans += min(sz[v], 2 * k - sz[v]); } } int main() { ios_...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; const int MAXK = 20; int times[MAXN]; int dp[MAXN][MAXK]; int subtree[MAXN]; int marc[MAXN]; int prof[MAXN]; vector<int> graph[MAXN]; vector<pair<int, int>> arcs; void init_dfs(int u) { marc[u] = 1; for (int v : graph[u...
#include <bits/stdc++.h> using namespace std; string s, t; int dp[5005][5005]; int get(int i, int j) { if (dp[i][j] != -1) return dp[i][j]; if (i >= s.size() or j >= t.size()) return 0; int ret = get(i, j + 1); if (s[i] == t[j]) ret = (ret + 1 + get(i + 1, j + 1)) % 1000000007; return dp[i][...
#include <bits/stdc++.h> using namespace std; bool gt(long double a, long double b) { return a > b + 1e-12; } int n, m; vector<pair<bool, pair<int, int> > > pt, org; pair<int, int> o; inline bool left_turn(const pair<int, int> &a, const pair<int, int> &b, const pair<int, int> &c) { ...
// *************************************************************************** // *************************************************************************** // 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; int main() { int n; int ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) { int k = i ^ j; if (k <= n && k >= 1 && k >= j && i + j > k) ans++; } printf( %d , 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 la...
#include <bits/stdc++.h> using namespace std; string rep(string s, int x) { string res; while (x--) res += s; return res; } int ask(string str) { cout << str << n ; fflush(stdout); int x; cin >> x; return x; } int main() { int a = ask( a ); if (a == 0) return 0; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int i, j, t, n, a[150], b[150], sum1 = 0, sum2 = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; } for (i = 1; i <= n; i++) { cin >> b[i]; } for (i = 1; i <= n; i++) { if (a...
#include <bits/stdc++.h> using namespace std; const long long int INF = LLONG_MAX; vector<long long int> v1; vector<pair<long long int, long long int> > v2; string s1, s2, s3; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int a, b, c, d, e, f, i, j, k, cnt1 = ...
// "flop_it.v" // @vcs-flags@ -P pli.tab `timescale 1ps / 1ps // `include "standard.v" `include "standard.v-wrap" `include "clkgen.v" //----------------------------------------------------------------------------- module timeunit; initial $timeformat(-9,1," ns",9); endmodule module TOP; reg a; wire clk; wire z;...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, sumaP, sumaI, ultimo, primero; cin >> t; while (t--) { cin >> n; if (n % 4 != 0) cout << NO << endl; else { sumaP = (n / 2) * (n / 2 + 1); sumaI = (n / 2 - 1) * (n / 2 - 1); ultimo = ...
#include <bits/stdc++.h> using namespace std; long long M = 1e9 + 7; long long cnt[3000005], pre[3000005]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); ; long long n; scanf( %lld , &n); long long a; for (long long i = 0; i < n; i++) { scanf( %lld , &a); cnt[a...
#include <bits/stdc++.h> using namespace std; int sum[5]; int n; int main() { cin >> n; int res = 0; for (int i = 1; i <= n; ++i) { int t; scanf( %d , &t); if (t) sum[t]++; } int tmp = min(sum[1], sum[2]); sum[3] += tmp; res += tmp; sum[2] -= tmp; sum[1] -= ...
//***************************************************************************** // (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 // ...
/********************* (C) COPYRIGHT 2011 e-Design Co.,Ltd. ******************** Pre-sampling FIFO address counter and control module Version : FPGA CFG Ver 2.x Author : bure *******************************************************************************/ module Ad...
// Code generated by Icestudio 0.8.1w202112300112 `default_nettype none //---- Top entity module main #( parameter v2af3e8 = 4'hA, parameter v98e11a = 4'h5 ) ( input v17b894, input vf8383a, output v7b511e, output v6ef206, output [3:0] v1469d9, output v6898ff, output v1e39f8 ); localparam p7 = v2af3e8; loca...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> cnt(1e5 + 2, 0), dp(1e5 + 2, 0); while (n--) { long long x; cin >> x; cnt[x]++; } dp[1] = cnt[1]; for (int i = 2; i < 1e5 + 2; i++) { dp[i] = max(dp[i - 1], dp[i - 2] + 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...
/* * File: pippo_div_uu.v * Project: pippo * Designer: * Mainteiner: * Checker: * Description: implmentation of 64/32 divider using non-restoring algorithm Detailed algorithm see [Computer Arithmetic - Algorithms and Hardware designs] chapter 13 * Task.II * optimize the imple...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long a[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t, n, k; cin >> t; while (t--) { cin >> n; string ans, e, ant; bool ok = 0; for (int i = 0; i < (int)n - 2;...
#include <bits/stdc++.h> using namespace std; long long n, a[200005]; long long k; int main() { scanf( %d%I64d , &n, &k); for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]); int p; for (p = 1; p <= n && a[p] == 0; p++) ; p = n - p + 1; long long mx = 0; for (int i = 1; i <= n; ...
// hps_design_SMP_HPS_hps_io.v // This file was auto-generated from altera_hps_io_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.0 145 `timescale 1 ps / 1 ps module hps_design_SMP_HPS_hps_io ( output wire [14:0] mem_a, // memory.mem_a output wire [2:0] ...
// // my_fpga_test_gates.v // `timescale 1ns/1ps module my_fpga_test_gates; reg clk = 0, n_rst = 0; reg up = 0, dn = 0; wire [31:0] cnt; wire [3:0] cnt_1k; reg in1 = 0, in2 = 0; wire out1, out2; my_fpga uut(clk, n_rst, up, dn, cnt, cnt_1k, in1, in2, out1, out2); tbmsgs msgs(); ...
/** * 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 comment(linker, /STACK:16000000 ) using namespace std; const int Maxn = 505; const int Maxk = 11; const int Maxd = 10; const int Inf = 1000000000; int n, k; string s; int w; struct trie { trie *ch[Maxd]; int cnt; trie() { for (int i = 0; i < Maxd; ...
#include<bits/stdc++.h> using namespace std; namespace Acc{ const int N = 1e2+10; string a,b; int n; void work(){ queue<pair<string,int> >q; cin>>n>>a,q.push({b,0}); while(1){ auto[u,pos]=q.front();q.pop(); u.resize(pos+1); fo...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000005; int n; int a[MAXN]; int x[MAXN]; int y[MAXN]; int match[MAXN]; bool vis[MAXN]; int main() { ios::sync_with_stdio(0); cin >> n; if (~n & 1) { cout << First << endl; for (int i = 1; i <= n; i++) cout << i <...
#include <bits/stdc++.h> using namespace std; const int N = 106, INF = 0x3f3f3f3f; 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 = ge...
#include <bits/stdc++.h> using namespace std; struct info { int id, d; bool operator<(const info &rhs) const { return d < rhs.d; } } a[200007]; vector<pair<int, int> > res; priority_queue<info> q; stack<info> st; int main() { int n, m; int k = 0; int M = 0; scanf( %d%d , &n, &m); ...
#include <bits/stdc++.h> using namespace std; long long a[105][5]; int n, Ans, b[105]; bool check(int i) { for (int j = 1; j <= n; j++) for (int k = j + 1; k <= n; k++) if (i != j && i != k) { long long tmp = 0; for (int l = 1; l <= 5; l++) tmp += (a[j][l] - a[i...
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; int main() { int n, size = 1, arr[200005], arr1[200005]; long long sum = 0; memset(arr, 0, sizeof(arr)); memset(arr1, 0, sizeof(arr1)); cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; if (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 la...
#include <bits/stdc++.h> using namespace std; const int maxN = 100000 + 5, inf = 2005120699; const long long INF = 9200512069999999999ll; int reads() { int ans = 0; bool fu = 0; char ch = getchar(); while ((ch > 9 || ch < 0 ) && ch != - ) ch = getchar(); if (ch == - ) fu = 1, ch = getch...
#include <bits/stdc++.h> using namespace std; double prec = 0.00000001; void calcHistory(vector<double>& history, int hp2, double p1, int l1, int h1) { double h[201]; double newh[201]; memset(h, 0, sizeof(h)); memset(newh, 0, sizeof(newh)); h[hp2] = 1.; for (int i = 0; i < history.size(); ...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; vector<int> v[maxn]; vector<int> edge[maxn]; int flag[maxn], val[2][maxn]; bool bad[maxn]; int par[maxn][20]; inline int dfs(int x, int p) { par[x][0] = p; for (int i = 1; i < 20; i++) par[x][i] = par[par[x][i - 1]][i - 1];...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; long long dp[10000005], sol = 0; int main() { int n, i; long long x, y; scanf( %d%I64d%I64d , &n, &x, &y); for (i = 1; i <= 10000005; i++) dp[i] = inf; dp[1] = x; for (i = 2; i <= n; i++) { dp[i] = min(dp[i],...
#include <bits/stdc++.h> using namespace std; int dp[30006][205][4]; int a[30006]; int n, k; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) for (int t = 0; t < 4; t++) dp[i][j][t] = -1e9 - 1e7; for (...
#include <bits/stdc++.h> using namespace std; long long n; long long ans[100100 << 1]; long long ksm(long long p, long long q) { long long res = 1; while (q) { if (q & 1) res = res * p % 1000000007; p = p * p % 1000000007; q >>= 1; } return res; } signed main() { cin >>...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////// // File name : sata_link.v // Note : This is top module of SATA link Layer // Test/Verification Environment // Dependencies : Nil ////////////////////////////////////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; int cnt1[N], cnt2[N]; struct Fenwick_tree { vector<long long> t; int n; void init(int _n) { n = _n; t.assign(n + 1, 0); } void add(int r, int x) { for (; r <= n; r = (r | (r + 1))) t[r] += 1LL...
#include <bits/stdc++.h> using namespace std; long long f(long long x) { return x * (x - 1) / 2; } vector<int> g[303]; int m1[303][303]; int m2[303][303]; int main() { int n, m, k; cin >> n >> m >> k; vector<int> a(k); vector<int> c(n + 1, 0); for (int i = 0; i < k; i++) { cin >> a...
#include <bits/stdc++.h> using namespace std; const int maxn = 300 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f; long long c[maxn][maxn], pw[2][maxn], f[maxn][maxn]; inline int add(long long a, long long b) { a += b; return a >= mod ? a - mod : a; } inline int mul(long long a, long long b) { return a * b %...
#include <bits/stdc++.h> using namespace std; int main() { int n, d = 0, e = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (i > 0) { e += a[i - 1] - a[i]; if (e < 0) { d -= e; e = 0; } } else { d += a[0]; ...
#include <bits/stdc++.h> using namespace std; long long t, i, n, res, mx, a[300009]; map<int, int> mp; int main() { cin >> n; for (i = 1; i <= 2 * n; i++) { cin >> a[i]; } for (i = 1; i <= 2 * n; i++) { mp[a[i]]++; if (mp[a[i]] == 1) { res++; } else { res-...
#include <bits/stdc++.h> using namespace std; const int maxn = 4005; vector<int> v[maxn]; int vis[maxn][maxn]; int main(void) { int n, m, ans = maxn; memset(vis, 0, sizeof(vis)); scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int x, y; scanf( %d%d , &x, &y); v[x].push_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 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 la...
#include <bits/stdc++.h> using namespace std; int n, x, y; string h; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> h >> x >> y; if (x >= 2400 and y > x) { cout << YES ; return 0; } } cout << NO ; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int k, n; cin >> n >> k; if (n == 2) return cout << 2 << << 1 << << 2 << endl, 0; int ans1, ans2; int l = 1, r = n; while (l < r) { int mid = (l + r) / 2; cout << 1 << ...
// wasca_mm_interconnect_0_avalon_st_adapter_001.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module wasca_mm_interconnect_0_avalon_st_adapter_001 #( parameter inBits...
/* 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; using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const int inf = (1 << 30) - 1; const ll INF = (1LL << 60) - 1; const double pi = acos(-1.0); const double EPS = 1e-10; tem...
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) void scan() {} template <typename F, typename... R> void scan(F& f, R&... r) { cin >> f; scan(r...); } int di_; string dnms_, co_ = , ; void debug_() { cout << endl; } template <typename F, typename... R> void deb...
/* * 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...
// (c) Copyright 1995-2017 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 license and does not grant ...
#include <bits/stdc++.h> using namespace std; long long modexpo(long long x, long long p) { long long res = 1; x = x % 1000000007; while (p) { if (p % 2) res = res * x; p >>= 1; x = x * x % 1000000007; res %= 1000000007; } return res; } long long max(long long a, long...
#include <bits/stdc++.h> using namespace std; int main() { int num, skill; cin >> num >> skill; int A[num]; for (int i = 0; i < num; i++) cin >> A[i]; int k = 0; while (A[k] <= skill && k < num) k++; int soluve; soluve = k; int stay; if (k == num) { cout << num << endl;...
/* 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 distributed...
// $Id: rtr_flow_ctrl_input.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: Redistri...
/** * 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...
#include<bits/stdc++.h> #define pairs pair<int,int> #define loop(i,a,n) for(int i=a;i<n;i++) #define m_p make_pair #define fi first #define se second #define pb push_back #define ll long long #define all(v) v.begin(),v.end() using namespace std; //vector<ll> siz; /*ll indes(ll i,ll right){ l...
/** * 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...
module io1_sub( /*AUTOARG*/); wire [42:0] bscan_data; // boundary scan stitch parameter bscan_count = 0; assign bscan_data[0] = bscan_in; /* * Emacs template to auto instaniate MD[31:0] pads */ /* autoinst_lopaz_srpad AUTO_TEMPLATE ( .pin(MD[@]), .pi...
// 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 : Thu Feb 09 23:36:35 2017 // Host : TheMosass-PC running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, s; cin >> n >> k; for (i = 1; i <= n + 5; i++) { s = i * k; if (s > n) { cout << s; break; } } return 0; }
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 21:16:29 03/15/2015 // Design Name: fsm // Module Name: /home/vka/Programming/VHDL/workspace/sysrek/fsm/tb_fsm.v // Project Name: fsm // Target Device: // Tool ver...
/** * 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() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<long long> m(n); for (int i = 0; i < n; i++) cin >> m[i]; long long sum = 0; for (int i = 0; i < n; i++) sum += m[i]; sum += n; vector<long long> a(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 law...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> joy; while (n > 0) { int f, t; cin >> f >> t; if (t > k) f = f - t + k; joy.push_back(f); n--; } sort(joy.begin(), joy.end()); cout << joy.back(); }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n; cin >> n; long long int one = (n / 2) + (n / 3) + (n / 5) + (n / 7), two = (n / 6) + (n / 10) + (n / 14) + (n / 15) + (n / 21) + ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2009 Xilinx, Inc. // This design is confidential and proprietary of Xilinx, All Rights Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/...
#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; } int h, w, q; char buf[505][505]; int ans[1000005]; struct query_ { int y1, x1, y2, x2; int id; }; bitset<...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }...
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, m, ta, tb, k; cin >> n >> m >> ta >> tb >> k; long long int a[n], b[m]; fo...
/** * 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; using ll = long long; using vll = vector<ll>; using ull = unsigned long long; using int2 = pair<ll, ll>; using int3 = tuple<ll, ll, ll>; template <typename A> string to_string(const A& v); string to_string(const string& s) { return + s + ; } strin...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long arr[N], dp[N], n; long long go(int indx) { if (indx == n) return 0; long long &ret = dp[indx]; if (~ret) return ret; long long sum = arr[indx], j = indx + 1; while (j != n && arr[j] == arr[indx]) sum += arr[j++]; ...
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; template <typename T> using V = std::vector<T>; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; int gcd(int a, int b) { return a ? gcd(b % 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 la...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, ans = 0; cin >> n; pair<int, int> p[n]; int ab, be, le, ri; for (i = 0; i < n; i++) { int r, s; cin >> r >> s; p[i] = make_pair(r, s); } for (i = 0; i < n; i++) { ab = 0, be = 0, le = 0, ri = ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &(n)); static long long a[int(5e3 + 5)]; set<int> s; for (int i = 1, __R = n; i <= __R; i++) { scanf( %lld , &(a[i])); s.insert(a[i]); } static long long b[int(5e3 + 5)], k = 0; for (long long 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 n, m, k, t; int index(int i, int j) { return (i - 1) * m + j; } int main() { cin >> n >> m >> k >> t; int arr[k]; for (int i = 0; i < k; i++) { int a, b; cin >> a >> b; arr[i] = index(a, b); } sort(arr, arr + k); while (...
// *************************************************************************** // *************************************************************************** // 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> using namespace std; inline long long read() { char ch = getchar(); register long long x = 0; int f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + (ch ^ 48); ...
//############################################################################# //# Purpose: SPI master Registers # //############################################################################# //# Author: Andreas Olofsson # ...
/** * 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...