akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int n,k;
    cin>>n>>k;
    ll int p[n+1];
    ll int i,ans=INT_MIN;
    for(i=1;i<=n;i++)
        cin>>p[i];
    ll int c[n+1];
    for(i=1;i<=n;i++)
        cin>>c[i];
    for(i=1;i<=n;i++)
    {
       ll int  ind=i;
        ll int q=0,w,start;
        ll int mp[5005]={0},mp1[5005]={0};
        vector<ll int> v;
        while(1)
        {
            //temp.PB(ind);
            mp1[ind]=q++;
           mp[ind]=-1;
           w=p[ind];
           if(mp[w]!=-1)
           {
                ind=w;
                v.PB(c[w]);
           }
           else
           {
                v.PB(c[w]);
                start=mp1[w];
                break;     
           }

        }ll int j,val=0;
        ll int fin;ll int tans=INT_MIN;
        if(k<=v.size())
        {//cout<<"ddj";
    //cout<<v.size()<<endl;
            for(j=0;j<k;j++)
            {
                val+=v[j];//cout<<v[j]<<endl;
                tans=max(val,tans);
            }
            fin=tans;

        }
        else
        {ll int r,t1=0;
           // cout<<start<<endl;
            ll int val=0,t1ans=INT_MIN,t2ans=INT_MIN;
            for(j=0;j<start;j++)
            {
                val+=v[j];
                tans=max(val,tans);
            }
            q=k-(start);
            r=q/(v.size()-start);
            for(j=start;j<v.size();j++)
            {
                t1+=v[j];
                t1ans=max(t1ans,t1);
            }
            w=q%(v.size()-start);
            ll int t2=0;
            for(j=0;j<w;j++)
            {
                t2+=v[start++];
                t2ans=max(t2,t2ans);
            }
            ll int val1=0,val2=0,val3=0;
            if(tans==INT_MIN)
                tans=0;
            if(t1ans==INT_MIN)
                t1ans=0;
            if(t2ans==INT_MIN)
                t2ans=0;
            //cout<<t1<<endl;
            //cout<<tans<<" "<<t1ans<<" "<<t2ans<<endl;
            val1=tans+t1ans;
            val2=tans+t1ans+(r-1)*t1;
            val3=tans+r*t1+t2ans;

           //cout<<val1<<" "<<val2<<" "<<val3<<endl;
            fin=max(val1,max(val2,val3));
          //  cout<<val<<" "<<i<<endl;

        }
        ans=max(fin,ans);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fr(i,j,p)   for(int i=j; i<p ;i++)
#define frr(i,j,p)  for(int i=j; i>=p ;i--)
#define PI          3.14159265358979323846
#define pb          push_back
#define mkp         make_pair
#define print(m)    std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define ff          first
#define ss          second
#define mod         1000000007


int main() {
    lli n;  cin>>n;
    lli h[n+1]={0};
    fr(i,1,n+1) cin>>h[i];
    lli dp[n+1];
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    fr(i,3,n+1) {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
    
    return 0;
}



Measured memory_bytes: 5140
#include <stdio.h>

int main(){
    int N, A, tmp = 0, count = 0;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &A);
        tmp = (A | tmp);
    }
    while((tmp & 1)== 0){
        tmp = tmp >> 1;
        count++;
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
while True:
    try:
        a,b,c,d,e,f=map(int,input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(c-a*x)/b
        if x==-0:
            x=0
        if y==-0:
            y=0
        print(f'{x:.3f} {y:.3f}')
    except EOFError:
        break


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

int main()
{
	int H, W;
	
	while (cin >> H >> W) {
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			if (i == 0 || i==H-1) {
				for (int j = 0; j < W; j++) {
					cout << "#";
				}
				cout << endl;
			}
			else {
				for (int j = 0; j < W; j++) {
					if (j == 0) {
						cout << "#";
					}
					else if (j == W - 1) {
						cout << "#" << endl;
					}
					else {
						cout << ".";
					}
				}
			}

		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long
#define br cout << endl ;
#define all(x) (x).begin() ,(x).end()
#define rall(x) (x).rbegin() ,(x).rend()
#define pb push_back
const int MOD = 1000* 1000 * 1000 + 7;
const int MAXN = 1000*1000 + 10 ; 
using namespace std;

int main() {
	int t = 1 ;
	// cin >> t ;
	while(t--){
	ll  n , k ;
	cin >> n >> k ;
	ll x =  abs(( n / k ) * k  - n ) ;
	ll y = abs(((n +k - 1) / k ) * k - n ) ;
	cout << min ( x , y ) ;   
	// cout << x <<" "<<y ; 

	}

	


return 0 ; 
}		



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

int main(){
    int N, ans = 0; cin >> N;
    int p[N];
    for(int i = 0; i < N; ++i) cin >> p[i];
    for(int i = 0; i < N; ++i)
    if(i+1 == p[i]){
        ans++;
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,a[200010];

int main(){
    I(n);
    REP(i,n) I(a[i]);
    
    bool flag = false;
    if (a[0]) flag = true;
    REP(i,n-1){
        if (a[i+1]-a[i] > 1) flag = true;
    }
    if (flag){
        cout << -1 << endl;
        return 0;
    }

    ll ret = 0;
    REP(i,n-1){
        if (a[i+1] - a[i] == 1){
            ret++;
        } else {
            ret += a[i+1];
        }
    }
    cout << ret << endl;
}

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

using namespace std;

int main(){
	int N, l, r, A;

	cin >> N;
	A=0;
  
	for( int i = 0; i < N; i++){

		cin >> l >> r;

		A = A + r - l +1 ; 

		}

	cout << A << endl;

	}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

struct memb{
	int ID;
	double time;
};

memb yosen1[3][8];

memb yosen2[18];

int main(){
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 8; j++){
			cin >> yosen1[i][j].ID >> yosen1[i][j].time;
		}
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 8; j++){
			for(int k = 6; k >= j; k--){
				if(yosen1[i][k].time > yosen1[i][k + 1].time){
					swap(yosen1[i][k], yosen1[i][k + 1]);
				}
			}
		}
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 2; j++){
			cout << yosen1[i][j].ID << " " << yosen1[i][j].time << endl;
		}
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = 2; j < 8; j++){
			yosen2[i * 6 + j - 2] = yosen1[i][j];
		}
	}
	
	for(int j = 0; j < 18; j++){
		for(int k = 16; k >= j; k--){
			if(yosen2[k].time > yosen2[k + 1].time){
				swap(yosen2[k], yosen2[k + 1]);
			}
		}
	}
	
	for(int j = 0; j < 2; j++){
		cout << yosen2[j].ID << " " << yosen2[j].time << endl;
	}
	return 0;
}

Measured memory_bytes: 1292
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	ll N;
	ll M;
	cin>>N>>M;
	vector<set<ll>> g(N+1);
	for (int i = 0;i < M;++i) {
		ll x, y;
		cin>>x>>y;
		g[x].insert(y);
		g[y].insert(x);
	}

	vector<bool> v(N+1);
	function<void(ll, ll&)> dfs = [&] (ll r, ll& d) {
		v[r] = true;
		for (auto neigh : g[r]) {
			if (!v[neigh]) {
				++d;
				dfs(neigh, d);
			}
		}
	};

	ll ans = LLONG_MIN;
	for (int i = 1;i <= N;++i) {
		ll d = 0;
		dfs(i, d);
		ans = max(ans, d);
	}

	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 43764
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector< ll > A(X), B(Y), C(Z);

    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());

    priority_queue< pair< ll, tuple< int, int, int > > > que;
    map< tuple< int, int, int >, bool > used;

    make_tuple(0, 0, 0);
    ll score = A[0] + B[0] + C[0];
    tuple< int, int, int > t = make_tuple(0, 0, 0);
    que.push(make_pair(score, t));
    used[t] = true;
    int cnt = 0;
    for (int i = 0; i < K; i++) {
        pair< ll, tuple< int, int, int > > x = que.top();
        que.pop();

        cout << x.first << endl;
        t = x.second;

        int a = get< 0 >(t);
        int b = get< 1 >(t);
        int c = get< 2 >(t);

        tuple< int, int, int > t1, t2, t3;
        t1 = make_tuple(a + 1, b, c);
        t2 = make_tuple(a, b + 1, c);
        t3 = make_tuple(a, b, c + 1);

        if (!used[t1] && a + 1 < X) {
            used[t1] = true;
            score = A[a + 1] + B[b] + C[c];
            que.push(make_pair(score, t1));
        }
        if (!used[t2] && b + 1 < Y) {
            used[t2] = true;
            score = A[a] + B[b + 1] + C[c];
            que.push(make_pair(score, t2));
        }
        if (!used[t3] && c + 1 < Z) {
            used[t3] = true;
            score = A[a] + B[b] + C[c + 1];
            que.push(make_pair(score, t3));
        }
    }
}

