akhauriyash/Code-Regression huggingface dataset:
read
while read t1 x1 y1; do
    (( d = (t1 - t2) - (x1 > x2 ? x1 - x2 : x2 - x1) - (y1 > y2 ? y1 - y2 : y2 - y1),
       d < 0 || d % 2 )) && echo No && exit
    read t2 x2 y2 || break
    (( d = (t2 - t1) - (x1 > x2 ? x1 - x2 : x2 - x1) - (y1 > y2 ? y1 - y2 : y2 - y1),
       d < 0 || d % 2 )) && echo No && exit
done < <(head -n 75000)
echo Yes


Measured memory_bytes: 688
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())

if N == 1:
    print(0)
    exit()

prime = factorization(N)
count = 0
for i in range(len(prime)):
    num, e = prime[i]
    tmp = 1
    while True:
        e -= tmp
        if e >= 0:
            count += 1
        else:
            break
        tmp += 1
        
print(count)

Measured memory_bytes: 9500
import sys
import numpy as np


input = sys.stdin.readline
n, k, q = map(int, input().split())
l = np.zeros(n + 1)
d = {}

for _ in range(q):
    a = int(input())
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

for key, v in d.items():
    l[key] = v

l += k - q

for i in l[1:]:
    if i > 0:
        print("Yes")
    else:
        print("No")

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

using namespace std;

#define MAX 300001
bool is_MSPrime[MAX+1];

void makeMSPrime() {
  fill(is_MSPrime, is_MSPrime+MAX, true);
  is_MSPrime[0] = is_MSPrime[1] = false;
  for(int i=0; i<=MAX; i++) {
    if((i%7 == 1 || i%7 == 6)
       && is_MSPrime[i]) {
      for(int j=i+i; j<=MAX; j+=i) {
	// for(int j=i*i ... ) ...
	is_MSPrime[j] = false;
      }
    }
  }
}

