akhauriyash/Code-Regression huggingface dataset:
// Problem : C - A+...+B Problem
// Contest : Virtual Judge - practice contest 2
// URL : https://vjudge.net/contest/390405#problem/C
// Memory Limit : 262 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b || (n==1 && a!=b))
	cout<<0;
	else if(n==1 && a==b)
	cout<<1;
	else
		cout<<(b-a)*(n-2)+1;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<i64>();
    }
    let mut lgcds = vec![0; n];
    let mut rgcds = vec![0; n];
    lgcds[0] = seq[0];
    rgcds[n - 1] = seq[n - 1];
    for i in 0..(n - 1) {
        lgcds[i + 1] = gcd(lgcds[i], seq[i + 1]);
        rgcds[n - 2 - i] = gcd(rgcds[n - 1 - i], seq[n - 2 - i]);
    }
    let mut ans = std::cmp::max(lgcds[n - 2], rgcds[1]);
    for i in 1..(n - 1) {
        ans = std::cmp::max(ans, gcd(lgcds[i - 1], rgcds[i + 1]));
    }
    println!("{}", ans);
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if((a + b) > (c + d)) cout << "Left" << endl;
  else if((a + b) == (c + d)) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  // ここにプログラムを追記
}

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;
int memo[2003][2];// nokori yamahuda, X gets
bool used[2003][2];// nokori yamahuda, X gets
int N;
int a[2003];
int dfs(int had, bool X, int xa, int xb){
  
  if(used[had][X]){
    return memo[had][X];
  }
  if(had == N){
    int ans;
    ans = abs(xa - xb);
    return memo[had][X] = ans;
  }

  int res;
  if(X){
    res = 0;
    for(int i = had + 1; i <= N; i++){
      res = max(dfs(i, !X, a[i - 1], xb), res);
    }
  }else{
    res = INF;
    for(int i = had + 1; i <= N; i++){
      res = min(dfs(i, !X, xa, a[i - 1]), res);
    }
  }

  used[had][X] = true;

  return  memo[had][X] = res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int Z, W;
  cin >> N >> Z >> W;
  REP(i,N) cin >> a[i];
  REP(i,N){
    memo[i][true] = -1;
    memo[i][false] = INF;
  }
  dfs(0, true, Z, W);
  cout << memo[0][true] << endl;
  return 0;
}


Measured memory_bytes: 384
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rds;
using io::print;
using io::prints;

const int N = 107, inf = 1e9;
int n, m, d[N][N], v[N][N];
char s[N][N];
deque<pi> q;

