akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int c = sc.nextInt();
		String s = sc.next();
		int[] mae = new int[k];
		int[] ato = new int[k];
		int count = 0;
		int safe = 0;
		for (int i = 0; i < n; i++) {
			if (i >= safe && s.charAt(i) == 'o') {
				mae[count] = i;
				safe = i + c + 1;
				count++;
			}
			if (count == k) {
				break;
			}
		}
		count = k - 1;
		safe = n - 1;
		for (int i = n - 1; i >= 0; i--) {
			if (i <= safe && s.charAt(i) == 'o') {
				ato[count] = i;
				safe = i - c - 1;
				count--;
			}
			if (count == -1) {
				break;
			}
		}
		for (int i = 0; i < k; i++) {
			if (mae[i] == ato[i]) {
				System.out.println(mae[i] + 1);
			}
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;

    int n = s.length();

    bool ans = true;

    for (int i = 0; i < n; i++)
    {
        if (s[i] != t[i])
        {
            ans = false;
        }
    }

    if (ans)
        cout << "Yes";
    else
        cout << "No";

    cout << "\n";

    return 0;
}

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

using namespace std;

int main() {
	int n;
	int stu[1000];
	double sum, m;

	while (cin >> n, n) {
		sum = 0;
		for (int i = 0; i < n; ++i) {
			cin >> stu[i];
			sum += stu[i];
		}
		m = sum / n;

		sum = 0;
		for (int i = 0; i < n; ++i) {
			sum += pow((stu[i] - m), 2);
		}
		cout << fixed << setprecision(5) << sqrt(sum / n) << endl;
	}

	return 0;
}


Measured memory_bytes: 3292
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int high=0;
	int ans=0;
	for(int i=0;i<n;i++){
		int h;
		cin >> h;
		if(h>=high) ans++;
		high=max(h,high);
	}
	cout << ans << endl;
	return 0;
}


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

vector<int> p(100005);
vector<int> imos(100005);

