akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;

const int inf = 1e9;
const int maxN = 1e5 + 5;
int l[maxN], dist[maxN], N, e;
bool vis[maxN];
struct edge{
	int v, fa, val;
}G[maxN * 10];

void add(int u, int v, int val) {
	G[e].v = v; G[e].val = val; G[e].fa = l[u]; l[u] = e++; 
}

void spfa() {
	for(int i = 0; i <= N; ++i) vis[i] = 0, dist[i] = inf;
	queue<int> q; q.push(N); vis[N] = 1; dist[N] = 0;
	while(!q.empty()) {
		int u = q.front(); vis[u] = 0;
		//cout << u << endl;
		q.pop();
		for(int i = l[u]; i != -1; i = G[i].fa) {
			int v = G[i].v;
			if(G[i].val + dist[u] < dist[v]) {
				dist[v] = G[i].val + dist[u];
				if(!vis[v]) {
					vis[v] = 1;
					q.push(v);
				}
			}
		}
	}
}

int main() {
	scanf("%d", &N);
	for(int i = 0; i <= N; ++i) l[i] = -1;
	for(int i = 1; i <= 9; ++i) {
		add(N, i % N, i);
	}
	for(int i = 0; i < N; ++i) {
		for(int j = 0; j <= 9; ++j) {
			add(i, (i * 10 + j) % N, j);
		}
	}
	//cout << "********" << endl;
	spfa();
	printf("%d\n", dist[0]);
	return 0;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
int main(){
  	int a,b;scanf("%d%d",&a,&b);
  	puts((b<=(a+1>>1))?"YES":"NO"); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,0,n-1)cin >> p[i];
    int ans = 1;
    int m = p[0];
    rep(i,1,n-1){
        if(m >= p[i])++ans;
        m = min(m,p[i]);
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

const int MAXN = (int)1e5 + 5;
const int INF = (int)1e9 + 1;
int h[MAXN];
int f[MAXN];

void solve(int n, int k) {
  f[1] = 0;
  for (int i = 2; i <= n; ++i) {
    f[i] = INF;
    for (int j = i - 1; j >= i - k && j >= 1; --j)
    f[i] = min(f[i], f[j] + abs(h[j] - h[i]));
  }
}

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", h + i);
  }
  solve(n, k);
  printf("%d\n", f[n]);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

int main() {
	int n,m=0;
	std::cin >> n;

	std::vector<int> v(n);
	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(),v.end());

	v[n-1] = v[n-1] / 2;

	for (int i = 0; i < n; i++) {
		m = v[i]+m;
	}

	std::cout << m << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<17;
const ll INF=1LL<<60;
int n;
ll dat[2*MAX-1];

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=INF;
    }
}

void update(int k,ll a){
    k+=n-1;
    dat[k]=a;
    
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}

