code_file1
stringlengths
80
4k
code_file2
stringlengths
91
4k
similar_or_different
int64
0
1
#include<bits/stdc++.h> using namespace std; const int MAXN=1000010; int cnt=0,G[100]; void Insertion_Sort(int s,int t,int n,int* A) { for(int i=s+t;i<n;i+=t) { int key=A[i],j=i-t; while(j>=0&&A[j]>key) { A[j+t]=A[j]; j-=t; cnt++; } if(A[j+t]!=key) { A[j+t]=key; //cnt++; } } } int m...
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> int main() { int N; cin>>N; string s,t; cin>>s>>t; reverse(s.begin(),s.end()); for(int i=N;i<=2*N;i++){ string S=s.substr(0,2*N-i); reverse(S.begin(),S.end()); if(S==t.substr(0,2*N-i)){cout<<i<<endl;return 0;} ...
0
#include <bits/stdc++.h> using namespace std; const long long INF = (1LL<<32); const long long MOD = 1000000007; const long double PI = 3.1415926; #define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++) #define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFO...
#include "bits/stdc++.h" using namespace std; typedef long long ll; const int nax = 5010; const ll INF = 1e18L; ll dp[nax][nax]; int main() { ios::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif for (int i = 0; i < nax; ++i) { ...
0
#include <bits/stdc++.h> #define rep(i, a, b) for(int i = a; i < b; i++) #define Rep(i, a, b) for(int i = a; i <= b; i++) #define repr(i, a, b) for(int i = a; i >= b; i--) #define _GLIBCXX_DEBUG #define Vl vector<ll> #define Vs vector<string> #define Vp vector<pair<ll, ll>> #define ld long double using ll = long long; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 998244353; ll Ep(int x, int y){ if(y == 1) return x; ll r = Ep(x,y/2); if(y%2 == 1) return r *r%MOD *x%MOD; else return r *r%MOD; } int main(){ int n, x; cin >> n; cin >> x; if(x != 0){ cout << 0 << endl; retur...
1
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<pair<int,int>> v; for(int i = 1; i <= n; i++){ int x, y; cin >> x >> y; v.push_back({x, y}); } int result = 0; for(int i = 1; i < v.size(); i++) if(v[i].second < v[0].seco...
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cstdlib> #include <string> #include <iostream> #include <climits> using namespace std; int main() { int i, j, k, to, min, temp_result; int n; int r[100], c[100]; int result[100][100]; cin >> n; for (i = 0; i < n; i++) { cin >> r[i] >> c[i]; result[...
0
#include<bits/stdc++.h> using namespace std; int main(){ string S; cin >> S; int ans = 753; for(int i = 0; i <= S.size()-3; ++i){ int buf = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0'); ans = min(ans, abs(buf-753)); } cout << ans << endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; cout<<n + (n*n) + (n*n*n); }
0
#include <bits/stdc++.h> using namespace std; #define FOR(i, j, k) for(int i=(j); i<=(k); i++) #define FFOR(i, j, k) for(int i=(j); i<(k); i++) #define DFOR(i, j, k) for(int i=(j); i>=(k); i--) #define bug(x) cerr<<#x<<" = "<<(x)<<'\n' #define pb push_back #define mp make_pair #define bit(s, i) (((s)>>(i))&1LL) #define...
#include <algorithm> #include <array> #include <assert.h> #include <bitset> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <fstream> #include <iomanip> #include <iostream> #include <istream> #include <map> #include <math.h> #include <numeric> #include <ostream> ...
0
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const ll maxn=1e5+10; ll mm,m,n,a[60]; ll f[60]; ll ans; inline void read(ll &x) { ll f;char c; for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1; for (x=0;c<='9'&&c>='0'...
#include<bits/stdc++.h> using namespace std; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename F> struct FixPoint : F{ FixPoint(F&& f):F(forward<F>(f)){} template<typename... Args> decltype...
1
#include<iostream> #include<algorithm> #define int long long using namespace std; const int N=1e5+2; pair<int,pair<int,int> > ar[N]; pair<int,int> wow[N]; int sum[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,x,i,j,k,l=0,val,val1,max1; int lef=0,rig=0,mid; cin>>n>>x; for(i=1;i<=n;i++){ cin>>ar[i...
#include<bits/stdc++.h> #define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i) #define DREP(i,a,b) for(int i=a,i##_end_=b;i>=i##_end_;--i) #define MREP(i,x) for(int i=beg[x],v;v=to[i],i;i=las[i]) #define debug(x) cout<<#x<<"="<<x<<endl #define fi first #define se second #define mk make_pair #define pb push_back #d...
0
#include <iostream> using namespace std; int solve(int x){ if(x == 1) return 3; else if(x == 2) return 2; else if(x == 3) return 1; else return 0; } int main() { // your code goes here int x, y; cin>>x>>y; int answer = solve(x); answer += solve(y); if(x == y && x == 1) answer += 4; cout<<answer * 100000; ret...
#include <bits/stdc++.h> using namespace std; int main() { double a; /* 現在のレーティング */ double b; /* 目標のレーティング */ // // ( a + x ) / 2 = b // x = 2b -a // cin >> a; cin >> b; cout << (2.0 * b) - a << endl; }
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() { ll N, A, B, C, D, E; cin >> N >> A >> B >> C >> D >> E; ll ans = 5; ll mincap = min(min(min(A, B), min(C, D)), E); ans += N / mincap - 1; if (...
// Copyright © 2019 Diego Garcia Rodriguez del Campo. All rights reserved. #include<bits/stdc++.h> #define MAX 305 #define MOD 998244353 using namespace std; #define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0); typedef long long i64; i64 N, sum; i64 a[MAX]; i64 memo[MAX][90005]; i64 dp( i64 x , i64 s ) { ...
0
#include <bits/stdc++.h> using namespace std; int main() { // int num; string str; long long cnt = 0; long long all = 0; cin >> num >> str; vector<int> r; vector<int> g; vector<int> b; for (int i = 0; i < num; i++) { if (str.at(i) == 'R') r.push_back(i); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> r,g,b; for(int i = 0; i < n; i++) { char x; cin >> x; if(x=='R') r.push_back(i+1); if(x=='G') g.push_back(i+1); if(x=='B') b.push_back(i+1); } ...
1
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include <numeric> using namespace std; #define int long long typedef long double ld; #define pii pair<int, int> #define vi vector<int> #define vii vector<vi> #define viii vector...
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; type...
1
#include <bits/stdc++.h> using namespace std; using ll = long long; using vec = vector<ll>; using mat = vector<vec>; using pll = pair<ll,ll>; #define INF (1LL << 60) #define MOD 1000000007 #define PI 3.14159265358979323846 #define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i)) #define FORR(i,v) for(auto (i...
#include <bits/stdc++.h> # define M_PI 3.14159265358979323846 /* pi */ using namespace std; int main() { int N; cin >> N; vector<int>A(N); int count = 0; int result = 200; for (int i = 0; i < N; i++) { cin >> A.at(i); while (true) { if (A.at(i) % 2 != 0 || A.at(i) == 0) { break; } ...
1
#include<bits/stdc++.h> using namespace std; int main(){ int n,l; cin >> n >> l; if(l>=0)cout << (2*l+n-1)*n/2-l << endl; else if(n+l>0){ cout << (2*l+n-1)*n/2 << endl; } else { cout << (2*l+n-1)*n/2-(l+n-1) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int n, l; cin >> n >> l; int ans = 0; for(int i=l; i<l+n; ++i){ if(l+n-1 < 0 && i == l+n-1) continue; if(l > 0 && i == l) continue; ans += i; } cout << ans << endl; }
1
#include<stdio.h> #include<math.h> int main(){ double x1, x2; double y1, y2; double L, l; scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2); L = pow(x2-x1, 2.0) + pow(y2-y1, 2.0); l = sqrt(L); printf("%f", l); return 0; }
#include <iostream> #include <stdio.h> #include <math.h> #include <string> using namespace std; int main() { double x1, y1, x2, y2, num, ans = 0, dou = 1, xx; cin >> x1 >> y1 >> x2 >> y2; num = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1); while (dou < num) { dou *= 10; } xx = dou; for (int i = 0; i < 100; i++) ...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i,n) for(int i=n; i>-1; --i) #define ALL(a) (a).begin(),(a).end() #define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); } #define CINA(a,n); REP(i,(n)){ cin >> (a)[...
#include <bits/stdc++.h> #include<math.h> #include<algorithm> #define rep(i,n) for (int i = 0; i < (n) ; ++i) using namespace std; using ll = long long ; using P = pair<int, int> ; #define PI 3.14159265358979323846264338327950 #define INF 1e18 #define mod 1000000007 int main () { int n, q ; string s ; cin...
0
#include<iostream> #include<iomanip> #include<cassert> #include<stdexcept> #include<utility> #include<functional> #include<numeric> #include<cmath> #include<algorithm> #include<cstdio> #include<cstdlib> #include<array> #include<stack> #include<queue> #include<deque> #include<vector> #include<complex> #include<set> #inc...
#include <iostream> #include <algorithm> #include <bitset> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #include <complex> #include <string.h> #include <numeric> using namespace std; //#define int long long #define reps(i,s,n) for(int (i)=(s);(i...
1
//Author:xht37 #include <bits/stdc++.h> #define ui unsigned int #define ll long long #define ul unsigned ll #define ld long double #define pi pair <int, int> #define fi first #define se second #define mp make_pair #define ls (p << 1) #define rs (ls | 1) #define md ((t[p].l + t[p].r) >> 1) #define vi vector <int> #d...
#include <iostream> #include <cstdio> #define il inline #define ri register using namespace std; int main(){ //freopen("in","r",stdin); //freopen("out","w",stdout); int n,d1,d2; scanf("%d%d%d",&n,&d1,&d2); int a[4]{},n1(n<<1),b1(0),b2(0); for(int i(d1);~i&1;++b1,i>>=1); for(int i(d2);~i&1;++b2,i>>=1); for(int i...
1
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; int N, K; const ll MOD = 998244353; ll F[4002], F_inv[4002]; ll modpow(ll a, ll b) { ll rtn = 1, kakeru = a; while (b > 0) { if (b & 1)rtn *= kakeru; kakeru *= kakeru; kakeru %= MOD; rtn %= MOD; b >>= 1; } return rtn; ...
#include<bits/stdc++.h> using namespace std ; #define Next( i, x ) for( register int i = head[x]; i; i = e[i].next ) #define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i ) #define drep( i, s, t ) for( register int i = (t); i >= (s); -- i ) #define re register #define int long long int gi() { char cc = getc...
1
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <queue> #include <climits> #include <set> #include <map> #include <stack> #define ll long long using namespace std; int main() { double n; cin >> n; double ave=0; vector<double> a(n); for (ll i =0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; double average = (double)accumulate(a.begin(), a.end(), 0)/n; int ans = 0; double minv=100100100; r...
1
#include <iostream> #include <iomanip> #include <algorithm> #include <complex> #include <utility> #include <vector> #include <string> #include <stack> #include <queue> #include <tuple> #include <cmath> #include <bitset> #include <cctype> #include <set> #include <map> #include <numeric> #include <functional> #define _ov...
#include <iostream> #include <stdio.h> #include <vector> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <stack> #include <queue> #include <algorithm> #include <string.h> #include <string> #include <math.h> #include <iomanip> using namespace std; #define SORT(v) sort((v).begin(...
0
#include <bits/stdc++.h> using namespace std; int main(){ int X,Y; cin >> X >> Y; int ans=0; vector<int> a={0,300000,200000,100000}; if(X<=3) ans+=a.at(X); if(Y<=3) ans+=a.at(Y); if(X==1 && Y==1) ans+=400000; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { cin.tie(0); ios::sync_with_stdio(false); int x, y; cin >> x >> y; --x, --y; int c[] = { 300000, 200000, 100000, 0 }; cout << c[min(x, 3)] + c[min(y, 3)] + (!x && !y ? 400000 : 0) << endl; return (0); }
1
#define scanf_s scanf //#define gets_s gets #include <stdio.h> #include <string> #include <iostream> #include <math.h> using namespace std; #define MAX 101 #define MIN -100001 #define _MAX 8 int main(void) { char roman[102]; char fig[8] = { "IVXLCDM" }; int value[7] = { 1,5,10,50,100,500,1000 }; int sum = 0, b =...
#include <iostream> using namespace std; int convert( char c ) { switch ( c ) { case 'I': return 1; case 'V': return 5; case 'X': return 10; case 'L': return 50; case 'C': return 100; case 'D': return 500; case 'M': return 1000; } } int main( void ) { string i...
1
#include<iostream> #include<string> using namespace std; int main(){ string a,b,c; int ca=0,cb=0,cc=0,flag=0,ans=0; cin>>a>>b>>c; for(int i=0;i<a.size()+b.size()+c.size();i++){ if(flag==0){ if(ca==a.size()){ ans=1; break; } ...
#include <bits/stdc++.h> #define rep(i, ns, ne) for (int i = ns; i < ne; ++i) using namespace std; int main() { vector<queue<char>> v(3); string s; rep(i, 0, 3) { cin >> s; for (char c : s) { v[i].push(c); } } int tmp, x = 0; while (true) { if (v[x].empty()) { break; } ...
1
#include <cstdio> #include <iostream> #include <cassert> #include <string> #include <algorithm> #include <cstring> #include <utility> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #include <cmath> #include <deque> using namespace std; typedef long long LL; typedef pair<int, int> pii;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll d; map < ll, ll > mp[20]; ll pw10[20]; ll coef[20]; ll gc[20]; int LEN = 0; int val[25]; int val0[25]; ll solve(int where, ll need) { //cout << where << " " << need << endl; if (where == LEN) { return (need == 0); } if (gc[w...
1
#include <iostream> using namespace std; const int MAX_N = 100005; int n, A[MAX_N], B[MAX_N], C[MAX_N], pos[3 * MAX_N], rev[3 * MAX_N]; void wypisz() { cout << "----------------------\n"; for(int i = 1; i <= n; i++) cout << A[i] << " "; cout << endl; for(int i = 1; i <= n; i++) cout << B[i] << " "; ...
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define ll long long #define read1(x) ...
0
#include <bits/stdc++.h> using namespace std; int dp[305][305][305]; string s; int my(int l,int r,int k) { if (dp[l][r][k]!=0) { return dp[l][r][k]; } else if (l==r) { dp[l][r][k]=1; return 1; } else if (l+1==r) { if (s[l]==s[r]||k>0) { dp[l][r][k]=2; return 2; } else { dp[l][r][k]=1;...
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " : " << x << '\n' using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<ll, ll> pll; ll Mod = 998244353; const int N = 2e3 + ...
0
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで #include <bits/stdc++.h> #define mod 1000000007 #define INF LLONG_MAX #define ll long long #define ln cout<<endl #define Yes cout<<"Yes"<<endl #define NO cout<<"NO"<<endl #define YES cout<<"YES"<<endl #define No cout<<"No"<<endl #define REP(i,m,n) for(ll ...
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { string S; cin >> S; string T = S.substr(2, S.size()-3); int count = 0; rep(i, T.size()) if( T[i] == 'C' ) count++; int o = 0; rep(i, S.size()) if( S[i] < 'a' || S[i] > 'z'...
0
#include <bits/stdc++.h> using namespace std; #define PI 3.141592653589793 #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < n; i++) #define all(v) v.begin(), v.end() typedef long long ll; typedef long double ld; int main() { ll A, B; cin >> A >> B; vector<ll> num_A; vector<ll> num_B; v...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> #define ll long long int #define ff first #define ss second #defin...
1
#include <iostream> using namespace std; int main(){ int x, y; cin >> x >> y; if(x==1&&y==1){ cout << 1000000 << endl; }else if(x==1&&y==2) { cout << 500000 << endl; }else if(x==1&&y==3) { cout << 400000 << endl; }else if(x==2&&y==1) { cout << 500000 << endl; ...
#include<cstdio> #include<iostream> #include<vector> #include<algorithm> using namespace std; int main(void) { int X, Y; scanf("%d %d", &X, &Y); int award[] = {300000, 200000, 100000, 0}; if (X == 1 && Y == 1) printf("1000000\n"); else printf("%d\n", award[min(3, X - 1)] + award[min(3, Y - 1)]); return 0; }
1
#include <iostream> #include <vector> using namespace std; void getResult(const uint actCount, uint *cookie1, uint *cookie2){ uint *first = cookie1; uint *second = cookie2; for(uint i = 0; i < actCount; i++){ if(*first % 2 != 0){ (*first)--; } uint half = *first / 2; *first = half; *sec...
#include <iostream> #include <iomanip> #include <cmath> int main(int argc, char const* argv[]) { double x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2; double x = std::abs( x1 - x2 ); double y = std::abs( y1 - y2 ); std::cout << std::setprecision(20) << std::sqrt( x * x + y * y ) << std::endl; return 0; }
0
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <atcoder/all> #define F first #define S second #define int long long #define ll long long //#define int unsigned long long #define pb push_back //#define double long double using namespace std; using namespace atc...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; template<class G> class Fenwick_tree{ vector<G> a; public: Fenwick_tree(){} Fenwick_tree(int n){ build(n); } Fenwick_tree(const vector<G>& a){ build(a); } void build(int n){ a.assign(n,G{}); } void bu...
1
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i=0; i<(int)(n); i++) int main(){ int H, W, ans=1; cin >> H >> W; string A[H]; REP(i, H){ cin >> A[i]; } int B[H][W]={}; vector< pair<int, int> > C; REP(i, H){ REP(j, W){ if(A[i][j]=='#'){ B[i][j]=1; C.push_back(make_pair(i, j)); } } } REP(i, ...
#include <bits/stdc++.h> using namespace std; //#define cerr if (false) cerr #define db(x) cerr << #x << "=" << x << endl #define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl #define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl #define dbv(v) cerr <<...
1
/* @uthor: Amit Kumar user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> #include <chrono> using namespace std; using namespace std::chrono; //#include <boost/multiprecision/cpp_int.hpp> //namespace mp = boost::multiprecision; //#def...
//om namah shivaay //faith over fear //no one wants to die,yet death is the destination we all share #include<bits/stdc++.h> using namespace std; #define mp make_pair #define mt make_tuple #define fi first #define se second #define pb push_back #define ll long long #define all(x) (x).begin(), (x).end() #define ral...
1
#include<iostream> #include<queue> #include<cstdio> using namespace std; int main(){ priority_queue<int,vector<int>,greater<int> > que; string ss; int c[5]; while(scanf("%d,%d,%d,%d,%d",&c[0],&c[1],&c[2],&c[3],&c[4])!=EOF){ int dt[14]; for(int i=0;i<14;i++){ dt[i]=0; } for(int i=0;i<5;i++){ que.push(...
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math") #include <bits/stdc++.h> #define ll long long #define ld long double #define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); using namespace std; const int N = 1e5 + 5, M = 4 * N + 5; int head[N], nxt[M], to[M], typ[M], ...
0
#include <map> #include <string> #include <iostream> using namespace std; int main(){ int i,r; string s; map<char,int>m; for(m['I']=1,m['V']=5,m['X']=10,m['L']=50,m['C']=100,m['D']=500,m['M']=1000;getline(cin,s);cout<<r<<endl)for(i=r=0;i<s.size();i++)r+=m[s[i]]*(m[s[i]]<m[s[i+1]]?-1:1); }
#include<iostream> #include<string> using namespace std; int Roman_to_Arabia(char c){ if (c == 'I')return 1; else if (c == 'V')return 5; else if (c == 'X')return 10; else if (c == 'L')return 50; else if (c == 'C')return 100; else if (c == 'D')return 500; else if (c == 'M')return 1000; else return 0; } int mai...
1
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define MAX 510000 #define Rep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep(i, n) for(ll i = 1; i <= (ll)(n); i++) using namespace std; typedef long long int ll; typedef pair<int, int> P; //cout << fixed << setprecision(10);// //最...
#include<cstdio> #include<cmath> #include<algorithm> #include<cstdlib> #include<cstring> using namespace std; int n,a[100005]; bool work(){ int num1=0,num2=0; for(int i=1;i<=n;i++) if(a[i]>1){ if(a[i]&1) num1++; else num2++; } if(!num1&&!num2) return false; if(num2&1) return true; if(num1>1||...
1
#include <cstdio> #include <cstring> using namespace std; int main(void) { int n; char str[10000],c; char *t; scanf("%d\n", &n); for(int i = 0; i < n; i++){ gets(str); while(t=strstr(str, "Hoshino"),t){ t[6] = 'a'; } printf("%s\n", str); } return 0; }
#include<iostream> #include<string> using namespace std; int main(){ int n,pos; string s; while(cin>>n&&n){ getline(cin,s); while(n--){ getline(cin,s); while((pos=s.find("Hoshino",0))!=string::npos) s.replace(pos,7,"Hoshina"); cout<<s<<endl; } } return 0; }
1
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <map> #include <set> #include <cmath> #include <iomanip> using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<long long>; template<class T>using vv = vector<vector<T>>; using vvi = vv<int>; using vvl = ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, r, n) for (int i = (r); i < (n); i++) using ll = long long; using namespace std; void chmax(ll &a, ll b){ if(a < b) a = b; return; } ll n, a[16][16], dp[1<<16]; int main(){ cin >> n; rep(i,n) rep(j,n) cin >> a[i][j]; ...
1
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using LL = long long; using P = pair<int,int>; int main(){ int N, K; cin >> N >> K; int ans = 0; for(int i = 1; i <= N - K + 1; ++i) { ans++; } cout << ans << endl; }
#include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <cstdio> #include <vector> using namespace std; typedef long long ll; const int maxn=1e5+7; int main() { // freopen("input.txt","r",stdin); int n,k; cin>>n>>k; cout<<n-(k-1)<<endl; return 0; }
1
#include<bits/stdc++.h> using namespace std; #define int long long #define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" void solve() { string s;cin>>s; if(s=="MON") cout<<6<<endl; else if(s=="TUE") cout<<5<<endl; else if(s=="WED") cout<<4<<endl; ...
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<long long>lve; typedef vector<pair<ll,ll> > lvp; typedef vector<vector<int> > ivve; #define sp ' ' #define endl '\n' #define F first #define S second #define pb push_back #define mp ma...
1
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using pii=pair<int,int>; #define rep(i,n) for(int i=0;i<n;i++) #define range(i,a,n) for(int i=a;i<n;i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define INF 1e9 #define EPS 1e-9 #de...
#include <iostream> #define INF 1e9 using namespace std; long long cnt; void merge(int A[],int L,int M,int R){ int n1=M-L; int n2=R-M; int a[500000],b[500000]; for(int i=0;i<n1;i++)a[i]=A[L+i]; for(int i=0;i<n2;i++)b[i]=A[M+i]; a[n1]=INF,b[n2]=INF; int i=0,j=0; for(int k=L;k<R;k++){ if(a[i]<=b[j]...
0
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) using namespace std; using Graph = vector<vector<int>>; #define MOD 1000000007 #define MOD2 998244353 #define INF ((1<<30)-1) #define LINF (1LL<<60) #define EPS (1e-10) typedef long long ll; typede...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define rrep(i,n) for(int i=1;i<(n);++i) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define maxs(a, b) a = max(a, b) #define mins(a, b) a = min(a, b) using namespace std; typedef long long ll; typedef pair<int, int> P; co...
0
#include<bits/stdc++.h> using namespace std; inline void read(long long &x) { char ch; bool flag = false; for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true; for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar()); x = flag ? -x : x; } inline void write(long long x...
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using vd=vector<double>; using vvd=vector<vd>; using vl=vector<ll>; using vvl=vector<vl>; using pii=pair<int,int>; using vs=vector<string>; #define rep(i,n) range(i,0,n) #define range(i,a,n) for(int i=a;i<n;i++...
1
#include <bits/stdc++.h> using namespace std; #define ll long long #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define scl(n) scanf("%lld", &n) #define pcl(n) printf("%lld\n", n) #define pcl1(n) printf("%lld ", n) #define nln pr...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <cstdint> #include <cstdio> #include <map> #include <queue> #include <set> #include <stack> #include <deque> #include <unordered_map> #include <unordered_set> #include <bitset> #include <cctype> #in...
1
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int64_t ans = 0; vector<int> a(n); for(int i=0; i<n; i++) { cin >> a[i]; if(i>=1) { ans += max(0, a[i-1]-a[i]); if(a[i-1]-a[i]>0) a[i] = a[i-1]; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct UnionFind{ vector<int> p; UnionFind(int n){ p.resize(n); for(int i=0; i<n; i++) p[i] = i; } int find(int x){ if(p[x] == x) return x; return p[x] = find(p[x]); } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) ...
0
#include <iostream> using namespace std; int main() { int N, Y; cin >> N >> Y; // 答えを格納するための変数 int ares = -1, bres = -1, cres = -1; // 全探索 for (int a = 0; a <= N; ++a) { // a + b が N 以下の範囲で for (int b = 0; a + b <= N; ++b) { int c = N - a - b; if (10000...
#include <bits/stdc++.h> using namespace std; void input(int& rnTrgSu, int& rnTrgKin) { cin >> rnTrgSu >> rnTrgKin; } void searchMoney(int nTrgSu, int nTrgKin) { vector<int> cnvnMoney{10000, 5000, 1000}; int nCalKin; int i, j; for (i = 0; i <= nTrgSu; i++) { for (j = 0; j <= (nTrgSu - i); j++) { ...
1
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; using vec = vector<ll>; using vect = vector<double>; using Graph = vector<vector<ll>>; #define loop(i, n) for (ll i = 0; i < n; i++) #define Loop(i, m, n) for (ll i = m; i < n; i++) #define pool(i, n) for (ll i = n; i >= 0; i--) ...
#include <bits/stdc++.h> using namespace std; const int x[10] = {-1,2,5,5,4,5,6,3,7,6}; void chmax(int &a, const int &b) { if (a < b) a = b; return; } int main(){ int n, m; cin >> n >> m; vector<int> data(m); for (int i = 0; i < m; i++) cin >> data[i]; sort(data.begin(),data.end(),greater<int>()); ...
1
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main(){ int n,m; int P[1010],Q[1000000]; while(true){ cin >> n >> m; if(n==0&&m==0) break; P[0]=0; for(int i=1;i<=n;i++) scanf("%d",&P[i]); int num=0; for(int i=0;i<=n;i++){ for(int j=i;j<=n;j++){ Q[num++]=P[i...
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "math.h" #include "utility" #include "string" #include "map" #include "unordered_map" #include "iomanip" #include "random" using namespace std; const long long int...
1
#include <string> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <queue> #include <iostream> #include <sstream> #include <cstdio> #include <cmath> #include <ctime> #include <cstring> #include <cctype> #include <cassert> #include <limits> #include <functional> #include <...
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) #define fi first #define se second template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; } template<typename A, typename B>...
0
#include <bits/stdc++.h> const double PI = acos(-1); #define rep(i, n) for (int i = 0; i < (int)(n); i++ ) using namespace std; int findSumOfDigits(int n) { int sum = 0; while (n > 0) { // n が 0 になるまで sum += n % 10; n /= 10; } return sum; } int main(){ int a, b, c, d, e, f; cin >> a >> b >> c >> d >...
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <map> #include <set> #include <bitset> #include <limits> typedef long long ll; #define REP(i,n) for(int i=0;...
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(){ double n,m,d;cin >>n>>m>>d; double p; if(d==0){ p=1/n; } else { p=2*(n-d)/(n*...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) #define all(v) v.begin(), v.end() #define sz(v) v.size() #define INF 100000000000000 //10^14 100兆 // aよりもbが大きいならばaをbで更新する // (更新されたならばtrueを返す) t...
1
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<int64_t>A(N); for(int i=0;i<N;i++) cin>>A.at(i); vector<int64_t>B(1+N); map<int64_t,int64_t>M; M[1]=A.at(0); for(int i=2;i<=N;i++) if(i%2==1) M[i]=M.at(i-2)+A.at(i-1); B.at(0)=0; B.at(0)=0; B.at(2)=max(A.at(...
#include <iostream> #include <algorithm> using namespace std; int main(void) { int i, j, n, cnt=0; cin >> n; int A[n]; for (i = 0; i < n; i++) cin >> A[i]; for (i = 0; i < n; i++) { for (j = n - 1; j > i; j--) { if (A[j] < A[j-1]) { swap(A[j], A[j-1]); ...
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; int n; void into(){ scanf("%d",&n); } void work(){ } void outo(){ printf("%d\n",(n-2)*180); } int main(){ into(); work(); outo(); return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define endl "\n" typedef long long ll; const double pi=3.14159265358979323846; int ctoi(const char c) { if ('0' <= c && c <= '9') return (c - '0'); return -1; } vector<int> input(int n) { vector<int> vec(n); ...
1
#include <iostream> #include <stdio.h> using namespace std; int main(){ int n[102], tn=0,ni=0,all = 0, i = 0,h=0; int data[1024][10]; int tdata[10] = { 0 }; //input while (1){ cin >> n[ni]; if (n[ni] == 0)break; tn += n[ni]; for (; i < tn; i++){ for (int j = 0; j < n[ni]; j++){ cin >> data[i][j...
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< "...
# include "bits/stdc++.h" using namespace std; using LL = long long; using ULL = unsigned long long; const double PI = acos(-1); template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); } template<class T>constexpr T HINF() { return INF<T>() / 2; } template <typename T_char>T_char TL(T_char cX) { re...
0
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define INF 1.1e9 #define LINF 1.1e18 #define FOR(i,a,b) for (long long i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(), (v).end() #define pb push_back #define fi first #define se second typedef long long ll; typedef pair<i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const double pi=3.141592653589793; typedef unsigned long long ull; typedef long double ldouble; const ll INF=1e18; #define rep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++) template<class T> inline bool ...
0
#include <iostream> using namespace std; int main() { string s; cin >> s; cout << "2018/01/" << s.substr(s.size() - 2) << endl; return 0; }
#include <stdio.h> int main(){ int year; int month; int day; scanf("%d/%d/%d", &year, &month, &day); printf("2018/%02d/%02d\n", month, day); return 0; }
1
//0017 #include <bits/stdc++.h> using namespace std; string str; int find_str(){ if(str.find("the",0) != string::npos) return 1; if(str.find("this",0) != string::npos) return 1; if(str.find("that",0) != string::npos) return 1; return 0; } int main(){ int i,j; while(getline(cin,str)){ for(i = 0;i < 2...
#include <cstdio> #include <cstring> #include <map> using namespace std; const int msg_size = 80; const char int2alp[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; typedef map<char, int> myMap; myMap alp2int; int get_len...
1
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<iomanip> using namespace std; int main(){ long long int n,x,ans=0; cin>>n>>x; vector<long long int>a(10000000); for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n-1;i++){ if((a[i]+a[i+1])>x){ ans+=(a[i]+a[i+1]-x); ...
#include <iostream> using namespace std; int main () { int x, y; cin >> x >> y; int ans = 0; ans += max(4 - x, 0); ans += max(4 - y, 0); if (x == 1 && y == 1) ans += 4; ans *= 100000; cout << ans << endl; }
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<bits/stdc++.h> using namespace std; typedef long long int ll; const ll MAXN = 55556; int main(){ ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); string s; cin >> s; vector < vector < ll > > v(26, vector < ll > ()); ll n = s.length(); for(int i = 0; i < n; i++){ v[s[i] - 'a'].pu...
1
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define rep(i, n) for(int i = 0; i < n; i++) #define REP(i, a, b) for(int i = a; i < b; i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fi first #define se second...
#include <bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<(b);++i) #define erep(i,a,b) for(int i=a;i<=(int)(b);++i) #define per(i,a,b) for(int i=(a);i>(b);--i) #define eper(i,a,b) for(int i=(a);i>=b;--i) #define pb push_back #define mp make_pair #define INF 100100100100 #define MOD 1000000007 #define all(x) (x).begin()...
0
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) #define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n"); template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n; cin >> n; vector<int> r,g,b; for(int i = 0; i < n; i++) { char x; cin >> x; if(x=='R') r.push_back(i+1); if(x=='G') g.push_back(i+1); if(x=='B') b.push_back(i+1); } ...
1
#include <bits/stdc++.h> using namespace std; int levenshtein_distance(string s1, string s2) { vector<vector<int> > dp(s1.size() + 1, vector<int>(s2.size() + 1)); for(int i = 0; i <= s1.size(); i++) { for(int j = 0; j <= s2.size(); j++) { if(i == 0) dp[i][j] = j; else if(j == 0) dp[i][j] = i; else { dp...
#include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; int ans=0; if(a>b) { ans+=a; a-=1; } else { ans+=b; b-=1; } ans+=max(a,b); cout<<ans; }
0
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> //#define __DEBUG__ class Dice { private: int iNS[4]; int iEW[4]; public: Dice( int v1, int v2, int v3, int v4, int v5, int v6 ) { iNS[0] = v1; iNS[1] = v2; iNS[2] = v6; iNS[3] = v5; iEW[0] = v1; iEW[1] = v3; iEW[2]...
// -*- mode: C++ -*- // Dice I // // Write a program to simulate rolling a dice, which can be constructed by the following net. // // // // // // // As shown in the figures, each face is identified by a different label from 1 to 6. // // Write a program which reads integers assigned to each face identified by the la...
1
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define MOD 1000000007 int main() { string s; cin >> s; ...
#include<bits/stdc++.h> #include<boost/variant.hpp> using namespace std; typedef long long ll; typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys; template<typename T> inline void pr(const vector<T> &xs){ for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" "; (xs.empty()?cout:(cout<<xs...
1
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <iostream> #include <algorithm> #include <iomanip> #include <fstream> #include <vector> #include <bitset> #include <queue> #include <stack> #include <map> #include <set> using namespace std; int n,m; int a[105]; i...
#include <bits/stdc++.h> using namespace std; #define ll long long #define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++) typedef pair<int, int> P; int N; vector<int> A; const int MONOID = 0; ll f(ll x, ll y) { return x + y; } void add(ll x, ll y) { ll i = x + N - 1; A.at(i) += y; while ...
0
#include<iostream> #include<vector> #include<queue> #include<climits> using namespace std; typedef long long ll; const ll INF = 2000000000000; const int dmax = 2000000001; int main(){ ll V,E,s,t,cost; cin >> V >> E; ll A[V][V]; for (int i=0;i<V;i++){ for (int j=0;j<V;j++){ A[i][j]=INF; } } for (...
#include<iostream> #include<cstdio> #include<vector> #include<cstdlib> using namespace std; int n,m; int dis[16][16]; int dp[1<<16][16]; int subres[1<<16]; int sum; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) { int x,y,z; scanf("%d%d%d",&x,&y,&z); x--;y--; dis[x][y]=dis[y][x]=z; sum+=z; } for...
0
// #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define uint unsigned int #define ull unsigned long long typedef string str; typedef long long ll; typedef double db; typedef pair<int, int> pii; typedef map<int, int> mii; typedef vector<int> vi; typedef vector<bool> vb; #define pb push_back #def...
/** * auther: moririn_cocoa */ #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #inc...
0
#include <bits/stdc++.h> using namespace std; int main() { string A, B, S; cin >> A >> B >> S; cout << ((regex_match(S, regex("\\d{" + A + "}-\\d{" + B + "}"))) ? "Yes" : "No") << "\n"; }
#include<stdio.h> #include<string.h> int main(){ int a,b,total=0; scanf("%d %d",&a,&b); char s[a+b+2]; scanf("%s", &s); for(int i=0; i<a+b+1 ;i++){ if(i!=a){ if(s[i]>=48 && s[i]<=57){ total++; } } else { if(s[i] == '-'){ ...
1
//#define __USE_MINGW_ANSI_STDIO 0 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #defi...
#include<iostream> #include<cstdio> #include<stack> using namespace std; int main(){ string str ; while ( cin >> str ){ int len = str.size() ; stack<char> container ; for ( int i = 0 ; i < str.size() ; i ++ ){ if ( str[i] == 'T' ){ if ( !container.empty() ){...
0
#include<bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define pb push_back #define ll long long #define ull unsigned long long #define ii pair<int,int> #define iii pair <int,ii> #define iil pair<ll,ll> #define iiil pair<ll,iil> #define max3(a,b,c) max(a, max(b,c)) #define min3(...
#include<iostream> using namespace std; int main(){ int n,a=0,b=0,aa,bb; cin>>n; while(n!=0){ for(int i=0;i<n;i++){ cin>>aa>>bb; if(aa<bb){ b+=aa+bb; }else if(aa>bb){ a+=aa+bb; }else if(aa==bb){ a+=aa; b+=bb; } } cout<<a<<" "<<b<<endl; cin>>n; a=0; ...
0
#include <bits/stdc++.h> using namespace std; #define int long long #define PI 3.141592653589793 #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, a, n) for (int i = a; i < (n); i++) #define rrep(i, n, k) for (int i = (n); i >= (k); i--); #define all(x) (x).begin(), (x).end() #define vi vector<int> templat...
#include <bits/stdc++.h> #include <atcoder/all> #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define all(v) v.begin(), v.end() typedef long long ll; using namespace atcoder; int main(){ int n,q; std::cin >> n >> ...
0
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<cmath> #include<bitset> #include<deque> #include<functional> #include<iterator> #include<map> #include<set> #include<stack> #include<queue> #include<utility> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define a firs...
#pragma GCC optimize ("O2") #pragma GCC target ("avx2") //#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define ...
0
#include <bits/stdc++.h> // #undef DEBUG // Uncomment this line to forcefully disable debug print. #if DEBUG template <typename T> void debug(T value) { std::cerr << value; } template <typename T, typename... Ts> void debug(T value, Ts... args) { std::cerr << value << ", "; debug(args...); } #define dbg(...) ...
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <string> #include <queue> #include <stack> #include <unordered_set> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); ...
1
//#pragma GCC optimize("Ofast") //#ifdef DEBUG //#define _GLIBCXX_DEBUG //#endif // -Ofast // -O3 // -O2 // -fsanitize=address // -fsanitize=undefined // add_compile_options() #include <iostream> #include <map> #include <vector> #include <set> #include <stack> #include <bitset> #include <queue> #include <algorith...
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <cmath> #include <map> #include <stack> #include <queue> #include <iomanip> #define MOD(x) (x + 1000000007) % (1000000007) using namespace std; template <class t> using vec = vector<t>; using ll = long long; const i...
1
#include <iostream> using namespace std; int main() { int a,b,c,d,e; cin>>a>>b>>c>>d; if(a>b) { e=a; a=b; b=e; } if(c>d) { e=c; c=d; d=e; } cout<<(a+c); return 0; }
#include <bits/stdc++.h> #define REP(i,n) for (int i=0; i<(n); ++i) #define REPR(i,n,m) for (int i=(n); i>=(m); --i) using namespace std; using LL = long long; using LD = long double; using PLL = pair<long long, long long>; using PLD = pair<long double, long double>; using VLL = vector<long long>; using VLD = vector<lo...
0
#include <cstdio> #include <cstring> #define ZeroMemory(ptr, size) ::memset(ptr, 0, size) typedef struct { int id; int cost; int acquired; } COMPETITION; typedef struct { int cost; } COMMITEE; #define MAX_N 1000 int MaxAcquiredID(COMPETITION *lpCompes, int num) { int id = 0; int max = 0; for (int i = 0; i ...
#include <stdio.h> int main() { int n,m,b[1000],a[1000]; int sum[1000]={0}; scanf("%d %d",&n,&m); for(int i=0;i<=n-1;i++){ scanf("%d",&a[i]); } for(int j=0;j<=m-1;j++){ scanf("%d",&b[j]); } for(int j=0;j<=m-1;j++){ for(int i=0;i<=n-1;i++){ if(b[j]>=a[i]) {sum[i]=sum[i]+1;b...
1
// #include<bits/stdc++.h> // using namespace std; // int main(){ // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // int tc; // cin >> tc; // while(tc--){ // string s; // cin >> s; // int count_0 = 0, count_1 = 0; // for(char ch : s) // count_0 += 1 - ch + '0', count_1 += ch - '0'; // int ...
#include <bits/stdc++.h> using namespace std; void fail(){ cout << "No" << endl; exit(0); } int main(){ int N; cin >> N; vector<pair<int, int>> task_p, task_n; for(int i=0; i<N; i++){ string S; cin >> S; int s = 0, mn = 0; for(char c : S){ s += (c ...
1
#include <bits/stdc++.h> #define rep(i, n) for(int i= 0; i < (n); i++) using ll= long long int; using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } ll mod= 1e9 + 7; ...
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> II; typedef vector< II > VII; typedef vector<int> VI; typedef vector< VI > VVI; typedef long long int LL; typedef vector<LL> VL; typedef unsigned long long int ULL; #define PB push_back #define MP make_pair #define F first #define S sec...
1
#include <bits/stdc++.h> using namespace std; using str = string; using ss = stringstream; int main() { cin.tie(0); ios::sync_with_stdio(0); int n; str s,t; cin>>n>>s>>t; int ans=2*n; for(int i=n;i>0;i--) { bool c=true; for(int j=0;j<i;j++)if(t[j]!=s[j+n-i]){c=false;...
//using class #include<iostream> #include<cmath> #include<cstdio> using namespace std; class Point{ public: //以下、外部からaccess可能 double x,y; //member Point(double xx,double yy){ //コンストラクタ x = xx; y = yy; } }; double getDistance(Point p1, Point p2){ return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, ...
0
#include<bits/stdc++.h> #define ls u*2 #define rs u*2+1 #define mid (l+r)/2 #define int long long using namespace std; const int N=3e5; int n,m,s,t; int x[N]; int bj[N*2],lmin[N*2],rmin[N*2]; inline int read(){ char c=getchar(); register int s=0; while(c<'0'||c>'9')c=getchar(); while(c>='0'&&c<='9'){ s=s*10+c-'0'...
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> typedef long long ll ; #define rep(i, a, b) for (int i = a; i <= b; ++ i) const int N = 2e5 + 5 ; const ll inf = 1e17 + 7 ; using namespace std ; int n, m, A, B, x[N] ; ll bit[2][2][N], dist[N], f[2][N] ; void put(int ...
1
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <sstream> #include <algorithm> #include <cstdlib> #include <map> #include <queue> #include <utility> #include <vector> #include <set> #include <memory.h> #include <iomanip> #include <bitset> #include <list> #include <stack> #include <deq...
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; string s; cin >> n >> s; vector<int> ans; for(int i = 0; i < 4; i++){ ans.resize(n); ans[0] = i%2; ans[1] = i/2; for(int j = 1; j < n-1; j++){ if(s[j] == 'o'){...
0
#include <iostream> #include <cstdio> #include <algorithm> #include <cassert> #include <vector> #include <string> #include <cmath> #include <map> using namespace std; const int MAX= 10000100; #define loop(i,a,b) for(int i = a ; i < b ; i ++) #define rep(i,a) loop(i,0,a) #define all(a) (a).begin(),(a).end() #define ...
#include<iostream> #include<stdio.h> using namespace std; int main() { int c[5]; while (scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) { for (int i = 0; i < 4; i++) { for (int j = 0; j<4; j++) { if (c[j] > c[j + 1]) { int tmp = c[j]; c[j] = c[j + 1]; c[j + 1] = tmp; } ...
1
#include<cstdio> #include<algorithm> #define fo(i,a,b) for(i=a;i<=b;i++) using namespace std; typedef long long ll; const int maxn=100000+10; int fa[maxn],co[maxn]; bool bz[maxn],pd[maxn]; int i,j,k,l,r,t,n,m,cnt; ll ans; int getfa(int x){ if (!fa[x]) return x; int t=getfa(fa[x]); co[x]^=co[fa[x]]; retu...
#include <bits/stdc++.h> using namespace std; int col[100005]; vector<int> v[100005]; bool dfs(int node,int c) { if (col[node]!=-1) return (col[node]==c); col[node]=c; bool ok=1; for (int u:v[node]) ok&=dfs(u,!c); return ok; } int main() { int n,m,c=0,b=0; scanf("%d%d",&n,&m); while (m--) { int a,b; scan...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REPR(i,n) for(int i=n; i>-1; --i) #define ALL(a) (a).begin(),(a).end() #define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); } #define CINA(a,n); REP(i,(n)){ cin >> (a)[...
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #include <fstream> #include <numeric> using namespac...
0
#include<iostream> #include<iomanip> using namespace std; int main() { double a; double n; double max,min,sum; cin>>n; sum=0; max=-1000000; min=1000000; for( int i=0; i<n; i++ ) { cin>>a; sum+=a; if( max < a ) { max=a; } if( a < min ) { min=a; } } cout <<setprecision(12)<<min<<" "<<max<...
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <functional> #include <queue> #include <set> #include <map> #include <numeric> #include <cstdio> #include <cstring> #include <cmath> #include <cctype> #define rep(i, a) REP(i, 0, a) #define REP(i, a, b) for(int i = a; i < b; ++i) ty...
1
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define ALL(v) (v).begin(), (v).end() using ll = long long; using P = pair<int, int>; constexpr int INF = 1e9; constexpr long long LINF = 1e18; constexpr long long MOD = 1e9 + 7; void solve() { int n; cin >> n; ll...
#include <bits/stdc++.h> #define debug(...) fprintf(stderr, __VA_ARGS__) #ifndef AT_HOME #define getchar() IO::myGetchar() #define putchar(x) IO::myPutchar(x) #endif namespace IO { static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23; inline char myGetchar() { static char buf[IN_BUF], *ps = buf, *pt = buf; if...
1
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int N=100005; int n,a[5][N],i,j,k,x,y,b[N],c[2]; int main() { scanf("%d",&n); for(i=1;i<=3;++i) for(j=1;j<=n;++j) scanf("%d",a[i]+j); for(i=1;i<=n;++i) { x=y=a[1][i]; for(j=2;j<=3;++j) x=max(x,a[j][i]),y=mi...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REP1(i,a,b) for (int i = a; i <= (int)(b); i++) using namespace std; const int MOD=998244353; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> c(n),d(n); REP(i,n) cin >> d[i], c[d[...
0
#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int c = 0; for (char c1 : s) if (c1 == 'R') c++; if (c != 2) cout << c << '\n'; else if (s[1] == 'S') cout << 1 << '\n'; else cout << '2' << '\n'; return 0; }
#include <iostream> using namespace std; int main() { string S; cin>>S; char a=S[0]=='R'; char b=S[1]=='R'; char c=S[2]=='R'; if(a&b&c) { cout<<"3"; } else if(a&b||b&c) { cout<<"2"; } else if(a|b|c) { cout<<"1"; } el...
1
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<queue> #include<cmath> #include<algorithm> using namespace std; typedef long long ll; const int mod=1e9+7; int main(){ int n,x,a; while(~scanf("%d%d%d",&n,&x,&a)){ ll ans=0; if(a>x) ans+=a-x,a=x; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vint; typedef vector<double> vd; typedef vector<ll> vll; typedef vector<string> vstr; typedef vector<vector<int>> vvint; typedef vector<pair<int, int>> v...
1
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "math.h" #include "utility" #include "string" #include "map" #include "unordered_map" #include "iomanip" #include "random" using namespace std; const long long int...
#include<iostream> #include<vector> #include<algorithm> using namespace std; int n,m,a[2000]; vector<int> t; int main(){ a[0]=0; while(cin>>n>>m&&n&&m){ t.clear(); for(int i=1;i<=n;i++)cin>>a[i]; for(int i=0;i<n;i++){ for(int j=i;j<=n;j++){ t.push_back(-(a[i]+a[j])); } } sort(t.begi...
1
//KING NIKAN #include <bits/stdc++.h> using namespace std; typedef long long ll ; ll ans[60] ; int main() { ios::sync_with_stdio(false) ;cin.tie(0) ;cout.tie(0) ; ll k ; cin >> k ; cout << 50 << "\n" ; ll x=k/50 ; for(int i=0 ;i<50 ;i++) { ans[i] = x+49; } ll y = k%50; for(int k=0 ;k<y ;k++)...
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; const int INF=1e9,MOD=1e9+7,ohara=1e6+10; const ll LINF=1e18; using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(int i=(a);i<(b);i++) #define rrrep(i,a,b) for(int i=(a);i>=(b);i--) #define all(v) (v).beg...
1
#include <iostream> #include <string> using namespace std; int main() { string str; cin >> str; string str2; int size = (int)str.size(); str2.resize(size); for(int i =0; i<size;++i) { str2[size-1-i] = str[i]; } cout << str2 << endl; return(0); }
#include <iostream> #include <string> #include <algorithm> int main(void) { std::string str; std::cin >> str; std::for_each(str.crbegin(), str.crend(), [](const char& ch){ std::cout << ch; }); std::cout << std::endl; return 0; }
1
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<iomanip> #include<utility> #include<cmath> #include<set> #include<list> #include<queue> #include<stack> #include<map> #include<set> using namespace std; typedef long long int ll; const ...
#define _CRT_SECURE_NO_WARNINGS // #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define all(c) begin(c), end(c) #define range(i,a,b) for(int i = a; i < (int)(b); i++) #define rep(i,b) range(i,0,b) #define eb emplace_back typedef long long ll; #define int ll auto const inf = numeric_limits<int>::...
1
#include <stdio.h> #include <string.h> #include <string> #include <iostream> #include <vector> #include <sstream> #include <memory> #include <iomanip> std::vector<int> parse_line(std::string const& line) { using namespace std; vector<int> result; istringstream s(line); string element; while (getlin...
#include <iostream> #include <iomanip> using namespace std; int main() { int n; while( cin >> n && n ){ int* table = new int[ (n+1) * (n+1) ](); for( int i = 0; i < n; ++i ){ int sum_col = 0; for( int j = 0; j < n; ++j ){ int d; cin >> d; table[ i * (n+1) + j ] = d; table[ i * (n+1) + n ...
1
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int i, j, n; scanf("%d", &n); for (i = 1; i <= n; i++){ if (i % 3 == 0){ printf(" %d", i); } else{ j = i; while (j > 0){ if (j % 10 == 3){ printf(" %d", i); break; } j /= 10; } } } putchar('\n'); r...
#include<iostream> using namespace std; int x, i = 1; int n; void check_num(); void include3(); void end_check_num(); void check_num() { x = i; if (x % 3 == 0){ cout << " " << i; end_check_num(); }else include3(); } void include3() { if (x % 10 == 3){ cout << " " << i; end_check_num(); }else{ x /= 10...
1
#include <bits/stdc++.h> using namespace std; long long int labs(long long int a, long long int b) { return ((a>b)?a-b:b-a); } long long int lmin(long long int a, long long int b) { return ((a>b)?b:a); } int main() { long long int n, k, x[100001]; cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> x[i]; ...
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <string> #include <vector> #include <map> #include <unordered_map> #include <queue> #include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <limits> using namespace std; long long N, K; vector<long long> x; lon...
1
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<cmath> #include<queue> #include<stack> #include<map> #include<set> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<pii,int> piii; typedef pair<ll,ll> pll; #define reps(i,f,n) for(int i = int(f); i <= ...
#include <iostream> using namespace std; int main(){ int n,p; while(1){ cin>>n>>p; if(n==0&&p==0){ break; } int sum=p; int cnt=0; int *data; int state=0; data = new int[n]; for(int i=0;i<n;i++){ data[i]=0; } while(1){ if(sum==0){ sum+=data[cnt]; data[cnt]=0; } else{ ...
1
#include <bits/stdc++.h> using namespace std; int main(){ int D,G; cin>>D>>G; vector<pair<int,int>> vec(D); for(int i=0;i<D;i++){ cin>>vec.at(i).first>>vec.at(i).second; } int ans=0; for(int i=0;i<(1<<D);i++){ bitset<10> bit(i); int point=0,ans_=0; for(int j=0;j<D;j++){ if(bit.test(j...
#include<cstdio> #include<iostream> using namespace std; int h,w; int l[200010],r[200010]; struct tree{ int l,r; long long tag,v; }tr[2][4*200010]; void build(int i,int l,int r) { tr[0][i].l=l,tr[0][i].r=r; if (l==r) return; int mid=(l+r)>>1; build(i<<1,l,mid); build(i<<1|1,mid+1,r); } void update(int i,int id)...
0