akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define MOD 1000000007

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

const int N = 1e5 + 5;

int arr[N];

/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    REP(i, n) cin >> arr[i];
    int f = 0;
    if(n == 1){
        cout << "Yes";
        return 0;
    }
    FORD(i, n - 1, 1){
        if(arr[i] >= arr[i - 1]) continue;
        else {
            if(arr[i] + 1 == arr[i - 1]) arr[i - 1] = arr[i];
            else {
                f = 1;
                break;
            }
        }
    }
    if(f == 1) cout << "No";
    else cout << "Yes";
}



Measured memory_bytes: 640
var i,n:longint;
    a,b:array[1..200000] of longint;
    tmp,k:qword;
procedure sort(l,r:longint);
var i,j,x,y: longint;
begin
  i:=l; j:=r; x:=a[(l + r) >> 1];
  repeat
    while a[i] < x do i:=i + 1;
    while x < a[j] do j:=j - 1;
    if not(i > j) then
      begin
        y:=a[i];
        a[i]:=a[j];
        a[j]:=y;
        y:=b[i];
        b[i]:=b[j];
        b[j]:=y;
        i:=i + 1; j:=j - 1;
      end;
 until i > j;
 if l < j then sort(l,j);
 if i < r then sort(i,r);
end;
begin
  readln(n,k);
  for i:=1 to n do readln(a[i],b[i]);
  sort(1,n);
  for i:=1 to n do 
    begin
      tmp+=b[i];
      if tmp >= k then
        begin
          write(a[i]);
          break;
        end;
    end;
end.

Measured memory_bytes: 896
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
h = LIST()


table = [0] * n
h[0] = h[0] - 1

while(1):
    h_def = h
    for i in range(n-1):
        if h[i]>h[i+1]:
            h[i] = h[i]-1
            table[i] += 1
    for i in range(n):
        if table[i] > 1:
            print("No")
            exit()


    # print(h_def)
    # print(h)
    count = 0
    for i in range(n-1):
        if h[i] <= h[i+1]:
            count += 1
    # print(count)

    if count == n-1:
        print("Yes")
        exit()

        
        # if h[i] > h[i+1]:
        #     flag = True
        

    # if h_def == h:
    #     print("Yes")
    #     exit()
    

#     # elif h[i]
# print(h)
# flag = True    
# for i in range(n-1):
#     if h[i]>h[i+1]:
#         flag = False

# if flag == True:
#     print("Yes")
# else:
#     print("No")


Measured memory_bytes: 16320
#include <stdio.h>

int main(void)
{
	int n, max = 0, scd_max = 0, a[200001];
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if (max < a[i])
			max = a[i];
		else if (scd_max < a[i])
			scd_max = a[i];
	}

	for (i = 0; i < n; i++)
	{
		if (a[i] == max)
			printf("%d\n", scd_max);
		else
			printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 2304
while True:
  a, op, b = input().split() 
  a = int(a)
  b = int(b)
  
  if op == "+":
    print(a+b)
  elif op == "-":
    print(a-b)
  elif op == "*":
    print(a*b)
  elif op == "/":
    print(int(a/b))
  elif op == "?":
    break


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;

pair<int, int> dfs(int i, int p, const vector<vector<int> > &g) {
	pair<int, int> r(0, i);
	for (int j : g[i]) if (j != p) {
		auto p = dfs(j, i, g);
		r = max(r, make_pair(p.first + 1, p.second));
	}
	return r;
}

bool getPath(int i, int t, int p, const vector<vector<int> > &g, vector<int> &path) {
	if (i == t) {
		path.push_back(i);
		return true;
	}
	for (int j : g[i]) if (j != p) {
		if (getPath(j, t, i, g, path)) {
			path.push_back(i);
			return true;
		}
	}
	return false;
}

int main() {
	int n;
	while (~scanf("%d", &n)) {
		vector<vector<int> > g(n);
		for (int i = 0; i < n - 1; ++i) {
			int u, v;
			scanf("%d%d", &u, &v), --u, --v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		vector<int> path;
		{
			int root = dfs(0, -1, g).second;
			int target = dfs(root, -1, g).second;
			getPath(root, target, -1, g, path);
		}
		vector<int> ans;
		for (int d = 0; d < 2; ++d) {
			reverse(path.begin(), path.end());
			vector<pair<int, int>> rank;
			vector<bool> vis(n);
			for (int u : path) vis[u] = true;
			int k = 0;
			for (int u : path) {
				rank.emplace_back(k+1, (int)rank.size());
				for (int v : g[u]) if (!vis[v]) {
					rank.emplace_back(k, (int)rank.size());
				}
				++k;
			}
			if (rank.size() != n) {
				continue;
			}
			sort(rank.begin(), rank.end());
			vector<int> v(n);
			for (int i = 0; i < n; ++i)
				v[i] = rank[i].second + 1;
			if (ans.empty() || ans > v)
				ans = v;
		}
		if (ans.empty()) {
			puts("-1");
			continue;
		}
		for (int i = 0; i < (int)ans.size(); ++i) {
			if (i != 0) putchar(' ');
			printf("%d", ans[i]);
		}
		puts("");
	}
}


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

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    int res = (H*W) - ((h*W) + (H*w)) + (h*w);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    static int mod=1000000007;
    public static void Main() {
        int[]hw=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h=hw[0];
        int w=hw[1];
        String[]grid=new String[h];
        for(int i=0;i<h;i++){
            grid[i]=Console.ReadLine();
        }
        int[,]dp=new int[h,w];
        dp[0,0]=1;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(grid[i][j]=='#')continue;
                if(0<i)Add(ref dp[i,j],dp[i-1,j]);
                if(0<j)Add(ref dp[i,j],dp[i,j-1]);
            }
        }
        Console.WriteLine(dp[h-1,w-1]);
    }
    public static void Add(ref int x, int y){
        x+=y;
        if(mod<=x)x-=mod;
    }
}