int main() {
    int N, C; cin >> N >> C;
    vector<multiset<int> > cs(C);
    vector<multiset<int> > ct(C);
    rep(i, N){
        int s, t, c;
        cin >> s >> t >> c;
        c--;
        p[s]++;
        p[t+1]--;
        cs[c].insert(s);
        ct[c].insert(t);
        if(cs[c].find(t) != cs[c].end()){
            p[t]--;
            p[t+1]++;
        }
        if(ct[c].find(s) != ct[c].end()){
            p[s]--;
            p[s+1]++;
        }
    }
    rep(i, 100000){
        imos[i+1] = imos[i] + p[i+1];
    }

    int ans = 0;
    rep(i, 100001){
        ans = max(ans, imos[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13480
import java.util.Scanner;
public class Main {
	static Node r;
	
	@SuppressWarnings("null")
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x;
		String com;
		Node z = null;
		
		for(int i=0; i<n; i++){
			com = sc.next();
			if(com.equals("insert")){
				x = sc.nextInt();
				insert(new Node(x, null, null));
			} else if (com.equals("print")){
				inorder(r);
				System.out.println();
				preorder(r);
				System.out.println();
			}
		}
	}
	
	static void insert(Node z){
		Node y = null;
		Node x = r;
		
		while (x != null){
			y = x;
			if (z.key < x.key){
				x =  x.l;
			} else {
				x = x.r;
			}
		}
		z.p = y;
		
		if (y == null){
			r = z;
		} else {
			if(z.key < y.key){
				y.l = z;
			} else {
				y.r = z;
			}
		}
	}

	static void inorder(Node u){
		if (u == null) return;
		inorder(u.l);
		System.out.print(" " + u.key);
		inorder(u.r);
	}
	static void preorder(Node u) {
		if (u == null) return;
		System.out.print(" " + u.key);
		preorder(u.l);
		preorder(u.r);
	}
}


class Node {
    int key;
    Node p;
	Node l;
	Node r;
    public Node(int key, Node l, Node r) {
    	this.key = key;
        this.l = l;
        this.r = r;
        this.p = p;
    }
}


Measured memory_bytes: 216116
n = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
                
            arr.append(cnt)

    if temp != 1:
        arr.append(1)
        
    if arr==[] and n != 1:
        arr.append(1)

    return arr
  
lst = factorization(n)
ans = 0
if not lst:
  print(ans)
else:
  mx = max(lst)
  for _ in lst:
    for i in range(1, mx+1):
      if _ - i >= 0:
      	_ -= i
      	ans += 1
      else:
      	break
  print(ans)

Measured memory_bytes: 9484
#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 = 2019;
typedef long double ld;
const ll INF = 1e+14;
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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N){
    cin>>A[i];
  }
  
  vector<ll> x(N);
  
  ll ori=A[N-1];
  
  rep(i,N-1){
    if(i%2==0) ori-=A[i];
    else ori+=A[i];
  }
  
  x[N-1]=ori;
  
  per(i, N-1){
    x[i]=2*A[i]-x[i+1];
  }
  
  rep(i,N){
    cout<<x[i]<<" ";
  }
}
    

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main()
{

	int a, b;
	cin >> a >> b;

	a = a % 500;

	if (a <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	
	return 0;
}



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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

void Main() {
    // todo
    string a, b; cin >> a >> b;
    a.append(b);
    int x = stoi(a);
    rep(i, x/2) {
        if (i*i == x) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 


 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll n;
  	cin>>n;
  n*=n;
  cout<<n<<endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;
    S[3] = '8';
    cout << S << endl;

    return 0;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  

vector<int> v;

pair<int, int> f(int l, int r, int curr, vector<vector<pair<int, int>>>& dp)
{
    int n = dp.size();
    if(l > r) return {0, 0};
    pair<int, int> temp = {-1, -1};
    if(dp[l][r] != temp)
        return dp[l][r];
    pair<int,int> first, second;
    first = f(l+1, r, 1-curr, dp);
    second = f(l, r-1, 1-curr, dp);
    if(curr) 
    {
        first.first += v[l];
        second.first += v[r];
    }
    else
    {
        first.second += v[l];
        second.second += v[r];
    }
    if(first.first - first.second > second.first - second.second)
    {
        if(curr)
            dp[l][r] = first;
        else dp[l][r] = second;
    }
    else
    {
        if(curr)
            dp[l][r] = second;
        else dp[l][r] = first;
    }
    return dp[l][r];
}

int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    v.resize(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    vector<vector<pair<int, int>>> dp(n, vector<pair<int, int>>(n, {-1, -1}));
    pair<int,int> temp = f(0, n-1, 1, dp);
    cout << dp[0][n-1].first - dp[0][n-1].second << "\n";

    return 0;
}



Measured memory_bytes: 141312
#include<bits/stdc++.h>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld  double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("birch.in");ofstream cout("birch.out");
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
const ll N=1e6;
const ll R=1e4;
const ll to[7]={1,2,3,1,3,2,1};
ll cnt[N];
signed main(){
    fast_io;
    ll n,x,y;
    cin>>n>>x>>y;
    --x;--y;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
//            cnt[x-i+j-y+1]++;
            ll mn=abs(x-i)+abs(j-y)+1;
            mn=min(mn,j-i);
            cnt[mn]++;
        }
    }
    for(ll i=1;i<n;i++){
        cout<<cnt[i]<<endl;
    }
}


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

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 = 1LL << 60;
const long long mod = 1000000007;

int main(void){
    int n,m;cin >> n >>m;
    vector<int> k(m), p(m);
    vector<vector<int> > s(m);
    for(int i=0;i<m;i++){
	cin >>k[i];
	for(int j=0;j<k[i];j++){
	    int a;cin >> a;
	    s[i].push_back(a);
	}
    }
    for(int i=0;i<m;i++){
	cin >> p[i];
    }
    int ans = 0;
    for(int bit = 0;bit<(1<<n);bit++){
	bool ok = true;
	for(int i=0;i<m;i++){
	    int t=0;
	    for(int j=0;j<k[i];j++){
    		if((1<<(s[i].at(j)-1)) & bit) t++;	
	    }
	    if(t%2 != p[i]) ok = false;
	}
	if(ok) ans++;
    } 
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
 
#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;
 
int main() {
    int n, m;
    cin >> n >> m;
 
    vector<int> a(n, 0);
 
    rep(i, n) {
        cin >> a[i];
    }
 
    double votes_num = accumulate(a.begin(), a.end(), 0);
    double th_value = votes_num / (4 * m);
 
    int count = 0;
    for(int i = 0; i < n; i++) {
        if( a[i] >= th_value ) {
            count++;
        } 
    }
 
    if(count >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
vert = [1]*(n)
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] > h[b-1]:
        vert[b-1] = 0
    elif h[a-1] < h[b-1]:
        vert[a-1] = 0
    elif h[a-1] == h[b-1]:
        vert[a-1] = 0
        vert[b-1] = 0
print(sum(vert))
# ab = [list(map(int,input().split())) for i in range(m)]


Measured memory_bytes: 20140
import sys
row = sys.stdin.readline
def read_int(row):
    return int(row().rstrip())
def read_strings(row):
    return list(map(str, row().split()))
N = read_int(row)
S,T= read_strings(row)
 
for i in range(N):
    print(S[i],T[i], sep = "", end="")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 100005
ll inf = 1e14;
int mod = 998244353;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll dp[N];
ll arr[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(dp, 0, sizeof(dp));
  dp[1] = 0;

  ll n, k;
  cin >> n >> k;
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  dp[2] = dp[1] + abs1(arr[2] - arr[1]);
  for (ll i = 3; i <= n; i++) {
    dp[i] = inf;
    for (ll j = max(i - k, 1ll); j < i; j++)
      dp[i] = min(dp[i], dp[j] + abs1(arr[i] - arr[j]));
  }

  cout << dp[n] << en;
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var s = ReadLine();
            var N = s.Length;
            var K = Sarray()[0];
            var mins = new List<char>();
            IEnumerable<char> enu = s.Where(_ => true);
            for (var i = 0; i < 5; ++i)
            {
                if (enu.Count() == 0)
                    break;
                var min = enu.Min();
                mins.Add(min);
                enu = enu.Where(w => w != min);
            }
            var hs = new HashSet<string>();
            foreach (var m in mins)
            {
                for (var i = 0; i < N; ++i)
                {
                    if (s[i] == m)
                    {
                        var num = 5;
                        num = Min(num, N - i);
                        var t = s.Substring(i, num);
                        for (var j = 0; j < t.Length; ++j)
                        {
                            var ss = t.Substring(0, j + 1);
                            hs.Add(ss);
                        }
                    }
                }
                if (K <= hs.Count())
                    break;
            }
            var kouho = new List<string>();
            foreach (var h in hs)
                kouho.Add(h);
            kouho.Sort(StringComparer.OrdinalIgnoreCase);
            WriteLine(kouho[(int)K - 1]);
            //Out.Flush();
        }
    }
}

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

const int MAX_N = 300;
int N;
ll A[MAX_N+5][MAX_N+5], d[MAX_N+5][MAX_N+5];

void warshall_floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            ll a; cin >> a;
            A[i][j] = d[i][j] = a;
        }
    }

    warshall_floyd();

    ll ans = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(A[i][j] != d[i][j]){
                cout << -1 << endl;
                return 0;
            }

            bool flg = true;
            for(int k=0;k<N;k++){
                if(i == k || j == k) continue;
                if(A[i][k]+A[k][j] == A[i][j]) flg = false;
            }

            if(flg) ans += A[i][j];
        }
    }

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

