code_file1
stringlengths
80
4k
code_file2
stringlengths
91
4k
similar_or_different
int64
0
1
#include <bits/stdc++.h> using namespace std; typedef double D; typedef long long int LL; #define st first #define nd second #define pb push_back #define PLL pair <LL, LL> #define PII pair <int, int> const int N = 507; const int MX = 1e9 + 7; const LL INF = 1e18 + 9LL; int n; LL tab[N][N]; vector <int> primes; LL...
#include "bits/stdc++.h" using namespace std; #define int long long int #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define se second #define fi first typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vector<int>> matrix; const int inf = 0x3f3f3f3f; const int mod = 1...
0
#include <bits/stdc++.h> using namespace std; typedef long long unsigned int ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--)...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second typedef long long ll; const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7; struct pair_hash { template <class T1, class T2> std::size_t operator () (const std::pair<T1,T2> &p) const { auto h1 = std::hash<T1>{}(...
1
#include <bits/stdc++.h> #include <stdlib.h> using namespace std; typedef long long ll; typedef vector<ll> vec; typedef vector<vec> mat; typedef vector<double> Vec; typedef vector<Vec> Mat; typedef pair<ll,ll> P; typedef pair<double,ll> Pd; typedef pair<double,double> PD; typedef priority_queue<P,vector<P>,greater<P> >...
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using P = pair<ll,ll>; using vl = vector<ll>; using Map = map<ll,ll>; using T = tuple<ll,ll,ll>; using vvl = vector<vector<ll>>; #define all(v) v.begin(), v.end() #define prt(v) cout<<v<<"\n"; #define fi(v) get<0>(v) #define se(v...
0
#include <iostream> int main(void) { int n; std::cin >> n; for(int i = 1; i <= n; i++) { int x = i; if(x % 3 == 0) { std::cout << " " << i; continue; } do { if(x % 10 == 3) { std::cout << " " << i; break; ...
#include <iostream> using namespace std; void check_num(int *i, int *x, int *n, int *flag); void include3(int *i, int *x, int *n, int *flag); void end_check_num(int *i, int *x, int *n, int *flag); void call(int n){ int i = 1; int x = 0; int END_FLAG = 0; check_num(&i, &x, &n, &END_FLAG); } int main(void){ int n...
1
#include <bits/stdc++.h> using namespace std; int main() { int a,b,c,d; cin >> a >> b >> c >> d ; int L=a+b,R=c+d; if (L==R){ cout << "Balanced" << endl; }else cout << (L<R ? "Right" :"Left") << endl; }
#pragma region template 2.4 #include <bits/stdc++.h> using namespace std; template <typename T> using pq_asc = priority_queue<T, vector<T>, greater<T>>; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector<string> vs; #define REP(i, n) for ...
0
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(false); int x, y; cin >> x >> y; int f = 300000; int s = 200000; int t = 100000; int ans = 0; if (x == 1) ans += f; else if (x == 2) ans += s; else if (x == 3) ans += t; if (y == 1) a...
#include <bits/stdc++.h> using namespace std; long long ans, n; int main() { string s; cin >> n >> s; for (int i = 0; i < (1 << n); i++) { string lr, lb; for (int j = 0; j < n; j++) { if (i & (1 << j)) lr += s[j]; else lb += s[j]; ...
0
#include "bits/stdc++.h" using namespace std; template<typename Itr> auto partition2(const Itr first, const Itr last){ auto i=first; for(auto j=first; j!=last; ++j){ if(*j<=*last){ iter_swap(i, j); ++i; } } iter_swap(i, last); return i; } int32_t main(){ size_t n; cin>>n; vector<uint32...
#include <iostream> #include <algorithm> #include <stack> #include <string> #include <queue> #include <cstdlib> #include <cstdio> #include <vector> #include <list> #include <string.h> #define _USE_MATH_DEFINES #include <math.h> using namespace std; int Partition(int a[], int p, int r) { int x = a[r]; int i = p-1; ...
1
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i=0; i<n; i++) #define pb push_back #define int long long const int ofs = 12800; int H, W; int A[82][82], B[82][82]; bool dp[82][82][25610]; signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> H >> W; rep(i, H) rep(j, W)...
#include <bits/stdc++.h> #define rp(i,n) for(int i=0; i<n; i++) using namespace std; using ll=long long; using P=pair<int,int>; using G=vector<vector<int>>; bool dp[6410][20000]; int abs(int x,int y){ if(x>=y) return x-y; else return y-x; } int main(){ int h,w; cin >> h >> w; vector<int> a(h*w), b(h...
1
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める int main() { int h, w; cin >> h >> w; vector<vector<char>> s(h, vector<char>(w)); rep(i,h) rep(j, w) cin >> s[i][j]; rep(...
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ int N,K,mx=0,gc=0; cin>>N>>K; vector<int> A(N); for(int &i:A){ cin>>i; mx=max(mx,i),gc=__gcd(gc,i); } if(K<=mx && K%gc==0)puts("POSSIBLE"); else puts("IMPOSSIBLE"); }
0
#include <bits/stdc++.h> #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 repr(i, n) for (ll i = n; i >= 0; i--) #define fi first #define sc second #define pb push_back #define COUT(x) cout << (x) << endl #define COUTF(x) cout << setprecision(15) << (x) <...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ar array #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_u...
1
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) using ll = long long; int main(){ int a,b,c; cin>>a>>b>>c; if((a-b == 0)+(a-c == 0)+(b-c == 0)==1){ cout<<"Yes"<<endl; }else{ cout<<"No"<<endl; } }
#include <bits/stdc++.h> #include <unordered_map> #include <unordered_set> #define pb push_back #define mpr make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define ll long long #define ld long double #define all(arr) arr.begin(), arr.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define fo(i,...
1
#include<bits/stdc++.h> using namespace std; /* 変数名を被らせない デバッグコードを取り除く */ #define ANSWER(x) cout<<x<<endl #define debug(x) cout<<#x<<": "<<x const int MAX_INT = 1000000; int dp[31]; int n; int solve(int a); int main(){ while(1){ memset(dp,-1,sizeof(dp)); cin >> n; if(n==0)break; cout << (solve(n)/1...
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--) #define all(a) (a).begin(),(a).end() ...
0
/* @uthor: Varun Mishra "varun21999" -> Codechef, Codeforce, Hackerrank, Hackerearth; */ //#include<boost/multiprecision/cpp_int.hpp> //using boost::multiprecision::cpp_int; #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using...
#include <bits/stdc++.h> using namespace std; int main() { long long n,m,d; cin>>n>>m>>d; cout << fixed << setprecision(8); double ans=1.000000*(n-d)/n*(m-1)/n; if(d!=0)ans*=2; cout<<ans<<endl; }
0
#include <bits/stdc++.h> using namespace std; // ----------- define -------------- #define int long long #define vi vector<int> #define vc vector<char> #define ii pair<int,int> #define fi first #define sc second #define all(x) (x).begin(),(x).end() #define get_bit(x, k) ((x >> k) & 1) // ------------------------------...
#include <bits/stdc++.h> using namespace std; typedef long long lint; #define rep(i,n) for(lint (i)=0;(i)<(n);(i)++) #define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++) #define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--) #define INF (1ll<<60) #define all(x) (x).begin(),(x).end() const lint MOD =1000000007; const lint MA...
1
#include <stdio.h> int main(){ int l, r, ll, rr, minn; scanf("%d%d", &l, &r); ll = l % 2019; rr = r % 2019; minn = 2019; if(r - l > 2019) rr += 2019; for (int i=ll;i<rr;i++){ for (int j=ll+i-ll+1;j<rr+1;j++){ if(minn > i * j % 2019){ minn = i * j % 2019; ...
#include <iostream> #include <algorithm> #define flush fflush(stdout) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> Pl; const int mod = (int)1e9 + 7, INF = (int)1e9; const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 }; int main(void) { int l, r, i, j, ans; scanf("...
1
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <iostream> // cout, endl, cin #include <iomanip> #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility...
#include <iostream> #include <algorithm> #include <vector> #include <cstring> #include <cstdio> #define int long long #define pb push_back #define mp make_pair #define INF 0x3f3f3f3f #define Inf 1000000000000000000LL #define F first #define S second using namespace std; typedef pair<int,int>pii; const int maxn=500010; ...
0
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { cin.tie(0); ios::ios_base::sync_with_stdio(false); int n, q; cin >> n; vector<int>S(n); for (int i = 0; i < n; ++i)cin >> S[i]; sort(S.begin(), S.end()); cin >> q; vector<int>T(q); for (int i = 0; i < q; ++i)cin >> T...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() string char_to_string(char val) { return string(1, val); } int char_to_int(char val) { return val - '0'; } int main() { int N; cin >> N; string A, ...
0
#include <iostream> #include <iomanip> #include <vector> #include <map> #include <algorithm> #include <string> #include <numeric> #include <math.h> using namespace std; void func() { double D,T,S; cin >> D>>T>>S; if(D/S <= T) cout << "Yes" << endl; else cout << "No" << endl; } int main() { // while(1) fun...
#include <iostream> #include <regex> #include <stdio.h> #include <string> using namespace std; int main() { int A, B; string S; cin >> A >> B >> S; regex rx(R"([0-9]{)" + to_string(A) + R"(}-[0-9]{)" + to_string(B) + R"(})"); if (regex_match(S, rx)) { printf("Yes\n"); } else { printf("No\n"); } ...
0
#include <bits/stdc++.h> #define mov(x) (1<<(x)) using namespace std; template <typename T> void cmin(T &x, const T &y) { if(y < x) x = y; } template <typename T> void cmax(T &x, const T &y) { if(y > x) x = y; } template <typename T> void read(T &x) { x = 0; char c = getchar(); bool f = 0; while(!isdigit(c) && ...
#include <iostream> #include<algorithm> using namespace std; typedef long long ll; ll sum[200010]; int bin_s(int l,int r) { ll g=(sum[l]+sum[r])/2; int ok=l,ng=r; while(ok+1<ng){ int mid=(ok+ng)/2; if (sum[mid]<=g)ok=mid; else ng=mid; } if(g-sum[ok]<sum[ng]-g)return ok; else return ng; } int main() { int ...
0
#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> // int64_t, int*_t #include <cstd...
#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"); #define degreeToRadian(deg) (((deg)/360)*2*M_PI) #define radianTodegree(rad) (((rad)/2/M_PI)*360) template<class T> inline bool chmax(T& a, T b) { i...
1
#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<iostream> #include<math.h> #include<algorithm> #include<tuple> using namespace std; #define fr(i,n) for(int i=0;i<n;i++) typedef double db; typedef tuple<bool,db> bod; db Pi = 3.14159265358979; db st(db t){ t+=4*Pi; while(t>=0) t-=2*Pi; t+=2*Pi; return t; } bod J(db a,db b){ if(a<=Pi){ return m...
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>; vector<P> tell[15]; int main() { int n; cin >> n; rep(i,n) { int a; cin >> a; rep(j,a) { int x, y; cin >> x >> y; ...
#include <iostream> #include <iomanip> #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <functional> #include <sstream> #include <string> #include <utility> #include <map> #include <memory> #include <set> #include <vector> #inclu...
0
#include <bits/stdc++.h> using namespace std; int n, p; int peb[55]; void solve() { int c = 0; int p_ = p; while (1) { if (p_ == 0) { p_ += peb[c]; peb[c] = 0; c++; } else { peb[c]++; if (peb[c] == p) break; p_--; c++; } c %= n; } cout << c << endl; } int main() { while (1)...
#include <iostream> int main(void){ while(1){ int stonNum[51] = {0}; int p, n; std::cin >> n >> p; int first = p; if(n == 0 && p == 0) return 0; int i=0; while(1){ bool flag = true; if(p > 0){ stonNum[i]++; p--; if(stonNum[i] == first){ std::cout <...
1
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(0); int n,y;cin>>n>>y; int sy=y-n*1000; int n1=-1,n5=-1,n10=-1; for(int i=0;i<=n;i++) { int bsy=sy-i*4000; if(bsy<0)break; if(bsy%9000==0) { if(bsy/9000...
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; int64_t Y; cin >> Y; int a = -1; int b = -1; int c = -1; for(int i = 0; i <= N; i++){ for(int j = 0; j + i <= N; j++){ int k = (N - i -j); int sum = 10000 * i + 5000 * j + 1000 * k; if(sum == Y){ ...
1
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <cassert> #include <cfloat> #include <complex> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <vector>...
#include<iostream> #include<iomanip> #include<algorithm> #include<bitset> #include<cctype> #include<cmath> #include<cstdio> #include<cstring> #include<functional> #include<limits> #include<list> #include<map> #include<set> #include<stack> #include<string> #include<sstream> #include<queue> #include<vector> using namespa...
0
#include <stdio.h> int main(int argc, char const *argv[]) { int i, n; scanf("%d", &n); for (i = 3; i <= n; i++) { if (i % 3 == 0) { printf(" %d", i); } else { int temp = i; do { if (temp % 10 == 3) { printf(" %d", i); break; } temp /= 10; ...
#include<iostream> using namespace std; int i = 1, x, n; void checknum(); void include3(); void endchecknum(); int main() { cin >> n; checknum(); return 0; } void checknum() { x = i; if (x % 3 == 0) { cout << " " << i; endchecknum(); } else { include3(); } } void include3() { if (x % 10 == 3) { cou...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll,ll> pll; #define mp make_pair #define pb push_back #define fi first #define se second #define ub upper_bound #define lb lower_bound ...
#include <bits/stdc++.h> using namespace std; int main() { int N, n; cin >> N; n = N; for (int i = 0; i < 9; i++) { int x; x += n % 10; n /= 10; if (i == 8){ if ( N % x == 0){ cout << "Yes" << endl;} else{ cout << "No" << endl;} } } }
0
#include <bits/stdc++.h> using namespace std; const int maxn = 110; const double PI = acos(-1); int n; pair<int, int> p[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &p[i].first, &p[i].second); } for (int i = 1; i <= n; i++) { vector<double> V; ...
#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 int long long #defi...
1
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (int)(n); i++) #define REP(i,n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define debug(var) do{cout << #var << " : "; view(var);}while(0) template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;ret...
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); char s[a+b+2]; scanf("%s", s); for(int i=0; i<a; i++){ if(s[i]<48 || s[i]>57){ printf("No\n"); return 0; } } if (s[a]!=45){ printf("No\n"); return 0; } for(int i=a+1; i<=(a+b); i++){ if(s[i]<48 || s[i]>57){ printf("No...
0
#include<iostream> #include<vector> #include <cmath> #include <map> #include <set> #include <algorithm> #include <string> #define rep(i,n) for (int i= 0;i<(n);++i) using namespace std; typedef long long ll; const int N = 3e5 + 1; int n, m, k; long long int A[N], B[N], cs[N], sum; int main(){ ll H , W , N ; cin...
#include <bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for(ll i=0;i<n;++i) #define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++) #define ALL(a) (a).begin(),(a).end() #define MOD 1000000007 int main(){ ll h, w, k; cin >> h >> w >> k; ll dp[110][10] = {}; dp...
0
#include <bits/stdc++.h> #include <gmpxx.h> #define NREP() for(ll i = 0; i < n; i++) #define MREP() for(ll j = 0; j < m; j++) #define REP(i, x, y) for(ll i = x; i < y; i++) #define ALL(x) (x).begin(), (x).end() #define MSG(x) cout << x << endl; #define MSGF(x, n) MSG(fixed << setprecision(n) << x) #define END(x) cout ...
#include <iostream> using namespace std; int main() { int n; cin >> n; int sum = 0; sum = (n - 2) * 180; cout << sum; return 0; }
0
#include <bits/stdc++.h> #define f first #define s second using namespace std; using ll = long long; using ii = pair<int, int>; int N, K, a[100001], d[100001], c[100001]; vector<int> G[100001]; void dfs(int u) { for (int v : G[u]) { dfs(v); d[u] = max(d[v]+1, d[u]); c[u] += c[v]; } ...
#include <iostream> #include <cmath> #include <vector> #include <map> #include <iomanip> #include <algorithm> #include <sstream> #include <string> #include <math.h> #include <set> #include <deque> #include <queue> #include <list> using namespace std; typedef long long ll; const int mod = 1000000007; int main() { i...
0
#include <iostream> #include <iomanip> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <utility> #include <string> #include <cmath> #include <cstdlib> #include <cstring> #include <deque> #include <numeric> using namespace std; typedef u...
#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() { int n, y; cin >> n >> y; for (int i = 0; i <= n; ++i) { for (int j = 0; i + j <= n; ++j) { int k = n - i - j; if (10000 * i + 5000 * j + 1000 * ...
0
#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { double x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; cout.precision(9); cout.setf(ios::fixed); cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl; return 0; }
#include <iostream> #include <string> #include <cctype> using namespace std; int main() { string str; while (getline(cin, str)) { for (int i = 0; i < 26; i++) { for (auto &itr : str) if (isalpha(itr)) itr = (itr - 'a' + 1) % 26 + 'a'; if (str.find("the") != -1) { cout << str << endl; break; } if (str.fin...
0
#include <iostream> #include <vector> #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; int main(void) { int64_t N, X; cin >> N >> X; vector<int64_t> A(N); rep(i, N) cin >> A[i]; int64_t answer = 0; for(int i = 1; i < N; ++i) { if(X < (A[i-1] + A[i])) { int64_t diff = (A[i] + A...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p); string to_string(const st...
1
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define MOD 1000000007LL #define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++) #define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++) #define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(...
#include <cmath> #include <iostream> using namespace std; int main() { int N, L; cin >> N >> L; int opt = (1 << 30), sum = 0; for (int i = 0; i < N; ++i) { int p = L + i; if (abs(opt) > abs(p)) { opt = p; } sum += p; } cout << sum - opt << endl; return 0; }
0
#include <bits/stdc++.h> using namespace std; int main() { int a,b,n,i=0; cin >> a >> b; n = 1; while(b>n){ n += a - 1; i++; } cout << i << endl; }
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; const int INF=1e9; int main(){ int n; string s; cin>>n>>s; vector<int> A(n),B(n); rep(i,n){ if(i==0){ if(s[0]=='W') A[0]=1; else A[0]=0; }...
0
#include<bits/stdc++.h> using namespace std; using lli = long long; #define rep(i,n) for(int i=0;i<n;i++) lli n, m; int main(void){ cin >> n >> m; vector<bool> ac(n+1); vector<lli> wa(n+1); rep(i, m){ int p; string s; cin >> p >> s; if(s == "AC") ac[p] = true; else{ if(!ac[p]) wa[p]++; } } lli su...
#include <bits/stdc++.h> using namespace std; inline int gi() { char c = getchar(); while(c < '0' || c > '9') c = getchar(); int sum = 0; while('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar(); return sum; } typedef long long ll; const int maxn = 100005; int n, s, x[maxn]; ll ans, p[maxn]; int mai...
0
#include <bits/stdc++.h> template <class T> T root(std::vector<T>& v, T x) { return v[x] - x ? (v[x] = root(v, v[x])) : x; } template <class T> bool same(std::vector<T>& v, T x, T y) { return root(v, x) == root(v, y); } template <class T> void unite(std::vector<T>& v, T x, T y) { x = root(v, x); y = root...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1<<30; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); int H, W; cin >> H >> W; ...
0
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ff first #define ss second #define BIT(X, i) ((X>>i)&1) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define rep(i, n) for(int i = 0; i < (n); ++i) #define all(a) (a).begin(), (a).end() #define r_all(a) (a).rbegin()...
#include <bits/stdc++.h> #define REP(i, n) for(long long i=0; i<n; i++) #define REPR(i, n) for(long long i=n-1; i>=0; i--) #define FOR(i, m, n) for(long long i=m; i<=n; i++) #define FORR(i, m, n) for(long long i=m; i>=n; i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define VSORTR(v) ...
0
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; bool Cmp(pii a,pii b){ if(a.first>b.first){ return true; }else{ return false; } } int main(){ int n; cin>>n; vector<pii>team; for(int j=0;j<n;j++) team.push_back(pii(0,j)); for(int i=0;i<(n*(n-1))/2;i++){ int ta,tb,sa,...
//https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_1_A #include <bits/stdc++.h> using namespace std; template<class Weight> struct WeightedGraph { struct Edge { int to; int weight; }; int n; vector<vector<Edge> > adj, rdj; explicit WeightedGraph(int n) : n(n), adj(n)...
0
#include <bits/stdc++.h> using namespace std; void Sum(int data[3],int K){ data[2] *= 2; if(K == 1){ int sum = 0; for(int i=0;i<3;i++) sum += data[i]; cout << sum << endl; } else{ Sum(data,K-1); } } int main(void){ int data[3]; int K; ...
#include<bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define mp make_pair #define mod 1000000007 #define vlli vector<ll> #define vi vector<int> #define vs vector<string> #define vplli vector< pair< ll,ll> > #define plli pair< ll,ll > #define vps vector<...
0
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> A(N); for(int i=0; i<N; i++) cin >> A.at(i); set<int> B; bool flg = true; for(int i=0; i<N; i++){ if(B.find(A.at(i)) == B.end()) B.insert(A.at(i)); else{ flg = false; ...
#define LOCAL #undef _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false);cin.tie(0) #define all(x) x.begin(), x.end() #define ff first #define ss second #define MOD 1000000007LL #define LLINF 100000000000000005LL #define INF (int)1e9+1 // Copied from Gennady-Korotkev...
0
#include <cstdio> #include <algorithm> using i8 = std::int8_t; using u8 = std::uint8_t; using i16 = std::int16_t; using u16 = std::uint16_t; using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = std::int64_t; using u64 = std::uint64_t; using usize = std::size_t; i32 a[200000]; auto main() -> i32 { i32 n,...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() typedef long long ll; typedef pair<ll, ll> P; const int mod = 1000000007; //出力は (ans % mod + mod) % mod (負の剰余を正にする) const int inf = 1e9; const long long INF = 1LL << 60; // INF ...
1
#include <bits/stdc++.h> using namespace std; int main() { long n,m,x=0,ans=0; cin >> n >> m; map<long,long> aaa; aaa[0]=1; for(long i=0;i<n;i++) { long a; cin >> a; x+=a; x=x%m; aaa[x]++; ans+=aaa[x]-1; } cout << ans << endl; }
#include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <algorithm> #define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i) #define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i) #define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i) #define ri rd<int> usin...
0
#include<iostream> using namespace std; int n,A,B; int main(){ while(true){ cin>>n; if(n==0)break; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; if(a>b)A=A+a+b; else if(a<b)B=B+a+b; else A=A+a,B=B+b; } cout<<A<<" "<<B<<endl; A=0,B=0; } return 0; }
#include <iostream> using namespace std; int main() { int n, a, b, count = 0, pointX = 0, pointY = 0; cin >> n; do { cin >> a >> b; if (a > b) { pointX += (a + b); } else if (a < b) { pointY += (a + b); } else { pointX += a; pointY += b; } count++; if (count == n) { cout << pointX ...
1
#include <iostream> #include <vector> //#define rep(i,n) for(int i = 0; i , (n); ++i) using ll = long long; using namespace std; int sum(int n) { if (n == 0) { return 0; } int s = sum(n - 1); return s + n; } int main() { int N, W; cin >> N >> W; vector<vector<char>>A(N, vec...
#include <bits/stdc++.h> using namespace std; #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;} //最大公約数 int lcm(int ...
1
#include <bits/stdc++.h> using namespace std; int main() { int64_t n; cin>>n; vector<int> L(2*n); for(int i=0;i<2*n;i++){ cin>>L.at(i); } sort(L.begin(),L.end()); int64_t sum=0; for(int i=0;i<2*n;i++){ if(i%2==1) sum+=min(L.at(i),L.at(i-1)); } ...
//BadWaper gg #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<vector> #include<deque> #include<bitset> #include<map> #include<set> #define inf 1e9 #define eps 1e-6 #define mp make_pair #define N 220 using namespace std; typedef long long ll; typedef uns...
1
#include <stdio.h> #include <algorithm> #include <iostream> #include <vector> using namespace std; static const long long INF = 100000000000000; bool warshall_floyd(vector<vector<long long> > &graph); int main() { int v,e; scanf ("%d %d",&v,&e); vector<vector<long long> > g (v, vector<long long>(v,INF)); ...
// D - Make Them Even #include <bits/stdc++.h> using namespace std; typedef long long ll; // const int INF = 2147483647; // const ll INF = 9223372036854775807; // const ll MOD = 1e9 + 7; struct Cell { int y; int x; int c; }; struct Move { int y1; int x1; int y2; int x2; }; int field[500][500]; Cell cells[5...
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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rep(i,n) REP(i,0,n) using...
#include <iostream> #include <cstdint> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <cctype> #include <cassert> #include <climits> #include <string> #include <bitset> #include <cfloat> #include <unorder...
0
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> const int N = 2e5 + 5; typedef long long ll; using namespace std; int n, A, B, x[N]; ll ans; template < typename T > inline T read() { T x = 0, w = 1; char c = getchar(); while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }...
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define vi vector <int> #define vii vector <int>::iterator #define vd vector <double> #define vdd vector <double>::iterator #define vs vector <string> #define vss vector <string>::iterator #define vc vector <char> #define vcc vector...
0
#include<iostream> using namespace std; #include<stdio.h> int f_r(int d,int x){ x=x+d; if(x>=600)return 0; return d*x*x+f_r(d,x); } int main(){ int d; int s; while((scanf("%d",&d))!=EOF){ s=f_r(d,0); printf("%d\n",s); } return 0; }
#include "bits/stdc++.h" #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c).end()) #define DESCSORT(c) sort(c.begin(), c.end(), greater<int>()) using namespace std; using LL = long long int; using LD = long double; using pii = pair<int, int>; using pll = pair<LL, LL>; using pdd = pair<double,...
1
#include <stdio.h> int main() { int n, i, num[2], result[2] = { 0,0 }; while (scanf("%d", &n)) { if (n == 0) break; result[0] = 0; result[1] = 0; for (i = 0; i < n; i++) { scanf("%d %d", &num[0], &num[1]); if (num[0] > num[1]) result[0] += num[0] + num[...
#include<iostream> using namespace std; int main(){ int a; int uma; int ushi; int b; int c; int i; while (true){ cin >> a; if (a == 0){ break; } else{ while (true){ if (i<a){ cin >> b; cin >> c; if (b>c){ uma = uma + b + c; } else if (b == c){ uma = uma + b; ushi = ushi + c; } else{ ushi = ushi + b + c...
1
#include <bits/stdc++.h> #define REP(i, n) for(int (i)=0;(i)<(n);++(i)) #define MOD 1000000007 using namespace std; typedef long long ll; const int match[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6}; int main() { int N, M; cin >> N >> M; int A[M]; REP(i, M) { cin >> A[i]; A[i]--; } ...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; const ll mod = 1e9+7; int main(){ int n, m; cin >> n >> m; int a[n], b[m]; vector<ll> va(n*m+1,0), vb(n*m+1,0); rep(i,n) { cin >> a[i]; va[a[i]]++; } rep(i,m) { ...
0
#include <bits/stdc++.h> using namespace std; int main() { int d,t,s; cin >> d >> t >> s; if (s*t>=d) cout << "Yes" << endl; else cout << "No " << endl; }
#include <iostream> #include <map> #include <unordered_map> #include <algorithm> #include <vector> using namespace std; //const char a[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'}; const int maxN=50; int dp[maxN+1][maxN+1][maxN*maxN+1]; void solver() {...
0
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; typedef pair<int, int> P; class UnionFind { public: vector<int> Parent; UnionFind(int N) { Parent = vector<int>(N, -1); } int root(int A) { if(Parent[A] < 0) return A; return Parent[A] =...
#include <bits/stdc++.h> #define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__) #define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout) using namespace std; typedef long long LL; typedef pair <int, int> PII; typedef pair <int, PII> PIII; template <typename T> inline T gi() { ...
1
//pragma //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define YOU using #define DONT namespace #define SAY std YOU DONT SAY; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ll,int> pli; typedef ...
// IOI 2021 #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ends ' ' #define die(x) return cout << x << endl, 0 #define all(v) v.begin(), v.end() #define sz(x) (int)(x.size()) void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr ...
0
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; #define all(x) x.begin(),x.end() #define rep(i,j,n) for (long long i = j; i < (long long)(n); i++) #define _GLIBCXX_DEBUG #define MOD 10000000...
#include <iostream> #include <vector> using namespace std; int main(){ int i,j; int h,w; cin >> h >> w; vector<vector<char>> v(h+2,vector<char>(w+2,'.')); for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ cin >> v[i][j]; } } for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ if(v[i][j]=='#'){ if(v[...
1
#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 <iomanip> #include <limits> using namespace...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1LL << 60; int main() { int n, r; cin >> n >> r; int rate; if (n > 10) { rate = r; } else { rate = r + (100 * (10 - n)); } cout << rate << endl; return 0; }
1
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i < (int)(b); ++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...
#include "bits/stdc++.h" #define rep(i,n) for(int i = 0; i < (n); ++i) using namespace std; typedef long long int ll; typedef pair<ll, ll> P; 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; } retu...
0
#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 <iomanip> #include <limits> using namespace...
#include <stdio.h> int main () { char x[100]; char y[100]; scanf("%s%s\n", &x,&y); printf("%s%s\n", y, x); return 0; }
1
#include<stdio.h> #include<iostream> #include<vector> #include<math.h> #include<queue> #include<map> #include<algorithm> #include<string.h> #include<functional> #include<limits.h> #include<stdlib.h> #include<cmath> #include<cstring> #include<set> #include<climits> #include<deque> #include<iomanip> #include<utility> usi...
#include <bits/stdc++.h> #define ll long long #define rep(i,n) for(int i=0;i<n;i++) #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 rev(i,n) for(int i=n-1;i>=0;i--) #define vi vector<int> #define vv vector<vi> #define pb push_back #define pi pair<int,int> #define vp vector<pair<...
0
#include <bits/stdc++.h> #define rep(i,n) for (long long i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<ll,ll>; using vec = vector<ll>; using vecp = vector<P>; using mat = vector<vec>; using matp = vector<vecp>; const ll MOD = 1e9+7; const ll INF = 1e18; #define all(v) v.begin(), v.end()...
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) int main(){ int N; cin >> N; int h,w; cin >> h >> w; int r = (N-h+1) * (N-w+1); cout << r << "\n"; }
0
#include <stdio.h> #define ICES 10 int main(){ int num[ICES]; int n, tmp; while (scanf("%d",&n), n!=0){ for (int i=0; i<ICES; i++) num[i]=0; for (int i=0; i<n; i++){ scanf("%d", &tmp); num[tmp]++; } for (int i=0; i<ICES; i++){ if (num[i]...
#include<bits/stdc++.h> using namespace std; //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("avx,avx2,fma") typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, int> pli; typedef pai...
0
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(),v.end() #define _GLIBCXX_DEBUG using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vd = vector<double>; using vvi = vector<vi>; using vvll = vector<vll>; using vvd = vec...
#include <bits/stdc++.h> #define int long long #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define all(box) box.begin(), box.end() using namespace std; usi...
1
#include<bits/stdc++.h> using namespace std; int main(){ int N, Q; cin >> N >> Q; vector<vector<int>> vec(N,vector<int>(3)); for(int i=0; i<N; i++){ for(int j=0; j<3; j++){ cin >> vec.at(i).at(j); } } vector<int> query(Q+2,-1e9); for(int i=1; i<=Q; i++){ cin >> query.at(i); } query.a...
#include<iostream> #include<iomanip> #include<cmath> #include<string> #include<vector> #include<list> #include<algorithm> #include<map> #include<set> #include<queue> #include<stack> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define rep(i, n) for(int i=0;i<n;++i) ...
1
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include <algorithm> #include <assert.h> #include <bitset> #include <cfloat> #include <complex> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include...
#include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<ctime> #include<map> #include<bitset> #include<set> #define LL long long #define mp(x,y) make_pair(x,y) #define pll pair<long long,long long> #define pii pair<int,int> using namespace std; ...
0
#include<bits/stdc++.h> using namespace std; int main() { int N,M,Q; cin >> N >> M >> Q; vector<int> L(M), R(M); for(int i = 0; i < M; i++) { cin >> L[i] >> R[i]; L[i]--, R[i]--; } vector<vector<int>> train(N, vector<int>(N, 0)); vector<vector<int>> train_cum(N+1, vector...
#include <iostream> #include <vector> #include <queue> #define INF 50000000000 struct vertex{ std::vector<int> edge_to; std::vector<int> edge_cost; bool done; long long int mincost; }; std::vector<vertex> G(100000); void shortest_path(int v); int V,E; int r; int main(void){ std::cin>>V>>E>>r; for(int i=0;i<E;i++)...
0
#include<iostream> using namespace std; class Dice { public: int *num; Dice(int *n) { num = n; } int top() { return num[0]; } void move(char c) { int n[6]; for (int i = 0; i < 6; i++) { n[i] = num[i];...
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <set> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) using LLONG = long long; const LLONG MOD = 1000000007; int main()...
0
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define debug(var) cerr << (#var) << " = " << (var) << endl; #else #define debug(var) #endif void init() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 1e5+23; vector<int> g[N], ans; bool bio[N]; int parent[N]; void dfs(int u)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll N,M; cin >> N >> M; vector<ll> A(N+M-1),B(N+M-1),G[N],in_cnt(N,0); vector<bool> is_root(N,true); for(int i=0;i<N+M-1;i++){ cin >> A[i] >> B[i]; A[i]--,B[i]--; G[A[i]].push_back(B[i]); is_root[B[i]] = false; in_cnt[B[i]]+...
1
#include<bits/stdc++.h> #define ll long long int #define ld long double #define inf LLONG_MAX>>2 #define MAX 1000000 #define mod 1000000007 #define pb push_back #define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x)) #define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x)) #define fi first #define se second #define mk make_pair #...
#include <bits/stdc++.h> using namespace std; using P = pair<int, int>; int main() { int h, w; cin >> h >> w; vector<string> g(h); vector<vector<bool>> seen(h, vector<bool>(w)); for(int i=0;i<h;i++) cin >> g[i]; long long ans = 0; long long black = 0, white = 0; for(int i=0;i<h;i++) { for(int j=0;j...
0
#include <vector> #include <algorithm> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <cstdio> #include <memory.h> #include <cmath> #include <array> using namespace std; void re(int& x); template<class T, class... Ts> void re(T& t, Ts&... ts); void pr(long long x); void ...
// Program Name: Minimum Spanning Tree // Written by: by_sknight // Date: 2019/4/27 #include <bits/stdc++.h> using namespace std; #define MAX 105 #define INFTY INT_MAX #define WHITE 0 #define GRAY 1 #define BLACK 2 int n, G[MAX][MAX]; int prim() { int d[MAX], p[MAX], color[MAX]; int u, minv; for (int i = ...
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 REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) #define rep(i,n) REP(i,0,n) usin...
#include <bits/stdc++.h> using namespace std; int main() { int A, B; cin >> A >> B; cout << max(max(A+B,A-B),A*B) << endl; return 0; }
0
#include <bits/stdc++.h> #include <fstream> #include <string> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define ll unsigned long long const ll MOD = 1000000000000000000; int main() { //入力 int k; string s; cin >> k >> s...
#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 INF 1e18 #define MOD 1000000007 using namespace std; typedef long long int ll; typedef pair <int,int> P; const int MAX = 510000; long long fac[MAX], finv[MAX], inv[MAX]; //n!, 1/n!, 1/n ...
0
#include <iostream> #include <string> #include <set> using namespace std; void input(int& N, set<int>& R_INDEX, set<int>& G_INDEX, set<int>& B_INDEX) { char c; for (int i= 0; i < N; i++){ cin >> c; switch(c){ case 'R': R_INDEX.insert(i); break; case 'G': G_INDEX.insert(i); ...
#include<bits/stdc++.h> using namespace std; using ll = long long; #define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0); int main() { fast_io; long long n,r,g,b; cin>>n; string s; cin>>s; r=0; g=0; b=0; for(int i=0;i<n;i++) { if(s[i]=='R')r++; ...
1
#include<iostream> #include<string> using namespace std; int main() { char s[5000]; long long n,i,j,k,total=0,red[5000]={0},green[5000]={0},blue[5000]={0},r=0,g=0,b=0,x,y; cin>>n; for(i=1;i<=n;i++) { cin>>s[i]; if(s[i]=='R') { r++; red[i]=red[i-1]+1; ...
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int b = 0; for(auto c : s) if(c == 'B') ++b; long long ans = 0; for(int i = 0; i < n; ++i){ if(s[i] != 'R') continue; for(int j = 0; j < n; ++j){ if(s[j] != 'G') continue; ...
1
#include<bits/stdc++.h> using namespace std; int main(void) { int a,b,s,i,x; s=100; x=0; for(i=0;i<4;i++){ cin>>a; if(s>a) s=a; x=x+a; } x=x-s; s=100; for(i=0;i<2;i++){ cin>>b; if(s>b) s=b; x=x+b; } x=x-s; cout<<x<<endl; return 0; }
#include<iostream> #include<string> #include<stdio.h> #include <algorithm> #include <set> #include<math.h> #include<vector> using namespace std; int main(){ int N,M,X,Y;cin >> N >> M >> X >> Y; int x[100]={}; int y[100]={}; int flag = 1; for(int i = 0;i < N;i++)cin >> x[i]; for(int i = 0;i < M...
0
#include <iostream> #include <iomanip> #include <vector> #include <string> #include <algorithm> #include <cctype> #include <cmath> #include <iomanip> #define REP(i,n) for(int i=0;i<n;++i) #define RREP(i,n) for(int i=n-1;i>=0;--i) #define FOR(i,m,n) for(int i=m;i<n;++i) #define RFOR(i,m,n) for(int i=m-1;i>=n;--i) #defi...
#include <bits/stdc++.h> #define ull unsigned long long #define ul unsigned long #define ll long long #define pb push_back #define sodayoda_C ios_base::sync_with_stdio(false);cin.tie(NULL); #define f(i,a,b) for(int i = a;i<b;i++) #define fb(i,a,b) for(int i = a;i>b;i--) #define endl "\n" #define yes cout<<"YES\n" #de...
0
#include<bits/stdc++.h> #define LL long long #define RG register using namespace std; template<class T> inline void read(T &x) { x = 0; RG char c = getchar(); bool f = 0; while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1; while (c >= '0' && c <= '9') x = x*10+c-48, c = getc...
//--------------------------------------------------------------- #include <bits/stdc++.h> using namespace std; #include <iostream> #include <vector> #include <cstdlib> #include <cmath> #include <math.h> #include <sstream> #include <numeric> #include <cctype> #include <bitset> #include <cassert> #include<algorithm> //-...
1
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long #define fr(i,a,b) for(int i = a ; i <= b ; ++i) #define rep(i, a, b) for(int i = a; i < (b); ++i) #define tr...
#include<stdio.h> int main() { int N,B; scanf("%d",&N); while(N!=0) { B=N%10; if(B==7) { printf("Yes"); break; } N=N/10; } if(B!=7) printf("No"); return 0; }
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 10; const ll mod = 1e9 + 7; ll powMod(ll a, ll k) { ll ret = 1; while(k) { if(k & 1) ret = ret * a % mod; a = a * a % mod; k >>= 1; } return ret; } ll inv(ll a) { return powMod(a, mod - 2);} ll C(int n, int m) { ll a =...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod = 1000000007; ll pl(ll a, ll b) { a %= mod, b %= mod; return (a+b) % mod; } ll mu(ll a, ll b) { a %= mod, b %= mod; return (a*b) % mod; } ll pow_mod(ll a, ll b) { if (b == 0) return 1; a %= mod; ll k = pow_mod(a, b/2)...
1
// // main.cpp // D // // Created by 曾憲揚 on 2020/8/21. // Copyright © 2020 曾憲揚. All rights reserved. // #include <bits/stdc++.h> using namespace std; const int maxn = 4e3+5; int main(int argc, const char * argv[]) { int n; cin>>n; string s; cin>>s; int r=0, g=0, b=0; for(int i=0; i<n; i++){ ...
#include <iostream> #include <string> #include <algorithm> using namespace std; bool is_palindrome(string str){ string rstr = str; reverse(str.begin(), str.end()); return rstr == str; } int main(){ int A, B, ans = 0; cin >> A >> B; for (int i = A; i <= B; i++){ if (is_palindrome(to_string(i))) ans+...
0
#include<iostream> int main(void){ int n; std::cin >> n; int seq[n]; for (int i =0; i <n; i++){ std::cin >> seq[i]; } for (int i = 0; i < n; i ++){ if (i < n-1) std::cout << seq[(n-1) - i] << " "; else std::cout << seq[ (n-1)-i] << std::endl; } return 0; }
#include <iostream> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <map> #include <cmath> #include <string> #include <sstream> #include <iomanip> #include <complex> using namespace std; #define ll long long #define vvi vector< vector<int> > #define vi vector<int> #define All(X) X.be...
0
#ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wunused-result" #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif #include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <sstream> #include <numeric> #include <map> #include <set> #include <q...
#include <bits/stdc++.h> #include <atcoder/fenwicktree> using namespace std; using namespace atcoder; int main(){ int N, Q; cin >> N >> Q; fenwick_tree<long long> a(N); for (int i = 0; i < N; i++){ int x; cin >> x; a.add(i, x); } for (int i = 0; i < Q; i++){ int t; cin >> t; if (t ==...
1
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; ++i) int main() { int n; cin >> n; queue<int> que; rep(i, n) { int p; cin >> p; if(i == 0) que.push(p); else { if(que.back() > p) que.push(p); } } cout << que.size() << endl; }
#include <bits/stdc++.h> using namespace std; #define vt vector #define sz(x) int((x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define fi first #define se second using ll = long long; using pii = pair<int, int>; void solve() { ...
1
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { long long n; cin >> n; string name = ""; while (1) { n--; name += (n % 26 + 'a'); n /= 26; if (n == 0) break; } reverse(name.begin(), name.end()); cout << name; }
#include<stdio.h> #define ll long long int main() { ll n, j = 0; char str[255]; scanf("%lld", &n); while(n != 0){ --n; str[j++] = n % 26 + 'a'; n /= 26; } for(int i = j - 1; i >= 0; i--){ printf("%c", str[i]); } }
1
#include <bits/stdc++.h> using namespace std; int main() { int n; double sum = 0; cin >> n; vector<int> x(n); vector<int> y(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { su...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++) int main(){ ll N; cin >> N; vector<ll> A(N), B(N), S(N); rep(i, 0, N){ cin >> A[i] >> B[i]; S[i] = A[i] + B[i]; } sort(S.begin(), S.e...
0
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; string ans=""; while(N){ N--; int r=N%26; N=N/26; ans+='a'+r; } reverse(ans.begin(),ans.end()); cout << ans << endl; }
#include <algorithm> #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...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const ll INF = 1LL << 60; //MAX 9223372036854775807 //https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_D //区間加算 区間和クエリ //演算の定義 auto query = [](ll x, ll y) { return x+y; }; //単位元 const ll ...
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <vector> #include <algorithm> #include <functional> #include <numeric> using namespace std; #define REP(i,n) for (int i = 0; i < n; i++) int main() { int N; vector<int> s(123),t; scanf("%d", &N); REP(i, N *(N - 1) / 2) { int A, B...
0
#include<iostream> #include<iomanip> #include<algorithm> #include<array> #include<bitset> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstring> #include<functional> #include<limits> #include<list> #include<map> #include<numeric> #include<set> #include<stack> #include<string> #include<sst...
#include<bits/stdc++.h> using namespace std; #define int long long void read(int &x) { x=0;int f=1;char ch=getchar(); for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f; for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f; } void print(int x) { if(x<0) putchar('-'),x=-x; if(!x) return ;print(x/10),p...
0
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; for(int i=1;i<s.size();i++){ if(1<i && s[i-2]==s[i]){ cout << i-1 << " " << i+1 << endl; return 0; } if(s[i-1]==s[i]){ cout << i << " " << i+1 << endl; ret...
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); #define FOR(i,s,n) for(int i = (s); i < (n); i++) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(int i = (n); i >= 0; i--) #define ALL(n) (n).begin(), (n).end() #define RALL(n) (n).rbegin(), (n).rend() #define ATYN(n) ...
0
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; double K=0; vector<int> X(N),Y(N); for(int i=0;i<N;i++){ cin >> X.at(i) >> Y.at(i); } for(int i=0;i<N-1;i++){ for(int j=i+1;j<N;j++){ int X2=X.at(i)-X.at(j); int Y2=Y.at(i)-Y.at(j); K+=sqrt(X2*X2+Y2*Y2); ...
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef pair <int,int> pi; typedef pair <int,pi> pii; struct point{ point(int x, int y, int ind){ this->x=x; this->y=y; this->ind=ind; } int x,y; int ind; }; int getdist(int i,int j, vector <pi> ...
0
#include<iostream> #include<algorithm> using namespace std; int main (void) { string s; cin>>s; if(s=="SUN")cout<<"7"<<endl; if(s=="MON")cout<<"6"<<endl; if(s=="TUE")cout<<"5"<<endl; if(s=="WED")cout<<"4"<<endl; if(s=="THU")cout<<"3"<<endl; if(s=="FRI")cout<<"2"<<endl; if(s=="SAT")cout<<"1"<<endl; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define Alhamdulillah return 0; #define debug(n) cerr << "[" << #n << " = " << n << "]" << endl void Suhaib_Sawalha (){ vector <string> v ...
1
#include <iostream> #include <cmath> using namespace std; int main(int argc, char *argv[]) { int w, h, diag, i, j; while (cin >> w >> h, w | h) { diag = w * w + h * h; i = 0; while (1) { i++; j = sqrt(diag - i * i); if (i >= j) { diag+...
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "iomanip" #include "random" using namespace std; const long long int MOD = 1000000007; const long double EPS = 0.00000001; const ...
1
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e6+10; struct node{ int pos,num; bool operator<(const node& a)const{ return num<a.num; } }; struct node1{ int pos,num; bool operator<(const node1& a)const{ return pos<a.pos; } }; char s[maxn]; bool vis[maxn]={0}; node p[maxn]={...
#include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int INF=1e9; const long double eps=1e-9; const double Pi=acos(-1.0); const int maxn=1e2+10; struct node{ int x,y,id; }a[maxn]; inline bool cmp(const node &lhs,con...
0
#include <iostream> #include <string> #include <cmath> #include<algorithm> #include<stack> #include<queue> #include<map> #include<set> #include<iomanip> #define _USE_MATH_DEFINES #include <math.h> #include <functional> using namespace std; #define rep(i,x) for(int i=0;i<x;i++) #define repn(i,x) for(int i=1;i<=x;i++) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MN = 100100; const int A = 60; ll w[MN]; ll fr[A]; int main() { ll n; cin >> n; for(int i=0;i<n;i++) { cin >> w[i]; for(int j=0;j<A;j++) { if(w[i]&(1LL<<j)) { fr[j]++; } } } ll res = 0; ll tot = 0; ll ms = 0; int st = ...
1
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int i=0;i<n;i++) const ll MOD=1000000007; const long double PI=3.14159265358979; const ll MAX=0; int main() { ll a,b,m; cin>>a>>b>>m; ll A[a];ll B[b];ll Maxa=MOD,Maxb=MOD; rep(i,a){ cin>>A[i]; Maxa=min(Maxa,A[i]); ...
#include <bits/stdc++.h> using namespace std; int main(){ int A,B,M; cin >> A >> B >> M; vector<int> a(A); vector<int> b(B); for(int i=0;i<A;i++){ cin >> a[i]; } for(int i=0;i<B;i++){ cin >> b[i]; } vector<vector<int>> ju(M,vector<int>(3)); for(int i=0;i<M;i++){ for(int j=0;...
1
#include <stdio.h> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <iterator> #include <assert.h> #pragma warning(disable:4996) typedef long long ll; #define MIN(...
#include<iostream> #include<cstdio> #include<cstring> #define N 100010 #define mod 1000000007 #define ll long long using namespace std; ll fac[N],inv[N],f[N]; ll ksm(ll a,ll b=mod-2) { ll ans=1; for(;b;b>>=1) { if(b&1) ans=ans*a%mod; a=a*a%mod; } return ans; } int main() { int n,l,r,lt,rt; scanf("%d%d%d%d%d"...
0
#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; using P = pair<ll,ll>; using graph = vector<vector<int>>; const int dx[4]...
#include <bits/stdc++.h> //#include <ext/numeric> using namespace std; //using namespace __gnu_cxx; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); // freopen("fence.out", "w", stdout); #endif int n; cin >> n; vector<int> arr(n); for (int &x : arr) cin >> x; i...
0
// clang-format off #include <bits/stdc++.h> #define int long long #define main signed main() // #define main int main() #define loop(i, a, n) for (int i = (a); i < (n); i++) #define rep(i, n) loop(i, 0, n) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prec(n) fixed << setprecis...
#include<iostream> using namespace std; int main() { while (1) { int m, nmin, nmax; cin >> m >> nmin >> nmax; if (m == 0) break; int ans = 0; int tmp; cin >> tmp; int maxgap = 0; for (int i = 1; i < m; ++i) { int s; cin >> s...
1