akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ll = int64_t;

// cond: a>b
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll gcd2(ll a,ll b){
  return a>b?gcd(a,b):gcd(b,a);
}

vector<ll> fact(ll x) {
  vector<ll> ans;
  for (ll i = 2; i*i <= x; ++i) {
    if ((x % i) == 0) {
      ans.push_back(i);
      while ((x % i) == 0) x /= i;
    }
  }
  if (x != 1) {
    ans.push_back(x);
  }
  return ans;
}

vector<ll> primes(ll n) {
  vector<ll> p(n+1, 1);
  for (ll i = 2; i*i <= n; ++i)
    if (p[i])
      for (ll j = i*i; j <= n; j += i)
        p[j] = 0;
  vector<ll> res;
  for (ll i = 2; i <= n; ++i)
    if (p[i])
      res.push_back(i);
  return res;
}

int main() {
  ll n;
  cin>>n;
  vector<ll> f(n+1);
  REP(i,n+1) cin>>f[n-i];
  ll g = abs(f[n]);
  REP(i,n) {
    g = gcd(g, abs(f[i]));
  }
  auto fct = fact(g);
  REP(i,n+1) {
    f[i] /= g;
  }
  auto p = primes(n);
  for(auto y : p) {
    auto fy = f;
    REP(i,n+1) {
      if (fy[i] < 0) {
        fy[i] = (y - (-fy[i])%y)%y;
      } else {
        fy[i] %= y;
      }
    }
    ll m = y-1;
    for (ll i = n; i >= y; --i) {
      fy[i-m] += fy[i];
      fy[i-m] %= y;
    }
    bool ok = true;
    REP(i,y) {
      if ((fy[i] % y) != 0) ok = false;
    }
    if (ok) fct.push_back(y);
  }
  sort(ALL(fct));
  fct.erase(unique(ALL(fct)), end(fct));
  for (auto y : fct) {
    cout << y << endl;
  }
  return 0;
}


Measured memory_bytes: 384
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var list = new Array(M);
  for(var i = 0; i < M; i++){
    var tmp = nextIntArray();
    list[i] = {
      si : tmp[0],
      ci : tmp[1]
    };
  }
  for(var i = 0; i < Math.pow(10, N); i++){
    var isOK = true;
    var check = i.toString();
    if(check.length != N){
      isOK = false;
    }
    for(var j = 0; j < M; j++){
      if(check[list[j].si - 1] != list[j].ci){
        isOK = false;
      }
    }
    if(isOK){
      myout(i);
      return;
    }
  }
  myout(-1);
}

Measured memory_bytes: 30312
#include <stdio.h>
#define M m[y][x]
void main(){int i,x,y,h,w;char m[102][102];while(scanf("%d %d ",&h,&w),h){for(y=0;y<h;y++)scanf("%s ",m[y]);for(i=x=y=0;i<10404&&M!='.';i++){x+=(M=='>')-(M=='<');y+=(M=='v')-(M=='^');}printf(M=='.'?"%d %d\n":"LOOP\n",x,y);}exit(0);}

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

using namespace std;

#define N 10005

char c[N];

