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

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

    if(a<b){
        cout<<"a < b"<<endl;
    }else if(a>b){
        cout<<"a > b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls(x) ((x)<<1)
#define rs(x) (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=500005;
bool inh[maxn];
int a[maxn],n,k,v[maxn];
priority_queue<pin,vector<pin>> heap[maxn];
priority_queue<int,vector<int>> res;
namespace seg{
	int l[maxn<<2],r[maxn<<2],maxi[maxn<<2];
	inline void update(int x){
		maxi[x]=max(maxi[ls(x)],maxi[rs(x)]);
	}
	inline void build(int x,int lq,int rq){
		l[x]=lq;r[x]=rq;if(lq==rq){maxi[x]=a[lq];return;}int md=(lq+rq)>>1;
		build(ls(x),lq,md);build(rs(x),md+1,rq);update(x);
	}
	inline void clear(int x,int place){
		if(l[x]==r[x]){
			maxi[x]=0;return;
		}int md=(l[x]+r[x])>>1;
		if(place<=md)
			clear(ls(x),place);
		else
			clear(rs(x),place);
		update(x);
	}
	inline int query(int x,int lq,int rq){
		if(lq<=l[x]&&r[x]<=rq)return maxi[x];
		int md=(l[x]+r[x])>>1,res=0;
		if(lq<=md)res=max(res,query(ls(x),lq,rq));
		if(rq> md)res=max(res,query(rs(x),lq,rq));
		return res;
	}
}
inline bool query(int x){
	return seg::query(1,max(1,x-k+1),min(n,x+k-1))==a[x];
}
inline void modify(int x){
	if(x<1)return;
	if(x>((n-1)/k)+1)return;
	if(inh[heap[x].top().w2])return;
	if(query(heap[x].top().w2))res.push(heap[x].top().w2),inh[heap[x].top().w2]=1;
}
int main(){
	read(n);read(k);rep(i,1,n)read(a[i]);
	seg::build(1,1,n);
	rep(i,1,n)heap[(i-1)/k+1].push(mk(a[i],i));
	rep(i,1,(n-1)/k+1)if(query(heap[i].top().w2))res.push(heap[i].top().w2),inh[heap[i].top().w2]=1;
	per(i,n,1){
		v[res.top()]=i;
		int x=res.top();res.pop();
		heap[(x-1)/k+1].pop();seg::clear(1,x);
		modify((x-1)/k+1);modify((x-1)/k);modify((x-1)/k+2);
	}
	rep(i,1,n)printf("%d\n",v[i]);
	return 0;
}

Measured memory_bytes: 53620
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

int main() {
    int N;
    cin >> N;
    long long res = 0;
    vector<vector<long long>> num(10, vector<long long>(10, 0));
    for (int n = 1; n <= N; ++n) {
        vector<int> d;
        int nn = n;
        while (nn) {
            d.push_back(nn % 10);
            nn /= 10;
        }
        int a = d[0];
        int b = d.back();
        if (!a || !b) continue;
        ++num[a][b];
    }
    for (int a = 1; a < 10; ++a) {
        for (int b = 1; b < 10; ++b) {
            res += num[a][b] * num[b][a];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 105;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
char a[N][N];
int dp[N][N];

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) {
                dp[i][j] = a[i][j] == '#';
            } else {
                dp[i][j] = inf;
                if (i != 1) {
                    int z = (a[i][j] == '#' && a[i - 1][j] == '.');
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + z);
                }
                if (j != 1) {
                    int z = (a[i][j] == '#' && a[i][j - 1] == '.');
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + z);
                }
            }
        }
    }

    cout << dp[n][m] << endl;
	return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int times = 0;
  while (A >= B){
    B = B * 2;
    times++;
  }
  while (B >= C){
    C = C * 2;
    times++;
  }
  if (times <= K) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

struct travel_s {
    int t;
    int x;
    int y;
};

