akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

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


    //K個になる上限
    ll ok = 0;
    ll ng = 1LL<<32;
    auto check = [&](ll x){
        ll cnt = 0;
        for(int i = 0; i < N; i++){
            cnt += A.end() - lower_bound(all(A), x - A[i]);
        }
        return cnt >= M;
    };
    while(ng - ok > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    //cerr<<ok<<endl;

    //累積和パート
    vector<ll> sum(N+1, 0);
    rep(i,N){
        sum[i+1] += sum[i] + A[i];
    }
    //print(A);
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll pos = upper_bound(all(A), ok - A[i]) - A.begin();
        ll cnt = N - pos;
        //cerr<<pos<<endl;
        ans += sum[N] - sum[pos] + A[i] * cnt;
        M -= cnt;
    }
    ans += M * ok;
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  const int NMMAX = 50;
  int A[NMMAX], B[NMMAX];

  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i];
  }

  int road[NMMAX];
  for (int i = 0; i < N; ++i) {
    road[i] = 0;
  }

  for (int i = 0; i < M; ++i) {
    road[A[i] - 1]++;
    road[B[i] - 1]++;
  }

  for (int i = 0; i < N; ++i) {
    cout << road[i] << endl;
  }
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$list = [];
for ($i = 1; $i <= $n; $i++) {
    fscanf(STDIN, "%s %d", $s, $p);
    $list[] = [
        'city' => $s,
        'point' => $p,
        'num' => $i,
    ];
}
foreach ($list as $index => $val) {
    $sortKey1[$index] = $val['city'];
    $sortKey2[$index] = $val['point'];
}
array_multisort($sortKey1, SORT_ASC, $sortKey2, SORT_DESC, $list);

foreach($list as $val){
    echo $val['num']."\n";
}

Measured memory_bytes: 4728
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

const int mxN = 3005;
vector<int> arr(mxN);
int n;
vector<vector<int>> dp(mxN,vector<int>(mxN,-1));

int func(int l, int r){
	if(dp[l][r]!=-1) return dp[l][r];
	if(l > r) return 0;
	if(l == r) {
		return arr[l];
	}
	int ans = arr[l] - func(l+1,r);
	ans = max(ans, arr[r] - func(l,r-1));
	dp[l][r] = ans;
	return ans;
}

void solve(){
	cin >> n;
	for(int i = 0;i < n; i++) cin >> arr[i];
	cout << func(0, n-1) << "\n";	
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 74436
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
 double x1, y1, x2, y2;
 cin >> x1 >> y1 >> x2 >> y2;
 double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
 printf ("%lf\n", d);
 return 0;
}


Measured memory_bytes: 3204
import sys
n = int(sys.stdin.readline().rstrip("\n"))
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
p = 10**9+7
s = 0
s_2 = 0
for i in a:
    s += i
    s = s % p
    s_2 += i*i
    s_2 = s_2 % p
ans = ((s**2 - s_2) % p)*(2**(p-2)) % p
print(ans)

Measured memory_bytes: 350868
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;


int main(){
    ll N;
    cin >> N;
    ll sum=0;
    REP(i,N)sum+=i;
    cout << sum<<endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3
apple
orange
apple
1
grape"# => r#"2"#,

r#"3
apple
orange
apple
5
apple
apple
apple
apple
apple"# => r#"1"#,

}


fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        s: [String; n],
        m: usize,
        t: [String; m],
    }
    let mut map:std::collections::HashMap<String, isize> = std::collections::HashMap::new();

    for i in s {
        *map.entry(i).or_insert(0) += 1;
    }

    for i in t {
        *map.entry(i).or_insert(0) -= 1;
    }

    let mut ans = 0;
    for m in &map {
        ans = std::cmp::max(ans, *m.1);
    }


    ans.to_string()
}

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

int main() {
  	int N;
  	cin >> N;
  
  	int sum = 0;
  	vector<int> vec(N);
  	for(int i = 0; i < N; i++) {
    	cin >> vec.at(i);
      	sum += vec.at(i);
    }
  
  	int M;
  	cin >> M;
  
  	vector<int> P(M);
  	vector<int> X(M);
  
  	for(int i = 0; i < M; i++) {
    	cin >> P.at(i) >> X.at(i);
      
      	cout << sum - vec.at(P.at(i) - 1) + X.at(i) << endl;
    }
    	
}