Measured memory_bytes: 896
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
def inli()
  n = gets.to_i
  as = []
  n.times {
    as << gets.split.map(&:to_i)
  }
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

def get_GCD(m, n)
  tmp = [n, m].max
  n = [n, m].min
  m = tmp
  while n != 0
    tmp = m % n
    m = n
    n = tmp
  end
  m
end

x, a = li()
if x < a
  puts 0
else
  puts 10

end


Measured memory_bytes: 1788
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
string S = "";

int main() {
	scanf("%lld", &N);
	// cin >> S;
	for(int i = 1; i <= 9; i++) {
		if(N % i == 0 && (N / i) <= 9 && (N / i) >= 1) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
typedef priority_queue<int, vector<int>, greater<int> > heapq;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int N; cin >> N;
    vector<int> A(N);
    int maxA = 0;
    int subMaxA = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a > maxA) {
            maxA = a;
        } else if (a > subMaxA) {
            subMaxA = a;
        }

        A[i] = a;
    }

    for (int i = 0; i < N; i++) {
        if (A[i] == maxA) cout << subMaxA << endl;
        else cout << maxA << endl;
    }
}


Measured memory_bytes: 2432
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;

std::size_t power(std::size_t num, std::size_t power)
{
    std::size_t result = 1;
    for (std::size_t i = 0; i < power; i++) {
        result *= num;
    }
    return result;
}