int main() {
	rd(n), rd(m);
	for (int i = 1; i <= n; i++) rds(s[i], m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			d[i][j] = inf;
	q.pb(mp(1, 1)), d[1][1] = s[1][1] == '#';
	while (q.size()) {
		pi x = q.front();
		q.pop_front();
		if (v[x.fi][x.se]) continue;
		v[x.fi][x.se] = 1;
		if (x.fi < n) {
			if (s[x.fi][x.se] == '.' && s[x.fi+1][x.se] == '#') {
				if (d[x.fi+1][x.se] > d[x.fi][x.se] + 1)
					q.pb(mp(x.fi + 1, x.se)), d[x.fi+1][x.se] = d[x.fi][x.se] + 1;
			} else {
				if (d[x.fi+1][x.se] > d[x.fi][x.se])
					q.push_front(mp(x.fi + 1, x.se)), d[x.fi+1][x.se] = d[x.fi][x.se];
			}
		}
		if (x.se < m) {
			if (s[x.fi][x.se] == '.' && s[x.fi][x.se+1] == '#') {
				if (d[x.fi][x.se+1] > d[x.fi][x.se] + 1)
					q.pb(mp(x.fi, x.se + 1)), d[x.fi][x.se+1] = d[x.fi][x.se] + 1;
			} else {
				if (d[x.fi][x.se+1] > d[x.fi][x.se])
					q.push_front(mp(x.fi, x.se + 1)), d[x.fi][x.se+1] = d[x.fi][x.se];
			}
		}
	}
	print(d[n][m]);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    ll t = 0;
    for (int i = 1;; ++i) {
        t += i;
        if (t >= x) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//int a[100000000];
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct BIT {
  int n;
  vector<ll> tree;
  BIT(int n):n(n),tree(n+1) {} 
  void fill(ll val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, ll val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  // sum[0, idx]
  ll range(int idx) {
    ll sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
  // sum[a, b]
  ll range(int a, int b) {
    return range(b) - range(a - 1);
  }
};

ll inversion_number(int *A, int N) {
  ll ans = 0;
  // normalize(A); // 蠎ｧ讓吝悸邵ｮ
  BIT bit(N + 5);
  REP(i, N) {
    ans += bit.range(N - A[i]);
    bit.add(N - A[i], 1);
  }
  return ans;
}

int a[212345];

int main2() {
  string s; cin >> s;
  int N = (int)s.size();

  int count[26] = {};
  REP(i, s.size()) count[ s[i] - 'a' ]++;
  int odd = 0;
  REP(i, 26) if (count[i] % 2 > 0) odd++;
  if (odd >= 2) {
    cout << -1 << endl;
    return 0;
  }
  int see[26] = {};
  string left = "";
  REP(i, s.size()) {
    int c = s[i] - 'a';
    ++see[c];
    if (see[c] <= count[c] / 2) left += s[i];
  }
  string t;
  t += left;
  REP(i, 26) if (count[i] % 2 == 1) t += (char)('a' + i);
  reverse(ALL(left));
  t += left;
  // cout << s << endl;
  // cout << t << endl;


  int used[26] = {};
  REP(c, 26) {
    REP(i, N) if (t[i] == c+'a') { used[c] = i; break; }
  }
  REP(i, N) {
    int c = (s[i]-'a');
    a[i] = used[c];
    used[c]++;
    while (used[c] < N && t[ used[c] ] != 'a'+c) used[c]++;
  }
  // pv(a, a + N);
  ll ans = inversion_number(a, N);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



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

int main() {
    int N;
    string input;
    string result;
    cin >> N;
    
    
    
    for(int i = 0; i < N; i++){
        cin >> input;
        result.append(input);
    }
    if(result.find('Y') != std::string::npos){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	int n; get n;

	vector<string> vec(n);

	for(int i = 0; i < n; i++){
		str w; get w;
		auto it = find(vec.cbegin(),vec.cend(),w);
		if (it!=vec.cend()){
			put "No";
			return;
		}
		vec[i] = w;
		if(i==0) continue;
		if(vec[i - 1].back() != vec[i].front()){
			put "No";
			return;
		}
	}

	put "Yes";

}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,dst=0;
  cin >> a >> b;
  int tmp,num=0;
  for(int i=a;i<=b;i++){
    tmp = i;
    num = tmp*0.0001f;
    if(num == tmp % 10){
      // 数字上下カット
    tmp -= tmp/10000*10000;
    tmp = tmp/10;
    num = tmp*0.01f;
    if(num == tmp % 10){
    dst++;
    }
    }
  }// for
  
  cout << dst << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string s; cin >> s;
  string t{s.rbegin(), s.rend()};
  auto ans = s == t ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
(_,k),*t=[map(int,t.split())for t in open(0)]
A,F=map(sorted,t)
o=10**12
g=-1
while o-g>1:
 m,l=o+g>>1,k
 for a,f in zip(A,F[::-1]):l-=max(0,a-m//f)
 if l<0:g=m
 else:o=m
print(o)

Measured memory_bytes: 124648
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

class Union_Find {
    public:
    std::vector<int> par;
    Union_Find() {}
    Union_Find(int n){
        par.resize(n, 0);
        for(int i = 0; i < n; i++){
            par[i] = i;
        }
    }

    void simplify(int x) {
        std::vector<int> path;
        while (par[x] != x) {
            path.push_back(x);
            x = par[x];
        }
        for (int p : path) {
            par[p] = x;
        }
    }
    
    int find(int x){
        simplify(x);
        return par[x];
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x != y) {
            par[y] = x;
            // 改造する時は「根になっているノードの親を変更する」という原則が守られていることに注意。
        }
    }
};

int calc_dist(int d1, int d2) {
    int tmp = abs(d1-d2);
    return std::min(tmp, 24 - tmp);
}

const int MAX_N = 200;
int N, D[MAX_N];

Union_Find uf = Union_Find(MAX_N);

bool can_sep(int s) {
    for (int i = 1; i <= N; i++) {
        if (D[i] < s) {
            return false;
        }
        uf.par[i] = i;
        uf.par[N+i] = N + i;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            if (calc_dist(D[i], D[j]) < s && calc_dist(D[i], -D[j]) < s) {
                return false;
            }
            if (calc_dist(D[i], D[j]) < s) {
                uf.unite(i, N + j);
                uf.unite(j, N + i);
            }
            if (calc_dist(D[i], -D[j]) < s) {
                uf.unite(i, j);
                uf.unite(N + i, N + j);
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        if (uf.find(i) == uf.find(i + N)) {
            return false;
        }
    }

    return true;
}

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> D[i];
    }

    //std::cout << can_sep(0) << std::endl;

    for (int i = 0; i <= 13; i++) {
        if (!can_sep(i)) {
            std::cout << i - 1 << std::endl;
            return 0;
        }
    }

    assert(false);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  int N, K; cin >> N >> K;
  vi x(N); rep(i,N) cin >> x[i];

  int ans = 1e9;
  rep(i, N-K+1) {
    int near_x = min(abs(x[i]),abs(x[i+K-1]));
    ans = min(ans, near_x+x[i+K-1]-x[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi a(4),b{1,4,7,9};
	rep(i,4)cin>>a[i];
	sort(all(a));
	OUT(a==b);
	return 0;
}

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

lli n;

int main(void){
	cin >> n;
	vector<lli> d(n);
	rep(i, n){
		lli a;
		cin >> a;
		while(a%2 == 0){
			a/=2;
			d[i]++;
		}
	}
	lli ans = 0;
	rep(i, n) ans+=d[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3684
using System;

namespace ALDS1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] price = new int[n];
            int[] difference = new int[n - 1];

            for (int i = 0; i < n; i++)
                price[i] = int.Parse(Console.ReadLine());

            int min = price[0];
            int max = price[1] - price[0];

            for (int i = 1; i < n; i++)
            {
                if (max < price[i] - min)
                    max = price[i] - min;
                if (min > price[i])
                    min = price[i];
            }
            Console.WriteLine("{0}", max);
        }
    }
}



Measured memory_bytes: 23156
#include <iostream>
#include <vector>
#include <math.h>

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

    std::vector<long long> as;
    as.reserve(n);

    for (int i = 0; i < n; ++i) {
        long long a;
        std::cin >> a;
        as.push_back(a);
    }

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

    for (int i = n / 2; i < n; ++i) {
        bs[i] = as[i];
    }

    int k = n / 2;
    while (k >= 1) {
//        std::cout << "k" << k << "\n";
        for (int i = k / 2; i < k; ++i) {
//            std::cout << "k" << as[i] << "\n";
            int s = as[i];
            int j = 2 * (i + 1);
            while (j <= n) {
//                std::cout << "j" << j << "\n";
                s = (s + bs[j - 1]) % 2;
                j += (i + 1);
            }
            bs[i] = s;
        }
        k = k / 2;
    }

    int m = 0;
    for (int i = 0; i < n; ++i) {
        if (bs[i] == 1) {
            m += 1;
        }
    }

    std::cout << m << "\n";
    for (int i = 0; i < n; ++i) {
        if (bs[i] == 1) {
            std::cout << i + 1 << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 3968
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();

    let cnt0:u32 = s.iter().filter(|&x| *x=='0').count() as u32;
    let cnt1:u32 = s.iter().filter(|&x| *x=='1').count() as u32;

    println!("{}", min(cnt0,cnt1)*2);

}


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    llint a, b, k;
    cin >> a >> b >> k;
    llint ans = a - k;
    ans = b + ans;
    cout << max(0LL, a - k) << " " << min(b, max(0LL, ans)) << endl;
    return 0;
}


Measured memory_bytes: 3632
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}

const ll N=5e5+5;

ll sp[N];

void sieve(){
  for(int i=2;i<N;i++)sp[i]=i;

    for(int i=2;i*i<N;i++){
      if(sp[i]==i){
      for(int j=i*i;j<N;j+=i){
        sp[j]=i;
      }
    }
}

}

ll fac[N],inv[N];

ll p=1e9+7;

void fill(){
  fac[0]=inv[0]=1;

  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%p;
    inv[i]=powM(fac[i],p-2,p);
  }
}

ll c(ll a,ll b,ll p){
if(a<b)return 0;

  return (fac[a]*inv[a-b]%p)*(inv[b])%p;
}


ll dp[3005][3005][2];

// p=998244353;

int main()
{ 

  IOS;


ll n,x=0;
cin>>n;

vl a(n+1);

for(int i=1;i<=n;i++){
  cin>>a[i];
  x+=max(0LL,a[i]-a[i-1]);
}
cout<<x<<endl;

return 0;
 
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,a[N],b[N],ans[N];

bool cmp(int x,int y) {return a[x]<a[y];}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++){
		a[i]=read();b[i]=i;
		ans[a[i]]=i;
	}
	sort(b+1,b+n+1,cmp);
	for (int i=1,t=1;i<=n;i++)
		for (int j=1;j<=b[i]-1;j++){
			while (ans[t]) t++;ans[t]=b[i];
			if (t>a[b[i]]) {printf("No\n");return 0;}
		}
	for (int i=n,t=n*n;i>=1;i--)
		for (int j=1;j<=n-b[i];j++){
			while (ans[t]) t--;ans[t]=b[i];
			if (t<a[b[i]]) {printf("No\n");return 0;}
		}
	printf("Yes\n");
	for (int i=1;i<=n*n;i++)
		printf((i!=n*n)?"%d ":"%d\n",ans[i]);
	return 0; 
}

Measured memory_bytes: 6272
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
stdin.readline()
data = [int(s) for s in stdin.readline().split()]
swap_times = 0
for i in range(len(data)):
    mini = i
    swap_flag = False
    for j in range(i, len(data)):
        if data[j] < data[mini]:
            mini = j
            swap_flag = True
    data[i], data[mini] = data[mini], data[i]
    swap_times += swap_flag
print(*data)
print(swap_times)

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

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

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max();
constexpr auto llinf = numeric_limits<ll>().max();

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << "\n";
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << "\n";
}

int n;
vi a;
constexpr auto mxN = 1000010;
bitset<mxN> seive;
int have[mxN];

void solve() {
  scanf("%d", &n);
  a.clear();
  a.resize(n);
	zero(have);
  rep(i, n) {
		scanf("%d", &a[i]);
		have[a[i]]++;
	}
	sort(all(a));
	seive.set();
	repa(i, 1, a[n-1]) {
		if (*lower_bound(all(a), i) == i && seive.test(i)) {
			auto mult = 2;
			while (i * mult <= a[n-1]) {
				seive.reset(i * mult);
				++mult;
			}
			if (have[i] >= 2) seive.reset(i);
		}
	}
	auto cnt = 0;
	rep(i, n) {
		cnt += seive.test(a[i]);
	}
	cout << cnt;
	cout << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 8044
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int n;
    string s;
    cin>>n>>s;
    int l=0;
    int r=0;
    int ans=0;
    
for(int i=1;i<n;i++){
        
        int count=0;
    
    for(char c='a';c<='z';c++){
           
        
      
        for(int g=0;g<i;g++){
                if(s[g]==c){
                     l=1;
                }
                }
        for(int j=i;j<n;j++){
                    if(s[j]==c){
                        r=1;
                    }
                   }
          
        if(l==1 && r==1){
                count+=1;
            }
           
           
           
           r=0;
           l=0;
           
            }
    
        
       if(count>=ans){
            ans=count;
        }
      
    
    }
    
    cout<<ans<<endl;
    
    
    return 0;
   
}






Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
    Scanner input=new Scanner(System.in);
    String s=input.next();
    String t=input.next();
    String temp=t.substring(0,t.length()-1);
    if(temp.equals(s)){
    System.out.print("Yes");
    }else System.out.print("No");
    }
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin, a, b, c, d;
    ll ans = -(1LL << 61);
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    print(ans);
    return 0;
}


Measured memory_bytes: 3608
N,x =  map(int, input().split())

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

ans = 0

for i in range(N):
    if i == N - 1:
        if a[i] == x:
            ans += 1
        break
        
    if a[i] <= x:
        x -= a[i]
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
vector<int> l[200005];
int visited[200005];
map<int,int> mp;
int main()
{
   int n;
   cin>>n;
   int a[n];

   for(int i=0;i<n;i++)
      cin>>a[i];

   int dp[n+1];
   memset(dp,0,sizeof(dp));
   dp[0]=0;
   dp[1]=abs(a[1]-a[0]);
   for(int i=2;i<n;i++)
   {
     dp[i]=min(abs(a[i-2]-a[i])+dp[i-2],abs(a[i]-a[i-1])+dp[i-1]);
   }
   // for(int i=0;i<n;i++)
   // cout<<dp[i]<<" ";

      cout<<dp[n-1];
}


Measured memory_bytes: 5760
import           Control.Exception           (assert)
import           Control.Monad
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  r <- getInt
  let pi = 3.141592653 :: Double
      ans = pi * fromIntegral (2*r)
  print ans

Measured memory_bytes: 3868
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int len = scanner.nextInt();
        int[] array = new int[len];

        int allXor = 0;
        for (int index = 0; index < len; index++) {
            array[index] = scanner.nextInt();
            allXor = allXor ^ array[index];
        }

        for (int index = 0; index < len; index++) {
            System.out.println( array[index] ^ allXor );
        }
    }
}