Measured memory_bytes: 256
n,d=map(int,input().split())
x=[]
import math
ans=0
for i in range(n):
    x.append([int(xi) for xi in input().split() ])
for i in range(n):
    for j in range(i+1,n):
        distance=math.sqrt(sum([(x[i][k]-x[j][k])**2 for k in range(d)]))
        if int(distance)==distance:
            ans+=1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    ll result = 0L;
    if (B <= A + 2) {
        result = K + 1;
    } else {
        ll has = 1;
        ll lest = K;

        while (lest > 0) {
            // DEBUG(has);
            // DEBUG(lest);
            if (has < A) { // 足りないから叩いて作るとき
                ll need = A - has;
                if (lest < need + 2) {
                    has += lest;
                    lest = 0;
                    break;
                } else {
                    lest -= need;
                    has += need;
                    has -= A;
                    has += B;
                    lest -= 2;
                }
            } else { // 足りてるからクッキーを変換するとき
                if (lest < 2) {
                    has += lest;
                    lest = 0;
                    break;
                } else {
                    has -= A;
                    has += B;
                    lest -= 2;
                }
            }
        }
        result += has;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

const int MAXN = 1010;
const int MAXK = 1010;
long long P[MAXN][MAXK];

// 分割数 (n: 玉の数, k: 箱の数)
// 前処理時間 O(nk)
// クエリ時間 O(1)
void calcPartition(int n, int k) {
    P[0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            P[i][j] = P[i][j - 1];
            if (i - j >= 0)
                P[i][j] = (P[i][j] + P[i - j][j]) % MOD;
        }
    }
}

void _main() {
    int n, k;
    cin >> n >> k;
    if (n - k < 0) {
        cout << 0 << endl;
        return;
    }
    calcPartition(n, k);
    cout << P[n - k][k] << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 10976
# Tenka1 Programmer Beginner Contest 2019
# https://atcoder.jp/contests/tenka1-2019-beginner
# 
# 

import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main(A, B, C):
    if A <= C and C <= B:
        print('Yes')
    elif B <= C and C <= A:
        print('Yes')
    else:
        print('No')

A, B, C = i2nn()
main(A, B, C)


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
   int N;
   cin >> N;
   map<int, int> log;
   int tmp;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      log[tmp] = 1;
   }
   int ans = 0;
   for (map<int, int>::iterator it = log.begin(); it != log.end(); ++it) {
      ans++;
   }
   cout << ans << endl;
   return 0;
}


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


public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		String strArray[] = str.split(" ",0);

		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);

		if(a<b){

			System.out.println("a < b");
		}
		else if(a>b){

			System.out.println("a > b");
		}
		else if(a==b){

			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17052
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        Console.WriteLine(s[0] == 'S' ? "Cloudy" : s[0] == 'C' ? "Rainy" : "Sunny");
    }
}


Measured memory_bytes: 11092
l,r=map(int,input().split())
s=10000
for i in range(l,r+1):
    if i%2019==0:
        s=0
        break
    elif (i%673==0 and r-l!=1) or (i%673==0 and (r%3==0 or l%3==0)):
        s=0
        break
if s==0:
    print(0)
else:
    t=10000
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ((i%2019)*(j%2019))%2019<t:
                t=((i%2019)*(j%2019))%2019
    print(t)

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	vector<int> v(3);
	REP(i,3){
		cin >> v[i];
	}

	SORT(v);
	int ans = v[0] + v[1];
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
var
n,i:longint;
xi,yi,ti:array[0..100000] of longint;
function travel:string;
begin
for i:=1 to n do
begin
if (ti[i]+ti[i-1]+xi[i]+yi[i]+yi[i-1]+xi[i-1]) mod 2=1 then exit('No');
if ti[i]-ti[i-1]<abs(xi[i]-xi[i-1])+abs(yi[i]-yi[i-1]) then exit('No');
end;
exit('Yes');
end;
begin
xi[0]:=0;
yi[0]:=0;
ti[0]:=0;
read(n);
for i:=1 to n do read(ti[i],xi[i],yi[i]);

