akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int M, D;
	cin >> M >> D;
	int a, ans = 0;
	for (int i = 10; i <= D; i++) {
		a = 0;
		if (i % 10 > 1 && i / 10 > 1) {
			a = (i % 10) * (i / 10);
		}
		if (a <= M && a > 0) {
			ans++;
		}
	}
	cout << ans;*/


	ll N, K;
	cin >> N >> K;
	vector<ll>a(N);
	rep(i, N)cin >> a[i];
	ll ans = 0;
	vector<pair<ll, ll>>x(N);
	rep(i, N) {
		for (int j = 0; j < N; j++) {
			if (a[i] > a[j]) {
				if (i < j)x[i].second++;
				else x[i].first++;
			}
		}
	}
	ll p = K * (K + 1) / 2;
	p %= 1000000007;
	ll m = K * (K - 1) / 2;
	m %= 1000000007;
	rep(i, N) {
		ans += x[i].second * p;
		ans %= 1000000007;
		ans+= x[i].first * m;
		ans %= 1000000007;
	}
	cout << ans;


	/*int N;
	string S;
	cin >> N >> S;*/


	return 0;
}

Measured memory_bytes: 256
import math
N , D = (map(int , input().split()))
x = []
ans = 0
for i in range(N):
    x.append(list((map(int , input().split()))))
for i in range(len(x)):
    for j in range(len(x)):
        ans_ = 0
        if i >= j:
            continue
        for k in range(D):
            ans_ += (x[i][k] - x[j][k])**2
        if math.sqrt(ans_).is_integer():
            ans += 1
print(ans)

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

# スペース区切りの文字列の入力
st = input().split()

for i in range(1001):
  #切り捨て
  a = int(i * 0.08)
  b = int(i * 0.1)
  if(a == int(st[0]) and b == int(st[1])):
    print(i)
    break;
  elif(i == 1000):
    print('-1')


Measured memory_bytes: 3064
from functools import reduce

N, M = map(int, input().split())
a = list(map(int, input().split()))


def f(x):
    c = 0
    while x % 2 == 0:
        x //= 2
        c += 1
    return c


def gcd(x, y):
    return gcd(y, x % y) if y != 0 else x