int main() {
  int n;
  
  makeMSPrime();
  
  while(cin >> n && n != 1) {
    cout << n << ":";
    
    for(int i=1; i<=n; i++) {
      if((i%7==1 || i%7==6) && is_MSPrime[i] && n%i==0) cout << " " << i;
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1452
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;


int main(){
    int sq=0,hi=0;
    int x[3];
    char hoge;
    while(cin>>x[0]>>hoge>>x[1]>>hoge>>x[2]){
        if(x[0]==0)break;
        if(x[0]*x[0]+x[1]*x[1]==x[2]*x[2])sq++;
        else
        if(x[0]==x[1])hi++;

    }
    cout<<sq<<endl<<hi<<endl;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> M_list;
    for (int i = 1; i * i <= M; i++) {
        if (M % i != 0) continue;
        M_list.push_back(i);
        if (M / i == i) continue;
        M_list.push_back(M / i);
    }

    int ans = 1;
    for (int i : M_list) {
        if (i <= M / N && i > ans) ans = i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Pond Skater
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_HW = 1000000;
const int dxs[] = { 1 , 0, -1, 0 }, dys[] = { 0, -1, 0, 1 };
const int INF = 1 << 30;

/* typedef */

typedef queue<int> qi;
typedef set<int> si;
typedef vector<si> vsi;

/* global variables */

char s[MAX_HW + 4];
int ds[MAX_HW], tmp[MAX_HW];
vsi hls, vls;

/* subroutines */

inline int xy2p(int x, int y, int w) { return y * w + x; }
inline void p2xy(int p, int &x, int &y, int w) { x = p % w, y = p / w; }

/* main */

int main() {
  int h, w, k;
  scanf("%d%d%d", &h, &w, &k);
  int hw = h * w, maxhw = max(h, w);

  for (int i = 0; i < maxhw; i++) tmp[i] = i;
  for (int y = 0; y < h; y++) hls.push_back(si(tmp, tmp + w));
  for (int x = 0; x < w; x++) vls.push_back(si(tmp, tmp + h));

  int sy, sx, gy, gx;
  scanf("%d%d%d%d", &sy, &sx, &gy, &gx);
  sy--, sx--, gy--, gx--;
  int st = xy2p(sx, sy, w), gl = xy2p(gx, gy, w);

  for (int y = 0; y < h; y++) scanf("%s", s + y * w);
  //puts(s);

  fill(ds, ds + hw, -1);
  ds[st] = 0;
  hls[sy].erase(sx);
  vls[sx].erase(sy);

  qi q;
  q.push(st);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int ux, uy;
    p2xy(u, ux, uy, w);
    //printf("(%d,%d)=%d\n", ux, uy, ds[u]);
    if (u == gl) break;

    int vd = ds[u] + 1;

    si &hlu = hls[uy], &vlu = vls[ux];

    // x-k .. x+k
    si::iterator sit0 = hlu.lower_bound(ux), sit1 = sit0;

    while (sit1 != hlu.end()) {
      int v = xy2p(*sit1, uy, w);
      if (*sit1 <= ux + k && s[v] == '.') {
	ds[v] = vd;
	q.push(v);
	vls[*sit1].erase(uy);
	sit1++;
      }
      else break;
    }

    while (sit0 != hlu.begin()) {
      si::iterator sit = sit0; sit--;
      int v = xy2p(*sit, uy, w);
      if (*sit >= ux - k && s[v] == '.') {
	ds[v] = vd;
	q.push(v);
	vls[*sit].erase(uy);
	sit0--;
      }
      else break;
    }

    if (sit0 != sit1) hlu.erase(sit0, sit1);

    // y-k .. y+k
    sit0 = vlu.lower_bound(uy), sit1 = sit0;

    while (sit1 != vlu.end()) {
      int v = xy2p(ux, *sit1, w);
      if (*sit1 <= uy + k && s[v] == '.') {
	ds[v] = vd;
	q.push(v);
	hls[*sit1].erase(ux);
	sit1++;
      }
      else break;
    }

    while (sit0 != vlu.begin()) {
      si::iterator sit = sit0; sit--;
      int v = xy2p(ux, *sit, w);
      if (*sit >= uy - k && s[v] == '.') {
	ds[v] = vd;
	q.push(v);
	hls[*sit].erase(ux);
	sit0--;
      }
      else break;
    }

    if (sit0 != sit1) vlu.erase(sit0, sit1);
  }

  printf("%d\n", (ds[gl] >= INF) ? -1 : ds[gl]);

  //for (int y = 0; y < h; y++) {
  //for (int x = 0; x < w; x++) printf("%3d", ds[xy2p(x, y, w)]);
  //putchar('\n');
  //}
  return 0;
}


Measured memory_bytes: 128940
#include <cstdio>

using namespace std;

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

typedef long long ll;

//------------------------------------------------------------------------------
int extgcd(int a, int b, int &x, int &y) {
  int ret = a;
  if (b == 0) {
    x = 1;
    y = 0;
  } else {
    ret = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return ret;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

//------------------------------------------------------------------------------
const int N_MAX = 200000;

ll fact[N_MAX + 1];

void init_fact(ll n, ll mod) {
  fact[0] = 1;
  FOR(i, 1, n) fact[i] = fact[i - 1] * i % mod;
}

ll mod_comb(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll a1 = fact[n];
  ll a2 = fact[k];
  ll a3 = fact[n - k];
  return a1 * mod_inverse(a2 * a3 % mod, mod) % mod;
}

//------------------------------------------------------------------------------
const ll MOD = 1000000007;

int H, W, A, B;

void solve() {
  init_fact(H + W, MOD);
  ll ans = 0;
  REP(i, H - A) {
    ll a = mod_comb(i + B - 1, B - 1, MOD);
    ll b = mod_comb(H - i + W - B - 2, W - B - 1, MOD);
    ans = (ans + (a * b % MOD)) % MOD;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d%d%d", &H, &W, &A, &B);
}

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


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

typedef struct{int s,e,c;}Edge;
int par[NUM];
int UF(){for(int i=0;i<NUM;i++)par[i]=-1;}
int Root(int x){if(par[x]<0)return x;else return par[x]=Root(par[x]);}
int Size(int x){return -par[Root(x)];}
bool Same(int x,int y){return Root(x)==Root(y);}
void Unite(int x,int y){x=Root(x);y=Root(y);if(x!=y){if(Size(x)<Size(y))swap(&x,&y);par[x]+=par[y];par[y]=x;}}
int cmpc(const void* a,const void* b){return ((Edge*)a)->c-((Edge*)b)->c;}
int Kruscal(Edge* edge,int n){int i,ans=0;Edge e;qsort(edge,n,sizeof(Edge),cmpc);UF();FOR(i,0,n){e=edge[i];if(!Same(e.s,e.e)){Unite(e.s,e.e);ans+=e.c;}}return ans;}


int main(){
  int A,B,C,i,j,a=0,ans=0;
  scanf("%d%d%d",&A,&B,&C);

  printf("%d\n",MIN(B/A,C));
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int n;
main()
{
	cin>>n;
	int k;
	cin>>k;
	for(int i=0;i<1<<n;i++)
	{
		if(__builtin_popcount(i)-k)continue;
		cout<<i<<":";
		for(int j=0;j<n;j++)if(i>>j&1)cout<<" "<<j;
		cout<<endl;
	}
}



Measured memory_bytes: 3100
#include<cassert>
#include<random>
#include<deque>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

void print(__int128 x) {
    string o;
    while (x > 0) {
	o += '0' + x % 10;
	x /= 10;
    }
    reverse(o.begin(), o.end());
    if (o.empty()) o = "0";
    puts(o.c_str());
}
int N;
LL X;
LL A[200011];
LL sums[200011];

void MAIN() {
    scanf("%d%lld", &N, &X);
    REP (i, N) scanf("%lld", A+i);
//    N = 200000;
//    X = 1000000000;
//    mt19937 engine(3);
//    REP (i, N) A[i] = engine() % 1000000000;
//

    sort(A, A+N);
    REP (i, N) sums[i+1] = sums[i] + A[i];

    LL ans = 1LL<<60;
    for (int block=1; block<=N; block++) {
	int r = N, l = r - block;
	__int128 tmp = (sums[r]-sums[l]) * 5 + X * block;;
	r = l; l -= block;
	for (LL c=5; r>0; c+=2) {
	    amax(l, 0);
	    tmp += __int128(sums[r]-sums[l]) * c;
	    r = l;
	    l -= block;
	}
	if (ans > tmp) ans = tmp;
    }
           
    ans += X * N;
    printf("%lld\n", (LL)ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int n,m,q;
vi A,B,C,D;
int ans;
void dfs(vi X){

  if(sz(X) == (n+1)){
    int now=0;
    rep(i,q){
      if(X[B[i]] - X[A[i]] == C[i]) now+=D[i];
      maxs(ans,now);
    }
    return;
  }

  X.push_back(X.back());
  while(X.back()<=m){
    dfs(X);
    X.back()++;
  }
}
int main() {
  cin>>n>>m>>q;
  A = B = C = D = vi(q);
  rep(i,q){
    cin>>A[i]>>B[i]>>C[i]>>D[i];
  }
  dfs(vi(1,1));
  print(ans);
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void dfsfillorder (vector<int> adj[],stack<int> &s,int u,bool visited[])
{
	if(visited[u])
	return ;
	else
	{visited[u]=true;

	for(int i=0;i<adj[u].size();i++)
	{
		dfsfillorder(adj,s,adj[u][i],visited);
	}
	//cout<<u<<" ";
		s.push(u);
}
}

void rev(vector<int> adjr[],vector<int> adj[],int v)
{for(int i=0;i<v;i++)
	{for(int j=0;j<adj[i].size();j++)
	adjr[adj[i][j]].push_back(i);
}
}

void dfsutil(vector<int> adj[],stack<int> &s,int x,bool visited[],vector<int> &vx)
{
	if(!visited[x])
	{vx.push_back(x);
		visited[x]=true;
		for(int i=0;i<adj[x].size();i++)
		{
			dfsutil(adj,s,adj[x][i],visited,vx);
		}
		
	}
	
}


int main()
{
io
stack<int> s;
	int v;
	cin>>v;
	vector<int> adj[v];
	int a,b;
int m,k;
cin>>m>>k;
for(int i=0;i<m;i++)
{
	cin>>a>>b;
	a--;
	b--;
	adj[a].push_back(b);
	adj[b].push_back(a);
}
int ind[v];
for(int i=0;i<v;i++)
ind[i]=adj[i].size();

vector<pair<int,int> > ed;

for(int i=0;i<k;i++)
{
	cin>>a>>b;
a--;
	b--;
	ed.push_back(make_pair(a,b));

//	adj[a].push_back(b);
	//adj[b].push_back(a);	
	
}



int pars[v];
int l=1;
bool visited[v]={false};
	for(int i=0;i<v;i++)
	dfsfillorder(adj,s,i,visited);

	
	vector<int> adjr[v];
	rev(adjr,adj,v);

	for(int i=0;i<v;i++)
	visited[i]=false;
	int ans[v];
	
	while(!s.empty())
	{
		int x=s.top();
		s.pop();
		if(!visited[x])
		
		{
		vector<int> vx;
		dfsutil(adjr,s,x,visited,vx);
		
		
		
		
	for(int i=0;i<vx.size();i++)
	{
		
		ans[vx[i]]=vx.size()-1-ind[vx[i]];
		pars[vx[i]]=l;
	}
	l++;
		}	}
		
		for(int i=0;i<k;i++)
		{
			int a=ed[i].first;
			int b=ed[i].second;
			if(pars[a]==pars[b])
			{
				ans[a]--;
				ans[b]--;
			}
		}
		
		
	
	for(int i=0;i<v;i++)
	cout<<ans[i]<<" ";
			
		return 0;
}

Measured memory_bytes: 15732
def main():
    S = input()
    Q = int(input())
    flip = False
    head = ''
    tail = ''
    for _ in range(Q):
        q = input()
        if q == '1':
            flip = not flip
            head, tail = tail, head
        else:
            _, f, c = q.split()
            if f == '1':
                head += c
            else:
                tail += c
    if flip:
        S = S[::-1]
    return head[::-1] + S + tail
   

print(main())


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

using namespace std;

int w, d;

int main() {
  while (true) {
    cin >> w >> d;
    if (w == 0 && d == 0) break;
    vector<int> front(w), side(d);
    for (int i = 0; i < w; i++) cin >> front[i];
    for (int i = 0; i < d; i++) cin >> side[i];

    for (int i = 0; i < w; i++) {
      for (int j = 0; j < d; j++) {
        if (side[j] == front[i]) {
          side[j] = 0;
          break;
        }
      }
    }
    int res = 0;
    for (int i = 0; i < w; i++) res += front[i];
    for (int i = 0; i < d; i++) res += side[i];

    cout << res << endl;
  }

  return 0;
}


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

int main(void) {
	string n;
	int sum = 0;
	cin >> n;
	for (int i = 0; i < n.length(); i++) {
		sum = sum + (int)(n[i] - '0');
	}
	cout << (atoi(n.c_str()) % sum == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
    #ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    long long h, n; cin >> h >> n;
    long long arr[n], sum = 0;
    repeat(n) cin >> arr[i], sum += arr[i];
    cout << (sum>=h ? "Yes" : "No");

    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2);
    ans *= ans; /// ans = (ans%mod)*(ans%mod);

    if(power&1) return ans*base; /// (ans%mod)*(base%mod);
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(n+1)
        if(isPrime[i]) c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    A,B=map(int,input().split())
    print((A+B)%24)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38548
N = int(input())
count = 0

for i in range(N):
    D_1, D_2 = map(int, input().split())
    if(D_1 == D_2):
        count += 1
        if(count >= 3):
            break
        else:
            pass
    else:
        count = 0

if(count >= 3):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
#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)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

int main() {
  string s;
  cin >> s;

  ll l = 0;
  ll r = (ll)s.size() - 1;

  ll ans = 0;
  while (l < r) {
    if(s[l] == 'x'){
      if(s[r] == 'x') {
        l++;
        r--;
      } else {
        ans++;
        l++;
      }
    } else {
      if(s[r] == 'x'){
        ans++;
        r--;
      } else{
        if(s[l] != s[r]){
          puts("-1");
          return 0;
        } else {
          l++;
          r--;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
 
function main(input) {
  var temp = input.split(' ');
  var a = parseInt(temp[0]);
  var b = parseInt(temp[1]);
  if (a < b) {
    console.log('a < b');
  } else if (a == b) {
    console.log('a == b');
  } else if (a > b) {
    console.log('a > b');
  } else {
    return new Error('Something wrong.');
  }
}

main(x);


Measured memory_bytes: 15092
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <algorithm>

using namespace std;



int main(){
	string a;
	string ai;
	int L;
	while (1){
		cin >> a >> L;
		if (a[0] == '0' && L == 0) break;
		map<string, int> m;
		m[a] = 0;
		int j = 1;
		ai = a;
		//??????????????????????????§?????????
		while (1){
			string max, min;
			stringstream ss;
			sort(ai.begin(), ai.end());
			min = ai;
			while (L > min.size()) min.insert(min.begin(),'0');
			sort(ai.rbegin(), ai.rend());
			max = ai;
			while (L > max.size()) max += '0';
			//?¨????
			int maxI, minI;
			ss.clear();
			ss << max;
			ss >> maxI;
			ss.clear();
			ss << min;
			ss >> minI;
			int sum = maxI - minI;
			//??????&0??°???
			ai.clear();
			ss.clear();
			ss << sum;
			ss >> ai;
			while (L > ai.size()) ai.insert(ai.begin(),'0');
			//??????????????????????????¢???
			if (m.find(ai) == m.end()){
				m[ai] = j;
				j++;
			}
			else{
				int aiI;
				ss.clear();
				ss << ai;
				ss >> aiI;
				ss.clear();
				cout << m[ai] << " " << aiI << " " << j - m[ai] << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1256
N, K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
MOD = 10**9 + 7


def dot(M1, M2, mod=10**9+7):
  n = len(M1)
  res = [[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        res[i][j] += M1[i][k] * M2[k][j] % MOD
  
  return res


def power(M, k, mod=10**9+7):
  if k == 1:
    return M
  elif k%2 == 0:
    return power(dot(M, M, mod), k//2)
  else:
    return dot(M, power(dot(M, M, mod), k//2), mod)


trans = power(A, K) 

ans = 0
for t in trans:
  ans += sum(t)%MOD
  ans %= MOD

print(ans)

Measured memory_bytes: 72796
from bisect import bisect_right
n = int(input())
a = [int(x) for x in input().split()]

cum = [0]
for x in a:
  cum.append(cum[-1]+x)

ans = 10**30
for i in range(2,n-1):
  for z in range(4):
    b = cum[bisect_right(cum, cum[i]//2)-1+(z&1)]
    c = cum[i]-b
    d = cum[bisect_right(cum, (cum[n]-cum[i])//2+cum[i])-1+(z>>1&1)] - cum[i]
    e = cum[n] - (b+c+d)
    ans = min(ans, max(b,c,d,e) - min(b,c,d,e))
  
print(ans)
  
  

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

int main(){
    ll n;
    cin >> n;
    ll h[n];
    for(ll i = 0; i < n; i++){
        cin >> h[i];
    }

    ll target = h[n-1];
    bool judge = true;
    int ans = 0;
    if(n > 2){
        for(ll i = n-1; i > 0; i--){
        if(h[i-1] - h[i] > 1){
            judge = false;
            break;
        }
        else if(h[i-1] - h[i] == 1){
            h[i-1] -= 1;
        }
    }
    }

    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
    ll a, b;
    cin >> a >> b;
    if(a <= 5)
        cout << 0 << endl;
    else if(a >= 6 && a <= 12)
        cout << b/2 << endl;
    else
        cout << b << endl;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split())) 

v.sort()

bans = v[0]
ans = 0
for i in range(len(v)-1):
  ans = ((bans + v[i+1])/2)
  bans = ans
  #print("ans: " + str(ans) + "bans: " + str(bans))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B;
    cin >> A >> B;
    int ans = 0;

    if(A >= 13) {
        ans = B;
    } else if(A >= 6 && A <= 12) {
        ans = B / 2;
    } else if(A <= 5) {
        ans = 0;
    }
    cout << ans << endl;
}


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

int main(){
  ll n;
  cin >>n;
  bool nine = true;
  int c = 0;
  while(n>=10){
    if(n%10!=9) nine = false;
    n/=10;
    c++;
  }
  int ans = n+c*9;
  if(nine) cout << ans << endl;
  else cout << ans-1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if(a<=b) cout<<a<<endl;
	else cout<<a-1<<endl;
}


Measured memory_bytes: 256
'use strict'

function main(s) {
  s = s.split('\n');

  const a = s[0].split('');
  const b = s[1].split('');
  const c = s[2].split('');

  const game = (turn) => {
    if (turn === 'a') return game(a.shift()) || 'A';
    if (turn === 'b') return game(b.shift()) || 'B';
    if (turn === 'c') return game(c.shift()) || 'C';
  }

  const winner = game('a');
  console.log(winner);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
// Book Replacement
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1258

#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

#define ALL(v) (v).begin(),(v).end()

using namespace std;

int M, C, N;
vector<vector<int>> desks;
vector<queue<int>> students;

bool is_full(int i) {
    return desks[i].size() == C;
}

int move_book(int book_num) {
    for (int i = 1; i < M; ++i) {
        if (!is_full(i)) {
            desks[i].push_back(book_num);
            return i + 1;
        }
    }
    return M + 1;
}

int lend_book(int book_num) {
    for (int i = 0; i < M; ++i) {
        if (find(ALL(desks[i]), book_num) != desks[i].end()) {
            desks[i].erase(find(ALL(desks[i]), book_num));
            return i + 1;
        }
    }
    return M + 1;
}

int return_book(int book_num) {
    int cost = 0;

    if (!is_full(0)) {
        desks[0].push_back(book_num);
        return 1;
    }

    cost += move_book(book_num);

    int old_book_num = desks[0].front();
    cost += 1;
    desks[0].erase(find(ALL(desks[0]), old_book_num));
    cost += move_book(old_book_num);

    for (int i = 1; i < M; ++i) {
        if (find(ALL(desks[i]), book_num) != desks[i].end()) {
            desks[i].erase(find(ALL(desks[i]), book_num));
            cost += i + 1;
            break;
        }
        if (i == M-1) cost += M + 1;
    }

    if (M == 1) cost += M + 1;
    desks[0].push_back(book_num);
    cost += 1;

    return cost;
}

int main() {
    while (true) {
        cin >> M >> C >> N;
        if (!M && !C && !N) break;
        desks.assign(M, vector<int>());
        students.assign(N, queue<int>());

        int max_turn = 0;
        for (int nth = 0; nth < N; ++nth) {
            int K;
            cin >> K;
            for (int i = 0; i < K; ++i) {
                int book_num;
                cin >> book_num;
                students[nth].push(book_num);
            }
            max_turn = max(max_turn, (int)students[nth].size());
        }

        int total_cost = 0;
        for (int turn = 0; turn < max_turn; ++turn) {
            for (int nth = 0; nth < N; ++nth) {
                if (students[nth].empty()) continue;
                int book_num = students[nth].front();
                students[nth].pop();
                total_cost += lend_book(book_num); 
                total_cost += return_book(book_num);
            }
        }

        cout << total_cost << endl;
    }
}

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


int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    int t;
    t = k;
    bool f = 0;
    rep(i, 1000){
        if(t >= a && t <= b){
            f = 1;
            break;
        }
        t += k;
    }
    if(f){
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 16 //1000 + " " + 1000 + " " + 1000 + \n + \0

int cmp(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}
int main() {
    char line[SIZE];
    int n_lines = atoi(fgets(line, SIZE, stdin));
    for (int i = 0; i < n_lines; i++) {
        fgets(line, SIZE, stdin);
        char *str;

        int num[3];
        str = strtok(line, " ");
        num[0] = atoi(str);
        str = strtok(NULL, " ");
        num[1] = atoi(str);
        str = strtok(NULL, " ");
        num[2] = atoi(str);

        qsort(num, 3, sizeof(int), cmp);

        if (num[2] * num[2] == num[0] * num[0] + num[1] * num[1]) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}



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

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

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll N;
ll A[202020];

ll i, j, k;

int main(){
    scanf("%lld", &N);
    rep(i,0,N){
        scanf("%lld", &A[i]);
    }
    ll ans = 0;
    j = 0;
    rep(i,0,N){
        ans += A[i] * j;
        ans %= MOD;
        j += A[i];
        j %= MOD;
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5392
def popcount(x)
    p = 0
    while x > 0
        x &= x - 1
        p += 1
    end
    return p
end

N = gets.to_i
X = gets.to_i(2)
ans = Array.new(N,0)

p0 = 0
N.times do |i|
    p0 += 1 if X[i] == 1
end


x0_mod_pp1 = X % (p0+1)
x0_mod_pm1 = X % (p0-1) if p0 != 1

N.times do |i|
    next if X ^ (1 << i) == 0
    pi = p0
    r = 0
    if X[i] == 1
        pi -= 1
        r = (x0_mod_pm1 - 2.pow(i, pi) + pi) % pi
        ans[i] += 1
    else
        pi += 1
        r = (x0_mod_pp1 + 2.pow(i, pi)) % pi
        ans[i] += 1
    end
    
    # r = xi
    # p r
    while r != 0 do
        pi = popcount(r)
        r = r % pi
        ans[i] += 1
    end
end
puts ans.reverse

Measured memory_bytes: 124660
#include<bits/stdc++.h> //ABC 111_a
using namespace std;
int main(){
	char n[5];
	cin>>n;
	for(int i=0;i<3;i++){
		if(n[i]=='1') 
			cout<<'9';
		else
			cout<<'1';
	}
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(3 * N);
  for (int &x: a) cin >> x;
  sort(begin(a), end(a));
  long long ans{};
  for (int i = 0; i != N; ++i) ans += a[N+i*2];
  cout << ans << endl;
}


Measured memory_bytes: 4572
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

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

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

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N, K = map(int, sys.stdin.readline().split())
    L = list(map(int, sys.stdin.readline().split()))

    ans = 10 ** 10
    for i in range(N - K + 1):
        left = i
        right = left + K - 1
        l_search = abs(L[left]) + abs(L[left] - L[right])
        r_search = abs(L[right]) + abs(L[left] - L[right])
        ans = min(ans, min(l_search, r_search))
    print(ans)

Measured memory_bytes: 16292
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

//DEBUG_OUT("----\n");

void func(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

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

    int n = 0;
    int tmp = -1;
    vector<int> hist;
    for(int i=0; i<N; i++){
        if(tmp != A[i]){
            tmp = A[i];
            hist.push_back(1);
            n++;
        }else{
            hist[n-1]++;
        }
    }

    sort(hist.begin(), hist.end());
    int ans = 0;
    int i = 0;
    while(n > K){
        ans += hist[i];
        i++;
        n--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10;
int po[N];
int cnt[N];
signed main()
{
	long long ans=0;
	int n,p;
	string a;
	cin>>n>>p>>a;
	int now=0;
	if(p%2&&p%5){
		po[0]=1;
		for(int i=1;i<=n;i++){
			po[i]=10*po[i-1]%p;
		}
		cnt[0]=1;
		for(int i=n-1;i>=0;i--){
			now=now+po[n-1-i]*(a[i]-'0')%p;
			now%=p;
			ans+=cnt[now];
			cnt[now]++;
		}
		cout<<ans;
	}
	else {
		for(int i=0;i<n;i++){
			if((a[i]-'0')%p==0){
				ans+=i+1;
			}
		}
		cout<<ans;
	}
}

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

int evenColor(string S) {
    int res = 0;
    for (int i = 0; i < (int)S.size(); i++) {
        if (i % 2 != 0 && S.at(i) != '0') {
            S.at(i) = '0'; res++;
        } 
        if (i % 2 == 0 && S.at(i) != '1') {
            S.at(i) = '1'; res++;
        } 
    }
    return res;
}

int oddColor(string S) {
    int res = 0;
    for (int i = 0; i < (int)S.size(); i++) {
        if (i % 2 == 0 && S.at(i) != '0') {
            S.at(i) = '0'; res++;
        }
        if (i % 2 != 0 && S.at(i) != '1') {
            S.at(i) = '1'; res++;
        }
    }
    return res;
}

int main() {
    string S; cin >> S;
    cout << min(evenColor(S), oddColor(S)) << endl;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) \
    sort(all((x)));    \
    (x).resize(unique(all((x))) - (x).begin())
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | ";
    __f(comma + 1, args...);
}

ll max(ll a, ll b) { return (a > b ? a : b); }
ll min(ll a, ll b) { return (a < b ? a : b); }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
void yes_or_no(ll x)
{
    if (x)
        cout << "YES\n";
    else
        cout << "NO\n";
}
const ll N = 1e6;
const ll MOD = 1e9 + 7;

ll add(ll x, ll y)
{
    ll ans = x + y;
    return (ans >= MOD ? ans - MOD : ans);
}
ll mul(ll x, ll y)
{
    ll ans = x * y;
    return (ans >= MOD ? ans % MOD : ans);
}
ll sub(ll x, ll y)
{
    ll ans = x - y;
    return (ans < 0 ? ans + MOD : ans);
}

vector<ll> fac, fac_inverse, num_inverse;

void preprocess()
{
    fac = fac_inverse = num_inverse = vector<ll>(N + 1);
    num_inverse[0] = num_inverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        num_inverse[i] = num_inverse[MOD % i] * (MOD - MOD / i) % MOD;
    fac_inverse[0] = fac_inverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        fac_inverse[i] = (num_inverse[i] * fac_inverse[i - 1]) % MOD;
    fac[0] = 1;
    for (ll i = 1; i <= N; i++)
        fac[i] = (fac[i - 1] * i) % MOD;
}

ll power(ll x, ll y)
{
    ll ans = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            ans = (ans * x) % MOD;

        y = y >> 1;
        x = (x * x) % MOD;
    }
    return ans;
}

ll modInverse(ll n)
{
    return power(n, MOD - 2);
}

ll nCr(ll n, ll r)
{
    if (r == 0)
        return 1;

    return mul(mul(fac[n], fac_inverse[r]), fac_inverse[n - r]);
}
ll cal(ll n)
{
    ll ans = mul(n, n - 1);
    //   ans = mul(ans, power(2, MOD - 2));
    return ans;
}
void solve_test()
{
    preprocess();
    ll ans = 0;
    ll n;
    cin >> n;
    if (n < 1)
        ans = mul(cal(n), power(10, n - 2));
    if (n < 1)
    {
        ans = mul(nCr(n, 2), 2);
        ans = mul(ans, power(10, n - 2));
        ll temp = ans;
        ans = mul(nCr(n, 2), 2);
        ans = mul(ans, power(10, n - 2));
        ans = add(ans, temp);
    }
    ans = power(10, n);
    for (ll i = 0; i < n; i++)
    {
        ans = sub(ans, mul(2, mul(power(8, i), power(9, n - i - 1))));
    }
    ans = sub(ans, power(8, n));
    cout << ans << "\n";
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    // cin >> t; while (t--)
    solve_test();
    return 0;
}


Measured memory_bytes: 26660
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long mod = 1_000_000_007;
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] a = new boolean[n+1];
        a[0] = false;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            a[x] = true;
        }
        long[] dp = new long[n+1];
        dp[0] = 1;
        if(!a[1]) dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            if(!a[i])dp[i] += dp[i-1] + dp[i-2];
            dp[i] %= mod;
        }
        System.out.println(dp[n]);
        sc.close();

    }

}


Measured memory_bytes: 48588
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define eps 0.0000000000000000001

int n,a[100005],k;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> k;
    cout << (n-1+k-2)/(k-1);
}


Measured memory_bytes: 256
<?php

while(1){

	list($H,$W)=explode(" ",trim(fgets(STDIN)));

	if($H==0 && $W==0){

		break;
	}

	for($i=1;$i<=$H;$i++){

		for($j=1;$j<=$W;$j++){

			if($j==$W){

				print "#\n";
			}else{

				print "#";

			}
		}
	}

	print "\n";

}

Measured memory_bytes: 15320
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll k;
	cin>>k;
	ll c=1;
	ll df = 1;
	while(k)
	{
		cout<<c<<"\n";
		k--;
		while(1)
		{
			ll ck = c + df;
			ll t=ck;
			ll sk=0;
			while(t)
			{
				sk = sk+t%10;
				t/=10;
			}
			ll ck2 = c + 10*df;
			t=ck2;
			ll sk2 = 0;
			while(t)
			{
				sk2 = sk2+t%10;
				t/=10;
			}
			if(ck*sk2<ck2*sk)
			{
				c = ck;
				break;
			}
			else
			{
				df *= 10;
			}
		}
	}
	return 0;
}

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

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int find(int k) {
        if (data[k] < 0) return k;
        return (data[k] = find(data[k]));
    }

    int size(int k) { return (-data[find(k)]); }
};

int main() {
    int n, q;
    cin >> n >> q;
    UnionFind U(n);
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0)
            U.unite(x, y);
        else
            cout << U.same(x, y) << endl;
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i =a;i<b;i++)
using namespace std;
int main(){	
	int k;
	string s;
	cin>>k>>s;
	if(s.length()<=k)cout<<s<<"\n";
	else{
		l(i,0,k)
		cout<<s[i];
		cout<<"...\n";
	}
	
}

Measured memory_bytes: 3636
N, Y = gets.split.map(&:to_i)

x = (Y / 1000) - N

N.downto(0) do |a|
  z = x - a * 9
  next if z < 0
  next if z % 4 > 0
  b = z / 4
  next if a + b > N
  c = N - a - b
  puts "#{a} #{b} #{c}"
  exit 0
end

puts '-1 -1 -1'


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string a;

ll solve() {
    ll res = 1;
    ll cnt[26];
    memset(cnt, 0, sizeof(cnt));

    for (int i = 1; i <= (int)a.size(); i++) {
        res += cnt[a[i-1]-'a'];
        for (char c = 'a'; c <= 'z'; c++) {
            if (c == a[i-1]) continue;
            cnt[c-'a']++;
        }
    }
    
    return res;
}

void input() {
    cin >> a;
}

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

    input();
    cout << solve() << endl;
}


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

int main(){
  long long int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  
  sort(H.begin(), H.end());
  reverse(H.begin(), H.end());
  long long int sum = 0;
  for(int i = 0; i < N; i++){
    if(i < K) H.at(i) = 0;
    sum += H.at(i);
  }
  
  cout << sum;
  return 0;
}

Measured memory_bytes: 1024
#pragma comment(linker, "/stack:200000000")
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
#define y1 sfasfd 
using namespace std;
 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;
const int N = 4e5 + 123;
int n , t , p[5][N] , Sz[5][N];
int u[N] , v[N];
int get(int t , int a){
	if(a == p[t][a])
		return a;
	return p[t][a] = get(t , p[t][a]);	
}
void unite(int t , int a , int b){
	a = get(t , a) , b = get(t , b);
	if(a == b)
		return;
	if(Sz[t][a] < Sz[t][b])
		swap(a , b);
	Sz[t][a] += Sz[t][b];
	p[t][b] = a;
	return;
}

main(){
	int n , l , k;
	scanf("%d%d%d" , &n , &k , &l);	

	for(int i = 1 ; i <= n ;i++)
		p[1][i] = p[2][i] = p[3][i] =i , Sz[1][i] = Sz[2][i] = Sz[3][i] = 1;
	
	for(int i = 1 ; i <= k ; i++){
		scanf("%d%d" , &u[i] , &v[i]);
		unite(1 , u[i] , v[i]);
	}
	for(int j = 1 , i = k + 1; j <= l ; j++ , i++){
		scanf("%d%d" , &u[i] , &v[i]);
		unite(2 , u[i] , v[i]);
	}
	map < pii , int > cnt;
	for(int i = 1 ; i <= n ; i++){
		cnt[{get(1 , i) ,get(2 , i)}]++;
	}
	for(int i = 1; i <= n ; i++){
		printf("%d " , cnt[{get(1 , i) ,get(2 , i)}]);
	}
	
}

Measured memory_bytes: 27648
n,m=map(int,input().split())
b=[]
b_clone=[]

for i in range(m):
    t=int(input())
    b.append(t)
    b_clone.append(t)


ans_list=[1]

if len(b)!=0 and b[0]==1:
    b.pop(0)
    ans_list.append(0)
else:
    ans_list.append(1)

for i in range(2,n+1):
    if len(b)!=0 and i==b[0]:
        b.pop(0)
        ans_list.append(0)
        continue
    else:
        ans_list.append((ans_list[i-2]+ans_list[i-1])%1000000007)

print(ans_list[n])


Measured memory_bytes: 8284
#include<stdio.h>
int main(void) {
	long long  int  a, b, k;
	scanf("%lld %lld %lld", &a, &b, &k);
	if (a <= k) {
		k -= a;
		a = 0;
		
		if (b <= k) {
			b = 0;
		}
		else {
			b -= k;
		}
	}
	else {
		a -= k;
	}
	printf("%lld %lld", a, b);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128