int main()
{
	cin >> (c + 1);
	int n = strlen(c + 1);
	if(n % 2 == 0) cout << "No" << endl;
	bool flag = 1;
	for(int i = 1; i < n / 2; i++)
		if(c[i] != c[n - i + 1]) 
		{
			flag = 0; 
			break;
		}
	int len = n / 2 + 1;
	for(int i = 1; i <= (n - 1) / 2; i++)
		if(c[i] != c[(n - 1) / 2 - i + 1] || c[i + len] != c[(n - 1) / 2 - i + 1 + len])
		{
			flag = 0;
			break;
		}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    dp=[1 for i in range(n)]
    dp[0]=0
    if n==1:
        print(0)
        sys.exit()
    dp[1]=0
    for i in range(3,n):
        for j in range(i-2):
            dp[i]=(dp[i]+dp[j])%mod
    #print(dp)
    print(dp[-1]%mod)
    

        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 68952
#include <stdio.h>
int main(void){
    char a[256];
    scanf("%c",a);
    if (a[0] == 'A'){
        printf("T");
    }else if (a[0] == 'T'){
        printf("A");
    }else if (a[0] == 'C'){
        printf("G");
    }else if (a[0] == 'G'){
        printf("C");
    }
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

const int MOD = 1e9 + 7;
inline int mod (int a, int m = MOD) { return (a % m + m) % m; }

signed main(){
    int n;
    string s, t;
    cin >> n >> s >> t;
    vector<int> dominoes;
    rep(i,n){
        if(s[i]==t[i]){
            dominoes.push_back(1);
        }else{
            dominoes.push_back(2);
            i++;
        }
    }
    int ans;
    if(dominoes[0] == 1){
        ans = 3;
    }else{
        ans = 6;
    }
    reps(i,1,dominoes.size()-1){
        if(dominoes[i] == 1){
            if(dominoes[i-1] == 1){
                ans = mod(ans * 2);
            }
        }else{
            if(dominoes[i-1] == 1){
                ans = mod(ans * 2);
            }else{
                ans = mod(ans * 3);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e3;
const int inf=1e6;
int rq[N+2],mn,vis[N+2];
vector<int>adj[N+2];
void dfs(int node)
{
  mn=min(mn,node);
  if(vis[node])return ;
  vis[node]=1;
  for(auto x:adj[node])
    dfs(x);
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int  n,m;cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int u,v;cin>>u>>v;
    adj[v].push_back(u);
  }
  for(int i=n;i>=1;i--)
  {
    mn=inf;
    dfs(i);rq[i]=mn;
  }
  int ans=n+1;
  for(int i=n;i>=1;i--)
  {
    mn=rq[i];
    for(int j=i;j>=max(mn,1);j--)
    {
      mn=min(mn,rq[j]);
    }
    ans+=(i-mn)*2;
    i=mn;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	unsigned long N, A, B, count;
	count = 0;
	cin >> N;
	cin >> A;
	cin >> B;
		if( (B-A)%2==0 )
		{
			cout << (B - A) / 2 << endl;
		}
		else
		{
			//上に近いか下に近いか
			if (A - 1 < N - B)
			{
				count += A;
				B -= A;
				A = 1;
				cout << count + (B - A) / 2  << endl;
			}
			else
			{
				count += (N - B + 1);
				A += (N - B + 1);
				B = N;
				cout << count + (B - A) / 2 << endl;
			}
		}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int a,b,c,d,e,f;
signed main(){
	cin>>a>>b>>c>>d>>e>>f;
	int A=0,B=0,C=0,D=0;
	if(a==1)A++;
	if(a==2)B++;
	if(a==3)C++;
	if(a==4)D++;
	
	if(b==1)A++;
	if(b==2)B++;
	if(b==3)C++;
	if(b==4)D++;
	
	if(c==1)A++;
	if(c==2)B++;
	if(c==3)C++;
	if(c==4)D++;
	
	if(d==1)A++;
	if(d==2)B++;
	if(d==3)C++;
	if(d==4)D++;
	
	if(e==1)A++;
	if(e==2)B++;
	if(e==3)C++;
	if(e==4)D++;
	
	if(f==1)A++;
	if(f==2)B++;
	if(f==3)C++;
	if(f==4)D++;
	int x[1111];
	x[0]=A;
	x[1]=B;
	x[2]=C;
	x[3]=D;
	sort(x,x+4);
	if(x[0]==1&&x[1]==1&&x[2]==2&&x[3]==2)puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) cout<< "Yes" <<endl;
  else cout<< "No" <<endl;
}

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

int  main(){
  int n; cin>>n;
  set<int> s;
  s.insert(n);
  int c=2;
  while (true){
    if(n%2==0){n/=2;}
    else{n=n*3+1;}
    if(s.count(n)){cout<<c;break;}
    else{s.insert(n);c++;}
  }
  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();

    let mut ans = n;
    for i in 1..=n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            let j = n / i;
            ans = cmp::min(ans, i + j - 2);
        }
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

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

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


Measured memory_bytes: 2268
#include<bits/stdc++.h> //万能头文件
using namespace std;
int ans;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d[10001];
    for(int i=1;i<=a;i++){
        cin>>d[i];
        if(d[i]<b||d[i]>=c)ans++;
    }
    cout<<ans<<endl; //一定要换行！！！
    return 0;   //AT的题目要打
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e12;

const long double eps = 1e-8;

const i64 MAXN = 400'000 + 5;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    string s;
    cin >> s;
    if (s == "RRR") {
        cout << 3 << endl;
    }
    else if (s == "RRS" || s == "SRR") {
        cout << 2 << endl;
    }
    else if (s == "SSS") {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
int a[50];
int main() {
	int n, k;
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
	}
	vector<int> q;
	int memo = -1;
	rep(i, k) {
		int chk = 100; int mi = 1000;
		rep(j, n) {
			if (memo == j)continue;
			if (a[j] < mi) {
				mi = a[j]; chk = j;
			}
		}
		rep(j, n) {
			if (j == chk||j==memo)continue;
			q.push_back(j); a[j]--;
		}
		q.push_back(chk); a[chk]--;
		memo = chk;
	}
	rep(i, n) {
		if (i == memo)continue;
		q.push_back(i); a[i]--;
	}
	bool valid = true;
	rep(i, n) {
		if (a[i] < 0)valid = false;
	}
	if (!valid) {
		cout << -1 << endl;
	}
	else {
		cout << q.size() << endl;
		rep(i, q.size()) {
			if (i > 0)cout << " ";
			cout << q[i]+1;
		}
		cout << endl;
	}
	//stop
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

typedef struct tyouten{ll id,x,y;}V;
int xsort(const void*a,const void*b){
	ll p=(*(V*)a).x,q=(*(V*)b).x;
	return p<q?-1:p>q?1:0;
}
int ysort(const void*a,const void*b){
	ll p=(*(V*)a).y,q=(*(V*)b).y;
	return p<q?-1:p>q?1:0;
}

//辺の情報を個別に持つタイプ

typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	ll vcnt,ecnt;
	E  e[200010];//適宜変える
	ll id[100010];//適宜変える
}G;
int csort(const void*a,const void*b){
	ll p=(*(E*)a).c,q=(*(E*)b).c;
	return p<q?-1:p>q?1:0;
}

V v[100010];
G g;
void readgraph(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		v[i].id=i;
		v[i].x=x;
		v[i].y=y;
	}
	qsort(v,n,sizeof(V),xsort);
	rep(i,0,n-1){
		g.e[i].s=v[i].id;
		g.e[i].g=v[i+1].id;
		g.e[i].c=v[i+1].x-v[i].x;
	}
 
	qsort(v,n,sizeof(V),ysort);
	rep(i,0,n-1){
		g.e[n-1+i].s=v[i].id;
		g.e[n-1+i].g=v[i+1].id;
		g.e[n-1+i].c=v[i+1].y-v[i].y;
	}
	
	g.vcnt=n;
	g.ecnt=(n-1)*2;
	qsort(g.e,g.ecnt,sizeof(E),csort);
}


//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int root(int x){return unicnt[x]<=0?-(unicnt[x]=-root(-unicnt[x])):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){if((x=root(x))==(y=root(y)))return;if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}unicnt[x]+=unicnt[y];unicnt[y]=-x;}
#undef UFLIMIT

//クラスカル法
//最小全域木を構成する辺を求める
//union findが必要
//O(ElogE)
ll saishou[200010];
void kurasukaru(G g){
	ufinit(g.vcnt);
	rep(i,0,g.ecnt){
		if(!same(g.e[i].s,g.e[i].g)){
			uni(g.e[i].s,g.e[i].g);
			saishou[i]=1;
		}
	}
}

int main(){
	readgraph();
	kurasukaru(g);
	
	ll ans=0;
	rep(i,0,g.ecnt)if(saishou[i])ans+=g.e[i].c;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll a, b, c, k; cin >> a >> b >> c >> k;
    if(k <= a) {cout << k << endl; return 0;}
    if(k <= b) {cout << a << endl; return 0;}
    cout << a - (k - a - b) << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long
#define int long long
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

int n;
vector<int> a;

void solve() {
	cin >> n;

	a.resize(n + 1);

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

	sort(a.begin() + 1, a.begin() + n + 1);

	int ans = 0;

	for (int i = 1; i <= n; ++i) {
		// choose a[i] as the max

		for (int j = 1; j < i; ++j) {
			// choose a[j] as the second max

			int m = a[i], s = a[j];

			// cerr << "m - s - i - j: " << m << ' ' << s << ' ' << i << ' ' << j << '\n';

			// s + k > m

			// cerr << "m: " << m << '\n';

			int k = m - s;

			auto it = upper_bound(a.begin() + 1, a.begin() + j, k);
			if (it == a.begin() + j) continue;
			else {
				// cerr << "*it: " << *it << '\n';
				int pos = a.begin() + j - it;
				ans += pos;

				// cerr << "pos: " << pos << '\n';
			}
		}
	}

	cout << ans;
}

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

	int t = 1;
	while (t--) 
		solve();
	return 0;
}

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

const ll MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}

int a[20000];
//~ ll Pow[20000];

int main(){
	int n;cin>>n;
	map<int,int>L;
	rep(i,n){
		scanf("%d",&a[i]);
		auto mp=prime_factor(a[i]);
		for(auto&p:mp)L[p.first]=max(L[p.first],p.second);
	}
	ll A=1;
	for(auto&p:L){
		(A*=ppow(p.first,p.second))%=MOD;
	}
	ll ans=0;
	rep(i,n){
		(ans+=A*ppow(a[i],MOD-2))%=MOD;
	}
	cout<<ans<<endl;
}

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

int k;
string s;
const int mod = 1e9 +7;

#define ll long long

ll int dp[10005][105][2];


ll int kil(int idx, int rem, int small)
{
  if(idx == s.length())
  {
    if(rem == 0)
      return 1;
    return 0;
  }
  if(dp[idx][rem][small] != -1)
    return dp[idx][rem][small];

  dp[idx][rem][small] = 0;

  for(int i=0;i<10;i++)
  {
    if(s[idx] - '0' < i && !small)
      break;
    if(s[idx] - '0' == i && !small)
      dp[idx][rem][small] = (dp[idx][rem][small] + kil(idx + 1, (rem + i) % k, 0)) % mod;
    else
      dp[idx][rem][small] = (dp[idx][rem][small] + kil(idx + 1, (rem + i) % k, 1)) % mod;
  }
  return dp[idx][rem][small] % mod;
}

int main()
{
  memset(dp, -1, sizeof dp);
  cin>>s;
  cin>>k;
  int res = kil(0, 0, 0) - 1;
  if(res == -1)
    res = mod - 1;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 17664
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int lis(vi v, bool f) {
  set<int > s;
  if(f) reverse(all(v));
  rep(i,0,v.size()) {
    if(s.lower_bound(v[i]) != s.end()) {
      s.erase(*s.lower_bound(v[i]));
    }
    s.insert(v[i]);
  }
  return s.size();
}

int fact(int n) {
  return (n <= 1) ? 1 : (n * fact(n - 1));
}

void bf() {
  vi v;
  int n;
  S(n);
  rep(i,1,n+1) v.pb(i);
  int f = fact(n);
  while(f--) {
    rep(i,0,n) printf("%d ",v[i]);
    printf("---> %d %d\n",lis(v, 0), lis(v, 1));
    next_permutation(all(v));
  }
}

int main() {
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  if(a * 1LL * b < n || a + b - 1 > n) {
    P(-1);
    return 0;
  }
  int cur = 0;
  rep(i,n-a+1,n+1) {
    printf("%d ",i);
    int nxt = min(cur + b - 1, n - a);
    for(int j = nxt; j > cur; j--) printf("%d ",j);
    cur = nxt;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m; cin >> n >> m;
    VI s(m);
    vector<char> c(m);
    FOR(i, 0, m)cin >> s[i] >> c[i];
    FOR(i, 0, pow(10, 3) + 10) {
        string t = to_string(i);
        if (t.length() != n)continue;
        bool ok = true;
        FOR(j, 0, m) {
            ok &= (t[s[j] - 1] == c[j]);
        }
        if (ok) {
            cout << t << "\n";
            return 0;
        }
    }
    cout << "-1\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((g * 10 + b) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int k,t,i,a,max=0,s=0;
  cin >> k >> t;
  for (i=0;i<t;i++){
    cin >> a;
    s+=a;
    if (max<a) max=a;
  }
  s-=max;
  if (max-1>=s) cout << max-1-s << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
class HashTable:
    def __init__(self, size = 1000003):
        self.size = size
        self.hash_table = [None] * size

    def _gen_key(self, val):
        raw_hash_val = hash(val)
        h1 = raw_hash_val % self.size
        h2 = 1 + (raw_hash_val % (self.size - 1))
        for i in range(self.size):
            candidate_key = (h1 + i * h2) % self.size
            if not self.hash_table[candidate_key] or self.hash_table[candidate_key] == val:
                return candidate_key

    def insert(self, val):
        key = self._gen_key(val)
        self.hash_table[key] = val

    def search(self, val):
        key = self._gen_key(val)
        if self.hash_table[key]:
            print('yes')
        else:
            print('no')


import sys

n = int(sys.stdin.readline())

simple_dict = HashTable()

ans = ''

for i in range(n):
    operation = sys.stdin.readline()
    if operation[0] == 'i':
        simple_dict.insert(operation[7:])
    else:
        simple_dict.search(operation[5:])

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int n;
  cin>>n;
  if(n==1)
    cout<<"Hello World"<<endl;
  else{
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;

  }



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;int K=1;
  for(int i=1;i<S.size();i++){
    K++;
    if(S.at(i)==S.at(i-1))i+=2,K++;
    if(i==S.size())K--;
    if(i==S.size()+1)K-=2;
  }
  cout<<K<<endl;
}

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

#define int long long

const int N = 1e5 + 10;
int n, q, ans, psum[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		psum[l]++;
		psum[r]--;
	}
	
	ans = (psum[0] == q);
	for (int i = 1; i < n; i++)
		psum[i] += psum[i - 1], ans += (psum[i] == q);
	cout << ans;
}

Measured memory_bytes: 1024
X,N = map(int,input().split())
if N != 0:
    p = list(map(int,input().split()))
    setp = set(p)
    ans_plus = X
    ans_minus = X
    val = 0
    while True:
        ans_plus = X + val
        ans_minus = X - val
        if ans_minus not in setp:
            print(ans_minus)
            break
        elif ans_plus not in setp:
            print(ans_plus)
            break
        else:
            val += 1
else:
    print(X)

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

int main(void){
	int b,r,g,c,s,t;
	while(cin>>b>>r>>g>>c>>s>>t,b||r||g||c||s||t){
		cout<<(100+15*b+15*r+7*g+2*c+13*(5*b+3*r)-(t-b*5-r*3-s)*3)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, long long M_a, long long M_b, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
  ll MAXDRAG = 401;
  ll INF = 1e8;

  vector<vector<vector<ll>>> dp(
      N + 1, vector<vector<ll>>(MAXDRAG, vector<ll>(MAXDRAG, INF)));

  dp[0][0][0] = 0;

  for (ll n = 1; n <= N; n++) {
    rep(ai, MAXDRAG) {
      rep(bi, MAXDRAG) {
        // 選ばない場合
        dp[n][ai][bi] = dp[n - 1][ai][bi];

        // 選ぶかもしれない場合
        if (ai - a[n - 1] >= 0 && ai - a[n - 1] < MAXDRAG &&
            bi - b[n - 1] >= 0 && bi - b[n - 1] < MAXDRAG) {
          dp[n][ai][bi] =
              min(dp[n][ai][bi],
                  dp[n - 1][ai - a[n - 1]][bi - b[n - 1]] + c[n - 1]);
        }
      }
    }
  }

  ll cost = INF;
  ll i = 1;
  ll ma = M_a;
  ll mb = M_b;
  while (ma < MAXDRAG && mb < MAXDRAG) {
    cost = min(cost, dp[N][ma][mb]);
    i++;
    ma = M_a * i;
    mb = M_b * i;
  }
  if (cost == INF) {
    print(-1);
  } else {
    print(cost);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M_a;
  scanf("%lld", &M_a);
  long long M_b;
  scanf("%lld", &M_b);
  std::vector<long long> a(N);
  std::vector<long long> b(N);
  std::vector<long long> c(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
  }
  solve(N, M_a, M_b, std::move(a), std::move(b), std::move(c));
  return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
string a, b;
void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b;

    int ans = 0;
    FOR(i, 0, 3)
    {
        if (a[i] == b[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; ++i){
  	cin >> a[i];
  	--a[i];
  }

  vector<int> cnt(n, 0);
  int to = 0;
  ++cnt[to];
  int now;
  int k_cnt = 0;
  for(int i = 0; i < n + 1; ++i){
  	to = a[to];
  	++cnt[to];
  	++k_cnt;
  	if(k_cnt == k){
  		cout << to + 1 << endl;
  		return 0;
  	}
  	if(cnt[to] >= 2){
  		now = i + 1;
  		break;
  	}
  }

  int cycle = 0;
  int start = to;
  for(int i = 0; i < n; ++i){
  	++cycle;
  	to = a[to];
  	if(to == start)break;
  }

  now -= cycle;

  int r = (k - now) % cycle;
  to = start;
  for(int i = 0; i < r; ++i){
  	to = a[to];
  }

  cout << to + 1 << endl;

  return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<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 int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    Yes(a[0]==a[1] && a[1] == a[2])

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 48

static const int d[ ] = {
  0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0
  };

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    char s[ N ], *p;
    int res = 0;

    scanf ( " %s", s );
    if ( *s == '#' ) break ;

    for ( p = s + 1; *p != '\0'; ++p )
    {
      res += !!( d[ p[ -1 ] - 'a' ] != d[ p[ 0 ] - 'a' ] );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    long n;
    cin >> n;
    
    vector<long> a(n,0);
    map<int, int> m;
    
    rep(i,n){
        cin >> a[i];
        m[i - a[i]]++;
    }
    
    long ans = 0;
    
    rep(i,n) ans += m[i + a[i]];
    
    cout << ans << "\n";
    
    return 0;
}



Measured memory_bytes: 21124
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 1e5+5;
vll a;
ll n;

ll dp[N];
ll go(ll i)
{
	if(i == n-1)
		return 0;
	if(i >= n)
		return 99999999999999999;
	ll &ans = dp[i];

	if(ans != -1)
		return ans;

	ans = min(go(i+2) + abs(a[i+2] - a[i]) , go(i+1) + abs(a[i+1] - a[i]));

	return ans;
}
signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	memset(dp , -1 , sizeof dp);

	cin >> n;
	cres(a , n);
	rep(i,0,n)
		cin >> a[i];


	cout<<go(0)<<endl;






	
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int cd(long long d)
{
    int w=0;
    while(d)
    {
        d/=10;
        w++;
    }
    return w;
}
int main(int argc, char *argv[])
{
    long long n;
    cin>>n;
    long long mod=1000;
    long long chu=1;
    int l=cd(n);
    long long mi=1000;
    long long h;
    for(int i=0;i<=l-3;i++)
    {
        h=abs((n%mod/chu)-753);
        //cout<<h<<endl;
        if(h<mi)mi=h;
        mod*=10;
        chu*=10;
    }
    cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	H = inputList()

	flg = True
	for i, val in enumerate(H):
		if i == 0:
			continue
		if H[i-1] < H[i]:
			H[i] -= 1

	#print(H)
	for i, val in enumerate(H):
		if i == 0:
			continue
		if H[i] < H[i-1]:
			flg = False

	if flg == True:
		print("Yes")
	else:
		print("No")


if __name__ == "__main__":
	main()


Measured memory_bytes: 60252
#include<cstdio>
#include<cmath>
using namespace std;
typedef double D;

D len(D ax, D ay, D bx, D by){
  return sqrt( (ax-bx)*(ax-bx) + (ay-by)*(ay-by) );
}

D tri_area(D a, D b, D c){
  D s = (a+b+c)/2;
  return sqrt( s*(s-a)*(s-b)*(s-c) );
}

int main(){
  int n;
  D x[20], y[20];
  for(n=0;scanf("%lf,%lf",&x[n],&y[n])!=EOF;n++);

  D res = 0;
  for(int i=1;i<n-1;i++){
    res += tri_area(len(x[0],y[0],x[i],y[i]),
		    len(x[0],y[0],x[i+1],y[i+1]),
		    len(x[i],y[i],x[i+1],y[i+1]) );
  }
  printf("%.9lf\n",res);
}

Measured memory_bytes: 1084
N = int(input())
H = list(map(int,input().split()))

h = H[0] - 1
for i in range(1,N):
    if h - H[i] >0:
        print("No")
        exit()
    elif h == H[i]:
        pass
    else:
        H[i] -= 1

    h = H[i]

    
print("Yes")


Measured memory_bytes: 63984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int ans = 0;
		for (int i = n; i > 0; i--) {
			ans += i;
		}
		System.out.println(ans);
	    scanner.close();
		}
}


Measured memory_bytes: 35740
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
template<class T=ll> 
T in(){T x;cin>>x;return (x);}
template<class T> 
void print(T &x){cout<<x<<"\n";}
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cerr << #x"="<< (x) << "\n"
#define dbgv(x) cerr<<#x<<"\n";reps(y,x){cerr<<y<<" ";}cerr<<"\n"

inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}

int main(){
  ll n=read(),a=read(),b=read(),ans=1e9,c=a-b;
  vector<ll> h(n);
  rep(i,n){
    h[i]=read();
  }
  ll left=1,right=1e9,mid,cnt=0;
  while (right!=left+1) {
    mid =(right+left)/2;
    cnt=0;
    rep(i,n){
      ll temp=h[i]-b*mid;
      if(temp>0){
        cnt+=temp/c+((temp%c)?1:0);
      }
    }
    if(cnt<mid){
      right=mid;
    }else left=mid;
  }
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*right;
    if(temp>0){
      cnt+=temp/c+((temp%c)?1:0);
    }
  }
  ans=min(ans,max(cnt,right));
  cnt=0;
  rep(i,n){
    ll temp=h[i]-b*left;
    if(temp>0){
      cnt+=temp/c+((temp%c)?1:0);
    }
  }
  ans=min(ans,max(cnt,left));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    c[i] = s;
  }
  int ret = 0;
  for (int is = 0; is < (1 << h); ++is) {
    for (int js = 0; js < (1 << w); ++js) {
      int cnt = 0;
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          if (((is >> i) & 1) && ((js >> j) & 1)) {
            if (c[i][j] == '#') {
              ++cnt;
            }
          }
        }
      }
      if (cnt == k) {
        ++ret;
      }
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void) {
   set<int> st1;
   set<int> st2;
   set<int> result;
   int n,a,m,b;
   cin >> n;
   for (int i=0;i<n;i++) {
       cin >> a;
       st1.emplace(a);
   }
   cin >> m;
   for (int j=0;j<m;j++) {
       cin >> b;
       st2.emplace(b);
   }
   set_symmetric_difference(st1.begin(),st1.end(),st2.begin(),st2.end(),inserter(result,result.end()));
   auto itr1 = result.begin();
   auto itr2 = result.end();
   for (itr1;itr1!=itr2;++itr1) {
       cout << *itr1 << endl;
   }
}



Measured memory_bytes: 40564
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	int n, k, q;
	cin>>n>>k>>q;
	int points[n+2];
	for(int i=0;i<=n;i++)
		points[i] = 0;
	while(q--)
	{
		int x;
		cin>>x;
		points[1] -= 1;
		points[x] += 1;
		points[x+1] -= 1;
	}
	for(int i=1;i<=n;i++)
	{
		points[i] += points[i-1];
		if(points[i] + k <= 0)
			cout<<"No\n";
		else
			cout<<"Yes\n";
	}

}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int c = min(a, b);
	int cnt = 0;
	while (cnt < k) {
		if (a % c == 0 && b % c == 0) {
			cnt++;
		}
		c--;
	}
	c++;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3568