akhauriyash/Code-Regression huggingface dataset:
/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
*/
function Main(input) {
  //write here!
  input = input.split("").map(Number);
  var a = 10*input[0]+input[1];
  var b = 10*input[2]+input[3];
  var p,q;
  if(a!=0&&a<=12) p = true;
  if(b!=0&&b<=12) q = true;
  if(p&&q) console.log("AMBIGUOUS");
  else if((!p)&&q) console.log("YYMM");
  else if(p&&(!q)) console.log("MMYY");
  else console.log("NA")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}
function pf(n) {
    var result = {};
    
    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}

Measured memory_bytes: 7372
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S_1 = str(input())
S_2 = str(input())

dominos = []
i = 0
while i < N:
    if S_1[i] == S_2[i]:
        dominos.append(1)
        i += 1
    else:
        i += 2
        dominos.append(2)
ans = 1
for i, domino in enumerate(dominos):
    if i == 0:
        if dominos[i] == 1:
            ans *= 3
        else:
            ans *= 6
    else:
        if dominos[i] == dominos[i - 1] == 1 or dominos[i-1] == 1 and dominos[i] == 2:
            ans *= 2
            ans = ans % mod
        elif dominos[i] == dominos[i - 1] == 2:
            ans *= 3
            ans = ans % mod

print(ans)


Measured memory_bytes: 10808
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1000000000000000000;
typedef pair<int, int> P;
typedef unsigned int ui;
typedef long long ll;
int main(){
	int n, a;
	cin >> n >> a;
	if (n % 500 > a) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int m,n,k[1001],a[101][101],mt[101],p[101],sum=0;
bool mark;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&k[i]);
		for(int j=1;j<=k[i];j++) scanf("%d",&a[i][j]);
	}
	for(int i=1;i<=m;i++) scanf("%d",&p[i]);
	for(int i=1;i<=pow(2,n);i++){
		mark=true;
		for(int j=1;j<=m;j++){
			for(int pp=1;pp<=k[j];pp++)
				if(i&(1<<(a[j][pp]-1))) mt[j]++;
			if(mt[j]%2!=p[j]) {
				mark=false;break;
			}
		}
		if(mark) {
			sum++;
			//printf("%d  ",i);
		}
		for(int j=1;j<=m;j++) mt[j]=0;
	}
	printf("%d",sum);
}

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

using namespace std;
using ll = long long;
int a[200005], b[200005];
int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    for( int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    for( int i = 0; i < n; ++i){
        scanf("%d", &b[i]);
    }
    int q = 0, w = n - 1 ;
    bool ok = true;
    reverse(b, b + n);
    for( int i = 0; i < n; ++i){
        if(a[i] != b[i]) continue;
        if(a[q] != b[i] and a[i] != b[q]){
            swap(b[q], b[i]);
            q++;
        }
        else if(a[w] != b[i] and a[i] != b[w]){
            swap(b[w], b[i]);
            w--;
        } else {
            ok = false;
            break;
        }
    }


    if(ok){
        cout << "Yes\n";
        for( int i = 0; i < n; ++i){
            printf("%d ", b[i]);
        }
    }
    else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 5384
import sys
input = sys.stdin.readline


n, k = map(int, input().split())
H = sorted(int(input()) for _ in range(n))

answer = float("inf")
for i in range(n - k + 1):
    temporary = H[i + k - 1] - H[i]
    if temporary < answer:
        answer = temporary

print(answer)


Measured memory_bytes: 7500
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

// swap(a,b);
// abs(a,b); a,bの型は問わない
// reverse(a+I,a+r); aは配列,a[i]からa[r-1]までを逆順にする.計算量はN. reverse(str.begin(),str.end());
// sortも上とあまり変わらない.
// ただし,sort(a,a+N,greater<int>());で大きい順にならべかえる.
// stack<int> a; 宣言 上に積み上げたものをとったり、一番上に積み上げる.
// a.push(x); aに要素xをつむ a.pop(); a.size(); a.empty(); これはtrue or false
// a.top;で一番上の要素を返す
// queue<int> a; a.front();
// priority_queue<int,vector<int>,greater<int>> Q1; 最も小さい奴を取り出す
// priority_queue<double,vector<double>,less<double>> Q2;最も大きい値を取り出す
// Q1.top();ができる
// count(a+l,a+r,x);
// find(a+l,a+r,x);
// 文字変換
//char a='a';
//a=a+1;
//cout<<a<<endl;


int main(){
  int H,A;cin>>H>>A;
  if(H%A==0){
    cout<<H/A<<endl;
  }
  else{
    cout<<H/A+1<<endl;
  }

}

Measured memory_bytes: 888
import java.util.Scanner;
class Main {
   public static void main(String[] args){
   Scanner scan = new Scanner(System.in);

   int a = scan.nextInt();
   int b = scan.nextInt();
   int c = scan.nextInt();
   int tmp;

   if(a > b){tmp = a;
             a = b;
             b = tmp;}

    if(a > c){tmp = a;
              a = c;
              c = tmp;}
 
    if(b > c){tmp = b;
              b = c;
              c = tmp;}

     System.out.println(a + " " + b + " " + c);
    }
}

    

Measured memory_bytes: 17160
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t = 0, x, n, m, k;int ans=0;
    cin >> n >> m >> k;
    vl A, B;ll s=0;ll ans1=0,ans2=0;
    rep(i, 0, n)
    {
        cin >> x;
        s+=x;if(s<=k)ans1++;
        A.pb(s);
    }
    s=0;
    rep(i, 0, m)
    {
        cin >> x;
        s+=x;if(s<=k)ans2++;
        B.pb(s);
    }
    ans=max(ans1,ans2);
    int mid;
    int st=0,end=m-1;
    rep(i,0,n){
        ans1=-1;if(A[i]>k)break;
        st=0,end=m-1;
        while(st<=end){
          mid=(st+end)/2;
          if((B[mid]+A[i])<=k){
              ans1=mid;
              st=mid+1;
          }
          else{
              end=mid-1;
          }
        }
        if(i+mid+2>ans&&(ans1!=-1)){ans=i+ans1+2;}
    } 
    cout << ans;
    return 0;
}

