akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll n,m;
  cin>>n>>m;
  vec(a,n);
  vector<pair<ll,ll>> p(m);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,m){
    cin>>p[i].second>>p[i].first;
  }
  sort(all(p));
  sort(all(a));
  ll cnt=0;
  ll ans=0;
  
    for(int i=p.size()-1;i>=0;i--){
      for(int j=0;j<p[i].second;j++){
        
        if(cnt==n){i=-1;break;}
        
        if(a[cnt]<p[i].first)ans+=p[i].first;
        else {i=-1;break;}
        cnt++;
      }
    }
  repf(i,cnt,a.size()){
    ans+=a[i];
  }
  op(ans);
  return 0;
}

Measured memory_bytes: 2560
# 2019/10/05

n,m=map(int,input().split())
res=[0]*n

for _ in range(m):
    a,b=(map(int,input().split()))
    res[a-1]+=1
    res[b-1]+=1

for e in res:
    if e%2:
        print('NO')
        exit()
else:
    print('YES')

Measured memory_bytes: 3828
#include<stdio.h>
#include<iostream>
#include<string>
#include<bitset>
using namespace std;
int main(){
  long long int k,sum,ans=0,tmp,i,j=0,a[15],b;
  string s;
  cin >> s;
  for(i=s.size()-1;i>=0;i--){
    a[j]=s[i]-'0';
    j++;
  }
  j--;
  for(tmp=0;tmp<(1<<j);tmp++){
    bitset<15> bit(tmp);
      sum=a[0],k=1;
    for(i=1;i<=j;i++){
      if(bit.test(i-1)){
        sum=sum+a[i];
        k=1;
      }
      else{
        k=k*10;
        sum=sum+k*a[i];
      }
    }
    ans=ans+sum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define RNG(i,from,to) for(ll i=(from); i<(ll)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  if (N==0) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> res(32);
  ll sm = 0;
  REP(i, 32) res[i] = 0;
  RNG(i, 1, 33) {
    ll cur = 1LL << i;
    if ((sm - N)%cur) {
      res[i-1] = 1;
      sm += cur/2*((i-1)%2 ? -1 : 1);
    }
  }
  ll st = 31;
  while (!res[st]) st--;
  for (int i = st; i >= 0; i--) cout << res[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

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

	deque<char> s;
	string in;
	cin >> in;
	s = deque<char>(in.begin(), in.end());

	int state = 0;
	int q;
	cin >> q;
	while(q --> 0) {
		int t;
		cin >> t;
		if(t == 1) {
			state ^= 1;
			continue;
		}
		int f;
		char c;
		cin >> f >> c;
		--f;
		if(f ^ state)
			s.emplace_back(c);
		else
			s.emplace_front(c);
	}
	if(state)
		reverse(s.begin(), s.end());
	for(char c : s)
		cout << c;
	cout << '\n';
}


Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,l[205];
  cin>>n;
  n*=2;
  rep(i,n){
      cin>>l[i];
  }
  sort(l,l +n);
  long long sum=0;
  for(int i=0;i<n;i+=2){
      sum+=l[i];
  }
  cout<<sum<<'\n';
  
  return 0;
}


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

ll a[15];
int main() {
	ll n, k; scanf("%lld%lld", &n, &k);
	rep(i, n)scanf("%lld", &a[i]);
	ll Min = LLONG_MAX;
	rep(i, 1 << n) {
		ll Max = -1;
		ll sum = 0;
		int cnt = 0;
		rep(j, n) {
			if (!(i >> j & 1)) {
				Max = max(Max, a[j]); continue;
			}
			cnt++;
			if (Max >= a[j]) {
				sum += Max + 1 - a[j];
				Max = Max + 1;
			}
			Max = max(Max, a[j]);
		}
		if (cnt < k)continue;
		Min = min(Min, sum);
	}
	cout << Min << endl;
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce
from collections import Counter

def cmb(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def prime_factor(n):
    ass = []
    for i in range(2, int(n ** 0.5) + 1):
        while n  % i == 0:
            ass.append(i)
            n = n // i
    if n != 1:
        ass.append(n)
    return ass

def main():
    N, M = map(int, input().split())
    num_list = prime_factor(M)
    MOD = 10 ** 9 + 7
    C = Counter(num_list)
    ans = 1
    for i, j in C.items():
        ans *= cmb(j+N-1, j)
        ans %= MOD
    print(ans)



if __name__ == "__main__":
    main()

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, m, c;
  cin >> n >> m >> c;
  
  int ans = 0;
  
  vector<int> b(m);
  rep(i, 0, m) cin >> b.at(i);
  
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, 0, n) {
    int clc = 0;
    rep(j, 0, m) {
      cin >> a.at(i).at(j);
      clc += a.at(i).at(j) * b.at(j);
    }
    if(clc + c > 0)
      ans++;
  }
  
  cout << ans << "\n";

}


Measured memory_bytes: 256
n=int(input())

def q(i):
    print(i)
    r=input()
    if r=='Vacant':exit()
    return r

t=q(0)

def is_ok(x):
    s=q(x)
    if x%2:
        return t!=s
    else:
        return t==s

ok=0
ng=n

while ng-ok:
    mid=(ok+ng)//2
    if is_ok(mid):
        ok=mid
    else:
        ng=mid

Measured memory_bytes: 3660
N=int(input())
if(N<=111):
  print(111)
elif(111<N<=222):
  print(222)
elif(222<N<=333):
  print(333)
elif(333<N<=444):
  print(444)
elif(444<N<=555):
  print(555)
elif(555<N<=666):
  print(666)
elif(666<N<=777):
  print(777)
elif(777<N<=888):
  print(888)
elif(888<N<=999):
  print(999)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
double a,b,c,d,e,f,x,y;
while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
{
//(bd-ae)y=cd-af
 y=(c*d-a*f)/(b*d-a*e);
 x=(c-b*y)/a;
 printf("%.3f %.3f\n",x,y);
}
return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  int a,b,c,k;
  cin >> a >> b >> c >> k;

  vector<int> two(k+1);
  int s = 1;
  for (int i = 0; i <= k; ++i) {
    two[i] = s;
    s *= 2;
  }

  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k - i; ++j) {
      for (int t = 0; t <= k - i - j; ++t) {
        int at = a * two[i];
        int bt = b * two[j];
        int ct = c * two[t];
        // cout << i << ' ' << j << ' ' << t << ' ' << at << ' ' << bt << ' ' << ct << endl;
        if (at < bt && bt < ct) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    sort(r.begin(),r.end());
    int index_red = A-X;
    int index_green = B-Y;
    int index_white = C-1;
    while(1){
        if(index_red >= A){
            if(q[index_green] < r[index_white]){
                q[index_green] = r[index_white];
                index_green++;
                index_white--;
            }
            else break;
        }
        else if(index_green >= B){
            if(p[index_red] < r[index_white]){
                p[index_red] = r[index_white];
                index_red++;
                index_white--;
            }
            else break;
        }
        else {
            if(p[index_red] < q[index_green]){
                if(p[index_red] < r[index_white]){
                    p[index_red] = r[index_white];
                    index_red++;
                    index_white--;
                }
                else break;
            }
            else{
                if(q[index_green] < r[index_white]){
                    q[index_green] = r[index_white];
                    index_green++;
                    index_white--;
                }
                else break;
            }
            if(index_white < 0 )   break;
        }
    }
    long long sum = 0 ;
    for(int i = A-X ; i < A ; i++){
        sum += p[i];
    }
    for(int i = B-Y ; i < B ; i++){
        sum += q[i];
    }
    cout << sum << endl;
    return ;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


Measured memory_bytes: 2560
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

long P = 10^^9+7;
long[10000] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

long inv(long x)
{
    return pow(x, P-2);
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

long perm(N)(N n, N k)
{
    if (k > n) return 0;
    auto n_b = F[n];
    auto n_k_b = RF[n-k];
    return (n_b * n_k_b) % P;
}

void main()
{
    init();
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    writeln(comb(N+K-1, K-1));
}


Measured memory_bytes: 2648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, h, prev = 0;

  cin >> n;

  int ans = 0;

  for(int i=0;i<n;i++){
    cin >> h;
    ans += max(0, prev - h);
    prev = h;
  }

  cout << ans + prev << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll s=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    int l=0;
    for(int i=0;i<n;i++){
        if(a[i]*4*m >= s){
            l++;
        }
        else break;
    }
    if(l>= m)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
aN = list(map(int, input().split()))

# 実はこんなシンプルで良かったなんて…
cnt = 0
for i in range(1, N):
	if aN[i] == aN[i-1]:
		cnt += 1
		# 左右と被らない数、を実際に探さないで-1ってことにしとく
		aN[i] = -1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, a, b;
	int sum = 0;
	int i, j, k;
	int con = 0;
	
	
	cin >> n >> a >> b;
	
	for (i = 1; i <= n; i++){
		j = i;
		
		while (j){
			k = j % 10;
			con += k;
			j /= 10;
		}
		
		if (con >= a && con <= b){
			sum += i;
		}
		con = 0;
	}
	
	cout << sum << "\n";
	
	return (0);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    long long X, K, D;
    cin >> X >> K >> D;
    long long count = X / D;
    if(abs(count) >= K) {
        if(X >= 0) {
            cout << X - K * D << endl;
        } else {
            cout << abs(X + K * D) << endl;
        }

    } else {
        if(count % 2 == 0) {
            if(K % 2 == 0) {
                cout << abs(X - count*D) << endl;
            } else if(count >= 0) {
                cout << abs(X - count*D -D) << endl;
            } else {
                cout << X - count*D + D << endl;
            }
        } else {
            if(K % 2 == 1) {
                cout << abs(X - count*D) << endl;
            } else if(count >= 0) {
                cout << abs(X - count*D - D) << endl;
            } else {
                cout << X - count*D + D << endl;
            }
        }
    }
    return 0;
}

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

int w,h;
int dx[8] = {0,1,1,1,0,-1,-1,-1};
int dy[8] = {1,1,0,-1,-1,-1,0,1};
vector<vector<int>> mp;

void dfs(int y, int x){
  mp[y][x] = 0;
  for (int i = 0; i < 8; i++)
  {
    if(x+dx[i]>=w || x+dx[i]<0 || y+dy[i]>=h || y+dy[i]<0) continue;
    if(mp[y+dy[i]][x+dx[i]]) dfs(y+dy[i], x+dx[i]);
  }
}


int main(){
  vector<int> anss;
  while(true){
    cin >> w >> h;
    if(w+h==0) break;
    mp = vector<vector<int>>(h,vector<int>(w));
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        cin >> mp[i][j];
      }    
    }

    int ans = 0;
    for (int i = 0; i < h; i++)
    {
      for (int j = 0; j < w; j++)
      {
        if(mp[i][j]){
          ans++;
          dfs(i,j);
        }
      }
    }
    anss.push_back(ans);
  }
  for(int ans:anss) cout << ans << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
int n,m,i,j,a[100005];
vector<int> oid,b;
int main()
{
	scanf("%d%d",&n,&m);
	fz1(i,m){
		scanf("%d",&a[i]);
		if(a[i]&1)oid.push_back(i);
	}
	if(oid.size()>2){
		puts("Impossible");
		return 0;
	}
	sort(oid.begin(),oid.end());
	if(oid.size()>0){
		swap(a[1],a[oid[0]]);
	}
	if(oid.size()>1){
		swap(a[m],a[oid[1]]);
	}
	fz1(i,m){
		printf("%d ",a[i]);
	}
	puts("");
	if(m==1){
		b.push_back(1);
		if(a[1]-1)b.push_back(a[1]-1);
	}
	else{
		a[1]--;a[m]++;
		fz1(i,m){
			if(a[i])b.push_back(a[i]);
		}
	}
	printf("%d\n",b.size());
	ff(b,it)printf("%d ",*it);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[2][100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    rep(i, S.length()) {
        if(S[i] == 'A') sum[0][i + 1] += sum[0][i] + 1;
        else sum[0][i + 1] += sum[0][i] + 2;
    }
    rep(i, T.length()) {
        if(T[i] == 'A') sum[1][i + 1] += sum[1][i] + 1;
        else sum[1][i + 1] += sum[1][i] + 2;
    }
    int q; cin >> q;
    while(q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        //cout << "*" << sum[0][b] - sum[0][a - 1] << " " << sum[1][d] - sum[1][c - 1] << " " << sum[0][b] - sum[0][a - 1] << " " << (sum[1][d] - sum[1][c - 1] - (sum[0][b] - sum[0][a - 1]) + 600000) % 3 << endl;
        int diff = (sum[1][d] - sum[1][c - 1] - (sum[0][b] - sum[0][a - 1]) + 600000) % 3;
        if(diff == 0) {
            cout << "YES" << endl;
        } else{
            cout << "NO" << endl;
        }
    }

    return 0;
}


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

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

long long MOD = 10000000000 + 7;
// modint
const ll mod = 998244353;

template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;

int main(){
  cout << setprecision(10);

  ll N,M,K; cin >> N >> M >> K;
  vector<mint> fact(N+1,0);
  fact[0] = 1;
  for(ll i = 1; i <= N; i++){
    fact[i] = fact[i-1] * i;
  }

  mint ans = 0;

  for(ll i = 0; i <= K; i++){
    mint tmp = M;
    tmp *= (tmp-1).pow(N-i-1);
    tmp *= fact[N-1];
    tmp *= fact[N-1-i].inv();
    tmp *= fact[i].inv();

    ans += tmp;
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
  	int n, m;
  	cin >> n >> m;
  	int ll = 1, rr = n;
  	while (m--)
    {
      	int l, r;
      	cin >> l >> r;
      	ll = max(l, ll);
      	rr = min(r, rr);
    }
  	cout << max(0, rr - ll + 1);
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

string s;

signed main() {
	int n;
	cin >> n;
	cin >> s;
	
	int cnt = 0;
	for (int i = 0; i < s.length() - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

int main()
{
	double a,b,c,d,e,f;
	double x,y;
	while(cin>>a>>b>>c>>d>>e>>f)
	{
		y=(c*d-a*f)/(b*d-a*e);
		x=(c-(b*y))/a;
		cout<<setiosflags(ios::fixed)<<setprecision(3)<<x<<" "<<y<<endl;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

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

void Main()
{
  ll n; cin >> n;
  vll p(n), q(n); rep(i, n) cin >> p[i]; rep(i, n) cin >> q[i];
  vll loot(n); rep(i, n) loot[i] = i + 1;
  ll P, Q;
  ll t = 0;
  do
  {
    if(equal(loot.cbegin(), loot.cend(), p.cbegin())) P = t;
    if(equal(loot.cbegin(), loot.cend(), q.cbegin())) Q = t;
    t++;
  }while(next_permutation(all(loot)));
  fin(abs(Q - P));
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

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

int main() {
  int N, Q; cin >> N >> Q;
  string s; cin >> s;
  vector<int> v;
  for (ll i = 0; i < s.size()-1; i++) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      v.push_back(i);
    }
  }
  for (ll i = 0; i < Q; i++) {
    ll l, r; cin >> l >> r; l--; r--;
    cout << lower_bound(v.begin(), v.end(), r) - lower_bound(v.begin(), v.end(), l) << endl;
  }
}

Measured memory_bytes: 1276
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
s = input()

s0 = s[0]
s1 = s[1]
s2 = s[2]
s3 = s[3]

if s0 == s1 and s2 == s3 and not s0 == s2:
    print("Yes")
    exit()
if s0 == s2 and s1 == s3 and not s0 == s1:
    print("Yes")
    exit()
if s0 == s3 and s1 == s2 and not s0 == s1:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 21272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			int x = vs[0], a = vs[1];

			Console.WriteLine(x < a ? "0" : "10");

		}
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    pair<pair<int,int>,bool> ab[n];
    for(int i=0;i<n;i++){
        int x;
        int y;
        cin >> x >> y;
        ab[i]=make_pair(make_pair(x,y),true);
    }
    pair<int,int> cd[n];
    for(int i=0;i<n;i++){
        int x;
        int y;
        cin >> x >> y;
        cd[i]=make_pair(x,y);
        
    }
    sort(ab,ab+n);
    sort(cd,cd+n);
    reverse(ab,ab+n);
    int count=0;
    int temp=0;
    bool flag = false;
    int falsenum;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(ab[j].second==true){
                if(cd[i].first>ab[j].first.first && cd[i].second>ab[j].first.second){
                   if(ab[j].first.second>=temp){
                       temp = ab[j].first.second;
                       falsenum = j;
                       flag=true;
                   }
                }
            }
        }
        if(flag==true){
            ab[falsenum].second=false;
            temp =0;
            count ++;
            flag=false;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return map(int, input_tuple)


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    n, q = intin()
    s = input()
    lrlist = intinl(q)
    lrlist = [(l, r) for l, r in lrlist]

    prev = None
    pos_i_list = []
    for i, c in enumerate(s):
        if prev == 'A' and c == 'C':
            pos_i_list.append(i)
        prev = c

    for l, r in lrlist:
        start = binl(pos_i_list, l)
        end = binl(pos_i_list, r)
        print(end - start)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55316
//---------------------------
// AOJ使い方説明
// made by Kevin
// 2015/6/19
//---------------------------

#include <stdio.h>

int main(void)
{
    int in_second;//入力される時間S
    int out_hour, out_minute, out_second;//出力のh:m:s

    //入力
    scanf("%d", &in_second);

    //それぞれ計算
    out_second = in_second % 60;
    out_minute = (in_second /60) % 60;
    out_hour = (in_second / 60) /60;

    //出力
    printf("%d:%d:%d\n", out_hour, out_minute, out_second);

    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int p=a;p<b;p++)
#define modulo 1000000007

int main()
{
    int n;
    cin>>n;
    int a[n+5];
    set_null(a,n+5);
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<n+1;i++)
    {
        cout<<a[i]<<endl;
    }

    return 0;
}



Measured memory_bytes: 4404
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;

	return 0;
}




Measured memory_bytes: 3548
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val S = sc.next()
  println {
    S.split("/").map(_.toInt) match {
      case Array(yyyy, mm, _) if 2019 <= yyyy && 5 <= mm => "TBD"
      case _ => "Heisei"
    }
  }
}


Measured memory_bytes: 55420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		
		for (int i = 0; i < n; i++) {
			if ((i + 1) == k) {
				s = s.substring(0, i) + Character.toLowerCase(s.charAt(i)) + s.substring(i+1);
			}
		}
		System.out.println(s);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

using namespace std;

int main() {

	int n;
	cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  
  int x=0;
  for(int i=0;i<n;i++){
    if(i%2==0) x+=v[i];
    else x -=v[i];
  }
  vector<int> s(n);
  s[0] = x;
  for(int i=1;i<n;i++){
    s[i] = v[i-1]*2-s[i-1];
  }
  for(int i=0;i<n;i++){
    cout << s[i] << endl;
  }
}
    





Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int ML=200100;

char s[ML],t[ML];

int nx[ML][26],tmp[26];

int main()
{
	scanf("%s%s",s,t);
	
	int n=strlen(s),m=strlen(t);
	
	for (int i=n; i<(n<<1); i++) s[i]=s[i-n];
	
	for (int i=0; i<26; i++) tmp[i]=(n<<1);
	
	for (int i=(n<<1)-1; ~i; i--)
	{
		tmp[s[i]-'a']=i;
		
		for (int j=0; j<26; j++) nx[i][j]=tmp[j];
	}
	
	int ans=0,np;
	
	for (int i=0,p=-1; i<m; i++,p=np)
	{
		np=nx[p+1][t[i]-'a'];
		
		if (np>=n) ans++,np-=n;
		
		if (np==n) { ans=-1; break; }
	}
	
	if (~ans) cout<<0LL+np+1LL*ans*n+1; else cout<<-1;
	
	return 0;
}

Measured memory_bytes: 20864
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int cnt4=0,cnt2=0,cnt=0;
    rep(i,n){
        if(a[i]%4==0) cnt4 ++;
        else if(a[i]%2==0) cnt2 ++;
        else cnt ++;
    }
    bool f=0;
    if(cnt2){
        f=(cnt4>=cnt);
    }
    else{
        f=(cnt-1<=cnt4 && cnt4>0);
    }
    if(f) Yes;
    else No;
}
//./problem.exe

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	a := nextInt()
	fmt.Fprintln(out, a*a*a)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long N, long long R){
    if(N >= 10){
        cout << R << endl;
    }else{
        cout << R + 100 * (10 - N) << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long R;
    scanf("%lld",&R);
    solve(N, R);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;

void boost()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
}



int main(void)
{
    boost();
    ll n;
    cin>>n;
    vi v(n);
    rep(i,0,n)
        cin>>v[i];
    ll a[n+1];
    a[0] = 0;
    a[1] = 0;
    if ( n >= 2){
        a[2] = abs(v[1] - v[0]);
    }
    rep(i,2,n){
        a[i+1] = min(a[i-1] + abs(v[i-2] - v[i]),a[i] + abs(v[i] - v[i-1]));
    }
    //cout<<a[2]<<"\n";
    cout<<a[n];
    
    
   
}   

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> k;
	int h[100010];
	rep(i, n) cin >> h[i];

	sort(h, h+n);

	f = 1e9 + 5;
	rep(i, n-k+1){
		f = min(f, h[i+k-1] - h[i]);
	}

	cout << f;
}

Measured memory_bytes: 640
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val xu = Array.fill(n)(readLine().split(" "))
    .map(list => (list(0).toDouble, list(1)))

  def solve() = {
    xu.foldLeft(0d) { case (acc, (x, u)) =>
      if(u == "JPY") acc + x
      else acc + x * 380000
    }
  }
  println(solve())

}



Measured memory_bytes: 54788
a = int(input())
b = int(input())
if(a==1 and b==2): print("3")
if(a==1 and b==3): print("2")
if(a==2 and b==1): print("3")
if(a==2 and b==3): print("1")
if(a==3 and b==2): print("1")
if(a==3 and b==1): print("2")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

void test(){
	string s1,s2;
	cin>>s1>>s2;
	int ans = 0;
	f(i,s1.length())if(s1[i]!=s2[i])ans++;
	cout<<ans<<"\n";
}

int main(){
	int tests=1;
//	cin>>tests;
	while(tests--){
		test();
	}
}

Measured memory_bytes: 3916
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  m := nextInt()

  vector := make([][]int, n + 1)
  for i := 0; i < n + 1; i++ {
    vector[i] = make([]int, m + 1)
    sum := 0
    for j := 0; j < m + 1; j++ {
	  if i == n {
        vector[i][j] = 0
	  } else if j == m {
        vector[i][j] = sum
	  } else {
		val := nextInt()
		sum = sum + val
        vector[i][j] = val
	  }
	}
  }

  for j := 0; j < m + 1; j++ {
    sum := 0
	for i := 0; i < n + 1; i++ {
		if i == n {
            vector[i][j] = sum
		}else {
	        sum = sum + vector[i][j]
		}
	}
  }
  for i := 0; i < n + 1; i++ {
    for j := 0; j < m + 1; j++ {
      fmt.Print(strconv.Itoa(vector[i][j]))
	  if j != m {
        fmt.Print(" ")
	  }
	}
    fmt.Println()
  }

  //fmt.Println(vector)


}


