akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int N = 1 << 19, mod = 1e9 + 7;

long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

long long mul[N], inv[N], val[N];

int p[N], h, n, leaf;

long long sum[N];

void add(int v, long long x) {
  while (v > 0) {
    sum[v] += x;
    if (sum[v] >= mod)
      sum[v] -= mod;
    v >>= 1;
  }
}

long long get(int v) {
  long long ret = 0;
  while (v > 1) {
    int par = v >> 1;
    ret = (ret + (sum[par] - sum[v]) * inv[par]) % mod;
    v = par;
  }
  if (ret < 0)
    ret += mod;
  return ret;
}

void upd(int v, int x) {
  if (v * 2 > n) {
    int u = p[v - leaf] + leaf;
    long long cur = val[v];
    if (x < 0)
      cur = (mod - cur) % mod;
    add(u, cur);
  } else {
    upd(v * 2, x);
    upd(v * 2 + 1, x);
  }
}

long long solve(int v) {
  if (v * 2 > n) return 0;
  long long ret = 0;
  int lef = v * 2, rig = v * 2 + 1;
  upd(lef, +1);
  int from = rig, til = rig;
  while (from * 2 <= n) {
    from = from * 2;
    til = til * 2 + 1;
  }
  for (int i = from; i <= til; ++i) {
    ret = (ret + get(p[i - leaf] + leaf) * val[i]) % mod;
  }
  ret = (ret * inv[v]) % mod;
  upd(lef, -1);
  ret = (ret + solve(lef) + solve(rig)) % mod;
  if (ret < 0)
    ret += mod;
  return ret;
}

int main() {
  scanf("%d", &h);
  leaf = (1 << (h-1));
  n = (1 << h) - 1;
  mul[1] = inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    mul[i] = mul[i / 2] * i % mod;
    inv[i] = powmod(mul[i], mod - 2);
    inv[i] = inv[i] * inv[i] % mod;
    inv[i] = inv[i] * i % mod;
  }
  for (int i = 0; i < leaf; ++i) {
    scanf("%d", p+i);
    --p[i];
    val[leaf + i] = mul[leaf + i] * mul[leaf + p[i]] % mod;
  }
  printf("%lld\n", solve(1));
  return 0;
}


Measured memory_bytes: 11484
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	string A, B;
	cin >> A >> B;
	int n=A.size();

	bool a[2010], b[6030];
	rep(i, n)
	{
		if(A[i]=='0') a[i]=0;
		else a[i]=1;
		if(B[i]=='0') b[i]=b[i+n]=b[i+2*n]=0;
		else b[i]=b[i+n]=b[i+2*n]=1;
	}
	int l[2010], r[2010];
	int left, right;
	bool muri=0;
	rep(i, n)
	{
		left=right=0;
		while(b[i+n-left]==0 && left<n)
		{
			left++;
		}
		while(b[i+n+right]==0 && right<n)
		{
			right++;
		}
		l[i]=left;
		r[i]=right;
		if(l[i]==n || r[i]==n) muri=1;
	}
	if(muri)
	{
		bool murii=0;
		rep(i, n)
		{
			if(a[i]==1)
			{
				murii=1;
				break;
			}
		}
		if(murii) cout << "-1" << endl;
		else cout << "0" << endl;
	}
	else
	{
		bool dif[2010];
		int ans=INF;
		int tmp1, tmp2;
		int ml, mr;
		rep(k, n)
		{
			vector<int> s[2010], t[2010];
			tmp1=0;
			rep(i, n)
			{
				if(a[i]!=b[i+k]) dif[i]=1, tmp1++;
				else dif[i]=0;
			}
			ml=mr=0;
			rep(i, n)
			{
				if(dif[i])
				{
					if(k<r[i])
					{
						ml=max(ml, l[i]);
						s[l[i]].push_back(r[i]-k);
					}
					if(n-k<l[i])
					{
						mr=max(mr, l[i]);
						t[r[i]].push_back(l[i]-(n-k));
					}
				}
			}
			tmp2=min(2*ml+k, 2*mr+(n-k));
			int rmm=0, lmm=0;
			for(int j=ml; j>0; j--)
			{
				rep(m, s[j].size()) rmm=max(rmm, s[j][m]);
				tmp2=min(tmp2, 2*(j-1)+k+2*rmm);
			}
			for(int j=mr; j>0; j--)
			{
				rep(m, t[j].size()) lmm=max(lmm, t[j][m]);
				tmp2=min(tmp2, 2*(j-1)+(n-k)+2*lmm);
			}
			ans=min(ans, tmp1+tmp2);
		}
		cout << ans << endl;
	}
	return 0;
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> n >> k;
    int a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    for(i=0; i<k; i++)
        s+=a[i];
    cout << s << endl;
}


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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string s;
  int ans = 0;
  while (cin >> s) {
    string tmp = s;
    reverse(ALL(tmp));
    if (s == tmp) ans++;
  }

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