Measured memory_bytes: 60224
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, ans = 1000;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        int cnt=0;
        cin >> a.at(i);
        while(a.at(i)%2 == 0){
            cnt++;
            a.at(i)/=2;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
}


Measured memory_bytes: 256
using System;
class ProgramE
    {
        static void Main(string[] args)
        {
            
            //入力
            string n = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            int keta = n.Length;
            int sum = 0;
            int frag = 0;

            for(int i = 0; i < n.Length; i++)
            {
                int temp = n[i] -'0';
 
                if(k == 1)
                {
                    if(i == 0)
                        sum += temp;
                    else
                        sum += 9;
                }
                else if(k == 2)
                {
                    if(i == 0)
                        sum = (keta -1) * (temp -1) * 9;
                    else
                        sum += (keta -1) * 81;
 
                    if(temp != 0 && frag == 1)
                    {
                        sum += temp + (keta -1)* 9;
                        frag++;
                    }
                  
                  
                    if(i == 0)
                      frag++;
                        
 
                }
                else
                {
                    if(i == 0)
                        sum = (keta -1) * (keta -2) / 2 * (temp - 1) * 9 * 9;
                    else
                        sum += (keta -1) * (keta -2) / 2 * 9*9*9;
                    
                    if(temp != 0 && frag == 2)
                    {
                        sum += temp + (keta -1)*9;
                        frag++;
                    }
 
                    if(temp != 0 && frag == 1)
                    {
                        sum += (temp -1) * (keta -1) * 9+ (keta -1)*(keta -2) / 2 * 9*9;
                        frag++;
                    }
 
                    
                    
                    if(i == 0)
                        frag++;
                    
                    
                }
 
                keta--;
 
            }
            Console.WriteLine(sum);
            
        } 
    }