nth = [f(ai) for ai in a]
if len(set(nth)) == 1:
    half_a = [ai >> 1 for ai in a]
    L = reduce(lambda x, y: x * y // gcd(x, y), half_a)
    ans = (M - L) // (2 * L) + 1 if M >= L else 0
else:
    ans = 0
print(ans)


Measured memory_bytes: 14748
<?php

while (TRUE) {
    $field = array();
    for ($i = 0; $i < 8; $i++) {
        $field[] = str_split(rtrim(fgets(STDIN)));
    }
    if (feof(STDIN)) {
        break;
    }

    for ($i = 0; $i < 8; $i++) {
        for ($j = 0; $j < 8; $j++) {
            if ($field[$i][$j] === '1') {
                break 2;
            }
        }
    }

    $f = 'A';
    if (isset($field[$i + 3][$j]) && $field[$i + 3][$j] === '1') {
        $f = 'B';
    } elseif (isset($field[$i][$j + 3]) && $field[$i][$j + 3] === '1') {
        $f = 'C';
    } elseif (isset($field[$i + 2][$j - 1]) && $field[$i + 2][$j - 1] === '1') {
        $f = 'D';
    } elseif (isset($field[$i + 1][$j + 2]) && $field[$i + 1][$j + 2] === '1') {
        $f = 'E';
    } elseif (isset($field[$i + 2][$j + 1]) && $field[$i + 2][$j + 1] === '1') {
        $f = 'F';
    } elseif (isset($field[$i + 1][$j - 1]) && $field[$i + 1][$j - 1]) {
        $f = 'G';
    }

    echo $f . PHP_EOL;
    fscanf(STDIN, '');
}

Measured memory_bytes: 6656
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
const int INF=100100100;

int main(){
    int n,m;
    int a[1010]     = {};
    int b[1010]     = {};
    int c[1010]     = {};
    vector<int> dp(1<<13,INF);
    dp[0] = 0;
    cin >> n >> m;
    rep(i,m){
        cin >> a[i] >> b[i];
        rep(j,b[i]){
            int t;
            cin >> t;
            t-=1;
            c[i] |= (1<<t);
        }
    }
    rep(i,m){
        rep(j,1<<n){
            dp[j|c[i]] = min(dp[j|c[i]],dp[j]+a[i]);
        }
    }
    if(dp[(1<<n)-1] == INF) cout << -1 << endl;
    else   cout << dp[(1<<n)-1] << endl;
    return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n + 2, 0);
    while(q--){
        int pos;
        cin >> pos;
        a[1]++;
        a[pos]--;
        a[pos + 1]++;
        a[n + 1]--;
    }
    for(int i = 1; i <= n; i++){
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= n; i++){
        if(k - a[i] <= 0){
            cout << "No" << nl;
        }else{
            cout << "Yes" << nl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
fn run() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim().parse().unwrap()
    };
    let mut ans = 0;
    for i in 1..(n + 1) {
        ans += i.to_string().len() & 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            C();
        }

        static void C()
        {
            var ABCD = ToIntArray(Read());
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];

            if (A + B + C + D == 7) Println($"{A}+{B}+{C}+{D}=7");
            else if (A + B + C - D == 7) Println($"{A}+{B}+{C}-{D}=7");
            else if (A + B - C - D == 7) Println($"{A}+{B}-{C}-{D}=7");
            else if (A - B - C - D == 7) Println($"{A}-{B}-{C}-{D}=7");
            else if (A - B + C - D == 7) Println($"{A}-{B}+{C}-{D}=7");
            else if (A - B + C + D == 7) Println($"{A}-{B}+{C}+{D}=7");
            else if (A - B - C + D == 7) Println($"{A}-{B}-{C}+{D}=7");
            else if (A + B - C + D == 7) Println($"{A}+{B}-{C}+{D}=7");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13396
from fractions import gcd
n,m = map(int, input().split())
s = input()
t = input()
# Xの長さLはnとmで割り切れる
# Xの1, L/n + 1, ..., (n-1) * L/n + 1 番目の文字をつなげるとSになる
# Xの1, L/m + 1, ..., (m-1) * L/m + 1 番目の文字をつなげるとTになる

ans = -1
if n==m:
    if s==t: ans= n
else:
    gcd_nm = gcd(n,m)
    for i in range(gcd_nm):
        if s[n//gcd_nm*i] != t[m//gcd_nm*i]: break
    else: ans = n*m//gcd_nm
print(ans)

Measured memory_bytes: 5432
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

const int N = 100 * 1000 + 5;
vector <int> id(N), sz(N);
vector <int> vx[N], vy[N];
set <int> stx[N], sty[N];
void init()
{
	for (int i = 0; i < N; i++)
	{
		id[i] = i;
		sz[i] = 1;
	}
}
int root(int x)
{
	return id[x] = (x == id[x] ? x : root(id[x]));
}
void union1(int x, int y)
{
	int p = root(x);
	int q = root(y);
	id[p] = q;
	sz[q] += sz[p];
}
int main()
{
	init();
	int n;
	cin >> n;
	vector <pair<int, int>> v(n + 1);
	vector <bool> visx(N), visy(N);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i].ff >> v[i].ss;
		vx[v[i].ff].push_back(i);
		vy[v[i].ss].push_back(i);
	}
	for (int i = 1; i <= n; i++)
	{
		if(!visx[v[i].ff])
		{
			for (auto g : vx[v[i].ff])
			{
				if(root(i) != root(g))
				{
					union1(i, g);
				}
			}
			visx[v[i].ff] = true;
		}
		if(!visy[v[i].ss])
		{
			for (auto g : vy[v[i].ss])
			{
				if(root(i) != root(g))
				{
					union1(i, g);
				}
			}
			visy[v[i].ss] = true;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		stx[root(i)].insert(v[i].ff);
		sty[root(i)].insert(v[i].ss);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		if(root(i) == i)
		{
			if((int) stx[i].size() > 1 || (int) sty[i].size() > 1)
				ans += 1LL * (int) stx[i].size() * (int) sty[i].size() - sz[i];
		}
	}
	cout << ans;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(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;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};


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

int main(){
  int H,N; cin >> H >> N;
  vi a(N);
  rep(i, N) cin >> a[i];
  int sum = 0;
  rep(i,N) sum += a[i];
  cout << (sum >= H ? "Yes" : "No") << endl;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll n; cin >> n;

    ll m = 0;
    ll dig;
    rep(i, 12){
        m += pow(26, i);
        if(m>n){
            dig = i;
            m -= pow(26, i);
            break;
        }
    }

    ll ans = n-m;
    rep(i, dig){
        cout << (char)('a'+((ll)(ans/pow(26, dig-i-1))%26));
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4008
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
def m():
    ans = 0
    time = 0
    while time < N:
        high = T[time] + K
        for i in range(C):
            if time >= N:
                break
            if T[time] <= high:
                time += 1
            else:
                break
        ans += 1
    return ans
print(m())

Measured memory_bytes: 7384
def shrinking():
	s = list(raw_input())
	ans = []
	possible_chars = list(set(s))

	for ch in possible_chars:
		a = 0
		# copy the list, very important
		_s = list(s)
		while len(list(set(_s)))!=1:
			for i in range(1, len(_s)):
				if _s[i] == ch:
					_s[i - 1] = ch
			a+=1
			_s = _s[:-1]
		ans.append(a)
	print min(ans)


if __name__ == "__main__":
	shrinking()

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

int main(){
    int n;
    while(cin >> n, n){
        bool field[110][110];
        memset(field, false, sizeof(field));
        int w, h;
        cin >> w >> h;
        for(int i=0; i < n; i++){
            int x, y;
            cin >> x >> y;
            field[--x][--y] = true;
        }
        int s, t;
        cin >> s >> t;

        pair<int, int> ans;
        int mcount = 0;
        for(int i=0; i < w-s+1; i++){
            for(int j=0; j < h-t+1; j++){
                int count = 0;
                for(int k=0; k < s; k++){
                    for(int l=0; l < t; l++){
                        if(field[i+k][j+l]) count++;
                    }
                }
                if(mcount < count){mcount = count; ans = make_pair(i, j);}
            }
        }
        cout << mcount << endl;
    }
}

Measured memory_bytes: 1176
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long
#define edge pair<int,int>
#define x first
#define v second

const int N=1e5+5;
int st[N][20],n,m,f[N];
vector<edge> g[N];

void update(int x){
	st[x][0]=f[x];
	for(int i=1;x>(1<<i-1);i++) st[x][i]=min(st[x][i-1],st[x-(1<<i-1)][i-1]);
}

int que(int l,int r){
	int k=log2(r-l+1);
	return min(st[r][k],st[l+(1<<k)-1][k]);
}


signed main(){
	read(n,m);
	for(int i=1,x,y,v;i<=m;i++){
		read(x,y,v);
		g[y].emplace_back(x,v);
	}
	for(int i=2;i<=n;i++){
		update(i-1);
		f[i]=1e15;
		for(auto e:g[i]) f[i]=min(f[i],e.v+que(e.x,i-1));
	}
	if(f[n]==1e15) f[n]=-1;
	write(f[n]);
}

Measured memory_bytes: 25048
a,b,m=gets.split.map(&:to_i)
a_p=gets.split.map(&:to_i)
b_p=gets.split.map(&:to_i)
x=Array.new(m)
y=Array.new(m)
c=Array.new(m)
m.times do |i|
    x[i],y[i],c[i]=gets.split.map(&:to_i)
end

ans=a_p.min+b_p.min
m.times do |i|
    ans=[ans,a_p[x[i]-1]+b_p[y[i]-1]-c[i]].min
end
puts ans


Measured memory_bytes: 26284
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///

const int  maX=1e5+10;
int a[2005];
int main()
{
    ll n,k;
    sff(n,k);
    ll ara[n];
    ll dp[maX];
    for(ll i=0;i<n;i++)dp[i]=infinity;
    dp[0]=0;
    for(ll i=0;i<n;i++){
        sf(ara[i]);
        for(ll j=1;j<=k;j++){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(ara[i]-ara[i-j]));
            }
        }
    }
    pfn(dp[n-1]);

return 0;
}


Measured memory_bytes: 5340
#include <bits/stdc++.h>
using namespace std;
#define maxn 405
#define maxm 100500
int n, m, x[maxm], y[maxm], mark[maxn];
int ans, S[maxn][maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

int main()
{
	n = read(), m = read();
	for(int i = 1; i <= m; i ++) x[i] = read(), y[i] = read();
	for(int i = 1; i <= n; i ++)
	{
		memset(mark, 0, sizeof(mark)); 
		mark[i] = 1; S[i][++ S[i][0]] = i;
		for(int j = m; j >= 1; j --)
		{
			if(mark[x[j]] && mark[y[j]]) { S[i][0] = -1; break; }
			if(mark[x[j]]) mark[y[j]] = 1;
			else if(mark[y[j]]) mark[x[j]] = 1;
		}
		if(S[i][0] == -1) continue;
		for(int j = 1; j <= n; j ++)
			if(mark[j]) S[i][0] ++, S[i][S[i][0]] = j;
	}
	
	for(int i = 1; i <= n; i ++)
		for(int j = i + 1; j <= n; j ++)
		{
			if(S[i][0] == -1 || S[j][0] == -1) continue;
			memset(mark, 0, sizeof(mark)); bool flag = 1;
			for(int k = 1; k <= S[i][0]; k ++) mark[S[i][k]] = 1;
			for(int k = 1; k <= S[j][0]; k ++) 
				if(mark[S[j][k]]) { flag = 0; break; }
			if(flag) ans ++;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
//static const int INFTY = (1<<20);


//ABC149_c
int main() {
	int n;
	cin >> n;

	bool flg = true;
	while(flg) {
		int a = sqrt(n);
		if (a==1) flg = false;
		for (int i=a; i>1; i--) {
			if (n%i == 0) break;
			if (i==2) flg = false;
		}
		n++;
	}
	cout << n-1 << endl;
}

Measured memory_bytes: 256
c=[list(map(int,input().split())) for i in range(3)]
x=c[0][2]-c[0][1]
y=c[0][1]-c[0][0]
for i in range(1,3):
    if c[i][1]-c[i][0]!=y:
        print("No")
        break
    if c[i][2]-c[i][1]!=x:
        print("No")
        break
else:
    print("Yes")


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

int main(void) {
  string s;
  int K;
  cin >> s >> K;
  int N = s.length();
  set<string> substrings;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i + j - 1 > N - 1) break;
      substrings.insert(s.substr(i, j));
    }
  }
  auto itr = substrings.begin();
  for (int i = 0; i < K - 1; i++) {
    itr++;
  }
  cout << (*itr) << endl;

  return 0;
}

Measured memory_bytes: 1664
# https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_1_A
import sys
from functools import reduce


def to_str(x, y):
    return str(x) + ' ' + str(y)


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

count = 0
flag = 1
while flag:
    flag = 0
    for j in range(n):
        if j <= n - 2 and A[j] > A[j + 1]:
            tmp = A[j + 1]
            A[j + 1] = A[j]
            A[j] = tmp
            count += 1
            flag = 1

print(reduce(to_str, A))
print(count)



Measured memory_bytes: 6284
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  u64 tn = 1, an = 1;
  for (int i = 0; i < n; ++i) {
    int t, a;
    cin >> t >> a;
    u64 amp = max((tn-1)/t, (an-1)/a)+1;
    tn = t*amp;
    an = a*amp;
  }
  cout << tn + an << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())

ans = 0
ans += min(x,y)*min(a+b,2*c)
if y > x:
  ans += (y-x)*min(b,c*2)
if x > y:
  ans += (x-y)*min(a,c*2)
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
        int N; cin >> N;
        if (N==0) break;
        int W,H; cin >> W >> H;
        vector<vector<int>> A(H+1, vector<int>(W+1));
        rep(i,N) {
            int x,y; cin >> x >> y;
            A[y][x]++;
        }
        int S,T; cin >> S >> T;

        rep(i,H+1) rep(j,W) A[i][j+1] += A[i][j];
        rep(j,W+1) rep(i,H) A[i+1][j] += A[i][j];

        int ans = 0;
        for (int i = T; i <= H; i++) {
            for (int j = S; j <= W; j++) {
                chmax(ans,A[i][j] - A[i-T][j] - A[i][j-S] + A[i-T][j-S]);
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3180
#include<iostream>
#include<cstdio>
using namespace std;
int num[400100];
int t[400100];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++)
		scanf("%d",&num[i]) , t[num[i]] = i;
	int ans = 1;
	int temp = 1;
	for(int i = 2 ; i <= n ; i ++)
	{
		if(t[i] > t[i-1])
			temp ++;
		else
		{
			ans = max(ans,temp);
			temp = 1;
		}
	}
	ans = max(ans,temp); 
	printf("%d\n",n-ans);
	return 0;
}





Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  // 頂点数と辺数
  int N, M;
  cin >> N >> M;

  // グラフ入力受取 (ここでは無向グラフを想定)
  Graph G(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  // sign[i]: 部屋iの道しるべが指す部屋の番号
  vector<int> sign(N, -1);

  // BFS のためのデータ構造
  vector<int> dist(N, -1);  // 全頂点を「未訪問」に初期化
  queue<int> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0);  // 0 を橙色頂点にする

  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    int v =
        que.front();  // キューから先頭頂点を取り出す(front()では削除されない)
    que.pop();  // 先頭を削除

    // v から辿れる頂点をすべて調べる
    for (int nv : G[v]) {
      if (dist[nv] != -1) continue;  // すでに発見済みの頂点は探索しない

      // signを追加
      sign[nv] = v;

      // 新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[nv] = dist[v] + 1;
      que.push(nv);
    }
  }

  for (int i = 1; i < N; i++) {
    if (sign[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) {
    cout << ++sign[i] << endl;
  }
}

Measured memory_bytes: 10720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll calc(ll a, ll b){
    return ll(pow(a, 5)) - ll(pow(b, 5));
}

int main(){
    ll x;
    cin >> x;
    ll ansa, ansb;
    for(ll a = -1000; a <= 1000; a++){
        for(ll b = -1000; b <= 1000; b++){
            if(calc(a, b) == x) {
                ansa = a;
                ansb = b;
                break;
            }
        }
    }

    cout << ansa << " " << ansb << endl;

    return 0;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int M;
  cin >> M;
  print(48 - M);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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(){
    vl v(5);
    rep(i,5)cin >> v[i];
    rep(i,5){
        if(v[i]==0)cout << i+1 <<endl;
    }
} 

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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    // Failed to predict input format
    long long N;
    cin >> N;
    long long arr[N];
    for (long long i = 0; i < N; i++) {
        cin >> arr[i];
    }

    for (long long i = 1; i <= N; i++) {
        if (arr[i - 1] % 2 == 0) {
            if (arr[i - 1] % 3 == 0 || arr[i - 1] % 5 == 0) {
                continue;
            } else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    k=parseInt(readline())
    x=parseMap(split(readline()))
    ans=0
    for i in x
        ans+=min(2*i,2*abs(k-i))
    end
    println(ans)
end
main()

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

using namespace std;

long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
    long long int ans=0,tmp;
    int N,now=0;
    cin >> N;

    vector<long long int> x(N),y(N),P,Q;
    map<pair<long long int,long long int>,long long int> mp;

    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i];
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j){
                continue;
            }

            long long int p,q,pp,qq;
            p = x[j]-x[i];
            q = y[j]-y[i];
            pp=p;
            qq=q;

            P.push_back(pp);
            Q.push_back(qq);

            mp[{pp,qq}]++;
        }
    }

    for(int i=0;i<N*(N-1)/2;i++){
        ans = max(ans,mp[{P[i],Q[i]}]);
    }

    cout << N-ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
typedef long double ld;
int main() {
  ld n, m, d;
  cin >> n >> m >> d;
  if (d == 0) {
    cout << fixed << setprecision(10) << (m - 1) / n << endl;
    return 0;
  }
  cout << fixed << setprecision(10) << (m - 1) * (n - d) * 2 / (n * n) << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int ans;
  
  
string N;
  string M;
  
    cin >> N;
  A = atoi(N.c_str());
  if(A < 10)
  {
  M = N[0];
  }
  else if(A < 100)
  {
    M = N[1];
  }
  else if(A< 1000)
  {
    M=N[2];
  }
  


  
  if ( M =="0")
  {
    cout <<"pon" << endl;
  }
    if ( M =="1")
  {
    cout <<"pon" << endl;
  }
    if ( M =="2")
  {
    cout <<"hon" << endl;
  }
    if ( M =="3")
  {
    cout <<"bon" << endl;
  }
    if ( M =="4")
  {
    cout <<"hon" << endl;
  }
    if ( M =="5")
  {
    cout <<"hon" << endl;
  }
    if ( M =="6")
  {
    cout <<"pon" << endl;
  }
    if ( M =="7")
  {
    cout <<"hon" << endl;
  }
    if ( M =="8")
  {
    cout <<"pon" << endl;
  }
    if ( M =="9")
  {
    cout <<"hon" << endl;
  }

  
  
}

Measured memory_bytes: 3632
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
AGC028 B
"""

import itertools
import math

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

cut = 10**9+7


def modInverse(a, b, divmod=divmod):
    r0, r1, s0, s1 = a, b, 1, 0
    while r1 != 0:
        q, rtmp = divmod(r0, r1)
        stmp = s0-q*s1
        r0, s0 = r1, s1
        r1, s1 = rtmp, stmp
    return s0 % cut


# def factorial(n):
#     nn = 1
#     for i in range(2, n+1):
#         nn = nn*i
#     return(nn)


invlist = [modInverse(i, cut) for i in range(1, n+1)]
accuminv = list(itertools.accumulate(invlist, func=lambda x, y: x+y % cut))

ans = 0
nfact = math.factorial(n)
for i in range(n):
    sump = accuminv[i]+accuminv[n-1-i] - 1
    ans += ali[i]*sump % cut

ans = ans*nfact % cut
print(ans)




Measured memory_bytes: 16880
using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');

        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

		if (a < b)
		{
			Console.WriteLine("a < b");
		} else if (a == b)
		{
			Console.WriteLine("a == b");
		} else
			Console.WriteLine("a > b");
    }
}


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

using namespace std;

int main() {

	int N, a[100010], count = 0;

	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> a[i];
	}

	for (int j = 1; a[j] != '\0'; ++j) {
		if (a[j] == j && a[j+1] != j + 1) ++count;
		if (a[j] == j && a[j+1] == j + 1) ++count, ++j;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0,b=0,c=0;
  for(int i=0;i<s.size();i++){
	if(s[i]=='a') a++;
    if(s[i]=='b') b++;
    if(s[i]=='c') c++;
  }
  if(a*b*c==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import math
n = int(input())
a = math.floor(n / 1.08)
b = a + 1
c = math.floor(a * 1.08)
d = math.floor(b * 1.08)

if c == n:
  print(a)
elif d == n:
  print(b)
else:
  print(":(")


Measured memory_bytes: 38484
a,b,h,m = map(int,input().split())
import math
sitah = 30 * h + 0.5 * m
sitam = 6 * m
sitax = abs(sitah - sitam)
if sitax > 180:
    sitax = 360-sitax
kosain = (math.cos((math.radians(sitax))))
x2 = a**2 + b**2 - 2*a*b*kosain
ans = math.sqrt(x2)
print(ans)

Measured memory_bytes: 9516
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a = n % 10 * 100 + n / 10 % 10 * 10 + n / 100;
    if(n == a){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
from itertools import accumulate

n, m = [int(x) for x in input().split()]
a = [0 for i in range(n + 2)]
for i in range(m):
    l, r = [int(x) for x in input().split()]
    a[l] += 1
    a[r + 1] -= 1
a = list(accumulate(a))
print(a.count(m))


Measured memory_bytes: 51616
N = int(input())
B = list(map(int, input().split()))
l = [0] * N
l[0] = B[0]
l[-1] = B[-1]
for i, b1, b2 in zip(range(1, N), B, B[1:]):
        if b1 > b2:
                l[i] = b2
        else:
                l[i] = b1

print(sum(l))

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b;
    cin >> a >> b;
    if((a*b)%2 != 0){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }
    return 0;
}



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

public class Main {
    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            solve(reader);
        }
    }

    private static void solve(InputReader reader) throws IOException {
        String input = reader.readLine();

        for (char c : input.toCharArray()) {
            switch(c) {
                case '9':
                    System.out.print('1');
                    break;
                case '1':
                    System.out.print('9');
                    break;
            }
        }

        System.out.println();
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


Measured memory_bytes: 22740
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int h, a;
  cin >> h >> a;
  if(h % a == 0) cout << h / a;
  else cout << (h / a) + 1;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int D, G;
  cin >> D >> G;

  vector<int> p(D + 10), c(D + 10);
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }

  int minv = 1e7;
  for (int i = 0; i < (1 << D); i++) {
    int sum = 0, cnt = 0;

    for (int j = 0; j < D; j++) {
      if (i & (1 << j)) {
        sum += p[j] * (j + 1) * 100 + c[j];
        cnt += p[j];
      }
    }
    for (int j = D-1; j >= 0; j--) {
      if (i & (1 << j)) continue;
      int cont = 0;

      while ((cont + 1) < p[j] && sum < G) {
        sum += (j + 1)*100;
        cnt++;
        cont++;
      }
    }

    if (sum >= G) {
      minv = min(minv, cnt);
    }
  }

  cout << minv << endl;
}


Measured memory_bytes: 256
from bisect import bisect_left as bl
N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda x: x[2])
Y = [int(input()) for _ in range(Q)]
res = [-1] * Q
jump = [-1] * Q
for s,t,x in X:
  l=bl(Y,s - x)
  r=bl(Y,t - x)
  while l < r:
    s = jump[l]
    if s == -1:
      res[l] = x
      jump[l] = r
      l += 1
    else:
      l = s
print(*res,sep = '\n')

Measured memory_bytes: 77356
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n, x;
  cin >> n >> x;
  vi d(n+1);
  d[0] = 0;
  rep(i,n) {
    int l = in();
    d[i+1] = d[i] + l;
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (d[i] <= x) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

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

    bool flag = 0;
    for(int i=1;i<=3;++i){
        int prod=a*b*i;
        if(prod%2!=0){
            flag = 1;
            break;
        }
    }

    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}


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

int main(){
    int n,k,ans=1,tmp_a,tmp_b;
    cin>>n>>k;
    
    for(int i=0;i<n;i++){
        tmp_a=2*ans;
        tmp_b=ans+k;
        
        if(tmp_a<tmp_b)
            ans=tmp_a;
        else
            ans=tmp_b;
            
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3548