Measured memory_bytes: 1664
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		String s=sc.next();
		int k=sc.nextInt();
		int l=s.length();
		char[] c=s.toCharArray();
		
		String list[]=new String[l*k];
		for(int i=0;i<l*k;i++) {
			list[i]="zzzzz";
		}
		for(int i=1;i<=k;i++) {
			for(int j=0;j<=l-i;j++) {
				list[j+(i-1)*l]=s.substring(j, j+i);
			}
		}
		
		Arrays.sort(list);
		int count=0;
		String S="zzzzzz";
		for(int i=0;i<list.length;i++) {
			if(S.equals(list[i])) {
				continue;
			}
			else {
				S=list[i];
				count++;
				if(count==k) {
					System.out.println(S);
					return;
				}
			}
		}
		
	}
	

}


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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    rep(i,1,6)
    {
        int x;
        cin>>x;
        if(x==0)
        {
            cout<<i;
            break;
        }
    }
return 0;
}

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

#define TASK ""
#define openfile ({freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);})

int n, m, k;

int main() {
	// openfile
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if (i * m + j * n - 2 * i * j == k) return cout << "Yes", 0;
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

a = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
a = a.split(',')

k = int(input())

print(a[k-1])

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string s, t;
	cin>>s>>t;
	int flag=0;
	
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]){
			flag=1;
		}
	}
	if(flag==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	// your code goes here
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i) >> t.at(i);
  }
  string x;
  cin >> x;
  int k,ans = 0;
  for(int i=0;i<n;i++){
    if(s.at(i) == x) k=i;
  }
  for(int i=k+1;i<n;i++){
    ans += t.at(i);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# 2019/08/11

from collections import Counter

n=int(input())
a=list(map(int,input().split()))

c=Counter(a)

if c.most_common(1)[0][1]>2 or c[0]>1:
    print(0)
    exit()

for k,v in c.items():
    if k!=0 and v!=2:
        print(0)
        exit()
    if n%2==k%2:
        print(0)
        exit()
        
print(2**(n//2)%(10**9+7))

Measured memory_bytes: 14820
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define parity(n)               __builtin_parity(n)
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define endl                    "\n"
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;

ll MAX_PRIME_DIV(ll n)
{
    ll maxi=INT_MIN;
    for (ll i=2;i*i<=n;i++)
    {
        if (n%i==0)maxi=max(maxi,i);
    }
    if (maxi==INT_MIN)return INT_MIN;
    return maxi;
}
void solve()
{
   ll n;
   cin>>n;
   ll a=MAX_PRIME_DIV(n);
   if (a==INT_MIN)
   {
       cout<<n-1<<endl;
       return;
   }
   ll b=n/a;
   cout<<a-1+b-1<<endl;
}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}




Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b,c,i,ans[3],min;
	scanf("%d%d%d",&a,&b,&c);
	ans[0]=a+b;
	ans[1]=b+c;
	ans[2]=a+c;
	min=ans[0];
	for(i=0;i<3;i++)
		if(ans[i]<min)
			min=ans[i];
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

float inf = std::numeric_limits<float>::infinity();
ll mod = 1e9+7;

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int max(int &a,int &b){if(a>b){return a;}else{return b;}}
int min(int &a,int &b){if(a>b){return b;}else{return a;}}

int ar_max(vector<int> &v){
  int max_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]>max_val){max_val=v[i];}
  }
  return max_val;
}