ll query(int a,int b,int k,int l,int r){
    
    if(r<=a||b<=l) return INF;
    if(a<=l&&r<=b) return dat[k];
    else{
        ll vl=query(a,b,2*k+1,l,(l+r)/2);
        ll vr=query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
}

struct edge{
    int from;
    int to;
    ll dis;
};

bool compare(edge a,edge b){
    if(a.from==b.from) return a.to<b.to;
    return a.from<b.from;
}

int main(){
    
    int N,M;cin>>N>>M;
    init(N);
    
    vector<edge> S(M);
    for(int i=0;i<M;i++){
        int a,b;ll c;cin>>a>>b>>c;
        a--;b--;
        S[i]={a,b,c};
    }
    
    sort(all(S),compare);
    
    update(0,0);
    
    for(int i=0;i<M;i++){
        int a=S[i].from,b=S[i].to;
        ll c=S[i].dis;
        ll mini=query(a,b+1,0,0,n);
        
        if(query(b,b+1,0,0,n)>mini+c) update(b,mini+c);
    }
    
    ll ans=query(N-1,N,0,0,n);
    if(ans>1000000000000000) ans=-1;
    
    cout<<ans<<endl;
    
    
}





Measured memory_bytes: 3840
n,m=map(int,input().split())
l=[0]*(n+1)
mod=10**9+7
for i in range(m):
    l[int(input())]=-1
l[0]=1
for i in range(n):
    if l[i]==-1:continue
    if l[i+1]!=-1:
        l[i+1]=(l[i+1]+l[i])%mod
    if i+2<=n and l[i+2]!=-1:
        l[i+2]=(l[i+2]+l[i])%mod
print(l[n])

Measured memory_bytes: 6884
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!
#define N_MAX 1001
ll prime[N_MAX], cnt;
int main(void){
    ll N, ans=1, n;
    scanf("%lld", &N);
    for(ll i=2; i<=N; i++) {
        n = i;
        for(ll j=2; j*j<=n; j++) {
            while(n%j==0) {
                n /= j;
                prime[j]++;
            }
        }
        if(n>1) prime[n]++;
    }
    rep(i, N_MAX) if(prime[i]) {
        ans *= 1+prime[i];
        ans %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , N = 2000 , _N = N + N + 3 , mo = 1000000007;

template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

int jc[_],rjc[_];

inline void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=1ll*jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return 1ll*jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,va[_],vb[_],g[_N][_N]={0};

#define gs(a,b) (g[(a)+N+1][(b)+N+1])

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)va[i]=ty(),vb[i]=ty(),gs(-va[i],-vb[i])++;

	fuck();
	
	lint ans=0;
	for(int i=-N;i<=N;i++)
		for(int j=-N;j<=N;j++)
			ad(gs(i,j),gs(i-1,j)),ad(gs(i,j),gs(i,j-1));
	for(int i=1;i<=n;i++)
		ad(ans,gs(va[i],vb[i])),dl(ans,C(va[i]+va[i]+vb[i]+vb[i],va[i]+va[i]));
	printf("%lld\n",ans*inva(2)%mo);
	
	return 0;
}


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

int X, Y, Z;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  cin >> X >> Y >> Z;

  int temp = X;
  X = Y;
  Y = temp;

  temp = X;
  X = Z;
  Z = temp;

  cout << X << " " << Y << " " << Z << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char a[510][510];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (a[i][j] == '#') {
                cout << '#';
                continue;
            }
            if ((j == 1 || i % 2 == 1) && j != m) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    cout << endl;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (a[i][j] == '#') {
                cout << "#";
                continue;
            }
            if ((j == m || i % 2 == 0) && j != 1) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import sys


def solve(n, k, aaa):
    pos = []
    neg = []
    MOD = 10 ** 9 + 7
    for a in aaa:
        if a > 0:
            pos.append(a)
        elif a < 0:
            neg.append(a)
    if len(pos) + len(neg) < k:
        return 0
    if len(pos) == 0:
        if k % 2 == 1:
            if len(neg) < n:
                return 0
            neg.sort(reverse=True)
        else:
            neg.sort()
        ans = 1
        for a in neg[:k]:
            ans = ans * a % MOD
        return ans
    if len(pos) + len(neg) == k:
        if n > k and len(neg) % 2 == 1:
            return 0
        ans = 1
        for a in pos:
            ans = ans * a % MOD
        for a in neg:
            ans = ans * a % MOD
        return ans

    pos.sort()
    neg.sort(reverse=True)

    ans = 1
    r = k
    while r >= 2:
        if len(pos) <= 1:
            ans = ans * neg.pop() * neg.pop() % MOD
        elif len(neg) <= 1:
            ans = ans * pos.pop() * pos.pop() % MOD
        else:
            pm = pos[-1] * pos[-2]
            nm = neg[-1] * neg[-2]
            if pm > nm:
                ans = ans * pm % MOD
                pos.pop()
                pos.pop()
            else:
                ans = ans * nm % MOD
                neg.pop()
                neg.pop()
        r -= 2

    if r == 1:
        ans = ans * pos[-1] % MOD

    return ans


n, k, *aaa = map(int, sys.stdin.buffer.read().split())
print(solve(n, k, aaa))


Measured memory_bytes: 27844
import sys
import collections

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline


def main():
    H, W = map(int, readline().split())
    c = []
    for _ in range(10):
        c.append(list(map(int, readline().split())))
    wall = []
    wallcount = collections.Counter([])
    for _ in range(H):
        tmp = list(map(int, input().split()))
        wall.append(tmp)
        wallcount += collections.Counter(tmp)
    wallitem = list(zip(*wallcount.items()))
    
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][k] + c[k][j], c[i][j])
    
    ans = 0
    for item in wallitem[0]:
        if item in [-1, 1]:
            continue
        ans += wallcount[item]*c[item][1]

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
int l;
int n;
int A[1000000];
long long cnt;
vector<int> G;