writeln(travel);
end.

Measured memory_bytes: 1280
n = int(input())
a = list(map(int,input().split()))
num = [0]*(n+1)
s = 0
for i in a:
    num[i] += 1
for i in num:
    s += i*(i-1)//2
for i in range(n):
    print(s-num[a[i]]+1)

    

Measured memory_bytes: 26140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}


bool vis[100000+10];
int main()
{

   ll n,m,k;
   cin>>n>>m>>k;
   ll temp=min(n,k);
   n=n-temp;
   k=k-temp;
   temp=min(k,m);
   m-=temp;
   cout<<n<<" "<<m<<endl;


}

















Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n=int(input())
x=list(map(int,input().split()))
mn=min(x)
mx=max(x)
ans=float("inf")
for i in range(mn,mx+1):
    a=0
    for X in x:
        a+=(i-X)**2
    ans=min(ans,a)
print(ans)


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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 a, b, n;
    cin >> a >> b >> n;
    if (n >= b) n = b - 1;
    cout << a * n / b - a * (n / b) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3652
n, a, b = map(int ,raw_input().split())
s = raw_input()

kaigai = 0
sougou = 0
for i in range(len(s)):
    if s[i] == 'a':
        if sougou < a+b:
            print "Yes"
            sougou += 1
        else:
            print "No"
    elif s[i] == 'b':
        if sougou < a+b and kaigai<b:
            print "Yes"
            sougou += 1
        else:
            print "No"
        kaigai+= 1
    else:
        print "No"


Measured memory_bytes: 6276
n=input()
S=list(map(int,input().split()))
q=input()
T=list(map(int,input().split()))

count=0
U0 = max(S)+1
for i in T:
    L=-1
    U=int(n)
    
    while(U-L>1):    
        if S[(L+U)//2]<=i:
            L=(L+U)//2
        else:
            U=(L+U)//2
    if S[L]==i:
        count+=1
print(count)


    
    


Measured memory_bytes: 16708
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def bit_add(a, i, n, x):
    while i < n:
        a[i] += x
        i += i & -i
def bit_add2(a, i, j, n, x):
    if j<<1 < n:
        n = 1 << j.bit_length()
    while i < n:
        a[i] += x
        i += i & -i
    while j < n:
        a[j] -= x
        j += j & -j

def bit_sum(a, i):
    res = 0
    while i > 0:
        res += a[i]
        i ^= i & -i
    return res

def resolve():
    it = map(int, sys.stdin.read().split())
    N, Q = next(it), next(it)
    X = Q.bit_length()
    mask = (1 << X)-1

    Aa = [next(it)-1 for i in range(N)]
    Aq = [0] * Q
    Ac = [0] * Q
    for i in range(Q):
        l, r = next(it), next(it)
        Aq[i] = r<<X | i
        Ac[i] = l

    Aq.sort()
    dp = [1] * N
    N1 = N+1
    bit = [0] * N1

    ans = [0] * Q
    offset = 0
    for arg in Aq:
        r = arg >> X
        i = arg & mask

        for j in range(offset, r):
            ci = Aa[j]
            j += 2

            j0 = dp[ci]
            bit_add2(bit, j0, j, N1, 1)

            dp[ci] = j

        offset = r
        l = Ac[i]

        ans[i] = bit_sum(bit, l)

    print(*ans, sep="\n")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 202460
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
const int N = 1e5 + 5;
typedef long long ll;
#define int ll
using namespace std; 

int n, l[N], r[N], len[N], ans, addl, addr; 
priority_queue<int> L;
priority_queue<int, vector<int>, greater<int> > R; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int mabs(int x) { return x > 0 ? x : -x; }

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> ();
	for(int i = 1; i <= n; i++) l[i] = read <int> (), r[i] = read <int> (), len[i] = r[i] - l[i]; 
	L.push(l[1]), R.push(l[1]); 
	for(int x, y, i = 2; i <= n; i++)
	{
		addl -= len[i], addr += len[i - 1]; 
		x = L.top() + addl, y = R.top() + addr;
		if(l[i] < x)
		{
			ans += x - l[i], L.pop(), R.push(x - addr);
			L.push(l[i] - addl), L.push(l[i] - addl); 
		}
		else if(l[i] > y)
		{
			ans += l[i] - y, R.pop(), L.push(y - addl);
			R.push(l[i] - addr), R.push(l[i] - addr); 
		}
		else L.push(l[i] - addl), R.push(l[i] - addr); 
	}
	printf("%lld\n", ans); 
	return 0; 
}


