akhauriyash/Code-Regression huggingface dataset:
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

template <typename T>
T abs(T x) { return (x < 0) ? (-x) : x; }

int gcd(int x, int y) {
	if(x > y) swap(x, y);
	while(x) {
		y %= x;
		swap(x, y);
	}
	return y;
}

cat solve_inner(int r, int c2, int W, int H, int K, auto & G) {
	int ret = 0;
	int C = 2*(K-1)+gcd(c2,r)-c2*(H-r);
	int c1 = 1, c1b = min(W-1, C/r);
	if(c1 <= c1b) {
		ret += c1b-c1+1;
		c1 = c1b+1;
	}
	while(c1 < W && c1*r <= C+2*H-r) {
		ret += (c1*r <= C+gcd(c1,H-r)+G[abs(c1-c2)]);
		c1++;
	}
	return ret;
}

cat solve(int W, int H, int K) {
	vector<int> G(W+1, 0);
	for(int i = 0; i <= W; i++) G[i] = gcd(H, i);
	cat ret = 0;
	for(int r = 1; r <= (H-1)/2; r++)
		for(int c2 = 1; c2 < W && c2*(H-r) <= 2*(K-1+H); c2++)
			ret += solve_inner(r, c2, W, H, K, G);
	ret *= 2;
	if(H%2 == 0) {
		int r = H/2;
		for(int c2 = 1; c2 < W && c2*(H-r) <= 2*(K-1+H); c2++)
			ret += solve_inner(r, c2, W, H, K, G);
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int W, H, K;
	cin >> W >> H >> K;
	cout << 2 * (solve(W, H, K) + solve(H, W, K)) << "\n";
}

// look at my code
// my code is amazing


Measured memory_bytes: 3960
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,n,x,ans=0;
    string s,t;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>x;
        ans+=x-1;
    }


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





