akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::BinaryHeap;
fn main() {
    input!{
        n:usize,
        m:i64,
        mut ab: [(i64,i64);n],
    }
    // let mut dp:Vec<Vec<i64>> = vec![vec![0;];];
    ab.sort();
    // ab.reverse();
    // println!("{:?}", ab);
    let mut ans:i64 = 0;
    let mut heap = BinaryHeap::new();
    let mut i = 0;
    for last_day in 0..m+1 {
        loop {
            if i>=n {break;}
            if ab[i].0 <= last_day {
                heap.push(ab[i].1);
            }else{
                break;
            }
            i+=1;
        }
        match heap.pop() {
            Some(s) => ans+=s,
            None => {}
        }
        // ans+=heap.pop();
    }
    println!("{}", ans);
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve(){
	ll n;
	cin >> n;
	string s;
	while(n > 0) {
		--n;
		s += char('a' + n % 26);
		n /= 26;
	}
	
	reverse(all(s));
	
	cout << s;
}

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

	solve();
    
    return 0;
}


Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int A, B, K;
		cin >> A >> B >> K;

		for( int i = 0; i < K; ++i ) {
			if( (i&1) == 0 ) {
				if( A&1 ) { A -= 1; }
				B += A/2;
				A /= 2;
			}
			else {
				if( B&1 ) { B -= 1; }
				A += B/2;
				B /= 2;
			}
		}

		cout << A << ' ' << B << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
## ABC105C - Base -2 Number
def main():
    n = int(input())
    ans = ""
    while n != 0:
        r = n % 2
        r += 2 if r < 0 else 0
        n = (n - r) // -2
        ans += str(r)
    print(0 if ans == "" else ans[::-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a,b,C,S,L,h,d;
        a = sc.nextDouble();
        b = sc.nextDouble();
        C = sc.nextDouble();
        d = Math.sqrt((a * a) + (b * b) -2 * a * b * Math.cos(Math.toRadians(C)));
        S = (a * b * Math.sin(Math.toRadians(C))) / 2.0;
        L = a + b + d;
        h = (S * 2.0) / a; 
        System.out.printf("%.10f\n",S);
        System.out.printf("%.10f\n",L);
        System.out.printf("%.10f\n",h);
        
    }
}


Measured memory_bytes: 28272
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define MOD 1000000007
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a,a+n);
	sort(b,b+n);
	cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<endl;
	
	return 0;
}

Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a,b; cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
}