int ar_min(vector<int> &v){
  int min_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]<min_val){min_val=v[i];}
  }
  return min_val;
}


/* Binary Search(v,N,flag)
  flag = true -> return ind(int) 挿入index
  flag = false -> return in(0or1) 入ってるかどうか*/
int b_search(vector<int> &v, int &N, bool flag=true){
  sort(v.begin(),v.end());
  int left=0,right=v.size()-1,ind;
  if (N < v[left]){return 0;}
  if (N > v[right]){return right+1;}
  while(true){
    ind = (left+right)/2;
    if (v[ind]>N){right = ind;}
    else if(v[ind]<N){left = ind;}
    else if(v[ind]==N){
      if(flag){return ind;}
      else{return 1;}
    }

    /* 終了判定*/
    if (right-left<=1){
      if(flag){
        if(v[left]==N){
          return left;
        }else{
          return right;
        }
      }else{
        if(v[left]==N || v[right]==N){return 1;}
        else{return 0;}
      }
    }
  }
}



/*素因数分解(N) ex:N=90(=2*3^2*5)
prime_tb = [2,3,5]
ans_tb = [[2,1][3,2][5,1]]*/
vector<vector<int>> prime_factor(int &N){
  vector<int> prime_tb;
  vector<vector<int>> ans_tb;
  int max_pr=0,prime=2,ind;
  while (N>=2){
    if (N%prime==0){
      if(max_pr>=prime){/*既に出た素因数*/
        ind = b_search(prime_tb,prime);
        ans_tb[ind][1]++;
      }else if(max_pr<N){/*初めて素因数*/
        ind = prime_tb.size();
        ans_tb.push_back({prime,1});
        prime_tb.push_back(prime);
        max_pr = prime;
      }
      N /= prime;
      prime = 2;
    }else{
      prime ++;
    }
  }
  return ans_tb;
}