int main()
{
    bint L;
    std::cin >> L;
    std::vector<bint> bits;
    bint L_copy = L;
    while (true) {
        if (L_copy <= 1) {
            bits.emplace_back(L_copy);
            break;
        }
        bits.emplace_back(L_copy % 2);
        L_copy = (L_copy - L_copy % 2) / 2;
    }
    std::reverse(bits.begin(), bits.end());

    std::size_t N = bits.size();
    std::vector<std::array<std::size_t, 3>> ans_graphs;
    for (std::size_t i = 1; i < N; i++) {
        std::array<std::size_t, 3> graph1, graph2;
        graph1.at(0) = i;
        graph1.at(1) = i + 1;
        graph1.at(2) = 0;
        graph2.at(0) = i;
        graph2.at(1) = i + 1;
        graph2.at(2) = power(2, i - 1);
        ans_graphs.emplace_back(graph1);
        ans_graphs.emplace_back(graph2);
    }
    L_copy = L;
    for (std::size_t i = N - 1; i > 0; i--) {
        if (L_copy - power(2, N - 1) == 0) {
            break;
        }
        if (L_copy - power(2, N - 1) >= power(2, i - 1)) {
            std::array<std::size_t, 3> graph1;
            graph1.at(0) = i;
            graph1.at(1) = N;
            graph1.at(2) = static_cast<std::size_t>(L_copy - power(2, i - 1));
            L_copy -= power(2, i - 1);
            ans_graphs.emplace_back(graph1);
        }
    }

    std::cout << N << " " << ans_graphs.size() << std::endl;
    for (const auto& graph : ans_graphs) {
        std::cout << graph.at(0) << " " << graph.at(1) << " " << graph.at(2) << std::endl;
    }

    return 0;
}

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