Measured memory_bytes: 6964
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

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

struct P {
  int y,x,d,t;
  P(int y, int x, int d, int t) :
    y(y),x(x),d(d),t(t) {}
};

int vt[4][4];

void click(int i, int j, int nxt[4][4]) {
  nxt[i][j]++;
  if (nxt[i][j] == 5) {
    nxt[i][j] = 0;
    queue<P> Q;
    REP(k,4) Q.push(P(i,j,k,0));
    memset(vt,-1,sizeof(vt));
    while(!Q.empty()){
      P p = Q.front(); Q.pop();
      int y = p.y + dy[p.d];
      int x = p.x + dx[p.d];
      if (!valid(y,x,4,4)) continue;
      if (vt[y][x] == p.t) continue;
      if (nxt[y][x]) {
        nxt[y][x]++;
        if (nxt[y][x] == 5) {
          nxt[y][x] = 0;
          vt[y][x] = p.t;
          REP(k,4) Q.push(P(y,x,k,p.t+1));
        }
      } else {
        Q.push(P(y,x,p.d,p.t+1));
      }
    }
  }  
}
int ans;
void solve(int now[4][4], int nest) {
  int cnt = 0;
  REP(i,4)REP(j,4) if (now[i][j])cnt++;

  // cout << nest << endl;
  // REP(i,4){REP(j,4)cout<<now[i][j];cout<<endl;}cout<<endl;
  
  if (cnt == 0) {
    chmin(ans, nest);
    return;
  }
  if (nest == 5) return;

  int nxt[4][4];
  REP(i,4) REP(j,4) {
    REP(ii,4)REP(jj,4)nxt[ii][jj]=now[ii][jj];
    click(i,j,nxt);
    solve(nxt, nest+1);
  }
}

int a[4][4];
int main() {
  REP(i,4)REP(j,4)cin>>a[i][j];
  ans = 6;
  solve(a,0);
  if (ans == 6) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, a, b);

    vector<bool> vec(4, true);
    vec[a] = vec[b] = false;

    reps(i, 1, 3) {
        if (vec[i]) {
            outl(i);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m1,m2,d1,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1==m2){
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
        
        string s =Console.ReadLine();
        if(s=="Sunny"){
            Console.WriteLine("Cloudy");
        }else if(s=="Cloudy"){
            Console.WriteLine("Rainy");
        }else{
            Console.WriteLine("Sunny");
        }
        
    }
}


Measured memory_bytes: 11092
import sys
import math

def readdata():
    for line in sys.stdin:
        yield map(int,line.split())

def rounder(decimal):
    rounded = round(decimal*1000)/1000
    if rounded == -0.0:
        rounded = +0.0
    return rounded

for data in readdata():
    [a,b,c,d,e,f] = map(float,data)
    det = a*e-b*d
    x = (c*e-b*f)/det
    y = (a*f-c*d)/det
    [x,y] = map(rounder,[x,y])
    print "%1.3f %1.3f" % (x,y)

Measured memory_bytes: 4384
#include <iostream>
#define MAX_N 50
using namespace std;