Measured memory_bytes: 3060
object Main {
  def main(args: Array[String]) {
    val factor = scala.io.StdIn.readLine.split("")
    factor.foreach { c =>
        if(c == "1") {
          print("9")
        }
        else if(c == "9") {
            print("1")
        }
        else {}
    }
    println()
  }
}


Measured memory_bytes: 25564
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] a = new double[n];
        for(int i = 0; i<n; i++)
            a[i] = sc.nextDouble();
        double[][] dp = new double[n+1][n+1];
        dp[0][0] = 1;
        for(int i = 1; i<=n; i++)
            dp[i][0] = dp[i-1][0]*(1-a[i-1]);
        for(int i = 1; i<=n; i++) {
            for(int j = 1; j<=n; j++) {
                dp[i][j] = dp[i-1][j]*(1-a[i-1]);
                dp[i][j]+=dp[i-1][j-1]*a[i-1];
            }
        }
        double ans = 0;
        for(int i = n; i>=0; i--) {
            if(i>n-i)
                ans+=dp[n][i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 122480
n, a, b = gets.chomp.split.map(&:to_i)

sum = 0
(n+1).times do |i|
  check = i%10 + (i/10%10) + (i/100%10) + (i/1000%10) + (i/10000)
  sum += i if check >= a && check <= b
end
puts sum

Measured memory_bytes: 1788
import sys


def solve(inp):
    N = int(inp.readline())
    S = [inp.readline() for i in range(N)]
    M = int(inp.readline())
    T = [inp.readline() for i in range(M)]

    score = {}
    for s in S:
        if s not in score:
            score[s] = 0
        score[s] += 1
    for t in T:
        if t not in score:
            score[t] = 0
        score[t] -= 1

    m = max(0, max(score.values()))
    return str(m)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string z;
  int x=0;
  cin>>z;
  for(int y=0;y<4;y++){
    if(z.at(y)=='+') x++;
    else if(z.at(y)=='-') x--;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3604
def main()
  n = gets.chomp.to_i
  x = gets.chomp.split(' ').map(&:to_i).reverse
  b = Array.new(n)
  for i in 0..n-1
    if i.modulo(2) == 0
      b[i/2] = x[i]
    else
      b[n - 1 - (i/2)] = x[i]
    end
  end
  puts b.join(' ')
end

main()

Measured memory_bytes: 27240
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


from collections import deque

def main():
    ans = 0
    N, D = mis()
    for _ in range(N):
        x, y = mis()
        if x**2 + y**2 <= D**2:
            ans += 1
    print(ans)


main()



Measured memory_bytes: 9940
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
ll mod2=998244353;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactive problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll tot=0;
    ll fg=0;
    for (int i = 0; i < n; ++i)
    {
        ll a,b;
        cin>>a>>b;
        if(a==b){
            tot++;
        }
        else{
            tot=0;
        }
        if(tot==3){
            fg=1;
        }
    }

    if(fg==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}


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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int INF=INT_MAX;
const ld PI=3.1415926535897932384626433;
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

void solve();
int singleNonDuplicate(vector<int>& nums);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
 //   cin >> t;
   // while(t--)
        solve();
}
void solve() {
    int a,b;
    cin >> a >> b;
    cout << a*b << "\n";
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

constexpr int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// 高速nCk（n == 10**9まで対応）
mint nCk(int n, int k) {
  mint x = 1, y = 1;
  for (int i = 0; i < k; i++) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

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

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

  ll t1 = 0;
  ll t2 = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) {
        t1++;
      }
    }

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

  mint ans1 = mint(t1) * mint(k);
  mint ans2 = mint(t2) * nCk(k, 2);

  mint ans = ans1 + ans2;

  cout << ans.x << ln;

  return 0;
}

Measured memory_bytes: 256
K = int(input())
top = 1
cand = [i for i in range(1,10)]

def dfs(s, c):
    global cand
    if c==0:
        cand.append(int(s))
        return
    if s[-1]=='0':
        dfs(s+str(0), c-1)
        dfs(s+str(1), c-1)
    elif s[-1]=='9':
        dfs(s+str(8), c-1)
        dfs(s+str(9), c-1)
    else:
        dfs(s+str(int(s[-1])-1), c-1)
        dfs(s+str(int(s[-1])), c-1)
        dfs(s+str(int(s[-1])+1), c-1)
        
flag = False
while True:
    for i in range(1,10):
        if len(cand)>1e5:
            flag = True
            break
        dfs(str(i) ,top)
    if flag:
        break
    top+=1
print(cand[K-1])

Measured memory_bytes: 49496
#include <ios>
#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);

	long n, r, k, d = LONG_MIN, min_r, i;
	cin >> n >> min_r;
	for(i = 1; i < n; ++i){
		cin >> r;
		k = r - min_r;
		if( k > d )
			d = k;
		if( r < min_r )
			min_r = r;
	}
	
	cout << d << "\n";

	return 0;
}