int a, b[100009];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 100009; i++) {
		b[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> a;
		for (int j = a; j < a + 3; j++) {
			b[j]++;
		}
	}
	sort(b, b + 100009);
	cout << b[100008] << endl;
	return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 2005
#define M 998244353
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve()
{
     lli x;
     cin>>x;
     if(x>=30)
     {
          Y
     }
     else
     {
          N
     }
     


}
int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcount(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";




Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

struct Idx { int ia, ib, ic; };
bool used[1003][1003][1003];
deque<Idx> que;
vector<ll> ans;

int main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<ll> a(X), b(Y), c(Z);
	for (int i = 0; i < X; i++) cin >> a[i];
	for (int i = 0; i < Y; i++) cin >> b[i];
	for (int i = 0; i < Z; i++) cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());
	vector<ll> abc;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			for (int k = 0; k < Z; k++) {
				if ((i + 1)*(j + 1)*(k + 1) > K) break;
				abc.push_back(a[i] + b[j] + c[k]);
			}
		}
	}
	sort(abc.rbegin(), abc.rend());
	for (int i = 0; i < K; i++) cout << abc[i] << endl;
	return 0;
}


Measured memory_bytes: 1404
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
import numpy as np

import math
#from math import gcd
from fractions import gcd




def main():
	n,m=map(int,input().split())
	a=list(map(int,input().split()))
	a=np.array(a)
	cnt=-2
	while True:
		cnt+=1
		b=a%2
		bsum=np.sum(b)
		if bsum==n:
			break
		elif 0<bsum<n:
			print(0)
			exit(0)
		a//=2
	
	l=1
	
	for i in a:
		l=l*i//gcd(l, i)
	
	
	base=(2**cnt)*l
	
	ans=math.floor((m)/(2*base)+0.5)
	
	print(ans)
	
	
	


if __name__ == "__main__":
	main()


Measured memory_bytes: 22696
#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 a;
cin>>a;
cout << a + a * a + a * a * a << endl;
}

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

using namespace std;

int dw[4] = {1,0,-1,0};
int dh[4] = {0,1,0,-1};

int main()
{
    int H,W;
    cin >> H >> W;
    vector<vector<char>>G(H,vector<char>(W,'.'));
    int num = 0;
    for(int i = 0; i < H; i++) 
    {
        for(int j = 0; j < W; j++)
        {
            cin >> G[i][j];
            if(G[i][j] == '.') num++;
        }
    }
    vector<vector<int>>dist(H,vector<int>(W,-1));
    queue<pair<int,int>>que;
    que.push(pair(0,0));
    dist[0][0] = 1;
    while(!que.empty())
    {
        int h = que.front().first;
        int w = que.front().second;
        que.pop();
        for(int i = 0; i < 4; i++)
        {
            int nh = h + dh[i];
            int nw = w + dw[i];
            if(nh >= H || nw >= W || nh < 0 || nw < 0) continue;
            if(dist[nh][nw] != -1) continue;
            if(G[nh][nw] == '#') continue;
            dist[nh][nw] = dist[h][w] + 1;
            que.push(pair(nh,nw));
        }
    }
    if(dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << num - dist[H-1][W-1] << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string
		a,b,c;
	cin >> a;// cin >> b; cin >> c;
	a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;

	
}

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

int main()
{
	long  a,b; 

	cin >> a >> b ;

	if( a*b <= 0)
	{
		cout << "Zero";
	}else if(a < 0){
		if( (b-a+1)%2 ==0){
			cout << "Positive" << endl; 
		}else{
			cout << "Negative" << endl;
		}
	}else{
		cout << "Positive" << endl; 
	}

	return 0;
}

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

const double pi = acos(-1);

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta = abs(6*m-30*h-m/2) / 360.0 * (2*pi);
    double ans = a*a + b*b - 2*a*b*cos(theta);
//    cout << sqrt(ans) << endl;
    printf("%.30lf\n", sqrt(ans));
    return 0;
}