void insertion_sort(int A[], int N, int g){
  for(int i = g; i<N; i++){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shell_sort(int A[], int N){
  for(int h = 1; ; ){
    if(h > N)
      break;
    G.push_back(h);
    h = 3*h +1;
  }

  for(int i = G.size() - 1; i >= 0; i--){
    insertion_sort(A,N,G[i]);
  }
}

int main(int argc, char const *argv[]) {
  cin >> n;
  for(int i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  cnt = 0;

  shell_sort(A,n);
  cout << G.size() << endl;
  for(int i = G.size()-1; i>=0; i--){
    printf("%d", G[i]);
    if (i) {
      printf(" ");
    }
  }
  printf("\n");
  printf("%lld\n", cnt);
  for(int i = 0; i<n; i++)
    printf("%d\n", A[i]);
  return 0;
}

Measured memory_bytes: 7196
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            char[] s = IChars();


            long hidari = 1;
            long ans = 1;

            if(s[0]=='W'){
                WriteLine(0);
                return;
            }

            for(int i=1;i<n*2;i++){
                if(s[i]=='B'){
                    if(hidari%2==0){
                        hidari ++;
                    }else{
                        ans *= hidari;
                        ans %= MOD;
                        hidari --;
                    }
                }else{
                    if(hidari%2==1){
                        hidari ++;
                    }else{
                        if(hidari==0){
                            WriteLine(0);
                            return;
                        }
                        ans *= hidari;
                        ans %= MOD;
                        hidari --;
                    }
                }
                if(hidari>n*2-i-1){
                    WriteLine(0);
                    return;
                }
            }

            for(int i=1;i<n+1;i++){
                ans *= i;
                ans %= MOD;
            }

            WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13536
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int K = scan.nextInt();

		List<Long> list = new ArrayList<>();

		for(int i = 0; i < N; i++) {
			list.add(scan.nextLong());
		}

		// 降順ソート
		Collections.sort(list, Collections.reverseOrder());

		if(N < K) {
			System.out.println(0);
			return;
		}

		long ans = 0l;

		for(int i = K; i < N; i++) {
			ans += list.get(i);
			//System.out.println(ans);

		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 95604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	int A[N];
	F0R(a, N)
		cin >> A[a];
	ll money = 1000;
	ll stock = 0;
	FOR(a, 0, N - 1){
		if(A[a] <= A[a + 1]){
			stock += money / A[a];
			money -= money / A[a] * A[a];
		}
		else{
			money += stock * A[a];
			stock = 0;
		}
	}
	cout << money + stock * A[N - 1] << endl;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 読み込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int gu = N*(N-1)/2;
		int ki = M*(M-1)/2;
		
		System.out.println(gu + ki);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
int n;
vector<ll> h;
vector<ll> v;
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
const int N = 2e5;
ll seg[4*N+20] = {};
ll update(int pos, int l, int r, int index, ll val){
    if(r < index || index < l){
        return seg[pos];
    }
    if(index <= l && r <= index){
        seg[pos] = val;
        return seg[pos];
    }
    int mid = (l+r)/2;
    return seg[pos] = max(update(pos*2, l, mid, index, val), update(pos*2+1, mid+1, r, index, val));
}
ll query(int pos, int l, int r, int qL, int qR){
    if(r < qL || qR < l){
        return 0;
    }
    if(qL <= l && r <= qR){
        return seg[pos];
    }
    int mid = (l+r)/2;
    return max(query(pos*2, l, mid, qL, qR), query(pos*2+1, mid+1, r, qL, qR));
}
int main() {
    IO;
    cin >> n;
    h.resize(n);
    v.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    for(int i = 0; i < n; ++i){
        ll mx = query(1, 1, n, 1, h[i]-1);
        update(1, 1, n, h[i], mx+v[i]);
    }
    cout << query(1, 1, n, 1, n);






    return 0;
}


Measured memory_bytes: 9472
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <malloc.h>
#include <stack>
#include <cstring>
#include <string>
#include <set>
#include <unordered_map>
#define INT long long int
#define MOD 1000000007
#define oo 987654321
using namespace std;

int n, x, y, a[110], b[110], c[110], dt[41][440][440];

int dp(int k, int p, int q)
{
    if( k == n ) return (p&&q&&(p*y==q*x))?0:oo;
    if(~dt[k][p][q]) return dt[k][p][q];
    int &ret = dt[k][p][q] = oo;
    ret = min(dp(k+1, (p+a[k]), (q+b[k])) + c[k], dp(k+1, p, q));
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    memset(dt, -1, sizeof(dt));
    cin>>n>>x>>y;
    for(int i = 0 ; i < n ; i++ )
        cin>>a[i]>>b[i]>>c[i];
    int ans = dp(0, 0, 0);
    cout<<(ans == oo?-1:ans)<<endl;
    return 0;
}




Measured memory_bytes: 31232
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

		int n = sc.nextInt() + 1;
		int m = sc.nextInt();

		Map<Integer, Set<Integer>> path = new HashMap<Integer, Set<Integer>>();
		for (int i = 1; i < n; i++)
			path.put(i, new HashSet<Integer>());

		for (int i = 0; i < m; i++) {
			int ai = sc.nextInt();
			int bi = sc.nextInt();
			path.get(ai).add(bi);
			path.get(bi).add(ai);
		}

		// 残り=探索すべき部屋の集まり
		Set<Integer> rest = new HashSet<Integer>(); // ダブり無しのやつ
		for (int i = 2; i < n; i++)
			rest.add(i);

		// 探索する予定のやつ
		// queueに最後に入れる = add(), 先頭を出す = poll()
		Deque<Integer> queue = new LinkedList<Integer>();
		queue.add(1); // 開始点=部屋1

		int[] before = new int[n];
		while (!queue.isEmpty()) { // 次に探索する箇所が無くなるまで
			int searchPos = queue.poll(); // 先頭から取り出す．
			Set<Integer> next = path.get(searchPos); // つながっている部屋
			
			for (Integer i : next) {
				// 次の部屋への道がある，かつ，まだ探索していなかったら
				if (next.contains(i) && rest.contains(i)) {
					queue.add(i); // キューに加える
					rest.remove(i); // 未探索から削除
					before[i] = searchPos; // 前ノードを覚えさせる
				}
			}
		}

		System.out.println("Yes");
		for (int i = 2; i < n; i++)
			System.out.println(before[i]);
	}

}


Measured memory_bytes: 111076
#include <bits/stdc++.h> 
using namespace std;
#define MAX 13
int solve(int idx, vector<int>& arr, vector<int>& dp){
    if(idx >= arr.size()-1)
        return 0;
    if(dp[idx] != -1)
        return dp[idx];
    if(idx == arr.size()-2)
        return dp[idx] = abs(arr[idx]-arr[idx+1]);
    return dp[idx] = min(abs(arr[idx]-arr[idx+1])+solve(idx+1,arr,dp), 
        abs(arr[idx]-arr[idx+2])+solve(idx+2,arr,dp));
}
int main()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> sol(n, -1);
    for(int i=0; i<n; ++i)
        cin >> arr[i];
    cout << solve(0, arr, sol);
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
    string s;
    cin >> s;
    int len=s.length();
    for(int i=0;i<len;i++){
    	if(s[i]+n<91){
    		printf("%c",s[i]+n);
		}else{
			printf("%c",((s[i]+n)%90)+64);
			
		}
    	
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    vector<int> a(3); rep(i,3) cin >> a[i];
    sort(all(a));

    cout << a[0] + a[1] + a[2] * 10 << endl;
}
   

Measured memory_bytes: 256
N = int(input())
k = 0

xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

for i in range(N):
    if x[i] == y[i]:
        k += 1
    else:
        k = 0
    if k == 3:
        break

if k == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    x = I()
    print("Yes" if x >= 30 else "No")

Measured memory_bytes: 27164
my $s = <STDIN>;
chomp $s;
my @dat =  split(/ /,$s);
my $N =  $dat[0] ;
my $K =  $dat[1] ;
my $C =  $dat[2] ;
$s = <STDIN>;
chomp $s;
my @data =  split(//,$s);
my @workday;
$day = -$C -1;
for(my $j=0;$j<$K;$j++){
    for($m=$day+$C+1;$m<=$#data;$m++){
         if($data[$N-$m-1] eq "x" ){ next;}
         $day = $m; last;
    }
    $bday = $N - $day -1;
    push (@workday,$bday);
}
$day = -$C - 1;
for(my $j=0;$j<$K;$j++){
    for($m=$day+$C+1;$m<=$#data;$m++){
         if($data[$m] eq "x" ){ next;}
         $day = $m; last;
    }
    if($workday[$K-$j-1] == $day ){
        $ans = $day +1;
        print "$ans\n";
    }
}


Measured memory_bytes: 30476
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
//Actual Code Is At The Top
const int mod = 1e9 + 7;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int32_t main()
{   
	very_slow
//	no_of_test(x)
	{  
      int n;
	  cin>>n;int sum=0;
	  for(int i=1;i<=n;i++)
	  {
		  for(int j=1;j<=n;j++)
		  {
			  for(int k=1;k<=n;k++)
			  {   int res;
				  res=gcd(gcd(i,j),k);
				  sum+=res;
			  }
		  }
	  }
	 cout<<sum<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    for(int i = 0; i < N; i++) cin >> C[i];
    ll sum = 0;
    for(int i = 0; i < N; i++){
        if(V[i] > C[i]) sum += V[i] - C[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624
#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> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main(){
        int n,W;
        cin >>n >>W;
        vector<int> v(n);
        vector<int> w(n);
        rep(i,n) { cin >> v[i]; cin >>w[i]; }
        vector<vector<int>> dp(n+1,vector<int>(W+1,0));
        
        for(int i=1;i<=n;i++){
                rep(j,W+1){
                           if(j < w.at(i-1)) dp.at(i).at(j) = dp.at(i-1).at(j);
                        else dp.at(i).at(j) = max(dp.at(i-1).at(j) , dp.at(i).at(j-w.at(i-1)) + v.at(i-1));
                }
        }
        
        cout << dp.at(n).at(W) << endl;
        
           

        return 0;
}



Measured memory_bytes: 6836
from collections import OrderedDict as od

m1 = od()

n=int(input())

for i in range(n):
	l=input().split()
	s=l[0];t=int(l[1])
	m1[l[0]]=t

x=input()
flag=0;total=0
for key,value in m1.items():
	if key == x:
		flag=1
		continue
	if flag==1:
		total+=value

print(total)


Measured memory_bytes: 3444
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
    }
    println!("{}", 180 * (n-2));
}


Measured memory_bytes: 4352
def main():
    x,y,z,k = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]

    a.sort(reverse=True)
    b.sort(reverse=True)
    c.sort(reverse=True)

    ans = []

    for i in range(x):
        if i > k:
            break
        for j in range(y):
            if i * j > k:
                break
            for m in range(z):
                if i * j * m > k:
                    break
                ans.append(a[i]+b[j]+c[m])

    ans.sort(reverse=True)
    for i in range(k):
        print(ans[i])


main()

Measured memory_bytes: 112348
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int p = 0;
	for (i = 0; i < n; i++)
	{
		if (i % 2 == 0)
			p += a[i];
		else
			p -= a[i];
	}
	long long int ans[100005];
	ans[0] = p;
	for (i = 1; i < n; i++)
		ans[i] = 2 * a[i - 1] - ans[i - 1];
	for (i = 0; i < n - 1; i++)
		printf("%lld ", ans[i]);
	printf("%lld\n", ans[n - 1]);
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n;cin>>n;
  string s;cin>>s;
  ll ans = 1;
  rep(i,n){
    if(i==0) continue;
    if(s[i] != s[i-1]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	char x; cin >> x;
	string a = "aiueo";
	if (find(all(a), x) != a.end())cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

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

void add(int &a, int b) {
  a = (a+b)%10007;
}

int dp[1001][1<<3];
int a[1001];

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i=0; i<n; ++i) {
    a[i] = s[i] == 'J' ? 0 : s[i] == 'O' ? 1 : 2;
  }
  memset(dp,0,sizeof(dp));
  dp[0][1] = 1;
  for (int i=0; i<n; ++i) {
    for (int S=0; S<(1<<3); ++S) {
      if (!(S>>a[i]&1)) continue;
      for (int T=0; T<(1<<3); ++T) {
        if ((S & T) != 0) {
          add(dp[i+1][S], dp[i][T]);
        }
      }
    }
  }
  int ans = 0;
  for (int S=0; S<(1<<3); ++S) {
    add(ans, dp[n][S]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1248
while true
  rect = gets.split.map(&:to_i)

  if rect[0] == 0 && rect[1] == 0
    break
  end

  for i in 1..rect[0] do
    if i % 2 == 0
        for j in 1..rect[1] do
            if j % 2 == 0
              print '#'
            else
              print '.'
            end
        end
            print "\n"
    else
        for j in 1..rect[1] do
              if j % 2 != 0
                print '#'
              else
                print '.'
              end
        end
            print "\n"
    end
  end
  print "\n"
end



Measured memory_bytes: 6868
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N, mid;
vi adj[MX];
bool ok;

bool OK(vi v, int ind) {
    // if (v[ind]+1 > mid) return 0;
    v.erase(v.begin()+ind);
    for (int i = 0; i < sz(v)-1-i; ++i) if (v[i]+v[sz(v)-1-i] > mid) return 0;
    return 1;
}

int test(int cur, int pre) {
    if (!ok) return 0;
    vi v; for (int i: adj[cur]) if (i != pre) v.pb(test(i,cur));
    if (!ok) return 0;
    
    if (cur == 1) {
        if (sz(v) % 2 == 1) v.pb(0);
        sort(all(v));
        for (int i = 0; i < sz(v)-1-i; ++i) if (v[i]+v[sz(v)-1-i] > mid) ok = 0;
        return 0;
    } else {
        if (sz(v) % 2 == 0) v.pb(0);
        sort(all(v));
        int lo = 0, hi = sz(v);
        while (lo < hi) {
            int mid = (lo+hi)/2;
            if (OK(v,mid)) hi = mid;
            else lo = mid+1;
        }
        // cout << "ZZ " << cur << " " << lo << " " << sz(v) << " " << v[0] << "\n";
        if (lo == sz(v)) {
            ok = 0;
            return 0;
        }
        if (v[lo]+1 > mid) {
            ok = 0;
            return 0;
        }
        // cout << "HAHA " << ok << " " << cur << " " << v[lo] << "\n";
        return v[lo]+1;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N-1) {
        // int a = i+1,b = i+2; 
        int a,b; cin >> a >> b;
        adj[a].pb(b), adj[b].pb(a);
    }
    // cout << ok << "\n";
    int A = 0; FOR(i,1,N+1) if (sz(adj[i])&1) A++;
    int lo = 1, hi = N-1; 
    while (lo < hi) {
        mid = (lo+hi)/2;
        ok = 1; test(1,0);
        if (ok) hi = mid;
        else lo = mid+1;
    }
    cout << A/2 << " " << lo;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 16384
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	string s;
	int i,leng;
	cin>>s;
	leng=s.size();
	
	for(i=0;i<leng-1;i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2;
			goto end;
		}
	}
	for(i=0;i<leng-2;i++){
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3;
			goto end;
		}
	}
	cout<<-1<<" "<<-1;
	end:
	i=0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

ll pate[52],pan[52];

int main()
{
	ll n,x;
	cin >> n >> x;
	pate[0] = 1;
	pan[0] = 1;
	for(int i=0;i<51;i++)
	{
		pate[i+1] = pate[i]*2+1;
		pan[i+1] = pan[i]*2+3;
	}
	//cout<<pan[2]<<endl;
	ll ans = 0;
	for(int i =n;i>=0;i--)
	{
		if(x>pan[i]/2)
		{
			ans += pate[i]/2+1;
			x-= pan[i]/2+1;
		}
		else
		{
			x--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

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

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0;i < n;i++) cin >> h[i];

    vector<ll> dp(n+1,INF);
    dp[0] = 0;
    for (int i = 0;i < n;i++){
        for (int j = 1;j <= k;j++){
            if (i + j < n){
                dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j])); 
            }
        }
    }

    cout << dp[n-1] << endl;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
char a[35][35];

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

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int a,b;
                    char ch;
                    cin>>a>>ch>>b;
                    if(ch=='+')
                         cout<<a+b;
                    else
                         cout<<a-b;
          }
          return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
}

Measured memory_bytes: 256
def read():
    S = input().strip()
    return S,


def solve(S):
    key = "keyence"

    for i in range(len(key)):
        head = S[:i]
        tail = S[len(S) - len(key) + i:]
        if head == key[:i] and tail == key[i:]:
            return True
    return False


if __name__ == '__main__':
    inputs = read()
    print("YES" if solve(*inputs) else "NO")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,d,a[15][15],ans;
int main(){
	scanf("%d %d",&n,&d);
	for(int i=1;i<=n;++i){
		for(int o=1;o<=d;++o){
			scanf("%d",&a[i][o]);
		}
		for(int o=1;o<i;++o){
			int s=0;
			for(int u=1;u<=d;++u){
				s+=(a[i][u]-a[o][u])*(a[i][u]-a[o][u]);
			}
			int z=sqrt(s);
			if(z*z==s)ans++;
		}
	}
	printf("%d\n",ans);
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, 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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

P division_code(double a, double b){
  P res;
  if (b < 0) {
    res.first = ceil(a / b);
    res.second = a - b * res.first;
  }
  else {
    res.first = floor(a / b);
    res.second = a - b * res.first;
  }
  return res;
}

int main(){
  int N; cin >> N;
  P res;
  string ans;
  while (true){
    res = division_code(N, -2);
    ans += to_string(res.second);
    N = res.first;
    if (res.first == 0) break;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,k,i,x,cnt=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(x>=k) cnt++;
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
using int64 = long long;
 
int main() {
  int N, M, P[100000], Q[100000];
  cin >> N >> M;
  map< int, vector< int > > mp;
  for(int i = 0; i < M; i++) {
    cin >> P[i] >> Q[i];
    mp[P[i]].emplace_back(Q[i]);
  }
  for(auto &p : mp) {
    sort(begin(p.second), end(p.second), [&](int a, int b) {
      return a < b;
    });
  }
  for(int i = 0; i < M; i++) {
    auto it = lower_bound(begin(mp[P[i]]), end(mp[P[i]]), Q[i]) - begin(mp[P[i]]);
    printf("%06d%06d\n", P[i], (int) (it + 1));
  }
}

Measured memory_bytes: 13184
#include <stdio.h>
 
int main(void) {

	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	    if(abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d){
			printf("Yes");
        }
  
		else{
			printf("No");
		}
  
	return 0;
}

Measured memory_bytes: 128
#include<cstring>
#include<cstdio>
int main(void){
int a,b;
char c[5];
for(;;){
scanf("%d %s %d",&a,c,&b);
if(c[0]=='+') printf("%d\n",a+b);
else if(c[0]=='-') printf("%d\n",a-b);
else if(c[0]=='*') printf("%d\n",a*b);
else if(c[0]=='/') printf("%d\n",a/b);
else if(c[0]=='?') break;
}
return 0;
}

Measured memory_bytes: 2664
#include<iostream>

using namespace std ;

int main()
{
	int n ;
	while( cin >> n ,n )
	{
		char C[ n + 1 ] ,c[ n + 1 ] ;
		for( int i = 0 ; i < n ; i++ )
		{
			cin >> C[ i ] >> c[ i ] ;
		}
		int m ;
		char str ;
		cin >> m ;
		for( int i = 0 ; i < m ; i++ )
		{
			cin >> str ;
			for( int j = 0 ; j < n ; j++ )
			{
				if( str == C[ j ] )
				{
					cout << c[ j ] ;
					goto next ;
				}
			}
			cout << str ;
			next : ;
		}
		cout << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    int n,ans=1e9;
    cin>>n;
    vector<int> x(n);
    rep(i,0,n)cin>>x[i];
    erep(i,1,100){
        int buf=0;
        rep(j,0,n){
            buf+=pow(i-x[j],2);
        }
        ans=min(ans,buf);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
i = input().split()

a,b,c = int(i[0]),int(i[1]),int(i[2])

while(True):
    if (a > b):
        a,b=b,a
    if (b > c):
        b,c=c,b
    if ((a <= b) and (b <= c)):
        break
print(a,b,c)


Measured memory_bytes: 5600