akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  string s;
  cin>>s;

  map<char,int> me;
  map<char,int> mo;
  
  mo['R']=1;
  mo['U']=1;
  mo['D']=1;

  me['L']=1;
  me['U']=1;
  me['D']=1;

  for(int i=0;i<s.size();i++){
    auto c=s[i];
    if(i%2==0){
      if( mo.find(c) ==end(mo)){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if( me.find(c) ==end(me)){
        cout << "No" << endl;
        return 0;
      }
    }

  }

  cout << "Yes" << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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


namespace _514_Quality_Checking
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				//??\???
				int[] inputNum = Console.ReadLine ().Trim ().Split (' ').Select (( str ) => int.Parse (str)).ToArray ();

				if (inputNum[0] == 0 && inputNum[1] == 0 && inputNum[2] == 0)
					break;

				int setCount = int.Parse (Console.ReadLine ().Trim ());

				//??????
				PartsState parts = new PartsState (inputNum[0], inputNum[1], inputNum[2]);

				for (int lp = 0; lp < setCount; lp++)
				{
					int[] order = Console.ReadLine ().Trim ().Split (' ').Select (( str ) => int.Parse (str)).ToArray ();
					parts.SetState (order[0], order[1], order[2], order[3]);
				}

				parts.Check ();
				
				//??????
				foreach (var item in parts.Parts)
				{
					Console.WriteLine (item);
				}
			}
		}
	}
}

class PartsState
{
	public PartsState ( int partsACount, int partsBCount, int partsCCount )
	{
		this.PartsList = new List<PartsClass> (partsACount + partsBCount + partsCCount);
		this.Parts = new int[partsACount + partsBCount + partsCCount];

		for (int lp = 0; lp < this.Parts.Length; lp++)
		{
			this.Parts[lp] = Unknown;
		}
	}

	private List<PartsClass> PartsList { set; get; }
	public int[] Parts { private set; get; }
	const int Failure = 0;
	const int Normal = 1;
	const int Unknown = 2;

	public void SetState ( int partsA, int partsB, int partsC, int pass )
	{
		//1.pass	0.do not pass
		//????????°??????????????¨???????????¨????????¨??????1??????
		partsA--; partsB--; partsC--;

		if (pass == 1)
		{
			Parts[partsA] = Normal;
			Parts[partsB] = Normal;
			Parts[partsC] = Normal;
		}
		else
		{
			PartsList.Add (new PartsClass (partsA, partsB, partsC));
		}
	}

	public void Check ()
	{
		int previousCount = -1;

		while (PartsList.Count != 0 && previousCount != PartsList.Count)
		{
			previousCount = PartsList.Count;

			//???????????§??????????¢??????????????????????
			var failureList = PartsList.Where (( list ) =>
				(Parts[list.PartsA] == Normal && Parts[list.PartsB] == Normal ||
				Parts[list.PartsB] == Normal && Parts[list.PartsC] == Normal ||
				Parts[list.PartsC] == Normal && Parts[list.PartsA] == Normal
				));

			foreach (var item in failureList)
			{
				Solve (item.PartsA, item.PartsB, item.PartsC);
			}

			//?¢???????????????????????????????
			PartsList.Except (failureList);
		}
	}

	private void Solve ( int indexA, int indexB, int indexC )
	{
		//b c
		if (Parts[indexA] == Unknown)
			Parts[indexA] = Failure;
		//a c
		else if (Parts[indexB] == Unknown)
			Parts[indexB] = Failure;
		// b c
		else if (Parts[indexC] == Unknown)
			Parts[indexC] = Failure;
	}
}

class PartsClass
{
	public PartsClass ( int partsA, int partsB, int partsC )
	{
		this.PartsA = partsA;
		this.PartsB = partsB;
		this.PartsC = partsC;
	}

	public int PartsA { private set; get; }
	public int PartsB { private set; get; }
	public int PartsC { private set; get; }
}

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
  
}  

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

X = 0
D = 0
N = 0

def loop():
    i=1
    a = int(input())
    while i*a+1 <= D:
        yield 1
        i += 1

def readlines():
    for _ in range(N):
        yield 1+sum(loop())

def main():
    global N, X, D
    N = int(input())
    D, X = map(int, input().split())
    return sum(readlines()) + X
	
if __name__ == "__main__":
    print(main())

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