Measured memory_bytes: 4216
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

static const int MAX_LENGTH = 1000;

int main(void) {
    int tmpSum;
    char *inputList = new char[MAX_LENGTH];

    while(true) {
        scanf("%s", inputList);
        if(*inputList == '0') break;

        tmpSum = 0;
        for(int i=0; i < strlen(inputList); i++) {
            tmpSum += inputList[i] - '0';
        }

        cout << tmpSum << endl;
    }

    return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int a,b;
  cin >> a >> b;
  int cnt = 0;
  int num = 1;

  while(b > num) {
    num--;
    num += a;
    cnt++;
  }
  
  cout << cnt << endl;

}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
 
show_flg=False
show_flg=True



m,d=LI()
M,D=LI()

ans=1-(m==M)*1
print(ans)


Measured memory_bytes: 39276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, X;
ll S[210];
mint dp[210][100010];

int main() {
  std::cin >> N >> X;

  rep( i, N )
    std::cin >> S[i];

  std::sort( S, S+N );

  rep( j, X+1 )
    dp[0][j] = j;

  rep( i, N ) rep( j, X+1 ) {
    dp[i+1][j] += dp[i][j%S[i]]+dp[i][j]*i;
  }

  std::cout << dp[N][X].x << endl;

  return 0;
}