func getStdin() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}



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

class Program
{
    public static void Main(string[] args)
    {
        string S = Console.ReadLine();
        Dictionary<char, int> d = new Dictionary<char, int>();
        for (int i = 0; i < 4; i++)
        {
            if (!d.Keys.Contains(S[i]))
            {
                d[S[i]] = 1;
            }
            else
            {
                d[S[i]]++;
            }
        }
        bool f = true;
        foreach (int a in d.Values)
        {
            if (a != 2) f = false;
        }
        Console.WriteLine((f)? "Yes": "No");
    }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int D, G;
ll ans = inf;

void dfs(vector<int> &p, vector<int> &c, string f) {
	if (sz(f) == D) {
		ll sum = 0;
		ll num = 0;
		rep(i, sz(f)) {
			if (f[i] == '1') {
				sum += c[i] + 100LL * p[i] * (i + 1);
				num += p[i];
			}
		}
		
		if (sum >= G) {
			chmin(ans, num);
		}
		else {
			for (int i = D - 1; i >= 0; i--) {
				if (f[i] == '1') continue;
				rep(j, p[i]) {
					if (sum >= G) break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			chmin(ans, num);
		}

		return;
	}

	dfs(p, c, f + "0");
	dfs(p, c, f + "1");

	return;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	cin >> D >> G;
	vector<int> p(D), c(D);
	rep(i, D) cin >> p[i] >> c[i];

	dfs(p, c, "");

	out(ans);

	return 0;
}

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

color=[0,0,0]
chance=1
for i in range(N):
  chance*=color.count(A[i])
  #print(chance)
  #print(color)
  for j in range(3):
    if A[i]==color[j]:
      color[j]+=1
      break
print(chance%(10**9+7))  

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define ll int
using namespace std;
ll R,C,Q, grid[2005][2005], node[2005][2005], edge[4005][4005], grid2[4005][4005];
int main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>R>>C>>Q;
    for (ll i=1; i<=R; i++){
        for (ll j=1; j<=C; j++){
            char a; cin>>a;
            grid[i][j] = a-'0';
        }
    }
    for (ll i=1; i<=R; i++){
        for (ll j=1; j<=C; j++){
            node[i][j]= grid[i][j] + node[i-1][j] + node[i][j-1] - node[i-1][j-1];
        }
    }
    for (ll i=1; i<=R; i++){
        for (ll j=1; j<=C; j++){
            if (grid[i][j]==1){
                if (grid[i-1][j]==1){
                    grid2[2*i -2][2*j -1]=1;
                }
                if (grid[i+1][j]==1){
                    grid2[2*i][2*j -1]=1;
                }
                if (grid[i][j-1]==1){
                    grid2[2*i -1][2*j -2]=1;
                }
                if (grid[i][j+1]==1){
                    grid2[2*i -1][2*j ]=1;
                }
                
            }
        }
    }
    for (ll i=1; i<=2*R; i++){
        for (ll j=1; j<=2*C; j++){
            edge[i][j]= grid2[i][j] + edge[i-1][j] + edge[i][j-1] - edge[i-1][j-1];
        }
    }

    for (ll i=1; i<=Q; i++){
        ll r1,c1,r2,c2,k1,k2;
        cin >> r1 >> c1 >> r2 >> c2;
        k1= node[r2][c2]-node[r2][c1-1]-node[r1-1][c2]+node[r1-1][c1-1];
        k2= edge[2*r2 -1][2*c2 -1] + edge[2*r1 - 2][2*c1 - 2] - edge[2*r2 -1][2*c1 -2] - edge[2*r1 -2][2*c2 -1];
        cout << k1-k2 << "\n";
    }
}

Measured memory_bytes: 158336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
  	cin >> s[i];
  }
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  int max = 0;
  
  for (int i = 0; i < k; i++) {
  	max += s[i];
  }
  cout << max << endl;
}

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

int main() {
    string S;cin >> S;
    int N = S.size();
    reverse(S.begin(),S.end());
    int ans = 0;int m = 0;int x = 1;
    vector<int> cnt(2019);
    for (int i = 0;i < N;i++){
        cnt[m]++;
        m += (S[i] - '0') * x;
        m %= 2019;
        ans += cnt[m];
        x = x * 10 % 2019;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;int n;
	cin >> n;cin >> s;
	for(int i=0; i < s.size(); ++i)
	{
		if((int(s[i]) +n)%65 + 65 <= 90)
		cout << char((int(s[i]) +n)%65 + 65);
		else
		{
			cout << char((int(s[i]) +n)%91 + 65);
		}
	}
	return 0;
}

Measured memory_bytes: 256