akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-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(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int n, m, x;
	cin >> n >> m >> x;

	int a[105];
	rep(i,m) cin >> a[i];

	int i = 0;
	for(i = 0; a[i] < x; i++)
		;

	int res = min(i, m-i);

	cout << res << endl;
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[11];
int main()
{
    gets(s);
    if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I') printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#define endl "\n"

int main()
{
	faster;
	
	int x,y;
	cin >> x >> y;

	if(y % x == 0 && (y/x == 2 || y/x == 4)){
		cout << "Yes";
	}else {
		bool flag = false;
		for(int i = 1; i < x; i++){
			if(i * 2 + (x-i) * 4 == y) {
				flag = true;
				break;
			}
		}
		cout << (flag ? "Yes" : "No");
	}
	
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int dp[114514];
set<int> ts[114514];
signed main(){
	int n,m;
	cin>>n>>m;
	string st;
	cin>>st;
	for(int i=0;i<=110000;i++){
		dp[i] = LINF;
	}
	dp[n] = 0;
	ts[0].insert(n);
	multiset<int> cand;
	cand.insert(0);
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if( st[i] == '1' ){
			cnt ++ ;
		}
		else{
			cnt = 0;
		}
		if( cnt >= m ){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=n-1;i>=0;i--){
		if( st[i] == '0' ){
			auto it = cand.begin();
			dp[i] = *it + 1;
			cand.insert( dp[i] );
			ts[dp[i]].insert(i);
		}
		if( i+m <= n ){
			auto it = cand.lower_bound(dp[i+m]);
			if( it != cand.end() )cand.erase(it);
		}
	}
	int pos = 0;
	if( dp[0] > n ){
		cout<<-1<<Endl;
		return 0;
	}
	vector<int> ans;
	for(int i=dp[0]-1;i>=0;i--){
		auto it = ts[i].lower_bound(pos);
		ans.pb(*it-pos);
		pos = *it;
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        c[i] = a[i] + b[i];
    }
    ll ans = 0;
    sort(c.begin(), c.end(), greater<ll>());
    for (ll i = 0; i < n; i++) {
        if (i % 2 == 0) ans += c[i];
        ans -= b[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5584
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(ll x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
string s;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>s;
	if(s.size()==1){
		cout<<s;
		return 0;
	}
	for(int i=1;i<s.size();i++){
		if(s[i]!='9'){
			break;
		}
		if(i==s.size()-1){
			cout<<s.size()*9-9+s[0]-'0';
			return 0;
		}
	}
	cout<<9*s.size()-9+s[0]-'0'-1;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
//////////////////

int const N = 5e5 + 41;

int n, q;
int d[N], dp[N], D, a[N];
int ans[N];

void solve(){
	cin >> n >> D;
	d[0] = D;
	fr(i, 1, n+1){
		cin >> a[i];
		d[i] = d[i-1];
		int di;
		if(a[i] > d[i]) di = a[i] - d[i];
		else di = d[i] - a[i];
		d[i] = min(d[i], di);
	}

	fdr(i, 1, n+1){
		if(i == n){
			dp[i] = 1;
		}else{
			dp[i] = dp[i+1];
			if(a[i+1] - dp[i] >= dp[i]){
			}else{
				dp[i] += a[i+1];
			}
		}
		if(d[i-1] >= dp[i]) ans[i] = 1;
	}
	//fr(i, 0, n+1){
	//	cerr << d[i] << " " << dp[i] << endl;
	//}

	cin >> q;
	fr(i, 0, q){
		int id;
		cin >> id;
		if(ans[id]) cout << "YES";
		else cout << "NO";
		cout << endl;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

bool is_r(string s){
   //さかさまにしたものをtとする
   string t(s.rbegin(),s.rend());
   //s==tの時にtrue,!=の時にfalseを返す
   return s==t;
}
int main(){
   string s; cin>>s;
   int n=s.size();
   if(is_r(s)&&is_r(s.substr(0,(n-1)/2))&&is_r(s.substr((n+1)/2))){
      cout<<"Yes"<<endl;
   }
   else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t=0;
	cin>>n;
	for(int c=1;c<=n;c++){
		int m=n-c;
		for(int i=1;i<=int(sqrt(m));i++){
			if(m%i==0){
				if(i==sqrt(m))    t++;
				else    t+=2;
			}
		}
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    char a;
    cin>>a;
    if(a<=90){
        cout<<"A";
    }else{
        cout<<"a";
    }
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long sum = saiki(N, 0);
            if (N % sum == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        static long saiki(long N,long f)
        {
            f += N % 10;

            if (N != 0)
            {
                return saiki(N / 10, f);
            }
            else
            {
                return f;
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);

Measured memory_bytes: 27384
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = 1000005;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int dp[45][505][505];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<pair<P, int>> v;

    for(int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        v.pb(MP(MP(a, b), c));

    }

    vector<P> ans;
    int x, y;
    x = ma, y = mb;
    while(x <= 500 && y <= 500) {
        ans.pb(MP(x, y));
        x += ma;
        y += mb;

    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= 500; ++j) {
            for(int k = 0; k <= 500; ++k) {
                dp[i][j][k] = INF;

            }
        }
    }

    for(int i = 0; i < n; ++i) {
        dp[i][0][0] = 0;
        int a, b, c;
        a = v[i].F.F;
        b = v[i].F.S;
        c = v[i].S;
        for(int j = 1; j <= 500; ++j) {
            for(int k = 1; k <= 500; ++k) {
                if(i == 0) {
                    if(j == a && k == b) {
                        dp[i][j][k] = c;

                    }
                } else {
                    dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
                    if(a <= j && b <= k) {
                        dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a][k - b] + c);

                    }
                }
            }
        }
    }

    int res = INF;
    for(int i = 0; i < ans.size(); ++i) {
        res = min(res, dp[n - 1][ans[i].F][ans[i].S]);


    }

    if(res == INF) {
        cout << -1;

    } else {
        cout << res;

    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 41216
function main(input) {
  let args = input.split(/\s|\n/);
  let change = 0;
  for (i = 0;i < args[0].length;i++) {
    if (args[0][i] !== args[1][i]) {
     change++;
    }
  }
  console.log(change);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 33040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,A,B,N,M,K,X,Y,Z;
  string S,T,U;
  cin >> S >> T >> A >> B >> U;

    if(S == U){
        A -= 1;
      
    }else{
        B -= 1;
    }

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
n=int(input())
list=[]
list2=[0]*n
count=0
next=1
for i in range(n):
  list.append(int(input()))
while True:
  list2[next-1]+=1
  count+=1
  next=list[next-1]
  if next==2:
    print(count)
    break
  if list2[next-1] >= 2:
    print(-1)
    break

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;

#define MAX 100010

int main(void)
{
  int N, M, H[MAX], ma[MAX];
  cin >> N >> M;

  for (int i = 1; i <= N; ++i)
  {
    cin >> H[i];
    ma[i] = 0;
  }

  for (int i = 0; i < M; ++i)
  {
    int a, b;
    cin >> a >> b;
    // 道に隣接する展望台の標高で最も高いものを求める
    // 展望台それぞれの標高はHにあるので、aに道でつながる相手のbの標高を更新している
    ma[a] = max(ma[a], H[b]);
    ma[b] = max(ma[b], H[a]);
  }

  int ans = 0;
  for (int i = 1; i <= N; ++i)
  {
    // 道で一番高い標高と比較して、高ければカウント
    ans += H[i] > ma[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4380
#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) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[20][2][1000][2];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  dp[0][0][0][0]=1;
  rep(i,n) rep(j,2) rep(k,1000) rep(l,2){
    ll now=s[i]-'0';
    rep(nxt,10){
      if(nxt>now&&j==0) continue;
      ll nj=j,nl=l;
      if(nxt<now) nj=1;
      ll nk=k%100*10+nxt;
      if(k/100==5&&k%100/10==1&&nxt==3) nl=1;
      dp[i+1][nj][nk][nl]+=dp[i][j][k][l];
    }
  }
  
  ll ans=0;
  rep(j,2) rep(k,1000) ans+=dp[n][j][k][1];
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    ll A,B,K; cin >> A >> B >> K;
    ll Af = max(0ll,A-K);
    ll Bf = max(0ll,B-max(0ll,K-A));
    cout << Af << " " << Bf << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N*3);
    for (int i = 0; i < N*3; ++i) cin >> a[i];

    // 左から前処理
    vector<long long> S(N*2+1, 0);
    priority_queue<long long, vector<long long>, greater<long long> > que1;
    for (int i = 0; i < N; ++i) {
        S[i+1] = S[i] + a[i];
        que1.push(a[i]);
    }
    for (int i = N; i < N*2; ++i) {
        long long mi = que1.top();
        if (a[i] > mi) {
            S[i+1] = S[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else S[i+1] = S[i];
    }

    // 右から前処理
    vector<long long> T(N*2+ 1, 0);
    priority_queue<long long> que2;
    for (int i = 0; i < N; ++i) {
        T[i+1] = T[i] + a[N*3-1 - i];
        que2.push(a[N*3-1 - i]);
    }
    for (int i = N; i < N*2; ++i) {
        long long ma = que2.top();
        if (a[N*3-1 - i] < ma) {
            T[i+1] = T[i] - ma + a[N*3-1 - i];
            que2.pop();
            que2.push(a[N*3-1 - i]);
        }
        else T[i+1] = T[i];
    }

    // 集計
    long long res = -(1LL<<60);
    for (int i = N; i <= N*2; ++i) {
        res = max(res, S[i] - T[N*3-i]);
    }
    cout << res << endl;
}
    
    


Measured memory_bytes: 8052
#include<iostream>
using namespace std;
int main() {
	int n, k, u;
	cin >> n >> k >> u;
	cout << min(n, min(k, u)) << ' ';
	if (min(n, min(k, u)) < n && max(n, max(k, u)) > n) {
		cout << n;
	}
	else if (min(n, min(k, u)) < k && max(n, max(k, u)) > k) {
		cout << k;
	}
	else {
		cout << u;
	}
	cout << ' ' << max(n, max(k, u)) << endl;
	int e; cin >> e;
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
	ll X, K, D, min;
	cin >> X >> K >> D;
	X = abs(X);
	if ( K <= X / D)
		min = X - K * D;
	else if ((K - X / D ) % 2 == 0)
		min = X % D;
	else
		min = D - X % D;
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;

class Program
    {
        static void Main(string[] args)
        {         
            string str = Console.ReadLine();

            int countOne = Array.FindAll(str.ToCharArray(), delegate (char x) { return x == '1'; }).Length;
            int countZero = Array.FindAll(str.ToCharArray(), delegate (char x) { return x == '0'; }).Length;

            int countStr = str.Count();

            if(countZero != countOne)
            {
                int dif = Math.Abs(countOne - countZero);
                Console.WriteLine(countStr - dif);
            }
            else
            {
                Console.WriteLine(countStr);
            }
        }
    }

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void){
    int n;
    cin >> n;

    int a[n + 1];
    a[n] = 0;

    ll current_pos = 0;
    ll max_cost = 0;
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n + 1){
        max_cost += abs(current_pos - a[i]);
        current_pos = a[i];
    }

    rep(i, n){
        if(signbit(current_pos - a[i]) == signbit(a[i] - a[i+1])){
            cout << max_cost << endl;
        }else{
            cout << max_cost - abs(current_pos - a[i]) - abs(a[i] - a[i+1]) + abs(current_pos - a[i+1]) << endl;
        }
        current_pos = a[i];
    }
    return 0;

}


Measured memory_bytes: 1664
////////////////////////////////////////BatTle rOweL ///////////////////////////////////////
#include <bits/stdc++.h>
#include <deque>
#include <vector>
using namespace std;
#define smackie ios_base::sync_with_stdio(0); cin.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
typedef long long ll;
#define mset(a,k) memset(a,k,sizeof(a));
#define rep(i,l,h) for(ll i=l;i<h;i++)
#define ds1(i,x) for(int  i=0;i<x.size();i++)
#define ds2(i,x) for(auto i:x)
typedef vector<ll>  vit;
typedef pair<int,int> pii;
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
typedef map<ll,ll >   mps;
//-------------------------------------------<dec>-------------------------------
 bool isPrime(int n) 
{ 
    if (n <= 1) return false; 
    rep(i,2,n)  if (n % i == 0) return false;  
    return true; 
}
 
 
 
//------------------------------------------<Assumes>----------------------------
int main()
{
    smackie
    int n,m;
    int s=0;
    cin>>n>>m;
    if(n>1)s+=n*(n-1)/2;
    if(m>1)s+=m*(m-1)/2;
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1061109567;
const ll LINF = 4557430888798830399ll;

/* --- */

void TestCase() {
    ll n;
    scanf("%lld", &n);
    if(n & 1) {
        printf("%lld\n", n * 2);
        return;
    }
    printf("%lld\n", n);
}

int main() {
#ifdef KisekiPurin
    freopen("KisekiPurin.in", "r", stdin);
    //freopen("KisekiPurin.out", "w", stdout);
#endif // KisekiPurin
    //InitCase();
    int t = 1;
    //scanf("%d", &t);
    for(int i = 1; i <= t; ++i) {
        //printf("Case #%d: ", i);
        TestCase();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int MaxN = 1e5;


int n ,x;
int a[105];
bool cmp(int a,int b)
{
	return a < b;
}

int main()
{
	cin >> n >> x;
	LL sum = 0;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
	}
	sort(a + 1,a + 1 + n,cmp);
	LL an = x - sum;
	n += an / a[1];

	cout << n  << endl;
}




Measured memory_bytes: 256
import java.util.Scanner


object Main {
  val sc = new Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val hh = sc.nextInt
    val ww = sc.nextInt
    val h = sc.nextInt
    val w = sc.nextInt

    println( (hh - h) * (ww - w) )

  }

}

Measured memory_bytes: 25640
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>


using namespace std;

typedef long long ll;

int k, length, pointer;
string S, str[100005];

int main(){

    cin >> S >> k;
    length = S.size();

    for (int i = 1; i <= 5; i++){
        for (int j = 0; j <= length-i; j++){
            str[pointer++] = S.substr(j,i);
        }
    }

    sort(str, str+pointer);
    unique(str, str+pointer);

    cout << str[k-1] << endl;

    return 0;

}

Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    for(;;){
        int n;
        cin >> n;
        if(n==0)break;
        int res = 0;
        int ans = 0;
        vector<pair<int,pair<int, pair<int, int> > > > hoge;
        for (int i=0; i<n; i++) {
            string s,g;
            cin >> s>>g;
            int sh,sm,ss,gh,gm,gs;
            sh = ((int)s[0]-(int)'0')*10+(int)s[1]-(int)'0';
            sm = ((int)s[3]-(int)'0')*10+(int)s[4]-(int)'0';
            ss = ((int)s[6]-(int)'0')*10+(int)s[7]-(int)'0';
            gh = ((int)g[0]-(int)'0')*10+(int)g[1]-(int)'0';
            gm = ((int)g[3]-(int)'0')*10+(int)g[4]-(int)'0';
            gs = ((int)g[6]-(int)'0')*10+(int)g[7]-(int)'0';
            hoge.push_back({sh,{sm,{ss,2}}});
            hoge.push_back({gh,{gm,{gs,1}}});
        }
        sort(hoge.begin(),hoge.end());
        for (int i=0; i<hoge.size(); i++) {
            if (hoge[i].second.second.second==1) {
                res++;
            }else{
                if (res>0) {
                    res--;
                }else{
                    ans++;
                }
            }
        }
        cout << ans <<endl;
    }
}

Measured memory_bytes: 1856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	string str;
	cin>>str;
	if(str[2]==str[3]&&str[4]==str[5]) cout<<"Yes\n";
	else cout<<"No\n";

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int MIN=10010,n;
int a[1010],b[1010],t[10010];
bool V[1010];
int solve(){
	int ans=0;
	sort(b,b+n);
	for(int i=0;i<n;++i) t[b[i]]=i;
	for(int i=0;i<n;++i){
		if(V[i]) continue;
		int cur=i;
		int S=0;
		int m=10010;
		int an=0;
		while(1){
			V[cur]=1;
			++an;
			int v=a[cur];
			m=min(m,v);
			S+=v;
			cur=t[v];
			if(V[cur]) break;
		}
		ans+=min(S+(an-2)*m,m+S+(an+1)*MIN);
	}
	return ans;
}
int main(){
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a[i];
		b[i]=a[i];
		V[i]=0;
		MIN=min(MIN,a[i]);
	}
	cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s;

    cin >> s;

    reverse(s.begin(), s.end());

    string t[4] = {"dream", "dreamer", "erase", "eraser"};

    for (int i = 0; i < 4; i++) {
        reverse(t[i].begin(), t[i].end());
    }

    int j = 0;
    bool isMatched = false;

    while (true) {
        for (int k = 0; k < 4; k++) {
            if (s.substr(j, t[k].size()) == t[k]) {
                j += t[k].size();
                isMatched = true;
                break;
            }
        }

        if (!isMatched) {
            cout << "NO" << endl;
            return 0;
        }

        if (j >= s.size()) {
            break;
        }

        isMatched = false;
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
    int a;
    cin >> a;

    for (auto i = 1; i < 10; ++i) {
        for (auto j = 1; j < 10; ++j) {
            if (i * j == a) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

int henkan(string);
string henkan(int);
bool suuzi(char);
int mcxi(char);
main(){
  int n;
  while(cin >> n){
    for(int i=0;i<n;i++){
      string in1, in2;
      cin >> in1 >> in2;
      int a, b, c;
      a = henkan(in1);
      b = henkan(in2);
      c=a+b;
      string ans;
      ans = henkan(c);
      cout << ans << endl;
    }
  }
  return 0;
}

int henkan(string in){
  int sum=0;
  int size=in.size();
  for(int i=0;i<size;i++){
    int r;
    if(suuzi(in[i])){
      r=in[i]-'0';
      for(int j=0;j<r;j++){
        sum+=mcxi(in[i+1]);
      }
      i++;
    }
    else{
      sum+=mcxi(in[i]);
    }
  }
  return sum;
}

string henkan(int n){
  string ans="";
  int a, b, c, d;
  char ac, bc, cc, dc;
  a=n/1000;
  ac=(char)a+'0';
  n-=a*1000;
  b=n/100;
  bc=(char)b+'0';
  n-=b*100;
  c=n/10;
  cc=(char)c+'0';
  n-=c*10;
  d=n;
  dc=(char)d+'0';
  if(a>1){
    ans+=ac;
  }
  if(a>0){
    ans+='m';
  }
  if(b>1){
    ans+=bc;
  }
  if(b>0){
    ans+='c';
  }
  if(c>1){
    ans+=cc;
  }
  if(c>0){
    ans+='x';
  }
  if(d>1){
    ans+=dc;
  }
  if(d>0){
    ans+='i';
  }
  return ans;
}

bool suuzi(char c){
  if(c>='0' && c<='9') return true;
  return false;
}

int mcxi(char c){
  if(c=='m') return 1000;
  else if(c=='c') return 100;
  else if(c=='x') return 10;
  else return 1;
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
#include<deque>
#include<map>
using namespace std;

int main() {
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	printf("%d\n", max(a*b, c*d));
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main (int argc, char **argv)
{
  int n = 0;
  int m = 0;
  int *a = NULL;
  int *b = NULL;
  int i = 0;
  int j = 0;

  scanf("%d", &n);

  a = (int *)malloc(n * sizeof(int));
  b = (int *)malloc(n * sizeof(int));
  memset(b, 0, n * sizeof(int));

  for(i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
  }

  for(i = n - 1; i >= 0; i--)
  {
    int l = 0;

    for(j = 2; (((i + 1) * j) - 1) < n; j++)
    {
      l += b[((i + 1) * j) - 1];
      l &= 1;
    }

    if(l != a[i])
    {
      b[i] = 1;
      m++;
    }
  }

  printf("%d\n", m);
  for(i = 0; i < n; i++)
  {
    if(b[i])
    {
      printf("%d ", i + 1);
    }
  }
  printf("\n");

  free(a);
  free(b);

  return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll maxi = -1, ans = 0;
  REP(i, n) {
    cin >> a[i];
    if (a[i] >= maxi) {
      ans++;
      maxi = a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double vx1, vy1, vx2, vy2, vxp, vyp;
	double s, t;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		vx1 = x2 - x1;
		vy1 = y2 - y1;
		vx2 = x3 - x1;
		vy2 = y3 - y1;
		vxp = xp - x1;
		vyp = yp - y1;
		s = (vyp*vx2 - vxp*vy2) / (vy1*vx2 - vx1*vy2);
		if (vx2) {
			t = (vxp - vx1*s) / vx2;
		} else {
			t = (vyp - vy1*s) / vy2;
		}

		if (s>0.0 && t>0.0 && s + t<1.0) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

const (
	INF  = 1e9 + 7
	maxN = 110
	maxV = 100100
)

func main() {
	sc.Split(bufio.ScanWords)
	N, W := readInt(), readInt()
	weight := make([]int, N)
	value := make([]int, N)
	for i := 0; i < N; i++ {
		weight[i] = readInt()
		value[i] = readInt()
	}

	dp := make([][]int, maxN)
	for i := 0; i < maxN; i++ {
		dp[i] = make([]int, maxV)
		for j := 0; j < maxV; j++ {
			dp[i][j] = INF
		}
	}

	dp[0][0] = 0

	for i := 0; i < N; i++ {
		for j := 0; j < maxV; j++ {
			if j < value[i] {
				dp[i+1][j] = dp[i][j]
				continue
			}

			dp[i+1][j] = min(dp[i][j], dp[i][j-value[i]]+weight[i])
		}
	}

	result := 0
	for i := 0; i < maxV; i++ {
		if dp[N][i] <= W {
			result = i
		}
	}

	fmt.Println(result)
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 89728
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>

using namespace std;
int A, B, C, D;

int main() {
  cin >> A >> B >> C >> D;
  
  cout << max(A*B, C*D) << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        l: usize,
        s: [String; n],
    }
    let mut s = s;
    s.sort();
    for i in s{
        print!("{}", i);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> l(n);
  vector<ll> r(n);
  vector<ll> lb(n);
  vector<ll> rb(n);
  vector<ll> imos(100100);
  for(int i=0;i<n;i++){
    cin >> l[i];
    cin >> r[i];
    lb[i] = l[i];
    rb[i] = r[i];
    imos[l[i]]++;
    imos[r[i]]--;
  }
  sort(l.begin(), l.end());
  sort(r.begin(), r.end());
  ll ans = 0;
  for(int i=0;i<n;i++){
    ll migi = l.end() - lower_bound(l.begin(), l.end(), rb[i]);
    ll hidari = upper_bound(r.begin(), r.end(), lb[i]) - r.begin();
    ans = max(ans, n - migi - hidari);
  }
  cout << ans << " ";
  ans = imos[0];
  for(int i=1;i<imos.size();i++){
    imos[i] += imos[i-1];
    ans = max(ans, imos[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9956
#include<iostream>
using namespace std;

int main(){

	int x, y, t;

	while(1){
		cin >> x >> y;

		if(x == 0 && y == 0) break;

		if(x > y){
			t = x;
			x = y;
			y = t;
		}

		cout << x << " " << y << endl;
	}

	return 0;
}


Measured memory_bytes: 3052
#include<stdio.h>
#include<string.h>
int main()
{
    char str[100],word[20];
    int len,i,j;
    gets(str);
    len=strlen(str);
    for(i=0,j=0;i<len;i++)
    {
        if(str[i]!=' ')
        {
            word[j]=str[i];
            j++;
        }

        else
        {
            word[j]='\0';
            printf("%c",word[0]-' ');
            j=0;
        }
    }
    if(j>0)
        {
            word[j]='\0';
            printf("%c",word[0]-' ');
   }
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    //#ifndef ONLINE_JUDGE
     //   freopen("input.txt", "r", stdin);
       // freopen("output.txt", "w", stdout);
    //#endif
    lli a,b;cin>>a>>b;
    if(a==b)cout<<a+b;
    else cout<<2*(max(a,b))-1;
 	return 0;
 }

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a < b) {
            System.out.println("a < b");
        } else if(a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26232
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

var infty = 1000000000 + 10

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	prev := -infty
	for i := 0; i < n; i++ {
		ai := nextInt()
		if prev != ai {
			if prev != -infty {
				fmt.Print(" ")
			}
			fmt.Print(ai)
		}
		prev = ai
	}
	fmt.Print("\n")
}



Measured memory_bytes: 3408
# 2020/03/28
# AtCoder Beginner Contest 160 - E

# Input
x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.append(-1000000000)
q.append(-1000000000)
r.append(-1000000000)

# Init
ans = 0

# Sort
p.sort()
p.reverse()
q.sort()
q.reverse()
r.sort()
r.reverse()

anslist = list()

# Make List
for i in range(x):
    anslist.append(p[i])

for i in range(y):
    anslist.append(q[i])

anslist.extend(r)

anslist.sort()
anslist.reverse()

for i in range(x+y):
    ans = ans + anslist[i]

# Output
print(ans)


Measured memory_bytes: 22720
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (max(a, max(b, c)) == a + b + c - max(a, max(b, c))) Yes;
  else No;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,x,sum;
int a,b,c,d,e,f,g;
while(1){
sum=0;
scanf("%d %d",&n,&x);
if(n==0&&x==0)
break;
for(a=1;a<=n;a++){
for(b=a+1;b<=n;b++){
for(c=b+1;c<=n;c++){
if(a+b+c==x)
sum++;
}
}
}
printf("%d\n",sum);
}
return 0;
} 

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := IOInitialize()
	N := Int(s)
	strs := scanstrings(s, N)
	m := map[string]int{}
	nextStr := ""
	for i, str := range strs {
		_strs := strings.Split(str, "")
		if i > 0 {
			if _strs[0] != nextStr {
				fmt.Println("No")
				return
			}
		}
		if _, ok := m[str]; ok {
			fmt.Println("No")
			return
		}
		m[str] = 1
		nextStr = _strs[len(_strs)-1]
	}
	fmt.Println("Yes")
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main() {
	int W,H;cin>>W>>H;
	vector<vector<int>>field(H+2,vector<int>(W+2,1));
	int gx,gy;
	for (int i = 0; i < H; ++i) {
		string st;cin>>st;
		for (int j = 0; j < W; ++j) {
			if (st[j] == '#') {
				
			}
			else if (st[j] == '.') {
				field[i+1][j+1]=0;
			}
			else if (st[j] == 't') {
				field[i+1][j+1]=0;
				gx=j+1;
				gy=i+1;
			}
		}
	}

	int start_id=W+3;
	int goal_id(gy*(W+2)+gx);
	UnionFind uf((H+2)*(W+2));
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,1,0,-1 };
	for (int y = 1; y <= H; ++y) {
		for (int x = 1; x <= W; ++x) {
			const int now_y=y;
			const int now_x=x;
			const int now_id=((W+2)*now_y+now_x);
			for (int way = 0; way < 4; ++way) {
				const int next_y=now_y+dy[way];
				const int next_x=now_x+dx[way];
				const int next_id=((W+2)*next_y+next_x);

				if (!field[next_y][next_x] && !field[now_y][now_x]) {
					uf.unionSet(now_id,next_id);
				}
			}
		}
	}

	int ans=-1;
	{
		if (uf.root(start_id) == uf.root(goal_id)) {
			ans=0;
		}
		else {
			int N; cin >> N;
			for (int i = 0; i < N; ++i) {
				int x, y; cin >> x >> y;
				int now_y(y + 1);
				int now_x(x + 1);
				const int now_id = ((W + 2)*now_y + now_x);
				field[now_y][now_x] = 0;
				for (int way = 0; way < 4; ++way) {
					const int next_y = now_y + dy[way];
					const int next_x = now_x + dx[way];
					const int next_id = ((W + 2)*next_y + next_x);

					if (!field[next_y][next_x] && !field[now_y][now_x]) {
						uf.unionSet(next_id,now_id);
					}
				}
				if (uf.root(start_id) == uf.root(goal_id)) {
					ans=i+1;
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10840
#include <cstdio>
#include <algorithm>
using namespace std;

int N,M,Q;
char A[2001][2001];
int sm[2000][2000];
int smLeft[2000][2000];
int smUp[2000][2000];

void psum(int v[2000][2000])
{
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)
		{
			if(i) v[i][j] += v[i-1][j];
			if(j) v[i][j] += v[i][j-1];
			if(i && j) v[i][j] -= v[i-1][j-1];
		}
}

int main()
{
	scanf("%d %d %d",&N,&M,&Q);
	for(int i=0;i<N;i++)
	{
		scanf("%s",A[i]);
		for(int j=0;j<M;j++)
		{
			if(A[i][j]=='1')
			{
				sm[i][j]++;
				if(i && A[i-1][j]=='1') smUp[i][j]++;
				if(j && A[i][j-1]=='1') smLeft[i][j]++;
			}
		}
	}
	psum(sm);
	psum(smLeft);
	psum(smUp);
	int x1,y1,x2,y2;
	for(int i=0;i<Q;i++)
	{
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		x1--,y1--,x2--,y2--;
		int ans = sm[x2][y2] - smUp[x2][y2] - smLeft[x2][y2];
		if(x1) ans -= (sm[x1-1][y2] - smUp[x1][y2] - smLeft[x1-1][y2]);
		if(y1) ans -= (sm[x2][y1-1] - smUp[x2][y1-1] - smLeft[x2][y1]);
		if(x1 && y1) ans += (sm[x1-1][y1-1] - smUp[x1][y1-1] - smLeft[x1-1][y1]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 52480
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
 
int f(int x) {
	if(x == 1) return 1;
	return 1 + 2 * f(x / 2);
}
 
int32_t main() {

	int x; cin >> x;
	cout << f(x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> lamps(n);
    vector<int> lamplog(n+1,0);
    for(int i = 0;i<n;i++){
        cin >> lamps[i];
    }
    for(int ki =0; ki<k;ki++){
        vector<int> lamplog(n+1,0);
        for(int i = 0;i<n;i++){
            lamplog[max(0,i-lamps[i])]++;//start+
            lamplog[min(i+lamps[i]+1,n)]--;//end+1-
        }
        for(int i = 0;i<n;++i){
            lamplog[i+1] += lamplog[i];
            // cout << lamplog[i] <<endl; 
        }
        lamplog.pop_back();
        if(lamps == lamplog)break;
        lamps = lamplog;
    }
    for(int i= 0;i<n;i++){
        cout << lamps[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
 ll a,b,c,d;
 cin >> a >> b >> c >> d;
 if(a > 0){
   if(d < 0){
     cout << ll(a*d) << endl;}
   else{
     cout << ll(b*d) << endl;
   }
 }
 else if(b < 0){
   if(c > 0){
     cout << ll(b*c) << endl;
   }
   else{
     cout << ll(a*c) << endl;
   }
 }
  else{
    if(c >= 0){
      cout << ll(b*d) << endl;
    }
    else if(d <= 0){
      cout << ll(a*c) << endl;
    }
    else{
      cout << ll(max(a*c,b*d)) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
const int MOD = 1000000007;
const ll INF = 1e18;
using namespace std;
ull i,j,k;
ull N,K;
ull cnt;
ull ans;
inline void solve(){
  INPUT2(N,K);
  FOR(i,1,N+1){
    if(i%K==0)cnt++;
  }
  ans+=cnt*cnt*cnt;
  if(K%2==0){
    cnt=0;
    FOR(i,1,N+1)if(i%K==K/2)cnt++;
    ans+=cnt*cnt*cnt;
  }
  OUTPUT(ans);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll M = 1e9+7;
const ll INF = 1e9+7;

ll n, ans;
ll cnt[100];

int main() {
  cin >> n;

  for (ll i = 0; i < n; i++) {
    ll a;
    cin >> a;
    for (ll j = 0; j < 64; ++j) {
      if ((a >> j) & 1) cnt[j]++;
    }
  }
  
  for (ll i = 0; i < 64; i++) {
    ans += cnt[i] * (n-cnt[i]) % M * ((1LL << i) % M);
    ans %= M;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
//DPによる解法
string divide[]={"dream","dreamer","erase","eraser"};
//DFS
bool DFS(int n){
    if(n==s.size()) return true;
    for(string i:divide){
        if(n+i.size()<=s.size() && s.substr(n,i.size())==i){
            if(DFS(n+i.size())) return true;//if内で次の単語が当てはまらなければスルー
        }
    }return false;
}
int main(){//切れるタイミングを確定させるために反転しておく
    cin >> s;
    cout << (DFS(0)? "YES" : "NO") << endl;
}


Measured memory_bytes: 2688
N, M, X, Y = map(int, input().split());
xList = list(map(int, input().split()));
yList = list(map(int, input().split()));

# ソートする
xList.sort();
yList.sort();

if xList[-1] < yList[0] and xList[-1] > X and xList[-1] + 1 <= Y:
  print("No War");
else:
  print("War");

Measured memory_bytes: 3060