int N;
int a[MAX_N];
int main(){
    cin >> N;
    int max_val = -1e7, min_val = 1e7, max_index = -1, min_index = -1;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        if(max_val < a[i]){
            max_val = a[i];
            max_index = i;
        }
        if(min_val > a[i]){
            min_val = a[i];
            min_index = i;
        }
    }
    cout << 2 * N - 1 << endl;
    if(abs(max_val) >= abs(min_val)){
        for(int i = 0; i < N; ++i){
            if(i == max_index) continue;
            cout << max_index + 1 << " " << i + 1 << endl;
        }
        cout << max_index + 1 << " " << max_index + 1 << endl;
        for(int i = 0; i < N - 1; ++i){
            cout << i + 1 << " " << i + 2 << endl;
        }
    }else{
        for(int i = 0; i < N; ++i){
            if(i == min_index) continue;
            cout << min_index + 1 << " " << i + 1 << endl;
        }
        cout << min_index + 1 << " " << min_index + 1 << endl;
        for(int i = N - 1; i >= 1; --i){
            cout << i + 1 << " " << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    vector<ll> ans(n);
    if(n%2==0){
        int now = n-1;
        rep(i,n){
            ans[i] = v[now];
            if(now==1) now = 0;
            else if(now ==0) now+=2;
            else if(now%2!=0) now-=2;
            else now+=2;
        }
    }else{
        int now = n-1;
        rep(i,n){
            ans[i] = v[now];
            if(now%2==0 && now>=2) now -= 2;
            else if(now == 0 ) now=1;
            else if(now%2!=0) now+=2;
        }
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i=0;i<N;i++) cin >> vec[i];
  
  long long ans = 0;
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      if (i!=j) ans += vec[i]*vec[j];
    }
  }
  
  cout << ans/2;
  
  return 0;
}


Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM = 
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	    cout<<"Yes";
	else
	    cout<<"No";
    return 0;
}


//252908XL

/*
comments:-

*/


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

int main()
{
	int red, green, blue, k, temp=0;
	cin>> red >> green >> blue >> k;
	temp = k;
	for(int i=1; i<=k; i++){
		if(red>=green){
			green = green*2;
			temp--;
		}else{
			break;
		}
	}
	for(int i=1; i<=temp; i++){
		if(green >= blue){
			blue = blue*2;
		}else{
			break;
		}
	}
	if(blue>green && green>red){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3632
hisi = 0
tyou = 0
while True:
    try:
        a,b,c = map(int,input().split(","))
        if a == b:
            hisi += 1
        elif a ** 2 + b ** 2 == c ** 2:
            tyou += 1
    except EOFError:
        print(tyou)
        print(hisi)
        break
        

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

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

typedef long long ll;
const int maxn = 2005, mod = 924844033;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n, k, fac[maxn << 2], ifac[maxn << 2], f[maxn];

struct edge
{ 
	int to, next;
} e[maxn << 3];
int h[maxn << 2], tot, cnt;
bool vis[maxn << 2];

inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}

void dfs(int u)
{
	vis[u] = 1; cnt += u > (n << 1);
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (!vis[v]) dfs(v);
}

inline int C(int n, int m)
{
	return (ll)fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

int main()
{
	n = gi(); k = gi();
	fac[0] = ifac[0] = ifac[1] = 1;
	for (int i = 1; i <= n << 2; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
	for (int i = 2; i <= n << 2; ++i) ifac[i] = (ll)(mod - mod / i) * ifac[mod % i] % mod;
	for (int i = 1; i <= n << 2; ++i) ifac[i] = (ll)ifac[i - 1] * ifac[i] % mod;

	cnt = n << 1;
	for (int i = 1; i <= n; ++i) {
		if (i > k) ++cnt, add(cnt, i - k), add(cnt, n + i);
		if (i <= n - k) ++cnt, add(cnt, i + k), add(cnt, n + i);
	}

	f[0] = 1;
	for (int i = 1; i <= n << 1; ++i)
		if (!vis[i]) {
			cnt = 0; dfs(i);
			for (int i = n; i >= 1; --i)
				for (int j = 1; j <= i && (j << 1) <= cnt + 1; ++j) f[i] = (f[i] + (ll)f[i - j] * C(cnt - j + 1, j)) % mod;
		}

	int ans = 0;
	for (int i = 0; i <= n; ++i)
		if (~i & 1) ans = (ans + (ll)fac[n - i] % mod * f[i]) % mod;
		else ans = (ans + (ll)(mod - fac[n - i]) * f[i]) % mod;
	printf("%d\n", ans);
	
	return 0;
}



Measured memory_bytes: 512
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();
 
	

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

    sort(all(a));
    if ((a[0] == a[1]) && (a[1] != a[2]) || (a[1] == a[2]) && (a[0] != a[1]))
       cout << "Yes" << endl;
    else
       cout << "No" << endl;         

    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;
//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
      
}

Measured memory_bytes: 256
#include <stdio.h>
#define max 100
#define INF 2147483647
#define nil -1
#define true 1
#define white 2
#define gray 3
#define black 4
typedef struct{
  int degree; //出次数を表す。
  int Adj[max]; //隣接リスト(隣接する頂点の番号のリスト)。
  int color;
  int d; //始点からそのノードまでの最短コストを記録する。
  int pi; //最短経路木におけるそれぞれのnodeの親を表す。
} node;
void initializeSingleSource(node *, int);
void dijkstra(node *, int);
int n, A[max][max];

int main()
{
  //単一始点最短経路のプログラム
  int i, j, num;
  node node[max];
      
  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++) A[i][j] = INF; }
  
  for(i = 0 ; i < n ; i++){
    scanf("%d",&num);
    scanf("%d",&node[num].degree);
    for(j = 0 ; j < node[num].degree ; j++){
      scanf("%d",&node[num].Adj[j]);
      scanf("%d",&A[num][node[num].Adj[j]]); }
  }

  dijkstra(node, 0);

  for(i = 0 ; i < n ; i++) printf("%d %d\n",i,node[i].d);

  return 0;
}