Measured memory_bytes: 7888
#include <bits/stdc++.h>
#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
vector<ll> v;
ll N;
void f() {
    ll copy = N;
    for(ll i = 2; i * i <= copy; i++) {
        if(copy % i != 0) continue;
        v.push_back(1);
        while(copy % i == 0) {
            v.back() *= i;
            copy /= i;
        }
    }
    if(copy != 1) {
        v.push_back(copy);
    }
}
ll ans = INF;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    N *= 2;
    f();
    if(v.size() == 1) {
        cout << N - 1 << endl;
        return 0;
    }
    for(int bits = 0; bits < (1 << v.size()); bits++) {
        ll a = 1;
        ll b = 1;
        for(int i = 0; i < v.size(); i++) {
            if(bits & (1 << i)) {
                a *= v[i];
            } else {
                b *= v[i];
            }
        }
        ll tmp = atcoder::inv_mod(a, b);
        if(a == 1 or b == 1) continue;
        if(tmp == 0) tmp += b;
        //cerr << a << " " << b << " " << tmp << endl;
        ll tmpans = tmp * a;
        chmin(ans, tmpans - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N; cin >> N;
  vector<pair<ll, int>> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.rbegin(), v.rend());
  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  for (int l = 0; l < N; l++) {
    for (int r = 0; l + r < N; r++) {
      ll lp = l;
      ll rp = N - r - 1;
      auto [val, p] = v[l + r];
      dp[l+1][r] = max(dp[l+1][r], dp[l][r] + abs(p - lp) * val);
      dp[l][r+1] = max(dp[l][r+1], dp[l][r] + abs(p - rp) * val);
    }
  }
  ll res = 0;
  for (int i = 0; i <= N; i++) {
    res = max(res, dp[i][N-i]);
  }
  cout << res << endl;
}
  


Measured memory_bytes: 34564
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    double sum =.0;
    for(int i = 1; i<=n; i++) {
        double tempProb ,tempScore;
        tempProb = 1.0/n;
        tempScore = i;
        while(tempScore < k) {
            tempScore *= 2;
            tempProb *= 1.0/2;
        }
        sum += tempProb;
    }
    cout << fixed;
    cout << setprecision(12);
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n,m,k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];

	ll res = 0;
	ll sumA = 0, cntA = 0;
	ll sumB = 0, cntB = 0;

	// まず、Aから一冊も読まないと仮定
	while(true){
		if(sumB + b[cntB] > k) break;
		sumB += b[cntB];
		cntB++;
		if(cntB == m) break;
	}
	res = cntB;

	// Aから取る冊数を増やしていく
	rep(i,n){
		cntA++;
		sumA += a[i];
		while(sumA + sumB > k){
			cntB--;
			if(cntB < 0) break;
			sumB -= b[cntB];
		}

		if(cntB < 0) break;
		res = max(res, cntA + cntB);
	}

	cout << res << endl;
	
	return 0;
}