Measured memory_bytes: 1200
P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[j] = cur[j] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)


Measured memory_bytes: 44668
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    int[int] t;
    int[] p;
    for(string s; "0,0"!=(s=readln().chomp()); )
    {
        auto m = s.split(",").map!(to!int).array();
        t[m[0]]=m[1];
        p~=m[1];
    }
    int[int] r;
    foreach(int i,v;p.sort!"a>b"().uniq().array()) r[v]=i+1;
    stdin.byLine().map!(s=>r[t[s.to!int()]].to!string()).join("\n").writeln();
}

Measured memory_bytes: 1132
import numpy as np
N = int(input())
a = np.array(list(map(int,input().split())), dtype=np.int32)
a = np.sort(a)
b = np.diff(a)
c = np.array([2,0]*(N//2), dtype=np.int32)
if N%2==0:
    c = np.array([0] + [2,0]*((N-1)//2), dtype=np.int32)
# print(b,c)
if (b==c).all():
    res = (pow(2, (N-1)//2, 10**9+7) * ((N+1)%2+1)) % (10**9+7)
    print(res)
else:
    print(0)

Measured memory_bytes: 23384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <functional>

using namespace std;
typedef long long ll;

ll K;
string S;
vector<ll> a;

const ll MOD = 1e9 + 7;

ll power(ll a, ll b)
{
    ll ret = 1;
    while(b)
    {
        if(b&1)
        {
            ret = (ret * a) % MOD;
        }
        a = (a * a) % MOD;
        b /= 2;
    }
    return ret;
}

ll fact(ll f)
{
    ll a = 1;
    for(ll i = 0;i < f;i++)
    {
        a = a * (f-i);
        a %= MOD;
    }
    return a;
}

int main()
{
    cin >> K >> S;
    ll SL = S.length();

    ll x = fact(SL-1);
    ll y = power(fact(SL-1), MOD-2);
    ll z = 1; // 1/(N-k)!

    ll sum = 0;
    for(ll i = SL;i <= SL+K;i++)
    {
        // i-1C|S|-1
        ll a = x * y % MOD;
        a = a * power(z, MOD-2) % MOD;
        x = x * i % MOD;
        z = z * (i+1-SL) % MOD;

        ll X25 = power(25, i-SL);
        ll X26 = power(26, K-(i-SL));
        ll XX = X25 * X26 % MOD;

        sum += (a * XX % MOD);
        sum %= MOD;
        X25 *= (i+1-SL);
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int main(void){
    long long q, h, s, d;
    cin >> q >> h >> s >> d;
    
    long long n;
    cin >> n;
    
    long long ans = 0;
    
    if (n % 2 == 0){
        
        ans += min( 4*q*n, min( 2*h*n, min( n*s,d*n/2 ) ) );
    }
    else{
        long long temp = n - 1;
        
        ans += min( 4*q*temp, min( 2*h*temp, min( temp*s, d*temp/2 ) ) );
        ans += min(4*q, min( 2*h, s ) );
    }
    cout << ans << endl;
}


Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
	long long int t,a[9];
	int i,j;
	scanf("%lld %lld %lld %lld %lld %lld %lld %lld %lld %lld",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
	for(i=0;i<10;i++)
	{
		for(j=0;j<9-i;j++)
		{
	   	if(a[j]<a[j+1])
  		{
			t=a[j];
			a[j]=a[j+1];
			a[j+1]=t;
	   	}
		}
	}
	printf("%lld\n%lld\n%lld\n",a[0],a[1],a[2]);
	return 0;
}

Measured memory_bytes: 600
use std::io;

fn main(){
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let c : Vec<char> = s.chars().collect();
    let mut f = true;
    for i in 0..3{
        if c[i] == c[i + 1]{
            f = false;
        }
    }
    let ans = if f {"Good"} else {"Bad"};
    println!{"{}", ans};
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int[][] bingo = new int[3][3];
		for(int i = 0;i < 3;i++) {
			for(int j = 0;j < 3;j++) {
				bingo[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();

		for(int i = 0; i < n;i++) {
			int number = sc.nextInt();
			for(int j = 0;j < 3;j++) {
				for(int k = 0;k < 3;k++) {
					if(bingo[j][k] == number) {
						bingo[j][k] = 0;
					}
				}
			}
		}

		for(int i = 0; i < 3; i++) {
			if(bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0) {
				System.out.println("Yes");
				return;
			}
		}
		for(int i = 0; i < 3; i++) {
			if(bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0) {
				System.out.println("Yes");
				return;
			}
		}
		if(bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0) {
			System.out.println("Yes");
			return;
		}

		if(bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");

	}
}

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

using namespace std;

#define Unknown ios_base::sync_with_stdio(0);ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);

#define fo(i, a, n) for(int i{ (int) (a) };i < (int)(n);i++)


int main(){
    Unknown
    int n{}, l{};
    cin >> n >> l;
    string str[n], tmp{};

    fo(i, 0, n){
        cin >> str[i];
    }

    sort(str, str + n);

    fo(i, 0, n){
        tmp += str[i];
    }

    cout << tmp;

    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
l = [0]*h
for i in range(h):
  l[i] = str(input())
  
dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
  for j in range(w):
    if i+1 < h and l[i+1][j] == '.':
      dp[i+1][j] += dp[i][j]
    if j+1 < w and l[i][j+1] == '.':
      dp[i][j+1] += dp[i][j]
      
print(dp[-1][-1]%(10**9+7))

Measured memory_bytes: 217464
#include<stdio.h>
#include<string.h>
#define LL long long
using namespace std;

const LL mod = 1e9 + 7;
LL dp[100];
char s1[100], s2[100];
int main()
{
    int n;
    scanf("%d", &n);
    getchar();
    scanf("%s",s1+1);
    scanf("%s",s2+1);
    dp[0] = 1;

    for (int i = 1; i <= n; i++) {
        if (s1[i] == s2[i]) {
            if (i == 1)
                dp[i] = (dp[i] + dp[i - 1] * 3) % mod;
            else if (s1[i - 1] == s2[i - 1])
                dp[i] = (dp[i] + dp[i - 1] * 2) % mod;
            else
                dp[i] = (dp[i] + dp[i - 1]) % mod;
        }
        if (s1[i] == s1[i - 1] && s2[i] == s2[i - 1]) {
            if (i == 2)
                dp[i] = (dp[i] + 6) % mod;
            else if (s1[i - 2] == s2[i - 2])
                dp[i] = (dp[i] + dp[i - 2] * 2) % mod;
            else
                dp[i] = (dp[i] + dp[i - 2] * 3) % mod;
        }
    }
    printf("%lld\n", dp[n] % mod);
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, a[55];
    long long ans = 0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            ans += a[i] * a[j];
        }
    }

    cout << ans << '\n';
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  if ((x >= 0) && (y >= x)){
    cout << (y-x);
  }else if ((x >= 0) && (y < x)){
    if (y >= 0){
      cout << min(x-y+2,y-(-x)+1);
    }else if (y >= (-x)){
      cout << (y-(-x)+1);
    }else{
      cout << (-y-x+1);
    }
  }else if ((x < 0) && (y >= x)){
    if (y <= 0){
      cout << (y-x);
    }else if (y > (-x)){
      cout << min(y-x,y-(-x)+1);
    }else{
      cout << min(y-x,(-x)-y+1);
    }
  }else if ((x < 0) && (y < x)){
    cout << (x-y+2);
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Calc
 * 整数 a が入力されます。
 * 値 a+a2+a3 を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        int a = sc.nextInt();

        System.out.println( ( int ) ( a + Math.pow( a, 2) + Math.pow( a, 3 ) ) );

        sc.close();
    }
}


Measured memory_bytes: 35960
import java.util.*;
public class Main {
	
	static int mod = (int)1e9+7;
	
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(); //pの個数
		
		int p[] = new int[n];  //{ 0, 0, 0, 0, 0, 0}  n個の配列 
		for(int i=0;i<n;i++) {
			p[i] = sc.nextInt();
		}
		sc.close();
		
		int cnt = 0;
		
		for(int i=0;i<n;i++) {
			if (i+2 >= n) break;
			int x1 = p[i];
			int x2 = p[i+1];
			int x3 = p[i+2];
			
			if( ((x1>=x2)&&(x2>x3)) || (x3>=x2)&&(x2>x1)) cnt++;
			
		}
		
		System.out.println(cnt);
		
	}
	
}

Measured memory_bytes: 21844
N, A, B = map(int, input().split())

ans = 0

for i in range(1, N+1):
    str_num = str(i)
    digit_sum = 0
    for c in str_num:
        n = int(c)
        digit_sum += n
    if digit_sum >= A and digit_sum <= B:
        ans += i

print(ans)


Measured memory_bytes: 39920
import itertools

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

for i in range(Q):
	series.append(list(map(int,input().split())))

A = [x for x in range(1,M+1)]

max_score = 0
for a in itertools.combinations_with_replacement(A,N):
	score = 0
	for s in series:
		if (a[s[1]-1] - a[s[0]-1]) == s[2]:
			score += s[3]

	if score > max_score: max_score = score

print(max_score)

Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int a[5],b[5],i,j;
	for(i=0;i<3;i++) cin>>a[i];
	for(j=0;j<2;j++) cin>>b[j];
	sort(a,a+3); sort(b,b+2);
	cout<<(a[0]+b[0])-50<<endl;
	return 0;
}


Measured memory_bytes: 3160
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		char[] pur = sc.next().toCharArray();
		
		int count = 0;
		for(int i = 0; i < N; i++){
			char[] input = sc.next().toCharArray();
			
			boolean flag = false;
			
			SUC:
			for(int j = 0; j < input.length; j++){
				if(input[j] != pur[0]){
					continue;
				}
				
				LOOP:
				for(int k = 0; j + (k + 1) * (pur.length - 1) < input.length; k++){
					
					for(int pos = 1; pos < pur.length; pos++){
						if(input[j + pos * (k + 1)] != pur[pos]){
							continue LOOP;
						}
					}
					
					flag = true;
					break SUC;
				}
			}
			

			if(flag){
				count++;
			}
		}
		
		
		System.out.println(count);
	}

}

Measured memory_bytes: 19944
//
// Created by kuroneko on 2019-09-28.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i]--;

        b[a[i]] = i + 1;
    }

    for (int i = 0; i < N; i++) {
        cout << b[i];
        if (i != N - 1) cout << " ";
        else cout << endl;
    }

    return 0;

}


Measured memory_bytes: 1664
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    k,n=parseMap(split(readline()))
    a=sort(parseMap(split(readline())))
    dif=[0 for i in 1:n]
    for i in 2:n
        dif[i]=a[i]-a[i-1]
    end
    dif[1]=k-a[end]+a[1]
    m=findmax(dif)[2]
    ans=0
    for i in m+1:n
        ans+=a[i]-a[i-1]
    end
    if m!=1
        ans+=k-a[end]+a[1]
        for i in 2:m-1
            ans+=a[i]-a[i-1]
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 129488
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1000000000
for i in range(n-k+1):
    if x[i+k-1] < 0:
        ans = min(ans, -x[i])
    elif x[i] < 0 <= x[i+k-1]:
        ans = min(ans, -2*x[i]+x[i+k-1])
        ans = min(ans, -x[i]+2*x[i+k-1])
    else: ans = min(ans, x[i+k-1])
print(ans)

Measured memory_bytes: 14384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderMake
{
    class ABC086A
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select((x) => int.Parse(x));
            if (a.Count((x) => x%2 == 0) > 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<double> p(N);
  REP(i, N) cin >> p[i];
  
  // dp[i][j]: i枚目までで表が出るのがj枚の確率
  vector<vector<double>> dp(N+1, vector<double>(N+1, 0.0));
  dp[0][0] = 1.0;
  REP(i, N){
    REP(j, i+1){
      dp[i+1][j+1] += dp[i][j]*p[i];
      dp[i+1][j]   += dp[i][j]*(1.0-p[i]);
    }
  }

  double ans = 0.0;
  for(int j = N/2+1; j <= N; j++){
    ans += dp[N][j];
  }

  printf("%.9f\n", ans);

  return 0;
}

Measured memory_bytes: 70656
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        if(m<20)System.out.println(0);
        else{
            int ans=0;
            for(int i=20;i<=m;i++){
                int po=i%10;
                int popo=i/10;
                if(po*popo<=n&&2<=po*popo&&po>=2){
                    ans++;
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1 || w==1){
    cout<<1;
  }else if(h*w%2==0){
    cout<<h*w/2;
  }else{
    cout<<(h*w+1)/2;
  }
}


Measured memory_bytes: 256
a = input()
l = a.split()
n = int(l[0])
k = int(l[1])
b = input()
ll = b.split()
for i in range(0,n):
    ll[i] = int(ll[i])
if n<k+1:
    print(0)
else:
    p = 0
    ll.sort()
    for i in range(0,n-k):
        p = p + ll[i]
    print(p)


Measured memory_bytes: 20632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
	char ss[55] = {}, t[55] = {};
	int i, j, lens, lent, ans = -1;
	scanf("%s\n%s", ss, t);
	lens = strlen(ss);
	lent = strlen(t);
	for (i = lens-lent; i >= 0; i--)
	{
		for (j = 0; j < lent; j++)
		{
			if (ss[i + j] != t[j] && ss[i + j] != 0x3f) {
				break;
			}
		}
		if (j == lent)
		{
			ans = i;
			break;
		}
	}
	if (ans != -1) {
		for (i = 0; i < ans; i++)
		{
			if (ss[i] == 0x3f) {
				ss[i] = 'a';
			}
		}
		for (i = ans; i < ans+lent; i++)
		{
			if (ss[i] == 0x3f) {
				ss[i] = t[i-ans];
			}
		}
		for (i = ans+lent; i < lens; i++)
		{
			if (ss[i] == 0x3f) {
				ss[i] = 'a';
			}
		}
		printf("%s", ss);
	}
	else
	{
		printf("UNRESTORABLE");
	}
	return 0;
}

Measured memory_bytes: 128
A, B, K = map(int, input().split())
if A+K <= B-K:
    for i in range(A, A+K):
        print(i)
        # print(A+K, B-K, i)
    for i in range(B-K+1, B+1):
        print(i)
else:
    for i in range(A, B+1):
        print(i)

Measured memory_bytes: 38384
s = list(input())
n = len(s); flag= 0
if s == s[::-1]:    flag += 1 ;
start, end = 0, ((n-1)//2)-1
while(end > start and flag == 1):
    if not(s[start] == s[end]):        break;
    start += 1 ; end -= 1
else:    flag += 1
start, end = (n+3)//2 -1, (n-1)
while(end > start and flag == 2):
    if not(s[start] == s[end]):        break;
    start += 1 ; end -= 1
else:    flag += 1
print('Yes' if flag == 3 else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// https://atcoder.jp/contests/arc100/submissions/15485633
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    
    vector<ll> acc(n + 1);
    rep(i, n) acc[i + 1] = acc[i] + a[i];
    
    ll ans = INF;
    rep3(bi_, 2, n - 1) { // 全探索!!
        if (bi_ <= 1 || bi_ >= n - 1) continue;
        
        int it = lb(acc, acc[bi_] / 2);
        int it2 = lb(acc, acc[bi_] + (acc[n] - acc[bi_]) / 2);
        
        rep3(qu_, it - 1, it + 2) rep3(qu_2, it2 - 1, it2 + 2) {
            if (qu_ <= 0 || qu_ >= bi_) continue;
            if (qu_2 <= bi_ || qu_2 >= n) continue;
            
            vector<ll> v;
            v.eb(acc[qu_]);
            //(0+...+(bi_-1)) - (0+...+(qu_-1)) = (qu_+...+(bi_-1))
            v.eb(acc[bi_] - acc[qu_]);
            v.eb(acc[qu_2] - acc[bi_]);
            v.eb(acc[n] - acc[qu_2]);
            sort(all(v));
            chmin(ans, v[3] - v[0]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 5544
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>




int main(void){
double r;
scanf("%lf",&r);
printf("%lf %lf\n",(double)r*(double)r*3.1415926535897932384626,(double)2.0*(double)r*3.1415926535897932384626);
return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
int main(void)
{
	int n;
	
	int V[21];
	int C[21];
	int ans=0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &V[i]);
	}
	for (int i = 0; i < n;i++) 
	{
		scanf("%d", &C[i]);
		if (V[i] > C[i])
		
			ans += V[i] - C[i];
		
	}
	printf("%d",ans);
	
	return 0;

}

Measured memory_bytes: 128
//*-- ILSH --*//
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
const ll inf=1e17;
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
void solve() {
	int n;
	cin>>n;
	int arr[n];
	for (int i=0;i<n;i++)
		cin>>arr[i];
	int brr[n];
	brr[0]=0;
	brr[1]=abs(arr[0]-arr[1]);
	for ( int i=2;i<n;i++)
		brr[i]=std::min(brr[i-1]+abs(arr[i]-arr[i-1]),brr[i-2]+abs(arr[i]-arr[i-2]));
	cout<<brr[n-1]<<'\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int t=1;
    // cin>>t;
    while ( t-- )
    	solve();    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll M1,D1,M2,D2; cin>>M1>>D1>>M2>>D2;

    cout<< ( M1!=M2 ? 1 : 0 )<<"\n";

}   
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

int Q[105],Adj[105][105],d[105],n,m[105];

void Q_Empty(){
  int i;
  for(i = 0; i < n; i ++){
    Q[i]=0;
  }
}

void Q_Enqueue(int s){
  int i;  
  for(i = 0; i < n; i ++){
    if(Q[i]==0){
      Q[i] = s;
      break;
    }
  }
 
}

int Q_Dequeue(){
  int i,u;
  u = Q[0];
  for(i = 0; i < n-1; i ++){
    Q[i] = Q[i+1];
  } 
  return u;
}

void BFS(int s){
  int i,u,v,color[105];
  for(u = 1; u <= n; u ++){
    color[u] = WHITE;
    d[u] = -1;
    color[s] = GRAY;
  }
  d[s] = 0;
  Q_Empty();
  Q_Enqueue(s);
  while(Q[0] != 0){
    u = Q_Dequeue(); 
    for(i = 1; i <= m[u]; i ++){
      if(color[Adj[u][i]] == WHITE){	
	color[Adj[u][i]] = GRAY;	
	d[Adj[u][i]] = d[u] + 1;	
	Q_Enqueue(Adj[u][i]);
      }
    }
    color[u] = BLACK;
  }
  
}
int main(){ 
  int u,i,j,dust;
  scanf("%d",&n);
  for(u = 1; u <= n; u++){
    for(j = 1; j <= n; j++){
      Adj[u][j]=0;
    }
  }
  for(u = 1; u <= n; u++){
    scanf("%d%d",&dust,&m[u]);
      for(i = 1; i <= m[u]; i++){
	scanf("%d",&Adj[u][i]);
      }	
  }
  BFS(1);
  
  for(u = 1; u <= n; u++){
    printf("%d %d\n",u,d[u]);
  }
  return 0;
}

Measured memory_bytes: 640
H, W, n = map(int, input().split())
obst = []
for _ in range(n):
	x, y = map(int, input().split())
	if x >= y:
		obst.append([x-1, y-1, x-y])

#obst.sort(key=lambda x: (x[2], x[0]))

#print(obst)
bothered = [1000000] * (H+1)

for i in range(len(obst)):
	h, w, gap = obst[i][0], obst[i][1], obst[i][2]
	#if gap == 0:
		#bothered[1] = min(bothered[1], h+1)
		#continue
	
	bothered[gap+1] = min(bothered[gap+1], h+1)
	#if  h < bothered[gap]:
		#print(h)
		#break

obst.sort(key=lambda x: x[0])

for i in range(len(obst)):
	h, w, gap = obst[i][0], obst[i][1], obst[i][2]
	if gap == 0:
		continue
	if h < bothered[gap]:
		print(h)
		break

else:
	print(H)

Measured memory_bytes: 44096
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    int ok = 0;
    for(int i = 0; i <= K; i++) {
        for(int j = 0; j + i <= K; j++) {
            for(int k = 0; i + j + k <= K; k++) {
                int AA = A, BB = B, CC = C;
                rep(ii, i) AA *= 2;
                rep(jj, j) BB *= 2;
                rep(kk, k) CC *= 2;
                if(AA < BB && BB < CC)
                    ok = 1;
            }
        }
    }
    if(ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)

def gojo(a, b):
    if b == 0:
        return a
    else:
        return gojo(b, a % b)

def calc(A, res):
    for a in A:
        if res == 0:
            res = a
        else:
            res =  gojo(max(res, a), min(res, a))
        gcds.append(res)
    return res

gcds = []
ig = -1
calc(A, 0)

for i, a in enumerate(reversed(gcds)):
    if a != gcds[-1]:
        ig = len(gcds) - i - 1
        break

item = A.pop(ig)
ans1 = calc(A, 0)
A.pop(ig)
A.insert(0, item)
ans2 = calc(A, 0)
print(max(ans1, ans2))


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

int a=scanner.nextInt();
int h=a%100;
int t=h%10;

if(a/100==7) {
	System.out.println("Yes");
}
else if(h/10==7) {
	System.out.println("Yes");
}
else if(t==7) {
	System.out.println("Yes");
}
else {
	System.out.println("No");
}

}
	  }

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll 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*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

ll x[maxn],k[maxn];
ll n,a,b;

bool check(ll t){
	memcpy(k,x,sizeof(x));
	for(ll i=1; i<=n; i++){
		k[i] -= t*b;
	}
	ll more = (a-b),cnt=0;
	for(ll i=1; i<=n; i++){
		if(k[i]>0) cnt += (k[i]%more==0) ? (k[i]/more) : (k[i]/more+1);
	}
	return cnt <= t;
}

int main(){
	cin >> n >> a >> b;
	for(int i=1; i<=n; i++){
		x[i] = read();
	}

	ll ans,L=1,R=1e9;
	while(L<=R){
		ll mid = (L+R)/2;
		if(check(mid)) ans=mid,R=mid-1;
		else L=mid+1;
	}

	cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1792