akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<limits.h>

#define max(a,b) a>b?a:b;
#define min(a,b) a<b?a:b;

int main(){
  int i,n,maxv,minv;
  int a[200000];

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }

  minv = a[0];
  maxv = INT_MIN;

  for(i=1; i<n; i++){
    maxv = max(maxv,a[i]-minv);
    minv = min(minv,a[i]);
  }
  
  printf("%d\n",maxv);

  return 0;
}



Measured memory_bytes: 2512
N, M, X = map(int, input().split())
CA = []
for i in range(N):
    ca = list(map(int, input().split()))
    CA.append(ca)

bit = []
for i in range(0, 2 ** N):
    pre_bit = []
    for k in range(N):
        pre_bit.append(i % 2)
        i = i // 2
    bit.append(pre_bit)

mi = 10 ** 7
for i in range(2 ** N):
    current = [0] * M
    okane = 0
    flag = 0
    for j in range(N):
        if bit[i][j] == 1:
            okane += CA[j][0]
            for k in range(M):
                current[k] += CA[j][k + 1]
    for i in range(M):
        if current[i] < X:
            flag = 1
    if flag == 0:
        if okane < mi:
            mi = okane

if mi == 10 ** 7:
    print(-1)
else:
    print(mi)

Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    string s;
    cin >> s;

    int counter = 0,sLength = s.length();

    if(sLength%2 == 0){
        for (int i = 0; i < sLength/2; i++)
        {
            if (s[i] != s[sLength - 1 - i])
            {
                counter++;
            }
        }
        cout << counter << endl;
    }else{
        for (int i = 0; i < (sLength - 1)/2; i++)
        {
            if (s[i] != s[sLength - 1 - i])
            {
                counter++;
            }
        }
        cout << counter << endl;
    }
  
    return 0;
}

Measured memory_bytes: 256
a = [int(input()) for i in range(5)]

sum = 0
minmo = 10
for i in range(5):
    mo = a[i] % 10
    if mo != 0:
        sum += a[i]+10-mo
        if mo < minmo:
            minmo = mo
    else:
        sum += a[i]

print(sum-10+minmo)


Measured memory_bytes: 2940
#!/usr/bin/env python3
import sys
import numpy as np
import numba
from numba import i8

input = sys.stdin.buffer.readline
mod = 998244353


def I():
    return int(input())


def MI():
    return map(int, input().split())


@numba.njit((i8, i8[:]), cache=True)
def main(N, LR):
    L, R = LR[::2], LR[1::2]
    K = len(L)

    dp = np.zeros(N + 1, np.int64)
    dpsum = np.zeros(N + 1, np.int64)
    dp[1] = 1
    dpsum[1] = 1

    for i in range(2, N + 1):
        for k in range(K):
            li = i - R[k]
            ri = i - L[k]
            if ri < 0:
                continue
            li = max(li, 1)
            dp[i] += dpsum[ri] - dpsum[li - 1]
            dp[i] %= mod
        dpsum[i] = dpsum[i - 1] + dp[i]
        dpsum[i] %= mod

    return dp[N]


N, K = MI()
LR = np.array(sys.stdin.buffer.read().split(), np.int64)

print(main(N, LR))


Measured memory_bytes: 109428
//
//  main.cpp
//  A
//
//  Created by Yoshinao Itakura on 2020/07/05.
//  Copyright © 2020 Yoshinao Itakura. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    int x=(N+1000-1)/1000;
    cout <<(x*1000-N)<<endl;
    
    return 0;
}


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