int main(){

	return mainsolve();
}

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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uni(n);
    int cnt[n]={};
    int ans[n]={};
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        cnt[a]++;
        cnt[b]++;
        uni.unite(a,b);
    }
    for(int i=0;i<k;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        if(uni.same(a,b)){
            ans[a]--;
            ans[b]--;
        }
    }
    for(int i=0;i<n;i++){
        ans[i] += uni.size(i) - cnt[i];
        cout << ans[i]-1 << " ";
    }
    cout << endl;



}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,ans=0;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<n-1;i++){
    ans+=v[i];
  }
  if(ans<=v[n-1]){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

pair<ll, int> mibit(ll l, ll r, int k) {
    if (l < 0)return mp(0ll, 0);
    pair<ll, int> res;
    for (int i = k; i >= 0; --i) {
        res.first |= r&(1ll << i);
        res.second += r >> i & 1;
        if ((l >> i & 1) != (r >> i & 1))break;
    }
    return res;
}

typedef vector<pair<long long, long long>> Intervals;
Intervals mergeIntervals(Intervals a) {
    Intervals res;
    sort(a.begin(), a.end());
    for (const auto & b : a) {
        if (res.size() == 0 || res.back().second < b.first)
            res.push_back(b);
        else
            res.back().second = max(res.back().second, b.second);
    }
    return res;
}

int N;
ll K;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> K;
    vll A(N);
    rep(i, N)cin >> A[i];
    sort(all(A));

    map<vll, Intervals> S;

    for (int k = 0; k <= 60; ++k) {
        vll B(N), C(N+1, -1), CC;
        ll div = 1ll << k;
        rep(i, N) {
            B[i] = A[i] / div;
            C[i] = A[i] % div;
        }
        CC = C;
        sort(all(C));
        C.erase(unique(all(C)), C.end());

        rep(i, sz(C) - 1) {
            ll P;
            int bitcnt;
            tie(P, bitcnt) = mibit(C[i], C[i + 1], k);
            if (k + bitcnt > K)continue;
            vll D = B;
            bool ok = true;
            rep(j, N) {
                D[j] += P > CC[j] ? -1 : 0;
                if (D[j] < 0) {
                    ok = false;
                    break;
                }
            }
            if (!ok)continue;

            ll rem = K - bitcnt - k;
            ll r = D[0] + 1, l = max(0ll, D[0] - rem); //[l, r)
            ll d0 = D[0];
            rep(j, N)D[j] -= d0;

            S[D].push_back(mp(l, r));
        }
    }

    const ll MO = (ll)1e9 + 7;
    ll ans = 0;
    each(p, S) {
        auto intervals = mergeIntervals(p.second);
        each(lr, intervals) {
            ans += (lr.second - lr.first) % MO;
        }
    }
    ans %= MO;
    cout << ans << endl;
}


Measured memory_bytes: 16512
A, B, C, X = map(int, [input() for _ in range(4)])

count = 0
for a in range(A + 1):
	for b in range(B + 1):
		for c in range(C + 1):
			value = 500 * a + 100 * b + 50 * c
			if X == value:
				count += 1
print(count)

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

using namespace std;

typedef long long ll;

map <ll,int> ma;
int main(){
        int n;
        cin>>n;
        long long sum=0,ans=0;
        ma[0]++;
        for(int i=1;i<=n;i++){
                int val;
                cin>>val;
                sum+=val;
                ans+=ma[sum];
                ma[sum]++;
        }
        cout<<ans;
}


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

using namespace std;

struct node
{
	int num,l,r,ls,rs,lazy;
	node(int _l,int _r)
	{
		num=INT_MAX;
		l=_l;
		r=_r;
	}
};

vector<node> T;

int make(int l,int r)
{
	int id=T.size();
	T.push_back(node(l,r));
	T[id].ls=(l+1==r?-1:make(l,(l+r)/2));
	T[id].rs=(l+1==r?-1:make((l+r)/2,r));
	return id;
}

void update(int id,int l,int r,int t)
{
	//printf("|%d %d %d %d\n",id,l,r,t);
	if(l==r||T[id].l>=r||T[id].r<=l)
		return ;
	if(T[id].l>=l&&T[id].r<=r)
	{
		T[id].num=t;
		return ;
	}
	int mid=(T[id].l+T[id].r)>>1;
	if(T[id].num>=0)
		T[T[id].ls].num=T[T[id].rs].num=T[id].num;
	if(l<mid)
		update(T[id].ls,l,r,t);
	if(r>mid)
		update(T[id].rs,l,r,t);
	T[id].num=-1;
}

int getmin(int id,int l,int r)
{
	if(l==r||T[id].l>=r||T[id].r<=l)
		return INT_MAX; 
	if(T[id].num>=0)
		return T[id].num;
	int mid=(T[id].l+T[id].r)>>1,mi=INT_MAX;
	if(l<mid)
		mi=min(mi,getmin(T[id].ls,l,r));
	if(r>mid)
		mi=min(mi,getmin(T[id].rs,l,r));
	return mi;
}

int main()
{
	T.reserve(200100);
	int n,q;
	scanf("%d%d",&n,&q);
	make(0,n);
	for(int i=0;i<q;i++)
	{
		int com;
		scanf("%d",&com);
		if(com==0)
		{
			int s,t,x;
			scanf("%d%d%d",&s,&t,&x);
			update(0,s,t+1,x);
		//	for(int i=0;i<T.size();i++) printf("%d %d %d %d %d %d\n",i,T[i].num,T[i].l,T[i].r,T[i].ls,T[i].rs);
		}
		else
		{
			int s,t;
			scanf("%d%d",&s,&t);
			printf("%d\n",getmin(0,s,t+1));
		}
	}
}
/*
20 100
0 4 14 3
0 6 12 6
1 14 18
*/