void initializeSingleSource(node *node, int s)
{
  int i;

  for(i = 0 ; i < n ; i++){
    node[i].d = INF;
    node[i].pi = nil;
    node[i].color = white; }

  node[s].d = 0;
  
}

void dijkstra(node *node, int s)
{
  int mincost, i, u;
  
  initializeSingleSource(node, s);

  while(true){
    mincost = INF;
    for(i = 0 ; i < n; i++){
      if(node[i].color != black && node[i].d < mincost){
	mincost = node[i].d;
	u = i; }
    }
      if(mincost == INF) break;
      node[u].color = black;
      for(i = 0 ; i < node[u].degree ; i++){
	if(node[node[u].Adj[i]].color != black && node[u].d + A[u][node[u].Adj[i]] < node[node[u].Adj[i]].d){
	  node[node[u].Adj[i]].pi = u;
	  node[node[u].Adj[i]].d = node[u].d +  A[u][node[u].Adj[i]]; }
      }
  }

}


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

#define int long long
#define test int t; cin >> t; while (t--)
#define deb(x) cerr << "[" << #x  << " : "<< x << "]\n";
#define debb(x, y) cerr << "\t[" << #x << " : " << x << ", " << #y << " : " << y << "]\n";
#define debv(v) { cerr << #v << " : "; for (auto x : v) cerr << x << ' '; cerr << "\n"; }
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define MAX 50000
 
typedef long double ld;
const int N = 1e5 + 10;
const int maxn = 2e6 + 10;