void main_()
{
    ll N;
    vector<travel_s> travels;

    cin >> N;
    for (ll n = 0; n < N; ++n) {
        int t, x, y;
        cin >> t >> x >> y;
        travels.push_back({ t, x, y });
    }

    auto manhattan_dist = [](int x1, int y1, int x2, int y2) {
        return abs(x1 - x2) + abs(y1 - y2);
    };

    for (const auto& t : travels) {
        auto md = manhattan_dist(0, 0, t.x, t.y);
        if (md > t.t || ((t.t - md) % 2 == 1)) {
            cout << "No\n";
            return;
        }
    }

    cout << "Yes\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1912
import collections
import itertools

n, c = map(int, input().split())
ds = [list(map(int, input().split())) for _ in range(c)]
colors = [collections.Counter() for _ in range(3)]
for i in range(n):
    for j, color in enumerate(map(int, input().split())):
        colors[(i + j) % 3][color - 1] += 1
res = float('inf')
for cs in itertools.combinations(range(c), 3):
    for cs2 in itertools.permutations(cs):
        s = 0
        for i in range(3):
            for k, v in colors[i].items():
                s += ds[k][cs2[i]] * v
        res = min(res, s)
print(res)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int c[4]={10,50,100,500},x;
  bool z=false;
  while(cin >> x && x) {
    if(z) cout << endl;
    z=true;

    int sum=0;
    int a[4],b[4];
    fill(b,b+4,0);
    rep(i,4) {
      cin >> a[i];
      sum+=a[i]*c[i];
    }
    sum-=x;
    rep(i,4) {
      b[3-i]=sum/c[3-i];
      sum%=c[3-i];
    }
    rep(i,4) {
      int ans=a[i]-b[i];
      if(ans>0) PR(c[i],ans);
    }
  }
  return 0;
}


Measured memory_bytes: 1160
N = int(input())
A = list(map(int,input().split()))
change_A = 0

for i in range(N):
    mini = i
    for j in range(i+1,N):
        if A[j] < A[mini]:
            mini = j
    
    if mini != i:
        v = A[i]
        A[i] = A[mini]
        A[mini] = v
        change_A += 1

for i in range(N):
    if i == N-1:
        print(A[i])
    else:
        print(A[i],end=' ')
        
print(change_A)
        
        


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else {
      x = x->right;
    }
    }
    z->parent = y;
    if(y == NIL){
      root = z;
    } else{
 if(z->key < y->key){
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  } inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL){
    return;
  } printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      // Node t = treeSearch(root, x);
      // if ( t != NIL ) printf("yes\n");
      //else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } //else if ( com[0] == 'd' ){
      //scanf("%d", &x);
      // treeDelete(treeSearch(root, x));
    // }
  }

  return 0;
}

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    long long n=b-a+1;
    long long mid;
    if(n==1)
        mid=a;
    else if((a&1)==0)
    {
        if((n/2)&1)
            mid=1;
        else
            mid=0;
        if(n&1)
            mid^=b;
    }
    else
    {
        n--;
        if((n/2)&1)
            mid=1;
        else
            mid=0;
        if(n&1)
            mid^=b;
        mid^=a;
    }
    cout<<mid;
    return 0;
}


Measured memory_bytes: 256
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	map<int, int> m;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (m.size()) {
			map<int, int>::iterator it = m.lower_bound(a);
			if (it != m.begin()) {
				--it;
				if (it->second >= 2) {
					it->second--;
				} else {
					m.erase(it);
				}
			}
		}
		m[a] += 1;
	}
	int ans = 0;
	for (auto kv : m) {
		ans += kv.second;
	}
	cout << ans << endl;
	return 0;
}


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

