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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

namespace
{
	struct UnionFind
	{
		UnionFind(int n) : par(n), rank(n, 0), ct(n,1) {
			iota(par.begin(), par.end(), 0);
		}
		int Find(int i)
		{
			if (par[i] == i)
				return i;
			else
				return par[i] = Find(par[i]);
		}
		void Unite(int i, int j)
		{
			i = Find(i);
			j = Find(j);
			if (i == j)
				return;
			if (rank[i] < rank[j])
			{
				par[i] = j;
				ct[j] += ct[i];
			}
			else
			{
				par[j] = i;
				ct[i] += ct[j];
				if (rank[i] == rank[j])
					++rank[i];
			}
		}
		ll Count(int i)
		{
			return ct[Find(i)];
		}
		vector<int> par;
		vector<int> rank;
		vector<ll> ct;
	};

}


void ABC120D()
{
	int N, M;
	cin >> N >> M;
	UnionFind uf(N);
	vector<pair<int, int> > edges(M);
	for (int i = 0; i < M; ++i)
	{
		int A, B;
		cin >> A >> B;
		--A; --B;
		edges[i] = { A,B };
	}
	vl counts(M+1);
	counts[0] = 0;
	int i = 1;
	for (auto p = edges.rbegin(); p != edges.rend(); ++p, ++i)
	{
		int A = p->first;
		int B = p->second;
		ll x1 = uf.Count(A);
		ll x2 = uf.Count(B);
		if (uf.Find(A) != uf.Find(B))
		{
			counts[i] = counts[i-1] + x1 * x2;
			uf.Unite(A, B);
		}
		else
		{
			counts[i] = counts[i - 1];
		}
	}
	ll maxCt = counts[M];
	for (int i = M - 1; i > -1; --i)
	{
		cout << maxCt - counts[i] << endl;
	}

}


int main()
{
	ABC120D();
	return 0;
}

Measured memory_bytes: 4480
# -*- coding: utf-8 -*-
import datetime
base_date = datetime.datetime(2019, 4, 30, 23, 59, 59)
# データ数の取込み
date_str = input()
in_date = datetime.datetime.strptime(date_str, "%Y/%m/%d")
if in_date <= base_date:
  print( "Heisei" )
else:
  print( "TBD" )

Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    auto dist = [&](int x1, int y1, int x2, int y2) {
        int dx = x1 - x2;
        int dy = y1 - y2;
        return sqrt(dx*dx + dy*dy);
    };

    vi perm(n);
    iota(perm.begin(), perm.end(), 0);
    double ans = 0;
    int cnt = 0;
    do {
        cnt++;
        double sum = 0;
        rep(i, n-1) {
            sum += dist(x[perm[i+1]], y[perm[i+1]], x[perm[i]], y[perm[i]]);
        }
        ans += sum;
    } while(next_permutation(perm.begin(), perm.end()));

    ans /= cnt;
    cout << fixed << setprecision(10) << ans << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (size_of(x) < size_of(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int size_of(int x) { return -parent[root(x)]; }
	bool is_root(int x) { return parent[x] < 0; }
};


signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, R; cin >> N >> R;
	vector<int>p(N); rep(i, 0, N) { cin >> p[i]; p[i]--; }
	vector<int>q(N);
	rep(i, 0, N) {
		q[p[i]] = i;
	}

	UnionFind uf(N);
	rep(i, 0, N) {
		uf.unite(i, q[i]);
	}
	vector<int>v;
	rep(i, 0, N) {
		if (uf.is_root(i)) {
			v.eb(uf.size_of(i));
		}
	}

	map<int, int>mp;
	for (auto x : v) {
		mp[x]++;
	}

	chmin(R, N - R);
	vector<int>dp(R + 1);
	dp[0] = true;
	for (auto yy : mp) {
		int i = 0;
		while (yy.second) {
			int m=min(yy.second, 1ll << i);
			i++;
			yy.second -= m;
			int x = yy.first*m;
			rrep(j, x, dp.size()) {
				chmax(dp[j], dp[j - x]);
			}
		}
	}
	Yes(dp.back());


	return 0;
}




Measured memory_bytes: 14036
import sys

input = sys.stdin.readline