Measured memory_bytes: 167688
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int count = 0;
  for(int i = 0; i < 3; i ++){
    if(a.at(i) == '1'){
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N,L = map(int,input().split())
ans = 0

if L <= 0 and 0<=L+N-1:     apple = 0
else:
    if abs(L) > abs(L+N-1): apple = L+N-1
    else:   apple = L

for i in range(1,N+1):
    ans += L+i-1

print(int(ans-apple))

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

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

    long int a, b, c, d; cin >> a >> b >> c >> d;

    while (c>0&&b>0)
    {
        c = c - b;
        if (c<=0) {
            cout << "Yes" << "\n";
            return 0;
        }
        
        a = a - d;
        if (a<=0) {
            cout << "No" << "\n";
            return 0;
        }
    }

}

Measured memory_bytes: 3612
#include <iostream>
#include <set>

using namespace std;

int main()
{
  int N;
  std::cin >> N;

  std::set<char> s;

  for (int n=0; n<N; ++n) {
    char S;
    std::cin >> S;
    s.insert(S);
  }
  
  std::cout << (s.size()==3 ? "Three":"Four") << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#ifdef ONLINE_JUDGE
    #undef DBG
#endif
 
#define sz(x) ((int) (x).size())
#define forn(i, n) for (int i = 0; i < n; ++i)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fr first
#define sc second
 
using ll = long long;
 
 
int n;
string s;

bool check(int ln) {
    unordered_map<string, vector<int>> mapik;
    for (int i = 0; i < n; ++i) {
        string cur = "";
        for (int j = i; j < i + ln; ++j) {
            cur += s[j];
        }
        mapik[cur].emplace_back(i);
    }
    for (auto& el : mapik) {
        int x = el.sc[0];
        auto it = lower_bound(all(el.sc), x + sz(el.fr));
        if (it != el.sc.end()) 
            return true;
    }
    return false;
}

 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    cin >> s;
    int l = 0;
    int r = n + 1;
    while (l < r) {
#ifdef DBG
        cout << "l = " << l << endl;
        cout << "r = " << r << endl;
#endif
        int mid = l + (r - l) / 2;
        if (check(mid)) {
            l = mid + 1;
        }
        else {
            r = mid;
        }
    }
    printf("%d\n", max(l - 1, 0));
    return 0;
}


Measured memory_bytes: 39280
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int a, b;
	while (cin >> a >> b) {
		if (b == 1)
			cout << "0" << endl;
		else if (a >= b)
			cout << "1" << endl;
		else {
			int i = 1;
			while (1) {
				if (a + (a - 1)*i >= b)
					break;
				else i++;
			}
			cout << i+1 << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int N,M; cin>>N>>M;
  N-=2; M-=2;
  long int res=0;
  if(N*M<0) res=max(N,M);
  else res=N*M;  
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
N, L = [int(i) for i in input().split()]

min_ = L
max_ = L + N -1

def eat_apple(N, L, max_):
    if max_<0:
        return max_ 
    if L < 0:
        return 0
    return L

print((min_+max_)*(max_-min_+1)//2 - eat_apple(N, L, max_))

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;

  int64_t ans = N/(A+B) * A +  min(N-(N/(A+B))*(A+B), A);
  cout << ans;
}

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

#define int long long int
#define mp make_pair
using namespace std;

int32_t main() {
    int n;
    scanf("%lld", &n);
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    int ans = 0 ;
    for (int i = 0; i < n; ++i) {
        if(s1[i] == s2[i] && s1[i] == s3[i]){
            continue;
        }
        else if(s1[i] != s2[i] && s1[i] != s3[i] && s2[i] != s3[i]){
            ans += 2;
        }
        else{
            ans += 1;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int max;
	int cnt = 0;
	scanf("%d", &max);
	for (int i = 1; i <= max; i++) {
		for (int j = i+1; j <= max; j += 2)
			cnt++;
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

from math import ceil,floor,log
x,y = myinput()

M = ceil( log(y/x,2) ) + 1

count = 0
for i in range(M):
    if x*(2**i)<=y:
        count += 1
print(count)

Measured memory_bytes: 38384
from fractions import gcd
A, B, C, D = map(int, input().split())
CD = C * D // gcd(C, D)

U = B - A + 1
U_c = (B // C) - (A // C) + int(A % C == 0)
U_d = (B // D) - (A // D) + int(A % D == 0)
U_cd = (B // CD) - (A // CD) + int(A % CD == 0)

ans = U - (U_c + U_d - U_cd)
print(ans)

Measured memory_bytes: 64108
from collections import deque
N = int(input())
a = [0]*N
for i in range(N):
    A = int(input())
    a[i] = A
a.sort()
c = a.copy()
c.reverse()
a = deque(a)
b = [0]*(N-1)
for i in range(N-1):
    if i%2==0:
        b[i]=a.pop()
    else:
        b[i]=a.popleft()
 
ans1 = 0
for i in range(N-2):
    ans1 += abs(b[i+1]-b[i])
ans1 += max(abs(a[0]-b[0]),abs(a[0]-b[-1]))
 
 
 
 
c = deque(c)
b = [0]*(N-1)
for i in range(N-1):
    if i%2==0:
        b[i]=c.pop()
    else:
        b[i]=c.popleft()
 
ans2 = 0
for i in range(N-2):
    ans2 += abs(b[i+1]-b[i])
ans2 += max(abs(c[0]-b[0]),abs(c[0]-b[-1]))
 
print(max(ans1,ans2))

Measured memory_bytes: 8872
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 18;

int n, m, k;

void solve(int test)
{
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<pair<int, int>> ans;
  if (a.front() >= 0 && a.back() >= 0) {
    int val = a[0];
    for (int i = 1; i < n - 1; ++i) {
      ans.emplace_back(val, a[i]);
      val -= a[i];
    }
    ans.emplace_back(a.back(), val);
  }
  else if (a.front() <= 0 && a.back() <= 0) {
    reverse(a.begin(), a.end());
    int val = a[0];
    for (int i = 1; i < n; ++i) {
      ans.emplace_back(val, a[i]);
      val -= a[i];
    }
  }
  else {
    int mid;
    for (mid = 0; a[mid] < 0; ++mid);
    int val = a[0];
    for (int i = mid; i < n - 1; ++i) {
      ans.emplace_back(val, a[i]);
      val -= a[i];
    }
    ans.emplace_back(a[n - 1], val);
    val = a[n - 1] - val;
    for (int i = 1; i < mid; ++i) {
      ans.emplace_back(val, a[i]);
      val -= a[i];
    }
  }
  cout << ans.back().first - ans.back().second << '\n';
  for (auto& pr : ans) {
    cout << pr.first << ' ' << pr.second << '\n';
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 3188
w, h, n = map( int, input().split())
l = 0
r = w
d = 0
u = h
for _ in range(n):
    x, y, a = map( int, input().split())
    if a == 1:
        l = max(l,x)
    elif a == 2:
        r = min(r,x)
    elif a == 3:
        d = max(d,y)
    else:
        u = min(u,y)
if r-l <= 0 or u-d <= 0:
    print(0)
else:
    print(max(0,(r-l)*(u-d)))


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

using namespace std;

bool check(int x){
    int a = x%10; x /= 10;
    int b = x%10; x /= 10;
    int c = x%10; x /= 10;
    int d = x%10; x /= 10;
    int e = x%10;
    return (a == e) && (b == d);
}

int main(void){
    int A, B, ans=0;
    cin >> A >> B;
    for(int i=A;i<=B;i++){
        if(check(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int i, n;
    float x1, x2, x3, x4, y1, y2, y3, y4;
    double AB, CD;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%f %f %f %f %f %f %f %f\n", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
        AB = (y2 - y1) / (x2 - x1);
        CD = (y4 - y3) / (x4 - x3);
        if (AB == CD)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

bool done[3000][3000] = {};

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	
	
	int dx = tx - sx, dy = ty - sy;
	int cnt = min(dx - 1, dy - 1);
	if (cnt * 2 >= dx) cnt--;

	string ans = "";
	
	REP(i, dy - cnt) ans += "U";
	REP(i, cnt) ans += "RU";
	REP(i, dx - cnt) ans += "R";
	
	REP(i, dy - cnt) ans += "D";
	REP(i, cnt) ans += "LD";
	REP(i, dx - cnt) ans += "L";
	
	ans += "LU";
	REP(i, dy - cnt) ans += "U";
	REP(i, cnt) ans += "RU";
	REP(i, dx - cnt) ans += "R";
	ans += "RD";

	ans += "RD";
	REP(i, dy - cnt) ans += "D";
	REP(i, cnt) ans += "LD";
	REP(i, dx - cnt) ans += "L";
	ans += "LU";
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
char s[SIZE];
int main(){
    RS(s);
    int n=LEN(s);
    int ll=n/2,rr=n;
    while(ll<rr){
        int mm=(ll+rr+1)/2;
        bool fail=0;
        FOR(i,n-mm+1,mm-1)
            if(s[i]!=s[i-1]){
                fail=1;
                break;
            }
        if(fail)rr=mm-1;
        else ll=mm;
    }
    W(ll);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
using namespace std;

void print_array(int B[], int N){
    for(int i = 0 ; i < N - 1 ; i++){
        cout << B[i] << " ";
    }
    cout << B[N - 1] << endl;   
}


int main(void){
    // Your code here!
    int N;
    int A[100];
    int key = 0;
    int j, k;
    
    cin >> N;
    
    for (int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    

    print_array(A, N);
    for (j = 1 ; j < N; j ++){
        key = A[j];
        k = j - 1;
        while(k >= 0 and A[k] > key){
            A[k + 1] = A [k];
            k--;
        }
        A[k + 1] = key;
        print_array(A, N);
    } 

}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int main(void) {
	
	int n,a,b;
	cin >>n >>a >>b;
	
	int max,min;
	
	if (a>b) {
		max=b;
	} else {
		max=a;
	}
	
	if (a+b>=n) {
		min=a+b-n;
	} else {
		min=0;
	}
	
	cout <<max <<" " <<min <<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static long func(long n, long x){
		if(n==-1){
			return 0;
		}else{
			return n/x + 1L;
		}
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();

		System.out.println(func(b,x)-func(a-1,x));
	}
}

Measured memory_bytes: 9684
// https://atcoder.jp/contests/abc099/tasks/abc099_d

#include "algorithm"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N, C;
  cin >> N >> C;
  VVL ds(C, VL(C));
  VVL cs(N, VL(N));

  // counts[parity][color]: その parity の中の color の数
  VVL counts(3, VL(C));

  rep(i, C) rep(j, C) cin >> ds[i][j];
  rep(i, N) rep(j, N) {
    cin >> cs[i][j];
    cs[i][j]--;
    counts[(i + j) % 3][cs[i][j]]++;
  }

  ll res = 1e18;

  rep(fc, C) rep(sc, C) rep(tc, C) {
    if (fc == sc || sc == tc || tc == fc) continue;
    VL ideal = VL({fc, sc, tc});
    ll _res = 0;

    rep(parity, 3) rep(from_c, C) {
      _res += ds[from_c][ideal[parity]] * counts[parity][from_c];
    }

    chmin(res, _res);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

ll pow(ll a, ll e) {
  ll res = 1;

  while (e > 0) {
    if ((e & 1) == 1) {
      res *= a;
    }

    res *= res;
    e >>= 1;
  }

  return res;
}


Measured memory_bytes: 2304
N,M = gets.strip.split.map(&:to_i)
div=1_000_000_007
div=(10e8+7).to_i

diff = (N-M).abs
if diff>1
  p 0
  exit
end

fanctors = [1]
(1..[N,M].max).to_a.map do|num|
  fanctors[num] = ((fanctors[num-1]*(num+1))%div)
end

result = (fanctors[N-1]*fanctors[M-1])%div
result *= 2 if (N==M)


#p fanctors
p (result%div)



Measured memory_bytes: 4296
#include <iostream>
#include <map>

using namespace std;
using ll = long long;

ll N, P;

map<ll, ll> prime_factor(ll n){
    map<ll, ll> m;
    for(ll i = 2; i * i <= n; ++i){
        while(n % i == 0){
            m[i]++;
            n /= i;
        }
    }

    if(n != 1) m[n]++;
    return m;
}

int main(){
    ll N, P;
    cin >> N >> P;

    auto m = prime_factor(P);

    ll ret = 1;
    for(auto p: m){
        while(p.second >= N){
            p.second -= N;
            ret *= p.first;
        }
    }

    cout << ret << endl;
}


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, x;
    cin >> N >> x;
    vec<ll> a(N);
    REP(i, N){
        cin >> a[i];
    }
    sort(ALL(a));
    ll cnt = 0;
    REP(i, N){
        if(x<a[i]){
            break;
        }
        x-=a[i];
        cnt++;
    }
    if(N==cnt && x!=0){
        cnt--;
    }
    cout << cnt << el;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
long double a,b,x,c,ans;
int main(){
	cin>>a>>b>>x;
	if(a*a*b/2<x)c=2*b-2*x/(a*a),ans=atan(c/a)/pi*180,cout<<fixed<<setprecision(8)<<ans<<endl;
	else c=2*x/a/b,ans=atan(b/c)/pi*180,cout<<fixed<<setprecision(8)<<ans<<endl;
	return 0;
}


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

int main(){
    ll h,w;
    cin>>h>>w;
    string c[h];
    for(ll i=0;i<h;++i){
        cin>>c[i];
        cout<<c[i]<<endl;
        cout<<c[i]<<endl;
    }
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/tdpc/tasks/tdpc_game
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N,K;
int h[100000];

LL ans = 0;
 
void solve(){
	vector<LL> dp(N,INF);
	dp[0] = 0;
	for(int i=0;i<=N-2;i++){
		for(int j=1;j<=K;j++){
			if(i+j<N){
				dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
			}
		}
	}
	ans = dp[N-1];
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> h[i];
 
	solve();
 
	cout << ans << endl;
	return 0;
}

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

int32_t main(){
	int n; cin>>n;
	vector<int> a(n);
	int t = 0;
	for(int i = 0; i <n; i++){
		cin>>a[i];
		t += a[i];
	}
	sort(a.begin(), a.end());
	if(a.back() <  t - a.back()){
		puts("Yes");
	}	
	else puts("No");
}


Measured memory_bytes: 256