Measured memory_bytes: 3648
#include<stdio.h>
int main(void) {
  getchar(); getchar(); getchar(); getchar();
  getchar(); getchar(); getchar(); getchar();
  int a;
  scanf("%d", &a);
  printf("2018/01/");
  if(a < 10)
    printf("0%d\n", a);
  else
    printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

void solve(){
    int n;
    cin >> n;
    vi a(n);
    cina(0, n, a);
    sort(all(a));
    for(int i = 1; i < n; i++){
        if(a[i] == a[i - 1]){
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;
using namespace atcoder;

/////////////////////////////////////////////////////
#define vv vector

ll N;
pll xy[202020];
ll ytoi[202020];
ll mk[202020];
__int128_t i, j, k;
int main(){
    scanf("%lld", &N);
    vv<pll> xi(N);
    dsu d(N + 3);

    rep(i,0,N){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        xy[i] = {x,y};
        ytoi[y] = i;
        xi[i] = {x, i};
    }
    sort(all(xi));

    map<ll,ll> mp;
    ll xmx = 0, ymn = N+1;
    rep(i,0,N){
        ll ii = xi[i].se;
        ll x = xy[ii].fi;
        ll y = xy[ii].se;

        if(y>ymn)
            continue;
        if(x<xmx)
            d.merge(ii, ytoi[ymn]);
        rep(j,y,ymn){
            //printf("%llda", ytoi[j]);
            d.merge(ii, ytoi[j]);
            xmx = max(xmx, xy[ytoi[j]].fi);
        }
        ymn = y;
    }
    rep(i,0,N){
        printf("%lld\n", d.size(i));
    }

    return 0;
}

Measured memory_bytes: 12024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    vec p(n);
    rep(i, n) cin >> p[i];

    sort(all(p));

    int res = 0;
    rep(i, k) res += p[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

const ll INF = 1 << 30;

int main() {
  ll N, M;
  string str;
  cin >> N >> M >> str;

  vll dp(N + 1, INF);
  ll cur = N;
  dp[N] = 0;
  for (ll i = N - 1; i >= 0; i--) {
    if (str[i] == '1') continue;
    while (1) {
      if (i >= cur) {
        puts("-1");
        return 0;
      } else if (dp[cur] != INF && cur - i <= M) {
        dp[i] = dp[cur] + 1;
        // cerr << i << " " << dp[i] << endl;
        break;
      }
      cur--;
    }  // while
  }    // i

  vll ans;
  cur = N;
  ll tmp = 0;
  ll cur_i = cur - 1;
  while (cur > 0) {
    tmp += 1;
    ll pval = 0;
    while (dp[cur_i] == tmp || dp[cur_i] == INF) {
      if (dp[cur_i] != INF) pval = cur - cur_i;
      cur_i--;
    }
    ans.push_back(pval);
    cur -= pval;
  }

  for (size_t i = 0; i < ans.size(); i++) {
    cout << ans[ans.size() - 1 - i] << endl;
  }

  return 0;
}


Measured memory_bytes: 2296
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define MAX_N 200
#define INF (1e9)
struct state{
  int cost,h,J,cnt;
  bool operator < (const state& p)const{
    return cost > p.cost;
  }
};

struct data{
  int w,cost;
};

vector<data> G[MAX_N];
int n,m;
int d[MAX_N][MAX_N][MAX_N];

void solve(){
  int ans=INF;
  for(int i=0;i<MAX_N;i++)
    for(int j=0;j<MAX_N;j++)
      for(int k=0;k<MAX_N;k++)
	d[i][j][k]=INF;
 
  priority_queue < state > Q;
  for(int i=0;i<2;i++){
    if(m-i<0)break;
    for(int j=0;j<(int)G[i].size();j++){
      data e=G[i][j];
      d[i][j][m-i]=0;
      Q.push((state){0,i,j,m-i});
    }
  }
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    //cout<<s.h<<' '<<s.J<<' '<<s.cost<<' '<<s.cnt<<endl;
    if(s.h+1==n){
      ans=min(ans,s.cost);
    }else if(s.h+2==n&&s.cnt>=1){
      ans=min(ans,s.cost);
    }
    
    if(s.cost>d[s.h][s.J][s.cnt])continue;
    
    data f=G[s.h][s.J];
    if(s.h+1>=n)continue;
    for(int i=0;i<(int)G[s.h+1].size();i++){
      data e=G[s.h+1][i];
      int ncost=(f.cost+e.cost)*abs(f.w-e.w)+s.cost;
      if(ncost>=d[s.h+1][i][s.cnt])continue;
      d[s.h+1][i][s.cnt]=ncost;
      Q.push( (state){d[s.h+1][i][s.cnt],s.h+1,i,s.cnt} );
    }

    if(s.cnt==0||s.h+2>=n)continue;
    s.cnt--;
    for(int i=0;i<(int)G[s.h+2].size();i++){
      data e=G[s.h+2][i];
      int ncost=(f.cost+e.cost)*abs(f.w-e.w)+s.cost;
      if(ncost>=d[s.h+2][i][s.cnt])continue;
      d[s.h+2][i][s.cnt]=ncost;
      Q.push( (state){d[s.h+2][i][s.cnt],s.h+2,i,s.cnt} );
    }
  }
  cout<<ans<<endl;
}

void init(){
  for(int i=0;i<MAX_N;i++)G[i].clear();
 
}
int main(){
  int a,b,c;
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    init();
    for(int i=0;i<n;i++){
      cin>>a;
      for(int j=0;j<a;j++){
	cin>>b>>c;
	G[i].push_back( (data){b,c} );
      }
    }

    solve();
  }
  return 0;
}

Measured memory_bytes: 34448
#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 11
char _buf[INTSPACE*1000000 + 3];  // ここ要確認

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

void solve(int N, vector<int>& a) {
    deque<int> dq;
    if (N%2 == 0) {
        rep(i, N){
            if (i%2 == 0)
                dq.push_back(a[i]);
            else
                dq.push_front(a[i]);
        }
    } else {
        rep(i, N){
            if (i%2 == 0)
                dq.push_front(a[i]);
            else
                dq.push_back(a[i]);
        }
    }
    rep(i, N) {
        int x = dq.front(); dq.pop_front();
        printf("%d", x);
        if (i != N-1) putchar(' ');
    }
    printf("\n");
}

int main() {
    vector<int> a;
    int N = loadvec(a);
    solve(N, a);
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)


#define trarr(a,n) forn(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) forn(i,0,n)forn(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 1e2+10;
const int K = 1e5+10;

void solve(int _t){
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, 0, n) cin >> a[i];
	int dp[N][K] = {0};
	ll DP[N][K] = {0};
	ll tmp = 0;
	for(int j = 0; j <= k; j++){
		if(j <= a[0])
			dp[0][j] = 1;
		tmp+=dp[0][j];
		DP[0][j] = tmp;
	} 
	for(int i = 1; i < n; i++){
		tmp = 0;
		for(int j = 0; j <= k; j++){
			dp[i][j] = DP[i-1][j];
			if(j-a[i]-1 >= 0) 
			dp[i][j] = (dp[i][j]-DP[i-1][j-a[i]-1]+P)%P;
			tmp = (tmp+dp[i][j])%P;
			DP[i][j] = tmp;
			// tr(tmp, i, j);
		}
	}	
	cout<<dp[n-1][k]<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Measured memory_bytes: 132552
def dfs(A):
  global ans
  if len(A)==N: 
    now=0
    for i in l:
      if A[i[1]-1]-A[i[0]-1]==i[2]:
        now+=i[3]
    ans=max(ans,now)
    return A

  A.append(A[-1])
  while A[-1]<=M:
    dfs(A[:])
    A[-1]+=1
    
  
N,M,Q=[int(x) for x in input().rstrip().split()]
A=[1]
l=[]
ans=0
for i in range(Q):
  abcd=[int(x) for x in input().rstrip().split()]
  l.append(abcd)
dfs(A)
print(ans)
  

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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;
    
    //-1で初期化
    //最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }
    
    //Aがどのグループに属しているか(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)];
    }

    //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)をくっつける
        //大証が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }
   //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m);
    for(int i=0;i<m;i++) {
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind uni(n);
    long long ans[m]={};
    ans[m-1]=(long long)n*(n-1)/2;

	for (int i=m-1;i>=1;i--){
		ans[i-1] = ans[i];
 
		if (uni.root(a[i]) != uni.root(b[i])) {
			ans[i-1] -= (long long)uni.size(a[i]) * uni.size(b[i]);
		    uni.connect(a[i], b[i]);
		}
	}

    for(int i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
    
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int MX = 0;
    int MN = INF;
    int cnt[3] = {};
    rep(i, S.length()) {
        cnt[S[i] - 'a']++;
    }
    int zerocnt = 0;
    rep(i, 3){
        if (cnt[i] == 0) zerocnt++;
        MX = max(cnt[i], MX);
        MN = min(cnt[i], MN);
    }
    if (zerocnt == 2) {
        if (S.length() == 1) {
            cout << "YES" << endl;
            return 0;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    } else if (zerocnt == 1) {
        if ( S.length() == 2) {
            cout << "YES" << endl;
            return 0;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    } else {
        if (MX - MN <= 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e5+5;
int32_t main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	if(n==1||m==1)
	{
		cout<<"1"<<endl;
		return 0;
	}
	int p=(m+1)/2;
	int z=m-p;
	cout<<p*((n+1)/2)+z*(n/2)<<endl;



	



	
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import deque
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for _ in range(n)]

dq = deque([a[0]])
for i in range(1, n):
    idx = bisect_left(dq, a[i])
    if idx == 0:
        dq.appendleft(a[i])
    else:
        dq[idx-1] = a[i]

print(len(dq))


Measured memory_bytes: 46940
#include<iostream>
#include<stdio.h>
//#include<bits/stdc++.h>
using namespace std;
#include<string>
int main()
{
    int t;
    cin>>t;
    string str;
    cin>>str;
    string str1,str2;
    int l=str.length();
    int mid = l/2;
    str1=str.substr(0,mid);
    str2=str.substr(mid,l);
    if( (str.length()%2)!=0)
        cout<<"No"<<endl;
    else if(str1==str2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
    
}


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

int main() {
    int N;
    cin >> N;
    vector<int> L(N);

    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
    }

    sort(L.begin(), L.end());

    int count = 0;


    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            for (int k = j + 1; k < N; k++) {

                if (L.at(k) < L.at(i) + L.at(j)) {
                    count++;
                }

            }

        }
    }

    cout << count << endl;

}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,a,b;
	cin >> n >> a >> b;
	
	long long mod=1000000007;
	
	//a<=b
	if(a>b) swap(a,b);
	
	vector<vector<long long>> dp(n+1,vector<long long>(b));
	vector<vector<long long>> dp2(n+1,vector<long long>(b));
	vector<long long> res(n+1);
	dp[0][0]=1;
	dp2[0][0]=0;
	
	for(int i=0;i<n;i++){
		res[i+1]+=(res[i]*2)%mod;
		res[i+1]%=mod;
		
		//add 1
		for(int j=0;j<n;j++){
			if((j+1)<b){
				dp[i+1][j+1]+=dp[i][j];
				dp[i+1][j+1]+=dp2[i][j];
				dp[i+1][j+1]%=mod;
			}
		}
		res[i+1]+=dp[i][b-1];
		res[i+1]+=dp2[i][b-1]*2;
		res[i+1]%=mod;
		
		//add 0
		for(int j=0;j<n;j++){
			if((j+1)<b){
				dp2[i+1][j+1]+=dp2[i][j];
				dp2[i+1][j+1]%=mod;
			}
			if(j<b){
				dp[i+1][0]+=dp[i][j];
				dp[i+1][0]%=mod;
			}
		}
		if((i+1-a)>=0){
			for(int j=1;j<b;j++){
				dp[i+1][0]=(dp[i+1][0]+mod-dp[i+1-a][j])%mod;
			}
			if((i+1-a)==0) dp[i+1][0]=(dp[i+1][0]+mod-1)%mod;
		}
		
		for(int j=1;j<n;j++){
			if((i+a)>n) continue;
			if((j+a)<b){
				dp2[i+a][j+a]+=dp[i][j];
				dp2[i+a][j+a]%=mod;
			}else if(j<b){
				res[i+a]+=dp[i][j];
				res[i+a]%=mod;
			}
		}
		if(i==0){
			if(a<b){
				dp2[i+a][a]+=dp[i][0];
				dp2[i+a][a]%=mod;
			}else{
				res[i+a]+=dp[i][0];
				res[i+a]%=mod;
			}
		}
	}
	cout << res[n] << "\n";
	return 0;
}

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

using namespace std;



int main()
{
	int N,jur,size,no;
    no=0;
	jur = 0;
	cin>>N;
	vector <string> W(N);
	for (int i = 0; i < N; i++){
		cin >> W[i];
		if (i>0){
			size=W[i - 1].length();
			if (W[i][0] != W[i - 1][size - 1])jur++;
			for (int j = 0; j < i-1; j++){
				if (W[i] == W[j])jur++;
			}
		}
		if (jur != 0){
			no++;
			break;
		}
	}
		
	if (no == 1) cout << "No" << endl;
    else cout << "Yes" << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long m=1000000007,ans=0;
  int x,y,a,b;cin>>x>>y;
  if((x+y)%3==0){ 
    a=(2*y-x)/3;b=(2*x-y)/3;
    if(a>=0&&b>=0){
      long long p=1,q=1;
      for(int i=a+b;i>a;i--){
        p*=i;
        p=p%m;
        q*=i-a;
        q=q%m;
      }
      for(int i=0;i<m;i++){
        if(i*q%m==p){ans=i;break;}
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  private void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int heapSize = Integer.parseInt(br.readLine());
      String[] keys = br.readLine().split(" ");
      int[] heap = new int[heapSize+1];
      for(int i=1; i<=heapSize; i++)
        heap[i] = Integer.parseInt( keys[i-1] );

      StringBuilder buf = new StringBuilder();
      for(int i=1; i<=heapSize; i++){
        buf.append("node " + i + ": key = " + heap[i] + ", ");
        if( i != 1 ) buf.append("parent key = " + heap[i/2] + ", ");
        if( i*2 <= heapSize) {
          buf.append("left key = " + heap[i*2] + ", ");
          if( i*2+1 <= heapSize) {
            buf.append("right key = " + heap[i*2+1] + ", ");
          }
        }
        buf.append("\n");
      }

      System.out.print(buf);
    } catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 24352
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	long long N, sum = 0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) sum += 1LL * i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3620
main = do
    n <- readLn :: IO Int
    as <- filter (\x -> even x) . map read . words <$> getLine :: IO [Int]
    putStrLn $ solve as

solve [] = "APPROVED"
solve (x:xs) | (even x) && x `mod` 3 == 0 = solve xs
             | (even x) && x `mod` 5 == 0 = solve xs
             | otherwise = "DENIED"


Measured memory_bytes: 4280
#include <stdio.h>
#include <string.h>
int main() {
	char s[51];
	int n, alCnt[50][26] = {0}, min;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		for (int j = 0; j < strlen(s); j++) {
			alCnt[i][s[j] - 'a']++;
		}
	}
	for (int i = 0; i < 26; i++) {
		min = 50;
		for (int j = 0; j < n; j++) {
			if (alCnt[j][i] < min) {
				min = alCnt[j][i];
			}
		}
		for (int j = 0; j < min; j++) {
			printf("%c", i + 'a');
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
H = [int(_) for _ in input().split()] + [10**10]
ans = 0
c = 0
for i in range(1, N+1):
    if H[i - 1] >= H[i]:
        c += 1
    else:
        ans = max(ans, c)
        c = 0
print(ans)

Measured memory_bytes: 14252
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
calc = 0
ans = 0

for i in range(N):
    A = list(map(int,input().split()))
    calc = 0
    for j in range(M):
        calc += A[j] * B[j]

    if calc + C > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdbool.h>

int main() {
	int i, N, k, d, sum;
	bool flag = false;

	scanf("%d", &N);

	for (k = 0; k <= 100; k += 4) {
		for (d = 0; d <= 100; d += 7) {
			sum = k + d;
			if (sum == N) flag = true;
		}
	}

	printf(flag == true ? "Yes\n" : "No\n");

	return 0;
}

Measured memory_bytes: 128
function Main(input) {
	let Arr = (input.trim()).split("\n");
	Arr.shift();
	 
	let bfr = [];
	for (let i = 0; i < 4; i++) {
		bfr.push([]);
		for (let j = 0; j < 3; j++) {
			bfr[i].push([]);
			for (let k = 0; k < 10; k++) {
				bfr[i][j].push(0);
			}
		}
	}
	 
	for (let i = 0; i < Arr.length; i++) {
		let arr = Arr[i].split(" ").map(Number);
		let b = arr[0] - 1;
		let f = arr[1] - 1;
		let r = arr[2] - 1;
		let v = arr[3] - 0;
	 
		bfr[b][f][r] = bfr[b][f][r] + v;
		if (bfr[b][f][r] > 9) bfr[b][f][r] = 9;
		if (bfr[b][f][r] < 0) bfr[b][f][r] = 0;
	 
	}
	 
	for (let i = 0; i < 4; i++) {
		for (let j = 0; j < 3; j++) {
			console.log(" " + bfr[i][j].join(" "));
		}
		if (i !== 3) console.log("####################");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 16144
import java.io.*;
import java.util.*;
import java.math.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}

public class Main {
  private static int solve(int n, int k) {
    return n - k + 1;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    out.println(solve(n, k));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    bool b = false;
    rep(i, n) {
        if (a[i] % 2) {
            b = true;
            break;
        }
    }

    if (b) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;

vector<int> v;


int main(){
  int n;
  while(cin>>n,n!=0){
    v.resize(0);
    for(int i=0;i<n;i++){
      int tmp;
      cin>>tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=1;i<v.size()-1;i++){
      ans+=v[i];
    }
    ans/=(n-2);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int a,b;

int main() {
	
	cin>>a>>b;
	int ans=a+b;
	ans=max(ans,a-b);
	ans=max(ans,a*b);
	cout<<ans<<endl;

	return 0;
}

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

int main() {
    int t;
    cin >> t;
    int h = 0, m = 0, s;
    bool flag = true;
    while(flag) {
        if(t >= 3600) {
            t -= 3600;
            h++;
            continue;
        }
         if(t >= 60) {
            t -= 60;
            m++;
            continue;
        }
    s = t;
    flag = false;
        }
    cout << h << ":" << m << ":" << s << endl;    
}



Measured memory_bytes: 3116
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

# p = 1
d1 = 0
r = []
for i in range(n):
    d = abs(x[i] - y[i])
    d1 += d
    r.append(d)

# p = 2
p = 2
d2 = 0
for i in range(n):
    d2 += abs(x[i] - y[i]) ** p
d2 = d2 ** (1/p)

# p = 3
p = 3
d3 = 0
for i in range(n):
    d3 += abs(x[i] - y[i]) ** p
d3 = d3 ** (1/p)

# p = ∞
d_inf = max(r)

print(d1)
print(d2)
print(d3)
print(d_inf)



Measured memory_bytes: 5644
fun main(args: Array<String>) {
    var S = readLine()!! .toCharArray()
    var map = mutableMapOf<Char, Int>()
    S.forEach {
        val n = map.get(it) ?: 0
        map.put(it, n+1)
    }
    var ans = "No"
    if (map.count() == 2) {
        if (map.values.all { it == 2}) ans = "Yes"
    }
    println(ans)
}


Measured memory_bytes: 33644
unittest
{
	assert( [ "3 2 5", "1 2 3", "2 3 3", "2", "3 2", "1 3" ].parse.expand.solve == "0\n1" );
	assert( [ "4 0 1", "1", "2 1" ].parse.expand.solve == "-1" );
	assert( [ "5 4 4", "1 2 2", "2 3 2", "3 4 3", "4 5 2", "20", "2 1", "3 1", "4 1", "5 1", "1 2", "3 2", "4 2", "5 2", "1 3", "2 3", "4 3", "5 3", "1 4", "2 4", "3 4", "5 4", "1 5", "2 5", "3 5", "4 5" ].parse.expand.solve == "0\n0\n1\n2\n0\n0\n1\n2\n0\n0\n0\n1\n1\n1\n0\n0\n2\n2\n1\n0" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

const C = 10L ^^ 14;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nml = input.front.split.to!( long[] );
	auto abcs = new long[ 3 ][ nml[ 1 ] ];
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
		abc[ 0 .. 2 ] -= 1;
	}
	input.popFront;
	auto q = input.front.to!( long );
	auto sts = new long[ 2 ][ q ];
	foreach( ref st; sts )
	{
		input.popFront;
		st = input.front.split.to!( long[] );
		st[] -= 1;
	}
	
	return tuple( nml[ 0 ], nml[ 2 ], abcs, sts );
}

auto solve( long n, long l, long[ 3 ][] abcs, long[ 2 ][] sts )
{
	// 辺配列を隣接リストに変換
	auto nss = new Tuple!( long, long )[][ n ];
	foreach( e; abcs )
	{
		if( l < e[ 2 ] ) continue;
		nss[ e[ 0 ] ] ~= tuple( e[ 1 ], e[ 2 ] );
		nss[ e[ 1 ] ] ~= tuple( e[ 0 ], e[ 2 ] );
	}
	
	// 最小補給回数を計算
	auto dss = new long[][ n ];
	foreach( i, ref ds; dss )
	{
		ds = dijkstraEx!( true )( n, nss, abcs.empty ? 1 : abcs.length, i, l );
	}
	
	// クエリに回答
	auto anss = new long[ sts.length ];
	foreach( ref ans, st; lockstep( anss, sts ) )
	{
		if( dss[ st[ 0 ] ][ st[ 1 ] ] == long.max ) ans = -1;
		else                                        ans = dss[ st[ 0 ] ][ st[ 1 ] ] / C;
	}
	return anss.to!( string[] ).join( "\n" );
}

// 正の重み付きグラフの始点指定最短経路探索（ダイクストラ法）
auto dijkstraEx( bool undirected = false )( long n, Tuple!( long, long )[][] nss, long ec, long s, long l )
{
	import std.container.binaryheap;
	
	auto ds = new long[ n ];
	ds[] = long.max;
	ds[ s ] = 0;
	auto us = new bool[ n ];
	auto uc = 0L;
	auto queue = heapify!( ( a, b ) => b[ 1 ] < a[ 1 ] )( new Tuple!( long, long )[ ec ], 0 );
	queue.insert( tuple( s, 0L ) );
	while( !queue.empty )
	{
		auto fi = queue.front[ 0 ];
		auto fd = queue.front[ 1 ];
		queue.popFront();
		
		if( us[ fi ] ) continue;
		us[ fi ] = true;
		uc++;
		if( uc == us.length ) break;
		
		foreach( t; nss[ fi ] )
		{
			auto ti = t[ 0 ];
			auto td = ( ( l < fd % C + t[ 1 ] ) ? fd + C - fd % C : fd ) + t[ 1 ];
			
			if( ds[ ti ] <= td ) continue;
			ds[ ti ] = td;
			queue.insert( tuple( ti, td ) );
		}
	}
	return ds;
}


Measured memory_bytes: 26108
#include <iostream>

using namespace std;

int main(void) {

  int n,k;
  int d;
  int kirai[11]={0};

  cin>>n>>k;
  
  for(int i=0;i<k;i++){
    cin>>d;
    kirai[d]=1;
  }
  
while(true){
  int man=n>=10000?n/10000:10;
  int sen=n>=1000?(n/1000)%10:10;
  int hyaku=n>=100?(n/100)%10:10;
  int juu=n>=10?(n/10)%10:10;
  int ichi=n%10;
  if(kirai[man]||kirai[sen]||kirai[hyaku]||kirai[juu]||kirai[ichi])n++;
  else break;
}

  cout<<n;

  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import collections

N = int(input())
S=[]
l=[]

for i in range(N):
    S.append(input())
c=collections.Counter(S)

m=max(c.values())

for i in c:
    if c[i]==m:
        l.append(i)

l.sort()

for i in l:
    print(i)


Measured memory_bytes: 35568
#include<stdio.h>
#include<string.h>

int main(void) {
        int a,b;
        char str[256];
        while(scanf("%d %d", &a, &b) != EOF) {
                sprintf(str, "%d", a+b);
                printf("%d\n", strlen(str));
        }
        return 0;
}

Measured memory_bytes: 612
# https://atcoder.jp/contests/abc134/submissions/7469219

def main():
    from functools import reduce
    from operator import xor

    N = int(input())

    a = [0]
    a += map(int, input().split())

    for x in reversed(range(1, N // 2 + 1)):
        a[x] = reduce(xor, a[x::x])

    ans = [i for i, x in enumerate(a) if x]
    print(len(ans))
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

using ll = long long;
using namespace std;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}


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

using ll = long long;

int main(){
    string s;
    int count=0;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1])
        count++;
    }
    cout<<count;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

 
class SegmentTree{
public:
    ll N, unit; 
    vector<ll> data, tree;
    SegmentTree(vector<ll> v, ll u){
        unit = u;
        data = v;
        ll n = data.size();
        N = 1;
        while(N<n)N*=2;
        tree = vector<ll>(N*2,u);
        build();
    }
    void build(){rep(i,N)update(i,data[i]);}
    void update(ll i, ll x){
        i += N-1;
        tree[i]=x;
        while(i){
            i = (i-1)/2;
            tree[i]=merge(tree[i*2+1],tree[i*2+2]);
        }
    }
    ll query(ll start, ll end){return query(start, end, 0, 0, N);}
private:
    ll query(ll a, ll b, ll k, ll l, ll r){
        if(r<=a||b<=l)return unit;
        if(a<=l&&r<=b)return tree[k];
        else{
            ll lv = query(a,b,2*k+1,l,(l+r)/2);
            ll rb = query(a,b,2*k+2,(l+r)/2,r);
            return merge(lv,rb);
        }
    }
    ll merge(ll l, ll r){
        return l|r;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    string s;cin>>s;
    int q; cin>>q;
    vector<ll> h(n);
    for(int i=0; i<n; i++){
        h[i] = 1LL<<(s[i]-'a');
    }
    SegmentTree seg(h,0);
    for(int Q=0; Q<q; Q++){
        int que; cin>>que;
        if(que==1){
            int i;cin>>i;i--;
            char c;cin>>c;
            seg.update(i,1LL<<(c-'a'));
        }else{
            int l,r;cin>>l>>r;l--;r--;
            ll ret = seg.query(l,r+1);
            ll ans = 0;
            while(ret){
                ans+=ret%2;
                ret/=2;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 20764
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	int N,K;
	cin >> N >> K;
	if(K==1)cout << 0 << endl;
	else cout << (N-(K-1))-1 << endl;
	return 0;
}

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

int main(void) {
    string S,T,U;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S == U) {
        cout << A-1 << " " << B << "\n";    
    } else if( T == U) {
        cout << A << " " << B-1 << "\n";    
    } else {
        cout << A << " " << B << "\n";    
    }
    return 0;
}


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//
//-----class-----//
class UnionFind{
    public:
        vector<ll> par; //parents
        vector<ll> siz; // sizes of set
        vector<ll> rank; // rank of each element 
    UnionFind(ll n): par(n), siz(n, 1LL), rank(n){
        LREP(i, 0, n) par[i] = i;
    }
    //initialization
    /*
    void init(ll n){
        par.assign(n);
        siz.assign(n, 1LL);
        rank.assign(n);
        LREP(i, 0, n) par[i] = i;
    }
    */

    // find the root of x
    ll find(ll x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    //Unite two set including x or y
    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //Do x and y belong to the same set?
    bool issame(ll x, ll y){
        return find(x) == find(y);
    }

};

ll N;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll L[N];
    LREP(i, 0, N) cin >> L[i];
    sort(L, L + N);
    ll ans = 0;
    LREP(i, 0, N){
        LREP(j, i + 1, N){
            LREP(k, j + 1, N){
                if(L[k] < L[i] + L[j]) ++ans;
            }
        }
    }
    cout << ans << '\n';


}


Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
a = readints()


def func(l):
    if len(l) == n:
        for i in range(len(l)):
            if l[i] % 2 == 0:
                return 1

        return 0
    return func(l+[(a[len(l)])])+func(l+[(a[len(l)]-1)])+func(l+[(a[len(l)]+1)])


print(func([]))


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int x; cin >> x;
	if(x>=30) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: u32 = sc.read();
    let b: u32 = sc.read();
    println!("{} {}", a*b, 2*(a+b));
}



Measured memory_bytes: 5028
N = int(input())
A = list(map(int,input().split()))

bits = [0 for x in range(len(bin(max(A))[2:]))]
for i in range(len(A)):
  ptr = 0
  while A[i] > 0:
    bits[ptr] += A[i] % 2
    A[i] >>= 1
    ptr += 1
for i in range(len(bits)):
  if bits[i] % 2 == 1:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 14120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll dp[410][410];
ll a[410], sa[410];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N; cin >> N;
    rep(i, N) cin >> a[i];
    rep(i, N) sa[i+1] = sa[i] + a[i];

    for(ll w = 2; w <= N; w++) {
        for(ll l = 0; l + w <= N; l++) {
            ll r = l + w;
            dp[l][r] = INF;
            for(ll m = l+1; m < r; m++) {
                ll tmp = dp[l][m] + dp[m][r] + sa[r] - sa[l];
                chmin(dp[l][r], tmp);
            }
        }
    }
    cout << dp[0][N] << endl;
}


Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner scan = new Scanner(System.in);
		int n=3;
		int[] array = new int[n];
		for(int i=0; i<n; i++) {
			array[i] = scan.nextInt();
		}
		Arrays.sort(array);

		System.out.println( ( (array[0]==5 && array[1]==5 )&& array[2]==7 )? "YES":"NO");

	}

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  rep(i, N) cin >> D[i];
  ll sum = 0;
  rep(i, N) rep(j, i) {
    sum += D[i] * D[j];
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  ll x, a, b; cin >> x >> a >> b;
  if(x < (a*(-1)) + b){
    cout <<  "dangerous" << endl;
  }
  else{
    if(a*(-1)+b > 0)cout << "safe" << endl;
    else cout << "delicious" << endl;
  }
  system("pause");
}

Measured memory_bytes: 504