akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;

int main(){

    ll X;
    cin >> X;
    ll A=0,B=0;

    A=0;
    B=0;
    while(true)
    {
        ll tmpB = B*B*B*B*B;
        A= -1*(B);
        while(true)
        {
            ll tmpA = A*A*A*A*A;
            ll sum = tmpA - tmpB;
            if(sum == X)
            {
                cout << A << " " << B;
                return 0;
            }

            if(sum > X)
                break;
            A++;
        }
        B--;

        if(-1*(B*B*B*B*B) > X) break;
    }

    A=0;
    B=0;
    while(true)
    {
        ll tmpA = A*A*A*A*A;
        B=0;
        while(true)
        {
            ll tmpB = B*B*B*B*B;
            ll sum = tmpA - tmpB;
            if(sum == X)
            {
                cout << A << " " << B;
                return 0;
            }

            if(sum < 0) break;
            B++;
        }
        A++;
    }

    return 0;
}



Measured memory_bytes: 3576
use std::cmp::{max, min};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let t: i64 = sc.read();

    let mut zero = vec![];
    let mut ab = vec![];
    for _ in 0..n {
        let a: i64 = sc.read();
        let b: i64 = sc.read();
        if a == 0 {
            zero.push(b);
        } else {
            ab.push((a, b));
        }
    }
    zero.sort();
    let mut sum = vec![0; zero.len() + 1];
    for i in 0..zero.len() {
        sum[i + 1] = sum[i] + zero[i] + 1;
    }

    ab.sort_by(|&(a1, b1), &(a2, b2)| (a2 * (b1 + 1)).cmp(&(a1 * (b2 + 1))));

    let mut dp = vec![t + 1; 40];
    dp[0] = 0;
    for (a, b) in ab.into_iter() {
        for cur in (0..(dp.len() - 1)).rev() {
            let t0 = dp[cur] + 1;
            let wait = t0 * a + b;
            let next = t0 + wait;
            dp[cur + 1] = min(dp[cur + 1], next);
        }
    }

    let mut tail = zero.len();
    while sum[tail] > t {
        tail -= 1;
    }
    let mut ans = tail;
    for head in 0..dp.len() {
        let head_sum = dp[head];
        if head_sum > t {
            continue;
        }
        let remain = t - head_sum;
        let tail = sum
            .binary_search_by_key(&(2 * remain + 1), |&s| 2 * s)
            .err()
            .unwrap();
        ans = max(ans, head + tail - 1);
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
    LL W,H; cin >> W >> H;
    LL x,y; cin >> x >> y;
    cout << W * H / 2.0 << " ";
    if(x*2 == W && y*2 == H) cout << 1 << endl;
    else cout << 0 << endl;


}

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

using namespace std;

struct Dinic {
    //using F = int; const static F INF = 0x3f3f3f3f; 
    using F = long long; const static F INF = 0x3f3f3f3f3f3f3f3f; 
    struct Edge {
        int v, bro; F cap;
        Edge() {}
        Edge(int _v, int _bro, F _cap) : v(_v), bro(_bro), cap(_cap) {}
    };
    vector<Edge> e;
    vector<int> pos, cur;
    int n, s, t, m;
    Dinic(int _n, int _s, int _t) : n(_n), s(_s), t(_t), m(0) {
        pos.assign(n, -1);
        cur.resize(n);
        d.resize(n);
        e.reserve(4e5);
    }
    void add(int u, int v, F c=INF) {
        assert(u < n && v < n);
        e.emplace_back(v, pos[u], c); pos[u] = m++;
        e.emplace_back(u, pos[v], 0); pos[v] = m++;
    }
    vector<int> d;
    // build layer graph
    bool bfs() {
        fill(d.begin(), d.end(), -1);
        d[s] = 0;
        queue<int> q; q.push(s);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (int i = cur[u] = pos[u]; i != -1; i = e[i].bro) {
                int v = e[i].v;
                if (d[v] == -1 && e[i].cap != 0) {
                    d[v] = d[u] + 1;
                    q.push(v);
                }
            }
        }
        return d[t] != -1;
    }
    // find blocking flow
    F dfs(int u, F lim) {
        if (u == t) return lim;
        F tot = 0;
        for (int& i = cur[u]; i != -1; i = e[i].bro) {
            int v = e[i].v;
            if (e[i].cap != 0 && d[v] == d[u] + 1) {
                F flow = dfs(v, min(e[i].cap, lim-tot));
                tot += flow;
                e[i].cap -= flow;
                e[i^1].cap += flow;
                if (tot == lim) return lim;
            }
        }
        return tot;
    }
    F flow() {
        F res = 0;
        while (bfs()) {
            res += dfs(s, INF);
        }
        return res;
    }
};
struct ProjectSelection {
    int n;
    int s,t;
    Dinic mc;
    using F = Dinic::F;
    F positive;

