akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int now = 0, cnt = 0;
    int ans[110][110] = {};
    rep(i, h)
    {
        if (i % 2 == 0)
        {
            rep(j, w)
            {
                ans[i][j] = now + 1;
                cnt++;
                if (cnt == a[now])
                {
                    cnt = 0;
                    now++;
                }
            }
        }
        else
        {
            for (int j = w - 1; j >= 0; j--)
            {
                ans[i][j] = now + 1;
                cnt++;
                if (cnt == a[now])
                {
                    cnt = 0;
                    now++;
                }
            }
        }
    }
    rep(i, h)
    {
        rep(j, w) cout << ans[i][j] << " ";
        cout << endl;
    }
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(n, m);

	out((n == m ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int K=105,N=1005;
int k,n;
int a[K];
vector<int>merge(const vector<int>&a,const vector<int>&b)
{
	vector<int>res;
	size_t i=0,j=0;
	while(i<a.size()&&j<b.size())
	{
		if(a[i]<b[j]) res.push_back(a[i]),i++;
		else res.push_back(b[j]),j++;
	}
	while(i<a.size())
		res.push_back(a[i]),i++;
	while(j<b.size())
		res.push_back(b[j]),j++;
	return res;
}
int ans[N],tot;
int b[K];
bool pos[K];
vector<int>add(int len)
{
	for(int i=1;i<=k;i++)
		pos[i]=false,b[i]=a[i];
	vector<int>pre;
	for(int i=tot,j=1;i>=1&&j<=k-len;i--,j++)
		pre.push_back(ans[i]);
	for(int u:pre)         
		pos[u]=true;        
	for(int i=1;i<=k;i++)
		if(!pos[i]) b[i]--;
	for(int i=1;i<=k;i++)
		if(b[i]<0) return {k+1};
	int Min=*min_element(b+1,b+k+1),Max=*max_element(b+1,b+k+1);
	if(Min*2>=Max)
	{
		vector<int>res;
		for(int i=1;i<=k;i++)
			if(!pos[i]) res.push_back(i);
		return res;
	}
	else if(Min*2+1==Max)
	{
		vector<int>x,y;
		for(int i=1;i<=k;i++)
			if(!pos[i]&&b[i]==Max) x.push_back(i);
		for(int i=1;i<=k;i++)
			if(!pos[i]&&b[i]==Min) x.push_back(i);
		for(int i=1;i<=k;i++)
			if(!pos[i]&&b[i]!=Min&&b[i]!=Max) y.push_back(i);
		vector<int>res=merge(x,y);
		pre.insert(pre.end(),res.begin(),res.end());
		int L=0,R=(int)(pre.size())-1;
		for(int i=0;i<pre.size();i++)
		{                  
			if(b[pre[i]]==Max) L=max(L,i);
			if(b[pre[i]]==Min) R=min(R,i);
		}
		if(L<R) return res;
		else return {k+1};
	}
	else return {k+1};
}
void solve()
{
	vector<int>res={k+1};
	for(int len=1;len<=k&&tot+len<=n;len++)
	{
		int d=k-len;
		if(tot-d>=0)
		{
			vector<int>now=add(len);
			res=min(res,now);
		}
	}
	for(int u:res)
	{
		ans[++tot]=u;
		a[u]--;
		printf("%d ",u);
	}
	return;
}
int main()
{
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
		scanf("%d",&a[i]),n+=a[i];
	int Min=*min_element(a+1,a+k+1),Max=*max_element(a+1,a+k+1);
	if(2*Min+1<=Max)
	{
		printf("-1");
		return 0;
	}
	while(tot<n)
		solve();
	return 0;
}

Measured memory_bytes: 3764
n = int(input())

a = list(map(int,input().split()))

dic = {}
lis = []
for i in a:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1
        lis.append(i)

lis.sort()
lis.reverse()

ans = 0
n -= 1
ma = lis[0]
for i in lis:
    if i == ma:
        k = 2 * dic[i] - 1
    else:
        k = 2 * dic[i]
    if n - k >= 0:
        ans += i * k
    else:
        ans += i * n
        break
    n -= k

print(ans)

Measured memory_bytes: 35208
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)
function bsearchg(a,x);l,r=1,length(a);while l<=r;m=r-div(r-l,2);if a[m]>x;r=m-1;else;l=m+1;end;end;return(l-1);end

function main()
	n = readline() |> parseInt
	a = Array{Int}(n)
	for i in 1:n
		a[i] = readline() |> parseInt
	end
	k = 1
	ma = a[n]
	stack=Int[a[n]]
	for i in 1:n-1
		x = bsearchg(stack,a[n-i])
		if x<length(stack)
			stack[x+1] = a[n-i]
		else
			push!(stack,a[n-i])
		end
	end
	println(length(stack))
end

main()

Measured memory_bytes: 123952
import math
from decimal import Decimal


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = Decimal(max(math.ceil(t / _t), math.ceil(a / _a)))
        t, a = _t * n, _a * n

    print(t + a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(i*j==n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int x[n];
    x[0] = 0;
	for (int i = 0; i < n; i++) {
		x[0] += (int)pow(-1, (double)i) * a[i];
	}
	for (int i = 1; i < n; i++) {
		x[i] = 2 * a[i - 1] - x[i - 1];
	}
	for (int i = 0; i < n; i++) {
		cout << x[i] << endl;
	}

    return 0;
}

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

int main() {
  set<string> s;
  int N;
  cin >> N;
  rep(i,N){
    string S;
    cin >> S;
    s.insert(S);
  }
  cout << s.size() << endl;
  return 0;
}

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

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {

  int N, K, L;
  cin >> N >> K >> L;

  UnionFind p(N + 1), r(N + 1);

  rep(i, K) {
    int a, b;
    cin >> a >> b;
    p.unite(a, b);
  }
  rep(i, L) {
    int a, b;
    cin >> a >> b;
    r.unite(a, b);
  }

  vector<P> ab(N + 1, make_pair(0, 0));
  map<P, int> cnt_m;
  rep(i, N + 1) {
    P k =  make_pair(p.root(i), r.root(i));
    ab[i] = k;

    // 同じペアの数を数え上げる
    decltype(cnt_m)::iterator it = cnt_m.find(k);
    if (it != cnt_m.end()) {
      int cnt = it->second;
      cnt_m.erase(k);
      cnt_m.emplace(k, cnt + 1);
    } else {
      cnt_m.emplace(k, 1);
    }
  }

  repi(i, 1, N + 1) { cout << cnt_m.at(ab[i]) << ' '; }
  cout << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define PUTS(x) cout << (x) << endl;
int main() {
    int h, w, n;
    cin >> h >> w >> n;
    if (h > w) swap(h, w);
    auto q = n / w;
    auto r = n % w;
    if (r > 0) q++;
    PUTS(q);
}


Measured memory_bytes: 256
n = int(input())
ls = map(int, input().lower().split())
even = []
for i in ls: 
  if i % 2 == 0:
    even.append(i)

count = 0
for i in even: 
  if i % 3 == 0 or i % 5 == 0:
    count = count + 1
    
if count == len(even):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> Grid(50, vector<bool>(50, false));
vector<vector<int>> Steps(50, vector<int>(50, -1));
queue<pair<int, int>> Que;
int H, W, wte = 0;

void addToQue(int x, int y, int step)
{
  if (x < 0 || y < 0 || x >= W || y >= H)
    return;
  if (Steps.at(y).at(x) == -1 && Grid.at(y).at(x))
  {
    Que.push(make_pair(x, y));
    Steps.at(y).at(x) = step;
  }
}

int main()
{
  cin >> H >> W;
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      Grid.at(i).at(j) = (c == '.');
      if (c == '.')
        wte++;
    }
  }
  pair<int, int> cur;
  int x, y, step;
  Que.push(make_pair(0, 0));
  Steps.at(0).at(0) = 1;
  while (!Que.empty())
  {
    cur = Que.front();
    x = cur.first;
    y = cur.second;
    Que.pop();
    step = Steps.at(y).at(x);
    addToQue(x + 1, y, step + 1);
    addToQue(x - 1, y, step + 1);
    addToQue(x, y + 1, step + 1);
    addToQue(x, y - 1, step + 1);
  }

  if (Steps.at(H - 1).at(W - 1) == -1)
    cout << -1 << endl;
  else
    cout << wte - Steps.at(H - 1).at(W - 1) << endl;
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int w=0;
	for(int i=0;i<s.size();i++)
		w+=s[i]=='o';
	if(w+15-s.size()>=8)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int I[300];
int cnt[300];
const int M = 256;

void solve(int n) {
    for (int i = 0; i < n; i++) {
        scanf("%d", I + i);
    }
    int S, A, C;
    long double aH = INF;
    REP(s, 16) REP(a, 16) REP(c, 16) {
        memset(cnt, 0, sizeof(cnt));
        int R = s;
        REP(i, n) {
            R = (a * R + c) % M;
            cnt[(I[i] + R) % M]++;
        }
        long double H = 0;
        REP(i, M) {
            if (cnt[i]) H -= (long double)((1. * cnt[i]) / (1. * n)) * logl((1. * cnt[i]) / (1. * n));
        }
        if (H< aH) {
            aH = H;
            tie(S, A, C) = make_tuple(s, a, c);
        }
    }
    printf("%d %d %d\n", S, A, C);
}

int main(void) {
	int a, b, c, x, y, z, n, m, p;
	string s;
	while (cin >> n, n) {
		solve(n);
		//break;
	}
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
ll ans;
ll modpow(ll a,ll n,ll MOD){
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}
int main(void){
    cin>>n;
    ans=(modpow(10,n,MOD)-modpow(9,n,MOD)-modpow(9,n,MOD)+modpow(8,n,MOD))%MOD;
    if(ans<0) ans+=MOD;
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 3596
//TO CHANGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define L first
#define R second
#define mp make_pair
#define pb push_back
typedef long long ll;

const int maxn=1e5+10;
int n, a[maxn], aa[maxn], ans;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i], aa[i]=a[i];
    sort(aa, aa+n);
    for(int i=0; i<n; i++) a[i]=lower_bound(aa,aa+n,a[i])-aa;
    for(int i=0; i<n; i+=2) ans+=a[i]%2;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	ll a, b, c, d, n;
	cin >> a >> b >> c >> d;
	cin >> n;
	b = min(b, a * 2);
	c = min(c, b * 2);
	d = min(d, 2 * c);
	cout << n / 2 * d + (n % 2) * c;
	return 0;
}



Measured memory_bytes: 768
#include<stdio.h>

int main(void)
{
	int n, i, j, r, c,gyouretu[101][101];

	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			scanf("%d", &gyouretu[i][j]);
		}
	}

	for (i = 0; i < r; i++)
	{
		gyouretu[i][c] = 0;

		for (j = 0; j < c; j++)
		{
			printf("%d ", gyouretu[i][j]);
			gyouretu[i][c] = gyouretu[i][c] + gyouretu[i][j];
		}
		printf("%d\n", gyouretu[i][c]);
	}

	for (j = 0; j < c; j++)
	{
		gyouretu[r][j] = 0;

		for (i = 0; i < r; i++)
		{
			gyouretu[r][j] = gyouretu[r][j] + gyouretu[i][j];
		}
		printf("%d ", gyouretu[r][j]);
	}

	gyouretu[r][c] = 0;

	for (i = 0; i < r;i++)
	{
		gyouretu[r][c] = gyouretu[r][c] + gyouretu[i][c];
	}
	printf("%d\n", gyouretu[r][c]);

	return 0;
}


