code_file1
stringlengths
80
4k
code_file2
stringlengths
91
4k
similar_or_different
int64
0
1
#include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ub upper_bound #define lb lower_bound #define isrt insert #define clr clear #define rsz resize #define ff first #define s...
#include<bits/stdc++.h> using namespace std; int H,W; short fid[110][110] = {0}; short dp[110][110][110][110] = {0}; int x,y; short sum(int y1,int x1,int y2,int x2) { if(y1 > y2 || x1 > x2)return 0; return fid[y1 - 1][x1 - 1] - fid[y1 - 1][x2] - fid[y2][x1 - 1] + fid[y2][x2]; } int main() { scanf("%d%d",...
0
#include <stdio.h> int main(void) { int n,a[4],t[100],p[100],i,j,k; scanf("%d",&n); for(i=0;i!=n;++i) t[i]=0; for(i=0;i!=n*(n-1)/2;i++){ for(j=0;j!=4;j++) scanf("%d",&a[j]); if(a[2]<a[3]) t[a[1]-1]+=3; else if(a[2]>a[3]) t[a[0]-1]+=3; else{ t[a[0]-1]+=1; t[a[1]-1]+=1; } } for(i=0;i!=n;+...
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n; while(cin>>n){ if( n == 0 ) break; int score[n]; for(int i = 0; i < n; ++i){ score[i] = 0; } for(int i = 0; i < n*(n-1)/2; ++i){ int a,b,c,d; cin >> a >> b >> c >> d; --a; ...
1
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #define INF 2001 #define MAX 101 using namespace std; int MAT[MAX][MAX]; int N; int prim(){ int sum; bool complete[MAX]; int dist[MAX]; int parent[MAX]; for (int i = 0; i < N; i++) { complete[i] = false; ...
#include <bits/stdc++.h> using namespace std; #define REP(i, m, n) for (int i = (m); i < (int)(n); i++) #define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define reps(i, n) for (int i = 0; i <= (int)(n); i++) #define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--) #define rr...
0
#pragma GCC optimize(2) #include <bits/stdc++.h> using namespace std; template<class t> inline t read(t &x){ x=0;char c=getchar();bool f=0; while(!isdigit(c)) f|=c=='-',c=getchar(); while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar(); if(f) x=-x;return x; } template<class t> inline void write(t x){ if(x<0){putch...
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; // 型定義 typedef long long ll; typedef pair<ll, ll> P; // forループ #define REP(i,n) for(ll i=0; i<(ll)(n); ++i) // 定数宣言 const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; // グラフ表現 using Graph = vector<vect...
0
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <cstring> #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, in...
#include <bits/stdc++.h> using namespace std; int main() { int A,B,M; cin >> A>>B>>M; vector<int>veca(A); vector<int>vecb(B); for(int i=0;i<A;i++){ cin>>veca.at(i); } for(int i=0;i<B;i++){ cin>>vecb.at(i); } int countera=999999; int counterb=999999; for(int ...
1
// M #include<bits/stdc++.h> using namespace std; const int N = 303, Mod = 998244353; int n, k, C[N], dp[N][N][N]; inline void Add(int &a, int b) { a += b; if (a >= Mod) a -= Mod; } int main() { string S; cin >> S >> k; S = "0" + S; for (int i = 0; i < (int)S.size();) { int r = i + 1; while (r < (int)S.siz...
#include<stdio.h> #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int mod = 1e9+7; void ad(int &x,int y) { x+=y; if(x>=mod)x-=mod; } int zy[8][2] = {{6,1},{3,2},{2,2},{4,1},{3,3},{6,1},{7,5},{6,6}}; char ss[300005]; int n; int dp[300005][8]; int main() { scanf("%s"...
0
#include <iostream> #include <queue> using namespace std; typedef long long ll; typedef pair<ll, int> P; int main() { int n; ll d; cin >> n >> d; ll a[200005]; priority_queue<P, vector<P>, greater<P>> que; for(int i = 0; i < n; i++){ cin >> a[i]; que.push(P(a[i], i)); } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define f(i,a,b) for (int i = a; i < b; i++) #define fr(i,a,b) for (int i = b-1; i >= a; i--) const int mod = 998244353; const int mxn = 1e5; int n,K; void add(ll &a, ll b) { if (b>=mod) b%=mod; a+=b; if (a>=mod) a-=mod; } ll modpow(ll a, ll b) { ...
0
#include<stdio.h> int main(){ int M=100000000; int n,m,i,u,s,c[510],f[20010],t[20010]; while(1){ scanf("%d%d",&n,&m); if(n==0&&m==0){ break; } for(i=u=1;i<=n;i++){ c[i]=M; } for(i=s=c[1]=0;i<m*2;i+=2){ scanf("%d %d",&f[i],&t[i]); f[i+1]=t[i]; t[i+1]=f[i]; } while(u){ for(i=u=0;i<=m*...
#include <cstdio> #include <vector> #define rep(i,n) for(int i = 0; i < n; i++) using namespace std; int n, m; bool used[500]; vector<int> e[500]; int main(){ while(scanf("%d%d", &n, &m), n||m){ rep(i,500) e[i].clear(); rep(i,500) used[i] = false; rep(i,m){ int x, y; scanf("%d%d", &x, &y); x--; y--; e...
1
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> #include <cassert> #include <cfloat> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #...
#include<cstdio> #include<math.h> #include<algorithm> #include<vector> #include<queue> #include<string> #include<set> #include<cstring> #include<map> using namespace std; #define int long long int #define rep(i,n) for(int i=0;i<n;i++) #define INF 1001001001 #define LLINF 1001001001001001001 #define mp make_pair #de...
1
#include<bits/stdc++.h> //#include<atcoder/all> // Begin Header {{{ //using namespace atcoder; using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; #define rep(i,n) for(ll i=0; i<n; i++) #define loop(i, j, n) for(ll i=j; i<n; i++) #define all(x) (x).begin(), (x).end() #de...
#include <bits/stdc++.h> #include <iostream> #include <string> #include <string.h> #include <ctype.h> #include <algorithm> using namespace std; int main() { int n,ans,W[310000] = {},E[310000] = {}; string s; cin >> n >> s; for(int i = 1; i <= n-1; i++) { if(s[i-1] == 'W') W[i] = W[i-1] + 1; ...
1
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(i = 0;i < n;++i) #define all(v) v.begin(), v.end() using ll = int; int main() { ll i,j,k; ll h,w; cin >> h >> w; ll inf = 160*80; vector<vector<ll>> a(h,vector<ll>(w,0)); vector<vector<ll>> b(h,vector<ll>(w,0)); for(i = 0;i...
#include <iostream> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <algorithm> #include <iomanip> #include <math.h> #include <string.h> #include <cstdio> #include <tuple> using namespace std; using ll = long long; using pll = pair<ll, ll>; using vl = vector<...
1
#pragma region header #include <bitset> #include <tuple> #include <cstdint> #include <cstdio> #include <cctype> #include <assert.h> #include <stdlib.h> #include <stdio.h> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #inc...
#include <bits/stdc++.h> using namespace std; #define SZ(x) (int)(x.size()) using ll = long long; using ld = long double; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vector<int>>; using vll = vector<ll>; using vvll = vector<vector<ll>>; const double eps = 1e-10; const int MOD = 1000000007; c...
0
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<vector> #include<functional> #include<algorithm> #include<stdlib.h> #include<string> #include<string.h> #define _USE_MATH_DEFINES #include<math.h> #include<deque> #include<set> #include<map> #include<queue> #include<list> #include<iostream> #include <bitset> us...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 100005; int n; string s; bool val = false; bitset<N> ans; int main() { cin.sync_with_stdio(0); cin.tie(0); cin >> n >> s; int variations[4][2] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; for (int v = 0; v < 4; ++v) { a...
1
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define IREP(i, n) IFOR(i,0,n) #define SORT(a) sort(a.begin(), a.end()) #define REVERSE(a) reverse(a.begin(), a.end()) #define Lower_bound(v, x) d...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int n, a[maxn]; long long sum[maxn]; long long F(int left, int m, int right) { return abs(sum[right]-2*sum[m]+sum[left]); } int find(int l, int r) { int left = l-1, right = r+1; while (r-l >= 3) { int m1 = l + (r-l)/3; int m2 = r - (r-l)...
0
#include <bits/stdc++.h> const int mod = 998244353; typedef long long LL; void reduce(int & x) { x += x >> 31 & mod; } int mul(int a, int b) { return (LL) a * b % mod; } int pow(int a, int b, int res = 1) { for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a); return res; } const int MAXS = 1000010; int fa...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for...
0
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <fstream> #include <unordered_map> using namespace std; ifstream fin("../data.txt"); int n, x, a1, a2, eat; long long ans; int main() { cin >> n >> x >> a1; n--; while (n--) { cin >> a2; if (a1 + a2 > x) { ea...
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) #define reps(i, f,...
1
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() #define m0(x) memset(x,0,sizeof(x)) int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1}; int main() { i...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1001001001; const ll LINF = 1001001001001001; const int MOD = 1000000007; template <typename T> void print(const T &v); int main() { int x, y; cin ...
1
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long using namespace std; /*2進数配列+1*/ vector<int> twoadd(vector<int> v, int N){ v[N-1]+=1; int ind = N-1; int j=N-1; for(j=N-1;j>=1;j--){ if(v[j]>1){ v[j-1]+=1; v[j]=0; } } return v; ...
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; int read() { int out = 0, sgn = 1; char jp = getchar(); while (jp != '-' && (jp < '0' || jp > '9')) jp = getchar(); if (jp == '-') sgn = -1, jp = getchar(); while (jp >= '0' && jp <= '9') out = out * 10 + jp - '0', jp = getc...
0
#include <iostream> #include <string> #include <iomanip> #include <math.h> #include <utility> #include <vector> #include <cstdlib> #include <algorithm> #include <climits> #include <queue> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; string table[12]; void dfs(int ...
#include<bits/stdc++.h> using namespace std; int ap[1005],bp[1005],cp[1005],abc[1005],r[1005]; int n,n1,n2,n3; int main(){ while(1){ cin >> n1 >> n2 >> n3; if(n1==0&&n2==0&&n3==0)break; cin >> n; for(int i=0;i<=n1+n2+n3;i++)abc[i]=2; for(int i=0;i<n;i++){ cin >> ap[i] >> bp[i] >> cp...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n; cin >> n; vector<ll> takahashi(n); ll sum = 0; for(int i = 0; i < n; i++){ ll a, b; cin >> a >> b; takahashi[i] = a+b; sum-=b; } sort(takahashi.begin(), takahashi.end(), greater<long long>()); for(int...
#include <cstdio> #include <iostream> #include <string> #include <cstdlib> #include <vector> #include <algorithm> #include <functional> #include <iomanip> #include <stdlib.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); int min = 0; int max = 0; long long sum = 0; for (int i = 0; i < n; ...
0
#include <iostream> #include <regex> #include <stdio.h> #include <string> using namespace std; int main() { string S; cin >> S; regex rx(R"(^A[a-z][a-z]*?C[a-z]*?[a-z]$)"); if (regex_match(S, rx)) { printf("AC\n"); } else { printf("WA\n"); } }
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dd; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; const int mx=1e6+11; const double PI = acos(-1); #define MOD 1000000007 #define nl '\n' #define pb push_back #define F first...
1
#include <bits/stdc++.h> #include <ext/rope> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define int long long #define pb push_back #de...
// 問題の URL を書いておく // #include <algorithm> #include <array> #include <bitset> #include <cmath> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; //#define ENABLE_PRINT #if defined(ENABLE_PRINT) #define Print(v) \ do {\ c...
0
#include <bits/stdc++.h> #define rep(i,N) for (int i = 0; i < (N); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main(void){ int A, B; cin >> A >> B; int ans = 0; for (int a = 1; a < 10; a++){ rep(b,10){ rep(c,10){ int x = 10001 * a + 1010 * b + 100 * c; ...
/* * @Author: Nazrul Islam * @Date: 2020-09-19 22:49:56 * @Last Modified by: Nazrul Islam * @Last Modified time: 2020-09-19 23:45:48 */ #include<bits/stdc++.h> using namespace std; #define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) typedef long long ll; typedef double dd; typedef vector<int>...
1
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if ((a < c && c < b) || (b < c && c < a)) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
//神题 #include<cstdio> #include<cstring> #include<algorithm> #define N 1000010 using namespace std; int n, ff, op, cl, d[N], ans, L, R, now; char s1[N], s2[N]; int main(){ scanf("%d%s%s", &n, s1+1, s2+1); s2[0]='$'; ff=1; for(int i=1; i<=n; i++)if(s1[i]!=s2[i]){ff=0; break;} if(ff){printf("0"); return 0;} now=n; R=n...
0
#include <bits/stdc++.h> //{{{ graph.hpp #ifndef INCLUDE_GRAPH_HPP #define INCLUDE_GRAPH_HPP #include <vector> namespace orislib { struct Edge { typedef int weight_t; int from, to; weight_t w; Edge(int from, int to, weight_t w) : from(from), to(to), w(w) {} bool operator<(const Edge& e) const { return w ...
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5; const int INF = 1e9; typedef pair<int, int> P; struct edge{ int to,cost; }; vector< edge > G[N]; void dikstra(int s,int V){ priority_queue<P,vector<P>,greater<P>> que; int d[N]; //sからの最短距離 fill(d,d+N,INF); d[s] = 0; que.p...
1
/* AuThOr GaRyMr */ #include<bits/stdc++.h> #define rb(a,b,c) for(int a=b;a<=c;++a) #define rl(a,b,c) for(int a=b;a>=c;--a) #define LL long long #define IT iterator #define PB push_back #define II(a,b) make_pair(a,b) #define FIR first #define SEC second #define FREO freopen("check.out","w",stdout) #define rep(a,b) for(...
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define fst first #define snd second using namespace std; typedef long long ll; typedef double db; typedef long double ldb; template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;} template<class T> inline void checkmax(T &a,const T &b){if...
1
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i)) #define REP(i, n) FOR(i,n,0) #define OF64 std::setprecision(10) const ll MOD = 1000000007; const ll INF = (ll) 1e15; struct Vertex { vector<ll> node; }; ll CA[10...
#include<bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second #define task "tst" using namespace std; const ll N = 1e5 + 9; const ll inf = 1e9 + 7; typedef pair<ll,ll> LL; ll n,i,mx[N],p,q,maxx,cur; LL a[N],b[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cou...
0
//include //------------------------------------------ #include <string> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <complex> #include <ss...
// // main.cpp // #include <algorithm> #include <array> #include <assert.h> #include <complex> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <math.h> #include <memory> #include <memory> #include <queue> #include <random> #include <set> #include <stdio.h> #include <stdlib.h> #include...
0
#include <bits/stdc++.h> #include <iostream> #include <math.h> //pow(x,y)=x^y 99999とかの場合+1するif文 #include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end()); #include <ctime> //実行時間を測る #define ll long long #define vecvec(h,w,name) vector<vector<ll>> name(h, vector<ll>(w)); #define rep(init, i, n) ...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for (int i = 0; i < (int)n; i++) int main() { int n, r; cin >> n >> r; if (n >= 10) cout << r << endl; else cout << r + (100 * (10 - n)) << endl; }
0
#include <bits/stdc++.h> #include<ext/pb_ds/hash_policy.hpp> #include<ext/pb_ds/assoc_container.hpp> #define N 200005 using namespace __gnu_pbds; using namespace std; typedef long long LL; typedef unsigned long long uLL; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; ...
#include <bits/stdc++.h> using namespace std; static const long long MOD=1000000007; int main(){ int N,temp; cin >> N; int c1,c2,c3; c1=0; c2=0; c3=0; long long ans=1; for(int i=0;i<N;i++){ int cnt=0; int flag=-1; cin>>temp; if(c1==temp){ cnt++; flag=1; } if(c2==temp...
0
#include <iostream> using namespace std; int main(){ int n; while(cin >> n, n){ int a[5000], ans = -100001; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n; i++){ int sum = 0; for(int j = i; j < n; j++){ sum += a[j]; ans = max(ans, sum); } } cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef complex<double> P; typedef pair<int,int> pii; #define REP(i,n) for(ll i=0;i<n;++i) #define REPR(i,n) for(ll i=1;i<n;++i) #define FOR(i,a,b) for(ll i=a;i<b;++i) #define DEBUG(x) cout<<#x<<": "<<x...
1
#include <stdio.h> #include <string.h> int main() { char angka[10]; scanf("%s", &angka); int ada = 0; for(int i = 0 ; i < strlen(angka); i++) { if (angka[i] == '7'){ ada = 1; } } if (ada ==1){ printf("Yes"); } else { printf("No"); } puts(" "); return 0; }
#include <stdio.h> #include <iostream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int N; cin >> N; if (N % 10 == 7 || (N/10) % 10 == 7 || (N/100) % 10 == 7){ cout << "Yes" << endl; } else { cout <...
1
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long #define all(x) (x).begin(),(x).end() template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; retur...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long #define all(x) (x).begin(),(x).end() template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} template<class T>bool chmin(T &a, const T &b) ...
0
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++) #define rrepit(ritr,x) for(auto ritr = x.rbegin(); rit...
#include <cstdio> #include <algorithm> using namespace std; const int MAXN = 3000; const int MAXM = MAXN*MAXN; const int MOD = int(1E9) + 7; int pow_mod(int b, int p) { int ret = 1; for(int i=p;i;i>>=1,b=1LL*b*b%MOD) if( i & 1 ) ret = 1LL*ret*b%MOD; return ret; } int fct[MAXM + 5], ifct[MAXM + 5]; int comb(int ...
0
#include <iostream> #include<algorithm> using namespace std; //upper_bound, lower_boundを用いた //のになぜか通らない・・・ int main(){ int n; long long a; if(scanf("%d", &n)==EOF){return 0;} long long top[n]; long long center[n]; long long down[n]; for(int i = 0; i<n; i++){if(scanf("%lld", &a)==EOF){return 0;} top[i] = a;...
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<cstdlib> #include<string> #include<sstream> #include<cmath> #include<numeric> #include<map> #include<stack> #include<queue> #include<list> using namespace std; int inf = 1000000000; int main(void) { vector<int> l(10); vector<int> v(...
0
#include <bits/stdc++.h> #define ll long long using namespace std; long long fpb(long long x, long long y) { return (y == 0) ? x : fpb(y, x % y); } long long kpk(long long x, long long y) { return x * (y / fpb(x, y)); } bool cmp(long long a,long long b) { return a>b; } int main() { ios::sync_with_st...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef vector<vector<int>> vv; typedef pair<int, int> P; // input int N, K; void input() { cin >> N >> K; } int main() { input(); int ans = 1; rep(i, N) { if (ans < K) a...
0
#include<cstdio> #include<vector> #include<algorithm> #include<iostream> #include<string> using namespace std; const double EPS=1e-8; struct data{ double b;string Name; data(double b_,string Name_):b(b_),Name(Name_){} data(){} bool operator<(const data &d)const{ return (b-d.b<EPS&&b-d.b>-EPS)?Na...
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; const ld eps=1e-9; //// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" int main() { w...
0
#include <cstdio> #include <cstdlib> #include <cstdint> #include <cstring> #include <cctype> #include <iostream> #include <sstream> #include <vector> #include <list> #include <deque> #include <map> #include <set> #include <stack> #include <queue> #include <unordered_map> #include <unordered_set> #include <algorithm> #i...
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(x) x.begin(),x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_fast32_t; u...
0
#include <iostream> using namespace std; int main() { int X, Y; cin >> X >> Y; if (X < 9 && Y <9){ cout << "Yay!" << endl; return 0; } cout << ":(" << endl; }
#include <bits/stdc++.h> using namespace std; int main(){ string s; int k, is; cin >> k >> s; is = s.size(); if(k >= is){ cout << s << endl; } else{ for(int i = 0; i < k; i++){ cout << s.at(i); } cout << "..." << endl; } }
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ long long n,q; cin >> n >> q; long long s[n],t[n],x[n],d[q]; pair<long long, int> p[n]; for(int i=0;i<n;i++){ cin >> s[i] >> t[i] >> x[i]; p[i]=make_pair(x[i], i); } sort(p, p+n); vector<pair<long long, int> > vec; ...
#include <bits/stdc++.h> using namespace std; template<typename T> void out(T x) { cout << x << endl; exit(0); } #define watch(x) cout << (#x) << " is " << (x) << endl typedef long long ll; const ll mod = 1e9+7; const int maxn = 1e6 + 5; int n,q; map<int,vector<pair<int,int>>> mp; int ans[maxn]; int main() { ...
1
#include <string> #include <vector> #include <sstream> #include <iostream> #include <algorithm> #include <map> #include <list> #include <set> #include <numeric> #include <queue> #include <stack> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <cstring> #include <climits> #include <cfloa...
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <iomanip> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cassert> #include <complex> #include <stdio.h> #include <...
1
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> using namespace std; int H, W; int A[200005], B[200005]; int C[200005]; set<int > S; int ans[200005]; multiset<int> M; int p = 0; int E[200005]; void ADD(int k) { E[k]++; } void DEL(int k) { E[k]--; while (E[p] == 0)...
#include <iostream> #ifdef MBP #include "stdc++.h" #else #include <bits/stdc++.h> #endif #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define REP(i, n) for (long long int i = 0, i##_len = (n); i < i##_len; ++i) #define REP_R(i, n) for (long long int i = (n - 1); i >= 0; --i) #define A...
0
#include <iostream> #include <functional> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <set> #include <queue> #include <map> #include <iomanip> #include <complex> #include <random> #include <bitset> #include <list> // #include <prettyprint.hpp> using namespace std...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); #define st first #define nd second #define endl '\n' //toggle off for interactive problems #define what_is(x) cerr << #x << " is " << x << endl; #define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' ...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); ++i) #define all(a) (a).begin(), (a).end() int main() { int x, y; cin >> x >> y; vector<int> dx = {1, 0, -1, 0}; vector<int> dy = {0, -...
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #include <numeric> #include <cctype> #include <tuple> #include <array> // BEGIN CUT HE...
0
#include <bits/stdc++.h> using namespace std; #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; ...
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <map> using namespace std; typedef long long ll; int main() { int n; cin >> n; vector<int> memo; while (n) { int r = n % (-2); if (r < 0) r *= -1; n = (n - r) /...
0
#include <iostream> #include <vector> #include <algorithm> #include <ctime> #include <cmath> #include <string> #include <stdlib.h> #include <fstream> #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <iterator> #include <iomanip> using namespace std; int main(){ long long n,...
#include <bits/stdc++.h> using namespace std; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } using ll = long long; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #defin...
1
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef vector<ll> vl; typedef vector<string> vs; typedef vector<char> vc; typedef queue<ll> ql; typedef deque<ll> dql; typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/) typedef set<ll> sl; typedef pair<ll, l...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); i++) #define reps(i,s,n) for(int i=(s); i<(n); i++) #define all(v) v.begin(),v.end() #define outve(v) for(auto i : v) cout << i << " ";cout << endl #define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;} #define in(n,v) for(int i=0;...
1
/*#include <bits/stdc++.h> #define N 300010 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; } int n,D[N][3],F[N],ct[2][2],vis[N]; struct BIT { int tree[N]; inline void ...
#include<bits/stdc++.h> typedef long long ll; ll gi(){ ll x=0,f=1; char ch=getchar(); while(!isdigit(ch))f^=ch=='-',ch=getchar(); while(isdigit(ch))x=x*10+ch-'0',ch=getchar(); return f?x:-x; } struct __orz_newbie314159_akioi__{ int m,inv,a[50010],t[50010]; void update(int x){while(x<=m)++t[x],x+=x&-x;} int quer...
1
// // Created on 2020/05/02. // #include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint>...
#include <cstdio> const int MAXN = 2e5+5; int seen[MAXN]{ }; int M, N; int main() { scanf(" %d%d", &N, &M); int lhs = 1; int rhs = N; for (int i = 0; i < M; ++i) { printf("%d %d\n", lhs, rhs); ++lhs; --rhs; while (seen[rhs - lhs] || seen[N - rhs + lhs] || (2*rhs == N + 2*l...
1
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; int main() { ll l, r; cin >> l >> r; ll ans = 2018; if (r - l >= 2 * 2019) { rep(i, 2019) rep(j, 2019) ans = min(ans, (ll)i * j % 2019); } else if (r - l >= 2019) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() #define MOD 1000000007 const int INF = 1LL<<30; int main(){ ll l,r; cin>>l>>r; ll ans=3000; for(int i=l;i<=min(r,l+3000);i++){ for(int j=i+1;...
1
#include <bits/stdc++.h> #define ll long long #define ld long double #define int long long using namespace std; const ll INF = 1e18; const ll MOD = 998244353; int basis[100]; int cnt = 0; void insert(int mask) { for(int i = 61; i >= 0; i--) { if(!(mask&(1ll << i))) continue; if(basis[i] == 0) { basis[i] = ma...
#include<bits/stdc++.h> using namespace std; #define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i) #define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i) typedef long long ll; template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;} template<typename T>inline bool chkmax(T &...
0
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=int(a);i<int(b);++i) #define SIZE 200005 #define INF 1000000005LL #define MOD 1000000007 using namespace std; typedef long long int ll; typedef pair <int,int> P; int main(){ int n; cin >> n; string s,t; cin >> s>>t; for(int i=n;i>=1;i--){ ...
#include <bits/stdc++.h> #define f(i,j,k) for(int i=j;i<k;i++) #define f2(i,j,k) for(int i=j;i>k;i--) using namespace std; int main(){ long long n,now=0; cin>>n; string s,t; cin>>s>>t; while(1){ if(s.substr(now,n-now)==t.substr(0,n-now)){ break; } now++; } ...
1
#include<stdio.h> int s[10], c[10], n, m; int main() { int i, ss, cc; scanf("%d%d", &n, &m); for(i = 1; i <= m; ++i) { scanf("%d%d", &ss, &cc); if(s[ss]) { if(c[ss] != cc) { printf("-1\n"); return 0; } } if(ss == 1 &...
#include <bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for (ll i=0; i<n; ++i) #define all(c) begin(c),end(c) /* */ int main(){ cin.tie(0); ios::sync_with_stdio(0); ll N,M; cin>>N>>M; if(M==0){ if (N==1) cout<<0<<endl; if (N==2) cout<<10<<endl; if (N==3) ...
1
#include<bits/stdc++.h> using namespace std; #define ll long long // memo fixed setprecision(20); using vvll = vector<vector<ll>>; ll mod =1e9+7; /*"itob" int to "N"base */ template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";s...
#include <bits/stdc++.h> #define len(x) ((int)(x).size()) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; // [ // (count_WA_before_passed, is_passed) // ] vector<pair<int, bool>> contest_result(105000, make_pair(0, false)); int WA_count = 0; ...
0
#include <bits/stdc++.h> #define ri register int using namespace std; const int rlen = 1 << 20 | 5; char buf[rlen], *ib = buf, *ob = buf; #define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++) #define pb push_back #define rez resize #define fi first #define se second typede...
#include <bits/stdc++.h> using namespace std; using ll = int64_t; #define rep(i,n) for(int i = 0; i < ((int)(n)); i++) // 0-indexed昇順 int main() { int H,W,A,B; cin >> H >> W >> A >> B; rep(i,H) { rep(j,W) { if (i < B) { cout << ((j < A) ? 0 : 1); } else { ...
1
#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; //const int INF = 2e9; //const ll INF = 9e18; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> p(N); // Male = 1, Female = 2; string response; auto ask = [&](in...
#include <stdio.h> int isprime(int n){ for(int i = 2 ; i*i<=n ;i++){ if(n%i==0)return 0; } return 1; } int main(){ int number[10000+2]={0}; int n ,i , fir ,sec; while(scanf("%d" ,&n)){ if(n==0)break; fir = 0 ,sec = 0; for(i=n ;i>3 ;i--){ if(isprime(i) && isprime(i-2)){ fir = i-2; ...
0
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i,n) for (int i=0;i<(int)(n);i++) #define codefor int test;scanf("%d",&test);while(test--) #define INT(...) int __VA_ARGS__;in(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;in(__VA_ARGS__) #define yes(ans) if(ans)p...
#include <iostream> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <string> #include <cmath> #include <iomanip> using namespace std; typedef long long ll; typedef pair<ll,ll>PP; int T[105]={0}; int main(){ int n;cin>>n;int sum=0; for(int i=0;i<n;i++){ int k;cin>>k; sum+=k;...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; int n; int a; int ans=1000000000; int main(void){ cin>>n; for(int i=0;i<n;i++){ cin>>a; int k=0; while(a%2==0){ a=a/2; k++; } ans=min(ans,k); } cout<...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { ll n; cin >> n; ll a[n]; rep(i,n) cin >> a[i]; int ans = 0; while(1){ rep(i,n){ if(a[i] % 2 == 0){ a[i] /= 2; }else{ cout << ans << end...
1
#include <bits/stdc++.h> using namespace std; #define ct cout #define in cin #define el endl #define rep(i, N) for (int i = 0; i < N; i++) #define ol(N) cout << N << endl int main() { int s1[4], s2[2]; rep(i, 4){ in >> s1[i]; } in >> s2[0] >> s2[1]; sort (s1, s1 + 4); reverse(s1, s1 + 4); ol(s1[0] + s1[1]...
#include <iostream> #include <string> #include <vector> using namespace std; int maxof(const int a[]) { int i; int max = a[0]; for (i = 1; i < 8; i++) { if (a[i] > max) max = a[i]; } return max; } int main() { int a, b, c, d, e, f; int r1, r2, r3,r4,r5, r6, r7, r8; cin >> a >> b >> c >> d >> e >> f; r1 = ...
1
//kruskal tree #include <cstdio> #include <algorithm> using namespace std; #define M 100000 int parent[M],a[M],b[M]; pair<int,int>node[M]; int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);} int unite(int a,int b){ int x=root(a),y=root(b); if(x==y)return 0; parent[x]=y; return 1; } int main(){ int i,...
#include <cstdio> #include <vector> #include <algorithm> #include <queue> #include <utility> using namespace std; template <class T> using gp_queue=priority_queue<T, deque<T>, less<T>>; using Weight=long long; static const Weight INF=1LL<<57; struct Edge { size_t src, dst; Weight weight; Edge() {} E...
1
#include<bits/stdc++.h> #define llu unsigned long long #define ll long long #define INF 0x3f3f3f3f #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" #define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower); #define to_upper(s) transform(s.begin(), s.end(), s.be...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } int main() { int n, l; cin >> n >> l; int sum = 0; for (int i = 0; i < n; i++) { sum += l + i; } int ans; int x = 100000000; for (int i = 0; ...
0
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #define ll long long using namespace std; template <class T> inline void rd(T &x) { x=0; char c=getchar(); int f=1; while(!isdigit(c)){if(c=='-')f=-1; c=getchar();} while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f; } const int N=2e5+10,mod...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (n); i++) #define reps(i, f, n) for (ll i = (f)...
0
#include <bits/stdc++.h> using namespace std; int v,e; set<pair<int,pair<int,int>>> g; int a[10005]={}; void init(){ for(int i=0;i<10005;i++)a[i]=i; } int find(int x){ if(a[x]==x)return x; else return (a[x]=find(a[x])); } void un(int x,int y){ a[find(x)]=y; } int main() { long long c=0; init(); cin>...
#include<bits/stdc++.h> using namespace std; #define int long long #define tc(t) int t; cin>>t; while(t--) #define f(n) for(int i=0;i<n;i++) #define endl "\n" int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; vector<pair<int,string>>v(m); vec...
0
#include <bits/stdc++.h> using namespace std; const int kN = 100'000 + 5; const int kMod = 1'000'000'000 + 7; int x[kN], y[kN]; int f(int *a, int n) { int sum = 0, res = 0; for (int i = 0; i < n; ++i) { a[i] = (a[i] % kMod + kMod) % kMod; int add = (1LL * a[i] * i + kMod - sum) % kMod; ...
#include <bits/stdc++.h> using namespace std; #define REP(i, N) for (int i = 0; i < (int)N; i++) #define FOR(i, a, b) for (int i = a; i < (int)b; i++) #define ALL(x) (x).begin(), (x).end() #define INF (1 << 30) #define LLINF (1LL << 62) #define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__) constexpr int MOD = 10000000...
1
#include<stdio.h> int insertionSort(int A[], int n, int g) { int cnt = 0; for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; while ( j >= 0 && v < A[j]) { A[j + g] = A[j]; j -= g; cnt++; } A[j + g] = v; } return cnt; } void shellSort(int A[], int n) { int im, m...
#include <iostream> #include <vector> #include <algorithm> using namespace std; int cnt; void insertionSort(vector<int> &mat,int g){ for(int i=g;i<mat.size();i++){ int v = mat[i]; int j = i - g; while(j>=0 && mat[j]>v){ mat[j+g] = mat[j]; j = j - g; cnt++...
1
#include<stdio.h> //operation a == doubled //operation b == increase by b int main(){ int a, b; scanf("%d %d", &a, &b); int result = 1; for(int i = 0; i < a; i++){ if(result < b)//it works if result + b is smaller than doubled { result = result * 2; } else//it...
#include <stdio.h> #include <string.h> int main() { int A,B; char S[20]; int C, counts = 0; scanf("%d %d", &A, &B); scanf("%s", S); C = strlen(S); if(!(S[A] == '-')){ printf("No"); return 0; } for(int i=0;i<C;i++){ if(S[i] == '-'){ counts++; ...
0
#include <iostream> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <algorithm> #include <iomanip> #include <math.h> #include <string.h> #include <cstdio> #include <tuple> #include <numeric> using namespace std; using ll = long long; using ld = long double; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i) using ll = long long; int main() { ll n, a; cin >> n; multiset<ll, greater<>> st; rep(i, n) { cin >> a; st.insert(a); } ll ans = 0; while(!st.empty()) { auto it = st.begin(); st...
1
#include <bits/stdc++.h> using namespace std; void solve() { int h, w; cin >> h >> w; vector<vector<char>> a(h+2, vector<char>(w+2)); for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } int di[] = {1, 0, -1, 0}; int dj[] = {0, 1, 0, ...
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408 // Ref : http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2679699#1 #include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; int NV, NE; struct artPoint { int cnt, N; vector<vector<int> > G; set<int> AP; vector<...
0
#include<bits/stdc++.h> using namespace std; #define int long long const int mod=1000000007; signed main(){ int N,ans=1; cin>>N; vector<int> A(3,-1); while(N--){ int a; cin>>a; vector<int> B(0); for(int i=0;i<3;i++) if(A[i]+1==a) B.push_back(i); if(B.size()==0){ puts("0")...
#include <algorithm> #include <cassert> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define repeat(i, n) for (int i = 0; (i) < (n); ++(i)) #define repeat_from(i, m, n) f...
0
#include <bits/stdc++.h> using namespace std; int main(void) { int a, b; cin >> a >> b; cout << a * b << endl; return (0); }
#include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <climits...
0
#include <bits/stdc++.h> using namespace std; using ll = long long; int ks(int n){ int ans=1; for(int i=0;i<n;i++){ ans*=10; } return ans; } int ki(int n){ if(n==1){ return 0; } int ans=1; for(int i=0;i<n-1;i++){ ans*=10; } return ans; } bool hantei(int N,int n,int s,int c){ int ss=...
#include <bits/stdc++.h> using namespace std; int prime_factors(long long x){ set<int>s; if(x%2 == 0){ s.insert(2); while(x%2 == 0){ x /= 2; } } for(int i = 3; i <= sqrt(x); i++){ if(x%i == 0){ s.insert(i); while(x%i == 0){ ...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL<<62 #define inf 1000000007 ll a[50]; int main() { for(ll i=0;i<50;i++){ a[i]=49-i; } ll k; cin>>k; for(ll i=0;i<50;i++){ a[i]+=k/50; } for(ll i=0;i<k%50;i++){ a[i]++; } cout << 50<<endl; for(ll i=0;i<50;i++){ cout << ...
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define _USE_MATH_DEFINES #include <math.h> #define NIL = -1; #define all(x) x.begin(),x.end() const ll INF = 1e9; const ll mod = 1e9 + 7; int digit(ll x) { if (x / 10 == 0) return 1; return digit(x / 10) + 1; } ll gcd(long long a,long long...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; #define all(x) (x).begin(), (x).end() #define endl '\n' #define fsp(x) cout << fixed << setprecision(x) const ll inf = LLONG_MAX; const long double pi = M_PI; void Yes() {cout << "Yes" << endl;} void No() {cout << "No" << endl;}...
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <clocale> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <l...
1
#include <cstdio> #include <string> #include <iostream> using namespace std; string s; string Replace( string s1, string s2, string s3 ) { string :: size_type pos( s1.find( s2 ) ); while( pos != string :: npos ) { s1.replace( pos, s2.size(), s3 ); pos = s1.find( s2, pos + s3.size() ); ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++) #define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend...
0
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; int n = N; int O,Y,A,U,M,S,H,J,I; O = N / 100000000; N = N % 100000000; Y = N / 10000000; N = N % 10000000; A = N / 1000000; N = N % 1000000; U = N / 100000; N = N % 100000; M = N / 10000; N = N % 10000; S = N / 1000...
#include<iostream> #include<string.h> using namespace std; int main(){ // int input = 0; char input[10]; cin >> input; // int angka1 = input%10; // int angka2 = input-100-angka1; // angka2 = angka2/10; // int angka3 = input-angka2-angka1; // angka3 = angka3/100; if(input[0] == '7' || input[1] == '7' || input[2] ==...
0
#include<bits/stdc++.h> //#include<tr1/unordered_map> //#include"Bignum/bignum.h" //#define lll bignum #define ls(x) ( x << 1 ) #define rs(x) ( x << 1 | 1 ) //#define mid ( ( l + r ) >> 1 ) #define lowbit(x) ( x & -x ) #define debug(x) (cout << "#x = " << x << endl) #define re register #define For(i, j, k) for(re int i...
#include<iostream> #include<vector> #include<set> #include<queue> #include<map> #include<algorithm> #include<cstring> #include<string> #include<cassert> #include<cmath> #include<climits> #include<iomanip> #include<stack> #include<unordered_map> #include<bitset> #include<limits> #include<complex> #include<array> #includ...
1
#include <bits/stdc++.h> using namespace std; #define all(a)a.begin(),a.end() using ll=long long; const int INF = 1<<30; const ll INFll =1LL<<62; const int mod =(1e9)+7; using P = pair<ll,ll>; int main(){ string s;cin >>s; ll n=s.size(); bool flg=true; if(n%2==1)flg=false; else { for (int ...
#include<iostream> int main() { int x = 0; int n = 0; std::cin >> x; n = x; for (int i = 1; i < 3; i++) n *= x; std::cout << n << std::endl; }
0
#include <iostream> #include <algorithm> #include <vector> #include <list> #include <map> #include <string> #include <functional> #include <math.h> #include <utility> using namespace std; typedef pair<int,int> P; int n,rnk[101]; P p[100]; int main() { cin>>n; for(int i=0;i<n;i++){ p[i].first=0; p[i].second=i+1; ...
#include<bits/stdc++.h> #define rep(i,a,b) for (int i=(a); i<=(b); i++) #define per(i,a,b) for (int i=(a); i>=(b); i--) using namespace std; const int maxn = 2005; int v[maxn][maxn], e0[maxn][maxn], e1[maxn][maxn]; int n, m, Q, X1, X2, Y1, Y2; char s[maxn]; int main() { scanf("%d%d%d", &n, &m, &Q); rep (i, 1, n) { ...
0
#include <bits/stdc++.h> using namespace std; long long s[200005],sum[200005],a,b,c,d,maxx,minn,ans=1e18; long long get(int l,int r){ return sum[r]-sum[l-1]; } int n; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&s[i]); sum[i]=s[i]+sum[i-1]; } int l=1,r=3; for(int...
#include<iostream> #include<algorithm> #include<map> #include<vector> #include<cstdint> #include<cstdlib> template<typename T> void fin(T const& t){ std::cout << t << std::endl; exit(0); } int64_t const INF = 1e18; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int N; std::cin >> N; std::vector...
1
#include <iostream> using namespace std; class Data{ private: int a_point, b_point; public: Data(){ a_point=0; b_point=0;} void Add(int a, int b); void Show(); }; struct DataList{ Data dataset; struct DataList* next; }; void Data::Add(int a, int b){ a_point += a; b_point += b; } void Data::Show(){ cout << ...
#include<iostream> using namespace std; int main() { int p1[10000], p2[10000], n, point1, point2, i; while (true) { point1 = 0; point2 = 0; cin >> n; if (n == 0) { break; } for (i = 0; i < n; i++) { cin >> p1[i] >> p2[i]; } for (i = 0; i < n; i++) { if (p1[i] == p2[i]) { point1 += p1[i]; ...
1
#include <iostream> #include <string> using namespace std; int main() { string week[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", }; int end_day[13] = {-1,31,29,31,30,31,30,31,31,30,31,30,31}; int month,day; while(cin >> month >> day) { ...
#include <iostream> #include <stdio.h> int main(void){ int month,day,chek; while(std::cin >> month >> day,month){ int year = 2004; if(month == 1 || month == 2){year--;month+=12;} chek = ((year+ year/4-year/100+year/400+(13*month+8)/5+day)%7); switch (chek) {case 0:puts("Sunday");break; case 1:puts("...
1
#pragma GCC optimize ("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse4") #include"bits/stdc++.h" using namespace std; typedef long long ll; #define int ll #define all(x) x.begin(), x.end() #define trav(i,a) for(auto &i:a) inline int in(){int x;scanf("%lld",&x);return x;} int cnt[100][100]; int32_t m...
// A. #include <stdio.h> typedef long long LL; char buffer[3072000]; LL cnt[20][20]; LL sum[20][20]; LL n; LL ans; int main(int argc, char* argv[]) { char c, *bufptr = buffer; fread(buffer, 1, 3072000, stdin); while ((c = *bufptr++) >= '0') { n = (n * 10) + (c - '0'); } for (LL i = 0; i < n; ++i) { LL x = ...
1
#include <iostream> #include <string> #include <cstring> #include <sstream> #include <fstream> #include <vector> #include <algorithm> #include <cmath> #include <stack> #include <queue> #include <chrono> #include <numeric> using namespace std; class cLSearch { int mn, mq; string mS, mT; vector<int> vs, vt; int ans...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back const int N = 16; int a[N + 1][N + 1]; ll value[1 << N]; ll f[1 << N]; int main() { int n; cin >> n; for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ++j) { cin >> a[i][j]; } } fo...
0
#include <iostream> #include <algorithm> using namespace std; int main() { int scores[2] = {0, 0}; int points[2][10]; for (int i = 0; i < 2; ++i) { for (int j = 0; j < 10; ++j) { cin >> points[i][j]; } sort(points[i], points[i]+10); for (int j = 0; j < 3; ++j) {...
#include <iostream> #include <algorithm> using namespace std; // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0533 int main() { int a[10], b[10]; for (int i = 0; i < 10; i++) cin >> a[i]; for (int i = 0; i < 10; i++) cin >> b[i]; sort(a, a + 10); sort(b, b + 10); cout << (a[7] + a[8] + a[9]); cout ...
1
#include <iostream> #include <iomanip> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> #include <sstream> #include <cstdlib> #include <cstring> #include <functional> #include <numeric> #include <cmath> #include <climits> #include ...
#include <stdio.h> char str[16][16]; /* void erase(int x, int y) { if (x < 0 || x > 11 || y < 0 || y > 11) return; if (str[y][x] == '0') return; str[y][x] = '0'; erase(x + 1, y); erase(x, y + 1); erase(x - 1, y); erase(x, y - 1); } */ void is(int i, int j) { int n; int k; str[i][j] = '0'; k = 1; ...
1
#include <bits/stdc++.h> using namespace std; int main(){ int r; cin >> r; cout << fixed << setprecision(20) << 2*r*M_PI << endl; }
#include<bits/stdc++.h> using namespace std; #define ll long long int #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define endl "\n" #define REP(i,a,n) for(ll i=a;i<n;i++) #define PER(i,n,a) for(ll i=n;i>a;i--) #define REP1(i,a,n) for(ll i=a;i<=n;i++) #define forit(it,x) for(auto it=(x).begin();it!=...
0
#include <bits/stdc++.h> using namespace std; signed main () { int n; cin >> n; if (n == 0) { cout << 0 << '\n'; return 0; } string ans; while (n) { if (n % (-2) == 0) ans += '0'; else --n, ans += '1'; n /= -2; } reverse(a...
#include <bits/stdc++.h> #include <math.h> using namespace std; int main() { int N, sum, digit; cin >> N; digit = log10(N); sum = 0; for (int i = 0; i <= digit; i++) { sum += N % (int (pow(10, i + 1))) / (int (pow(10, i))); } if (N % sum == 0) { cout << "Yes" << endl; } ...
0
#include<iostream> #include<vector> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<cstdlib> #include<ctime> #include<queue> #include<set> #include<map> #include<stack> using namespace std; typedef long long LL; int gi() { int w=0;bool q=1;char c=getchar(); while ((c<'0'||c>'9') && c!=...
#include<bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(),(v).end() using namespace std; using ll=long long; using pii=pair<int, int>; using vi=vector<int>; using vii=vector<vector<int>>; const ll LINF=1LL<<60; const int INF=1<<29; const int MOD=1e9+7; template<typename T> bool chmax(T &a,const T b...
0
#include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <map> #include <algorithm> #include <math.h> #include <cassert> #define rep(i,n) for(int i = 0; i < n; ++i ) using namespace std; using ll = long long; using P = pair<int,int>; int main() { ll n,a,b; c...
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int N,A,B,n; cin>>N>>A>>B>>n; vector<int> C(N); C[0]=n; int ans=0; for(int i=1;i<N;i++){ cin>>C[i]; ans+=min((C[i]-C[i-1])*A,B); } cout<<ans<<endl; }
1
#include<bits/stdc++.h> //Ithea Myse Valgulious namespace chtholly{ typedef long long ll; #define re0 register int #define rel register ll #define rec register char #define gc getchar //#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++) #define pc putchar #define p32 pc(' ') #define pl puts("...
#include <bits/stdc++.h> using namespace std; inline void prep () { cin.tie (0); cin.sync_with_stdio (0); }; const double pi = acos(-1.); //printf(%.12lf\n,mid); // __builtin_popcount(int) count 1's in binary // get decimal part of number /* double intpart; double thiss = modf((double)(n*m)/(double)k, &intpart); ...
1
#include<bits/stdc++.h> #define rep(i,n) for(int i=0; i<(n); i++) using namespace std; using ll=long long; int main(){ int N,count=0; cin >> N; vector<int> L(N); rep(i,N) cin >> L.at(i); for(int i=0; i<N-2; i++){ for(int j=i+1;j<N-1;j++){ for(int k=j+1;k<N;k++){ int a=L.at(i),b=L.at(j)...
#include <bits/stdc++.h> using namespace std; #define forn(i, n) for(int i = 0; i < int(n); i++) #define fore(i, l, r) for(int i = int(l); i < int(r); i++) #define pb push_back #define all(x) x.begin(), x.end() #define sz(a) int((a).size()) typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; ...
1
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (int)x.size() #define rep(i,n) for(int i = 0; i < n; i++) #define REP(i, k , n) for(int i = k; i <= n; i++) typedef long long ll; const char nl = '\n' ; const ll MOD = 1e9 + 7; int main...
#include <bits/stdc++.h> #include <ext/rope> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#define int long long #define pb push_back #...
0
#include <bits/stdc++.h> using namespace std; int main(){ vector<int> a(2); int k; cin >> a[0] >> a[1] >> k; int times = 0; int side = 0; while(1){ if(a[side] % 2 == 1) a[side] -= 1; a[side] /= 2; a[(side+1)%2] += a[side]; side += 1; side %= 2; t...
#include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <numeric> #include <string> #include <algorithm> #include <iostream> #include <vector> #include <bitset> #include <queue> #include <map> #include <utility> #include<functional> #include <iomanip> #include <unordered_map> #include <set> us...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n; cin>>n; vector<vector<pair<ll,ll>>>ro(n+1); for(int i=0;i<n-1;i++){ ll a,b,c; cin>>a>>b>>c; ro[a].push_back({b,c}); ro[b].push_back({a,c}); } queue<ll>que; ll q,k; cin>>q>>k; ll dis[114514]; for(int i=1;i<=n;i++)dis...
#include <iostream> #include<iomanip> #include <cmath> #include <climits> #include <algorithm> #include <stdio.h> #include <vector> #include <queue> #include <tuple> #include <map> #include <list> #include <string> #include <numeric> #include <utility> #include <cfloat> #include <set> using namespace std; int sqrtN...
0
#include <iostream> #include <vector> #include <algorithm> #include <deque> using namespace std; long long INF = 1e18; int main() { int N; cin >> N; vector<long long> A(N); for(int i = 0; i < N; i++) { cin >> A[i]; } deque<long long> dp(N, INF); for(int i = 0; i < N; i++) { ...
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; typedef long long ll; typedef long double ld; const int inf=1e9+7; const ll longinf=1LL<<60; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define F first #define S second constexpr char ln = '\n'; const...
0
#include <iostream> using namespace std; static int bubbleSort(int *A, int N){ int temp, count=0; bool flag; do{ flag = false; for (int j = N - 1; j >= 1; j--){ if (A[j] < A[j - 1]){ temp = A[j]; A[j] = A[j - 1]; A[j - 1] = temp; count++; flag = true; } } } while (flag); return co...
#include <iostream> #include <complex> #include <cmath> #include <iomanip> #include <algorithm> using namespace std; void rotate(int a[], string str) { for(auto itr = str.begin(); itr != str.end(); ++itr) { int tmp; switch (*itr) { case 'N': tmp = a[0]; ...
0
#include <bits/stdc++.h> using namespace std; #define LL long long #define DB double #define ST string #define BS bitset #define VE vector #define VL vector<LL> #define VP vector<pair<LL,LL>> #define VVL vector<vector<LL>> #define PQ priority_queue<LL> #define PQS priority_queue<LL, vector<LL>, greater<LL>> #define PB ...
#include <bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define MAX 2000005 #define MOD 1000000007 #define MOD2 998244353 #define pb push_back #define mp make_pair #define pii pair<ll,ll> #define vi vector<...
1
#include <iostream> using ll = long long int; constexpr ll mod = (1e9)+7; constexpr int MAX = 2*1e5+10; ll fac[MAX]; void init() { fac[0]=1; for(int i=1;i<MAX;++i) fac[i]=(fac[i-1]*i)%mod; } ll inv(ll x){ ll n = mod-2; ll y = 1; ll z = 1; for(int i=0;i<40;++i){ if(n&y) z = (z*x)%mod; x=(x*x)%mod; y*...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; const int mod = 1e9 + 7; ll pwr (ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; } ll inv (ll a) { return pwr (a, mod - 2); } ll nCr (ll n, ll r) { l...
1
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #define LL long long #define mod 998244353 #define inv2 499122177 #define M 1000020 using namespace std; namespace IO{ int Top=0; char SS[20]; void write(int x){ if(!x){putchar('0');return;} if(x<0) x=-x,putchar('-'); while(...
#include <stdio.h> using ll = long long; const int MX = 1000005, MM = 998244353; ll F[MX], I[MX], IF[MX]; ll C(int x,int y){return F[x+y]*IF[x]%MM*IF[y]% MM;} int main() { int N, M, i; I[1]=F[0]=IF[0]=F[1]=IF[1]=1; for(i = 2; i < MX; i++){ I[i] = (MM - MM/i) * I[MM%i] % MM; F[i] = F[i-1] * i % MM; IF[i] = ...
1
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) #define INF 1000000007 using namespace std; int main(){ long n; cin >> n; string ans = ""; while(n){ if(n%2==0){ ans.push_back('0'); }else{ ans.push_back('1'); n -= 1; } n /= (-2); } if(int(ans.size())==0)ans.pu...
#include <bits/stdc++.h> template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}} template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}} #define ll long long #define double long double #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i...
1