Measured memory_bytes: 256
// Problem : A - Range Product
// Contest : AtCoder - AtCoder Grand Contest 002
// URL : https://atcoder.jp/contests/agc002/tasks/agc002_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
    return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
    mem(isprime,true);
    for(ll p=2;p*p<=n;p++)
    {
        if(isprime[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
                isprime[i]=false;
        }
    }
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
void solve()
{
    ll a,b;
    cin>>a>>b;
    if(a*b <= 0)
    	cout<<"Zero";
    else if(a>0 and b>0)
    	cout<<"Positive";
    else if(a*b>0 and (abs(a-b))&1)
    	cout<<"Positive";
    else
    	cout<<"Negative";
}
int main()
{
    ll inpoup = 0;
    if(inpoup==1)
    {
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    IOS
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    long long ret = 0;
    int next = 1;
    int a;
    for (auto i = 0;i < N; ++i) {
        cin >> a;
        if (a == next) {
            next ++;
            continue;
        }
        ret ++;
    }
    if (next == 1) {
        cout << -1 << endl;
    } else {
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
#include <cfenv>
#include <cmath>
#include <vector>
#include <iterator>
#include <sstream>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<vector<int>> X(N,vector<int>(2));
	for (int a = 0; a < N; a++) {
		cin >> X[a][0];
		X[a][1] = a;
	}
	sort(X.begin(), X.end(), [](const vector<int> & a, const vector<int> & b) {return a[0] < b[0]; });

	vector<int> A(N);
	for (int a = 0; a < N; a++)
	{
		int index = X[a] [1] ;
		int temp;
		if ((double)(N + 1) / 2 > a+1) {
			temp = X[ceil((double)(N + 1) / 2) - 1][0];
		}
		else {
			temp=X[floor((double)(N + 1) / 2) - 1][0];
		}
		A[index] = temp;
	}
	for (int a = 0; a < N; a++) {
		cout << A[a]<<endl;
	}
}

Measured memory_bytes: 13952
#include<iostream>
using namespace std;
int main()
{
	string s,t;int f=0;
	cin>>s>>t;
	if (s.size()!=t.size()) f=1;
	for (int i=0;i<s.size();i++) if (s[i]!=t[t.size()-i-1]) f=1;
	if (f==1)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;
}

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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

int main() {
  modint fact[100005];
  fact[0] = fact[1] = 1;
  for (int i = 2; i < 100005; i++) {
    fact[i] = fact[i - 1] * i;
  }
  auto nCk = [&](int n, int k) -> modint {
    if (n < k) return 0;
    return fact[n] / fact[k] / fact[n - k];
  };

  int N;
  cin >> N;
  int x, y;
  map<int, int> m;
  for (int i = 0; i < N + 1; i++) {
    int a;
    cin >> a;
    if (m.count(a)) {
      x = m[a];
      y = i;
    }
    m[a] = i;
  }
  for (int k = 1; k <= N + 1; k++) {
    int r = N + 1 - (y - x + 1);
    modint ans = nCk(N + 1, k) - nCk(r, k - 1);
    cout << ans << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 6656
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n k xs

solve :: Int -> Int -> U.Vector Int -> Int
solve n k xs = go 0 sums 40
  where
    sums :: U.Vector Int
    sums = U.concatMap (U.scanl1' (+) . flip U.drop xs) $ U.generate n id

    go !res !acc i
        | i < 0 = res
        | U.length xs >= k = go (setBit res i) xs (i - 1)
        | otherwise = go res acc (i - 1)
      where
        (xs, _) = U.unstablePartition (`testBit` i) acc


Measured memory_bytes: 13692
#include <cstdio>

using namespace std;

int main()
{
	int price;
	int min_p = 3000, min_j = 3000;
	for (int i = 0; i < 3; i++){
		scanf("%d", &price);
		
		if(min_p > price) min_p = price;
	}
	
	for (int i = 0; i < 2; i++){
		scanf("%d", &price);
		
		if(min_j > price) min_j = price;
	}
	
	printf("%d\n", min_p + min_j - 50);
	
	return (0);
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <stdlib.h>

using namespace std;

struct Point {
  int x;
  int y;
  Point(int x1, int y1) : x(x1), y(y1) {;}
  Point() : x(0), y(0) {;}
};

int direction(Point p, Point pre_p) {
  if (p.x > pre_p.x) { return 0; }
  if (p.x < pre_p.x) { return 2; }
  if (p.y > pre_p.y) { return 1; }
  if (p.y < pre_p.y) { return 3; }
  assert(false);
}

int main() {
  int polygon_num;
  int polygon_ore[51];
  int polygon_length[51][11];
  int polygon_angle[51][11];
  Point polygon_point[51][11];
  while (cin >> polygon_num, polygon_num > 0) {
    for (int i = 0; i < polygon_num + 1; i++) {
      cin >> polygon_ore[i];
      int vect = 0;
      int pre_vect = 0;
      for (int j = 0; j < polygon_ore[i]; j++) {
	Point p;
	cin >> p.x >> p.y;
	polygon_point[i][j].x = p.x;
	polygon_point[i][j].y = p.y;
	if (j > 0) {
	  Point pre_p = polygon_point[i][j-1];
//	  cout << "i = " << i << ", j = " << j << " " << abs(p.x - pre_p.x) << " " << abs(p.y - pre_p.y) << endl;
          polygon_length[i][j-1] = max(abs(p.x - pre_p.x), abs(p.y - pre_p.y));
	  pre_vect = vect;
	  vect = direction(p, pre_p);
	  if (j > 1) {
	    polygon_angle[i][j-2] = ((vect - pre_vect + 4) % 4 == 1) ? 1 : -1;
	  }
	}
      }
    }
    for (int i = 1; i < polygon_num + 1; i++) {
//      cout << i << endl;
      int j = 0;
      for (j = 0; j < polygon_ore[i] - 1; j++) {
//        cout << "j " << j << endl;
	if (polygon_ore[i] != polygon_ore[0]) { break; }
//	cout << j <<  " test1 ";
//	cout << polygon_length[i][j] << " " << polygon_length[0][j] << endl;
	if (polygon_length[i][j] != polygon_length[0][j]) { break; }
//	cout << "test2 " << endl;;
	if (j > 0) {
//	  cout << polygon_angle[i][j-1] << " " << polygon_angle[i][j-1] << endl;
	  if (polygon_angle[i][j-1] != polygon_angle[0][j-1]) { break; }
	}
      }
      if (j == polygon_ore[0] - 1) { cout << i << endl; continue; }
      for (j = 0; j < polygon_ore[i] - 1; j++) {
	int index = polygon_ore[i] - j - 2;
	if (polygon_ore[i] != polygon_ore[0]) { break; }
	if (polygon_length[i][index] != polygon_length[0][j]) { break; }
//	cout << "test" << endl;
	if (index > 0) {
//	  cout << j << " " << -polygon_angle[i][index-1] << " " << polygon_angle[0][j] << endl;
	  if (-polygon_angle[i][index-1] != polygon_angle[0][j]) { break; }
	}
      }
      if (j == polygon_ore[0] - 1) { cout << i << endl; continue; }
    }
    cout << "+++++" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    cout << vec[N - 1] - vec[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  long long lm2 = 2;
  long long lm1 = 1;

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  long long l;
  for (int i = 2; i <= N; ++i) {
    l = lm1 + lm2;
    lm2 = lm1;
    lm1 = l;
  }

  cout << l << endl;

  return 0;
}

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

void solved(int a, int b, int c, int k){
    if(a < b && b < c){
        cout << "Yes" << endl;
        exit(0);
    }
    if(k == 0) return;
    solved(a*2,b,c,k-1);
    solved(a,b*2,c,k-1);
    solved(a,b,c*2,k-1);
}

int main() {
    int A,B,C,K;
    cin >> A >> B >> C;
    cin >> K;
    solved(A,B,C,K);
    cout << "No" << endl;
}

Measured memory_bytes: 3668
X = int(input())
ans = 0
if 400 <= X < 600:
    ans=8
elif 600 <= X <800:
    ans = 7
elif 800 <= X < 1000: 
    ans = 6
elif 1000 <= X < 1200:
    ans = 5
elif 1200 <= X < 1400:
    ans = 4
elif 1400<=X<1600:
    ans = 3
elif 1600<= X < 1800:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 9188
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int r, g, b, n, ans = 0;
	scanf("%d%d%d%d", &r, &g, &b, &n);
	rep(i, 10000){
	  rep(j, 10000){
	    if(n - i * r - j * g >= 0 and (n - i * r - j * g) % b == 0)++ans;
	    else if(n - i * r - j * g < 0)break;
		}
	}
	printf("%d\n", ans);
	
	Please AC;
}


Measured memory_bytes: 256
def solve(n,l):
    conteo = [0]*n
    ans = 0
    for i in range(n-1):
        if l[i] >= l[i+1]:
            conteo[i+1] = conteo[i] + 1
            ans = max(ans,conteo[i+1])
    return ans
if __name__ == '__main__':
    n = int(input())
    num = list(map(int,input().split()))
    print(solve(n,num))

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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main() {
	
	int n;
	cin >> n;
	vector<ll>v(n);

	rep(i, n) {
		cin >> v[i];
		if (i != 0)v[i] += v[i - 1];
	}

	ll a1 = 0, s1 = 0;
	rep(i, n) {
		if (i % 2 == 0 && v[i] + s1 <= 0) {
			a1 += 1 - (v[i] + s1);
			s1 += 1 - (v[i] + s1);
		}
		else if(i%2 == 1 && v[i] + s1 >= 0){
			a1 += v[i] + s1 + 1;
			s1 -= v[i] + s1 + 1;
		}
	}
	ll a2 = 0, s2 = 0;
	rep(i, n) {
		if (i % 2 == 0 && v[i] + s2 >= 0) {
			a2 += v[i] + s2 + 1;
			s2 -= v[i] + s2 + 1;
		}
		else if (i % 2 == 1 && v[i] + s2 <= 0) {
			a2 += 1 - (v[i] + s2);
			s2 += 1 - (v[i] + s2);
		}
	}

	pr(min(a1, a2));

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>

#define NMAX 52
#define MMAX 52
using namespace std;

bool G[NMAX][NMAX] = {}, used[NMAX] = {};
int A[MMAX], B[MMAX];
int N,M,ans;
int main(){
  cin >> N >> M;
  for (int i = 0; i < M; ++i)
  {
    scanf("%d %d", &A[i], &B[i]);
    G[A[i]][B[i]] = G[B[i]][A[i]] = true;
  }

  for(int i = 0; i < M; ++i){
    memset(used, 0, sizeof(used));
    int a = A[i], b = B[i];
    // printf("%d <-> %d:\n", a, b);
    G[a][b] = G[b][a] = false;
    queue<int> que;
    que.push(a);
    used[a] = true;

    while(!que.empty()){
      int j = que.front();
      que.pop();
      for(int jj = 1; jj <= N; ++jj){
        if(G[j][jj] && !used[jj]){
          que.push(jj);
          used[jj] = true;
          // cout << jj << " ";
        }
      }
    }
    // cout << endl << (used[b] ? "connected" : "splitted") << endl;
    ans += (int)!used[b];
    // repair
    G[a][b] = G[b][a] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,0,N-2)rep(j,i+1,N-1)rep(k,j+1,N){
    if(P[i]+P[j]-P[k]>0)sum++;
    else break;
    }
  Out(sum);
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin >> n >> k;
vector<ll> a(n);
rep(i,n)
cin >> a[i];
sort(a.begin(),a.end());
ll sum = 0;
rep(i,k)
sum += a[i];
cout << sum << endl;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    ll x;
    rep(i, N){
        cin >> x;
        ans += 2 * min(x, K - x);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int ans = 0;
		int in = s.nextInt();
		ans = in+(int)Math.pow(in,2)+(int)Math.pow(in,3);
		System.out.print(ans);	
	}
}

Measured memory_bytes: 35584
def main():

    N = int(input())
    A = []
    for _ in range(pow(2, N)): A.append(int(input()))

    # print(A)
    while len(A) > 1:
        temp = []
        for i in range(len(A)//2):
            if A[2*i] < A[2*i+1]: temp.append(A[2*i+1] - A[2*i])
            elif A[2*i] > A[2*i+1]: temp.append(A[2*i] - A[2*i+1])
            else: temp.append(A[2*i])
        A = temp
        # print(A)
    return A[0]

if __name__ == '__main__':
    print(main())

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


int main()
{
	int h, w;
	int i=0, j=0;
	while (1) {
		cin >> h >> w ;
		if (h == 0 && w == 0) {
			break;
		}
		else {
			for (j = 0; j < h; j++) {
				for (i = 0; i < w; i++) {
					if (j == 0 || j == h - 1) {
						cout << "#";
					}
					else if (i == 0 || i == w - 1) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				cout << endl;
			}
			cout << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3000
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AtCoder {
    public class Program {
        static int[] getKeys() {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(delimiter);
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        public static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        public static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }


        static void Main() {
            Console.ReadLine();
            var Key = getKeys();
            int L = Key.Max();
            if (L < Key.Sum() - L) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
N, K = map(int, input().split(' '))
x = list(map(int, input().strip().split()))
ans=1000000000

for i in range(N-K+1):
    xl=x[i]
    xr=x[i+K-1]
    ans=min(ans,min(abs(xr)+abs(xr-xl),abs(xl)+abs(xl-xr)))
    

print(ans)


Measured memory_bytes: 14392
n, k = gets.chomp.split(' ').map(&:to_i)
count = 0
(1..n).each do |i|
  next if i <= k
  count += (i - k) * (n / i)
  if k != 0
    count += (n % i) - k + 1 if (n % i) - k + 1 >= 0
  else
    count += (n % i) - k if (n % i) - k >= 0
  end
end
puts count

Measured memory_bytes: 1788
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);

	//1019
	static class VampirishNight {
		void print_solution() {
			for(;;) {
				int n = sc.nextInt();
				int k = sc.nextInt();
				if(n == 0 && k == 0) break;
				int[] s = new int[k];
				for(int i=0; i<k; i++) {s[i] = sc.nextInt();}

				String ans = "Yes";
				for(int i=0; i<n; i++) {
					for(int j=0; j<k; j++) {
						s[j] -= sc.nextInt();
						if(s[j] < 0) ans = "No";
					}
				}
				System.out.println(ans);
			}
		}
	}

	public static void main(String[] args) {
		VampirishNight vn = new VampirishNight();
		vn.print_solution();
	}
}

Measured memory_bytes: 12000
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
s=[None]*N
t=0
for i in range(N):
    t+=A[i]
    s[i]=t
S=M*(N-V)
l=P
r=N
if P==1:
    a=0
else:
    a=s[P-2]
while l<r:
    m=(r - l) // 2 + l
    if A[P-1]-M>A[m]:
        r=m
        continue
    if s[m-1]-a-(m-P+1)*A[m]>S:
        r=m
        continue
    l=m+1
print(l)


Measured memory_bytes: 14480
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

int main(void){
  stack<int> st;
  string str, buf;
  getline(cin, str);  
  stringstream ss(str);

  while(ss >> buf){
    if(buf == "+"){
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();
      st.push(a+b);
    }else if(buf == "-"){
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();
      st.push(b-a);
    }else if(buf == "*"){
      int a = st.top(); st.pop();
      int b = st.top(); st.pop();
      st.push(a*b);
    }else {
      st.push(atoi(buf.c_str()));
    }
  }

  cout << st.top() << endl;
	return 0;
}

Measured memory_bytes: 1216
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	int A, B, C, X;
	LL ans = 0;
	cin >> A >> B >> C >> X;

	FOR(i, 0, A+1) {
		FOR(j, 0, B+1) {
			FOR(k, 0, C+1) {
				if (500 * i + 100 * j + 50 * k==X) {
					ans++;
				}
			}
		}
	}
	O(ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <sstream>
#define endl '\n'
#define ll long long
#define pb push_back
#define PI acos(-1)
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 500010
using namespace std;

int main()
{
    int n, i;
    cin >> n;
    int arr[n+1];
    for (i=1; i<=n; i++) cin >> arr[i];
    int cnt=0;
    for (i=1; i<=n; i+=2) {
        if (arr[i]%2) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int ans;
string S1;
int main(){
  cin >> S1;
  if(S1[0]== '1' ) ans++;
  if(S1[1]== '1' ) ans++;
  if(S1[2]== '1' ) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll N, T, ans=0;
  cin >> N >> T;
  ll t[N];
  for(int i=0; i<N; i++) {
    cin >> t[i];
  }
  for(int i=0; i<N; i++) {
    if(t[i+1]-t[i]<=T) {
      ans+=t[i+1]-t[i];
    }
    else {
      ans+=T;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
/*Remember: The Struggle Is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vector<int> a(n+1,0),b(n+1,0),c(n+1,0);

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

    for(int i=1;i<=n;++i)
        cin>>b[i];

    for(int i=2;i<=n;++i)
        cin>>c[i];

    int ans=b[a[1]];
    for(int i=2;i<=n;++i)
    {
        ans+=b[a[i]];

        if(a[i-1]==a[i]-1)
            ans+=c[a[i]];
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline().strip()

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

min_time = 10000000000000000
for i in range(N - K + 1):
	l = x[i]
	r = x[i + K - 1]
	min_time = min(min_time, min(abs(l), abs(r)) + abs(l - r))

print(min_time)

Measured memory_bytes: 62576
#coding:utf8
Alphabet_List = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
N = int(input())
S_1 = list(input())
S_2 = []

for i in range(len(S_1)):
    S_2.append(Alphabet_List.index(S_1[i]))
    S_2[i] = (S_2[i] + N) % 26
    S_2[i] = Alphabet_List[S_2[i]]

S_3 = "".join(S_2)
print(S_3)


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

       cin >> a >> b;
       if((a+b)%2!=0){
           Cout((a+b)/2+1);
       }
       else{
           Cout((a+b)/2);
       }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}
int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	string s;
	cin >> s;
	int c = s.size();
	int i = 0, k = 1, count = 0;
	while (i < c) {
		if (k > 1) {
			i += k;
			count++;
			k = 1;
		}
		else if (s[i] != s[i + k]) {
			i += k;
			count++;
			k = 1;
		}
		else {
			i++;
			count++;
			k = 2;
		}
		if (i == c - 2 && k == 1 && s[i] == s[i + 1])
			count--;
	}

	cout << count << endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int i=0;
    while(pow(2,i)<=N) i++;
    i--;
    cout<<pow(2,i)<<endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d %d', $length, $max, $quad);
$map = [];
$highScore = 0;
for ($i=0; $i < $quad; $i++) { 
    $nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $map[] = $nums;
}
$arr = [1];
dfs($arr);
echo $highScore;

function dfs($arr) {
    global $length, $max, $highScore;
    $size = count($arr);
    if ($size-1 == $length) {
        $highScore = setHighScore($arr);
        return $highScore;
    }
    $arr[] = $arr[$size-1];
    $size++;
    while($arr[$size-1] <= $max) {
        dfs($arr);
        $arr[$size-1]++;
    }
}

function setHighScore($arr) {
    global $quad, $map, $highScore;
    $tmpScore = 0;
    for ($i=0; $i < $quad; $i++) { 
        $target = $map[$i];
        if ($arr[$target[1]]-$arr[$target[0]]==$target[2]) {
            $tmpScore+=$target[3];
        }
    }
    return max($tmpScore, $highScore);
}

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

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

    ll N, A, B;
    cin >> N >> A >> B;
    ll answer;
    if((B - A) % 2) {
        ll leftShiftCount = A;
        ll tmpA = 1;
        ll tmpB = B - A;
        leftShiftCount += (tmpB - tmpA) / 2;
        ll rightShiftCount = N - B + 1;
        tmpA = A + (N - B);
        tmpB = N;
        rightShiftCount += (tmpB - tmpA) / 2;
        answer = min(leftShiftCount, rightShiftCount);
    } else {
        answer = (B - A) / 2;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int n,k,ans;
int dp[52][2600][52];//到第 i个，已经有 j的奇怪值，有 u个空位 
int main(){
	scanf("%d%d",&n,&k);
	memset(dp,-1,sizeof(dp));
	dp[0][1270][0]=1;
	for(int i=0;i<n;i++){
		int now=i+1;
		for(int j=0;j<=2600;j++){
			for(int u=0;u<=i;u++){
				if(dp[i][j][u]==-1)continue;
				int num=dp[i][j][u];
				if(dp[i+1][j][u]==-1)dp[i+1][j][u]=1ll*num*(u*2+1)%mo;
				else dp[i+1][j][u]=(dp[i+1][j][u]+1ll*num*(u*2+1)%mo)%mo;
				if(dp[i+1][j-now*2][u+1]==-1)dp[i+1][j-now*2][u+1]=num;
				else dp[i+1][j-now*2][u+1]=(dp[i+1][j-now*2][u+1]+num)%mo;
				if(u){
					if(dp[i+1][j+now*2][u-1]==-1)dp[i+1][j+now*2][u-1]=1ll*num*u*u%mo;
					else dp[i+1][j+now*2][u-1]=(dp[i+1][j+now*2][u-1]+1ll*num*u*u%mo)%mo;
				}
			}
		}
	}
	if(k+1270>2590)puts("0");
	else if(dp[n][k+1270][0]==-1)puts("0");
	else printf("%d\n",dp[n][k+1270][0]);
	return 0;
}

Measured memory_bytes: 27648
var
	N,K,i,p,q,get,L,R,M:Longint;
	ans,now,make:double;
begin
	read(N,K);
	if N>=K then begin
		ans:=(N-K+1)/N;
		q:=K-1;
	end
	else q:=N;
	make:=1;
	get:=1;
	for i:=1 to 17 do begin
		if q=0 then break;
		get:=get*2;
		make:=make*0.5;
		L:=0;R:=q+1;
		while R-L>1 do begin
			M:=(L+R)div 2;
			if (K+M-1)div M>get then L:=M else R:=M;
		end;
		p:=R-1;
		if p<q then begin;
			ans:=ans+(q-p)/N*make;
			q:=p;
		end;
	end;
	writeln(ans:0:9);
end.

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

int H, W, K;
char grid[11][11];

vector<int> extract(int bits)
{
	vector<int> ans;
	for(int i = 0; i < 6; i++)
	{
		ans.push_back(bits % 2);
		bits /= 2;
	}
	
	return ans;
}

bool isBlack[11][11];
void fillRow(int row)
{
	for(int i = 0; i < W; i++)
		isBlack[row][i] = false;
}

void fillCol(int col)
{
	for(int i = 0; i < H; i++)
		isBlack[i][col] = false;
}

void resetGrid()
{
	for(int i = 0; i < H; i++)
	{
		for(int j = 0; j < W; j++)
			isBlack[i][j] = (grid[i][j] == '#');
	}
}

int main()
{
	scanf("%d%d%d", &H, &W, &K);
	for(int i = 0; i < H; i++)
	{
		for(int j = 0; j < W; j++)
			scanf(" %c", &grid[i][j]);
	}
	
	const int maxHBits = (1 << H) - 1, maxWBits = (1 << W) - 1;
	int ans = 0;
	
	for(int hBits = 0; hBits <= maxHBits; hBits++)
	{
		for(int wBits = 0; wBits <= maxWBits; wBits++)
		{
			resetGrid();
			
			vector<int> extractedH = extract(hBits), extractedW = extract(wBits);
			for(int i = 0; i < 6; i++)
			{
				if(extractedH[i])
					fillRow(i);
					
				if(extractedW[i])
					fillCol(i);
			}
			
			int blackCount = 0;
			for(int i = 0; i < H; i++)
			{
				for(int j = 0; j < W; j++)
					blackCount += (int)(isBlack[i][j]);
			}

			if(blackCount == K)
			{
				//printf("hBits = %d, wBits = %d\n", hBits, wBits);
				ans++;
			}
		}
	}
	
	printf("%d", ans);
}


Measured memory_bytes: 3776
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    sum_a = list(itertools.accumulate(a))
    sum_b = list(itertools.accumulate(b))
    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[0] > k and b[0] > k:
        print(0)
        return

    for i in range(n):
        if sum_a[i] > k:
            break

    s_a = i - 1
    if sum_a[-1] <= k:
        s_a = n-1
    now_sum = 0
    if s_a >= 0:
        now_sum = sum_a[s_a]
    for i in range(m):
        if now_sum + sum_b[i] > k:
            break
    s_b = i - 1
    ans = s_a + 1 + s_b + 1
    now_sum = 0
    for a_i in range(s_a-1, -2, -1):
        for b_i in range(s_b+1,m):
            if a_i < 0:
                now_sumtime = sum_b[b_i]
            else:
                now_sumtime = sum_a[a_i] + sum_b[b_i]

            if b_i == m-1 and now_sumtime <= k:
                now_sum = a_i + m + 1
                break
            if now_sumtime > k:
                now_sum = a_i + b_i + 1
                break
        s_b = b_i-1
        ans = max(ans, now_sum)
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 49192
#include <stdio.h>

int main(){
    char a[300000];
    char b[300000];

    scanf("%s", a);
    scanf("%s", b);

    int count = 0;
    for (int i = 0; i < sizeof(a); i++){
        if (a[i] == '\0') break;
        if (a[i] != b[i]) count++;
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 2552
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 500010
int c[2][N];
int n;
string s;

void ZAlgo(string &s, vector<int> &z){
	int n = s.size();
	z = vector<int>(n);
	z[0] = n;
	int i = 1, j = 0;
	while(i < n){
		while(i+j < n && s[j]==s[i+j]) j++;
		z[i] = j;
		if(j==0){
			i++;
			continue;
		}
		int k = 1;
		while(i+k < n && k+z[k]<j) z[i+k] = z[k], k++;
		i += k;
		j -= k;
	}
}

int main(){
	cin>>s;
	n = s.size();
	rep(k, 2){
		vector<int> z;
		ZAlgo(s, z);
		for(int i = 1; i <= n/2; i++){
			if(c[k][i]) continue;
			for(int j = 2*i; j <= n; j+=i){
				if(z[j-i]>=i) c[k][j] = 1;
				else break;
			}
		}
		reverse(all(s));
	}

	reverse(c[1], c[1]+n+1);

	if(!c[0][n]){
		cout<<1<<endl;
		cout<<1<<endl;
	} else if(s==string(n, s[0])){
		cout<<n<<endl;
		cout<<1<<endl;
	} else {
		cout<<2<<endl;
		int sum = 0;
		for(int i = 0; i <= n; i++) if(!c[0][i]&&!c[1][i]) sum++;
		cout<<sum<<endl;
		//for(int i = 0; i <= n; i++) cout<<c[i]<<" "<<c2[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 6628
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

int A[1000][999];
bool todayState[1000][1000*999/2];
queue<int>que;
vector<int>shintyoku(1000, 0);
int endCount = 0;
int N;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

bool IsSuccess(int day, int currentP) {
	bool isSuccess = false;
	if (todayState[currentP][day])return isSuccess;
	int aite = A[currentP][shintyoku[currentP]] - 1;
	if (A[aite][shintyoku[aite]] - 1 == currentP && !todayState[aite][day]) {
		todayState[currentP][day] = true;
		todayState[aite][day] = true;
		que.push(currentP);
		que.push(aite);
		shintyoku[currentP]++;
		shintyoku[aite]++;
		isSuccess = true;
		if (shintyoku[currentP] == N - 1)endCount++;
		if (shintyoku[aite] == N - 1)endCount++;
	}
	return isSuccess;
}

int main() {

	int a;
	cin >> a;

	string s;
	cin >> s;

	if (3200 <= a) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
}


Measured memory_bytes: 256