int main() {
  string s;
  getline(cin, s);
  rep(i, s.size()) {
    if(isdigit(s[i])) continue;
    else if(islower(s[i])) {
      s[i] = toupper(s[i]);
    } else {
      s[i] = tolower(s[i]);
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3148
s = list(input())
ac = True
c = False
for i in range(len(s)):
    if i == 0:
        if s[i] != 'A':
            ac = False
    else:
        if not('a' <= s[i] <= 'z'):
            if (s[i] == 'C' and c == False and 2 <= i <= len(s)-2):
                c = True
            else:
                ac = False
print(['WA','AC'][ac and c])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{    
    int n;
    cin >> n;
    int max_num = 0;
    rep(i,n)
    {
        int a;
        cin >> a;
        if(a == max_num + 1)
            max_num += 1;
    }

    if(max_num == 0) cout << -1 << endl;
    else cout << n - max_num << endl;
    return 0;
}

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

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

int a[100][100];
int main() {
  int n;
  cin >> n;
  REP(i,n)REP(j,n)cin>>a[i][j];
  ll ans = 0;
  REP(i,n)REP(j,i) ans+=min(a[i][j],a[j][i]);
  cout << ans << endl;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <iterator> // std::back_inserter

using namespace std;

int h, w, sx, sy, distx, disty;
deque<pair<int, int>> q = {};
int mark[1005][1005];
char map[1005][1005];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

void print()
{
  cout << "map=" << endl;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cout << map[i][j] << ((sx == j && sy == i) ? "S" : ((disty == i && distx == j) ? "D" : " "));
    }
    cout << endl;
  }
  cout << "mark=" << endl;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cout << mark[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl
       << "Q=";
  for (int i = 0; i < q.size(); i++)
  {
    cout << "<" << q[i].first << "," << q[i].second << "> ";
  }
  cout << endl;
}

int main()
{
  cin >> h >> w >> sy >> sx >> disty >> distx;
  sy--;
  sx--;
  disty--;
  distx--;

  for (int i = 0; i < h; i++)
  {
    string t;
    cin >> t;
    for (int j = 0; j < t.length(); j++)
    {
      map[i][j] = t[j];
    }
  }
  q.push_back(make_pair(sx, sy));

  mark[sy][sx] = 1;
  while (q.size() > 0)
  {
    //    print();
    tie(sx, sy) = q.front();
    q.pop_front();
    for (int i = 0; i < 4; i++)
    {
      int tx = sx + dx[i];
      int ty = sy + dy[i];
      if (0 <= tx && tx < w && 0 <= ty && ty < h && map[ty][tx] == '.' && (mark[ty][tx] == 0 || mark[ty][tx] > mark[sy][sx]))
      {
        mark[ty][tx] = mark[sy][sx];
        q.push_front(make_pair(tx, ty));
      }
    }
    for (int wy = sy - 2; wy <= sy + 2; wy++)
    {
      for (int wx = sx - 2; wx <= sx + 2; wx++)
      {
        if (0 <= wx && wx < w && 0 <= wy && wy < h && map[wy][wx] == '.' && (mark[wy][wx] == 0))
        {
          mark[wy][wx] = mark[sy][sx] + 1;
          q.push_back(make_pair(wx, wy));
        }
      }
    }
  }

  if (mark[disty][distx] > 0)
  {
    cout << mark[disty][distx] - 1 << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}


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

using namespace std;

typedef long long ll;

const ll INF = LLONG_MAX;

int main () {
  int n;
  cin >> n;
  vector <int> arr(n + 1);
  vector <ll> acc(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    acc[i] = acc[i - 1] + arr[i];
  }
  vector <vector <ll>> dp(n + 1, vector <ll> (n + 1, INF));
  for (int l = n; l >= 1; l--) {
    dp[l][l] = 0;
    for (int r = l; r <= n; r++) {
      for (int k = l; k + 1 <= r; k++) {
        dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + (acc[r] - acc[l - 1]));
      }
    }
  }
  cout << dp[1][n] << endl;
  return (0);
}


Measured memory_bytes: 1536
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_7_D: Reconstruction of a Tree

#include <cstdio>
using uint = unsigned int;

static void solve(const uint preorders[], const uint inorders[], const uint indices[],
                  const uint p_index, const uint i_begin, const uint i_end)
{
  if (i_begin >= i_end) {
    return;
  }
  const auto root = preorders[p_index];
  const auto i_index = indices[root];
  const auto len = i_index - i_begin;
  solve(preorders, inorders, indices, (p_index+1), i_begin, i_index);
  solve(preorders, inorders, indices, (p_index+len+1), (i_index+1), i_end);
  std::printf("%u", root);
  std::printf("%s", (p_index == 0) ? "\n" : " ");
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  uint preorders[n];
  uint inorders[n];
  uint indices[n+1]; // 0 not used.
  uint k;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u", &k);
    preorders[i] = k;
  }
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u", &k);
    inorders[i] = k;
    indices[k] = i;
  }

  solve(preorders, inorders, indices, 0, 0, n);
}

// eof

Measured memory_bytes: 2744
#![allow(dead_code)]

mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }

    pub fn read_and_parse<T: std::str::FromStr>() -> T {
        read_line!().trim().parse().ok().unwrap()
    }
}