Measured memory_bytes: 2112
using System;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
           int a, b;
           string[] str = Console.ReadLine().Split(' ');
           a = int.Parse(str[0]);
           b = int.Parse(str[1]);
           Console.WriteLine(a*b + " " + 2*(a+b));
           
        }
    }
}


Measured memory_bytes: 15960
n = int(input())
a = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
total = 0
for i in range(len(a)):
    total += a[i]
    if i % 2 == 0:
        if total >= 0:
            cnt1 += 1 + total
            total -= 1 + total
    else:
        if total <= 0:
            cnt1 += 1 - total
            total += 1 - total
total = 0
for i in range(len(a)):
    total += a[i]
    if i % 2 != 0:
        if total >= 0:
            cnt2 += 1 + total
            total -= 1 + total
    else:
        if total <= 0:
            cnt2 += 1 - total
            total += 1 - total
print(min(cnt1, cnt2))

Measured memory_bytes: 14648
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#alist.sort()
#print(alist)

def calc_leq_neg(m):
  ret=0
  j=0
  for i in range(len(alist_neg)):
    while j<len(alist_pos):
      if alist_neg[i]*alist_pos[j]<=m:
        ret+=len(alist_pos)-j
        break
      else:
        j+=1
  return ret

def calc_leq_pos(m):
  ret=0
  j=0
  alist_neg2=alist_neg[::-1]
  for i in range(len(alist_neg)):
    while j<len(alist_neg):
      if alist_neg[i]*alist_neg2[j]<=m:
        ret+=len(alist_neg)-j
        if alist_neg[i]<=alist_neg2[j]:
          ret-=1
        break
      else:
        j+=1
        
  j=0
  alist_pos2=alist_pos[::-1]
  for i in range(len(alist_pos)):
    while j<len(alist_pos):
      if alist_pos[i]*alist_pos2[j]<=m:
        ret+=len(alist_pos)-j
        if alist_pos[i]<=alist_pos2[j]:
          ret-=1
        break
      else:
        j+=1

  return ret//2