def main():
    ans = float('INF')
    n, m, x = map(int, input().split())
    c = [0]*n
    a = [[0 for _ in range(m)]for _ in range(n)]
    for i in range(n):
        temp = list(map(int, input().split()))
        c[i] = temp[0]
        for j in range(m):
            a[i][j] = temp[j+1]
    for bit in range(1<<n):
        acquired = True
        cost = 0
        d = [0]*m
        for i in range(n):
            if (bit & (1 << i)):
                cost += c[i]
                for j in range(m):
                    d[j] += a[i][j]
        for k in range(m):
            if d[k] < x:
                acquired = False
        if acquired:
            ans = min(ans, cost)
    if ans == float('INF'):
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9272
import java.util.*;
public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];

    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }
    sc.close();

    int count = 0;
    
    for(int i=1; i<n-1; i++){
      int p1 = p[i-1];
      int p2 = p[i];
      int p3 = p[i+1];
      if ((p1 < p2) && (p2 < p3)){
        count++;
      } else if ((p3 < p2) && (p2 < p1)) {
        count++;
      }
    }

    System.out.println(count);

  }
  
}

Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll R;
    cin>>R;
    if(R<1200)cout<<"ABC";
    else if(R<2800)cout<<"ARC";
    else cout<<"AGC";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

  int start = B * 10;
  for (int i = 0; i < 10; i++) {
    double target = (double)(start + i);
    double d = target * 0.08;
    int check = (int)d;
    if (check == A) {
      cout << start + i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


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

using namespace std;

int main()
{
    long long n, h, x=0;
    int k;
    priority_queue < long long > p;
    cin >> n >> k;
    for(int i=0; i<n; i++)
    {
        cin >> h;
        p.push(h);
    }
    for(int i=0; i< k; i++)
    {
        p.pop();
    }
    for(int i=0; i< (n-k); i++)
    {
        x+=p.top();
        p.pop();
    }
    cout << x;
    return 0;
}


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

using namespace std;
using int64 = long long int;

int main()
{
    double a, b;
    cin >> a >> b;

    double average = (a + b) / 2;
    if ((int) average == average)
    {
        cout << (int) average << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int n;
    cin >> n;
    u64 f[n + 1];
    f[0] = f[1] = 1;
    rep (i, n - 1)
    {
        f[i + 2] = f[i + 1] + f[i];
    }

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



Measured memory_bytes: 3140
import collections

n = int(input())

S = []
ans = []
key = []
max = 0
for i in range(n):
    s = input('')
    S.append(s)
c = collections.Counter(S)
C = sorted(c.items(), key = lambda x:x[1],reverse = True)
#keys = c.keys()
for k in c.keys():
    key.append(k)
for i in range(len(C)):
    max = C[0][1]
    if c[key[i]] == max:
        ans.append(key[i])
ans = sorted(set(ans))
for i in ans:
    print(i)

Measured memory_bytes: 61680
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int N,L;
    cin >> N >> L;
    vector<int>a(N);
    vector<int>ans;
    int sum = 0,res = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(i) {
            if(sum < a[i]+a[i-1]) {
                res = i;
                sum = a[i]+a[i-1];
            }
        }
    }
    if(sum < L) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(int i = 1; i < res; i++) {
        cout << i << endl;
    }
    for(int i = N-1; i >= res; i--) {
        cout << i << endl;
    }
}

Measured memory_bytes: 4056
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			IntStream.range(0, n).forEach(i -> scanner.nextInt());
			System.out.println((n + k - 3) / (k - 1));
		}
	}
}


Measured memory_bytes: 58800
#include <stdio.h>
#include <stdlib.h>
#define u_int unsigned int
int main(void){
  struct ID{
    u_int id;
    u_int unit;
    u_int number;
  };
  u_int n,x,y,k,i,p,q,count;
  struct ID *member;
  u_int *uriage;
  while(scanf("%d",&n)&&n!=0){
    member=(struct ID *)calloc(n,sizeof(struct ID));
    uriage=(u_int *)calloc(n,sizeof(u_int));
    for(k=0;k<n;k++){
      scanf("%u %u %u",&((member+k)->id),&((member+k)->unit),&((member+k)->number));
      *(uriage+k)=((member+k)->unit)*((member+k)->number);
    }
    for(x=0;x<n;x++){
      for(y=x+1;y<n;y++){
	if(((member+y)->id)==(member+x)->id){
	  *(uriage+x)+=*(uriage+y);
	  *(uriage+y)=0;
	}
      }
    }
    count=0;
    for(k=0;k<n;k++){
      if(*(uriage+k)>=1000000){
	printf("%u\n",(member+k)->id);
	count++;
      }
    }
    if(count==0) printf("NA\n");
    free(member);
  }
  return 0;
}
  
  
  
  

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