Measured memory_bytes: 25180
#include<iostream>
using namespace std;
int main(){
	int n,ans=0,cnt=0;
	cin>>n;
	int a[2][n];
	for(int i=0;i<n;i++){
		cin>>a[0][i];
	}
	for(int i=0;i<n;i++){
			cin>>a[1][i];
	}
	int c=0,j=0,i=0;

	for(c=0;c<n;c++){
		cnt=0;j=0;i=0;
		for(int x=0;x<n;x++){
			//cout<<"cnt="<<cnt<<" a["<<i<<"]["<<j<<"]"<<"="<<a[i][j]<<endl;
			cnt+=a[i][j];
			if(c==j){
				i++;
				//cout<<"cnt="<<cnt<<" a["<<i<<"]["<<j<<"]"<<"="<<a[i][j]<<endl;
				cnt+=a[i][j];
			}
			j++;
		}
		ans=max(ans,cnt);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
const int N=1e5+5;
int sum[N];
int main() {
    int n,k,q;
    scanf("%d%d%d",&n,&k,&q);
    sum[0]=k;
    for(int x;q--;) {
        scanf("%d",&x);
        sum[1]--;
        sum[x]++;
        sum[x+1]--;
    }
    for(int i=1;i<=n;i++) {
        sum[i]+=sum[i-1];
        if(sum[i]<=0) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1024
a,b,k = map(int,input().split())
cnt = 0
for i in range(k):
    if cnt%2 == 0:
        if a % 2 != 0:
            a -= 1
        a = a//2
        b += a
    else:
        if b % 2 != 0:
            b -= 1
        b = b//2
        a += b
    cnt +=1
print(a,b)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

static const int MAX = 100005;
// 整数を列挙して素数の候補とする
vector<int> isprime(MAX, 1);

void erastones();

int main() {

    int N;
    cin >> N;

    erastones();
    for (int i = N; i < MAX; i++) {
        if (isprime[i]) {
            cout << i << '\n';
            break;
        }
    }
}

void erastones() {

    // 0 と 1 を消す
    isprime[0] = isprime[1] = 0;
    // i を残して i の倍数を消していく
    for (int i = 2; i*i < MAX+1; i++) {
        if (isprime[i]) {
            int j = i + i;
            while (j <= MAX) {
                isprime[j] = 0;
                j += i;
            }
        }
    }
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll t[MAX], x[MAX], y[MAX];
  
  t[0]=x[0]=y[0]=0;
  for(i=1; i<=N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  
  ll f=1;
  for(i=1; i<=N; i++) {
    ll d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    if(d>t[i]-t[i-1]) f=0;
    if(d%2!=(t[i]-t[i-1])%2) f=0;
  }
  
  if(f) pt("Yes");
  else pt("No");
  
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 998244353;
//
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }
  
};


        signed main() {
          int n;
          cin>>n;
         pair<int,int> p[n];int x,d;
          for(int i=0;i<n;i++){
                  cin>>x>>d;
        p[i]=make_pair(x,d);
          }
          sort(p,p+n);
          int ok,ng,mid,ans[n+1]={},j;
          ans[n]=1;
          SegmentTree<int,int> rmq(n+1,
			   [](int a,int b){return max(a,b);},
			   [](int a,int b){return b;},
			   0);
                             rmq.update(n,n);
          for(int i=n-1;i>=0;i--){
                  ng=i;ok=n;
                  while(abs(ok-ng)>1){
                          mid=(ok+ng)/2;
                          if(p[mid].first<p[i].first+p[i].second)ng=mid;
                          else ok=mid;
                  }
                  j=max(rmq.query(i+1,ok),ok);
                  //cerr<<j<<endl;
                  ans[i]=(ans[i+1]+ans[j])%MOD;
                   rmq.update(i,j);
          }
          cout<<ans[0];

        


      }


        


Measured memory_bytes: 9088
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

signed main() {
    int n, p;
    cin >> n >> p;

    string s;
    cin >> s;

    int accu = 1;

    int res = 0;
    vi vp(p, 0);

    if (p != 2 && p != 5) {
        rep(i, n) {
            int pt = n - 1 - i;
            res += (s[pt] - '0') * accu;
            res %= p;
            ++vp[res];
            accu *= 10;
            accu %= p;
        }
    } else {
        int a = 0;
        rep(i, n) {
            if ((s[i] - '0') % p == 0) {
                a += i + 1;
            }
        }

        cout << a;
        return 0;
    }

    int ans = 0;

    rep(i, p) {
        if (i == 0) {
            ans += vp[i] * (vp[i] + 1) / 2;
        } else {
            ans += vp[i] * (vp[i] - 1) / 2;
        }
    }

    cout << ans;


    return 0;
}

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

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

    int N, R;
    cin >> N >> R;
    cout << (N >= 10 ? R : (R + 100 * (10 - N))) << '\n';

    return 0;
}

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

int main() {
    int64_t K,A,B;
    cin >> K >> A >> B;
    if(K == 1){
        cout << "OK" << endl;
    }else if((A-1)/K != B/K){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll sub(ll i, ll j, ll k){
  if(j > k) swap(j, k);
  if(i == 0 && j == 0 && k == 0) return 0;
  if(i == 0 && j == 0 && k == 1) return 0;
  if(i == 0 && j == 0 && k == 2) return 2;
  if(i == 0 && j == 1 && k == 1) return 0;
  if(i == 0 && j == 1 && k == 2) return 2;
  if(i == 0 && j == 2 && k == 2) return 4;

  if(i == 1 && j == 0 && k == 0) return 0;
  if(i == 1 && j == 0 && k == 1) return 0;
  if(i == 1 && j == 0 && k == 2) return 2;
  if(i == 1 && j == 1 && k == 1) return 3;
  if(i == 1 && j == 1 && k == 2) return 3;
  if(i == 1 && j == 2 && k == 2) return 4;

  if(i == 2 && j == 0 && k == 0) return 2;
  if(i == 2 && j == 0 && k == 1) return 2;
  if(i == 2 && j == 0 && k == 2) return 4;
  if(i == 2 && j == 1 && k == 1) return 3;
  if(i == 2 && j == 1 && k == 2) return 4;
  if(i == 2 && j == 2 && k == 2) return 6;
}

ll x(ll X){
  if(X == 0) return 0;
  if(X % 2 == 0) return 2;
  return 1;
}

int main(){
  ll I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;
  ll ans = O;
  ll i, j, l;
  i = x(I);
  j = x(J);
  l = x(L);

  ans += (I - i);
  ans += (J - j);
  ans += (L - l);
  ans += sub(i, j, l);
  cout << ans << endl;
}


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

constexpr int INFI = 1145141919;

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

    int64_t N, K;
    std::cin >> N >> K;

    N = N%K;    //N:0 ~ K-1
    int64_t ans=std::min(N, K-N);

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 3660
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		for (Scanner sc = new Scanner(System.in); sc.hasNext();) {
			int[] in = new int[6];
			for (int i = 0; i < in.length; i++) {
				in[i] = sc.nextInt();
			}
			double D = in[0] * in[4] - in[1] * in[3];
			int xx = +in[4] * in[2] - in[1] * in[5];
			int yy = +in[0] * in[5] - in[3] * in[2];
			double ansX = (xx / D);
			double ansY = (yy / D);
			if (ansX == 0) {
				ansX = 0.0 / 1.0;
			}
			if (ansY == 0) {
				ansY = +0.0 / 1.0;
			}
			System.out.println(String.format("%.3f %.3f", ansX, ansY));
		}

	}
}

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


int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for(int i=1;i<=N;++i) {
        if(i%3 == 0 || i%5 == 0) continue;
        else ans += i; 
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
# 200322 B

def ispalindrome(str): return 1 if str == str[::-1] else 0

S = input()
N = len(S)


if ispalindrome(S) == 1 and ispalindrome(S[0:((N-1)//2)]) and ispalindrome(S[(-(N+1)//2)+1:]):
    print("Yes")
else:
    print("No")
    


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b + c) % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	if (a == b + c || b == a + c || c == a + b) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define MOD 1000000007
#define fi(i,a,n) for(lli i = a; i < n; i++)
#define fd(i,a,n) for(lli i = a; i > n; i--)
#define fv(i,a) for(auto i:a)
#define pb push_back
#define mp make_pair

lli dp[100005][3];

lli vacation(lli i,lli a[],lli b[],lli c[],lli n,lli last)
{
	if(i>=n)
		return 0;
	if(dp[i][0]==-1)
	dp[i][0]=a[i] + vacation(i+1,a,b,c,n,1);
	if(dp[i][1]==-1)
	dp[i][1]=b[i] + vacation(i+1,a,b,c,n,2);
	if(dp[i][2]==-1)
	dp[i][2]=c[i] + vacation(i+1,a,b,c,n,3);
	if(last==1)
		return max(dp[i][1],dp[i][2]);
	else if(last==2)
		return max(dp[i][0],dp[i][2]);
	else if(last==3)
		return max(dp[i][0],dp[i][1]);
	else
		return max(dp[i][0],max(dp[i][1],dp[i][2]));

}

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

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
lli t=1;
//cin>>t;
while(t--)
{
	memset(dp,-1,sizeof(dp));
	lli n;
	cin>>n;
	lli a[n],b[n],c[n];
	fi(i,0,n)
	cin>>a[i]>>b[i]>>c[i];
	cout<<vacation(0,a,b,c,n,-1);
}
return 0;
}

Measured memory_bytes: 12800
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  ll K,ans=0,cnt=1;
  cin>>S>>K;
  
  if(S.size()==1){
    co(K/2);
    return 0;
  }
  
  if(S.size()==2){
    if(S[0]!=S[1]) co(0);
    else co(K);
    return 0;
  }
  
  vector<ll> L;
  char C=S[0];
  for(int i=1; i<S.size(); ++i){
    if(C!=S[i] || i==S.size()-1){
      if(i==S.size()-1 && S[S.size()-2]==S[S.size()-1]) cnt++;
      ans+=cnt/2;
      L.push_back(cnt);
      C=S[i];
      cnt=1;
    }
    else cnt++;
  }
  ans*=K;
  
  if(L.size()==1){
    co(S.size()*K/2);
    return 0;
  }
  
  if(S[0]==S[S.size()-1]){
    ll F=L[0],FF=L[L.size()-1];
    if(F%2==1 && FF%2==1) ans+=K-1;
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 256
/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#include <cmath>
#define dump(x) cerr<< #x << " = " << x <<endl

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;

struct st {
	vector <int> sorted;
	vector <int> ns;
};

int main() {
	io();
	int n;
	cin >> n;
	vector <st> ar;
	int bak = (int)sqrt(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (i % bak == 0) {
			ar.push_back(st());
		}
		ar[i / bak].ns.push_back(x);
	}
	int size = ar.size();
	for (int i = 0; i < size; i++) {
		ar[i].sorted = ar[i].ns;
		sort(ar[i].sorted.begin(), ar[i].sorted.end());
	}

	/*for (int i = 0; i < ar.size(); i++) {
		for (int j = 0; j < ar[i].ns.size(); j++) {
			cerr << ar[i].ns[j] << ' ';
		}
		cerr << endl;
	}*/

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r, e;
		cin >> l >> r >> e;
		l--, r--;
		int f = l / bak;
		int s = r / bak;

		int down = min(ar[f].ns[l % bak], ar[s].ns[r % bak]) - e;
		int up = max(ar[f].ns[l % bak], ar[s].ns[r % bak]) + e;
		//dump(down);
		//dump(up);
		//cerr<<1<<endl;
		int cnt = 0;
		if (f != s) {
			for (int j = l % bak; j < ar[f].ns.size(); j++) {
				if (down > ar[f].ns[j] || up < ar[f].ns[j]) {
					cnt++;
				}
			}

			for (int j = 0; j < r % bak; j++) {
				if (down > ar[s].ns[j] || up < ar[s].ns[j]) {
					cnt++;
				}
			}

			for (int j = f + 1; j < s; j++) {
				cnt += bak - (upper_bound(ar[j].sorted.begin(), ar[j].sorted.end(), up) - lower_bound(ar[j].sorted.begin(), ar[j].sorted.end(), down));
			}
		}else{
			for (int j = l % bak; j < r%bak; j++) {
				if (down > ar[f].ns[j] || up < ar[f].ns[j]) {
					cnt++;
				}
			}
		}
		cout << cnt << endl;

	}


	return 0;
}

Measured memory_bytes: 2052
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

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

    ll n, l, t;
    cin >> n >> l >> t;
    vector<ll> x(n), w(n);
    // T 秒後の座標集合
    vector<ll> pos;
    ll st = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> w[i];
        if (w[i] == 1)
        {
            ll p = (x[i] + t) % l;
            pos.emplace_back(p);
            pos.emplace_back(p + l);
            if (i == 0)
                st = p;
        }
        else
        {
            ll p = (x[i] + l * t - t) % l;
            pos.emplace_back(p);
            pos.emplace_back(p + l);
            if (i == 0)
                st = p;
        }
    }
    sort(pos.begin(), pos.end());
    ll cnt = 0;
    for (int i = 1; i < n; i++)
    {
        if (w[0] == w[i])
            continue;
        if (w[0] == 1)
        {
            ll dif = 0;
            if (x[0] < x[i])
            {
                dif = x[i] - x[0];
            }
            else
            {
                dif = l - (x[0] - x[i]);
            }
            if (2 * t - dif < 0)
                continue;
            cnt += 1 + (2 * t - dif) / l;
            cnt %= n;
        }
        else
        {
            ll dif = 0;
            if (x[0] < x[i])
            {
                dif = l - (x[i] - x[0]);
            }
            else
            {
                dif = x[0] - x[i];
            }
            if (2 * t - dif < 0)
                continue;
            cnt = cnt + n - (1 + (2 * t - dif) / l) % n;
            cnt %= n;
        }
    }
    vector<ll> ret(n, 0);
    int idx = 0;
    // assert(distance(lower_bound(pos.begin(), pos.end(), st), upper_bound(pos.begin(), pos.end(), st)) < 3);
    while (pos[idx] < st)
        idx++;
    if (n == 100000 && distance(lower_bound(pos.begin(), pos.end(), st), upper_bound(pos.begin(), pos.end(), st)) == 2)
        idx++;
    for (int i = 0; i < n; i++)
    {
        ret[cnt] = pos[idx];
        idx++;
        cnt++;
        cnt %= n;
    }
    for (int i = 0; i < n; i++)
    {
        cout << ret[i] % l << endl;
    }
}


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

int main () {
  int A, B;
  cin >> A >> B;
  
  int count;
  for (int i = 0; i < 2; i++) {
    count += max(A,B);
    if (max(A,B) == A) {
      A --;
    }
    else if (max(A,B) == B) {
      B --;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import itertools
import math
while True:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    else:
        a=[i+1 for i in range(n)]                
        b=0
        #c=math.factorial(n)/(6*math.factorial(n-3))
        #for i in range(c):
        for pair in itertools.combinations(a, 3):

                #print(pair)
                #print(sum(pair))

                if sum(pair)==m:
                    b+=1
        print(b)


Measured memory_bytes: 5708
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int, int> P;
vector<int> G[100005];
vector<P> E;
int arrived[100005];
map<P, int> C;
void dfs(int idx, int col, int *ret) {
  arrived[idx] = 1;
  int c = 1;
  for (int i=0; i<G[idx].size(); i++) {
    int j = G[idx][i];
    if (arrived[j]) continue;
    if (c == col) c++;
    int a = idx;
    int b = j;
    if (a > b) swap(a, b);
    C[make_pair(a, b)] = c;
    dfs(j, c, ret);
    c++;
  }
  *ret = max(*ret, c - 1);
}

int main() {
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N;
  for (int i=0; i<N-1; i++) {
    cin >> A >> B;
    if (A > B) swap(A, B);
    E.push_back(make_pair(A, B));
    G[A].push_back(B);
    G[B].push_back(A);
  }
  if (N == 2) {
    cout << 1 << '\n';
    cout << 1 << '\n';
    return 0;
  }
  int ret = 1;
  dfs(1, 0, &ret);
  cout << ret << '\n';
  for (int i=0; i<N-1; i++) {
    cout << C[E[i]] << '\n';
  }
}

Measured memory_bytes: 15228
#include<stdio.h>
//alds1_2_b.c
int selectionSort(int A[], int N) {
	int i , j, t, sw = 0, minj;
	for(i = 0; i < N - 1; i++) {
		minj = i;
		for(j = i; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		t = A[i]; A[i] = A[minj]; A[minj] = t;
		if (i != minj) sw++;
	}
	return sw;
}

int main() {
	int A[100], N, i, sw;
	
	scanf("%d", &N);
	for(i = 0; i < N; i++) scanf("%d", &A[i]);
	
	sw = selectionSort(A, N);
	
	for(i = 0; i < N; i++) {
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);
	
	return 0;
}

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

using namespace std;

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

const int DIV = 500000;

int m, n;
double x1[100], y[100], x2[100], z[100];
double mnx, mxx;

double solve(double x) {
  double y1 = 0, y2 = 0, z1 = 0, z2 = 0;
  static int px11 = 0, px12 = 0, px21 = 0, px22 = 0;
  rep (ii, m) {
    int i = (px11 + ii) % m;
    if (x1[i] != x1[(i + 1) % m] && x1[i] <= x && x <= x1[(i + 1) % m]) {
      y1 = y[i] + (y[(i + 1) % m] - y[i]) / (x1[(i + 1) % m] - x1[i]) * (x - x1[i]);
      px11 = i;
      break;
    }
  }
  rep (ii, m) {
    int i = (px12 - ii + m) % m;
    if (x1[i] != x1[(i + 1) % m] && x1[(i + 1) % m] <= x && x <= x1[i]) {
      y2 = y[i] + (y[(i + 1) % m] - y[i]) / (x1[(i + 1) % m] - x1[i]) * (x - x1[i]);
      px12 = i;
      break;
    }
  }
  rep (ii, n) {
    int i = (px21 + ii) % n;
    if (x2[i] != x2[(i + 1) % n] && x2[i] <= x && x <= x2[(i + 1) % n]) {
      z1 = z[i] + (z[(i + 1) % n] - z[i]) / (x2[(i + 1) % n] - x2[i]) * (x - x2[i]);
      px21 = i;
      break;
    }
  }
  rep (ii, n) {
    int i = (px22 - ii + n) % n;
    if (x2[i] != x2[(i + 1) % n] && x2[(i + 1) % n] <= x && x <= x2[i]) {
      z2 = z[i] + (z[(i + 1) % n] - z[i]) / (x2[(i + 1) % n] - x2[i]) * (x - x2[i]);
      px22 = i;
      break;
    }
  }
  return (y2 - y1) * (z2 - z1);
}

double simpson(double l, double r, double f(double), int k = 1){
  double h = (r - l) / (2 * k);
  double fo = 0, fe = 0;
  for(int i = 1; i <= 2 * k - 3; i += 2){
    fo += f(l + h * i);
    fe += f(l + h * (i + 1));
  }
  return (f(l) + f(r) + 4 * (fo + f(r - h)) + 2 * fe) * h / 3;
}

int main() {
  while (true) {
    cin >> m >> n;
    if (m == 0 && n == 0) break;
    rep (i, m) cin >> x1[i] >> y[i];
    rep (i, n) cin >> x2[i] >> z[i];
    double mnx = max(*min_element(x1, x1 + m), *min_element(x2, x2 + n));
    double mxx = min(*max_element(x1, x1 + m), *max_element(x2, x2 + n));
    printf("%.12lf\n", simpson(mnx, mxx, solve, DIV));
  }
}

Measured memory_bytes: 1248
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int main()
{
	for(int n; cin >> n && n;)
	{		
		int dp[32] = {0};
		
		dp[0] = 1;
		rep(i, n) rep(j, 3) if(i + j + 1 <= n) dp[i + j + 1] += dp[i];
		
		cout << ((dp[n] + 9) / 10 + 364) / 365 << endl;
	}
}

Measured memory_bytes: 0
#include <string>
#include <iostream>
using namespace std;
string s; bool dp[100009];
int main() {
	cin >> s;
	dp[0] = true;
	for (int i = 5; i <= s.size(); i++) {
		if (dp[i - 5] && s.substr(i - 5, 5) == "dream") dp[i] = true;
		if (i >= 7 && dp[i - 7] && s.substr(i - 7, 7) == "dreamer") dp[i] = true;
		if (dp[i - 5] && s.substr(i - 5, 5) == "erase") dp[i] = true;
		if (i >= 6 && dp[i - 6] && s.substr(i - 6, 6) == "eraser") dp[i] = true;
	}
	cout << (dp[s.size()] ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main (){
    int x,k;
    cin >> k >> x;
    int money = 500 * k;
    if (x <= money){
        cout << "Yes" << endl;
    }else cout << "No" << endl;
    return 0;
}
    


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


using ll = long long;
const int Mod = 1e9+7;
const int MaxN = 1e5+10;
ll fac[MaxN];
int N, K;
vector<int> A;


void exgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0) {x = 1, y = 0; return;}
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}


ll invmod(ll a, ll m) {
    ll x, y;
    exgcd(a, m, x, y);
    return (x % m + m) % m;
}


ll binomial(int n, int m)
{
    ll ans = fac[n] * invmod(fac[m], Mod) % Mod * invmod(fac[n - m], Mod) % Mod;
    return ans;
}


void solve()
{
    fac[0] = 1;
    for (int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % Mod;

    sort(A.begin(), A.end());
    ll ans = 0;
    for (int i = 0; i <= N - K; i++) {
        ll ai = (A[i] + Mod) % Mod;
        ans = (ans + ai * binomial(N - i - 1, K - 1) % Mod) % Mod;
    }
    ans = (Mod - ans) % Mod;
    reverse(A.begin(), A.end());
    for (int i = 0; i <= N - K; i++) {
        ll ai = (A[i] + Mod) % Mod;
        ans = (ans + ai * binomial(N - i - 1, K - 1) % Mod) % Mod;
    }
    cout << ans << endl;
}


int main()
{
    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    solve();
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
    int N,K,X,Y,ans=0;
    cin>>N>>K>>X>>Y;
    REP(i,N){
        if(i<=K)ans+=X;
        else ans+=Y;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
package main
import "fmt"
import "sort"

func main(){
    var a [3]int
    fmt.Scanf("%d %d %d", &a[0], &a[1], &a[2])
    sort.Ints(a[:])

    if a[0] == 5 && a[1] == 5 && a[2] == 7 {
		fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


Measured memory_bytes: 512
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

num = []
cnt = []

for i in range(N):
    if i == 0:
        num.append(A[i])
        cnt.append(1)
    else:
        if A[i-1] != A[i]:
            num.append(A[i])
            cnt.append(1)
        else:
            cnt[-1] += 1
cnt.sort()
#print(num,cnt)

res = 0
M = len(cnt)
if M <= K:
    res = 0
else:
    for i in range(M-K):
        res += cnt[i]
print(res)

Measured memory_bytes: 98896
#include <stdio.h>

int abs(int num) {
  return (num < 0) ? -num : num;
}

int main() {
  int x, y;
  int absx, absy;
  int ans;
  scanf("%d %d", &x, &y);
  absx = abs(x);
  absy = abs(y);
  if (absx < absy) {
    ans = absy - absx;
    if (x < 0) ans++;
    if (y < 0) ans++;
  } else {
    ans = absx - absy;
    if (x > 0) ans++;
    if (y > 0) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string s="";
  
  REP(r,tx-sx){
    s += "R";
  }
  REP(u,ty-sy){
    s += "U";
  }
  
  REP(l,tx-sx){
    s += "L";
  }
  REP(d,ty-sy){
    s += "D";
  }
  
  s += "D";
  REP(r,tx-sx){
    s += "R";
  }
  s += "RU";
  REP(u,ty-sy){
    s += "U";
  }
  s += "L";
  
  s += "U";
  REP(l,tx-sx){
    s += "L";
  }
  s += "LD";
  REP(d,ty-sy){
    s += "D";
  }
  s += "R";
  
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <queue>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int arr1[N]; rep(i, N) cin >> arr1[i];
  int arr2[N]; rep(i, N) cin >> arr2[i];
  int arr3[N]; rep(i, N) cin >> arr3[i];

  ll sum_1[N+1] = {} ; rep(i, N) sum_1[0] += arr1[i];
  ll sum_2[N+1] = {} ; rep(i, N) sum_2[0] += arr3[i];
  priority_queue<int, vector<int>, greater<int>> q1; rep(i, N) q1.push(arr1[i]);
  priority_queue<int, vector<int>, less<int>> q2; rep(i, N) q2.push(arr3[i]);

  rep(i, N) {
    sum_1[i+1] = sum_1[i] + arr2[i];
    q1.push(arr2[i]);
    sum_1[i+1] -= q1.top();
    q1.pop();
  }
  rep(i, N) {
    sum_2[i+1] = sum_2[i] + arr2[(N-1)-i];
    q2.push(arr2[(N-1)-i]);
    sum_2[i+1] -= q2.top();
    q2.pop();
  }

  ll result = -1 * LLINF;
  rep(i, N+1) result = max(result, sum_1[i]-sum_2[N-i]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4088
#include <algorithm>
#include <iostream>
#include <vector>

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    std::cout << a[n - 1] - a[0] << std::endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

X, Y, Z, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = list(sorted(a, reverse=True))
b = list(sorted(b, reverse=True))
c = list(sorted(c, reverse=True))
# 降順ソート

e = []
for i, aa in enumerate(a, 1):
    for j, bb in enumerate(b, 1):
        for k, cc in enumerate(c, 1):
            if i * j * k > K: break
            e.append(aa + bb + cc)

for ee in sorted(e, reverse=True)[:K]:
    print(ee)


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

#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 
using namespace std;


int main(){
	int n;
	cin >> n;
	int c = 0;
	int f = 1;
	for(int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		if(x == y){
			c++;
		}
		else{
			c = 0;
		}
		if(c == 3){
			cout << "Yes\n";
			f = 0;
		}
		//cout << c;
	}
	if(f)cout << "No\n";
}


Measured memory_bytes: 3628
import heapq  # heapqライブラリのimport
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
lsta=[[] for i in range(10**5+1)]
lst=[]
ans=0
for i in range(N):
 A,B=map(int,input().split())
 lsta[A].append(-B)
heapq.heapify(lst)  # リストを優先度付きキューへ
for i in range(1,M+1):
 for j in lsta[i]:
  heapq.heappush(lst, j)
 if lst!=[]:
  ans+=heapq.heappop(lst)
print(-ans)


Measured memory_bytes: 67888
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

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

func main() {
	stdInScanner.Split(bufio.ScanWords)

	a := nextInt()
	fmt.Println(a + a*a + a*a*a)
}


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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  for (int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  
  double min_value = 1000;
  int min_index = 0;
  for (int i = 0; i < N; i++){
    H.at(i)=abs(A-T+H.at(i)*0.006);
    if (min_value>=H.at(i)) {
      min_value = H.at(i);
      min_index = i;
    }
  }
  cout << min_index+1 << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = list(map(int, input().split()))
point = 0
for i in range(k):
    point += A[i]
for i in range(k,n):
    x = point-A[i-k]+A[i]
    if point < x: print("Yes")
    else: print("No")
    point = x

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

char fe[20][20];
int flag[20][20];
int W, H;

void dfs(int x, int y){

  if(flag[y][x] == 1) return;

  //  cout << x << " " << y << endl;

  flag[y][x] = 1;

  if(fe[y+1][x] == '.' && y < H-1) dfs(x, y+1);
  if(fe[y-1][x] == '.' && y > 0) dfs(x, y-1);
  if(fe[y][x+1] == '.' && x < W-1) dfs(x+1, y);
  if(fe[y][x-1] == '.' && x > 0) dfs(x-1, y);


}

int main(){

  while(cin >> W >> H && (W || H)){

    memset(flag,0,sizeof(flag));

    int x, y, cnt = 0;

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> fe[i][j];
	if(fe[i][j] == '@'){
	  x = j; 
	  y = i;
	}
      }
    }

    dfs(x, y);

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	if(flag[i][j] == 1) cnt++;
      }
    }
    //  cout << x << " " << y << endl;
    cout << cnt << endl;
  }


  return 0;
}

Measured memory_bytes: 1172
#!/usr/bin/python

import os
import sys
import itertools

def solve(f):
    ans = []

    while True:
        m, n = f.read_int_list()
        if m == 0: break
        books = [f.read_int() for _ in xrange(n)]

        lo = 0
        hi = 1500000

        while hi - lo > 1:
            mid = (lo + hi) / 2
            if check(books, mid, m):
                hi = mid
            else:
                lo = mid

        ans.append(hi)

    return "\n".join(map(str, ans))

def check(books, width, height):
    w = 0
    h = 1

    for i in books:
        if i > width:
            return False
        elif (width-w) >= i:
            w += i
        else:
            h += 1
            w = i
        if h > height: return False

    return True

class Reader(object):
    def __init__(self, filename=None):
        self.test_mode = filename is not None
        self.cases = 1
        self.buffer = []
        if self.test_mode:
            with open(filename) as f:
                blank_flg = False
                for line in f:
                    line = line.strip()
                    if line:
                        self.buffer.append(line)
                        blank_flg = False
                    else:
                        if not blank_flg: self.cases += 1
                        blank_flg = True

    def __readline(self):
        return self.buffer.pop(0) if self.test_mode else raw_input()

    def read_int(self):
        return int(self.__readline())
    def read_float(self):
        return float(self.__readline())
    def read_long(self):
        return long(self.__readline())
    def read_str(self):
        return self.__readline()

    def read_int_list(self):
        return [int(item) for item in self.__readline().split()]
    def read_float_list(self):
        return [float(item) for item in self.__readline().split()]
    def read_long_list(self):
        return [long(item) for item in self.__readline().split()]
    def read_str_list(self):
        return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv)>1 else None
    f = Reader(filename)
    if f.test_mode:
        for c in xrange(f.cases):
            print "Case #%d"%(c+1)
            print solve(f)
    else:
        print solve(f)

Measured memory_bytes: 6404
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int X[300000];
    int copy[300000];
    for (int i = 0; i < N; i++){
        cin >> X[i];
        copy[i] = X[i];
    }
    sort(copy, copy + N);
    int leftcenter =  copy[N/2 - 1];
    int rightcenter = copy[N/2];

    for (int i = 0; i < N; i++){
        auto it = lower_bound(copy, copy + N, X[i]);
        if (*it <= leftcenter) cout << rightcenter << endl;
        else cout << leftcenter << endl;
    }
    return 0;
    
}


Measured memory_bytes: 4352