    ProjectSelection(int _n) : n(_n)
        , s(n)
        , t(n+1)
        , mc(n+2, s, t)
        , positive(0)
    {}

    // i: [0..n)
    void add_proj(int i, F profit) {
        if (profit >= 0) {
            mc.add(s, i, profit);
            positive += profit;
        } else {
            mc.add(i, t, -profit);
        }
    }

    // u dep on v: [0..n)
    // i.e. u implies v
    void add_dep(int u, int v) {
        mc.add(u, v);
    }

    F profit() {
        return positive - mc.flow();
    }
};

using ll=long long;
void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    ProjectSelection ps(n);
    // keep i?
    for (int i = 0; i < n; i++) {
        ps.add_proj(i, a[i]);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i; (j+=i) <= n;) {
            ps.add_dep(j-1, i-1);
        }
    }
    cout << ps.profit();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

long long  n, a, b, c, d;
int main() {
    scanf("%d%lld%lld%lld%lld", &n, &a, &b, &c, &d);
    n -= 1; long long e = d - c;
    for(long long i = 0; i <= n; i++) {
        long long f = a + 2*i*c - n*c, u = f + i*e, l = f - (n-i)*e;
        if(u >= b && b >= l) return !printf("YES");
    }
    printf("NO");
}

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

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}


vector<ll> adj[N];
vector<bool> vis(N, 0);
vector<ll> tDistance(N, 0);
vector<ll> aDistance(N, 0);

vector<ll> leafDepth(N, 0);

ll t, a, n;

void dfsFill1(ll cur) {
    vis[cur] = 1;
    for (auto next: adj[cur]) {
        if (!vis[next]) {
            tDistance[next] = tDistance[cur] + 1;
            dfsFill1(next);
        }
    }
}

void dfsFill2(ll cur) {
    vis[cur] = 1;
    for (auto next: adj[cur]) {
        if (!vis[next]) {
            aDistance[next] = aDistance[cur] + 1;
            dfsFill2(next);
        }
    }
}

ll dfsDepth(ll cur) {
    vis[cur] = 1;
    bool isLeaf = 1;
    ll dep = 0;
    for (auto next: adj[cur]) {
        if (!vis[next]) {
            isLeaf = 0;
            dep = max(dep, dfsDepth(next));
        }
    }

    if (isLeaf) {
        leafDepth[cur] = 0;
        return 1;
    } else {
        leafDepth[cur] = dep;
        return leafDepth[cur] + 1;
    }
}