int latte[100002],dp[100002];

int main(){
	int N,L,ans=0;
	cin>>N>>L;
	for(int i=1;i<=N;i++){
		cin>>latte[i];
		dp[i]=L-latte[i];
	}
	for(int i=1;i<=N;i++){
		if(latte[i]<latte[i-1]) dp[i]=dp[i-1]+(L-latte[i]);
	}
	for(int i=N;i>=1;i--){
		if(latte[i]<latte[i+1]) dp[i]=max(dp[i],dp[i+1]+(L-latte[i]));
		ans = max(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct edge { ll to; ll d; };
vector<vector<edge>> adj;

vector<ll> dijkstra(int n=0) {
  int N = adj.size();
  auto c = [](const p_ll &x, const p_ll &y){return x.second>y.second;};
  priority_queue<p_ll, vector<p_ll>, decltype(c)> q(c);
  vector<ll> result(N,LLINF); result[n] = 0; q.push(make_pair(n,0));
  while(q.size()) {
    p_ll now = q.top(); q.pop();
    ll np = now.first, nd = now.second;
    if (nd>result[np]) continue;
    for (auto x: adj[np]) {
      if (result[x.to]<=result[np]+x.d) continue;
      q.push(make_pair(x.to, result[np]+x.d));
      result[x.to] = result[np]+x.d;
    }
  }
  return result;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  int N, M; cin >> N >> M;
  adj.resize(N);
  rep(i,M) {
    int A, B; cin >> A >> B; A--; B--;
    adj[A].push_back({B,1});
    adj[B].push_back({A,1});
  }

  vector<ll> d = dijkstra();
  bool ok = true; rep(i,N) ok &= d[i]!=LLINF;

  if (!ok) { cout << "No" << endl; return 0; }

  int result[N] = {};
  repr(i,1,N) {
    for (auto x: adj[i]) {
      if (d[x.to]<d[i]) {
        result[i] = x.to+1;
        break;
      }
    }
  }

  cout << "Yes" << endl;
  repr(i,1,N) cout << result[i] << endl;
  return 0;
}

Measured memory_bytes: 18804
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int m; cin >> m;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=1;i<=m;i++){
		for(int j=0;j<n-1;j++){
			if(a[j]%i>a[j+1]%i){
				swap(a[j],a[j+1]);
			}
		}
	}
	for(int i=0;i<n;i++){
		cout << a[i] << endl;
	}
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N, K;
	cin >> N >> K;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	ll t = 0;
	ll d = 0;

	rep(i, N)rep(j, N) {
		if (A[i] > A[j]) { d++; }
		if (i<j&&A[i]>A[j]) { t++; }
	}

	ll X = K * (K - 1) / 2 % MOD;

	ll ans = (t * K + d * X)%MOD;

	cout << ans;
	system("PAUSE");

}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a,b;
cin>>n>>a>>b;int i=1,f=0;
while(i<1e9||a>=1||b<=n){
    if(i%2==1)
    {if(a+1!=b)a++;
    else {a--;if(a==0){f=1;break;}}
    }
    else
        {if(b-1!=a)b--;
        else {b++;if(b>n){f=2;break;}}
}
i++;
}if((a<=1)||(f==1))cout<<"Borys\n";
else if((b<n)||(f==2))cout<<"Alice\n";

return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //空白で分割する
            var line_origin = Console.ReadLine();

            if (string.IsNullOrEmpty(line_origin))
            {
                return;
            }

            int week_num = int.Parse(line_origin);
            double money = 100000; //１０万円

            for (int i = 0; i < week_num; i++)
            {
                money *= 1.05;
                //1000未満の切り上げ
                money = Math.Ceiling((money / 1000)) * 1000;
            }
            Console.WriteLine("{0}", (int)money);
        }
    }
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n,m;
    cin >> n >> m;
    vector<int> ac(n), pena(n);
    rep(i,m) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if(ac[p]) continue;
        if(s == "AC") {
            ac[p] = 1;
        } else {
            pena[p]++;
        }
    }
    int AC = 0, PENA = 0;
    rep(i,n) {
        AC += ac[i];
        if(ac[i]) PENA += pena[i];
    }
    printf("%d %d\n", AC,PENA);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> s(H);
	for (auto &x : s) {
		cin >> x;
	}

	vector<vector<int>> ans(H, vector<int>(W, 0));
	int id = 1;

	for (int i = 0; i < H; ++i) {
		if (s[i].find('#') != string::npos) {
			int j = 0;
			for (; j < W && s[i][j] == '.'; ++j) {
				ans[i][j] = id;
			}
			if (j < W) {
				ans[i][j] = id;
				++j;
			}
			for (; j < W && s[i][j] == '.'; ++j) {
				ans[i][j] = id;
			}
			for (; j < W; ++j) {
				if (s[i][j] == '#') {
					++id;
				}
				ans[i][j] = id;
			}
			++id;
		}
	}

	for (int i = 0; i < H; ++i) {
		if (ans[i][0] != 0) {
			for (int k = i + 1; k < H; ++k) {
				if (ans[k][0] == 0) {
					ans[k] = ans[k - 1];
				}
			}
			for (int k = i - 1; k >= 0; --k) {
				if (ans[k][0] == 0) {
					ans[k] = ans[k + 1];
				}
			}
			break;
		}
	}

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

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