alist_neg,alist_pos=[],[]
num_neg,num_zero,num_pos=0,0,0
for a in alist:
  if a<0:
    num_neg+=1
    alist_neg.append(a)
  elif a>0:
    num_pos+=1
    alist_pos.append(a)
  else:
    num_zero+=1
alist_neg.sort()
alist_pos.sort()
    
num_neg_prod=num_neg*num_pos
num_pos_prod=((num_pos*(num_pos-1))//2)+((num_neg*(num_neg-1))//2)
num_zero_prod=(N*(N-1))//2-num_neg_prod-num_pos_prod
#print(num_neg_prod,num_zero_prod,num_pos_prod)

if K<=num_neg_prod:
  #neg
  #print(alist_neg)
  #print(alist_pos)
  l,r=alist_neg[0]*alist_pos[-1],-1
  while l<=r:
    mid=(l+r)//2
    k1=calc_leq_neg(mid-1)
    k2=calc_leq_neg(mid)
    #print(mid,k1,k2)
    if k1<K<=k2:
      print(mid)
      break
    elif k1>=K:
      r=mid-1
    else:
      l=mid+1  
elif K<=num_neg_prod+num_zero_prod:
  print(0)
else:
  #pos
  K-=num_neg_prod+num_zero_prod
  for i in range(len(alist_neg)):
    alist_neg[i]*=-1
  alist_neg.sort()  
  #print(alist_neg)
  #print(alist_pos)
  l,r=float("inf"),0
  if len(alist_neg)>=2:
    l=alist_neg[0]*alist_neg[1]
    r=alist_neg[-2]*alist_neg[-1]
  if len(alist_pos)>=2:
    l=min(l,alist_pos[0]*alist_pos[1])
    r=max(r,alist_pos[-2]*alist_pos[-1])
  #print(K,l,r)
  while l<=r:
    mid=(l+r)//2
    k1=calc_leq_pos(mid-1)
    k2=calc_leq_pos(mid)
    #print(mid,k1,k2)
    if k1<K<=k2:
      print(mid)
      break
    elif k1>=K:
      r=mid-1
    else:
      l=mid+1

Measured memory_bytes: 158316
/* code by AbhiTaker
         ____
        /    \
       /  __  \              _______      __       _   _    _____    _____
      /  /  \  \            |__   __|    /  \     | | / /  |  ___|  |  _  \
     /  /____\  \     ___      | |      / /\ \    | |/ /   | |__    | |_)  )
    /  /______\  \   |___|     | |     / /__\ \   |   /    |  __|   |    _/
   /  /        \  \            | |    / /----\ \  | |\ \   | |___   | |\ \
  /__/          \__\           |_|   /_/      \_\ |_| \_\  |_____|  |_| \_\
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll dp[N],val[N];

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   ll n,k;
   cin>>n>>k;
   for(ll i=1; i<=n; i++) {
        cin>>val[i];
        if(i>1)
            dp[i] = inf;
        for(ll j=1; j<=k; j++) {
            if(i-j == 0)
                break;
            dp[i] = min(dp[i], dp[i-j] + abs(val[i]-val[i-j]));
        }
   }

   cout<<dp[n]<<"\n";
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int>P(N),Q(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
  }
  vector<int>a(N);
  for(int i=0;i<N;i++){
    a.at(i)=i+1;
  }
  map<vector<int>,int>mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  cout<<abs(mp[P]-mp[Q])<< endl;
}

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


int main() {
  int N,X,Y;
  cin>>N>>X>>Y;
  X--,Y--;
  vector<vector<int>> G(N);
  vector<int> p(N);
  G.at(X).push_back(Y);
  G.at(Y).push_back(X);
  for(int i=1;i<N;i++){
    G.at(i).push_back(i-1);
    G.at(i-1).push_back(i);
  }
  for(int i=0;i<N;i++){
    vector<int> r(N,-1);
    queue<int> q;
    q.push(i);
    r.at(i)=0;
    while(!q.empty()){
      int a=q.front();
      q.pop();
      for(int x:G.at(a)){
        if(r.at(x)==-1){
          r.at(x)=1+r.at(a);
          q.push(x);
          if(x>i){
            p.at(r.at(x))++;
          }
        }
      }
    }
  }
  for(int i=1;i<N;i++){
    cout<<p.at(i)<<endl;
  }
        
}

Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <map>

using namespace std;

int main()
{
    // 整数の入力
    long long N,ai,i;
    long long start = -1;
    long long before = -1;
    bool isContinue = false;
    long long minTime = 0;
    cin >> N;
    for (i= 1;i<=N;i++){
        cin >> ai;
        if (i == ai){
            if (before != i-1){
                minTime += 1;
                before = i;
            }else{
                before = -1;
            }
        }
    }
    cout << minTime << endl;
    return 0;
}

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

int main(){
    ll n,d;
    ll cnt=0;
    cin >> n >> d;
    for(int i=0; i<n; i++){
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
// AOJ 2006
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  string input;
  string trm = "cfilov";
  while (cin >> input) {
    char c = '\0', current = '\0';
    for (char btn : input) {
      if (c == '\0') {
        if (btn == '1') {
          c = '.';
        } else if (btn == '2') {
          c = 'a';
        } else if (btn == '3') {
          c = 'd';
        } else if (btn == '4') {
          c = 'g';
        } else if (btn == '5') {
          c = 'j';
        } else if (btn == '6') {
          c = 'm';
        } else if (btn == '7') {
          c = 'p';
        } else if (btn == '8') {
          c = 't';
        } else if (btn == '9') {
          c = 'w';
        }
        current = btn;
      } else if (btn == '0') {
        cout << c;
        c = current = '\0';
      } else {
        if (btn != current) {
      //    cout << "guwaa!" << endl;
          goto END;
        }
        if (c == 's' or c == 'z') {
          c -= 3;
        } else if (find(trm.begin(), trm.end(), c) != trm.end()) {
          c -= 2;
        } else if (c == '.') {
          c = ',';
        } else if (c == ',') {
          c = '!';
        } else if (c == '!') {
          c = '?';
        } else if (c == '?') {
          c = ' ';
        } else if (c == ' ') {
          c = '.';
        } else {
          c++;
        }
      }
    }
    cout << endl;
END:
    ;
  }
}

Measured memory_bytes: 1192
li=list(input())
li.sort()
if len(li)%2:
    print("No")
    exit()
while True:   
    if len(li)==0:
        print("Yes")
        break
    elif li[0]==li[1]:
        li.pop(0)
        li.pop(0)
    else:
        print("No")
        break

Measured memory_bytes: 3060
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int H = sc.nextInt();
    int W = sc.nextInt();
    String[] C = new String[H];

    for (int i = 0; i < H; i++) {
      C[i] = sc.next();
    }

    sc.close();

    for (int i = 0; i < H; i++) {
      System.out.println(C[i]);
      System.out.println(C[i]);
    }

  }

}

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


int main() {

    int n, k, p{ 0 };
    cin >> n >> k;
    vector<int>price(n);
    for (int i{ 0 }; i < n; i++) {
        cin >> price[i];
    }

    sort(price.begin(), price.end());
    for (int i{ 0 }; i < k; i++) {
        p += price[i];
    }

    cout << p;

    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  long long int T1, T2, A1, A2, B1, B2, tmp;
  scanf("%lld%lld", &T1, &T2);
  scanf("%lld%lld", &A1, &A2);
  scanf("%lld%lld", &B1, &B2);

  long long int Dt1=0, Dt2=0, ans=0;
  Dt1 = A1*T1 - B1*T1;
  Dt2 = Dt1 + A2*T2 - B2*T2;

  // do not meet
  if((Dt1>0 && Dt2 > 0) || (Dt1 < 0 && Dt2<0)){
    std::cerr << "Answer: do not meet" << std::endl;
    std::cout << 0 << std::endl;
  }
  // meet infinite times
  else if(Dt2 == 0){
    std::cerr << "Answer: meet infinite times" << std::endl;
    std::cout << "infinity";
  }
  // meet finite times
  else{
    Dt1 = std::abs(Dt1);
    Dt2 = std::abs(Dt2);

    tmp = Dt1/Dt2;
    if((Dt1%Dt2) == 0){
      ans = 2*tmp;
    }
    else{
      ans = 2*tmp+1;
    }

    std::cerr << "Answer: meet finite times" << std::endl;
    std::cout << ans << std::endl;
  }

  return 0;
  
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  val Array(n, time) = readLine.split(" ").map(_.toInt)
  val t = readLine.split(" ").map(_.toInt)

  var nextT = 0
  var sum = 0
  for(i <- 0 until n) {
    val ti = t(i)
    if(nextT <= ti) {
      sum += time
    } else {
      sum += ti + time - nextT
    }
    nextT = ti + time
  }

  println(sum)

}

Measured memory_bytes: 52860
using System;

namespace SolutionB
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            String[] inputs = s.Split();
            int n = int.Parse(inputs[0]);
            int l = int.Parse(inputs[1]);

            int res = 0;
            for (int i = 0; i < n; i++)
            {
                if (l > 0)
                {
                    // 味が全て正の場合、最初の要素を除外
                    if (i == 0) continue;
                } 
                else if (l < 0 && n + l <= 0)
                {
                    // 味が全て負の場合、最後の要素を除外
                    if (i == n - 1) continue;
                }
                else
                {
                    // 味が負から正に変わる場合、0になる要素を除外するが、足しても合計は変わらない
                }
                res += l + i;
            }
            Console.WriteLine($"{res}");
        }
    }
}


Measured memory_bytes: 13140
n,a,b=map(int,input().split())
mod = 10**9 + 7
N = 10**6 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[mod % i] * (mod - int(mod / i)) % mod]
  fac += [(fac[i-1] * i) % mod]
  finv += [(finv[i-1] * inv[i]) % mod]
t=(pow(2,n,mod)-1+mod)%mod
sa1,sa2,sb1,sb2=1,1,1,1
for i in range(1,a+1):
  sa1*=(n-i+1)
  sa1%=mod
sa=sa1*finv[a]%mod
for i in range(1,b+1):
  sb1*=(n-i+1)
  sb1%=mod
sb=(sb1*finv[b])%mod
print((t-sa-sb+mod)%mod)


Measured memory_bytes: 122068
#include <iostream>

int main(int argc, char* argv[]){
  std::string N;
  
  std::cin >> N;
  if(N[0] == N[2]){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
using namespace std;

int main() {
  int N; cin >>N;
  vector<int> a(N);
  rep(i,0,N) cin >>a[i];
  int ans=0;
  rep(i,0,N) {
    if (a[a[i]-1]==i+1) ans+=1;
  }
  cout <<ans/2 <<endl;
  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int N,M;
int a;
int ma[10] = { -1, 2,5,5,4,5,6,3,7,6 };
int ok[10] = {};
int number[10] = {};
vector<pair<int,int> > s;
stack<int> ans;
stack<int> preans;

bool serached = false;
void dfs( int dig ){
    if( serached = dig == N ) return;
    if( dig > N ) {
        return;
    }
    for( pair<int,int> p : s ){
        ans.push( p.second );
        dfs( dig + p.first );
        if( serached ) return;
        ans.pop();
    }
}

int main() {


    Scd2(N,M);
    Rep(i,M){
        Scd(a);
        ok[a] = true;
    }

    Rep(i,10){
        if( ok[i] ){
            ok[number[ma[i]]] = false;
            number[ma[i]] = i;
        }
    }
    Rep(i,10){
        if(ok[i]){
            s.push_back( make_pair(ma[i],number[ma[i]] ));
        }
    }
    sort(s.begin(),s.end());
    bool hit[10] = {};
    auto it = s.begin();
    Rep( i,s.size() ){
        pair<int,int> k = s[i];
        hit[k.first] = true;
        if( k.second == 9 && hit[5] ){
            if( ++it == s.end() ) break;
            s.erase( ++it );
        }
        it++;
    }
    dfs(0);
    vector<int> ans2;
    while( !ans.empty() ){
        ans2.push_back(ans.top());
        ans.pop();
    }
    sort(ans2.begin(), ans2.end() );
    reverse(ans2.begin(), ans2.end() );
    for( int k : ans2 ){
        printf ("%d", k );
    }

    printf ("\n");


    return 0;
}

// 71111111111111111111111111111111111111111111111111


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

typedef long long ll;
typedef vector<ll> vll;
const ll MOD = 1e9 + 7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1e9;
    int cur = 0;
    vector<int> numE(n);
    vector<int> numW(n);
    int totalE = 0;
    int totalW = 0;
    s.back() == 'E' ? ++totalE : ++totalW;
    for (int i = 1; i < n; ++i) {
        if (s[i - 1] == 'E') {
            numE[i] = numE[i - 1] + 1;
            numW[i] = numW[i - 1];
            ++totalE;
        }
        else if (s[i - 1] == 'W') {
            numW[i] = numW[i - 1] + 1;
            numE[i] = numE[i - 1];
            ++totalW;
        }
    }
    for (int i = 0; i < n; ++i) {
        cur = numW[i] + (totalE - numE[i]);
        if (s[i] == 'E') cur -= 1;
        ans = min(cur, ans);
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 2964
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
struct edge{int to,cost;};

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

int main(){
    int a = 0;
    for(int i=0;i<10;i++){
        int temp;
        cin >> temp;
        a += temp;
    }
    cout << a<< endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main() {
	int x[4], y[4], X, Y;

	scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);
	
	X = x[0] - x[1];
	Y = y[0] - y[1];
	x[2] = x[1] + Y;
	y[2] = y[1] - X;
	x[3] = x[2] + X;
	y[3] = y[2] + Y;

	printf("%d %d %d %d", x[2], y[2], x[3], y[3]);

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(void){
	int x,h;
	double s;
	while(scanf("%d %d",&x,&h)){
		if((x==0)&&(h==0)){
			break;
		}
		s = x * x + x * sqrt(4 * h * h + x * x);
		printf("%f\n",s);
	}
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=1e9+7;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<ll> b;
    map<ll,ll> c;
    ll pos=1,h=0;
    while(c.find(pos)==c.end()){
        c[pos]=h++;
        b.pb(pos);
        pos=a[pos];
    }
    if(k<c[pos]){
        cout<<b[k];
        return 0;
    }
    k-=c[pos];
    vector<ll> d;
    for(ll i=c[pos];i<b.size();i++)
        d.pb(b[i]);
    //for(ll i=0;i<b.size();i++)
    //    cout<<b[i]<<" ";
    ll r=d.size();
    ll p=k%r;
    cout<<d[p];


    return 0;
}


Measured memory_bytes: 19096
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N;
    cin >> N;
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<set<int>> A(26, set<int>());
    rep(i, 26) { A[i].insert(1e9); }
    rep(i, N) {
        int num = s[i] - 'a';
        A[num].insert(i);
    }
    rep(i, q) {
        int a, b;
        cin >> a >> b;
        b--;
        if (a == 1) {
            char c;
            cin >> c;
            if (s[b] != c) {
                int moto = s[b] - 'a';
                A[moto].erase(b);
                s[b] = c;
                A[c - 'a'].insert(b);
            }
        } else {
            int c;
            cin >> c;
            c--;
            ll ans = 0;
            rep(j, 26) {
                if (A[j].empty())
                    continue;
                int n = *A[j].lower_bound(b);
                if (n <= c) {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 27240
n=int(input())
s=[]
for i in range(n):
    s.append( input() )
t=["AC","WA","TLE","RE"]
c=[0,0,0,0]

for i in range(n):
    for j in range(4):
        if s[i]==t[j]:
            c[j]+=1

for j in range(4):
    print(t[j], "x",c[j])


Measured memory_bytes: 16232
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 ;
    int max;
    int min;
    int i;
    long sum=0;
    int list[];
       list = new int[a];
       for(i=0;i<a;i++){
           b = sc.nextInt();
           list[i]=b;
       }
       min=list[0];
       max=list[0];
       for(i=0;i<a;i++){
           
           if(list[i]>max){
               max=list[i];
           }
           if(list[i]<min){
               min=list[i];
           }
           sum+=list[i];
   
       }
       System.out.println(min+" "+max+" "+sum);
   }
 }


Measured memory_bytes: 42388
#include <bits/stdc++.h>
using namespace std;
int main() {
    int s;
    cin >> s;
    int a[100000];
    a[0]=s;
    int ans=0;
    for(int i=0;i<100000;++i) {
        if(a[i]%2==0) {
            a[i+1]=a[i]/2;
        }
        else {
            a[i+1]=3*a[i]+1;
        }
        if(a[i]==4 || a[i]==1 || a[i]==2) {
            ans=i+4;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int N,L; cin >> N >> L;
    int A=0,B=0, ans = 99999,anss = 0;
    REP(i,N){
        A += L+i;
    } 
    REP(i,N){
        B = A-(L+i);
        if(ans > abs(A-B)){
        ans = min(abs(A-B),ans);
        anss = B;
        }
    }


    cout << anss << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,h,m=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>h;
    if(h<m){cout<<"No";return 0;}
    m=max(m,h-1);
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools

#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
ans = (N-1)*(N)//2
print(int(ans))


Measured memory_bytes: 38892
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,dis[1005][1005],vis[1005][1005],a[1000005],dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
void dfs(int x,int y)
{
	int fl=0;
	for(int k=0;k<4;k++)
	{
		int xx=x+dx[k],yy=y+dy[k];
	//	if(xx<=0||xx>n||yy<=0||yy>n) continue;
		if(dis[xx][yy]+vis[x][y]<dis[x][y])
		{
			dis[x][y]=dis[xx][yy]+vis[x][y];
			fl=1;
		}
	}
	if(fl)
	{
		for(int k=0;k<4;k++)
		{
			int xx=x+dx[k],yy=y+dy[k];
			if(xx<=0||xx>n||yy<=0||yy>n) continue;
			dfs(xx,yy);
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			vis[i][j]=1;
			dis[i][j]=min(min(i-1,n-i),min(j-1,n-j))+1;
		}
	for(int i=1;i<=n*n;i++)
		scanf("%d",&a[i]);
	int ans=0;
	for(int i=1;i<=n*n;i++)
	{
		int x=(a[i]-1)/n+1,y=(a[i]-1)%n+1;
		vis[x][y]=0;
		ans+=dis[x][y]-1;
	//	printf("i=%d,a=%d,x=%d,y=%d,dis=%d\n",i,a[i],x,y,dis[x][y]);
		dfs(x,y);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 18168
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const string YES = "Yes";
const string NO = "No";

bool f(string s){
    string t=s;
    reverse(all(t));
    return s==t;
}
void solve(std::string S){
    ll sz=S.size();
    bool ok=f(S);
    ok&=f(S.substr(0,sz/2));
    ok&=f(S.substr(sz/2+1,sz/2));
    cout<<(ok?YES:NO)<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String a = n();
		String b = n();
		int ab = Integer.parseInt(a + b);
		for (int i = 1; i <= 1000; i++) {
			if (i * i == ab) {
				out(Y);
				return;
			}
		}
		out(N);
	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	ll A,B,C,ans;
        in(A);
        in(B);
        in(C);

        ans = min(B/A,C);
        outn(ans);

	return 0;
}


Measured memory_bytes: 256
var lines = [];
var result = 0;
var N, V, C;
var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    N = Number(lines[0]);
    V = lines[1].split(" ").map(value => Number(value));
    C = lines[2].split(" ").map(value => Number(value));

    dfs(0, []);
    console.log(result);
});

function dfs(n, comb) {
    if (n === N) { calc(comb) }
    else {
        for (var i = 0; i < 2; i++) {
            comb[n] = i;
            dfs(n + 1, comb);
        }
    }
    return (0)
}

function calc(comb) {
    var X = 0; var Y = 0;
    for (var i = 0; i < comb.length; i++) {
        if (comb[i] === 1) { X += V[i]; Y += C[i] }
    }
    result = Math.max(result, X - Y);
}

Measured memory_bytes: 11596
public class Hello{
    public static void Main(){

        var line = System.Console.ReadLine().Trim().Split(' ');
        int a =int.Parse(line[0]);
        int b =int.Parse(line[1]);
        int c =int.Parse(line[2]);
      
      if(a==b&& a==c)
        
        System.Console.WriteLine("Yes");
      else
        
        System.Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
#!/usr/bin/env python


def read():
    return input()


def work(N):
    divisor2cnt = {}
    for i in range(1, N + 1):
        num = i
        divisor = 2
        
        while divisor * divisor <= num:
            while num % divisor == 0:
                num /= divisor
                if divisor not in divisor2cnt:
                    divisor2cnt[divisor] = 1
                else:
                    divisor2cnt[divisor] = divisor2cnt[divisor] + 1
            divisor += 1
        
        if num != 1:
            if num not in divisor2cnt:
                divisor2cnt[num] = 1
            else:
                divisor2cnt[num] = divisor2cnt[num] + 1

    ans = 1
    for (divisor, cnt) in divisor2cnt.items():
        ans = ans * (cnt + 1) % 1000000007
    print ans


if __name__ == "__main__":
    work(read())


Measured memory_bytes: 2692
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long d = b - a;
    long ans = 0;
    for(long i = 1; i < d; i++) {
      ans += i;
    }
    ans -= a;
    System.out.println(ans);
  }
}


Measured memory_bytes: 25172
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
total = sum(b)
for i in range(n-1):
    if a[i] + 1 == a[i+1]:
        total += c[a[i] - 1]
print(total)

Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int x=scan.nextInt();
boolean a=true;
for(int i=1; i<x+1; i++){
   if(i%3==0){
      System.out.print(" "+i);
      a=false;
   }
   int n=i; 
   while(a){
      if(n%10==3){
         System.out.print(" "+i);
         a=false;
      }else if(n>10){
         n /=10;
      }else  a=false;
   }
   a=true;
}
System.out.println();
}
} 

Measured memory_bytes: 29036
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef long long ll;
#define sz(a) int((a).size()) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define rep(i, n) for(int i = 0; i < n; ++i) 
#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) 

#define TRACE(x...) x
#define watch(x) TRACE(cout << #x" = " << x << endl)
#define watcharr(i, x) TRACE(cout << #x" = "); rep(i, sz(x)) cout << x[i] << " "; cout << endl

int main() {
	
	ifstream infile("input.in");
	if(infile.good()) cin.rdbuf(infile.rdbuf());
	
    int N, M;
    cin >> N >> M;

    vector<int> h(N);
    rep(i, N) cin >> h[i];

    int a, b;
    vector<bool> good(N, true);
    rep(i, M) {
        cin >> a >> b;
        if(h[b-1] >= h[a-1]) good[a-1] = false;
        if(h[a-1] >= h[b-1]) good[b-1] = false;
    }

    int ret = count_if(all(good), [] (bool n) {
        return n;
    });

    cout << ret << endl;

	if(infile.good()) infile.close();
	return 0;
	
}



Measured memory_bytes: 3792