Measured memory_bytes: 7568
import collections
import heapq

x,y,z,t = map(int, raw_input().split(' '))
mat = [map(int,raw_input().split(' ')) for _ in range(3)]
for ii in range(len(mat)): mat[ii].sort(key = lambda x:-x)

seen,heap = set([(0,0,0)]),[(-mat[0][0]-mat[1][0]-mat[2][0], 0,0,0)]


while(heap and t):
	u,i,j,k = heapq.heappop(heap)
	print -u
	t-=1
	for nei in [(i+1,j,k), (i,j+1,k), (i,j,k+1)]:
		if nei not in seen and all([0<=nei[ii]<len(mat[ii]) for ii in range(3)]):
			seen.add(nei)
			vv = -sum([mat[ii][vvv] for ii,vvv in enumerate(nei)])
			heapq.heappush(heap,(vv,nei[0],nei[1],nei[2]))


Measured memory_bytes: 37916
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

int main() {
    long long n, a, sum = 0, min = 1e12;
    cin >> n;
    vector<int> as(n);
    for (int i = 1; i <= n; i++){
        cin >> a;
        as[a - 1] = i;
    }
    for (int i = 0; i < n; i++){
        cout << as[i] << " ";
    }
}

Measured memory_bytes: 1280
import itertools
h, w, k = map(int, input().split())
s = []

total = 0
hcnt = [0 for i in range(h)]
wcnt = [0 for i in range(w)]
for i in range(h):
  c = input()
  hcnt[i] = c.count('#')
  total += c.count('#')
  s.append(c)

for i in range(w):
  cnt = 0
  for j in range(h):
    if s[j][i] == '#':
      cnt += 1
  wcnt[i] = cnt

ans = 0
for i in itertools.product([0,1], repeat=h):
  for j in itertools.product([0,1], repeat=w):
    cnt = 0
    for a in range(h):
      for b in range(w):
        if i[a] == 1 and j[b] == 1:
          if s[a][b] == '#':
            cnt += 1
    if cnt == k:
      ans += 1
print (ans)


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<ll> sum(N+1, 0);
  map<ll, int> mp;
  mp[sum[0]]++;
  REP(i, N){
    sum[i+1] = sum[i] + A[i];
    mp[sum[i+1]]++;
  }
  ll ans = 0;
  for(auto m : mp){
    ll cnt = m.second;
    ans += cnt * (cnt-1) / 2;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 15872
#include <iostream>

int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	if (a * b > c * d) {
		std::cout << a * b << std::endl;
	}
	else {
		std::cout << c * d << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::io::*;
use std::str::FromStr;
use std::collections::*;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let d: i32 = sc.next();
    let t: i32 = sc.next();
    let s: i32 = sc.next();

    if s * t >= d {
	println!("Yes");
    } else {
	println!("No");
    }
}


// Scanner
struct Scanner<R: std::io::Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
	Scanner { reader: reader }
    }

    fn read<T: FromStr> (&mut self) -> Option<T> {
	let token = self
	    .reader
	    .by_ref()
	    .bytes()
	    .map(|c| c.unwrap() as char)
	    .skip_while(|c| c.is_whitespace())
	    .take_while(|c| !c.is_whitespace())
	    .collect::<String>();
	if token.is_empty() {
	    None
	} else {
	    token.parse::<T>().ok()
	}
    }

    fn next<T: FromStr>(&mut self) -> T {
	if let Some(s) = self.read() {
	    s
	} else {
	    writeln!(stderr(), "Terminated with EOF").unwrap();
	    std::process::exit(0);
	}
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
	(0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
	self.next::<String>().chars().next().unwrap()
    }
}


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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  
  vector<int> gone(N,0);
  gone.at(1)=2;
  bool check=true;
  int i=0;
  int ans=0;
  while(check){
    if(gone.at(i)==0){
      gone.at(i)=1;
      i=a.at(i)-1;
      ans++;
    }
    else if(gone.at(i)==2)
      break;
    else
      check=false;
  }
  if(check)
    cout<<ans<<endl;
  else
    cout<<"-1"<<endl;
}


Measured memory_bytes: 4040
//38
#include<iostream>
#include<algorithm>

using namespace std;

#define M ((1<<10)-1)

int main(){
  int n;
  cin>>n;
  while(n--){
    unsigned u[10]={};
    for(int y=0;y<10;y++){
      for(int x=0;x<10;x++){
	int b;
	cin>>b;
	u[y]=(u[y]<<1)+b;
      }
    }
    unsigned a[10];
    for(a[0]=0;;a[0]++){
      unsigned c[10];
      copy(u,u+10,c);
      c[0]^=a[0]^(a[0]<<1&M)^a[0]>>1;
      c[1]^=a[0];
      for(int i=1;i<9;i++){
	a[i]=c[i-1];
	c[i]^=a[i]^(a[i]<<1&M)^a[i]>>1;
	c[i+1]^=a[i];
      }
      a[9]=c[8];
      if((a[9]^(a[9]<<1&M)^a[9]>>1^c[9])==0){
	break;
      }
    }
    for(int y=0;y<10;y++){
      for(int x=9;x>=0;x--){
	cout<<!!(1<<x&a[y])<<((x==0)?'\n':' ');
      }
    }
  }
  return 0;
}

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

