akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {

    int N;
    cin >> N;
    
    int sum = 0;
    set<int> st;
    for(int i = 1;; i++) {
        sum += i;
        st.insert(i);
        if (sum >= N) {
            int diff = sum - N;
            if (diff) st.erase(st.find(diff));
            for (auto x : st) {
                cout << x << endl;
            }
            return 0;
        }
    }


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

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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    ll cntr = 0, cntl = 0;
    int n = s.size();
    rep(i, n){
        if(s[i] == '<')cntr++;
        if(s[i] == '>')cntl++;
        if((s[i] == '>' && s[i+1] == '<') || i == n-1){
            ll MAX = max(cntr, cntl);
            ll MIN = min(cntr, cntl);
            ans += MAX*(MAX+1)/2 + (MIN-1)*MIN/2;
            cntr = 0;
            cntl = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

/*
0<3>2>1>0
0<1<2>0 
0<1<2<3<4<5>2>1>0
0<1
<>>><<><<<<<>>><<>

*/

Measured memory_bytes: 4220
#include <stdio.h>
const int INF=1e9+10;
long long int now=1234819384719LL;
bool rand(int a,int b){
    now^=1932847192384LL;
    now+=1293419328471LL;
    now%=(a+b);
    return now>=b;
}
int min(int a,int b){return a<b?a:b;}
struct node{
    node* l;
    node* r;
    int val;
    int top;
    int size;
    node(int n){
        l=r=nullptr;
        val=top=n;
        size=1;
    }
    void pull(){
        size=1;
        top=val;
        if(l){
            size+=l->size;
            top=min(top,l->top);
        }
        if(r){
            size+=r->size;
            top=min(top,r->top);
        }
        return ;
    }
    void out(){
        if(l){
            l->out();
            printf(" ");
        }
        printf("%d",val);
        if(r){
            printf(" ");
            r->out();
        }
        return ;
    }
    int lsize(){
        return l?l->size+1:1;
    }
};
node* merge(node* a,node* b){
    if(!a)return b;
    if(!b)return a;
    if(rand(a->size,b->size)){
        a->r=merge(a->r,b);
        a->pull();
        return a;
    }
    else{
        b->l=merge(a,b->l);
        b->pull();
        return b;
    }
}
void split(node* s,int n,node*&a,node*&b){
    if(!s){
        a=b=nullptr;
        return ;
    }
    if(s->lsize()>n){
        b=s;
        split(s->l,n,a,b->l);
        b->pull();
    }
    else{
        a=s;
        split(s->r,n-s->lsize(),a->r,b);
        a->pull();
    }
    return ;
}
int find(node* s,int pl,int pr,int L,int R){
    int ans=INF;
    if(L>pr||pl>R||!s)return ans;
    if(L<=pl){
        if(pr<=R)return s->top;
        if(s->lsize()+pl-1<=R){
            if(s->l)ans=min(ans,s->l->top);
            ans=min(ans,min(s->val,find(s->r,s->lsize()+pl,pr,L,R)));
        }
        else return find(s->l,pl,s->lsize()+pl-2,L,R);
    }
    else if(pr<=R){
        if(s->lsize()+pl-1>=L){
            if(s->r)ans=min(ans,s->r->top);
            ans=min(ans,min(s->val,find(s->l,pl,s->lsize()+pl-2,L,R)));
        }
        else return find(s->r,s->lsize()+pl,pr,L,R);
    }
    else{
        if(L<=s->lsize()+pl-1&&s->lsize()+pl-1<=R)ans=min(ans,s->val);
        ans=min(ans,min(find(s->l,pl,s->lsize()+pl-2,L,R),find(s->r,s->lsize()+pl,pr,L,R)));
    }
    return ans;
}
int main(){
    int n,q,k,temp,l,r;
    node* root,*a,*b,*c,*d;
    scanf("%d%d%d",&n,&q,&temp);
    root=new node(temp);
    for(int i=1;i<n;i++){
        scanf("%d",&temp);
        root=merge(root,new node(temp));
    }
    while(q--){
        scanf("%d%d%d",&k,&l,&r);
        if(k==0){
            split(root,r,a,b);
            split(b,1,c,d);
            root=merge(a,d);
            split(root,l,a,b);
            root=merge(a,c);
            root=merge(root,b);
            //root->out();
            //printf("\n");
        }
        else if(k==1)printf("%d\n",find(root,1,n,l+1,r+1));
        else{
            split(root,l,a,b);
            split(b,1,c,d);
            c->val=c->top=r;
            root=merge(a,c);
            root=merge(root,d);
        }
    }
}


Measured memory_bytes: 12144
from math import sqrt
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, shortest_path
def distance(x0, y0, x1, y1):
    return sqrt((x1-x0)**2 + (y1-y0)**2)

xs, ys, xt, yt, n, *XYR = map(int, open(0).read().split())
P = [(xs, ys, 0), (xt, yt, 0)] + list(zip(XYR[::3], XYR[1::3], XYR[2::3]))

edges = np.zeros((n+2, n+2))
for i in range(n+1):
    for j in range(i+1, n+2):
        dist = distance(P[i][0], P[i][1], P[j][0], P[j][1])
        dist = max(dist - P[i][2] - P[j][2], 0.0)
        edges[i, j] = edges[j, i] = dist

G = csgraph_from_dense(edges, null_value=-1)
print(shortest_path(G, indices=0)[1])

Measured memory_bytes: 75496
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    deque<int> q;
    rep(i, n) {
        int idx = lower_bound(all(q), a[i]) - q.begin();
        if (idx == 0) q.push_front(a[i]);
        else q[idx-1] = a[i];
    }
    int ans = q.size();

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

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

ll H;

ll go(ll x)
{
	if(!x) return 0;
	if(x == 1) return 1;
	ll res = 1 + 2*go(x/2);
	return res;
}

void solve()
{
	if(H == 1) cout << 1 << '\n';
	else{
		cout << go(H) << '\n';
	}
}

int main()
{
	cin >> H;
	solve();
	return 0; 
}


Measured memory_bytes: 256
import os
import numpy as np

class getStdin(object):
    @classmethod
    def get_int(cls):
        return int(input())

    @classmethod
    def get_str(cls):
        return str(input())

class funcCls(object):
    @classmethod
    def done(cls, n, s):
        l = len(s) // 2
        mm = s[0:l]
        if s == mm + mm:
            print('Yes')
        else:
            print('No')

        return


if __name__ == '__main__':
    n = getStdin.get_int()
    s = getStdin.get_str()
    funcCls.done(n, s)

    os.sys.exit(0)

Measured memory_bytes: 21480
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T, class T2> long long modpower(long long radix, T x, T2 mod) {
    // 高速階乗計算 radix^x
    long long ans = 1;
    auto moder    = [&]() {
        if (mod != 0)
            ans %= mod;
    };
    while (0 < x) {
        if (x & 1) {
            ans = ans * radix;
            moder();
        }
        radix = radix * radix;
        moder();
        x >>= 1;
    }
    return ans == 0 ? 1 : ans;
}

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

    int N, P;
    cin >> N >> P;
    vector<int> a(N);
    for (auto &&i : a) {
        cin >> i;
    }

    ll odd = 0;
    for (auto &&i : a) {
        if (i % 2 == 1)
            odd++;
    }
    ll ans = 0;
    if (odd == 0 && P == 0) {
        ans = modpower(2, N, 0);
    } else if (0 < odd) {
        ans = modpower(2, N - 1, 0);
    }
    print(ans);

    return 0;
}

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

int N, M, Q, a[50], b[50], c[50], d[50], ans, cnt[10], num[10];

void dfs(int m, int r) {
  if (m == M-1) {
    for (int i=N-r; i<N; i++)
      num[i] = M-1;
    int res = 0;
    for (int i=0; i<Q; i++) {
      if (num[b[i]]-num[a[i]] == c[i])
        res += d[i];
    }
    ans = max(ans, res);
    return ;
  }
  for (int i=0; i<=r; i++) {
    for (int j=N-r; j<N-r+i; j++)
      num[j] = m;
    dfs(m+1, r-i);
  }
  return ;
}
int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  dfs(0, N);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 2000;

int N, M;

int main() 
{
	while(scanf("%d %d", &N, &M) != EOF)
	{
		int t = 1 << M;
		int ans = t * (1900 * M + 100 * (N - M));
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int a, b, cnt = 0;
    scanf("%d %d",&a, &b);

    for(int i = 0; i < 2; i++){
        if(a < b){
            cnt += b;
            b -= 1;
        }else{
            cnt += a;
            a -= 1;
        }
    }

    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 128
A = list(map(int,input().split()))

L = A[0]
R = A[1]
d = A[2]
result = 0
tmp = L

for i in range(R):
    if i+1 < L:
        continue
    if i+1 > R:
        break
    
    if (i+1) % d == 0:
        result += 1
    

print(result)

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

int main(){
    int A,B,X,min_cat,max_cat;
    cin >> A >> B >> X;
    min_cat = A;
    max_cat = A + B;
    if (min_cat <= X and X <= max_cat){
        cout << "YES" << endl;
    } else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

char s[100];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s+1;
	int len=strlen(s+1);
	bool ok=false;
	for(int i=1;i<=len;i++){
		if(i%2){
			if(s[i]=='h') continue;
			else ok=true;
		}else{
			if(s[i]=='i') continue;
			else ok=true;
		}
	}
	if(len%2) ok=true;
	if(ok) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,t,i,count=0;
    scanf("%d %d %d",&a,&b,&t);
    for(i=a;i<=t+0.5;i+=a){
        count=count+b;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N, P;
  std::cin >> N >> P;
  std::vector<std::pair<i64, i64>> v, a;
  for (usize i = 0; i < N; i++) {
    i64 w, b;
    std::cin >> w >> b;
    v.push_back({w, b});
    a.push_back({(100 - P) * w + P * b, i});
  }

  std::sort(a.begin(), a.end(), std::greater<std::pair<i64, i64>>());

  i64 sum = 0;
  for (usize i = 0; i < N; i++) {
    usize idx = a[i].second;
    sum -= P * v[idx].second;
  }

  for (usize i = 0; i < N; i++) {
    usize idx = a[i].second;
    sum += (100 - P) * v[idx].first + P * v[idx].second;

    if (sum >= 0) {
      std::cout << i + 1 << std::endl;
      return;
    }
  }
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,X;
    cin >>N>>X;
    int ans=1;
    int d=0;
    for(int i=0;i<N;i++){
        int a;
        cin >>a;
        if(d+a<=X){
            ans++;
            d+=a;
        }
        else{
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char b[1];
	scanf("%c",b);

	if(b[0]=='A'){
		printf("T");
	}else if(b[0]=='T'){
		printf("A");
	}else if(b[0]=='G'){
		printf("C");
	}else if(b[0]=='C'){
		printf("G");
	}else{
		printf("error");
	}

	return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()
r_ary = []
g_ary = []
b_ary = []
for i in (s):
    if i == 'R':
        r_ary.append(i)
    elif i == 'G':
        g_ary.append(i)
    elif i == 'B':
        b_ary.append(i)
r = len(r_ary)
g = len(g_ary)
b = len(b_ary)
first_conditions = r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i<n and s[i]!=s[2*j-i] and s[j]!=s[2*j-i] and s[i]!=s[j]:
            first_conditions -= 1
print(first_conditions)

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

const int N = 1e5+10;
int n, nim[N];
vector<int> g[N];

void dfs(int u, int f) {
	for(int v : g[u]) if(v != f)
		dfs(v,u);
	for(int v : g[u]) if(v != f) {
		nim[u] ^= (nim[v] + 1);
	}
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,-1);
	if(nim[1] == 0) puts("Bob");
	else puts("Alice");
	return 0;
}

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

using namespace std;

int cost[101];

int N, M, X;

int saiki(int i, int d)
{
  if (i == N || i == 0) return 0;
  return saiki(i+d, d) + cost[i];
}

int main()
{
  cin >> N >> M >> X;
  while (M--) {
    int a;
    cin >> a;
    cost[a] = 1;
  }
  cout << min(saiki(X, 1), saiki(X, -1)) << endl;
}

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

using namespace std;

int main()
{
  int N,M;
  string s[100];
  string t[100];
  cin>> N;
  for(int i=0;i<N;i++)cin>> s[i];
  cin>> M;
  for(int i=0;i<M;i++)cin>> t[i];

  int ret=0;
  for(int i=0;i<N;i++){
    string ser=s[i];
    int sum=0;
    for(int j=0;j<N;j++)if(s[j]==ser)sum++;
    for(int j=0;j<M;j++)if(t[j]==ser)sum--;
    if(sum>ret)ret=sum;
  }
  cout<< ret<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> memo(10001);
  for(int x=1; x<=100; x++) {
    for(int y=1; y<=100; y++) {
      for(int z=1; z<=100; z++) {
        ll val = x*x+y*y+z*z+x*y+y*z+z*x;
        if(val<=10000) memo[val]++;
      }
    }
  }
  rep(i, n+1) if(i) cout << memo[i] << "\n";
  return 0;
}


Measured memory_bytes: 3688
N,K=map(int,input().split())
ans=0
for b in range(K+1,N+1):
  if N-b*(N//b)>=K:
    ans+=(N//b)*(b-K)+(N-b*(N//b)-K+1)
    if K==0:
      ans-=1
  else:
    ans+=(N//b)*(b-K)
    if K==0:
      ans-=1
print(ans)


Measured memory_bytes: 39408
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  set<int64_t> s;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    auto itr = s.find(a);
    if (itr == s.end()) {
      s.insert(a);
    } else {
      s.erase(itr);
    }
  }
  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  cout << min(b,c) << " " << max(b+c-a, 0) <<endl;
  
}


Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

ll dp[2005];

void solve()
{
    reps(i, 3, 2005) {
        dp[i] = 1;
        rep(j, i-3) {
            dp[i] = (dp[i] + dp[i-j-3]) % MOD;
        }
    }
    IN(n);
    cout << dp[n] % MOD << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3664
x,n = map(int, input().split())
p = [int(i) for i in input().split()]
ans = 0
if x in p:
    p.sort()
    for i,v in enumerate(p):
        if v == x:
            break
    j = 1
    while True:
        if i-j < 0 or v-j != p[i-j]:
            ans = v-j
            break
        if i+j > n-1 or v+j != p[i+j]:
            ans = v+j
            break
        j += 1
else:
    ans = x
print(ans)


Measured memory_bytes: 9136
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
char suit;
int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
int i, j, k;
int n1 = mid - left;
int n2 = right - mid;
for (i = 0; i < n1; i++ )
	L[i] = A[left + i];
for (i = 0; i < n2; i++ )
	R[i] = A[mid + i];
L[n1].value = R[n2].value = SENTINEL;
i = j = 0;
for ( k = left; k < right; k++ ) {
	if ( L[i].value <= R[j].value ) {
A[k] = L[i++];
} else {
A[k] = R[j++];
}
}
}

void mergeSort(struct Card A[], int n, int left, int right) {
int mid;
if ( left + 1 < right ) {
mid = (left + right) / 2;
mergeSort(A, n, left, mid);
mergeSort(A, n, mid, right);
merge(A, n, left, mid, right);
}
}

int partition(struct Card A[], int n, int p, int r) {
int i, j;
struct Card t, x;
x = A[r];
i = p - 1;
for(j = p; j < r; j++ ) {
if ( A[j].value <= x.value ) {
i++;
t = A[i]; A[i] = A[j]; A[j] = t;
}
}
t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
int q;
if (p < r){
q = partition(A, n, p, r);
quickSort(A, n, p, q - 1);
quickSort(A, n, q + 1, r);
}
}

int main() {
int n, i, v;
struct Card A[MAX], B[MAX];
char S[10];
int stable = 1;

scanf("%d", &n);

for (i = 0; i <n; i++ ) {
scanf("%s %d", S, &v);
A[i].suit = B[i].suit = S[0];
A[i].value = B[i].value = v;
}

mergeSort(A, n, 0, n);
quickSort(B, n, 0, n - 1);

for (i = 0; i < n; i++ ) {
	if (A[i].suit != B[i].suit ) stable = 0;
}

if ( stable == 1) printf("Stable\n");
else printf("Not stable\n");
for (i = 0; i < n; i++ ) {
printf("%c %d\n", B[i].suit, B[i].value);
}

return 0;
}


Measured memory_bytes: 4140
import sys
n = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    sys.exit()
ans = 1
for i in range(n):
    ans *= A[i]
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)

Measured memory_bytes: 21564
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	alist := make([]int, n)
	max1st := 0
	max1stIdx := 0
	max2nd := 0
	max2ndIdx := 0

	for i := 0; i < n; i++ {
		alist[i] = nextInt()
		if max2nd < alist[i] {
			max2nd = alist[i]
			max2ndIdx = i
			if max1st < max2nd {
				tmp := max1st
				max1st = max2nd
				max2nd = tmp

				tmp = max1stIdx
				max1stIdx = max2ndIdx
				max2ndIdx = tmp
			}
		}
	}

	for i := 0; i < n; i++ {
		if i == max1stIdx {
			fmt.Println(max2nd)
		} else {
			fmt.Println(max1st)
		}
	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 6460
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	LL n, k;
	cin >> n >> k;
	n %= k;
	cout << min(n, k - n) << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int md = 1e9 + 7;
inline void mad(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
inline void mub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
}
inline int mow(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
      b--;
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
  a %= md;
  if(a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= a * t; swap(a, b);
    u -= v * t; swap(u, v);
  }
  assert(b == 1);
  if(u < 0) u += md;
  return u;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i]; a[i] ^= a[i - 1];
  }
  constexpr int amx = 1 << 20;
  vector<int> dp(amx, 1), ep(amx, 0), prv(amx, 0); int cnt(0);
  for (auto const& crr : a) {
    if (!crr) cnt++;
    else {
      mad(dp[crr], mul(cnt - prv[crr], ep[crr]));
      mad(ep[crr] , dp[crr]);
      prv[crr] = cnt;
    }
  }
  if (a[n]) {
    cout << dp[a[n]] << endl;
    return 0;
  }
  int ret = 0;
  for (int i = 0; i < amx; i++) mad(ret, ep[i]);
  mad(ret, mow(2, cnt - 2));
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 14464
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    int M = scanner.nextInt();
    for (int i = 0; i < M; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
      nodes[b].adjacent.add(nodes[a]);
    }
    for (int i = 0; i < N; i++) System.out.println(nodes[i].adjacent.size());
  }

  private static class Node {
    private List<Node> adjacent = new ArrayList<>();
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(a-b>0){
    if((a-v*t)-(b-w*t)>0){
      cout<<"NO"<<endl;
    }
    else{
      cout<<"YES"<<endl;
    }
  }
  else if(a-b<0){
    if((a+v*t)-(b+w*t)<0){
      cout<<"NO"<<endl;
    }
    else{
      cout<<"YES"<<endl;
    }
  }
}

Measured memory_bytes: 3636
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g;
    cin >> r >> g;
    cout << g + (g - r) << '\n';
}


Measured memory_bytes: 256
/*
	Name: We Love ABC
	Author: Jerryjiang090210
	Date: 30/06/19 16:44
	Description: Jerryjiang090210's code <We Love ABC>
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10),MOD=(1e9+7);
string s;
long long dp[maxn][3],type=1;
int main()
{
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
	{
		if(s[i]=='?')
		{
			dp[i+1][0]=(dp[i][0]*3+type)%MOD;
			dp[i+1][1]=(dp[i][1]*3+dp[i][0])%MOD;
			dp[i+1][2]=(dp[i][2]*3+dp[i][1])%MOD;
			type=type*3%MOD;
		}
		else if(s[i]=='A')
		{
			dp[i+1][0]=(dp[i][0]+type)%MOD;
			dp[i+1][1]=dp[i][1];
			dp[i+1][2]=dp[i][2];
		}
		else if(s[i]=='B')
		{
			dp[i+1][0]=dp[i][0];
			dp[i+1][1]=(dp[i][1]+dp[i][0])%MOD;
			dp[i+1][2]=dp[i][2];
		}
		else
		{
			dp[i+1][0]=dp[i][0];
			dp[i+1][1]=dp[i][1];
			dp[i+1][2]=(dp[i][2]+dp[i][1])%MOD;
		}
	}
	cout<<dp[n][2]<<endl;
	return 0;
}

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

using namespace std;

int N;
int custo[100000];
int pd[100000];

int mam(int i){
    if (i >= N - 1){
        return 0;
    }
    if (i == N - 2){
        return abs(custo[i] - custo[i + 1]);
    }
    if (pd[i] == -1){
        return pd[i] = min(abs(custo[i] - custo[i + 1]) + mam(i + 1), abs(custo[i] - custo[i + 2]) + mam(i + 2));
    }
    return pd[i];
}

int main(){
    scanf("%d", &N);

    memset(pd, -1, sizeof(int) * N);

    for (int i = 0; i < N; i++){
        scanf("%d", &custo[i]);
    }

    printf("%d\n", mam(0));

    return 0;
}

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

typedef long long ll;
const int maxn = 2e5 + 2;
using namespace std;;
ll n;
ll k;
map<ll, ll> mm;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		ll temp = (ll) i * 2;
		if (temp % k == 0)  {
			mm[i % k]++;
		}
	}
	ll ans = 0;
	for (auto it:mm){
		ll s = it.second;
		ll add = s * s * s;
		ans += add;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
x = A.index(1)
y = x + 1
c = 0
a = (math.ceil((y-1)/(K-1))) * (K-1) + 1
c += math.ceil((y-1)/(K-1))
c += math.ceil((N-a)/(K-1))
print(c)



Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll ans=INF;
void num(ll h,ll w){
		for(ll i=h/3;i<h;i++){
		ll a,b,c;
		a=(h/3)*w;
		b=(i-h/3)*w;
		c=h*w-a-b;
		if(a<=0||b<=0||c<=0){
			continue;
		}
		ll sum=(max({a,b,c})-min({a,b,c}));
		ans=min(sum,ans);
	}
}
void num1(ll h,ll w){
	for(ll i=1;i<h;i++){
		ll a,b,c;
		a=i*w;
		b=(h-i)*(w/2);
		c=h*w-a-b;
		if(a<=0||b<=0||c<=0){
			continue;
		}
		ll sum=(max({a,b,c})-min({a,b,c}));
		ans=min(sum,ans);		
	}
}
int main() {
	ll h,w;
	cin>>h>>w;
	num(h,w);num(w,h);
	num1(h,w);num1(w,h);
	// your code goes here
	cout << ans;
	return 0;
}

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

int main()
{
    int H, W;
    while (cin >> H >> W) {
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j)
                cout << "#";
            cout << "\n";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    string s, t;
    cin >> s >> t;
    int c = 0;
    for (int i = 0; i < s.length(); i++)
        c += (s[i] != t[i]);
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int N=500005;
char s[N];int a[N<<1],n,sum;
int main()
{
	int x=0;
	scanf("%s",s+1);n=strlen(s+1);
	for(RI i=1;i<=n;++i) a[i]=(s[n-i+1]-'0')*9;
	for(RI i=1;i<=n;++i) a[i]+=x,x=a[i]/10,a[i]%=10;
	while(x) a[++n]=x%10,x/=10;
	for(RI i=1;i<=n;++i) sum+=a[i];
	for(RI i=1,j;;++i) {
		a[1]+=9,sum+=9,j=1;
		while(a[j]>9) {
			sum-=a[j+1],a[j+1]+=a[j]/10,sum+=a[j+1];
			sum-=a[j],a[j]%=10,sum+=a[j];
			++j;if(j>n) n=j;
		}
		if(sum<=9*i) {printf("%d\n",i);return 0;}
	}
	return 0;
}

Measured memory_bytes: 4608
N,M=[int(i) for i in input().split()]
inf=1000000007
dp=[-1]*(N+1)
for i in range(M):
	dp[int(input())]=0
dp[0]=1
if dp[1]==-1:
	dp[1]=1
for i in range(2,N+1):
	if dp[i]==0:
		continue
	else:
		dp[i]=(dp[i-2]+dp[i-1])%inf
print(dp[N]%inf)

Measured memory_bytes: 6900
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ll n, m, c;
  cin >> n >> m >> c;
  vll bs(m);
  rep(i, m) cin >> bs[i];

  ll ans = 0;
  rep(i, n) {
    ll sum = 0;
    rep(j, m) {
      ll a;
      cin >> a;
      sum += a * bs[j];
    }
    sum += c;
    if (sum > 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size()-8;i++)
	cout<<a[i];
}

Measured memory_bytes: 256
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

string s;

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> s;
	int ans = (s[0] == s[sz(s) - 1]) ^ (s.size() % 2 == 0);
	if (ans) puts("Second");
	else puts("First");

}


Measured memory_bytes: 512
#include <iostream>

#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

int
main()
{
  int N, M;
  cin >> N >> M;
  vector<int> R(N);
  for (int m = 0; m < M; m++)
  {
    int a, b;
    cin >> a >> b;
    R[a - 1]++;
    R[b - 1]++;
  }
  for (int n = 0; n < N; n++)
  {
    cout << R[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////


int main() {
	ll N;
	cin >> N;
	vll h(N + 1);
	repn(i, N) cin >> h[i];

	vll dp(N + 1, INF);
	dp[1] = 0;
	for(ll i=2; i<=N; i++) {
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1)dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N] << endl;
}



Measured memory_bytes: 4852
#include <stdio.h>
#include <string.h>
#define LEN 100006

typedef struct pp
{
  char name[100];
  int t;
}P;

P syori[LEN];
int head,tail,kosuu;//bunki=1;
void syoki(void);
int karahan(void);
int manhan(void);
void osikomi(P);
P osidasi(void);


int main()
{
  int keika=0, mini=0;
  int i, cutt;
  P keisyo;
  scanf("%d %d", &kosuu, &cutt);

  for ( i = 1; i <= kosuu; i++)
    {
      scanf("%s", syori[i].name);
      scanf("%d", &syori[i].t);
    }
  syoki();
  while(head!=tail)
    {
      keisyo=osidasi();
      if(cutt>keisyo.t)
	{
	  mini=keisyo.t;
	}
      else
	{
	  mini=cutt;
	}
      keisyo.t=keisyo.t-mini;
      keika=keika+mini;
      if(keisyo.t>0)
	{
	  osikomi(keisyo);
	}
      else
	{
	  printf("%s %d\n",keisyo.name,keika);
	}
    }
  return 0;
}

void syoki()
{
  head = 1;
  tail = kosuu+1;
}
/*
int karahan()
{
  if(head==tail)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}

int manhan()
{
  if(head==(tail+1)%n)
    {
      return 1;
    }
  else
    {
      return 0;
    }

}
*/
void osikomi(P x)
{
  /*
    if(manhan()==1)
    {
    printf("エラー（オーバーフロー）\n");
    }
  
    if(buniki==1)
    {
    syori[tail%n]=x;
    bunki++;
    tail=(tail)%n;
    }
    else
    {
    syori[tail]=x;
    }
  
    if(tail+1==LEN+1)
    {
    tail=0;
    }
    else
    {
    tail++;
	
    }
  */
  syori[tail]=x;
  tail=(tail+1)%LEN;
}

P osidasi()
{
  P kaeri;
  /*
    if(karahan()==1)
    {
    printf("エラー（アンダーフロー）\n");
    }
  */
  kaeri=syori[head];
  /*
    if(head+1==LEN+1)
    {
    head=0;
    }
    else
    {
    head++;
    }
  */
  head=(head+1)%LEN;
  return kaeri;
}



Measured memory_bytes: 11864
H, W, K = map(int, input().split())

f = [1, 1]
while len(f)<=W:
  f.append(f[-2]+f[-1])

A = {(0,k):(1 if k==1 else 0) for k in range(1, W+1)}

for h in range(1, H+1):
  for x in range(1, W+1):
    pat = f[x-1]*f[W-x]*A[(h-1, x)]
    if x > 1:
      pat += f[x-2]*f[W-x]*A[(h-1, x-1)]
    if x < W:
      pat += f[x-1]*f[W-x-1]*A[(h-1, x+1)]
    A[(h, x)] = pat

print(A[(H, K)]%1000000007)

Measured memory_bytes: 3188
import sys
n,m = map(int,input().split(" "))
nums = [-1] * n
for _ in range(m):
    s,c = map(int,input().split(" "))
    if n > 1 and s == 1 and c == 0:
        print(-1)
        sys.exit(0)
    if nums[s-1] != -1 and c != nums[s-1]:
        print(-1)
        sys.exit(0)
    nums[s-1] = c
nums = [0 if num == -1 else num for num in nums]
if n == 1:
    print(nums[0])
    sys.exit(0)
if nums[0] == 0:
    nums[0] = 1
print("".join(map(str,nums)))

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/priority_queue.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define endl '\n'
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
#define lowbit(x) x &(-x)
#define all(x) (x).begin(), (x).end()
#define sf(x) scanf("%d", &x)
#define pf(x) printf("%d", x)
#define debug(x) cout << x << endl
#define mod(x) (x % mod + mod) % mod

template <typename T>
void read(T &x)
{
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch))
    {
        if (ch == '-')
            f *= -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}

const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e2 + 7;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;

#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//template<typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
ll qpow(ll a, ll n)
{
    ll re = 1;
    while (n)
    {
        if (n & 1)
            re = (re * a) % mod;
        n >>= 1;
        a = (a * a) % mod;
    }
    return re % mod;
}
ll inv(ll a) { 
    return a == 1 ? 1 : (mod - mod / a) * inv(mod % a) % mod;  
}  
ll C(ll m,ll n)
{
	ll ans1=1,ans2=1;
	if(n>m-n)n=m-n;
	for(int i=0;i<n;i++)
	{
		ans2=ans2*(i+1)%mod;
		ans1=ans1*(m-i)%mod;
	}
	ll x,y;
	return ans1*inv(ans2)%mod;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    if (n<k)
    cout<<0<<endl;
    else
    cout<<C(n-1,k-1)<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main(){
	ll n, m;
	vector<ll> s;
	cin >> n >> m;
	for (int i = 1; i <= sqrt(m); i++) {
		if (m % i == 0) {
			s.push_back(i);
			s.push_back(m / i);
		}
	}
	sort(ALL(s));
	auto it = lower_bound(ALL(s), n);
	cout << m / *it << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n;
    cin >> n;
    cout << n*(1 + n)/2 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
	
    string s; cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])Yes();
    else No();
    return 0;

}

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


int main() {

	string s;
	cin >> s;

	if(s == "SUN") cout << 7 << endl;
	if(s == "MON") cout << 6 << endl;
	if(s == "TUE") cout << 5 << endl;
	if(s == "WED") cout << 4 << endl;
	if(s == "THU") cout << 3 << endl;
	if(s == "FRI") cout << 2 << endl;
	if(s == "SAT") cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    cn_l = []
    for i, m in enumerate(s):
        if 1<i<l-1 and m=='C':
            cn_l.append(i)
            c_cnt += 1
    if c_cnt == 1:
        cn = int(cn_l[0])
        tmp = s
        tmp.pop(0)
        tmp.remove('C')
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3064
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [0 for i in range(n)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    mina = 1000000000
    for s in range(1,min(k+1,i+1)):
        mina = min(mina ,dp[i-s]+ abs(h[i]-h[i-s]))
    dp[i] = mina

print(dp[-1])


Measured memory_bytes: 56544