const int mod = 1e9+7;

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> arr(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> arr[i][j];
        }
    }
    vector<int> cost(1<<n, 0);
    for(int mask = 0; mask < (1<<n); ++mask) {
        for(int i = 0; i < n; ++i) {
            if(mask&(1<<i)) {
                for(int j = i+1; j < n; ++j) {
                    if(mask&(1<<j)) {
                        cost[mask] += arr[i][j];
                    }
                }
            }
        }
    }
    const int inf = 1e17;
    vector<int> memo(1<<n, -inf);
    memo[0] = 0;
    for(int mask = 0; mask < (1<<n); ++mask) {
        for(int subMask = mask;; subMask = (subMask-1)&mask) {
            memo[mask] = max(memo[mask], memo[subMask] + cost[subMask^mask]);
            if(subMask == 0) break;
        }
    }
    cout << memo[(1<<n)-1] << '\n';
    return 0;
}


























Measured memory_bytes: 1280
#include<iostream>
#define DIM 200005
#define mod 998244353
using namespace std;
int n, i, sol, j, sum, ok;
char s[DIM], s2[DIM], ff[DIM];
int v[DIM];
int main(){
    cin>> n;
    cin>> s + 1;
    for(i = 1; i <= n; i++){
        if(n % i == 0 && (n / i) % 2 == 1){
            ff[i] = 1;
            sum = 0;
            for(j = 1; j <= i; j++){
                sum = (sum * 2 + s[j] - '0') % mod;
            }
            ok = 1;
            for(j = 1; j <= i; j++){
                s2[j] = s[j];
            }
            for(j = i + 1; j <= n; j++){
                s2[j] = '0' + '1' - s2[j - i];
            }
            for(j = 1; j <= n; j++){
                if(s2[j] != s[j]){
                    if(s2[j] < s[j]){
                        break;
                    }
                    else{
                        ok = 0;
                        break;
                    }
                }
            }
            sum = (sum + ok) % mod;
            v[i] = sum;
        }
    }
    for(i = 1; i <= n; i++){
        if(ff[i] == 0){
            continue;
        }
        for(j = i + i; j <= n; j += i){
            v[j] = (mod + v[j] - v[i]) % mod;
        }
        sol = (sol + v[i] * 2LL * i) % mod;
    }
    cout<< sol;
}


Measured memory_bytes: 1408
#c
def sosu(num):
    flag=True
    for i in range(2,num):
        if num%i==0:
            flag=False
    return flag
x=int(input())
ans=0
cnt=0
while True:
    ans=x+cnt
    if sosu(ans):
        print(ans)
        break
    cnt+=1

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

const ll mod = 2019;

