code_file1
stringlengths
80
4k
code_file2
stringlengths
91
4k
similar_or_different
int64
0
1
#include <bits/stdc++.h> #define name "bai3" #define pii pair<int,int> #define fi first #define se second #define pb push_back #define mp make_pair #define fto(i,a,b) for(int i=a; i<=b; ++i) #define maxn 100009 #define ll long long using namespace std; const int mod=1e9+7; int n,a[maxn*2],xd[maxn*2]; ll p[maxn]; //ll q...
typedef long long ll; typedef long double ld; #include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int main() { ll n; string s; std::cin >> n>>s; ll rc = 0; string c = "L"; for (int i = 1; i < n*2; i++) { if(s[i]!=s[i-1]){ if(c[i-1]=='R'){ ...
1
// 7/3 #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) 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 N, A[5]; cin >> N; rep(i, 5) cin >> A[i]; sort(A, A + 5); ll mn...
#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 rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x...
1
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define db long double #define pb push_back #define ppb pop_back #define F first #define S second #define mp make_pair #define all(x) (x).begin(), (x).end() mt19937 rng(chrono::steady_clock::now().time_since_epoch().coun...
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <i...
1
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef unsigned long long ull; ull B = 100000007; ll mod = 1000000007; int INF = 0x3f3f3f3f; int main() { int n, m; cin >> n >> m; vector<int> v(n+1); int u1 = 1+m; int d1 = 1; int u2= n; int d2 = n - m + 1; int c =...
#include <iostream> #include <algorithm> using namespace std; void solve() { int n, k; cin >> n >> k; int l[n]; for (int i=0; i<n; ++i) cin >> l[i]; sort(l, l+n); int ans = 0; for (int i=0; i<k; ++i) ans += l[n-1-i]; cout << ans; } int main() { solve(); return 0...
0
#include <bits/stdc++.h> using namespace std; #define rep(i, a) for(int i=0; i<(a); i++) typedef long long ll; #ifdef _DEBUG inline void dump() { cerr << endl; } template<typename Head> void dump(Head&& head) { cerr << head; dump(); } template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { c...
#include <iostream> #include <cstring> using namespace std; #define N 8 bool col[N],hi[2*N-1],mi[2*N+1]; int row[N]; void point(int y,int x){ row[y] = x; col[x] = false; hi[x+y] = false; mi[y-x+N-1] = false; } void del(int y, int x){ row[y] = -1; col[x] = true; hi[x+y] = true; mi[y-x+N-1] = true;...
0
#include<bits/stdc++.h> using namespace std; ///Welcome to Nasif's Code #define bug printf("bug\n"); #define bug2(var) cout<<#var<<" "<<var<<endl; #define co(q) cout<<q<<endl; #define all(q) (q).begin(),(q).end() typedef long long int ll; typedef unsigned long long int ull; const int MOD = (int)1e9+7; const int MAX = 1...
#include <bits/stdc++.h> #include <string> #include <vector> #include <algorithm> #include <math.h> #include <iostream> #include <numeric> #define rep(i,n) for (int i = 0;i < (n); ++i) using namespace std; using ll = long long; using P = pair<int,int>; #define chmax(x,y) x = max(x,y) int INF = 1e9; int main(){ int n,...
1
#include <iostream> #include<vector> #include<array> #include<cmath> #include <algorithm> using namespace std; int main() { // 初期処理(iostream軽くする) cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); string n; cin >> n; if (n.find("7") != string::npos) { cout << "Yes"; } else { cout << "No"; } re...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; vector<pair<int,int> >bara,koma; bool comp1(const pair<ll,ll> &a, const pair<ll,ll> &b) { return (a.second<b.second); } bool comp2(const pair<ll,ll> &a, const pair<ll,ll> &b){ return (a.first>b.first); } int main() { int t; cin>...
0
#include <bits/stdc++.h> #define F first #define S second #define PB push_back using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef priority_queue<int> HEAP; typedef priority_queue<int, vector<int>, greater<int> > RHEAP; const int N = 100010, M = 1010; int n; int q[N]; int main() { sca...
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #includ...
1
/* Simplicity and Goodness */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; void my_dbg() { cout ...
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> string S; signed main() { cin >> S; int tmp = 0; int ans = S.size(); for(auto e : S) { if(e == 'T' && tmp) { tmp--; ans -= 2;...
1
#include<bits/stdc++.h> #define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i)) #define rd read() #define maxn 200001 #define gc getchar() #define mem(a,b) memset(a,b,sizeof(a)) #define mp make_pair #define ll long long #define ull unsigned ll #define pb push_back #define db double #define pu puts(" ") using namespa...
#include <iostream> #include <fstream> #include <cstdlib> #include <math.h> #include <utility> #include <algorithm> #include <functional> #include <vector> #include <numeric> #include <bits/stdc++.h> #define int long long struct edge { int to; int cost; }; using namespace std; using vi = vector<int>; using v...
0
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) cin >> a[i]; long long ans = 0, mul = a[0]; for (int i = 1; i < n; i++){ ...
#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 gc getchar_unlocked #define fo(i,n) for(int i=0;i<n;i++) #define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long int #define s(x) cin>>x...
1
#include <bits/stdc++.h> using namespace std; // Macros for easier access #define ll long long #define endl '\n' #define F first #define S second #define umap unordered_map #define uset unordered_set #define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++) //test cases #define fill(name,...
#include <bits/stdc++.h> #include <iostream> //#include <algorithm> // #include <iomanip> #define ll long long #define map unordered_map #define set unordered_set #define pll pair<ll, ll> #define vll vector<ll> #define mll map<ll, ll> using namespace std; const ll MOD = 1000000007LL; const ll INF = (1LL << 60LL); l...
0
#include <bits/stdc++.h> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define pb push_back #define eb emplace_back #define all(x) x.b...
#include "bits/stdc++.h" #define rep(i,n) for(int i=0;i<n;i++) using namespace std; using ll = long long; int main() { int N, Q; string S; cin >> N >> S >> Q; vector<int> k(Q); rep(i, Q) cin >> k[i]; rep(i, Q) { ll ans = 0; vector<ll> D(N + 1, 0), M(N + 1, 0), DM(N + 1, 0); ...
1
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef string str; typedef vector<ll> vel; typedef vector<str> ves; #define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++) #define rep(i, b) REP(i, 0, b) const ll mod = 1000000007; const double pi = 3.14159265358979; ll ex...
#include <iostream> using namespace std; int main() { int A, B; cin >> A >> B; int X = A*B; int Y = A+B; int Z = A-B; if((X>=Y)&&(X>=Z)) { cout << X; } else if((Y>=X)&&(Y>=Z)) { cout << Y; } else if((Z>=Y)&&(Z>=X)) { cout << Z; } re...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, c, d; cin >> a >> b >> c >> d; if (a <= b && c <= d) { cout << a + c << "\n"; } else if (a <= b && c >= d) { cout << a +...
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c,d,ans; while(cin >> a >> b >> c >> d){ ans = 0; ans+=min(a,b); ans+=min(c,d); cout << ans << endl; } }
1
// Graph: Adjacency list #include<vector> typedef std::vector<std::vector<int>> Graph; // Utility const Graph reverse(const Graph& g) { Graph result(g.size()); for(int u = 0; u < g.size(); ++u) for(auto v: g.at(u)) result.at(v).push_back(u); return result; } void postorder_dfs(const Graph& g, int current, std::ve...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vl = vector<ll>; template<class T> using vc = vector<T>; template<class T> using vvc = vector<vector<T>>; const ll MOD = 1e9 + 7; const ll INF = 1e16; const ld EPS = 1e-11; const ld PI = acos(-1.0L); #define eb emplace_ba...
0
#include<bits/stdc++.h> using namespace std; #define ll long long int main(){ string a,b,c; cin>>a>>b>>c; int l=a.length(),r=b.length(),p=c.length(); if(a[l-1]==b[0] && b[r-1]==c[0])cout<<"YES"; else cout<<"NO"; }
#include<bits/stdc++.h> #define forr(i, a, b) for(int i = (a); i < (b); i++) #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()) using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<ll, ll> LP; const ll LINF = 1LL...
0
#include<iostream> #include<string> #include<vector> #include<numeric> #include<math.h> #include<algorithm> #include<iomanip> #include<list> #include<bitset> #include<sstream> using namespace std; int main() { vector<string> S(3, ""); for (long long i = 0; i < S.size(); i++) { cin >> S[i]; } vector<list<long ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, s, n) for (int i = s; i < (int)(n); i++) #define out(x) cout << x << endl; #define INF 1ll<<60; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool ...
1
#include <cstdio> #include <algorithm> using namespace std; class Dice { int num[6]; public: void set(int n, int s) { num[s] = n; } void move(char c) { if (c == 'E') { swap(num[0], num[3]); swap(num[3], num[5]); swap(num[5], num[2]); } else if (c == 'N') { swap(num[0], num[1]); swap(num[1],...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; int a,b; string s; int main(void){ cin>>a>>b>>s; for(int i=0;i<a+b+1;i++){ if(i==a){ if(s[i]!='-'){ cout<<"No"<<endl; return 0; } }else{ ...
0
#include <iostream> #include <vector> #include <deque> #include <algorithm> #include <numeric> #include <string> #include <cstring> #include <list> #include <unordered_set> #include <tuple> #include <cmath> #include <limits> #include <type_traits> #include <iomanip> #include <map> #include <unordered_map> #include <que...
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<utility> #include<cmath> #include<string> #include<cstring> #include<map> #include<queue> #include<set> #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define prin(arg) std::cout<<arg<<"\n" #define prin2(arg...
0
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <ctime> #include <cstring> #include <functional> #include <iostream> #include <iomanip> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <regex> #include <vector> #define fix(...
#include<bits/stdc++.h> #define all(v) v.begin(),v.end() using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int a[5]; char ans[5]; string b; cin>>b; for(int i=0;i<4;i++){ a[i]=b[i]-'0'; ans[i]='+'; } for(int i=0;i<4;i++){ for(int j=0;j<4;j++){ int sum=0; for(int k=0;k<4;k+...
0
#include <bits/stdc++.h> using namespace std; int main(void){ int sx,sy,tx,ty; cin>>sx>>sy>>tx>>ty; std::map<pair<int,int>, int> seen; int x=sx,y=sy; for (int i=0;i<2;i++) { seen[pair(tx,ty)]=0; seen[pair(x,y)]++; while (1) { if (x<tx&&seen[pair(x+1,y)]==0) { cout<<"R...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=5500+5,M=1500,inf=0x3f3f3f3f,mod=1e9+7; #define mst(a,b) memset(a,b,sizeof a) #define lx x<<1 #define rx x<<1|1 #define reg register #define PII pair<int,int> #define fi first #define se second #define pb push_back #define il inline int sx,s...
1
#include <bits/stdc++.h> using namespace std; using ll=long long; #define rep(i,n) for (ll i=0; i<n; ++i) #define all(c) begin(c),end(c) /* 5の数 2の数 mapでいれとく {2,5,小数の数} 7.5=0,3,1 2.4=3,0,1 3-2=1>0だからOK 全部9桁として 9+4=13桁として扱う 2と5が18桁あればOK 10.000 20.000 10*10の組み合わせもとっちゃう。 2 200000*400はぎりぎりせーふ。50msくらい。 200000*1になりそう */ in...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> ii; struct fastio { fastio() { ios::sync_with_stdio(false); cout << setprecision(10) << fixed; cin.tie(0); } }; fastio _fast_io; const int N = 2e5 + 5; int n; int a[N]; int cnt[N]; int res;...
0
#include <iostream> #include <vector> #include <algorithm> int main (){ int n = 0, m = 0; while(true){ int ans = 0; //for answer std::cin >> n >> m; //exit when n = m = 0 if(n == 0 && m == 0){ break; } std::vector<int> price(n); //each vegetable price...
#include <cstdio> #include <set> #include <vector> using namespace std; inline int abs(int x) { return (x >= 0) ? x : - x; } int main() { int n; long d; scanf("%d%ld", &n, &d); vector<long> a(n); for (int i = 0; i < n; i++) scanf("%ld", &a[i]); vector<long> b(n); for (int i = 0; ...
0
#include <iostream> #include <vector> #include <tuple> using namespace std; using int64 = long long; using TP = tuple<int64,int,int>; int main() { int n; cin >> n; vector<TP> ab; for (int i=0; i<n; i++) { int a, b; cin >> a >> b; ab.emplace_back(a+b, a, b); } sort(ab.rbegin(), ab.rend()); ...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> way; int64_t N, M; vector<int> color; bool dfs(int x, int col) { color.at(x) = col; for(int i = 0; i < way.at(x).size(); i++) { if(color.at(way.at(x).at(i)) == col) { return false; } if(color.at(way.at(x).at(i)) == -1) { if(...
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() { int a, b; cin >> a >> b; int n = 0; while (1) { if ((a-1) * n + 1 >= b) break; n++; } cout << n << endl; return 0; }
// time-limit: 2000 // 23 #include <bits/stdc++.h> using namespace std; #define coutc "\033[48;5;196m\033[38;5;15m" #define endc "\033[0m" #define endl '\n' #define M(_1, _2, _3, _4, NAME, ...) NAME #define rep(...) \ M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rep4(_, x, n, s) \ for (int _ = x; (s ...
1
#include <algorithm> #include <cstdio> #include <iostream> #include <numeric> #include <utility> #include <vector> using namespace std; vector<int> ant; int main() { #ifdef HOME freopen("agc01d.in", "r", stdin); freopen("agc01d.out", "w", stdout); #endif ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int ...
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; int ...
0
#include<cstdio> #include<iostream> #include<map> #include<set> #include<vector> #include<cstring> #include<cassert> #include<sstream> #include<cmath> #include<algorithm> #include<queue> #include<limits> #include<ctime> #include<stack> #include<bits/stdc++.h> #include<string> #include<stdlib.h> #include<stdio.h> typed...
/* Push yourself, because no one else is going to do it for you. */ #include <bits/stdc++.h> #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define set_zero(a) memset(a,0,sizeof(a)); #define ll long long int #define PI 2 * acos(0.0) #define MAX 10000000000000000 #define in(a) scanf("%...
1
const int LG = 21; const int FN = 400005; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long INFLL = 1e18; #include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> v...
#include <iostream> #include <vector> using namespace std; int main(int argc, char* argv[]) { int K, T; cin >> K >> T; vector<int> a(T); int maximum = 0; for (int i = 0; i < T; ++i) { cin >> a[i]; maximum = max(maximum, a[i]); } cout << max(maximum - (K - maximum) - 1, 0) << endl; return 0;...
1
#include <iostream> #include <string> #include <vector> #include <set> #include <stack> #include <queue> #include <map> #include <algorithm> #include <iomanip> #include <math.h> #include <string.h> #include <cstdio> #include <tuple> #include <numeric> using namespace std; using ll = long long; using ld = long double; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int i = 0; i < (n); i++) #define all(v) v.begin(), v.end() //#define MOD 1000000007 const int INF = 1LL<<30; char fi[410][410]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int h,w; int vis[410][410]; int main() { ...
1
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define trav(x,a) for (const auto& x: a) #define sz(x) (int)(x).size() #define mem(a,v) memset((a), (v), sizeof (a)) #define enl printf("\n") #define case(t) printf("Case #%d: ", (t)) #def...
#include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define all(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod #define N 100010 vecto...
0
#include <bits/stdc++.h> #include<algorithm> #include<cstring> #include<cmath> #include<cstdlib> #include<string.h> using namespace std; #define pb push_back #define all(v) v. begin(),v. end() #define rep(i,n,v) for(i=n;i<v;i++) #define per(i,n,v) for(i=n;i>v;i--) #define ff first #define ss second #define pp pair<l...
#include<iostream> using namespace std; int main() { // 整数の入力 int N, X, T; cin >> N >> X >> T; // スペース区切りの整数の入力 int x = N / X * T; if ( N % X > 0 ){ x += T; } cout << x << endl; }
0
#include<bits/stdc++.h> typedef long double ld; using namespace std; int main(void){ int n; cin>>n; vector<pair<ld,ld>> ab(n); for(auto& i:ab) cin>>i.first>>i.second; ld res=0; for(int i=0; i<n; ++i) for(int j=i+1; j<n; ++j){ ld x=ab[i].first-ab[j].first; ld y=ab[i].second-ab[j].second; res+=sqrtl...
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; double dist(int x1,int y1, int x2, int y2){ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } int main() { int N; cin>>N; vi x(N),y(N); for (int i = 0; i < N; i++){ cin>>x[i]>>y[i]; }...
1
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<int> a(n); vector<int> b(n); vector<int> x(n); int64_t sb=0; for(int i=0;i<n;i++){ cin>>a.at(i)>>b.at(i); x.at(i)=a.at(i)+b.at(i); sb+=b.at(i); } sort(x.begin(),x.end(),greater<int>()); int64_t sx=0; for(int...
#include <stdio.h> #include <string.h> #include <limits.h> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <set> #include <stack> #include <queue> typedef unsigned long long ULLONG; typedef long long LLONG; static const LLONG MOD_NUM = 1000000007; template<class _...
1
#include<bits/stdc++.h> #define endl '\n' #define INF (1 << 21) const int MOD = 1000000009; using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; int ice[10]; int c; cin >> n; while(n != 0){ memset(ice, 0, sizeof(ice)); for(int i = 0;i < n;i++){ cin >> c; ic...
#include<iostream> using namespace std; int main(void) { int n,i,j=1,max,a[3]; cin>>n; for(i=0;i<n;i++) cin>>a[i]; if(n==2){ if(a[1]<=a[0]) max=a[0]; else max=a[1]; while(1){ if(j==max) break; if(a[0]%j==0 && a[1]%j==0){ cout<<j<<endl; } j+=1; } } if(n==3){ if(a[0]>=a[1] && a[0]>=a[2]) m...
0
#include <bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9+7; const long long LINF = 1e18; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define rep(i,n) for(ll i=0;i<(n);++i) #define REPR(i,n) for(ll i=n;i>=0;i--) #define FOREACH(x,a) for(auto& (x) : (a) ) typedef long long ll; using namespace std; typedef pair<ll...
#include <iostream> #include <complex> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <numeric> #include <cstring> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <cmath> #include <bitset> #...
0
#include <bits/stdc++.h> using namespace std; int main() { int D, G; cin >> D >> G; vector < int >p(D), c(D); for (int i = 0; i < D; i++) { cin >> p[i] >> c[i]; } int ans = INT_MAX; for (int bits = 0; bits < (1 << D); bits++) { int score = 0; int num = 0; int resultMax = -1; for (int i = 0; i < D; i...
#include<bits/stdc++.h> using namespace std; template<class T> void chmax(T& x, T y){if(x < y) x = y;} template<class T> void chmin(T& x, T y){if(x > y) x = y;} int N, M; int A[310][310]; int cnt[310]; bool hold[310]; int idx[310]; int solve(){ bool flag = false; for(int i = 1; i <= M; i++){ if(hold[i]...
0
#include<bits/stdc++.h> using namespace std; typedef long long ll; constexpr int Inf = 1000000001; constexpr ll INF= 1e18; constexpr ll MOD = 1000000007; const double PI = 3.1415926535897; typedef pair<int,int> P; int main() { int N; cin >> N; string A,B,C; cin >> A >> B >> C; int ret = 0; for(...
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; int main() { ll n; cin >> n; vector<string> s(3); for(ll i=0;i<3;i++) { cin >> s[i]; } ll ans=0; for(ll i=0;i<n;i++) { set<char> ss; for(ll j=0;j<3;j++) { ss.insert(s[j][i]); } ans+=ss.si...
1
#include <iostream> #include <vector> using namespace std; typedef pair<int, bool> Link; typedef vector<vector<Link> > Graph; int main () { int V, E; cin >> V >> E; Graph g(V, vector<Link>(V)); // Set identity to 0 for(int i=0; i<V; i++) g[i][i] = make_pair(0, true); // Set known ed...
#include<bits/stdc++.h> using namespace std; int N,M; int main() { while(true){ scanf("%d%d",&N,&M); if(N==0&&M==0)return 0; int cost[200][200]; int time[200][200]; int minc[200][200]; int mint[200][200]; for(int i=0;i<M;i++){ for(int j=0;j<M;j++){ cost[i][j]=1<<25; time[i][j]=1<<25; minc...
0
#include<iostream> #include<string> #include<vector> #include<cstdio> #include<sstream> #include<algorithm> #include<cmath> #include<map> using namespace std; int main(){ int n, dp[50]; while(cin>>n,n!=0){ fill(dp,dp+50,0); dp[0]=0,dp[1]=1,dp[2]=1,dp[3]=2; for(int i=3;i<=n+1;i++)dp[i]=dp[i-1]+dp[i-2]+dp[i-3]; int ans=d...
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define x first #define y second typedef pair<int,int> pii; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; template <typename T> void chkmax(T &x,T y){x<y?x=y:T();} template <typena...
0
#include<iostream> #include<algorithm> using namespace std; int main(){ int a,b,l=100,s=0; for(int i=0;i<4;i++){ cin>>a; s+=a; l=min(a,l); } cin>>a>>b; cout<<s-l+max(a,b)<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> SubjectsInfo; int main() { int score; for (int i = 0; i < 6; ++i) { cin >> score; SubjectsInfo.push_back(score); } sort(SubjectsInfo.begin(), SubjectsInfo.begin() + 4); cout << SubjectsInfo[1] + SubjectsInfo[2] + SubjectsInfo[3] + max(SubjectsInfo[4...
1
#include<bits/stdc++.h> using namespace std; int main(){ string S; cin>>S; if(S.size()==2) cout<<S<<endl; else cout<<S.at(2)<<S.at(1)<<S.at(0)<<endl; }
const int LG = 21; const int FN = 400005; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long INFLL = 1e18; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ve...
1
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); string S; cin >> S; int ok=0; for (int i=0;i+1<S.size();++i) if (S[i]=='A'&&S[i+1]=='C') ok=1; cout << (ok?"Yes":"No") << '\n'; }
#include<iostream> using namespace std; int main(){ int x; cin>>x; int temp=x; int sum=0; while(temp!=0) { sum+=temp%10; temp/=10; } if(x%sum==0) { cout<<"Yes"; } else cout<<"No"; }
0
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define all(z) (z).begin(),(z).end() #define MOD 1000000007 #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll isprime(ll n) { for(int i=2;i<n;i++) if(n%i==0) return 0; return 1; } i...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int d, t, s; cin >> d >> t >> s; string ans = "Yes"; if (s * t < d) ans = "No"; cout << ans << endl; }
1
#include<iostream> #include<math.h> using namespace std; class Xcubic{ public: int cal(int x){ int res=(int)pow(x,3); return res; } }; int main(){ int x; cin>>x; Xcubic xcubic; cout<<xcubic.cal(x)<<endl; return 0; }
#include<iostream> #include<iomanip> using namespace std; int main(void){ int x; cin >> x; cout << x*x*x <<"\n"; return 0; }
1
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; if(S == "SSS") cout << "0" << endl; else if(S == "RRR") cout << "3" << endl; else if(S == "SRR" || S == "RRS") cout << "2" << endl; else cout << "1" << endl; }
#include<iostream> #include<cstring> using namespace std; char str[1010]; int main(){ scanf("%s",str); int len=strlen(str); int res=0; for(int i=0;i<len;++i){ int cnt=0; while(i<len&&str[i]=='R'){ cnt++; i++; } res=max(cnt,res); } cout<<...
1
#include<iostream> #include<vector> #include<string> using namespace std; int main() { while (1) { int a; cin >> a; if (a == 0)break; for (int b = 0; b < a; b++) { int c, d, e; cin >> c >> d >> e; if (c == 100 || d == 100 || e == 100)cout << "A" << endl; else if (c+d>179)cout << "A" << endl; e...
#include <iostream> #include <algorithm> using namespace std; int mp[101][101]; bool flg[101] ={}; int n,q; int dis[101]; int sssp(int s,int g) { for(int i=1;i<=n;i++) dis[i] = 1000000000,flg[i] = 0; //flg[s] = 1; dis[s] = 0; int ima; while(1) { int mindis = 1000000000; for(int i=1;i<=n;i++) ...
0
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); ++i) double const PI = 3.1415926535897932384626433; int main() { int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k; if (e - a <= k) { cout << "Yay!" << endl; } else { cou...
#include<bits/stdc++.h> using namespace std; int A, B, C, D, E, K; vector<int> a; int main() { cin >> A >> B >> C >> D >> E >> K; a.push_back(A); a.push_back(B); a.push_back(C); a.push_back(D); a.push_back(E); bool istrue = true; for (int i=0; i<a.size(); i++) { for (int j=i+1; j<a.size(); j++...
1
#include <iostream> #include <string> using namespace std; class Dice{ public: int n1,n2,n3,n4,n5,n6; void East(){ int t = n1; n1 = n4; n4 = n6; n6 = n3; n3 = t; } void West(){ int t = n1; n1 = n3; n3 = n6; n6 = n4; n4 ...
#include <iostream> #include <algorithm> #include <string> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) string str; int ans; class dice{ public: int n[6]; void E(){ int t = n[0]; n[0] = n[3]; n[3] = n[5]; n[5] = n[2]; n[2] = t; } void W(){ int t = n[0]; n[0] = n[2]; n[2] = n[5]; n...
1
#include <bits/stdc++.h> using namespace std; signed main() { double x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; cout << fixed << setprecision(10) << sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) << endl; return (0); }
#include<stdio.h> int main() { int x,y,z; scanf("%d %d %d",&x,&y,&z); if (x>9 || x<1 || y>9 || y<1 || z>9 || z<1) { printf("Error!"); } else if( x == y && y == z && x == z){ printf("No"); } else if (x == z || x == y || y == z){ printf("Yes"); } else if (x>y || z>x || y>z){ printf("No"); } }
0
#include<iostream> using namespace std; const int INF = 2000000; struct LineTable{ int cost; int times; LineTable(){ cost = INF; times = INF; } }; int main(){ int n,m; while(1){ cin >> n >> m; if(n==0&&m==0){ break; } LineTable table[m][m]; for(int i=0;...
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> P; struct Graph{ Graph(int n):E(n),d(n){} vector<vector<tuple<int,int,int>>>E; vector<int>d; void add_edge(int a,int b,int c,int d){ E[a].push_back(make_tuple(b,c,d)); } void dijkstra(int s,int f){ priority_queue<P,vector<P>,greater<...
1
#include <bits/stdc++.h> #define ll long long int using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); ll a; ll b; ll c; cin>>a; cin>>b; cin>>c; if((a==b)&&(b==c)) { cout<<"No"<<"\n"; } else if((a!=b)&&(b!=c)&&(c!=a)) { cout<<"No"<<"\n"; } else { cout<<"Yes"<<"\n"; } return...
#include <bits/stdc++.h> #include <iostream> #include <algorithm> #include <ctype.h> #include <math.h> #include <stack> #include <string> #include <string.h> using namespace std; double PI = 3.1415926535897932; long mod = 1000000007; const long INF = 1e9 + 1; int main() { int a[3]; cin >> a[0] >> a[1] >> a[2]; ...
1
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define SZ(X) ((int)(X).size()) #define endl "\n"; int main() { ios::sync_with_stdio(0); cin.tie(0); int n,a[9]={111,222,333,444,555,666,777,888,999}; cin>>n; for(int i=0;i<9;i++){ if(n<=a[i]) { cout<<a[i]<<endl; re...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = n - 1; i >= a; i--) using namespace std; using ll = long long; using P = pair<int, int>; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b)...
1
#include<bits/stdc++.h> #define int long long #define for0(i, n) for(int i = 0; i < (n); i++) #define mp make_pair using namespace std; int t, n, q, l = 0, r = 123456, x = 2147483647, q1; pair<int, int>t1[123456], t2[12345], t3[1234], t4[123], t5[12]; void f1() { r++; while (l < r) { if (l % 10000 == 0 && l + 10000...
#include <bits/stdc++.h> using namespace std; const int INF=INT_MAX; struct lst { private: int n; vector<int> node; vector<int> lazy; vector<bool> lflg; public: lst(int sz) { n=1; while(n<sz) n*=2; node.resize(2*n-1, INF); la...
1
#include <iostream> #include <iomanip> #include <algorithm> #include <bitset> #include <string> #include <cmath> #include <complex> #include <numeric> #include <cassert> #include <vector> #include <array> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <utility> #define int64...
#include<bits/stdc++.h> using namespace std; #define FOR(i,l,r) for(long long i=(l);i<(r);++i) #define REP(i,n) FOR(i,0,n) #define REPS(i,n) FOR(i,1,n+1) #define RFOR(i,l,r) for(long long i=(l);i>=(r);--i) #define RREP(i,n) RFOR(i,n-1,0) #define RREPS(i,n) RFOR(i,n,1) #define int long long #define mp make_pair #define ...
1
#include <bits/stdc++.h> using namespace::std; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef array<int, 3> tri; typedef long double ld; template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;} template <class T> ostream& op...
#include <bits/stdc++.h> using namespace std; #define print cout << #define printl(s) cout << s << endl; #define rep(i,n) for (int i = 0; i < (n); ++i) using ll = long long; const ll modseed = pow(10,9) + 7; template <typename T> vector<T> getValues(int num){ vector<T> values(num); for(int i=0;i<num;i++){ ...
0
#include<iostream> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<vector> #include<cmath> #include<cstring> #include<cstdio> #include<time.h> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define rp(a) while(a--) #define pb push_back #define mp make_...
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for(int i=0; i<n; i++) cin >> v[i]; for(int i=n-1; i>=0; i--){ if(i != n-1) cout << " "; cout << v[i]; } cout << endl; return 0; }
0
#include <iostream> #include <vector> #include <string> using std::cin; using std::cout; using std::endl; char encode(char c, int n) { char ret = c; for (int i = 0; i < n; i++) { if (ret == 'a') { ret = 'Z'; } else if (ret == 'A') { ret = 'z'; } else { ret -= 1; } } return ret; } int main(v...
#include<iostream> using namespace std; #define MAX 100 #define BLANK 0 #define LONG 4 #define SHORT 2 #define HORIZONTAL 0 #define VERTICAL 1 #define VISITED 9 int field[MAX+2][MAX+2]; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; void rec(int x,int y,int c) { int i; if(field[x][y]!=c)return; field[x][y]=VISITED;...
0
#include<bits/stdc++.h> using namespace std; using ll = long long; /***********debug tools***********/ template<class T> inline ostream& operator<<(ostream& os,vector<T> arr) {os << "["; for(int i = 0; i < (int)arr.size(); i++)os << arr[i] << (i == (int)arr.size() - 1 ? "]" : ",");os << endl;return os;} template<type...
#include "bits/stdc++.h" using namespace std; /////////////////////////////////////////// const long long int INF = 1LL<<60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using P = pair<int, int>; using PLL = pair<ll, ll...
0
#include<iostream> using namespace std; #include<string> #include<strstream> #include<sstream> #include<algorithm> #include<math.h> #include<iomanip> #include<set> long long mod = 10e18; long long is(int n) { if (n == 0) return 2; if (n == 1) return 1; return (is(n - 1) + is(n - 2)); } int main() { int n, k; ci...
#include<iostream> #include<cstdio> #include<map> using namespace std; #define int long long map<char, int> m={ {'I',1}, {'V',5}, {'X',10}, {'L',50}, {'C',100}, {'D',500}, {'M',1000}, }; signed main(){ char buf[256]; while( scanf("%s", buf) != EOF ...
0
#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<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define ll long long #define FASTIO ios_base::sync_with_stdio(0);cin.t...
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0; i < (n); i++) #define REP1(i, n) for(int i = 1; i <= (n); i++) #define REPD(i,a,b) for (int i=(a);i<(b);i++) #define ALL(v) (v).begin(), (v).end() using namespace std; typedef long long ll; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> v...
0
#include <iostream> using namespace std; int main() { int n; while(1){ cin >> n; if(n == 0) break; int num[10000][2] = {}; int score[2] = {}; for (int i = 0; i < n; ++i) { for (int j = 0; j < 2; ++j){ cin >> num[i][j]; } if (num[i][0] > num[i][1]) ...
#include <iostream> using namespace std; int result[200] = { 0 }; int main(){ int num; int tmp1, tmp2, sc1 = 0, sc2= 0; while (cin >> num){ sc1 = sc2 = 0; if (num == 0)break; for (int i = 0; i < num; i++){ cin >> tmp1 >> tmp2; if (tmp1 == tmp2){ sc1 += tmp1; sc2 += tmp2; } else ...
1
#include <iostream> #include <vector> #include <cassert> #include <cmath> using ll = long long; #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) int const nmax = 200; ll v[1 + nmax]; class IndependentSet{ private: std::vector<std::pair<ll,int>> v; public: ll reduce(ll numbe...
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MOD=1000000007; #define INF 1LL<<30 #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() // a^n mod を計算する // O(logn) ll modpow(ll a, ll n, ll mod=998244353) { ll res = 1; while (n > 0) { if (n & ...
0
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define REP(a,b) for(int a=0;a<(b);++a) #define REP1(i,n) for(int i=1;i<=(n);++i) #define debug(x) cerr<<#x<<": "<<x<<'\n' #define all(x) (x).begin(),(x).end() #define YES() printf("YES\n") #define NO() printf("NO\n") #define isYES(x) printf("...
#include<bits/stdc++.h> using namespace std; vector<int>adj[100003],leaf; int par[100003],depth[100005],sparse[100005][20],root=0,lz=0; int lca(int p,int q) { int a,b,c,d,lp,i,j; if(depth[p]<depth[q]) { c=p; p=q; q=c; } for(j=19;j>=0;j--) { if((depth[p]-(1 << j))>=depth[q])...
1
# include <bits/stdc++.h> using namespace std; int main(){ long long N; cin>>N; long long A[N]; long long O[65]; for(long long i=0;i<65;i++){ O[i]=0; } for(long long i=0;i<N;i++){ cin>>A[i]; int count=0; long long temp=A[i]; while(temp!=0){ O[count]+= temp%2; temp/=2; ...
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> //required #include <ext/pb_ds/tree_policy.hpp> //required using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // find_by_order(k) r...
1
#include <stdio.h> #include <algorithm> int n, t, x; int a[100000]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", a + i); } std::sort(a, a + n); t = 1; for (int i = 0; i < n; i++) { if (i == n - 1 || a[i] != a[i + 1]) { if (t % 2)x++; t = 1; } else t++; } printf("%d\n", x...
#include<iostream> #include<string> using namespace std; string data[22]; int solve(int x, int y){ if(x < 0 || y < 0 || x == 12 || y == 12 || data[y][x] == '0') return 0; data[y][x] = '0'; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; for(int i=0;i<4;i++) solve(x+dx[i], y+dy[i]); return 1; } ...
0
#include <bits/stdc++.h> #define CHOOSE(a) CHOOSE2 a #define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x #define dump_1(x1) cerr << #x1 << ": " << x1 << endl #define dump_2(x1, x2) \ cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl #define dump_3(x1, x2, x3) \ ce...
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <iomanip> // fixed, se...
0
#include <iostream> #include <cstdio> #include <string> using namespace std; int main() { string s; cin >> s; for(int i = s.size()-1; i >= 0; i--) printf("%c", s[i]); cout << endl; }
#include<bits/stdc++.h> using namespace std; signed main(void){ ios::sync_with_stdio(false); int d,ans; while(cin>>d){ ans=0; for(int i=0;i<600;i+=d) ans+=i*i*d; cout<<ans<<endl; } }
0
/* * sto Qingyu orz * 感谢真神sqy无私的教诲。膜时队者处处阿克,只因大师sqy在他背后。不膜大师者违背了真神的旨意,真神必将降下天谴, * 使其天天爆零 * 我不由自主地膜拜真神sqy。 * Author: RainAir * Time: 2019-10-16 10:11:35 */ #include <algorithm> #include <iostream> #include <cstring> #include <climits> #include <cstdlib> #include <cstdio> #include <bitset> #include <vector> #inclu...
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <queue> #include <cmath> #include <climits> #include <iomanip> #include <set> #include <map> using namespace std; typedef long long ll; int main(){ ll n = 0; ll m = 0; cin >> n >> m; vector<ll> a(n); vector<ll> b(m); map<l...
0
#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; int main(void) { int n,a,b; cin >> n; if(n==2) { cin >> a >> b; cout << a + b << endl; } else { cout << "Hello World\n" << endl; } return 0; }
1
#include <bitset> #include <cmath> #include <iostream> using namespace std; int a(int i) { int ret{}; for (int j = 0; j != i; ++j) { ret += lround(pow(2, 2 * j + 1)); } return ret; } int main() { long long N; cin >> N; bitset<64> ans; for (int i = 0; i != 16; ++i) { auto x = ((N + a(i)) >> 2...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int main(){ ll N; cin >> N; if (N == 0){ cout << '0' << endl; exit(0); } vector<ll> bin(0); while (N != 1){ ll amari = N % -2; if (amari >= 0){ bin.push_back(amari); N /= -2; } else{ bin.pus...
1
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<random> #include<functional> #include<algorithm> #include<stack> #include<cstdio> #include<bitset> #include<unordered_map> #include<climits> #include<fstream> using ...
#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; typedef long long int lli; typedef unsigned long long int ulli; typedef long double ld; #define vec(s) vector<s> #define vvec(s) vector<vector<s>> typedef vector<lli> vi; typedef vector<vi> vvi; typedef pair<lli,lli> pii; #define rep(i, n) for (int i =...
0
#pragma warning(disable: 4996) #include <string> #include <vector> #include <iostream> #include <cstdio> #include <sstream> #include <fstream> #include <math.h> #include <algorithm> using namespace std; typedef long long ll; #define rep(i,n) for (int i = 0; i < (n); i++) int main() { int n, m; cin >> n >> m; ...
#include <bits/stdc++.h> using namespace std; bool intCheck(int i, int N, int M, vector<int> S, vector<int> C) { string sx = to_string(i); if (sx.size() != N) return false; for (int j = 0; j < M; j++) { if (sx.at(S.at(j)) != (char)C.at(j) + '0') return false; } return true; } int main() { ...
1
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; map<ll, ll> a; for(int i = 0; i < N; i++) { ll A; cin >> A; a[A]++; } vector<ll> x; for(auto i = begin(a); i != a....
#include <bits/stdc++.h> using namespace std; using pp=pair<int,char>; using ll=long long; int main() { int N; cin >> N; vector<int> A(N), V(2, 0); for (int i=0; i<N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); A.push_back(0); int s=1; for (int i=0; i<N; i++) { if (A[i]==A[i+1]) { ...
1
#include <iostream> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #...
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define repr(i,n) for(int i = (int)(n); i >= 0; i--) #define all(v) v.begin(),v.end() typedef long long ll; int main(){ int H,W; cin >> H >> W; vector<vector<int> > A(H, vector<int> (W)), B(H, vector<int> (W));...
0
#include <bits/stdc++.h> #define int long long #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() #define pb push_back #define F first #define S second using namespace std; typedef pair<int,int> P; typedef vector<int> ivec; template<class T> inline bool chmax(T& a, T b) { if (a < ...
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<(int)n;i++) using namespace std; using qp=queue<pair<int,int>>; int main(){ int H,W; cin>>H>>W; string s; vector<string> S(H+2,string(W+2,'#')); int cnt=0; REP(h,H) { cin>>s; S[h+1]='#'+s+'#'; for(auto x: S[h+1]) if(x=='.') cnt++; }...
0
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() int main(void){ char a; bool contain = false; rep(i, 3){ cin >> a; if(a == '7'){ contain = true...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < (int)(n); i++) int main() { string s; cin >> s; if(s.size()%2 == 1){ cout << "No" << endl; return 0; } rep(i,s.size()){ if(i%2 == 0 && s[i] != 'h'){ cout << "No" << endl; return 0;...
0
#include <bits/stdc++.h> #define ln '\n' #define all(dat) dat.begin(), dat.end() #define loop(i, to) for (int i = 0; i < to; ++i) #define cont(i, to) for (int i = 1; i <= to; ++i) #define circ(i, fm, to) for (int i = fm; i <= to; ++i) #define foreach(i, dat) for (__typeof(d...
#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <map> using namespace std; typedef long long ll; typedef pair < int, int > pii; const int N = 16; const int M = (1 << N); const int INF = 0x3f3f3f3f; int dp[N][M], g[N][N], n, m, r...
1
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long const int N=1e3+5; const int MOD=1e9+7; int n, a, b, c, d; int cache[N][N], cache2[N][N]; int fact[N], invfact[N]; int pow(int a, int b, int m) { int ans=1; while...
#include <bits/stdc++.h> #define all(vec) vec.begin(),vec.end() using namespace std; using ll=long long; using P=pair<int,int>; const ll INF=1LL<<30; const ll LINF=1LL<<61; const double eps=1e-9; const ll MOD=1000000007LL; vector<ll> f,fi; ll mpow(ll x,ll n){ ll res=1; while(n>0){ if(n&1){ r...
1
#include <bits/stdc++.h> using namespace std; int main() { int N,k; cin >> N >>k; int sum; if(k==1){ sum = N+1; } else if(k==2||k==3||k==4){ if (N==1){ sum = 2; } else{ sum = 4 + k*(N-2); } } else if(k==5||k==6||k==7){ if (N==1){ sum = 2; } else if(N==2){ ...
#include <stdio.h> int main() { int n, k, number = 1; scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) { number = number * 2 < number + k ? number * 2 : number + k; } printf("%d\n", number); return 0; }
1
#include<bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; using Pii = pair<int, int>; using Pll = pair<ll, ll>; #define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i) #define ALL(x) (x).begin(),(x).end() #define pb push_back ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;} ll ...
# include <bits/stdc++.h> # define sz(x) (int)((x).size()) # define F first # define S second # define pb push_back # define ub upper_bound # define lb lower_bound # define all(x) x.begin(), x.end() # define pqueue priority_queue # define mset multiset # define umap unordered_map # define Speed() ios_base::sync_with_st...
0
#include <bits/stdc++.h> using ll = long long; using namespace std; constexpr int inf = 0x3f3f3f3f; constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL; int main() { cin.tie(0); ios::sync_with_stdio(false); ll k; cin >> k; ll m = k % 50; cout << 50 << '\n'; vector<ll> a(50, k / 50 + 49 - m); for (in...
#include <cstdio> #include <cstdint> #include <vector> #include <algorithm> bool f(std::vector<intmax_t>& a) { std::sort(a.rbegin(), a.rend()); intmax_t n = a.size(); a[0] -= n; for (size_t i = 1; i < a.size(); ++i) ++a[i]; std::sort(a.begin(), a.end()); return !std::all_of(a.begin(), a.end(), [=](auto x)...
1
/** * author: souzai32 * created: 14.08.2020 14:10:05 **/ #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int n,k; cin >> n >> k; vector<long long> x(n); rep(i,n) cin >> x.at(i); long long left,right; long long ans=1e9; ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long int #define ld long double #define ordered_set tree < ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > //added tw...
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #defi...
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n)...
0
#include <bits/stdc++.h> typedef long long ll; #define pb push_back using namespace std; typedef pair<ll,ll> pll; vector< pll > v; ll n; ll h[5005], p[5005]; ll dp[5005][5005]; const ll inf = 1e16; int main() { cin >> n; v.pb(make_pair(-2LL , -2LL)); for(ll i=1;i<=n;i++) { cin ...
#include <iostream> #include <map> #include <set> #include <vector> using namespace std; typedef std::pair<int, int> P; bool is_vis[1003][1003]; bool is_fin[1003][1003]; bool is_cycle; void dfs(map<P, vector<P>> &g, P p) { int player1 = p.first; int player2 = p.second; is_vis[player1][player2] = true; for...
0
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n); i++) using ll = long long; using ull = unsigned long long; using P = pair<int,int>; using PP = pair<int,pair<int,int>>; using T = tuple<string,int,int>; const ll INF = 1LL<<60; int main(){ vector<int> a(3); rep(i,3) cin >> a[i];...
#include <iostream> #include <vector> #include <climits> #include <algorithm> #include <cmath> #include <map> #include <set> #include <string> #include <bitset> #include <utility> #include <numeric> #include <queue> #include <stack> using ll = long long; using namespace std; constexpr int MOD = 1e9 + 7; constexpr ll ...
1
#include <bits/stdc++.h> #include <vector> #define rep(i, n) for(int i = 0; i < n; ++i) #define ll long long using namespace std; bool check(string x, string y) { int a = x.size()-1; return x[a] == y[0]; } int main() { string a, b, c; cin >> a >> b >> c; if(check(a, b) && check(b, c)) cout << "YES" << endl; ...
#include <bits/stdc++.h> using namespace std; //type #define ll long long typedef pair<int, int> P; //定数 #define INF 1000000000000 //10^12:∞ #define MOD 1000000007 //10^9+7:合同式の法 #define MAXR 100000 //10^5:配列の最大のrange //略記 #define PB push_back //挿入 #define MP make_pair //pairのコンストラクタ #define F first //pa...
0
/****************************************** * AUTHOR : GURUTEJA * ******************************************/ #include <bits/stdc++.h> using namespace std; #define LL long long #define N 100005 #define MOD 1000000007 #define dd double #define rep(i, n) for(int i = 0; i < n; i++) #define REP(i,a,b) for(int i=a;i<b;i++) ...
#include<bits/stdc++.h> using namespace std; #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<<fixed; cout<<setprecision(12); #define randomINT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); #define newl cout<<"\n" #define DISP(as) for(auto it : as) cout<<it<<" ";...
1
#include<iostream> #include<vector> #include<map> #include<algorithm> using namespace std; class BIT{ public: int size; int* bit; BIT(int _size = 0){ size = _size; bit = new int[size]; for(int i = 0; i < size; i++) bit[i] = 0; } ~BIT(){delete[] bit;} /* En: returns sum of [from bit[0] t...
#include <iostream> #include <cstdio> using namespace std; typedef long long ll; ll /*A[2000000],*/ cnt = 0; int A[210000]; int L[110001]; int R[110001]; int merge(int l, int m, int r){ int n1 = m - l, n2 = r - m, i, j; //ll L[n1 + 1], R[n2 + 1]; for(i = 0;i < n1;i++)L[i] = A[i + l]; for(i = 0;i < n2...
1
#include <bits/stdc++.h> #define INF 5000000000000000000 #define ll long long #define pll pair<ll, ll> using namespace std; ll N, M; ll count_max(vector<queue<ll>>& A, vector<bool>& already) { vector<ll> cnt(M, 0); for (ll i = 0; i < N; ++i) { while (true) { if (already.at(A.at(i).front())) { A....
#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<string,int>; const double PI = acos(-1); int main() { int l,m,n; cin >> l >> m >> n; vector<int> a(l); vector<int> b(m); rep(i,l) cin >> a.at(i); rep(i,m) cin >> b.at(i); vector<vecto...
0
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<ll> vl; typedef pair<ll, ll> PP; #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define all(v) v.begin(), v.end() #define inputv(v, n) \ vl v; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define elif else if #define sp(x) fixed << setprecision(x) #define pb push_back #define eb emplace_back #define all(x) x.begin()...
1
#include "bits/stdc++.h" #define int long long using namespace std; const int mod = 1e9 + 7; int32_t main() { cin.tie(0); ios_base::sync_with_stdio(0); int n; cin >> n; vector<vector<int>> a(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { c...
#include<string> #include<iostream> #include<cctype> #include<cmath> #include<cstdio> using namespace std; int main(void){ int a; cin >> a; int b[10000]; long long min=pow(10,6); long long max=-pow(10,6); int i; for(i=0;i<a;i++){ cin >> b[i]; } for(i=0;i<a;i++){ if(min>b[i]) min=b[i]; if(max<b[i]) ...
0
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstdlib> #include<queue> #include<set> #include<cstdio> using namespace std; #define ll long long #define rep(i, n) for(int i = 0; i < n; i++) #define P pair<int, int> typedef vector<int> vec; typedef vector<vec> mat; int main(){ ...
#include <bits/stdc++.h> using namespace std; #define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); } #define all(v) (v).begin(), (v).end() #define int long long #define sz(v) (int)(v).size() #define mod 1000000007 // (...
1
#include <stdio.h> int main(){ int dice[7]; char com[1000]; int i,j,k; int n,e,w,s,top; for(i=1;i<=6;i++) scanf("%d",&dice[i]); scanf("%s",com); top=1; n=5; s=2; w=4; e=3; for(i=0;com[i]!='\0';i++){ if(com[i]=='N'){ n=top; top=s; s=7-n; }else if(com[i]=='S'){ ...
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; map<char,vector<int>> dist; for(int i=0; i< s.size(); i++){ dist[s.at(i)].push_back(i); } /*ここからアンバランス探しmapにはアルファベットと出現箇所が紐づけ 各アルファベットについて、隣り合ってたらok */ bool seikai = false; for(auto& a: dist ){ if...
0
/* bfs 找环 */ #include <bits/stdc++.h> #define N 1005 #define M 2005 using namespace std; int n, m; int dep[N]; int head[N], nex[M], to[M], e; int stk[N], top; bool instack[N], vis[N], G[N][N]; vector<int> res; inline int Rd() { int x = 0; char ch = getchar(); while(!isdigit(ch)) ch = getchar(); while(isdigit(ch)...
#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(...) ...
1
#include <bits/stdc++.h> // #include <atcoder/all> using namespace std; // using namespace atcoder; #define rp(i, k, n) for (int i = k; i < n; i++) using ll = long long; using ld = double; template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>inline bool chmi...
#pragma GCC optimize(3 , "Ofast" , "inline") #include <bits/stdc++.h> #define rep(i , a , b) for(register int i=(a);i<=(b);i++) #define per(i , a , b) for(register int i=(a);i>=(b);i--) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int , int> pi; template<class T> inline v...
1
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; const ll INF = 1LL << 60; vector<ll> calc_divisor(ll n) { vector<ll> res; for (ll i = 1LL; i*i <= n; ++i) { if (n % i == 0) { ...
#include<bits/stdc++.h> #include<cctype> using namespace std; #define rep(i,n) for (int i=0;i<(n);i++) #define all(v) (v).begin(),(v).end() typedef long long int ll; #define pi 3.1415926535897932384 #define E9 1000000000 #define eps 1e-4 #define pii pair<int,int> int main(){ int N, M; cin >> N >> M; int MAX = M/N;...
1
#include<bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; struct Node { int first , second; int dir; }node[maxn]; // x + y bool cmp1(const Node & a , const Node & b) { if (a.first + a.second != b.first + b.second) return a.first + a.second < b.first + b.second; return a.first < b.fi...
#include<cstring> #include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<map> #include<set> #define l(x) (x<<1) #define r(x) ((x<<1)|1) #define IL inline #define reg register #define LL long long #define N 200010 #define INF 0x3f3f3f3f using namespace std; int n,i,j; int ans=...
1
#include <bits/stdc++.h> using namespace std; #define int long long #define f first #define s second #define pb push_back typedef vector<int> vi; #define mod 1000000007 #define nos ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) int dp[3005][3005]; int n,t; int happy(vector<pair<int,int>>&a,int pidx,int time) { ...
#include<bits/stdc++.h> #define rep(i, n) for(int i=0; i<n; i++) #define repo(i, n) for(int i=1; i<=n; i++) #define INF 1001001001 #define INFll 100100100100100 // debug用 #define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl; using namespace std; using ull = unsigned long l...
1
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1}; #define PI 3.14159265358979323846264338327950L #define MOD 1000000007 //setprecision(15) int main()...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i) #define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i) #define rreps(i, n) for(int i=((int)(n)); i>0; --i) #define all(x) (x).begin(), (x).end() #define ...
1