ll i,j,k,l;
vector<ll> dp(200001),cnt(10000);

int main(){
    int n,p;cin>>n>>p;
    string s;
    cin>>s;
    cnt.resize(p);
    for(i=0;i<200001;i++){dp[i]=0;}
    for(i=0;i<p;i++){cnt[i]=0;}
    
    cnt[0]++;

    ll pow_ten=1,ans=0;
    if(!(p==2 || p==5)){
        for(i=s.size()-1;i>=0;i--)
        {
           
            dp[i]=(dp[i+1]+(s[i]-'0')*pow_ten)%p;
            pow_ten*=10;
            pow_ten%=p;
            cnt[dp[i]]++;
        }

        for(i=0;i<p;i++){
        ans+=cnt[i]*(cnt[i]-1)/2;
        }
    }else{
        for(i=0;i<s.size();i++)
        {
            if((int)(s[i]-'0')%p==0){
                ans+=(i+1);
            }
        }
    }   

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

Measured memory_bytes: 2304
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            if (K % 2 == 0)
            {
                Console.WriteLine((K / 2) * (K / 2));
            }
            else
            {
                Console.WriteLine(((K / 2) + 1) * (K / 2));
            }
        }
    }
}

Measured memory_bytes: 11092
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

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

  ll n;
  std::cin>>n;

  std::vector<std::vector<P>> graph(n);

  rep(i,0,n-1){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back({b,i});
    graph[b].push_back({a,i});
  }

  std::vector<ll> color(n-1,-1);

  std::queue<P> que;

  ll max=0;
  for(P e:graph[0]){
    color[e.second]=max;
    que.push({e.first,e.second});
    max++;
  }

  max--;

  while(!que.empty()){
    P e=que.front();que.pop();

    ll cnt=0;

    rep(i,0,graph[e.first].size()){
      if(graph[e.first][i].second!=e.second){
        if(cnt==color[e.second])cnt++;
        color[graph[e.first][i].second]=cnt;
        chmax(max,cnt);
        que.push({graph[e.first][i].first,graph[e.first][i].second});
        cnt++;
      }
    }
  }

  std::cout<<max+1<<"\n";

  rep(i,0,n-1)std::cout<<color[i]+1<<"\n";

  return 0;
}

Measured memory_bytes: 8960
#include<stdio.h>

int main(){
	int a;
  	int b;
  	int c;
  
  scanf("%d",&a);
  scanf("%d",&b);
  
  c = a*b;
  
  if(c % 2 ==0){
    printf("Even");
  }else{
    printf("Odd");
  }
  
  	
 
  
 
	return 0;
  
}



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

max_a = 0
before_a = A[0]
for i in range(1, N):
    if A[i]-before_a > max_a:
        max_a = A[i]-before_a
    before_a = A[i]

if (K-A[N-1]+A[0]) > max_a:
    print(A[N-1]-A[0])
else:
    print(K-max_a)

Measured memory_bytes: 26444
#include <stdio.h>
int main(){
	double v,n;
	while(scanf("%lf",&v)!=EOF){
		n = (v*v)/98+1;
		//if(n>(double)((int)n))
		printf("%d\n",(int)n+1);
		//else printf("%d\n",(int)n);
	}
	return 0;
}

Measured memory_bytes: 1056
#!/usr/bin/env python3

def main():
    N = int(input())
    s = []
    for i in range(N):
        s.append(input())
    M = int(input())
    t = []
    for i in range(M):
        t.append(input())

    d = {}
    for v in s:
        if v in d:
            d[v] += 1
        else:
            d[v] = 1
    for v in t:
        if v in d:
            d[v] -= 1
        else:
            d[v] = -1

    max_v = max(d.values())
    max_v = max(max_v, 0)

    print(max_v)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
n, m = map(int, input().split())
T1 = [[] for i in range(n)]
T2 = [[] for i in range(m)]
for i in range(n):
    a = list(input())
    T1[i] = a
for i in range(m):
    a = list(input())
    T2[i] = a

flag = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        l = 0
        if T1[i][j: j + m] == T2[l]:
            k = i
            while k < n - m + 1 and l < m:
                if T1[k][j:j + m] != T2[l]:
                    break
                k += 1
                l += 1
                if l == m:
                    flag = True


if flag:
    print("Yes")
else:
    print("No")

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define MOD 1000000007
typedef pair<li, li> PI;

li b[111];

li res[111];