Measured memory_bytes: 13140
#include <iostream>
#include <string>
using namespace std;
int main(){
	string  c;
	cin >> c;
	if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o"){
		cout << "vowel" << endl;
	}
	else{
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
	string a, b;
	
	cin >> a >> b;
	cout << b << a; 
}

int main(){
	int t = 1;

	while(t--){
		solve();
	}
}




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

using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
 
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll g1(ll x, ll p){
    if(x==0) return 0;
    return x/p + g1(x/p, p);
}
ll g2(ll x, ll p){
    if(x%2 == 1){
        return g1(x,p) - g2(x-1,p);
    }
    ll res = g1(x/2,p);
    if(p==2) res += x/2;
    return res;
}
int main(){
    ll n;
    cin >> n;
    ll ans = min(g2(n,2), g2(n,5));
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N;
  long long result = 0;;
  cin >> N;
  for(int a = 1;a <= N;a++){
   int k =  N / a;
    k *= a;
    result += (k + a) * (N / a) / 2;
    
  }
  cout << result << endl;
  
}

Measured memory_bytes: 3632
n = gets.to_i
a = gets.split.map(&:to_i)
x = [0]
n.times do |i|
  x[i + 1] = x[i] + a[i] 
end
min = Float::INFINITY
1.upto(n.pred) do |i|
  min = (x[-1] - 2 * x[i]).abs if min > (x[-1] - 2 * x[i]).abs