int main(){
  ll l,r; cin >> l >> r;
  bool flag = (r-mod>l);
  
  ll ans=1e7;
  if(flag){
    ans = 0;
  }else{
    for(ll i=l; i<r; i++){
      for(ll j=i+1; j<=r; j++){
        ll dmy = i*j;
        dmy %= mod;
        ans = (ans > dmy ? dmy : ans);
        if(ans == 0) break;
      }
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
    if(c<d){
        bool ok=true;
        for(int i=b;i<d;i++){
            if(s[i]=='#' && s[i+1]=='#') ok=false;
        }
        for(int i=a;i<c;i++){
            if(s[i]=='#' && s[i+1]=='#') ok=false;
        }
        if(ok) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
    }

    bool ok=true;
    bool aok=false;
    for(int i=b-1;i<d;i++){
        if(s[i]=='#' && s[i+1]=='#') ok=false;
        if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') aok=true;
    }
    for(int i=a;i<c;i++){
        if(s[i]=='#' && s[i-1]=='#') ok=false;
    }
    if(aok && ok){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;


}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int ans=0;
int play(int x,int y,int z){
	if(x>=y&&x>=z)	ans=x*10+y+z;
	if(y>=x&&y>=z)   ans=y*10+x+z;
	if(z>=x&&z>=y) ans=z*10+x+y;
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	play(a,b,c);
	cout<<ans;
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; long long c, k; cin >> n >> c >> k;
    vector<long long> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    sort(t.begin(), t.end());
    t.emplace_back(1e15);
    int lf = 0; int ans = 0;
    for (int i = 0; i < n; i++) {
        if (t[lf] + k < t[i+1]) {
            ans++; lf = i+1;
        }
        if (i - lf == c-1) {
            ans++; lf = i+1;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

#define MAX 1002

int main(void)
{
	char target_string[MAX] = {};
	char the_string[MAX] = {};
	int i = 0;
	
	scanf("%s", target_string);
	scanf("%s", the_string);
	
	if ( strlen(target_string) >= strlen(the_string) ) {
    	for ( i = 0; i < strlen(target_string) - strlen(the_string)+1; i++ ) {
    		if ( strncmp(target_string + i,  the_string, strlen(the_string)) == 0 ) {
    			printf("%d\n", i );
    		}
    	}
	}
	
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200
#define mod 998244353
int n,x[MN+5],y[MN+5];
int b[MN+5][MN+5],ans,pw[MN+5],q[MN+5],top;
int main(){
	n=read();pw[0]=1;register int i,j,l,r,k;
    for(j=1;j<=n;++j) pw[j]=2*pw[j-1]%mod;ans=(pw[n]-n-1+mod)%mod;
    for(i=1;i<=n;++i) x[i]=read(),y[i]=read();
    for(i=1;i<=n;++i) for(j=i+1;j<=n;++j) if(!b[i][j]){
        q[top=1]=i;q[top=2]=j;
        for(k=j+1;k<=n;++k) if((x[j]-x[i])*(y[k]-y[i])==(x[k]-x[i])*(y[j]-y[i])) q[++top]=k;
        for(l=1;l<top;++l) for(r=l+1;r<=top;++r) b[q[l]][q[r]]=1;
        ans=((ans-pw[top]+top+1)%mod+mod)%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	vector<int> a;
	cin>>n>>m;
	int sum = 0;
	for( int i=0; i<n; i++ )
	{
		int x;
		cin>>x;
		a.push_back(x);
		sum += x;
	}
	double d = 1.0*sum/(4*m);
	sort(a.begin(),a.end());

	if( a[n-m] >= d )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
  input! {
    h: usize,
    n: usize,
    mut ab: [(usize, usize);n]
  }
  let mut magics: HashMap<usize, usize> = HashMap::new();
  
  for i in 0..n {
    let (a, b) = ab[i];
    if let Some(v) = magics.get(&a) {
      magics.insert(a, std::cmp::min(*v, b));
    } else {
      magics.insert(a, b);
    }
  }
  
  let mut dp = vec![10usize.pow(10); h+1];
  dp[0] = 0;
  for i in 0..h {
    let v = dp[i];
    for (a, m) in magics.iter() {
      let next_index = if i + a > h {
        h
      } else {
        i + a
      };
      
      dp[next_index] = std::cmp::min(dp[next_index], m + v);
    }
  }

  println!("{}", dp[h]);
}

Measured memory_bytes: 2368
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import random
import pprint
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


# nは頂点の数
n, m = MI()
ans = 0
sides = [LI() for _ in range(m)]
visited = [False] * n
# 隣接行列を用いてグラフの管理をする
graph = [[False] * n for _ in range(n)]

# 初期化、graph[i-1][j-1] = 1ならば頂点i,jは連結している
for a, b in sides:
    graph[a-1][b-1] = True
    graph[b-1][a-1] = True 

# pprint.pprint(graph)

for a, b in sides:
    # 辺の削除
    graph[a-1][b-1] = False
    graph[b-1][a-1] = False

    for i in range(n):
        visited[i] = False
    
    dfs(0)

    # 探索実行後訪れていないノードが1つでもあれば
    # 削除した辺は橋である
    for i in range(n):
        if visited[i] == False:
            ans += 1
            break

    # 辺を元に戻す
    graph[a-1][b-1] = True
    graph[b-1][a-1] = True

print(ans)


Measured memory_bytes: 6972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

const int MAX = 510000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
  ll N,M,K;cin >> N >> M >> K;
  COMinit();

  ll N_ = 0, M_ = 0;
  int i;
  REP(i,N-1){
    N_ += ((i+1)*(N-1-i))%MOD;
    N_ %= MOD;
  }

  REP(i,M-1){
    M_ += ((i+1)*(M-1-i))%MOD;
    M_ %= MOD;
  }

  ll combi = COM(N*M-2,K-2)%MOD;
  
  ll r1 = 0, r2 = 0, ans = 0;
  r1 = (combi*M_)%MOD;
  r1 *= N;
  r1 %= MOD;
  r1 *= N;
  r1 %= MOD;

  r2 = (combi*N_)%MOD;
  r2 *= M;
  r2 %= MOD;
  r2 *= M;
  r2 %= MOD;

  ans = (r1+r2)%MOD;
  cout << ans << endl;
  return 0;
}


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

int cnt=0;

void merge(int n,int a[],int f,int m,int c){
	int n1=m-f+1;
	int n2=c-m;
	vector<int> L;
	vector<int> R;
	int i,j;
	for(i=0;i<n1;i++){L.push_back(a[f+i]);}
	for(i=0;i<n2;i++){R.push_back(a[m+i+1]);}
	L.push_back(1<<30);
	R.push_back(1<<30);
	i=j=0;
	for(int k=f;k<=c;k++){
		if(L[i]<R[j]){
			a[k]=L[i++];
		}else{
			a[k]=R[j++];
		}
		cnt++;
	}
}

void mergeSort(int n, int a[], int i, int j){
	if(i<j){
		int mid=i+(j-i)/2;
		mergeSort(n,a,i,mid);
		mergeSort(n,a,mid+1,j);
		merge(n,a,i,mid,j);
	}
}

void mergeSort(int n, int a[]){
	mergeSort(n,a,0,n-1);
}

int main(){

	int n, a[500000];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	mergeSort(n,a);
	cout << a[0];
	for(int i=1;i<n;i++){
		cout << " " << a[i];
	}
	cout << endl;
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 7348
<?php


[$N, $X, $M] = fscanf(STDIN, "%d%d%d");

$list = [];
$sum = array_fill(0,100000,0);
$N--;
$ans = $X;
$sum[0] = $X;
$list[$X] = 0;
$now = 1;
$n = $X;
while($N--){
    $n = ($n * $n) % $M;
    if(isset($list[$n])){
        $zan = $N + 1;
        $per = $zan % ($now - $list[$n]);
        $mul = intdiv($zan,  ($now - $list[$n]));
        $ans += $mul * ($sum[$now-1] - $sum[$list[$n] -1]);
        $ans += $sum[$list[$n] -1 + $per] - $sum[$list[$n] -1];
        echo $ans;
        exit;
    }else{
        if($n === 0){
            echo $ans;
            exit;
        }
        $list[$n] = $now;
        $ans += $n;

        $sum[$now] = $ans;
        $now++;
    }
}
echo $ans;

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

using namespace std;

int main(){
  int A, B, K; cin >> A >> B >> K;
 
  vector<int> d;
  d.push_back(0);
  
  int denominator=1;
  do{
    if(A%denominator==0 && B%denominator==0){
      d.insert(d.begin(),denominator);
    }
    denominator++;
  }while(denominator <= A && denominator <= B);
  
  cout << d[K-1] << endl;
  
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int con = 0, fuga = 0;
	int N, D, A;
	vector<int> x;
	vector<pair<int,int>> in;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> hoge;
	
	cin>>N>>D>>A;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].first>>in[i].second;
	}
	
	sort(in.begin(), in.end());
	
	for(int i = 0; i < N; i++){
		int c = 0;
		
		for(;hoge.size();){
			pair<int,int> p = hoge.top();
			
			// cout<<p.first<<" >= "<<in[i].first<<endl;
			if(p.first >= in[i].first) break;
			else {
				fuga -= p.second;
				hoge.pop();
			}
		}
		// cout<<"i = "<<i<<" "<<fuga<<endl;
		in[i].second -= fuga;
		
		if(in[i].second >= 0) c = (in[i].second + A - 1)/ A;
		// cout<<"c = "<<c<<endl;
		con += c;
		
		hoge.push({in[i].first + D * 2, A * c});
		fuga += A * c;
	}
	
	cout<<con<<endl;
	
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	int a[1000];

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

	sort(a, a+n);

	printf("%d\n", (a[n-1]-a[0]));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>


using namespace std;


int main() {
	long n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	int* front = new int[k+2];
	int* back = new int[k+2];
	front[0] = back[0] = -c-1;
	front[k + 1] = back[k + 1] = n +c;
	for (int i = 1;i <= k;i++) {
		for (int j = front[i - 1] + c+1;;j++) {
			if (s[j] == 'o') {
				front[i] = j;
				break;
			}
		}
		for (int j = back[k - i + 2] - c-1;;j--) {
			if (s[j] == 'o') {
				back[k-i+1] = j;
				break;
			}
		}
	}
	for (int i = 1;i <= k;i++) {
		if (front[i] == back[i]) {
			cout << front[i]+1 << "\n";
		}
	}


}


Measured memory_bytes: 3332
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a==1 && b==2 || a==2 && b==1)
  {
    cout<<"3";
  }
  else if(a==1 && b==3 || a==3 && b==1)
  {
    cout<<"2";
  }
  else
  {
    cout<<"1";
  }
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N, K; cin >> N >> K;
    ll ans = 0, now = 1;
    while(now <= N){
        now *= K;
        ans++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 1000

void Print(int A[MAX],int N)
{
    for(int i = 0;i < N;i++) {
        if(i == N-1)
            printf("%d",A[i]);
        else
            printf("%d ",A[i]);
    }
    printf("\n");
}

void insertionSort(int *A,int N)
{
    for(int i = 1;i < N;i++) {
        int v = A[i];
        int j = i-1;
        while(j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        Print(A,N);
    }
}


int main()
{
    int A[MAX];
    int n;

    scanf("%d",&n);
    for(int i = 0;i < n;i++) {
        scanf("%d",&A[i]);
    }
    Print(A,n);
    insertionSort(A,n);
    return 0;
}



Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++) 
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
	string S,T;
	cin >> S >> T;
  int ans = 0;
  for(auto e:{0,1,2}){
    if(S[e] == T[e]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *
from bisect import *

A = input()[:-1]
K = [0]*(len(A)) #K[i]: A[i+1:]の部分列に含まれない最小の文字列の長さ
s = set()
cnt = 1

for i in range(len(A)-1, -1, -1):
    K[i] = cnt
    s.add(A[i])
    
    if len(s)==26:
        cnt += 1
        s = set()

d = defaultdict(list)

for i in range(len(A)):
    d[A[i]].append(i)

ans = []
now = -1

for i in range(cnt):
    for alpha in 'abcdefghijklmnopqrstuvwxyz':
        idx = bisect_right(d[alpha], now)
        
        if idx==len(d[alpha]):
            ans.append(alpha)
            break
        
        nex = d[alpha][idx]
        
        if K[nex]==cnt-i-1:
            now = nex
            ans.append(alpha)
            break

print(''.join(ans))

Measured memory_bytes: 50124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int[] ary1 = new int[3];
    	int[] ary2 = new int[3];
    	int[] ary3 = new int[3];
    	for(int i = 0; i < 3; i++){
    		ary1[i] = sc.nextInt();
    	}
    	for(int i = 0; i < 3; i++){
    		ary2[i] = sc.nextInt();
    	}
    	for(int i = 0; i < 3; i++){
    		ary3[i] = sc.nextInt();
    	}
    	int n = sc.nextInt();
    	for(int i = 0; i < n; i++){
    		int b = sc.nextInt();
    		for(int j = 0; j < 3; j++){
        		if(ary1[j] == b){
        			ary1[j] = 0;
        		}
        		if(ary2[j] == b){
        			ary2[j] = 0;
        		}
        		if(ary3[j] == b){
        			ary3[j] = 0;
        		}
        	}
    	}
    	sc.close();
    	if(ary1[0] == 0 && ary1[1] == 0 && ary1[2] == 0){
    		System.out.println("Yes");
    	}else if(ary2[0] == 0 && ary2[1] == 0 && ary2[2] == 0){
    		System.out.println("Yes");
    	}else if(ary3[0] == 0 && ary3[1] == 0 && ary3[2] == 0){
    		System.out.println("Yes");
    	}else if(ary1[0] == 0 && ary2[0] == 0 && ary3[0] == 0){
    		System.out.println("Yes");
    	}else if(ary1[1] == 0 && ary2[1] == 0 && ary3[1] == 0){
    		System.out.println("Yes");
    	}else if(ary1[2] == 0 && ary2[2] == 0 && ary3[2] == 0){
    		System.out.println("Yes");
    	}else if(ary1[0] == 0 && ary2[1] == 0 && ary3[2] == 0){
    		System.out.println("Yes");
    	}else if(ary1[2] == 0 && ary2[1] == 0 && ary3[0] == 0){
    		System.out.println("Yes");
    	}else{
    		System.out.println("No");
    	}
    }
}

Measured memory_bytes: 21716
/** 
 * THIS IS CFMASTER'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

const int MAX = 1010;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << (s[0] == s[1] && s[1] == s[2] ? "No" : "Yes") << '\n';
  return 0;
}

Measured memory_bytes: 256
rules = ['dream', 'dreamer', 'erase', 'eraser']

s = input()
stack = [0]
mem = [0 for _ in range(len(s)+1)]
ok = False
while len(stack) > 0:
    start_id = stack.pop()
    string = s[start_id:]
    if start_id == len(s):
        print('YES')
        ok = True
        break

    for rule in rules:
        if string.startswith(rule):
            next_start_id = start_id + len(rule)
            if next_start_id <= len(s):
                part = string[next_start_id:]
                if mem[next_start_id] == 0:
                    stack.append(next_start_id)
                    mem[next_start_id] = 1
if not ok:
    print('NO')

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

int main() {
  ll n,k; cin >> n >> k;
  vector<ll>v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  ll sum = 0;
  rep(i,n-k) sum+=v[i];
  cout << sum << endl;
    
  return 0;
}

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

#define llint long long int

using namespace std;

int main()
{
    int N, K;

    cin >> N >> K;

    vector<int> A(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    auto it = max_element(A.begin(), A.end());

    int left = 1;
    int right = A[it - A.begin()];

    while (left + 1 < right)
    {
        int center = (left + right) / 2;
        int count = 0;

        for (int i = 0; i < N; i++)
        {
            count += (A[i] + center - 1) / center - 1;
        }
        if (count <= K)
        {
            right = center;
        }
        else
        {
            left = center;
        }
    }
    int center = left;
    int count = 0;

    for (int i = 0; i < N; i++)
    {
        count += (A[i] + center - 1) / center - 1;
    }
    if (count <= K)
    {
        cout << left << endl;
    }
    else
    {
        cout << right << endl;
    }
}

Measured memory_bytes: 4044
// 2020-09-19 19:47:09
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
int dp[100010];
void answer() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  REP(i, 2, n) {
    dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
    chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << '\n';
}

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

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

int main() {
	ll K;
	cin >> K;

	queue<ll> q;

	for (ll i = 1; i <= 9; i++) q.push(i);

	for (ll i = 1; i <= K; i++) {
		ll front = q.front();
		q.pop();

		if (i == K) cout << front << endl;


		if ((front % 10) == 9) {
			ll a = 10 * front + (front % 10 - 1);
			ll b = 10 * front + front % 10;
			q.push(a); q.push(b);
		}
		else if ((front % 10) == 0) {
			ll a = 10 * front + front % 10;
			ll b = 10 * front + (front % 10 + 1);
			q.push(a); q.push(b);
		}
		else {
			ll a = 10 * front + (front % 10 - 1);
			ll b = 10 * front + front % 10;
			ll c = 10 * front + (front % 10 + 1);
			q.push(a); q.push(b); q.push(c);
		}
	}

	return 0;

}


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

int main()
{
    long long n,i,j,k,yen=1000,stock=0;
    cin>>n;
    long long a[100];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n-1;i++){if(a[i+1]==a[i])continue;
        if(a[i+1]>a[i]){
            long long ns=yen/a[i];
            stock+=ns;
            yen=yen-ns*a[i];
        }
        else{
            yen=yen+stock*a[i];
            stock=0;
        }
        //cout<<yen<<" "<<stock<<endl;
    }
    yen+=stock*a[n-1];
    cout<<yen;
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*; 
import java.lang.*;

public class Main 
{   
    static long[] A;
    static long[][] dp;
    
    static long fn(int i, int j, int c) {
        if (i > j) { return 0; }
        if (dp[i][j] != -1) { return dp[i][j]; }
        if (c == 0) {
            dp[i][j] = Math.max(A[i] + fn(i+1, j, 1), A[j] + fn(i, j-1, 1));
        }
        else {
            dp[i][j] = Math.min(-A[i] + fn(i+1, j, 0), -A[j] + fn(i, j-1, 0));
        }
        return dp[i][j];
    }
    
    public static void main(String[] args) throws IOException 
    {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        A = new long[N];
        for (int n =0; n < N; n ++) {
            A[n] = scan.nextLong();
        }
        dp = new long[N][N];
        for (int i =0; i < N; i ++) {
            for (int j = 0; j < N; j ++) {
                dp[i][j] = -1;
            }
        }
        System.out.println(fn(0, N-1, 0));
    }
}    

Measured memory_bytes: 131716
#include <cstdio>
#include <iostream>
#define MN 266666

int n, v;
int a[MN];
int f[MN], g[MN];
int b[MN];
int nxt[20][MN];
int lst[20][MN];

int main()
{
	scanf("%d%d", &n, &v);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int x = v;
	int m = 0;
	while(x) {b[m++] = x / 2; x /= 2;}
	b[m] = v;
	
	for(int i = 0; i <= m; i++)
	{
		lst[i][1] = 1;
		for(int j = 2; j <= n; j++)
		{
			if(a[j] - a[j - 1] <= b[i]) lst[i][j] = lst[i][j - 1];
			else lst[i][j] = j;
		}
	}
	
	int tot = 0;
	for(int i = 0; i <= m; i++)
	{
		nxt[i][n] = n;
		for(int j = n - 1; j >= 1; j--)
		{
			if(a[j + 1] - a[j] <= b[i]) nxt[i][j] = nxt[i][j + 1];
			else {nxt[i][j] = j; if(i == m) tot++;}
		}
	}
	
	if(m < tot) 
	{
		for(int i = 1; i <= n; i++) puts("Impossible");
		return 0;
	}
	
	for(int S = 0; S < (1 << m); S++) g[S] = n + 1; 
	for(int S = 0; S < (1 << m); S++)
	{
		for(int i = 0; i < m; i++)
		{
			if(!((S >> i) & 1))
			{
				f[S | (1 << i)] = std::max(f[S | (1 << i)], nxt[i][f[S] + 1]);
				g[S | (1 << i)] = std::min(g[S | (1 << i)], lst[i][g[S] - 1]);
			}
		}
	}
	
	for(int i = 1; i <= n; i++)
	{
		bool ok = 0;
		for(int S = 0; S < (1 << m); S++)
		{
			int T = ((1 << m) - 1) ^ S;
			if(f[S] >= i - 1 && g[T] <= nxt[m][i] + 1) {ok = 1; break;}
		}
		for(int j = i; j <= nxt[m][i]; j++)
		{
			if(ok) puts("Possible");
			else puts("Impossible");
		}
		i = nxt[m][i];
	}
}

Measured memory_bytes: 47488
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,k,cc[50000][20],dd[500000],a,b;
char s[500000];
int main(){
	for (int i=1;i*i<=50000;i++) dd[i*i]=1; 
	scanf("%d%d",&n,&a);
	for (int i=0;i<n;i++){
		for (int j=0;j<a;j++) scanf("%d",&cc[i][j]);
	}
	for (int i=0;i<n;i++){
		for (int j=i+1;j<n;j++){
			b=0;
			for (int k=0;k<a;k++) b+=(cc[i][k]-cc[j][k])*(cc[i][k]-cc[j][k]);
			if (dd[b]) m++;
		}
	}
	printf("%d\n",m);
	return 0;
} 

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

int gcd(int a, int b);
int gcd(const std::vector<int>& arr);

int main() {

        int n = 0;
        std::cin >> n;
        std::vector<int> w(n);
        int sum = 0;

        for (auto& v : w) {
                std::cin >> v;
                sum += v;
        }

        int ret = std::numeric_limits<int>::max();

        int det = 0;
        for (const auto& v : w) {
                det += v;
                sum -= v;
                auto t = std::abs(sum - det);
                if (t < ret) {
                        ret = t;
                }
        }

        std::cout << ret << std::endl;

        return 0;
}

int gcd(int a, int b) {
        if (a > b) {
                std::swap(a, b);
        }

        for (int r = b % a; r != 0; b = a, a = r, r = b % a)
                ;

        return a;
}

int gcd(const std::vector<int>& arr) {
        const int size = arr.size();
        if (size == 0) {
                return 0;
        }
        else if (size == 1) {
                return arr[0];
        }

        int ret = gcd(arr[0], arr[1]);

        for (std::size_t i = 2; i < size && ret != 1; ++i) {
                ret = gcd(arr[i], ret);
        }

        return ret;
}



Measured memory_bytes: 256
from collections import deque

N=int(input())
array=deque()
for n in range(N):
    bun=input()
    if bun=='deleteFirst':
        del array[0]
    elif bun=='deleteLast':
        del array[-1]
    else:
        order,num=bun.split()
        if order=='insert':
            array.insert(0,num)
        else:
            try:array.remove(num)
            except:pass
print(' '.join(array))



Measured memory_bytes: 69732
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


void check()
{
	ll n, k, ans = 0;
	cin >> n >> k;
	vl p(n);
	for(int i=0;i<n;i++) cin >> p[i];
	sort(p.begin(),p.end());
	for(int i=0;i<k;i++) ans+=p[i];
	cout << ans << endl;
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>

#define ll long long

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N,0);
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    vector<int> dp(N,0);
    dp[1]=abs(vec[1]-vec[0]);
    for(int i=2;i<N;i++){
        dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static class Task {
        public void solve(InputReader in, PrintWriter out) {
        	int a = in.nextInt();
        	if(a == 5 || a == 3 || a == 7)
        		out.println("YES");
        	else
        		out.println("NO");
        }
    }
	
    public static void main(String argds[]) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
 
        public long nextLong() {
            return Long.parseLong(next());
        }
    }	
}

Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	string s, t;
	cin >> N >> s >> t;
	string ans = s, tmp = s;
	int j = N;
	for (int i = 0; i <= N; i++) {
		ans = tmp;
		ans += t.substr(j, i);
		if (ans.substr(i, N) == t) {
			break;
		}
		j--;
	}		
	cout << ans.size() << endl;
}

Measured memory_bytes: 256
let powers =
    let rec loop b v l =
        if v <= 1000 then loop b (v * b) (v :: l)
        else
            let b' = b + 1 in
            if b' * b' <= 1000 then loop b' (b' * b') l
            else l
    in 1 :: loop 2 4 []

let () =
    let x = read_int () in
    List.filter ((>=) x) powers
    |> List.fold_left max 1
    |> string_of_int
    |> print_endline


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 2005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K,Q;
int a[MAXN],val[MAXN],tot;

bool check(int mid) {
    for(int i = 1 ; i <= tot ; ++i) {
	int l = val[i],r = val[i] + mid;
	int res = 0,st = 0,ed = -1,cnt = 0;
	for(int j = 1 ; j <= N ; ++j) {
	    if(a[j] >= l) {
		if(!st) st = ed = j;
		ed = max(ed,j);
		if(a[j] <= r) ++cnt;
	    }
	    else {
		if(ed - st + 1 >= K) {
		    res += min(cnt,(ed - st + 1) - K + 1);
		}
		st = 0,ed = -1;cnt = 0;
	    }
	}
	if(ed - st + 1 >= K) {
	    res += min(cnt,(ed - st + 1) - K + 1);
	}
	if(res >= Q) return true;
    }
    return false;
}
void Init() {
    read(N);read(K);read(Q);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	val[i] = a[i];
    }
    sort(val + 1,val + N + 1);
    tot = unique(val + 1,val + N + 1) - val - 1;
    
}
void Solve() {
    int L = 0,R = val[tot] - val[1];
    while(L < R) {
	int mid = (L + R) >> 1;
	if(check(mid)) R = mid;
	else L = mid + 1;
    }
    out(L);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
  ll n,k;
  cin >> n >> k;
  n = n - n/k*k;
  ll t = 2000000000000000000;
  while(true){
    n = abs(n-k);
    if(t < n){
      cout << t << endl;
      return 0;
    }
    t = n;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <iterator>
#include <stack>
#include <deque>
#include <list>
#include <array>
#include <unordered_set>
#include <unordered_map>
using namespace std;
const int MOD = 1e9 + 7;
int main()
{
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n - 1];
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int p=998244353;
typedef long long ll;
int n,a[N],f[N]={0};
short int mu[N];
ll inv[N],w[N];
int main(){
    mu[1]=1;inv[1]=1;
    for(int i=2;i<N;i++)inv[i]=(p-p/i)*inv[p%i]%p;
    for(int i=1;i<N;i++)
    for(int j=i+i;j<N;j+=i)mu[j]-=mu[i];
    for(int i=1;i<N;i++)
    for(int j=i;j<N;j+=i)w[j]+=mu[j/i]*inv[i],w[j]=(w[j]%p+p)%p;
    cin>>n;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),f[a[i]]++;
    ll ans=0;
    for(int d=1;d<N;d++){
        ll res=0,ret=0;
        for(int i=d;i<N;i+=d){
            if(f[i]){
                ret+=1LL*i*((res*f[i]%p+1LL*f[i]*(f[i]-1)/2%p*i%p)%p)%p;
                res+=1LL*i*f[i]%p;
                ret%=p,res%=p;
            }
        }
        ans+=w[d]*ret%p;
        ans%=p;
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 22784
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define ff first
#define pi pair<int,int>
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

int32_t main() { 
    boost;
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=n;j++){
    		int tt = __gcd(i,j);
    		for(int k=1;k<=n;k++)
    			ans+=__gcd(tt,k);
    	}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
// Aizu Vol0 0024: Physical Experiments
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>

#define Magic   19.6
#define Epsilon 0.00001

int main()
{
	double v, y;
	long long y2, n;
	
	while (scanf("%lf", &v) == 1) {
		y = v*v;
		v = y;
		y = v / Magic;
		y2 = (long long)y;
		n = y2 / 5 + 2;

#if 0
		if (y2 % 5 == 0) {
			if (-Epsilon <= y-y2 && y-y2 <= Epsilon) n--;
		}
#endif
		printf("%lld\n", n);
	}
	return 0;
}

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

#define rep(i, x, n) for(int i=(x);i<(n);i++)
#define reps(i, x, n) for(int i=(x);i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
//八方向を見るのに使うと便利(楽)
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<lol> a, b, c;
  lol foo;
  reps(i, 1, n){
    cin >> foo;
    a.push_back(foo);
  }
  reps(i, 1, n){
    cin >> foo;
    b.push_back(foo);
  }
  reps(i, 1, n){
    cin >> foo;
    c.push_back(foo);
  }
  sort(all(a));
  sort(all(b));
  sort(all(c));
  lol b_sum[n + 5] = {};
  rep(i, 0, n){
    b_sum[i] = n - (upper_bound(all(c), b[i]) - c.begin());
  }
  for(int i = n - 1;i > 0;i --){
    b_sum[i - 1] += b_sum[i];
  }
  lol ans = 0;
  rep(i, 0, n){
    lol memo = upper_bound(all(b), a[i]) - b.begin();
    ans += b_sum[memo];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6656