signed main() {
						
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s;
	cin >> s;
	
	int ans = 0;
	for (int i = 0; i < (int)s.size(); ) {
		if (s[i] == 'R') {
			int cnt = 0;
			while (i < (int)s.size() && s[i] == 'R') {
				i++;
				cnt++;
			}
			ans = max (ans, cnt);
		}
		else {
			i++;
		}
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

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


int main() {
	vector<int> four,two,other;
	int N, a;
	cin >> N;
	rep(i, N) {
		cin >> a;
		if (a % 4 == 0) {
			four.push_back(a);
		}
		else if (a % 2 == 0) {
			two.push_back(a);
		}
		else {
			other.push_back(a);
		}
	}
	if (N / 2 <= four.size()) {
		cout << "Yes" << endl;
	}
	else if (other.size() <= four.size() ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1012
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}

Measured memory_bytes: 21972
n = gets.to_i
cities = gets.split(' ').map(&:to_i)
braves = gets.split(' ').map(&:to_i)
count = 0
n.times do |i|
  brave = braves[i]
  2.times do |j|
    city = cities[i + j]
    monster = city <= brave ? city : brave
    brave -= monster
    cities[i + j] = city - monster
    count += monster
  end
end
puts count

Measured memory_bytes: 15500
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
	vector<int> arr(3);
	int k;
	for(int i=0;i<3;i++){
		cin >> arr[i];
	}
	cin >> k;
	
	for(int i=0;i<k;i++){
		sort(arr.begin(), arr.end());
		arr[2] *= 2;
	}
	cout << arr[0] + arr[1] + arr[2] << endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define rf(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rb(i,b,a) for(int (i) = (b); (i) >= (a); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl
#define test(t) int(testCnt) = 0; int(t); cin >> (t); while(t -- && ++testCnt)

const int INF = 2e9 + 7;
const int MAXA = 1e5 + 10;
const ll MOD = (ll) 1e9 + 7;
const ll INFLL = 9e18 + 7;

typedef pair<int, int> ii;
typedef pair<ii, int> II;
typedef vector<int> vi;
typedef vector<ii> vii;

int f[MAXA], h[MAXA];
int n;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
    #endif
    cin >> n;
    rf(i, 1, n) {
        cin >> h[i];
    }
    f[1] = 0;
    f[2] = f[1] + abs(h[2] - h[1]);
    rf(i, 3, n) {
        f[i] = min(f[i - 1] + abs(h[i - 1] - h[i]), f[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1024
while True:
    a,op,b = map(str,input().split())
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a -b)
    elif op == '/':
        print(a // b)
    elif op == '*':
        print(a * b)



Measured memory_bytes: 5596
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(mst_a,mst_b) memset(mst_a,mst_b,sizeof(mst_a))
#define fora(fora_x,fora_a,fora_b) for(re nti (fora_x)=(fora_a);(fora_x)<=(fora_b);++(fora_x))
#define forb(forb_x,forb_a,forb_b) for(re nit (forb_x)=(forb_a);(forb_x)>=(forb_b);--(forb_x))
#define foral(foral_x,foral_a,foral_b) for(re ll (foral_x)=(foral_a);(foral_x)<=(foral_b);++(foral_x))
#define forbl(forbl_x,forbl_a,forbl_b) for(re ll (forbl_x)=(forbl_a);(forbl_x)>=(forbl_b);--(forbl_x))
#define re register
#define stt struct
#define nms namespace
#define gc getchar
#define sl(sl_a) strlen(sl_a)
#define gt(gt_a) goto gt_a
#define rt return
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(abss_x) ((abss_x)>(0)?(abss_x):(-1)*(abss_x))
#define maxx(maxx_a,maxx_b) ((maxx_a)>(maxx_b)?(maxx_a):(maxx_b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define in(in_a) freopen("F:/""/in"in_a".in","r",stdin)
#define out(out_a) freopen("F:/""/out"out_a".out","w",stdout)
#define filein(a) freopen(a,"r",stdin)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=100004;
const nit maxb=104;
const nit maxc=4;
const tni maxd=10004;
const int mod = 998244353;
#include<algorithm>

ll ans=1;
tin n,x[maxa]={0},t[maxa]={1};

tin main()
{
    scanf("%d",&n);
    fora(i,1,n)
    {
        scanf("%d",&x[i]);
        if(((i==1)&&(x[i]!=0))||((i!=1)&&(x[i]==0)))
		{
            printf("0\n");
            rt 0;
        }
    }
    //
    stable_sort(x+1,x+1+n);
	fora(i,1,n)
	{
		ans=ans*t[x[i]]%mod;
		++t[x[i]+1];
	}
	//
    printf("%lld\n",ans);
    rt 0;
}

Measured memory_bytes: 1036
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;

ll n, a[N], par[N];
int main(){
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		a[i] -= i;
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++){
		par[i] = par[i - 1] + a[i];
	}
	pll Min = {INF, -INF};
	for (int i = 1; i <= n; i++){
		ll Sum = par[n] - 2 * par[i] + a[i] * (2 * i - n);
		if (Sum < Min.F){
			Min = {Sum, a[i]};
		}
	}
	cout << Min.F;
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 3328