end
puts min

Measured memory_bytes: 16972
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
    int a=0, b=0;
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'A') {
            a++;
        }
        else {
            b++;
        }
    }
    if (a == 2 || b == 2) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s=input()
ans1=ans2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="1":
            ans1+=1
        else:
            ans2+=1
    else:
        if s[i]=="0":
            ans1+=1
        else:
            ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m;
    cin >> n >> m;
    vector<string >ss;
    rep(i, n){
        string s; cin >> s; ss.pb(s);
    }

     sort(all(ss));
     for(auto x: ss) cout << x;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  string S;cin>>S;
  
  if(S=="SUN"){
    cout<<7<<endl;
  }
  else if(S=="MON"){
    cout<<6<<endl;
  }
  else if(S=="TUE"){
    cout<<5<<endl;
  }
  else if(S=="WED"){
    cout<<4<<endl;
  }
  else if(S=="THU"){
    cout<<3<<endl;
  }
  else if(S=="FRI"){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 256
# vim: set fileencoding=utf-8:


def main():
    D = input()

    if D == 25:
        print("Christmas")
    elif D == 24:
        print("Christmas Eve")
    elif D == 23:
        print("Christmas Eve Eve")
    elif D == 22:
        print("Christmas Eve Eve Eve")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    double n; cin>>n;
    n=n/3;
    n=n*n*n;
    cout<<fixed<<sp(10)<<n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main()
{
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        int x;cin >>x;
        vec[i]=x-1;
    }
    bool ha=true;
    int i=0;
    int j=0;
    int k=0;
    vector<vector<int>> reg(h,vector<int>(w));
    while(1){
       // cout<<i<<" "<<j<<endl;
        if(ha){
            reg[i][j]=k+1;
            if(j==w-1){
                if(i==h-1)break;
                i++;
                ha=false;
            }else{
                j++;
            }
            if(vec[k]==0){
                k++;
            }else{
                vec[k]--;
            }
        }else{
            reg[i][j]=k+1;
            if(j==0){
                if(i==h-1){
                    break;
                }
                i++;
                ha=true;
            }else{
                j--;
            }
            if(vec[k]==0){
                k++;
            }else{
                vec[k]--;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j==w-1){
                cout<<reg[i][j]<<endl;
            }else{
                cout<<reg[i][j]<<" ";
            }
        }
    }
    
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll inf = 1e16;

int N;
int arr[maxn];
vector<int> res;
int main(){
//    freopen("in.txt", "r", stdin);
    cin>>N;
    for(int i = 0;i<N;i++){
        scanf("%d",&arr[i]);
    }
    reverse(arr, arr+N);
    int res = 0,cur = 0;
    for(int i = 1;i<N;i++){
        if(arr[i]>=arr[i-1]){
            cur++;
        }else{
            cur = 0;
        }
        res = max(res,cur);
    }
    cout<<res<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll s;
  cin >> s;
  ll ret = sqrt(s);
  while (ret * ret < s) ret++;
  cout << 0 << ' ' << 0 << ' ';
  cout << ret << ' ' << (ret * ret - s) << ' ';
  cout << 1 << ' ' << ret << ' ';
  cout << '\n';
}


Measured memory_bytes: 256
import bisect
n,m = map(int,input().split())
x = [list() for i in range(n)]
p = []
y = []
for i in range(m):
  s,t = map(int,input().split())
  p.append(s)
  y.append(t)
  x[s-1].append(t)
for i in range(n):
  x[i].sort()
  
for i in range(m):
  index = bisect.bisect_left(x[p[i]-1],y[i])
  print("{:06}{:06}".format(p[i],index+1))

Measured memory_bytes: 26968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long t[] = new long[N];
		long ans[] = new long[N];
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextLong();
		}

		int i = 0;
		ans[0] = t[0];
		for(int j = 1; j < N; i++, j++) {
			ans[j] = lcm(ans[i], t[j]);
		}

		System.out.println(ans[N-1]);

	}

	static long gcd(long a, long b) {
		 long v0 = a, v1 = b, v2 = a % b;
		 while (v2 != 0) {
		 v0 = v1;
		 v1 = v2;
		 v2 = v0 % v1;
		 };
		 return v1;
	}

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

Measured memory_bytes: 21844