bool cmp(ll fir, ll sec) {
    return (aDistance[fir] + leafDepth[fir] > aDistance[sec] + leafDepth[sec]);
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    ll i, j, k, m, p, q, x, y, b, l, r;

    cin >> n >> t >> a;

    fo(i, n - 1) {
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    dfsFill1(t);
    fo(i, n + 1) {
        vis[i] = 0;
    }
    dfsFill2(a);

    fo(i, n + 1) {
        vis[i] = 0;
    }
    dfsDepth(1);


//    Fo(i, 1, n + 1) {
//        cout << i << " " << tDistance[i] << " " << aDistance[i] << " " << leafDepth[i] << "\n";
//    }

//    if (n == 2) {
//        cout << 0 << "\n";
//        return 0;
//    }

    ll last = 0;

    Fo(i, 1, n + 1) {
        if (tDistance[i] < aDistance[i]) {
            last = max(aDistance[i], last);
        }
    }
    cout << last - 1;


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif

//    124999999999999995


    return 0;
}




Measured memory_bytes: 24588
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n, h, w = map(int, input().split())

    count = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a >= h and b >= w:
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
int main(){
    int H,W;
    scanf("%d", &H);
    scanf("%d", &W);
    
    //char **S;
    int i,j;
    /*S = malloc(sizeof(char *) * (H));
    for (i=0;i<H;i++) {
	    S[i] = malloc(sizeof(char) * (W+1));
    }*/
    char S[H+1][(W+1)];
    int check[101],flag = 0,tate[101]; 
    for(i = 0; i < 101; i++){
        check[i] = 0;
        tate[i] = 0;
    }
    for(i = 0; i < H+1; i++){
        //printf("%d\n",i);
        gets(S[i]);
        
    }
    printf("\n");
    for(i=1; i<H+1;i++){
        for(j = 0; j < W;j++){
            if(S[i][j] == '#')  
                flag = 1;
        }
        if(flag == 0){
            check[i] = -1;
            
        }
        flag = 0;
    }
    for(j = 0; j < W; j++){
        for(i = 1; i < H+1; i++)
            if(S[i][j] == '#')
                flag = 1;
        if(flag == 0)
            tate[j] = -1;
        flag = 0;
    }


    for(i = 1; i < H+1; i++){
        if(check[i] < 0)
            continue;
        for(j = 0; j < W; j++){
            if(tate[j] <0)
                continue;
            printf("%c",S[i][j]);
        }
        printf("\n");
    }
    return 0;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

int main() {
    string S; cin >> S;
    for(int i = 0; i < S.size(); ++i) {
        if(S[i]=='?') S[i] = 'D';
    }    
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3728
// F - LCS
// O(n * m)

#include <bits/stdc++.h>

using namespace std;
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

const ll inf = 1e15L;
const int maxn = 3030;
int dp[maxn][maxn];

int main(){
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string sa, sb;
    cin >> sa >> sb;
    int len_a = sa.size(), len_b = sb.size();
    memset(dp, 0, sizeof(dp));
    string s = "";
    vector<vector<int>>v(len_a+1, vector<int>(len_b+1, 0));
//    if(sa[0] == sb[0]){s += sa[0];t ++;}
    for(int i = 0; i < len_a; ++i){
        for(int j = 0; j < len_b; ++j){
            if(sa[i] == sb[j]){
                dp[i+1][j+1] = dp[i][j] + 1; 
                v[i+1][j+1] = 1;
            }
            else{
                if(dp[i+1][j] > dp[i][j+1]){
                    dp[i+1][j+1] = dp[i+1][j]; 
                    v[i+1][j+1] = 2;
                }
                else {
                    dp[i+1][j+1] = dp[i][j+1];
                    v[i+1][j+1] = 3;
                }
            }
        }
    }
    int a = len_a, b = len_b;
    // cout << dp[len_a][len_b] << endl;
    while(a && b && dp[len_a][len_b]){
        if(v[a][b] == 1){
            a--; b--;
            s += sa[a];
        }
        else if(v[a][b] == 2){
            b--;
        }
        else {
            a--;
        }
        // cout << a << " " << b << endl;
    }
//     for(int i = 0; i < len_a; ++i){
//         for(int j = 0; j < len_b; ++j){
// //            if(dp[i][j] == dp[i-1][j] + 1){s += sa[i-1]; break;}
// //            if(dp[i][j] == t){
// //                s += sa[i]; t++;
// //                break;    
// //            }
//             cout << dp[i][j] << " ";
//         }
//         cout << endl;
//     }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;

}

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

int n;

int main(){
	int r,c,m[101][101];
	cin >> r >> c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> m[i][j];
		}
	}
		for(int i=0;i<r;i++)m[i][c]=0;
		for(int i=0;i<c;i++)m[r][i]=0;
		m[r][c]=0;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			m[i][c]+=m[i][j];
		}
	}
	for(int i=0;i<c;i++){
		for(int j=0;j<r;j++){
			m[r][i]+=m[j][i];
		}
	}
	for(int i=0;i<r;i++){
		m[r][c]+=m[i][c];
	}
	for(int i=0;i<r+1;i++){
		for(int j=0;j<c+1;j++){
			cout << m[i][j];
			if(j!=c) cout << " ";
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    VI b(n);
    int cnt = 0;
    RREP(i,1,n+1) {
        int sum = 0;
        for (int j = i + i; j <= n; j+=i) {
            sum += b[j-1];
        }
        sum %= 2;
        if (a[i-1] != sum) {
            b[i-1] = 1;
            ++cnt;
        }
        //dump(b[i-1]);
    }
    REP(i,0,n) {
        int sum = 0;
        for (int j = i; j < n; j+=i+1) {
            sum += b[j];
        }
        if (sum % 2 != a[i]) {
            //dump(i);
            //dump(b[i]);
            std::cout << -1 << endl;
            return;
        }
    }
    bool isf = true;
    std::cout << cnt << endl;
    REP(i,0,n) {
        if (b[i] == 0) continue;
        if (!isf) std::cout << " ";
        std::cout << i+1;
        isf = false;
    }
    std::cout << endl;
}

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

Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(){
  int n;
  int score[1111][1111]={0};
  int ans[1111]={0};
  int count=0;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> score[i][j];
    }
  }
  for(int k=0;k<3;k++){
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	if(score[i][k]==score[j][k]){
	  count++;
	  score[j][k]=0;
	}
      }
      if(count > 0){
	score[i][k]=0;
	count=0;
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      ans[i]+=score[i][j];
    }
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 5992
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	int n,a,b;
  	cin>>n>>a>>b;
  	cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	int mx = (N + 1) / 2;
	puts(mx >= K ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 764
def check(num, n, sc):
    num = str(num)
    if not len(num) == n:
        return False

    for s, c in sc:
        if not num[s-1] == str(c):
            return False

    return True

def main():
    n, m = map(int, input().split())
    sc = [list(map(int, input().split())) for _ in range(m)]
    for i in range(1000):
        if check(i, n, sc):
            print(i)
            exit()
    print(-1)

main()

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

int main() {

	string a, b, c; cin >> a >> b >> c;
	if (a.back() == b[0] && b.back() == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3604
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn lcm(a: usize, b: usize) -> usize{
    return a/gcd(a, b)*b;
}

fn gcd(a: usize, b: usize) -> usize{
    if b == 0{
        return a;
    }

    return gcd(b, a%b);
}
fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);
    let s = read_as_string().chars().collect::<Vec<char>>();
    let t = read_as_string().chars().collect::<Vec<char>>();
    let l = lcm(n, m);
    let d = lcm(l/n, l/m);
    let mut di = 0;
    while di < l{
        if s[di/(l/n)] != t[di/(l/m)]{
            println!("-1");
            return;
        }
        di += d;
    }

    println!("{}", l);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,m,r,a,b,c,rl[10],w[210][210],i,j,k;
  bool con=true;
  const int INF=1e9;
  cin >> n >> m >> r;
  for (i=0;i<r;i++) cin >> rl[i];
  for (i=1;i<=n;i++) for (j=1;j<=n;j++) w[i][j]=INF;
  for (i=1;i<=n;i++) w[i][i]=0;
  for (i=0;i<m;i++){
    cin >> a >> b >> c;
    w[a][b]=w[b][a]=c;
  }
  while (con){
    con=false;
    for (i=1;i<n;i++) for (j=i+1;j<=n;j++) for (k=1;k<=n;k++){
      if (w[i][j]>w[i][k]+w[k][j]){
        w[i][j]=w[j][i]=w[i][k]+w[k][j];
        con=true;
      }
    }
  }
  sort(rl,rl+r);
  int s,ans=INF;
  do{
    s=0;
    for (i=0;i<r-1;i++) s+=w[rl[i]][rl[i+1]];
    if (ans>s) ans=s;
  }while (next_permutation(rl,rl+r));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

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

  int ans = 0;
  repa(i, 1, n+1) ans += i;
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int a,b,c;
	string result="NO";
	cin >> a;
    cin >> b;
    cin >> c;
    if(b-a==c-b) result="YES";
	cout << result << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
// Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

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

    int n, k; cin >> n >> k;
    int ans = 0;
    while (n) {
        ans++;
        n /= k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(scanner.next());
        }
        scanner.close();

        int count = 0;
        while (isEven(A)) {
            for (int i = 0; i < N; i++) {
                A[i] = A[i] / 2;
            }

            count++;
        }
        System.out.println(count);
    }

    private static boolean isEven(int[] a) {
        boolean isEven = true;
        for (int n : a) {
            if (n == 0 || n % 2 != 0) {
                isEven = false;
                break;
            }
        }
        return isEven;
    }
}


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