int main(void)
{
	li n;
	cin >> n;
	rep(i, n - 1) {
		cin >> b[i];
	}

	res[0] = b[0];
	res[n - 1] = b[n - 2];
	rep(i, n - 2) {
		res[i + 1] = min(b[i], b[i + 1]);
	}
	li ans = 0;
	rep(i, n) {
		ans += res[i];
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
ans = []
sets = {}
def dfs(s,keta,mx):
  if keta == n+1:
    ans.append(s)
  else:
    for i in range(mx):
      dfs(s+chr(ord("a")+i),keta+1,max(i+2,mx))

dfs("",1,1)
ans.sort()
print(*ans,sep = "\n")

# data10 = ["aaaaaaaaaa","abcdefghij"]

  


Measured memory_bytes: 65136
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,i,n;
  cin >> n;
  int ans=0;
  for(i=1;i<=n;i++){
    cin >> a;
    if(i%2==1 && a%2==1){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#define N NULL

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};

typedef struct node *Node;


Node root;

void insert(int k){
    Node y = N;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = N;
    z->right = N;
    
    while( x != N ){
        y = x;
        if( z->key < x->key )
            x = x->left;
        else
            x = x->right;
    }
    
    if( y == N )
        root = z;
    else if( z->key < y->key )
        y->left = z;
    else
        y->right = z;
    
}

void inorder(Node u){
    if( u != N ){
        inorder(u->left);
        printf(" %d",u->key);
        inorder(u->right);
    }
}
void preorder(Node u){
    printf(" %d",u->key);
    
    if( u->left != N ) preorder(u->left);
    
    if( u->right != N ) preorder(u->right);
    
    
}

Node treeSearch(Node u, int k){
    while( u != N )
    {
        if( u->key == k ) break;
        if( u->key < k )
            u = u->right;
        else
            u = u->left;
        
    }
    
    return u;
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d",&n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s",com);
        
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        }
        else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if ( com[0] == 'f' ){
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if ( t != N ) printf("yes\n");
            else printf("no\n");
        }
    }
    
    return 0;
}



Measured memory_bytes: 20468
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  while(1){
    ll n,m;
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    V<P> a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
      ll d,p;
      cin>>d>>p;
      sum+=d*p;
      a[i]={p,d};
    } 
    sort(all(a),greater<P>());
    for(int i=0;i<n;i++){
      if(m>=a[i].se){
        sum-=a[i].fi*a[i].se;
        m-=a[i].se;
      }
      else{
        sum-=m*a[i].fi;
        break;
      }
    }
    cout<<sum<<"\n";
  }
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
int main()
{string s,t;
cin>>s>>t;
 int l1,l2,c=0,i;
 l1=s.length();
 l2=t.length();
    if(l2-l1!=1)
        cout<<"No";
    else
    {for(i=0;i<l1;i++)
    {if(s[i]!=t[i])
    {c++;
    break;}}
    if(c==0)
    {
    if(t[l1]>=97 && t[l1]<=122)
        cout<<"Yes";
    else
        cout<<"No";
    }
    else
        cout<<"No";
    }
    return 0;
    }


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
 
#pragma comment(linker, "/STACK:336777216")  
 
using namespace std;
 
const int MAXN = 200000 + 10;

int N, K;
int A[MAXN];

void Work()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i ++)
		scanf("%d", &A[i]);

	map <int, int> S;
	for (int i = 0; i < N; i ++)
		S[A[i]] ++;
	
	int ans = 0;
	vector <int> V;
	for (auto it: S)
		V.push_back(it.second);
	sort(V.begin(), V.end());

	int cnt = V.size();
	for (int i = 0; i < V.size(); i ++)
	{
		if (cnt > K)
		{
			ans += V[i];
			cnt --;
		}
	}

	printf("%d\n", ans);
}
 