/*約数の数*/
int divsor_num(int &N){
  vector<vector<int>> pf_tb;
  int ans=1;
  pf_tb = prime_factor(N);
  for (size_t i = 0; i < pf_tb.size(); i++) {
    ans *= pf_tb[i][1]+1;
  }
  return ans;
}

int main(void) {
  int K,S;
  ll ans=0;
  cin >> K >> S;
  REP(x,K+1){
    REP(y,K+1){
      if (0<=S-x-y and S-x-y<=K){
        ans ++;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (C >= A && C <= B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

int main(){
  string s,t,kekka = "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{";
  string cur = "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{";
  cin >> s >> t;
  int n = s.size(),m = t.size();
  for(int i = 0;i < n - m + 1;i++){
    int hantei = 0;
    for(int j = 0;j < m;j++){
      if(s.at(i+j) == t.at(j) || s.at(i+j) == '?'){
        hantei++;
      }
    }
    if(hantei == m){
      for(int k = 0;k < n;k++){
        if((k < i || k >= i + m) && s.at(k) == '?'){
          cur.at(k) = 'a';
        }
        else if(k < i || k >= i + m){
          cur.at(k) = s.at(k);
        }
        else{
          cur.at(k) = t.at(k-i);
        }
      }
      if(cur < kekka){
        kekka = cur;
      }
    }
  }
  if(kekka != "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{"){
    for(int i = 0;i < n;i++){
      cout << kekka.at(i);
    }
    cout << " " << endl;
  }
  else{
    cout << "UNRESTORABLE" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
rec = 0
ind = 0
mi = False
for i in range(N):
    if A[i] < 0 and abs(A[i]) > rec:
        rec = abs(A[i])
        ind = i
        mi = True
    elif A[i] > 0 and A[i] > rec:
        rec = A[i]
        ind = i
        mi = False

ans = []
if mi:
    for i in range(N):
        ans.append((ind + 1, i + 1))
    for i in range(N - 1, 0, -1):
        ans.append((i + 1, i))
else:
    for i in range(N):
        ans.append((ind + 1, i + 1))
    for i in range(1, N):
        ans.append((i, i + 1))

print(len(ans))
for i in ans:
    print(i[0], i[1])


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
    
    int n;
    int* a;
    bool ans= true;
    cin >> n;
    a = new int [n];
    
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int j=0;j<n;j++){
        if(a[j]%2!=0) continue;
        else{
            if(a[j]%3==0)continue;
            else if(a[j]%5==0)continue;
            else ans=false;
        }
    }
    if(ans==true) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    
    delete[] a;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static long mod = 1000000007;
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	long N = s.nextLong();
	long result = 1;
	long src = 1;
	for(int i = 0; i < N; i++){
		result = (result*10)%mod;
		src = (src*9)%mod;
	}
	result = (((result-src)%mod)*2)%mod;


	long result2 = 1;
	long src2 = 1;
	for(int i = 0; i < N; i++){
		result2 = (result2*10)%mod;
		src2 = (src2*8)%mod;
	}
	result2 = (result2-src2)%mod;
	result = (result-result2)%mod;

	if(result<0){
		System.out.println(result%mod+mod);
	}else{
		System.out.println(result%mod);
	}
	
    
  }
}

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

#define int int64_t
#define double long double

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

//using VV = vector<vector<int>>;
//using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
using T = tuple<int, int, int>;

double dist(T& a, T& b) {
	int xa, xb, ya, yb, ra, rb;
	tie(xa, ya, ra) = a;
	tie(xb, yb, rb) = b;
	return max((double)0, hypotl(xa - xb, ya - yb) - (double)ra - (double)rb);
}

double cost[1002][1002];
double d[1002];
int V;
bool used[1002];

void dijkstra(int s) {
	fill(d, d + V, 1e50);
	d[s] = 0;

	while (true) {
		int v = -1;
		rep(u, V) {
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		}
		if (v == -1) break;
		used[v] = true;
		rep(u, V) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}
	}
}

signed main() {
	int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
	int n; cin >> n;
	vector<T> v(n + 2);
	rep(i, n) {
		int x, y, r; cin >> x >> y >> r;
		v[i + 1] = T(x, y, r);
	}
	v[0] = T(xs, ys, 0);
	v[n + 1] = T(xt, yt, 0);
	V = n + 2;
	rep(i, V) rep(j, V) {
		T a = v[i], b = v[j];
		cost[i][j] = cost[j][i] = dist(a, b);
	}
	dijkstra(0);
	printf("%.11Lf\n", d[V - 1]);
	system("pause");
}

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

using namespace std;
using ll = long long;

const int N = 3000 + 1;

int n;
ll a[ N ], DP[ N ][ N ][ 2 ];

ll dfs(int l = 1, int r = n, int turn = 0) {
    if( l > r ) return 0LL;
    ll &ret = DP[ l ][ r ][ turn ];
    if( ~ret ) return ret;

    if( turn == 0 ) {
        ret = -4e18;
        ret = max(ret, a[ l ] + dfs(l + 1, r, turn ^ 1));
        ret = max(ret, a[ r ] + dfs(l, r - 1, turn ^ 1));
    } else {
        ret = 4e18;
        ret = min(ret, -a[ l ] + dfs(l + 1, r, turn ^ 1));
        ret = min(ret, -a[ r ] + dfs(l, r - 1, turn ^ 1));
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    memset(DP, -1, sizeof DP);
    cout << dfs() << '\n';

    return 0;
}


Measured memory_bytes: 141184
num = int(input())
list = [int(item) for item in input().split()]
 
order = dict(zip(range(1,num+1), list))
p_order = sorted(order.items(), key=lambda x:x[1])
 
 
 
for i in [item[0] for item in p_order]:
    print(str(i) + ' ', end='')

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

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

int main()
{
    /*
       8 3
       ACACTACG
       v v  v
       11222333
       012344566
       3 7
       2 3
       1 8
    */

    int n, q;
    scanf("%d %d", &n, &q);

    char inp[n + 3];
    scanf("%s", inp);

    int dp[n + 1];
    dp[0] = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (i + 1 < n && inp[i] == 'A' && inp[i + 1] == 'C')
            dp[i + 1] = ++cnt, dp[i + 2] = ++cnt, i++;
        else
            dp[i + 1] = cnt;
    }

    for (int i = 0; i <= n; i++) {
        // printf("%d %d\n", i, dp[i]);
    }

    for (int i = 0; i < q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);

        if (inp[l - 1] == 'C')
            l++;
        if (inp[r - 1] == 'A')
            r--;

        if (l <= r)
            printf("%d\n", (dp[r] - dp[l - 1]) / 2);
        else
            printf("0\n");
    }

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{

  int eight,ten;
  cin>>eight>>ten;
  
  float en_min8 = eight/0.08f;
  float en_max8 = (eight+1)/0.08f;
  float en_min10 = ten/0.1f;
  float en_max10 = (ten+1)/0.1f;
  
  if(en_min8>= en_min10&&en_min8<en_max10)
  {
    if(en_min8 > (int)en_min8)
      en_min8 +=1;
    cout<<(int)en_min8<<endl;
    return 0;
  }
  
  else if(en_min10>= en_min8&&en_min10<en_max8)
  {
        if(en_min10 > (int)en_min10)
      en_min10 +=1;
    cout<<(int)en_min10<<endl;
    return 0;
  }
  
  cout<< -1<<endl;
  return 0;
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

signed main() {
	int N, K;
	cin >> N >> K;
	vector<int>H(N);
	rep(i, N) {
		cin >> H[i];
	}
	vector<int>dp(N,INF);
	rep(i, N) {
		if (i == 0) {
			dp[i] = 0;
		}
		else {
			for (int j = 1; j <= K; j++) {
				if (i - j >= 0) {
					dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]));
				}
			}
		}
	}
	cout << dp[N - 1] << enld;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define rank afsdlkfjaslf
using namespace std;
#define int long long

class TSort{
 public:
  int V;
  vector<set<int> > in,out;
  vector<int> sorted;
  vector<int> rank;
  TSort(){V = 0;};
  TSort(int V){
    in.resize(V);
    out.resize(V);
    rank.resize(V);
    this->V = V;
  }

  void add_edge(int from,int to){
    out[from].insert(to);
    in[to].insert(from);
  }

  void sort(){
    sorted.clear();
    queue<int> Q;
    for(int i=0;i<V;i++) if(in[i].empty()) Q.push(i);

    while(!Q.empty()){
      int v = Q.front();Q.pop();
      sorted.push_back(v);
      for(int nx:out[v]){
	if(in[nx].size() == 1) Q.push(nx);
	in[nx].erase(v);
      }
    }
    for(int i=0;i<V;i++) rank[sorted[i]] = i;
    for(int i=0;i<V;i++) assert(in[i].empty());
  }
};

TSort T;
struct dat{int to,cost1,cost2;};
vector<dat> G[1010];  
int n;
int mem[1010][1010],used[1010][1010];

int dfs(int pos1,int pos2){
  if(T.rank[pos1] > T.rank[pos2]) swap(pos1,pos2);
  if(pos1 == n-1 && pos2 == n-1) return 0;
  if(used[pos1][pos2]++) return mem[pos1][pos2];
  
  int res = 1LL<<50;
  if(pos1 == pos2){
    for(dat nx1:G[pos1])
      for(dat nx2:G[pos1]){
	int cost;
	if(nx1.to == nx2.to) cost  = nx1.cost1 + nx1.cost2;
	else cost = nx1.cost1 + nx2.cost1;
	res = min(res,cost+dfs(nx1.to,nx2.to));
      }    
  }
  else {
    for(dat nx1:G[pos1]){
      int cost = nx1.cost1;
      res = min(res,cost+dfs(nx1.to,pos2));
    }
  }
  return mem[pos1][pos2] = res;
}


signed main(){
  int m;
  cin>>n>>m;
  T = TSort(n);
  for(int i=0,from,to,cost1,cost2;i<m;i++){
    cin>>from>>to>>cost1>>cost2;
    from--,to--;
    T.add_edge(from,to);
    G[from].push_back((dat){to,cost1,cost2});
  }
  T.sort();
  cout<<dfs(0,0)<<endl;
  
  return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  ll N; ll X;
  cin >> N >> X ;
  vl a(N+1);
  vl b(N+1);
  a[0] = 1;
  b[0] = 1;
  rep(i,N) a[i+1] = 2*a[i]+3;
  rep(i,N) b[i+1] = 2*b[i]+1;
  dump(a);
  map<Pl,ll> memo;
  function<ll(ll,ll)> f = [&](ll n,ll x){
    dump(n,x);
    if(n==0) return 1LL;
    if(x==1LL||x==0LL) return 0LL;
    if(x<=a[n]/2LL) return f(n-1,x-1);
    else if(x==a[n]/2LL+1LL) return b[n-1]+1;
    else return b[n-1]+1+f(n-1,x-a[n-1]-2);
  };
  cout << f(N,X) << endl;
  // dump(memo);
}

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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// cout<<fixed<<setprecision(10);
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    ll n; cin >> n;
    ll x = sqrt(n);
    for(ll i = x; i>=i; i--){
        if(n % i == 0){
            x = i;
            break;
        }
    }
    cout << ((x-1) + (n/x-1)) << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a < b){
			System.out.println("a < b");
		} else if(a == b) {
			System.out.println("a == b");
		} else {
			System.out.println("a > b");
		}
	}
}




Measured memory_bytes: 26136
N = int(input())
 
if (0 <= N) and (N <105):
  print(0)
elif (105 <= N) and (N < 135):
  print(1)
elif (135 <= N) and (N < 165):
  print(2)
elif (165 <= N) and (N < 189):
  print(3)
elif (189 <= N) and (N < 195):
  print(4)
else:
  print(5)

Measured memory_bytes: 3060