using namespace std;

int main(void){
  string s,t;
  int cnt = 0;
  cin >> s >> t;
  
  for(int i=0;i < s.size();i++){
    if(s[i] != t[i])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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



namespace Test1 {





    class ClassMain {

        


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                for (int i = 0; i < n; i++) {
                    line = Console.ReadLine();
                    int[] ints = line.Split(':').Select(int.Parse).ToArray();
                    //Console.WriteLine(ints[0] + " - " + ints[1]);
                    double tyoushinkaku = 30 * (ints[0] % 12) + 30.00 * (((double)ints[1]) / 60);
                    double tanshinkaku = 6 * ints[1];
                    //Console.WriteLine(tyoushinkaku + " - " + tanshinkaku);
                    double absDiff = Math.Abs(tyoushinkaku - tanshinkaku);
                    if (absDiff < 30.00 || 330.00 < absDiff) {
                        Console.WriteLine("alert");
                    } else if (90.00 <= absDiff && absDiff <= 270) {
                        Console.WriteLine("safe");
                    }
                    else {
                        Console.WriteLine("warning");
                    }

                }
                break;


            }
        }
    
    }



    
}

Measured memory_bytes: 5800
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\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(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	if(n%2){
		cout<<"No"<<endl;
		return 0;
	}
	rep(i,n/2){
		dump(s.at(i));
		dump(s.at(n/2+i));
		if(s.at(i)!=s.at(n/2+i)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

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

using namespace std;

int a[100010], b[100010], n, m, k;

int main() {
	cin >> n >> m >> k;
	int mina = 0x7fffffff, minb = 0x7fffffff;
	for(register int i = 1; i <= n; i++) {
		cin >> a[i];
		mina = min(mina, a[i]);
	}
	for(register int i = 1; i <= m; i++) {
		cin >> b[i];
		minb = min(minb, b[i]);
	}
	int ans = mina + minb;
	while(k--) {
		int x, y, z;
		cin >> x >> y >> z;
		ans = min(ans, a[x] + b[y] - z);
	}
	cout << ans << endl;
	return 0;
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int a[N];
	rep(i, N) cin >> a[i];
	deque<int> dq;
	rep(i, N) {
		if (i % 2 != N % 2) dq.push_front(a[i]);
		else dq.push_back(a[i]);
	}
	rep(i, N) cout << dq[i] << " ";
	cout << endl;

    return 0;
}


Measured memory_bytes: 3840
import numpy as np
a, b, h, m = map(int, input().split())
h %= 12
m %= 60
th1 = (h/12)*360+0.5*m
th2 = (m/60)*360
th = 0
if th1 > th2:
    th = th1 - th2
else:
    th = th2 - th1
if th > 180:
    th = 360 - th

th *= (np.pi/180)
c = np.sqrt(a**2+b**2-2*a*b*np.cos(th))
print(c)

Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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

#define P pair<int, int>

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    if (s < 1e9) {
        for (int i = 0; i < k; i++) {
            cout << s;
            if (i < n - 1) cout << ' ';
            else cout << endl;
        }
        for (int i = k; i < n; i++) {
            cout << s + 1;
            if (i < n - 1) cout << ' ';
            else cout << endl;
        }
    } else {
        for (int i = 0; i < k; i++) {
            cout << s;
            if (i < n - 1) cout << ' ';
            else cout << endl;
        }
        for (int i = k; i < n; i++) {
            cout << 1;
            if (i < n - 1) cout << ' ';
            else cout << endl;
        }
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int askRow(int s, int n) {
	cout << "?";
	for (int i = s+1; i <= s+n; ++i) cout << ' ' << i;
	cout << endl;

	string res;
	cin >> res;
	return (res == "Red") ? 1 : -1;
}
int askEq(int i, int s, int n) {
	cout << "? " << i+1;
	for (int j = s+1; j < s+n; ++j) {
		if (j > 2*n) cout << ' ' << j - 2*n;
		else cout << ' ' << j;
	}
	cout << endl;

	string res;
	cin >> res;
	return (res == "Red") ? 1 : -1;
}

const int N = 100;
int col[2*N];

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

	int n;
	cin >> n;

	// Ask first N. Shift window right one-by-one until the answer changes.
	// Since last N must have opposite answer, this happens at some point.
	// Binary search where it happens. Note that we don't need to find the first such position.
	// 1 + log2(100) ~ 8 < 10

	int x = askRow(0, n); // Sum of first n has more of x
	int low = 1;
	int high = n;
	while(low != high) {
		int mid = (low + high) >> 1;
		int y = askRow(mid, n);
		if (x != y) high = mid;
		else low = mid + 1;
	}

	// Now askRow(low-1, n) and askRow(low, n) give different answers, hence both colors appear an equal number of times in [low, low+n-2].
	for (int i = 0; i < low; ++i) col[i] = askEq(i, low, n);
	for (int i = low; i < low + n - 1; ++i) col[i] = askEq(i, low + n, n);
	for (int i = low + n - 1; i < 2*n; ++i) col[i] = askEq(i, low, n);

	cout << "! ";
	for (int i = 0; i < 2*n; ++i) {
		if (col[i] == 1) cout << 'R';
		else cout << 'B';
	}
	cout << endl;
}


Measured memory_bytes: 724
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

const ll mod=1000000007;
ll x,y;

ll modpow(ll a,ll p){
    if(p==0)return 1;
    if(p%2==0){
        ll d=modpow(a,p/2);
        return d*d%mod;
    }
    return a*modpow(a,p-1)%mod;
}

ll divide(ll a,ll b){
    return a*(ll)modpow(b,mod-2)%mod;
}

vecll perm;
void make_perm(ll m){
    perm.resize(m+1);
    perm[0]=1;
    rep2(i,1,m){
        perm[i]=perm[i-1]*i%mod;
    }
    return;
}
ll comb(ll a,ll b){
    return divide(divide(perm[a],perm[b]),perm[a-b])%mod;
}
 
int main(){
    x=in();
    y=in();
    if((x+y)%3!=0 || y > 2*x || x > 2*y){
        cout<<0<<endl;
        return 0;
    }
    ll a=(2*y-x)/3;
    ll b=(2*x-y)/3;
    make_perm((a+b+10));
    cout<<comb(a+b,a)<<endl;
}



Measured memory_bytes: 5504
fun main(args: Array<String>) {

    val (a, b, k) = readLine()!!.split(" ").map { it.toInt() }

    val an = (1..a).filter { a % it == 0 }
    val bn = (1..b).filter { b % it == 0 }

    val r = an.intersect(bn).sortedDescending()
    println(r[k-1])
}


Measured memory_bytes: 35944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


typedef struct{
  ll i;
  ll j;
  ll depth;
} data;



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

ll X,Y,Z,K;
ll pmax = 30000000000;
vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }



int main() {



  ll H,W;
  cin >> H >> W;
  char A[H+2][W+2];

  //門兵
  rep(i,H+2){
    rep(j,W+2){
      A[i][j]='#';
    }
  }

  queue<data> q;

  rep(i,H){
    rep(j,W){
      cin >> A[i+1][j+1];
      if(A[i+1][j+1]=='#'){
        q.push(data{i+1,j+1,0});
      }
    }
  }

  ll ans = 0;

  while(!q.empty()){
    data tmp = q.front();
    q.pop();
    ans = max(ans, tmp.depth);
    // cout << ans << " " << tmp.depth << endl;
    rep(i,4){
      if(A[tmp.i+dx[i]][tmp.j+dy[i]]=='.'){
        q.push(data{tmp.i+dx[i], tmp.j+dy[i], tmp.depth+1});
        A[tmp.i+dx[i]][tmp.j+dy[i]]='#';
      }
    }
  }

  cout << ans << endl;



}

















//


Measured memory_bytes: 25396
#include <cstdio>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
using namespace std;
inline char nc()
{
//	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
	x=0; int f=1,ch=nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x*=f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const int maxn=100+5;
int n;
int h[maxn];
int dp[maxn][maxn][2];
vector<pii> rec[maxn];
inline void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
ll power(ll x,ll y)
{
	ll re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
int main()
{
	read(n);
	for(int i=1;i<=n;++i) read(h[i]);
	for(int i=1;i<=n;++i) if(h[i]!=1)
	{
		int l=i,r=i,ok=1;
		for(l=i;;--l)
		{
			if(l!=i&&h[l]==h[i]) {ok=0; break;}
			if(l==1||h[l-1]<h[i]) break;
		}
		if(!ok) continue;
		for(r=i;;++r)
		{
			if(r==n||h[r+1]<h[i]) break;
		}
//		debug("%d %d %d %d\n",l,r,h[i],h[i]-max(l==1?1:h[l-1],r==n?1:h[r+1]));
		rec[r].push_back(make_pair(l,power(2,h[i]-max(l==1?1:h[l-1],r==n?1:h[r+1]))));
	}
	dp[1][0][0]=dp[1][0][1]=rec[1].size()?rec[1][0].se:1;
	for(int i=2;i<=n;++i) 
	{
		for(int j=0;j<i;++j) for(int k=0;k<2;++k) if(dp[i-1][j][k])
		{
			upd(dp[i][i][k],dp[i-1][j][k]);
			upd(dp[i][j][k^1],dp[i-1][j][k]);
		}
		for(int j=0;j<=i;++j) for(int k=0;k<2;++k) if(dp[i][j][k])
		{
			for(int l=0;l<rec[i].size();++l)
			{
				if(j<=rec[i][l].fi) dp[i][j][k]=(ll)dp[i][j][k]*rec[i][l].se%mod;
			}
		}
	}
	int an=0;
	for(int j=0;j<=n;++j) for(int k=0;k<2;++k) upd(an,dp[n][j][k]);
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		int sum = abs(a[0]);
		for(int i = 0; i < n-1; i++){
		    sum += abs(a[i+1] - a[i]);
		}
		sum += abs(a[n-1]);
		int[] d = new int[n];
		for(int i = 0; i < n; i++){
		    if(i == 0){
		        d[i] = abs(a[i+1]) - (abs(a[i]) + abs(a[i+1] - a[i]));
		    }else if(i < n-1){
		        d[i] = abs(a[i+1] - a[i-1]) - (abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]));
		    }else{
		        d[i] = abs(a[i-1]) - (abs(a[i] - a[i-1]) + abs(a[i]));
		    }
		}
		
		// 出力
		for(int i = 0; i < n; i++){
		    System.out.println(sum + d[i]);
		}
		
	}
}




Measured memory_bytes: 63436
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;
int main() {
	bool p =true;
	ll n;
	cin>>n;
	ll a[110000];
	rep(i,0,n)cin>>a[i];
	sort(a,a+n);
	if(n%3==0){
		if(a[0]!=a[n/3-1] || a[n/3]!=a[2*n/3-1] || a[2*n/3]!=a[n-1])p=false;
		if(a[n/3]!=(a[2*n/3]^a[0])) p=false;
	}
	else if(a[n-1]==0 && n%3!=0) p=true;
	else p=false;

	if(p)cout<<"Yes";
	else cout<<"No";


}

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

int main() {
    int64_t s, c;
    cin >> s >> c;

    int64_t k = min<int64_t>(s, c / 2LL);
    c -= k * 2LL;
    k += c / 4LL;
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,t=0,j=0;
	cin>>a>>b;
	string s;
	cin>>s;
	if(s[a]=='-')
		t++;
	for(int i=0;i<=a+b;i++)
		if(s[i]!='0'&&s[i]!='2'&&s[i]!='3'&&s[i]!='4'&&s[i]!='5'&&s[i]!='6'&&s[i]!='7'&&s[i]!='8'&&s[i]!='9'&&s[i]!='1'&&i!=a)
			j=1;
	if(j==0)
		t++;
	if(t==2)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;	
} 

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

long long N, M, A[100009], B[100009], C[100009], ans;
map<long long, long long> D;

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) B[i] = B[i - 1] + A[i];
	for (int i = 1; i <= N; i++) C[i] = B[i] % M;
	for (int i = 0; i <= N; i++) D[C[i]]++;
	for (int i = 0; i <= N; i++) ans += (D[C[i]] - 1);
	cout << ans / 2 << endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