int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=1LL<<50;
int n,d[17][17];
ll dp[1<<16],c[1<<16];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) read(d[i][j]);
	for (int t=0;t<(1<<n);t++) {
		for (int i=1;i<=n;i++)
		if (t&(1<<(i-1)))
		for (int j=i+1;j<=n;j++)
		if (t&(1<<(j-1))) c[t]+=d[i][j];
		dp[t]=-INF;
	}
	dp[0]=0;
	for (int t=0;t<(1<<n);t++) {
		for (int s=t;s;s=(s-1)&t) dp[t]=max(dp[t],dp[t-s]+c[s]);
	}
	printf("%lld\n",dp[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main(void){
	int N, A, B;
	do{
		scanf("%d%d%d", &N, &A, &B);
	}while(N < 1 || N > 20 || A < 1 || A > 100 || B < 1 || B > 2000);

	if(N * A <= B)	printf("%d\n", N * A);
	else	printf("%d\n", B);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline void chmax(T& a, T b){if(a<b)a=b;}
template<class T> inline void chmin(T& a, T b){if(a>b)a=b;}
const long long INF = 1LL << 60;

int N;
int a[3100];
bool ischecked[3100][3100] = {false};
long long int dp[3100][3100] = {0};

long long int rec(int L,int R){
  if(L > R) return 0;
  if(ischecked[L][R]) return dp[L][R];
  ischecked[L][R] = true;
  int turn = N - (R - L + 1);
  long long int ret = 0;
  if(turn % 2 == 0){ // 先攻は最大化
    ret = -INF;
    chmax(ret, rec(L+1,R)+a[L]); //左端を取ったら最大か？
    chmax(ret, rec(L,R-1)+a[R]); //右端を取ったら最大か？
  } else { // 後攻は最小化
    ret = INF;
    chmin(ret, rec(L+1,R)-a[L]);
    chmin(ret, rec(L,R-1)-a[R]);
  }
  
  return dp[L][R] = ret;
}
      
      

int main(){
  cin >> N;
  for(int i=0;i<N;++i) cin >> a[i];
  
  cout << rec(0,N-1) << endl;
  return 0;
}

Measured memory_bytes: 84608
n = int(input())
    
P = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    if (P[i-1] < P[i] < P[i+1]) or (P[i-1] > P[i] > P[i+1]):
        cnt += 1
    
print(cnt)

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

bool check(char *s){
  if(s[0]=='A'&&s[1]=='C') return true;
  return false;
}

int N,Q;
char S[1000000];
int l[1000000],r[1000000];
int ac[1000000];
int acnum=0;

int count(int n){
  int lmid=0;
  int rmid=0;
  int l0=l[n];
  int r0=r[n];
  int min=1,max=acnum;
  if(l0<=ac[0]) lmid=1;
  else if(l0>ac[acnum-1]) return 0;
  else{
    while(1){
      if(max-min<=1){
        if(l0==ac[min-1]) lmid=min;
        else              lmid=max;
        break;
      }
      int mid = min+(max-min)/2;
      if(l0==ac[mid-1]){
        lmid=mid;
        break;
      }else if(l0<ac[mid-1]) max=mid;
      else min=mid;
    }
  }

  min=1,max=acnum;
  if(r0<ac[0]+1) return 0;
  else if(r0>=ac[acnum-1]+1) rmid=acnum;
  else{
    while(1){
      if(max-min<=1){
        if(r0==ac[max-1]+1) rmid=max;
        else                rmid=min;
        break;
      }
      int mid = min+(max-min)/2;
      if(r0==ac[mid-1]+1){
        rmid=mid;
        break;
      }else if(r0<ac[mid-1]+1) max=mid;
      else min=mid;
    }
  }

  return rmid-lmid+1;
}

int main(void){
  cin>>N>>Q;
  cin>>S;
  for(uint i=0;i<strlen(S)-1;i++){
    if(check(&S[i])){
      ac[acnum]=i+1;
      acnum++;
      i++;
    }
  }

  for(int i=0;i<Q;i++){
    cin>>l[i]>>r[i];
  }

  for(int i=0;i<Q;i++){
    cout<<count(i)<<endl;
  }
  return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
using namespace std;
int count(int x){
    int i = 1;
    while(x){
        ++i;
        x /= 2;
    }
    return i;
}
int main(){
    int N,K;
    cin >> N >> K;
    if(count(N) < K){
        cout << 0 << endl;
        return 0;
    }
    vector<long long> line(N+1,1);
    long long ans = 0;
    REP(i,K){
        for(int j = N;j>=1;--j){
            for(int k = j * 2;k<=N;k+=j){
                line[k] += line[j];
            }
            if(i+1==K)ans+=line[j];
            line[j] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3540
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>

#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>

#include <memory.h>
#include <cassert>
#include <time.h>
#include <functional>

using namespace std;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;

const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;

#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif

void prepare(string s) {
#ifdef MY_DEBUG
  freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#endif
}

const int NMAX = 100005;

int n;
int a[NMAX];

void read() {
  scanf("%d", &n);
  forn(i, n) {
    scanf("%d", &a[i + 1]);
  }
}

void solve() {
  a[0] = 0;
  a[n + 1] = 0;
  int result = 0;
  int cur = 0;
  forab(i, 1, n) {
    result += abs(cur - a[i]);
    cur = a[i];
  }
  result += abs(a[n]);

  forab(i, 1, n) {
    int cur_result = result;
    cur_result -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
    cur_result += abs(a[i + 1] - a[i - 1]);
    printf("%d\n", cur_result);
  }
}

int main() {
  prepare("");

  read();
  solve();
  dbg("Clock = %.3f\n", clock() / (double)CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 1664
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

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

var sosuu map[int]struct{} = make(map[int]struct{})

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

	pool := make([]int, 101)
	for i := 2; i <= n; i++ {
		ok := true
		for k, _ := range sosuu {
			i2 := i
			var l int
			for i2%k == 0 && i2 > 0 {
				l ++
				i2 /= k
			}
			if l > 0 {
				ok = false
				pool[k] += l
			}
		}
		if ok {
			sosuu[i] = struct{}{}
			pool[i] = 1
		}
	}

	var more3 int
	for i := 2; i <= n; i++ {
		if pool[i] >= 2 {
			more3++
		}
	}

	var more5 int
	for i := 2; i <= n; i++ {
		if pool[i] >= 4 {
			more5++
		}
	}

	var more15 int
	for i := 2; i <= n; i++ {
		if pool[i] >= 14 {
			more15++
		}
	}

	var more25 int
	for i := 2; i <= n; i++ {
		if pool[i] >= 24 {
			more25++
		}
	}

	var more75 int
	for i := 2; i <= n; i++ {
		if pool[i] >= 74 {
			more75++
		}
	}

	//fmt.Println(pool[0:n])
	//fmt.Println("more75", more75)
	//fmt.Println("more25", more25)
	//fmt.Println("more15", more15)
	//fmt.Println("more5", more5)
	//fmt.Println("more3", more3)

	result := 0
	if more5 >= 3 {
		result += more5 * (more5 - 1) * (more5 - 2) / 2
	}
	if more5 >= 2 && more3 >= 3 {
		result += (more3 - more5) * more5 * (more5 - 1) / 2
	}
	if more15 >= 1 && more5 >= 2 {
		result += more15*(more15-1) + more15*(more5-more15)
	}
	if more25 >= 1 && more3 >= 2 {
		result += more25*(more25-1) + more25*(more3-more25)
	}
	if more75 >= 1 {
		result += more75
	}

	fmt.Println(result)
}


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

using namespace std;

int main(){
    int n,m;bool way[9][9] = {false};
    int64_t ans = 0;
    cin >> n >> m;
    vector<int> a(30),b(30);
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        way[a[i]][b[i]] = true;
        way[b[i]][a[i]] = true;
    }
    vector<int> order(n);
    for(int i = 0;i < n;i++)order[i] = i+1;
    do{
        if(order[0] != 1)break;
        bool exist = true;
        for(int i = 1;i < n && exist;i++){
            if(!(way[order[i-1]][order[i]]))exist = false;
        }
        if(exist)ans++;
    }while(next_permutation(order.begin(),order.end()));
    std::cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;

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

  vector<tuple<string, int, int>> p(N);

  string S;
  int P;
  for (int i = 0; i < N; ++i) {
    cin >> S >> P;
    p[i] = make_tuple(S, -P, i);
  }

  sort(p.begin(), p.end());
  for (auto e: p) cout << get<2>(e) + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

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

#define llint long long int

using namespace std;

int main(){
    int X, Y, A, B, C;

    cin >> X >> Y >> A >> B >> C;

    vector<llint> p(A), q(B), r(C);

    for(int i = 0; i < A; i ++){
        cin >> p[i];
    }
    sort(p.begin(), p.end(), greater<llint>());

    for(int i = 0; i < B; i ++){
        cin >> q[i];
    }
    sort(q.begin(), q.end(), greater<llint>());

    for(int i = 0; i < C; i ++){
        cin >> r[i];
    }
    sort(r.begin(), r.end(), greater<llint>());

    vector<llint> eat;

    for(int i = 0; i < X; i ++){
        eat.push_back(p[i]);
    }
    for(int i = 0; i < Y; i ++){
        eat.push_back(q[i]);
    }
    sort(eat.begin(), eat.end());

    int j = 0;

    for(int i = 0; i < X + Y; i ++){
        if(j < C && eat[i] < r[j]){
            eat[i] = r[j];

            j ++;
        }else{
            break;
        }
    }
    llint sum = 0;

    for(int i = 0; i < X + Y; i ++){
        sum += eat[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 4724
dict={'a':input(),'b':input(),'c':input()}
#print(dict)

turn='a'
while True:
   #ループの終了条件
    if len(dict[turn])==0:
        print(turn.upper())
        exit()  
    #次のターンの人の更新
    tem=dict[turn][0]
    dict[turn]=dict[turn][1:]
    turn=tem

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
	cin>>n>>s;
	if(n<3200)
	{
	    cout<<"red";
	}
	else
	{
	    cout<<s<<endl;
	}
	return 0;
}

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

int main(){
	ll r, D, x1;
	cin >> r >> D >> x1;
	vector<ll> res(20);
	res[0] = (r * x1)  - D;
	for(int i = 1; i < 10; i++){
		res[i] = (r * res[i - 1])  - D;
	}
	for(int i = 0;i < 10; i++){
		cout << res[i] << endl;
	}
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {
	
	int n;
	cin >> n;
	VI b(n - 1);
	REP(i, n - 1)cin >> b[i];
	VI a(n);
	a[0] = b[0];
	a[n - 1] = b[n - 2];

	FOR(i,1, n-1) {
		a[i] = min(b[i - 1], b[i]);
	}
	int ans = 0;
	REP(i, n)ans += a[i];
	cout << ans << endl;
	
}

Measured memory_bytes: 256