int main() {
  string s;
  cin >> s;
  for(char c = 'a';c<='z';c++){
    if( count(s.begin(),s.end(),c) == 0 ){
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
  
}

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

using namespace std;

int n, m;
const int MOD = 1e9 + 7;

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

    long long pref, suff, ans = 0;


    pref = 0, suff = 0;
    for(int i = 1; i <= n + 1; i++){
        pref += (i - 1);
        suff += (n - i + 1);

        if(i >= m) ans += suff - pref + 1, ans %= MOD;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

int h,w;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>h>>w;
    set<P>st;
    multiset<int>mst;
    rep(i,w){
        st.insert({i,i});
        mst.insert(0);
    }
    st.insert({-1,-INF});
    st.insert({INF,INF});
    mst.insert(INF-1);
    rep(i,h){
        //for(auto p:st)cout<<p.fi<<" "<<p.se<<endl;
        int a,b;
        cin>>a>>b;
        a--,b--;
        while(1){
            auto it=st.lower_bound({a,-INF});
            if(it->first>b)break;
            if(next(it)->first<=b+1){
                mst.erase(mst.find((it->first)-(it->second)));
                st.erase(it);
                continue;
            }
            mst.erase(mst.find((it->first)-(it->second)));
            st.erase(it);
            int x=it->second;
            if(b+1<w){
                int e=b+1;
                st.insert({e,x});
                mst.insert(e-x);
            }
        }
        int ans=*mst.begin()+i+1;
        if(ans>=h+w)cout<<-1<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<string> t(h);
    rep(i,h) cin>>t[i];
    rep(i,h){
        rep(j,w){
            if (t[i][j]=='#'){
                cout<<'#';
                continue;
            }
            int cnt=0;
            FOR(k,max(0,i-1),min(i+1,h-1)){
                FOR(l,max(0,j-1),min(j+1,w-1)){
                    if (t[k][l]=='#') cnt++;
                }
            }
            cout<<cnt;
        }
        cout<<endl;
    }
    return 0;
}


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

int main(void){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    
    int max_x = x, min_y = y;
    int i;
    for(i = 1; i <= n; i++){
        cin >> x;
        if(x > max_x){
            max_x = x;
        }
    }
    for(i = 1; i <= m; i++){
        cin >> y;
        if(y < min_y){
            min_y = y;
        }
    }
    
    if(max_x < min_y){
        cout << "No ";
    }
    
    cout << "War" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD 1000000007
#define MOD2 998244353

#include <boost/algorithm/string/replace.hpp>

using namespace std;

int fast_pow(ll base, ll n, ll M = 1)   // calculate the value of base^p in O(log p)
{
    if(n==0)
       return 1;
    
    if(n==1)
        return base;
    
    ll halfn = fast_pow(base, n/2, M);
    
    if(n%2==0)
        return ( halfn * halfn ) % M;
    else
        return ( ( ( halfn * halfn ) % M ) * base ) % M;
}


int main()
{
  ll k1,s;
  
  cin >> k1 >> s;
  ll ct = 0;
  
  for(int i = 0; i <= k1 ; i++)
  {
    for(int j = 0; j <= k1 ; j++)
    {
      ll k = s - (i + j);
      if(k >= 0 && k <= k1)
        ct++;
    }
  }
  
  p1(ct);
  return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
awari=[]
bwari=[]
wari=[]

for i in range(a,0,-1):
    if a%i==0:
        awari.append(i)
        #print(i)
for i in range(b,0,-1):
    if b%i==0:
        bwari.append(i)
        #print(i)

if len(awari)<=len(bwari):
    for i in range(0,len(awari)):
        if awari[i] in bwari:
            wari.append(awari[i])
else:
    for i in range(0,len(bwari)):
        if bwari[i] in awari:
            wari.append(bwari[i])

wari=sorted(wari); wari=wari[::-1]
print(wari[k-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmin(x,y) x=min(x,y)

int main(void){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    int ans=1e9;
    for(int i=-100;i<=100;++i){
        int temp=0;
        rep(j,n) temp+=(A[j]-i)*(A[j]-i);
        //cout<<i<<" "<<temp<<endl;
        chmin(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 50;
int n,k;
pll p[MAX_N];

int main()
{
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p,p+n);

  i64 res = INT64_MAX;
  for (int i = 0; i < n; i++) {
    i64 x1 = p[i].first;
    for (int j = i+k-1; j < n; j++) {
      i64 x2 = p[j].first;
      vl ys;
      for (int l = i; l <= j; l++) {
        ys.push_back(p[l].second);
      }
      sort(ys.begin(),ys.end());
      i64 dy = INT64_MAX;
      for (int l = 0; l+k <= (int)ys.size(); l++) {
        dy = min(dy,ys[l+k-1] - ys[l]);
      }
      res = min(res, (x2-x1)*dy);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
using namespace std;

#define pb push_back
#define pbb pop_back
#define pf pop_front
#define pff push_front
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 5e5, MOD = 1e9 + 7;
const ld EPS = 1e-9, PI = acos(-1);

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x, y;
    cin >> x >> y;
    if (x % y == 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << x << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    cin>>n;
    ll ans=0;
    ll cnt = 0;
    while(n>0){
        n /= 2;
        cnt++;
    }
    ans = pow(2,cnt)-1;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

# 案の定TLE
# ans = N+1
# for i in range(N):
#     ans = min(ans,S[:i].count("W") + S[i+1:].count("E"))

left = 0
right = S.count("E")
ans = N+1
for i in range(N):
    if S[i] == "E":
        right -= 1
    ans = min(ans,left + right)
    if S[i] == "W":
        left += 1

print(ans)


Measured memory_bytes: 3700
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
const LL mod = 1e9 + 7;

struct BIT
{
	int n;
	LL sum[N];
	
	#define lowbit(x) ((x) & -(x))
	
	void update(int x, LL d) { for (; x <= n; x += lowbit(x)) (sum[x] += d) %= mod; }
	
	LL inquire(int x)
	{
		LL ans = 0;
		for (; x; x -= lowbit(x)) (ans += sum[x]) %= mod;
		return ans;
	}
} T;

struct P { int x, y; };

bool operator<(P a, P b)
{
	if (a.x != b.x) return a.x < b.x;
	return a.y > b.y;
}

bool operator==(P a, P b) { return a.x == b.x && a.y == b.y; }

int n, m;
int a[N], b[N], y[N], cnt_y;

P p[N];
int cnt;

int main()
{
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
	for (int i = 1; i <= m; ++ i) scanf("%d", &b[i]);
	int s = 1;
	for (; s <= n && a[s] < b[1]; ++ s);
	if (s > n)
	{
		printf("1\n");
		return 0;
	}
	for (int i = s, j = 2; i <= n && j <= m; ++ j)
	{
		for (; i <= n && a[i] < b[j]; ++ i)
			p[++ cnt] = (P) { a[i] - b[j - 1], b[j] - a[i] }, y[++ cnt_y] = b[j] - a[i];
		for (; a[i] == b[j]; ++ i);
	}
	sort(y + 1, y + cnt_y + 1);
	cnt_y = unique(y + 1, y + cnt_y + 1) - y - 1;
	for (int i = 1; i <= cnt; ++ i)
		p[i].y = lower_bound(y + 1, y + cnt_y + 1, p[i].y) - y;
	sort(p + 1, p + cnt + 1);
	cnt = unique(p + 1, p + cnt + 1) - p - 1;
	T.n = cnt;
	LL ans = 0;
	for (int i = 1; i <= cnt; ++ i)
	{
		LL sum = T.inquire(p[i].y - 1) + 1;
		(ans += sum) %= mod;
		T.update(p[i].y, sum);
	}
	printf("%lld\n", (ans + 1) % mod);
}

Measured memory_bytes: 2560
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    string str;
    cin>>str;
    for(ll i=0;i<3;i++)
    {
        if(str[i]=='9')
            cout<<"1";
        else if(str[i]=='1')
            cout<<"9";
        else
            cout<<str[i];
    }

}



Measured memory_bytes: 256
students    = []
checkPoints = []
answer      = []

num_of_students, num_of_checkPoints = gets.split.map(&:to_i)
num_of_students.times{ students << gets.split.map(&:to_i) }
num_of_checkPoints.times{ checkPoints << gets.split.map(&:to_i) }

num_of_students.times do |st|
  minDistance  = 2E8+10
  nearestCP = 0
  num_of_checkPoints.times do |cp|
    distance = ( students[st][0] - checkPoints[cp][0] ).abs + ( students[st][1] - checkPoints[cp][1] ).abs
    if minDistance > distance
      minDistance = distance
      nearestCP = cp
    end
  end
  answer << nearestCP + 1
end

puts answer


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using pii =pair<int,int>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=int(a);i<int(b);++i)

ll x,k;
void input(){
    cin>>k>>x;
}
void src(){
    repi(i,x-k+1,x+k) cout<<i<<" ";
    return;
}

int main(int argc,char* argv[]){
  //  ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

void insert_stack(std::vector<std::vector<char> > &map, std::stack<std::pair<int, int> > &st, char self_color, char other_color, int &count, bool &check_surrounded, bool &check_only_wall); 
void dfs(std::vector<std::vector<char> > &map, int i, int j, char self_color, char other_color, int &total); 
int whole_search(std::vector<std::vector<char> > map, int w, int h, char self_color, char other_color); 

int main(void) {
    int w;
    int h;

    while (1) {
        std::cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        std::vector<std::vector<char> > map_b(h+2, std::vector<char>(w+2, '#'));
        std::vector<std::vector<char> > map_w(h+2, std::vector<char>(w+2, '#'));

        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                std::cin >> map_b[i][j];
                map_w[i][j] = map_b[i][j];
            }
        }
        std::cout << whole_search(map_b, w, h, 'B', 'W') << " " << whole_search(map_w, w, h, 'W', 'B') << std::endl;
    }


    return 0;
}

void insert_stack(std::vector<std::vector<char> > &map, std::stack<std::pair<int, int> > &st, char self_color, char other_color, int &count, bool &check_surrounded, bool &check_only_wall) {
    int dx[] = {0, 0, 1, -1};
    int dy[] = {1, -1, 0, 0};
    int first;
    int second;

    first = st.top().first;
    second = st.top().second;
    st.pop();
    ++count;

    for (int k = 0; k < 4; k++) {
        if (map[first + dx[k]][second + dy[k]] == '.') {
            st.push(std::make_pair(first + dx[k], second + dy[k])); 
            map[first + dx[k]][second + dy[k]] = '$';
        } else if (map[first + dx[k]][second + dy[k]] == other_color) {
            check_surrounded = false; 
        } else if (map[first + dx[k]][second + dy[k]] == self_color) {
            check_only_wall = true;
        }
    }
    return;
}

void dfs(std::vector<std::vector<char> > &map, int i, int j, char self_color, char other_color, int &total) {
    int count = 0;
    bool check_surrounded = true;
    bool check_only_wall = false;

    std::stack<std::pair<int, int> > st;
    st.push(std::make_pair(i, j));
    map[i][j] = '$';

    while (1) {
        if (st.empty() == 1) {
            break; 
        }
        insert_stack(map, st, self_color, other_color, count, check_surrounded, check_only_wall);
    }

    if (check_surrounded == true && check_only_wall == true) {
        total += count;
    } else {
        check_surrounded = true;
        check_only_wall = false;
    }
    return;
}

int whole_search(std::vector<std::vector<char> > map, int w, int h, char self_color, char other_color) {
    int total = 0;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (map[i][j] == '.') {
                dfs(map, i, j, self_color, other_color, total);
            }
        }
    }
    return total; 
}

Measured memory_bytes: 3172
# -*- coding: utf-8 -*-
"""
A - 居合を終え、青い絵を覆う / UOIAUAI
https://atcoder.jp/contests/abc049/tasks/abc049_a

"""
import sys


def solve(c):
    if c in 'aeiou':
        return 'vowel'
    return 'consonant'


def main(args):
    c = input()
    ans = solve(c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 2940
def kth_common_divisor(a, b, k):

    count = []
    for i in range(1, max(a, b)+1):
        if a%i == 0 and b%i == 0:
            count.append(i)

    count.sort(reverse=True)
    return count[k-1]

def main():
    a, b, k = map(int, input().split())
    print(kth_common_divisor(a, b, k))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import numpy as np
s = list(map(int, list(str(input()))))
s = np.array(s)

s1 = np.array([0 if i%2 == 0 else 1 for i in range(len(s))])
s2 =np.array([0 if i%2 == 1 else 1 for i in range(len(s))])

print(min(np.sum(np.abs(s-s1)), np.sum(np.abs(s-s2))))

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

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

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

void Main()
{
  ll n;
  cin >> n;
  ll sum_a = 0, sum_b = 0, value;
  vll a(n), b(n), c(n);
  rep(i, n)
  {
    cin >> a[i];
    sum_a += a[i];
  }
  rep(i, n)
  {
    cin >> b[i];
    sum_b += b[i];
    c[i] = a[i] - b[i];
  }
  if(sum_a < sum_b) fin(-1);
  value = sum_a - sum_b;
  sort(all(c));
  ll ok = 0;
  for(ll i = 0;i < n;i++)
  {
    if(c[i] < 0) continue;
    if(value < c[i])
    break;
    value -= c[i];
    ok++;
  }
  fin(n - ok);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  string n; cin >> n;
  ll sum = 0;
  REP(i,n.size()) {
    sum += n[i] - '0';
  }
  Yes(sum % 9 == 0);

  return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
bool boin(char c) {
	return c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vector<string> v(n);
		REP(i, n)cin >> v[i];
		vector<string> code(n);
		int cmax = -1;
		REP(i, n) {
			string t;
			t += v[i][0];
			REP(j, v[i].size()-1) {
				if (boin(v[i][j]))t += v[i][j + 1];
			}
			code[i] = t;
			cmax = max(cmax, t.size());
		}
		REP(k, cmax+1) {
			vector<string> tmp(n);
			REP(i, n) {
				if (code[i].size() < k)tmp[i] = code[i];
				else tmp[i] = code[i].substr(0, k);
			}
			set<string> s;
			REP(i, n)s.insert(tmp[i]);
			if (s.size() == n) {
				cout << k << endl;
				break;
			}
			else if (k == cmax)cout << -1 << endl;

		}
		
	}
	return 0;
}

Measured memory_bytes: 3152
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double;
using u32 = unsigned int; using u64 = unsigned long long int; using str = string;
template <typename T> using vec = vector<T>; void in() { }
template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); }
template <typename T> void out(T &&x) { cout << x << "\n"; }
template <typename T, typename...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t x; cin >> x; return x; }()
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define bisect_left lower_bound
#define bisect_right upper_bound
#define bound(a, x, b) (a <= x && x <= b)
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

i32 ans[100][100];

void solve() {
    indef(i32, h, w);
    indef(i32, n);
    queue<i32> a;
    times(n, i){
        a.push(get(i32));
    }
    i32 t = 0, c = 0;
    times(h, i) {
        times(w, j) {
            i32 jj = even(i) ? j : w-j-1;
            if (t == 0) {
                t += a.front();
                a.pop();
                c++;
            }
            t--;
            ans[i][jj] = c;
        }
    }
    times(h, i) {
        times(w-1, j) {
            cout << ans[i][j] << " ";
        }
        cout << ans[i][w-1] << endl;
    }
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    //cout << fixed << setprecision(9);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>


int main (void){
        int N;
        int K;
        int ans=0;
        scanf("%d",&N);
        scanf("%d",&K);
N-=K;
ans=1;
ans+=((N+K-2)/(K-1));

printf("%d",ans );
        return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ali = []
bob = []
for i in range(n):
    if i % 2 == 0:
        ali.append(a[i])
    else:
        bob.append(a[i])

print(sum(ali)-sum(bob))

Measured memory_bytes: 3064