ll n;
set<ll> ans;

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

    cin >> n;

    if (n == 2) {
        cout << 1;
        return 0;
    }

    ans.insert(2LL);
    ans.insert(n);
    ans.insert(n-1);
    ll x = n-1;

    for (ll i = 2LL; i*i <= x; i++) {
        if (x%i == 0) {
            ans.insert(i);
            ans.insert(x/i);
        }
    }

    for (ll i = 2LL; i*i <= n; i++) {
        if (n%i == 0) {
            ll d = i;
            x = n/d;
            while (x%d == 0) x /= d;
            if (x%d == 1) ans.insert(d);

            d = n/i;
            x = n/d;
            while (x%d == 0) x /= d;
            if (x%d == 1) ans.insert(d);
        }
    }

    cout << ans.size();

    //for (auto it: ans) cout << it << " ";




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v) memset(x,v,sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j,k;
long long dp[100000];
void solve(){
            ll n; cin>>n;
            vl v(n);
            ll z=0;
            for(i=0;i<n;i++) cin>>v[i];
              
            for(i=1;i<n;i++){
                 dp[i]=min((dp[max(z,i-1)]+abs(v[i]-v[i-1])),(dp[max(z,i-2)]+abs(v[i]-v[max(z,i-2)])));
            }
            //cnl;
            cout<<dp[n-1]<<endl;

    
}
 signed main(){
    solve();
    return 0;
  }

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    ll n;
    ll cnt=0;
    ll ans=0;
    ll a[maxn];
    
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    
    rep(i,n){
        cnt+=a[i];
        if(a[i]==0){
            ans+=cnt/2;
            cnt=0;
        }
    }
    
    ans+=cnt/2;
    
    cout << ans<<endl;
    
    return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解？
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;
}




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

vector<bool> start(N, false), en(N, false);
REP(i, M){
  int a, b;
  cin >> a >> b;
  if(a == 1) start.at(b - 1) = true;
  if(b == N) en.at(a - 1) = true;
  
}

REP(i, N){
  if(start.at(i) && en.at(i)){
    print("POSSIBLE");
    return 0;
}
}
print("IMPOSSIBLE");

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    int x = a / 0.08;
    int y = b / 0.1;

    rep(i, min(x, y), max(x, y)*max(x, y))
    {
        if (int(i * 0.08) == a && int(i * 0.1) == b)
        {
            cout << i << endl;
          	return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import sys
import math

input = sys.stdin.readline

def can(arr, m, K):
  need = 0
  for x in arr:
    if x > m:
      need += int(x // m)
  return need <= K

N, K = map(int, input().split())
arr = list(map(int, input().split()))

lo = 1
hi = int(1e9) + 1

while (lo < hi):
  m = int((lo + hi) // 2)
  if (can(arr, m, K)):
    hi = m
  else:
    lo = m + 1
print(lo)


Measured memory_bytes: 103528
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'

int main()
{
    ll sum,n,i,j;
    cin>>sum>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll x = accumulate(arr,arr+n,0);
    if(x>=sum)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 1024