use reader::*;

fn main() {
    let n: u32 = read_and_parse();
    let v: Vec<i32> = read_to_vec();
    let c: Vec<i32> = read_to_vec();

    let mut sum: i32 = 0;

    for (x, y) in v.iter().zip(c) {
        let diff = x - y;
        if diff > 0 { sum += diff }
    }

    println!("{}" , sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
long long A[310][310];


int main() {
    while (cin >> N) {
        long long sum = 0;
        for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) cin >> A[i][j], sum += A[i][j];
        sum /= 2;
        
        bool ok = true, ichi = false;
        for (int i = 0; i < N; ++i) for (int j = i+1; j < N; ++j) {
            ichi = false;
            for (int k = 0; k < N; ++k) {
                if (k == i || k == j) continue;
                long long wa = A[i][k] + A[k][j];
                if (wa < A[i][j]) ok = false;
                else if (wa == A[i][j]) {
                    ichi = true;
                }
            }
            if (ichi) {
                //cout << i << ", " << j << ": " << A[i][j] << ", " << sum << endl;
                sum -= A[i][j];
            }
        }
        if (ok) cout << sum << endl;
        else cout << -1 << endl;
    }
}














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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

int main(){
    int h, w; cin >> h >> w;
    vector<string> lis(h);
    REP(i, 0, h){cin >> lis[i];}
    REP(i, 0, h){
        REP(l, 0, w){
            if(lis[i][l] != '#'){
                int count = 0;
                REP(k, 0, 8){
                    int x = i + dx[k], y = l + dy[k];
                    if(x >= 0 && y >= 0 && x < h && y < w && lis[x][y] == '#'){
                        count++;
                    }
                }
                lis[i][l] = '0'+count;
            }
        }
    }
    REP(i, 0, h){
        cout << lis[i] << endl;
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    ll n,k; cin >> n >> k; vector<ll> A(n,0);
    for (int i=0;i<n;i++)
    {
        cin >> A[i];
    }
    ll mod=1e9+7;
    map<int,ll> mp,mp1;
    for (int i=0;i<n;i++)
    {
        for (int j=i+1;j<n;j++)
        {
            if (A[j]<A[i])
                mp[i]++;
        }
    }
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            if (i!=j)
            {
                if (A[i]>A[j])
                    mp1[i]++;
            }
        }
    }
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        ans= (ans + (k*mp[i])%mod+ (mp1[i]*((k*(k-1)/2)%mod))%mod)%mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
//============================================================================
// Name        : 140A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

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

	cout << pow(N, 3);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

vector<vector<int>> v_x,v_y;
vector<ll> S;
vector<int> root;
int n;
bool used[200000];

struct uf {
private:
    vector<int> par, ran;
public:
    void init(int n) {
        par.resize(n, 0);
        ran.resize(n, 0);
        rep(i, n) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (ran[x] < ran[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (ran[x] == ran[y])ran[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

void solve(){
    cin >> n;
    int x,y;
    rep(i,200000){
        v_x.push_back({});
        v_y.push_back({});
        S.push_back(0);
        root.push_back(0);
        used[i]=false;
    }
    rep(i,n){
        cin >> x >> y;
        v_x[y-1].push_back(x-1);
        v_y[x-1].push_back(y-1);
    }
    uf u;u.init(200000);
    rep(x,200000){
        Rep(i,1,v_y[x].size()){
            y=v_y[x][i];
            u.unite(v_y[x][0],y);
        }
    }
    rep(y,200000){
        int a=S[u.find(y)];
        root[u.find(y)]+=1;
        rep(i,v_x[y].size()){
            x=v_x[y][i];
            if (used[x]) continue;
            a+=1;
            used[x]=true;
        }
        //cout << a << " " << b << " " << root[u.find(y)] << endl;
        S[u.find(y)]=a;
    }

    ll ans=0;
    rep(y,200000){
        ll a=S[y],r=root[y];
        ans+=a*r;
    }

    cout << ans - n << endl;

}

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

Measured memory_bytes: 18980
#include<iostream>
#include<string>

using namespace std;

int main(void){

	string inp;
	string data("AIDUNYAN");
	string tmda;

	cin>>inp;

	if(inp.size()>=8){
		for(int i=0;i<=inp.size()-data.size();i++){
			tmda=data;
			for(int j=0;j<=data.size()-1;j++){
				if(tmda.find(inp[i+j])!=-1){
					tmda[tmda.find(inp[i+j])]='-';
				}
				else break;
				if(j==data.size()-1) inp[i]='A',inp[i+1]='I',inp[i+2]='Z',inp[i+3]='U',inp[i+4]='N',inp[i+5]='Y',inp[i+6]='A',inp[i+7]='N',i+=7;
			}
		}
	}

	cout<<inp<<endl;

}

Measured memory_bytes: 1192
#include <iostream>
#include <climits>
using namespace std;
int main () {
  long long int N;
  cin >> N;
  long long int ans = 0;
  long long int min_num = LLONG_MAX;
  for (int i = 0; i < 5; i++) {
    long long int num;
    cin >> num;
    min_num = min(min_num, num);
  }
  cout << 4 + (N + min_num - 1) / min_num << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  size_t n;
  cin >> n;
  
  vector<int> weights(n);
  int back_sum = 0;
  for(size_t i = 0; i < n; ++ i)
  {
    cin >> weights[i];
    back_sum += weights[i];
  }
  
  int front_sum = 0;
  for(size_t i = 0; i < n; ++ i)
  {
    const int prev_front = front_sum;
    const int prev_back = back_sum;
    
    front_sum += weights[i];
    back_sum -= weights[i];
    if(front_sum < back_sum)
      continue;
    
    if(prev_back - prev_front < front_sum - back_sum)
      cout << prev_back - prev_front << endl;
    else
      cout << front_sum - back_sum << endl;
    
    break;
  }  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    vector<int> dp(n);
    dp[0]=0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+ abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3932
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long int ans = 1000000000, n, k, a[100005];
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i <= n - k; i++) {
		long long cnt = a[i + k - 1] - a[i] + min(abs(a[i]), abs(a[i + k - 1]));
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
// E.cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
using namespace std;
const int MX_N = 1e5 + 200;
ll n, wi[101], vi[101], dp[MX_N], W;
int main()
{
    scanf("%lld%lld", &n, &W);
    int tot = 0;
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld", &wi[i], &vi[i]), tot += vi[i];
    for (int i = 1; i <= n; i++)
        for (int cv = tot; cv >= vi[i]; cv--)
            dp[cv] = min(dp[cv], dp[cv - vi[i]] + wi[i]);
    ll ans = 0;
    for (int i = tot; i >= 0; i--)
        if (dp[i] <= W)
            printf("%d", i), exit(0);
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;
int INF = 1001001001;
int main(){
	int n;
	cin >> n;
	vector<int > w(n);
	rep(i,n) cin >> w[i];
	int ans=0;
	int mn = INF;
	rep(i,n){
		int s1=0, s2=0;
		rep(j,n){
			if(j<i){ s1 += w[j];
			}else s2 += w[j];
		}
		mn = min(mn, abs(s1-s2));
	}
	cout << mn << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
map<ll,ll>gg,gg1;
int main()
{
  //flash;
  vedos ko;
  ll n;
  cin>>n;
  for (ll i = 0; i < n; ++i)
  {
    ll yo;
    cin>>yo;
    ko.pb({i,yo});
  }
  sort(all(ko));
  for(auto it:ko){
    gg[-it.first-it.second]++;
  }
  ll ans=0;
  reverse(all(ko));
  for (auto it:ko)
  {
    gg[-it.first-it.second]--;
    ans+=gg[it.second-it.first];
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 28992
#include<iostream>
using namespace std;
int main(){
  int n,bell,hess=0,aice[100]={0};
  while(1){
    for(int i=0;i<100;i++){
      aice[i]=0;
    }
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> bell;
      aice[bell]++;
    }
    for(int i=0;i<10;i++){
      for(int j=0;j<aice[i];j++){
	hess++;
	cout << "*";
      }
      if(hess==0){
	cout << "-";
      }
      hess=0;
      cout << endl;
    }
  }
  return (0);
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <functional>


using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> vec(m);
  for(int i=0;i<m;i++){
    cin >> vec[i];
  }
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  sort(vec.begin(),vec.end());
  vector<int> diff(m-1);
  for(int i=0;i<m-1;i++){
    diff[i] = vec[i+1] - vec[i];
  }
  sort(diff.begin(),diff.end(),greater<int>());
  
  cout << accumulate(diff.begin(),diff.end(),0) - accumulate(diff.begin(),diff.begin()+n-1,0) << endl;
  
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

bool dislike[10];

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

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; ++i){
        int foo;
        cin >> foo;
        dislike[foo] = true;
    }
    for(int i = n; i <= 100 * n; ++i){
        string s = to_string(i);
        int m = s.length();
        bool ok = true;
        for(int j = 0; j < m; ++j){
            if(dislike[s[j] - '0']){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int a[]=new int[n];
		int b[]=new int[n];
		int c[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();
		}
		int hp[][]=new int[n][3];
		hp[0][0]=a[0];
		hp[0][1]=b[0];
		hp[0][2]=c[0];
		for(int j=1;j<n;j++) {
			hp[j][0]=Math.max(hp[j-1][1]+a[j],hp[j-1][2]+a[j]);
			hp[j][1]=Math.max(hp[j-1][0]+b[j],hp[j-1][2]+b[j]);
			hp[j][2]=Math.max(hp[j-1][0]+c[j],hp[j-1][1]+c[j]);
		}
		
		System.out.println(Math.max(Math.max(hp[n-1][0],hp[n-1][1]),hp[n-1][2]));
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			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: 48880
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = numeric_limits<int>::max();

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

    int N;
    cin >> N;
    vector<int> a(3*N);
    REP(i, 3*N) cin >> a[i];
    
    priority_queue<int, vector<int>, greater<int>> F;
    priority_queue<int> B;
    int Fs = 0, Bs = 0;
    REP(i, N){
        F.push(a[i]);
        Fs += a[i];
        B.push(a[3*N-1-i]);
        Bs += a[3*N-1-i];
    }

    vector<int> F_score(N+1, 0), B_score(N+1, 0);
    F_score[0] = Fs;
    B_score[0] = Bs;
    FOR(i, N, 2*N){
        F.push(a[i]);
        Fs += a[i];
        Fs -= F.top();
        F.pop();
        F_score[i-N+1] = Fs;
        B.push(a[3*N-1-i]);
        Bs += a[3*N-1-i];
        Bs -= B.top();
        B.pop();
        B_score[i-N+1] = Bs;
    }
    int ans = -INF;
    REP(i, N+1){
        // cout << F_score[i] << " " << B_score[N-i] << "\n";
        ans = max(F_score[i] - B_score[N-i], ans);
    }

    cout << ans << "\n";
    return 0;
}

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

int main(){
	int W, H, x, y, r;
		cin >> W >> H >> x >> y >> r;
		if(W >= x + r && H >= y + r && x >= 0 && y >= 0){
			cout << "Yes" << endl;
		}
		
		else{
			cout << "No" << endl;
		}
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int x,y;
    cin >>x>>y;
    cout << x+y/2<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int main(){
	int n,m,sum,x;
	while(cin>>n>>m,n||m){
		sum=0;
		priority_queue<int> que;
		for(int i=0;i<n;i++){
		cin>>x;
			que.push(x);
		}
		for(int i=1;i<=n;i++){
			
			if((m+i)%m!=0){
			sum+=que.top();
			}
			que.pop();
		}
		cout<<sum<<endl;
	}
	return 0;
} 

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << "Draw";
    else
    {
        if (a == 1)
            cout << "Alice";
        else
        {
            if (b == 1)
                cout << "Bob";
            else
            {
                if (a > b)
                    cout << "Alice";
                else
                    cout << "Bob";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
def calc(A, B, C, K):
    if K < A:
        return K
    elif K <= A + B:
        return A
    else:
        return A - (K - A - B)

    

(A, B, C, K) = tuple([int(s) for s in input().split()])
print(calc(A, B, C, K))

Measured memory_bytes: 61404
import sys
input = sys.stdin.readline
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [None] * N
for i in range(N):
  A[i] = list(map(int, input().split()))


ans = 0
for i in range(N):
  condition = 0
  for j in range(M):
    condition += A[i][j] * B[j]
  condition += C
  if (condition > 0):
    ans += 1

print(ans)


Measured memory_bytes: 38256
#include<stdio.h>

int main(){
	int x=0,y=0;
	while(1){
		scanf("%d",&x);
		scanf("%d",&y);
		if(x==0 && y==0){
			break;
		}
		if(x<y){
			printf("%d %d\n",x,y);
		}else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}



Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;

ll dp[(1<<17)];
ll a[17][17], n;

ll score[(1<<17)];
ll calc_group(ll x) {
	ll score = 0LL;
	for(int i=0;i<n;i++) {
		if(x&(1<<i))
			for(int j=0;j<n;j++)
				if(x&(1<<j) && i < j) 
					score += a[i][j]; 
	}
	return score;
}	

int main() {
	cin>>n;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			cin>>a[i][j];
		}
	}

	for(ll mask=1LL;mask<(1<<n);mask++) {
		score[mask] = calc_group(mask);
	}

	for(ll mask=1LL;mask<(1<<n);mask++) {
		ll x = mask;
		int b = 0; 
		do {
        	dp[mask] = max(dp[mask], dp[mask^b] + score[b]);
		} while (b=(b-x)&x);
	}
	cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 1280
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):

    def binary_search(ary, val):
        n = len(ary)
        l = -1
        r = n
        while r - l > 1:
            mid = (l + r) // 2
            if ary[mid] >= val:
                r = mid
            else:
                l = mid
        if l == -1:
            return [ary[0]]
        if r == n:
            return [ary[n - 1]]
        return [ary[l], ary[r]]

    for q in x:
        ret = float('inf')
        a_pos = binary_search(s, q)
        b_pos = binary_search(t, q)
        for a in a_pos:
            for b in b_pos:
                ret = min(ret, abs(a - q) + abs(b - a))
                ret = min(ret, abs(b - q) + abs(a - b))
        print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(A) ]  # type: "List[int]"
    t = [ int(next(tokens)) for _ in range(B) ]  # type: "List[int]"
    x = [ int(next(tokens)) for _ in range(Q) ]  # type: "List[int]"
    solve(A, B, Q, s, t, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), h = in.nextInt();
            TaskD.Weapon[] ws = new TaskD.Weapon[n];
            int maxA = -1;
            for (int i = 0; i < n; i++) {
                TaskD.Weapon w = new TaskD.Weapon(in.nextInt(), in.nextInt());
                ws[i] = w;
                maxA = Math.max(maxA, w.a);
            }
            Arrays.sort(ws);
            int res = 0;
            for (int i = 0; i < n; i++) {
                if (h <= 0) {
                    out.println(res);
                    return;
                }

                if (ws[i].b <= maxA) {
                    break;
                }

                h -= ws[i].b;
                ++res;
            }

            if (h <= 0) {
                out.println(res);
                return;
            }

            res += (int) Math.ceil((h * 1.0) / maxA);
            out.println(res);
        }

        static class Weapon implements Comparable<TaskD.Weapon> {
            int a;
            int b;

            public Weapon(int a, int b) {
                this.a = a;
                this.b = b;
            }


            public int compareTo(TaskD.Weapon o) {
                if (b == o.b) return -Integer.compare(a, o.a);
                return -Integer.compare(b, o.b);
            }

        }

    }
}



Measured memory_bytes: 85856
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(A:i32,B:i32,X:i32);
    let mut ans = (1e9) as i32;
    for i in 0..100{
        for j in 0..100{
            let litter = i*1000 + j*500;
            if litter < X {
                continue;
            }
            ans = min(ans,i*A+j*B);
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 5036
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int a, b;
	cin >> a >> b;
	if (b == 1) {
		cout << 0 << endl;
	}
	else {
		cout << a-b << endl;
	}
}



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

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(a+b>=c?"Yes":"No");

		}
	}
}

Measured memory_bytes: 25372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for   (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double N;
    cin >> N;
    double pi=3.1415926535898;
    printf("%.12f %.12f",  N * N * pi, (N + N) * pi);
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

template<typename T>
T mypow(T a, T p) {
	T ret = 1;
	while( p ) {
		if( p & 1 ) {
			ret *= a;
		}
		
		a *= a;
		p >>= 1;
	}
	
	return ret;
}


int main(void) {
	string s;
	cin >> s;
	
	ll ans = 0LL;
	int n = (int)s.size();
	
	for(int bits = 1; bits < (1 << (n - 1)); ++bits) {
		ll sum = 0LL;
		int prev = n - 1;

		for(int i = 0; i < n - 1; ++i) {
			if( bits & (1 << i) ) {
				ll base = 1LL;
				
				for(int j = prev; j >= n - i - 1; --j) {
					sum += (ll)(s[j] - '0') * base;
					base *= 10LL;
				}
				
				prev = n - i - 2;
			}
		}
		
		ll rsum = 0LL;
		ll b = 1LL;
		for(int i = prev; i >= 0; i--) {
			rsum += (ll)(s[i] - '0') * b;
			b *= 10LL;
		}
	
		ans += sum;
		ans += rsum;
	}
	
	ans += stoll(s);
	
	cout << ans << endl;
	
	return 0;
}


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

struct UnionFind{
	vector<int> data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
};

int ModPow(int a,int r,int m)
{
	long long x=1;
	for(int i=32;i--;){
		x=x*x%m;
		if(r>>i&1)
			x=x*a%m;
	}
	return x;
}

int main()
{
	constexpr int MOD=1e9+7;
	
	for(int n,m;cin>>n>>m && n|m;){
		UnionFind uf(n);
		int cc=n;
		while(m--){
			int a,b; cin>>a>>b; a--,b--;
			cc-=uf.Unite(a,b);
		}
		int res=ModPow(2,cc,MOD);
		if(cc<n) res=(res+1)%MOD;
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1584
/*input
5
abcab
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

     int freq[26];

void solve(){
     int n;
     string s;
     cin >> n >> s;
     int ans = 1;
     REP(i,n){
     	freq[s[i]-'a']++;
     }
     REP(i,26){
     	ans *= (freq[i]+1);
     	ans %= MOD;
     }
     ans--;
     if(ans < 0)ans += MOD;
     debug(ans);
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

distance = []

for i in range(0,len(A)-1):
    tem = A[i+1] - A[i]
    distance.append(tem)

tem = A[0] + K - A[-1]
distance.append(tem)

print(sum(distance)- max(distance))


Measured memory_bytes: 26420
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
int n ;
double p[N] , dp[N][N];
double calc(int i , int h){
    if(i == n)
    return h > n / 2;
    double &ret = dp[i][h];
    if(ret != -1)return ret;
    return ret = (p[i] * calc(i + 1 , h + 1)) + ((1 - p[i]) * calc(i + 1, h));
}
int main(){
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> p[i];
    }
    for(int i = 0 ; i < N ; i++)
        for(int j = 0 ; j < N ; j++)
            dp[i][j] = -1;
    cout << fixed;
    cout << setprecision(9);
    cout<<calc(0 , 0);
    return 0;
}


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

const int MAX = 10000;
const int INFINITY = 2 << 21;
int n;
vector<pair<int, int> > G[MAX];
int distances[MAX];
int states[MAX];

void dijkstra() {
  int id = 0;
  distances[id] = 0;
  priority_queue<pair<int, int> > PQ;
  PQ.push(make_pair(0, 0));

  while (!PQ.empty()) {
    pair<int, int> p = PQ.top(); PQ.pop();
    id = p.second;
    states[id] = 1;

    if (distances[id] < p.first * -1) continue;

    int s = G[id].size();
    for (int i = 0; i < s; i++) {
      int k = G[id][i].first;
      int v = G[id][i].second;
      if (states[k] == 1) continue;
      if (distances[id] + v < distances[k]) {
        distances[k] = distances[id] + v;
        PQ.push(make_pair(distances[k] * -1, k));
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << (distances[i] == INFINITY ? -1 : distances[i]) << endl;
  }
}

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

  cin >> n;

  int u, k, v, c;
  for (int i = 0; i < n; i++) {
    distances[i] = INFINITY;
    states[i] = 0;
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      G[i].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}

Measured memory_bytes: 8132
function Main(input){
	input = input.split(" ").map(Number);
	var n = input[0];
	var m = input[1];
	var p = n*100+m*1800;
	var c = Math.pow(2,m);
	console.log(c*p)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
#include <iostream>
using namespace std;
int main(){
    int n;
    int a[3];
    bool flag = true;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        a[i] = n % 10;
        n /= 10;
    }
    
    if (a[2] < a[1]) {
        flag = false;
    }
    else if (a[2] == a[1]) {
        if (a[1] < a[0]) {
            flag = false;
        }
    }
    if (flag) {
        cout << a[2] << a[2] << a[2];
    }
    else {
        for (int i = 0; i < 3; i++) {
            cout << a[2] + 1;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256