class Main {
    public static void main(String[] args) {
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int c;
        int[] amounts = new int[26];

        try {
            while ((line = buf.readLine()) != null) {
                for (int j = 0; j < line.length(); j++) {
                    c = (int)line.charAt(j);
                        for (int i = 0; i < 26; i++) {
                            if (c == 97 + i || c == 65 + i) { // 97+の方で小文字と、65+の方で大文字との合致を判定
                                amounts[i] += 1;
                            }
                    }
                }
            }
            for (int i = 0; i < 26; i++) {
                System.out.println((char)(i + 97) + " : " + amounts[i]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 17784
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	int f[101][10];
	int p[101][11];
	rep(i, n) {
		rep(j, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}
	int ret = -INF;
	for (int bit = 0; bit < (1 << 10); ++bit) {
		vector<int> open;
		vector<int>same(n, 0);//i件目のお店ではsame[i]個の時間帯で同時に営業している
		rep(i, 10) {
			if (bit & (1 << i)) {
				open.push_back(i);
			}
		}
		if (open.size() == 0)continue;
		rep(i, open.size()) {
			rep(j, n) {
				if (f[j][open[i]] == 1)same[j]++;
			}
		}
		int profit = 0;
		rep(i, n) {
			profit += p[i][same[i]];
		}
		ret = max(ret, profit);
	}
	print(ret);
}

Measured memory_bytes: 3628
program ABC083B;
var 
    n,a,b,r,i,j,s: integer;
begin
    read(n);
    read(a);
    read(b);
    r:=0;
    for i:=1 to n do begin
        s:=0;
        j:=i;
        while j>0 do begin
            s:=s+(j mod 10);
            j:=j div 10;
        end;
        if (a<=s) and (s<=b) then begin
            r:=r+i;
        end;
    end;
    writeln(r);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(all(A));
	int cnt = 0, ans = 0;
	for (int i = 1;i < N;i++) {
		if (A[i] == A[i - 1])
			cnt++;
	}
	if (cnt % 2) cout << N - cnt - 1 << endl;
	else cout << N - cnt << endl;
}


Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let mut each_max = vec![0i64; n + 1];
    each_max[0] = 1 - a[0];

    for i in 1..n + 1 {
        each_max[i] = min(each_max[i - 1] * 2 - a[i], 100000000_00000_0000);
    }
    debug!(each_max);

    if each_max.iter().any(|&x| x < 0) {
        println!("-1");
        return;
    }

    let mut plus = vec![0; n + 2];
    for i in 0..n + 1 {
        plus[0] += a[i];
        plus[i] -= a[i];
    }
    let mut accum = vec![0; n + 1];
    accum[0] = plus[0];
    for i in 1..n + 1 {
        accum[i] = accum[i - 1] + plus[i];
    }
    debug!(accum);
    let mut child = vec![0; n + 1];
    for i in 0..n {
        child[i] = min(accum[i], each_max[i]) + a[i];
    }
    child[n] = a[n];
    debug!(child);

    println!("{}", child.iter().sum::<i64>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5748
#include<stdio.h>
int main(void){
	int n = 0;
	char s[3];
	scanf("%s",&s);
	if(s[0] == '1') ++n;
	if(s[1] == '1') ++n;
	if(s[2] == '1') ++n;
	printf("%d",n);
	 return 0;
}	 


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main(void){
	int a;
	int b;
	int x;
	int y;
	scanf("%d %d", &a, &b);
	x = a * b;
	y = (a + b) * 2;
	printf("%d %d\n", x, y);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<b){
    for(int i=0;i<b;i++)printf("%d",a);
  }
  else{
    for(int j=0;j<a;j++)printf("%d",b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n, h;
    int step = 0, maxStep = 0, buf = 0;

    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> h;

        if(buf >= h) ++step;
        else {
            maxStep = max(maxStep, step);
            step = 0;
        }

        buf = h;
    }

    maxStep = max(maxStep, step);
    cout << maxStep << '\n';
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
#c = Counter(S)
#print (c.most_common())
#ls = list(c.values())
ans = S.count('R') * S.count('G') * S.count('B')


for i in range(N):
    for j in range(1,N):
        if (i-j<0 or i+j>=N):
            break
        #print (i,j)
        #s = set([S[i-j],S[i],S[i+j]])
        l = S[i-j]
        m = S[i]
        r = S[i+j]

        if l!=m and m!=r and r!=l:
            ans -= 1
        # if len(s)==3:
        #     ans -= 1
print (ans)


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

typedef long long ll;
typedef pair<ll,ll> ii;
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;i++)
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fst first
#define snd second

const int MAXN=2e5+15;
int n;
ll a[MAXN],sp[MAXN];
ll sum(int i,int j){return sp[j]-sp[i-1];}
ll get(int i,int j,int k) {
	return abs(sum(i,j)-sum(j+1,k));
}
ii get(int i,int j) {
	int l=i,r=j-1;
	while(l<=r) {
		int m1=l+(r-l)/3;
		int m2=r-(r-l)/3;
		if(get(i,m1,j)<get(i,m2,j))r=m2-1;
		else l=m1+1;
	}
	// cout<<i<<" "<<j<<" : r: "<<r<<endl;
	ii res={sum(i,r),sum(r+1,j)};
	if(res.fst>res.snd)swap(res.fst,res.snd);
	// cout<<i<<" "<<j<<" : "<<res.fst<<" "<<res.snd<<endl;
	return res;
}
ll get(ii a,ii b){
	return max(a.snd,b.snd)-min(a.fst,b.fst);
}
int main() {FIN;
	cin>>n;
	fore(i,1,n+1)cin>>a[i],sp[i]=sp[i-1]+a[i];
	ll res=1e18;
	fore(i,2,n-1) {
		ii l=get(1,i),r=get(i+1,n);
		res=min(res,get(l,r));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3328
N, M = map(int, input().split())
Edge = []
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    Edge.append([a, b])


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)


UF = UnionFind(N)
Score = N * (N - 1) // 2
ans = []
while Edge:
    ans.append(Score)
    a, b = Edge.pop()
    pa, pb = UF.find(a), UF.find(b)
    if not UF.same(pa, pb):
        Score -= (UF.size[pa] * UF.size[pb])
    UF.union(a, b)

print(*ans[::-1], sep='\n')


Measured memory_bytes: 30972
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
ll T;
ll a[100004],ans;
int main(){
	cin>>n>>T;
	ll minn=1e9+1;
	for (int i=0;i<n;i++){
		scanf ("%d",&a[i]);
		if (a[i]>minn)ans=max(ans,a[i]-minn);
		minn=min(minn,a[i]);
	}
	minn=a[0];ll res=0;
	for (int i=1;i<n;i++){
		if (a[i]>minn+ans-1){
			res+=a[i]-(minn+ans-1);
			a[i]=minn+ans-1;
		}
		minn=min(minn,a[i]);
	}
	cout<<res;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll A=0;
	ll B = 0;
	cin >> A >> B;
	if (A > 8 || B > 8) {
		cout << ":(";
	}
	else {
		cout << "Yay!";
	}

	return 0;

}

Measured memory_bytes: 256
import itertools

N, M = map(int, input().split())
transit = [[0]*N for _ in range(N)]

for m in range(M):
    a, b = map(int, input().split())
    transit[a-1][b-1] = 1
    transit[b-1][a-1] = 1
permutation = list(itertools.permutations(list(range(1, N+1))))
ans = 0
for p in permutation:
    if p[0] != 1:
        continue
    for i in range(len(p) - 1):
        if transit[p[i]-1][p[i+1]-1] != 1:
            break
        if i == len(p) - 2:
            ans += 1
print(ans)


Measured memory_bytes: 13916
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    rep(i, 1, 5) {
        int x;
        cin >> x;
        if (x == 0)
            cout << i;
    }
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3636
use std::io::*;
fn main() {
    let mut x = read();
    let a = read();
    let b = read();
    x -= a;
    while x - b >= 0 {
        x -= b;
    }
    println!("{}", x);
}

fn read() -> i32 {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse::<i32>().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
int T;cin>>T;
while(T--){
int N,D;
cin>>N>>D;
int res=127*(N-1);
if(N%2)res+=D;
else res+=127-D;
cout<<res<<endl;
}
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int n;
int table[10][10];
int ans;

void func(int p, int q, int cnt1, int cnt2){
	if(cnt1 > n / 2 || cnt2 > n / 2){
		return;
	}
	if(p >= n){
		ans += 1;
		return;
	}
	if(q >= n){
		func(p + 1, 0, 0, 0);
		return;
	}
	if(p == q){
		func(p, q + 1, cnt1, cnt2);
		return;
	}
	if(table[p][q] == 1){
		func(p, q + 1, cnt1 + 1, cnt2);
	}else if(table[p][q] == -1){
		func(p, q + 1, cnt1, cnt2 + 1);
	}else{
		table[q][p] = -1;
		func(p, q + 1, cnt1 + 1, cnt2);
		table[q][p] = 1;
		func(p, q + 1, cnt1, cnt2 + 1);
		table[q][p] = 0;
	}
}

int main(){
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		int m;
		cin >> m;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				table[i][j] = 0;
			}
		}
		for(int i = 0; i < m; i++){
			int x, y;
			cin >> x >> y;
			table[x - 1][y - 1] = 1;
			table[y - 1][x - 1] = -1;
		}
		ans = 0;
		func(0, 0, 0, 0);
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
  int H, W, a;
  cin >> H >> W;
  string S[H + 2], T[H];
  for (int i = 0; i < W + 2; i++) S[0] += '.' ;
  for (int i = 0; i < W + 2; i++) S[H + 1] += '.' ;
  for (int i = 1; i < H + 1; i++) {
  	cin >> S[i];
    S[i] = '.' + S[i] + '.';
  }

  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
	  if (S[i].at(j) == '#') {
		T[i - 1] += '#';
      } else {
        a = 0;
        if (S[i - 1].at(j - 1) == '#') a++;
        if (S[i - 1].at(j) == '#') a++;
        if (S[i - 1].at(j + 1) == '#') a++;
        if (S[i].at(j - 1) == '#') a++;
        if (S[i].at(j + 1) == '#') a++;
        if (S[i + 1].at(j - 1) == '#') a++;
        if (S[i + 1].at(j) == '#') a++;
        if (S[i + 1].at(j + 1) == '#') a++;
        T[i - 1] += to_string(a);
        }
    }
    a = 0;
  }
  
  for (int i = 0; i < H; i++) cout << T[i] << endl;

  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;

vector<int> xs, ys, d;
vector<vector<int>> e;
int n,m;

void dfs(int p){
	d[p] = 1;
	rep(i, e[p].size()){
		if(d[e[p][i]]==-1){
			dfs(e[p][i]);
		}
	}
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	cin>>n>>m;
	e = vector<vector<int>>(n);
	d = vector<int>(n, -1);
	rep(i, m){
		int x,y,z;cin>>x>>y>>z;x--;y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	ll ans = 0;
	rep(i, n){
		if(d[i]==-1){
			ans++;
			dfs(i);
		}
	}
	 cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9216
#import<iostream>
#define a(x) 1LL<<64-__builtin_clzll(x)
long long A,B,C,i;main(){std::cin>>A>>B;if(A^B){C=(a(A^B))-1;A&=C;B&=C;i=++C>>1;B=(B-i)?(a(B-i))-1:0;C=C-A-(A>B)*(A-1-B);std::cout<<C;}else puts("1");}

Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App {
  val Array(a, b, c, x, y) = readLine.split(" ").map(_.toInt)
  var cost = Long.MaxValue
  for (i <- 0 to math.max(x, y) * 2 by 2) {
    val tmp = math.max(0, (x - i / 2)) * a + math.max(0, (y - i / 2)) * b + c * i
    cost = math.min(cost, tmp)
  }
  println(cost)
}


Measured memory_bytes: 25428
#include<iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

bool G[N][N];
int  row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

void initialize() {
    for( int i = 0; i < N; i++ ) { row[i] = FREE; col[i] = FREE; }
    for( int i = 0; i < 2 * N-1; i++) { dpos[i] = FREE; dneg[i] = FREE;}
}

void printBoard() {
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( G[i][j] && row[i] != j) return;
		}
	}
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			cout << ( ( row[i] == j ) ? "Q" : "." );
		}
		cout << endl;
	}
}
void recursive(int i) {
   if( i == N ) { printBoard(); return; }

   for( int j = 0; j < N; j++) {
   		if( NOT_FREE == col[j] ||
   			NOT_FREE == dpos[i + j] ||
   			NOT_FREE == dneg[i - j + N - 1] ) continue;
   		row[i] = j; 
   	    col[j] = dpos[i + j] = dneg[i - j + N -1] = NOT_FREE;
   	    recursive(i + 1);
   	    row[i] = col[j] = dpos[i + j] = dneg[i - j + N -1] = FREE;
   }
}
int main(int argc, char const *argv[])
{
	initialize();
    
    for( int i = 0; i < N; i++ )
    	for( int j = 0; j < N; j++ ) G[i][j] = false;

    int k, r, c;
	cin >> k;
	for( int i = 0; i < k; i++ ) {
		cin >> r >> c;
		G[r][c] = true;
	}

	recursive(0);

	return 0;
}


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

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  rep(i,n+1) {
    if ((i % 3 != 0) && (i % 5 != 0)) {
      sum += i;
    }
  }
  cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3636
from itertools import groupby
x = input()
if x[0] == ">":
	x = "<" + x
if x[-1] == "<":
	x += ">"
l = [len(list(g)) for k, g in groupby(x)]
ans = 0
for i, j in zip(*[iter(l)] * 2):
	M = max(i, j)
	m = min(i, j)
	ans += M * (M + 1) // 2 + m * (m - 1) // 2
print(ans)

Measured memory_bytes: 8348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<int> a(n + 1, 0);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  rep(i, n) {
    ans += a[i] / 2;
    a[i] %= 2;
    if (a[i] == 1 && a[i + 1] != 0) {
      ans++;
      a[i]--, a[i + 1]--;
    }
  }
  cout << ans << '\n';



  
  return 0;
}

Measured memory_bytes: 640
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int ans = 1;
    Cini(N);
    rep(i,3) ans *= N;
    cout << ans << nn; 
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int height = in.nextInt();
            int width = in.nextInt();
            int n = in.nextInt();
            int sr = in.nextInt() - 1;
            int sc = in.nextInt() - 1;
            String s1 = in.next();
            String s2 = in.next();
            if (remains(height, s1, s2, 'U', 'D', sr) && remains(width, s1, s2, 'L', 'R', sc)) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        private boolean remains(int size, String s1, String s2, char dec, char inc, int start) {
            int min = 0;
            int max = size - 1;
            for (int pos = s1.length() - 1; pos >= 0; --pos) {
                char p2 = s2.charAt(pos);
                if (p2 == inc) {
                    min = Math.max(0, min - 1);
                }
                if (p2 == dec) {
                    max = Math.min(size - 1, max + 1);
                }
                char p1 = s1.charAt(pos);
                if (p1 == inc) {
                    --max;
                }
                if (p1 == dec) {
                    ++min;
                }
                if (min > max) {
                    return false;
                }
            }
            return (min <= start && start <= max);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 27192
MOD = 10**9 + 7

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

inv2 = pow(2, MOD-2, MOD)
nums = []
for i in range(N+3):
    num = i*(i+1)%MOD*inv2%MOD
    nums.append(num)
nums.append(0)
#print('nums:', nums)

ans = 0
for i in range(K, N+2):
    mn = nums[i-1]
    mx = nums[N] - nums[N-i]
    ans += mx-mn+1
    ans %= MOD

print(ans)


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

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

    int flag = 0;
    if(s.length() <= 3){
        flag = 1;
    }else{
        if(s.substr(0, 4) != "YAKI"){
            flag = 1;
        }
    }

    if(flag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3632
n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 10 + 1
count = 0

def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
    count += right - left

def mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)

mergeSort(S, 0, n)
print(*S)
print(count)

Measured memory_bytes: 63884
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
struct P{double x,y;};
#define rep(i,n) for(int i=0;i<n;i++)
const double EPS = 1e-15;

vector<P> cross(P a, P b){
	vector<P> ret;
	
	double x = a.x - b.x , y = a.y - b.y;
	double L = x * x + y * y;
	if(L > 4.0)return ret;
	
	L = sqrt(L);
	double C = atan2(b.y-a.y,b.x-a.x);
	double alpha = acos(L/2);
	
	P r1,r2;
	r1.x = a.x + cos(C+alpha) , r1.y = a.y + sin(C+alpha);
	r2.x = a.x + cos(C-alpha) , r2.y = a.y + sin(C-alpha);
	
	ret.push_back(r1) , ret.push_back(r2);
	return ret;
}

bool check(P cir , P pt){
	cir.x -= pt.x , cir.y -= pt.y;
	return (cir.x*cir.x + cir.y * cir.y) <= 1.0 + EPS;
}

int main(){
	int n;
	while(scanf("%d",&n) && n){
		int ret = 1;
		vector<P> data(n);
		rep(i,n)scanf("%lf,%lf\n",&data[i].x,&data[i].y);
		
		vector<P> search;
		rep(i,n){
			for(int j=i+1;j<n;j++){
				vector<P> get = cross(data[i],data[j]);
				rep(k,get.size())search.push_back(get[k]);
			}
		}
		rep(i,search.size()){
			int count = 0;
			rep(j,n)count += check(data[j],search[i]);
			ret = max(ret,count);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 1396
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1100031;

vector<pair<int,int> > g[N];
int used[N],clr[N];
int n;

void dfs(int v,int c){
	used[v]=1;
	clr[v]=c;
	for (int i=0;i<g[v].size();i++){
		int to=g[v][i].first;
		int nc=(c^g[v][i].second);
		if (used[to])
			continue;
		dfs(to,nc);
	}
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n;
    for (int i=1;i<n;i++){
    	int a,b,c;
    	cin>>a>>b>>c;
    	g[a].push_back(make_pair(b,c%2));
    	g[b].push_back(make_pair(a,c%2));
    }
    dfs(1,0);

    for (int i=1;i<=n;i++){
    	cout<<clr[i]<<endl;
    }

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 33408
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            return consoleReader.String().Replace('1', 'a').Replace('9', '1').Replace('a', '9');
        }

        IEnumerable<int> GetYakusu(int n)
        {
            int amari;
            var sqrt = (int)Math.Sqrt(n);
            for (int i = 1; i <= sqrt; i++)
            {
                var d = Math.DivRem(n, i, out amari);
                if (amari == 0)
                {
                    yield return i;
                    if (i != d)
                        yield return d;
                }
            }
        }

        public const int mod = 1000000007;
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
    }

    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int32() => int.Parse(String()); public long Int64() => long.Parse(String()); public ulong UInt64() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray(); public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt32(int count) { for (int i = 0; i < count; i++) yield return Int32(); } public IEnumerable<long> RepeatInt64(int count) { for (int i = 0; i < count; i++) yield return Int64(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt32(int count) { for (int i = 0; i < count; i++) yield return SplitInt32(); } }
}

Measured memory_bytes: 11092
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cn = [abs(a[i+1] - a[i]) for i in range(n+1)]
ct = sum(cn)
cs = [ct - cn[i] - cn[i+1] + abs(a[i] - a[i+2]) for i in range(n)]
print('\n'.join(map(str, cs)))

Measured memory_bytes: 23088
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//文字列を分割するためにchar配列で取得
		char[] ch = sc.next().toCharArray();
		//文字列を前半・後半部分に分割
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();

		for(int i = 0; i < (ch.length-1) / 2 ; i++) {
			sb1.append(ch[i]);	
			sb2.append(ch[(ch.length + 3) / 2 - 1 + i]);
		}
		String s1 = sb1.toString();
		String sr1 = sb1.reverse().toString();
		String s2 = sb2.toString();
		String sr2 = sb2.reverse().toString();
		//out.println(s1 + " " + s2);
		//out.println(sr1 + " " + sr2);
		
		boolean flag = true;

		if (!s1.equals(s2) || !s1.equals(sr1) || !s2.equals(sr2)) {
			flag = false;
		}
		
		if (flag) out.println("Yes");
		else out.println("No");
				
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
    int N;
    cin >> N;
    vector<pll> Dmin_p;
    vector<pll> Dmin_m;
    rep(i, N) {
        string S;
        cin >> S;
        ll d = 0;
        pll Dmin = make_pair(InfLL, 0);
        rep(j, S.length()) {
            d += (S[j] == '(') ? 1 : -1;
            Dmin.first = min(Dmin.first, d);
        }
        Dmin.second = d;
        if (Dmin.second > 0)
            Dmin_p.push_back(Dmin);
        else {
            Dmin.second *= -1;
            Dmin.first += Dmin.second;
            Dmin_m.push_back(Dmin);
        }
    }
    sort(Dmin_p.begin(), Dmin_p.end(), greater<pll>());
    sort(Dmin_m.begin(), Dmin_m.end(), greater<pll>());
    string ans = "Yes";
    ll dbegin = 0;
    ll dend = 0;
    rep(i, Dmin_p.size()) {
        if (dbegin + Dmin_p[i].first < 0)
            ans = "No";
        dbegin += Dmin_p[i].second;
    }
    rep(i, Dmin_m.size()) {
        if (dend + Dmin_m[i].first < 0)
            ans = "No";
        dend += Dmin_m[i].second;
    }
    if (dbegin != dend)
        ans = "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
/* AtCoder Beginner Contest 105 (๑•﹏•๑｀) */

int main(){
	int N,K;
	SCD2(N,K);
	if (N%K == 0){
		PRINTD(0);
	}else{
		PRINTD(1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if(a == c) cout << b << endl;
    else cout << a << endl;

    return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	
	ll mini = 2000000007;
	ll maxi = 0 , maxi1 = -mini , maxi2 = -mini;
	
	for(int i = 0;i<n;i++)
	{
		ll x ,y;
		cin>>x>>y;
		maxi = max(maxi , x+y);
		mini = min(mini , x+y);
		maxi1 = max(maxi1 , -x+y);
		maxi2 = max(maxi2 , x-y);
	}
	
	cout<<max(maxi - mini , maxi1 + maxi2)<<endl;
	
	return 0;
}

Measured memory_bytes: 3724