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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64,
    }

    println!("{} {}", std::cmp::min(a, b), std::cmp::max(0, a + b - n));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int vec[200002];
int lspa[200002][18];
ll lsum[200002][18];

int rspa[200002][18];
ll rsum[200002][18];

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    for (int i = 0; i < 18; i++) lspa[n+1][i] = n + 1;
    for (int i = 1; i <= n; i++) scanf("%d", &vec[i]);

    for (int i = 1; i <= n; i++) {
        int ne = lower_bound(vec + 1, vec + n + 1, vec[i] + k) - vec;
        lspa[i][0] = ne;
        lsum[i][0] = ne-1;

        ne = upper_bound(vec + 1, vec + n + 1, vec[i] - k) - vec - 1;
        rspa[i][0] = ne;
        rsum[i][0] = ne;    // 얘는 더하고 l은 빠진다.
    }

    for (int j = 1; j < 18; j++) {
        for (int i = 0; i <= n + 1; i++) {
            lspa[i][j] = lspa[lspa[i][j-1]][j-1];
            lsum[i][j] = lsum[i][j-1] + lsum[lspa[i][j-1]][j-1];
            rspa[i][j] = rspa[rspa[i][j-1]][j-1];
            rsum[i][j] = rsum[i][j-1] + rsum[rspa[i][j-1]][j-1];
        }
    }

    int q;
    scanf("%d", &q);
    while (q--) {
        int le, ri;
        scanf("%d %d", &le, &ri);

        int now = le;
        ll ans = ri - le + 1;
        // printf("%lld\n", ans);
        for (int j = 17; j >= 0; j--)
            if (lspa[now][j] <= ri) {
                // printf("%d %d %d : pass\n", now, j, lspa[now][j]);
                ans -= lsum[now][j];
                now = lspa[now][j];
            }
        // printf("%lld\n", ans);

        now = ri;
        for (int j = 17; j >= 0; j--)
            if (rspa[now][j] >= le) {
                ans += rsum[now][j];
                now = rspa[now][j];
            }
        printf("%lld\n", ans);
    }
}


// author: rdd6584


Measured memory_bytes: 88928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
void solve()
{
	ll a = 1, b = 1, c8 = 1;
	int n;
	cin >> n;
	for (int c = 1; c <= n; c++)
	{
		(a *= 10) %= mod;
		(b *= 9) %= mod;
		(c8 *= 8) %= mod;
	}
	cout << (2 * mod + a - 2 * b + c8) % mod << endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	for (int tt = 1; tt <= t; tt++)
	{

		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
import scala.collection.mutable._

object Main extends App {
    val ns = ArrayBuffer(
      Array(7,5,3): _*
    )
  
    val n = io.StdIn.readLine.toInt
    
    1.to(9-1).foreach { i => 
      val newNs = ArrayBuffer[Int]()
      List(7,5,3).foreach { suffix =>
        ns.foreach { n =>
		  val m = n * 10 + suffix
          newNs += m
        }
      }
      ns ++= newNs
	}
    
    println(ns.sortBy(identity).distinct.count {
      x => 
        val xs = x.toString
        x <= n &&
        xs.contains("7") && 
        xs.contains("5") && 
        xs.contains("3")
    })
}

Measured memory_bytes: 66556
#!/usr/bin/env python3
# Bitset 2 - Enumeration of Subsets 1


def subset(n):
    for i in range(2**n):
        yield [v for v in range(n) if i & (1 << v) > 0]


def run():
    n = int(input())

    for i, vs in enumerate(subset(n)):
        print("{}:{}".format(i, "".join([" {}".format(v) for v in vs])))


if __name__ == '__main__':
    run()



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

unsigned euclidean_gcd(unsigned a, unsigned b) {
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N;
    unsigned int X;
    cin >> N >> X;

    unsigned int x[N + 1];
    x[0] = X;
    for (int i = 1; i < N + 1; i++){
        cin >> x[i];
    }
    sort(x, x + N + 1);

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

    if (N == 1){
        cout << y[0] << endl;
        return 0;
    }

    unsigned int ans = euclidean_gcd(y[0], y[1]);

    for (int i = 2; i < N - 1; i++){
        ans = euclidean_gcd(ans, y[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

typedef struct _dataset_st
{
    int n, x;
    struct _dataset_st *next;
} dataset_st;

#define min(a, b) ((a) < (b) ? (a) : (b))

int get_combination_count(dataset_st *dataset)
{
    int count = 0;
    const int first_bound = min(dataset->n - 1, (dataset->x - 3) / 3 + 1); /* i+(i+1)+(i+2) <= dataset->x */
    for (int i = 1; i < first_bound; ++i)
    {
        const int second_bound = min(dataset->n, (dataset->x - i - 1) / 2 + 1); /* i+j+(j+1) <= dataset->x */
        for (int j = i + 1; j < second_bound; ++j)
        {
            count += !!(dataset->x - i - j <= dataset->n);
        }
    }
    return count;
}

int main(int argc, char *argv[])
{
    dataset_st *head = NULL, *tail = NULL;
    for (int n, x; scanf("%d %d", &n, &x) == 2 && (n || x);)
    {
        dataset_st *dataset = (dataset_st *)malloc(sizeof(dataset_st));
        if (!dataset)
        {
            break;
        }
        *dataset = (dataset_st){.n = n, .x = x};
        head = head ?: dataset;
        if (tail)
        {
            tail->next = dataset;
        }
        tail = dataset;
    }
    while (head)
    {
        dataset_st *dataset = head;
        head = head->next;
        printf("%d\n", get_combination_count(dataset));
        free(dataset);
    }
    tail = NULL;
    return 0;
}



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

def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    ans = 0
    now = T
    start = t[0]
    for i in range(1, N):
        if t[i-1] + T < t[i]:
            ans += t[i-1] + T - start
            start = t[i]
    
    ans += t[-1] + T - start
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25104
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int main(){
	int r=gi();
	printf("%d\n",3*r*r);
	return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
MOD = 10 ** 9 + 7
if W == 1:
    print(1)
    exit()
ladder = W - 1
num_lad = [0] * ladder
limit = 0 #ハシゴの掛け方の総数
for i in range(2 ** ladder):
    flag = True
    for j in range(ladder-1):
        if (i >> j) & 1 and (i >> j+1) & 1:
            flag = False
    if not flag:
        continue
    limit += 1
    for j in range(ladder):
        # iのbitをj右にシフトしたらフラグが立っているかチェック
        if ((i >> j) & 1):
            num_lad[j] += 1

dp = [[0] * W for _ in range(H+1)]
dp[0][0] = 1

for i in range(1, H+1):
    for j in range(W):
        if j == 0:
            dp[i][j] = (dp[i-1][j] * (limit - num_lad[0]) + dp[i-1][j+1] * num_lad[0]) % MOD
        elif j == (W-1):
            dp[i][j] = (dp[i-1][j] * (limit - num_lad[ladder-1]) + dp[i-1][j-1] * num_lad[ladder-1]) % MOD
        else:
            dp[i][j] = (dp[i-1][j] * (limit - num_lad[j-1] - num_lad[j]) + \
                    dp[i-1][j+1] * num_lad[j] + dp[i-1][j-1] * num_lad[j-1]) % MOD

print(dp[H][K-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod=1e9+7;


int N;
int T[100010];
int A[100010];
ll mn[100010];
bool ok[100010];
ll ans;
int main(){
	cin>>N;
	ans=1;
	REP(i,0,N) cin>>T[i];
	REP(i,0,N) cin>>A[i];
	REP(i,0,N) mn[i]=min(T[i],A[i]);
	bool flag=false;
	if(T[N-1]==A[0]) {
		int mx=T[N - 1];
		REP(i,0,N) {
			if (T[i]==A[i] && T[i] == mx) {
				flag=true;
			}
		}
	}
	if(!flag) ans=0;
	ok[0] = ok[N - 1] = true;
	int t= T[0];
	int a=A[N-1];
	REP(i,1,N-1) {
		if (T[i] != t) ok[i]=true;
		t = T[i];
	}
	RREP(i,1,N-1) {
		if (A[i]!= a) ok[i]=true;
		a = A[i];
	}
	RREP(i,0,N-1){
		if(!ok[i]){
			ans*=mn[i];
			ans%=mod;
		}
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 1920
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL h,w,q;
string c[20],d[20];

int main()
{
	FIO;
	cin >> h >> w >> q;
	rep(i,0,h-1) cin >> c[i];
	LL ans = 0;
	rep(i,0,(1<<h)-1) rep(j,0,(1<<w)-1) {
		// cout << i << " " << j << endl;
		rep(i,0,h-1) d[i] = c[i];
		rep(k,0,h-1) if(((1<<k)&i) > 0) {
			// cout << k << endl;
			rep(l,0,w-1) d[k][l] = '?';
		}
		rep(k,0,w-1) if(((1<<k)&j) > 0) {
			rep(l,0,h-1) d[l][k] = '?';
		}
		LL cnt = 0;
		rep(k,0,h-1) rep(l,0,w-1) if(d[k][l] == '#') cnt++;
		if(cnt == q) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var K = parseInt(line[0]);
    var S = parseInt(line[1]);
    var roop = Math.min(K,S);
    var ans =0;
    for(var A=0;A<=roop;A++){
        if(S-K-A>=0){
            if(2*K-S+A+1>0){
                ans += 2*K-S+A+1;
            }
        }
        else if(S-K-A<0){
            if(S-A+1>0){
                ans += S-A+1;
            }
        }
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
const int MOD=998244353;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main(){
  int N,M,K;
  cin>>N>>M>>K;
  mint tmp(M);
  for(int i(0);i<N-1;i++){
    tmp *= (M-1);
  }
  if(N == 1){
    cout << M << endl;
    return 0;
  }
  if(M == 1){
    if(N-1 <= K){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
  }
  mint tmpi(tmp);
  for(int i(1);i<=K;i++){
    tmpi /= (M-1);
    tmpi *= (N-1)-(i-1);
    tmpi /= i;
    //cout << tmpi << endl;
    tmp += tmpi;
  }
  cout << tmp << endl;
  return 0;
}



Measured memory_bytes: 3608
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define y2 azdfsdgwre

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1e5 + 123;
int n, m, col[N], del[N];
vector <int> adj[N];
vector <pii> edges;

void dfs(int v, int p) {
    col[v] = 1;
    int child = 0;
    for (int to : adj[v]) {
        if (to == p) {
            continue;
        }
        if (col[to] == 1) {
            edges.pb({v, to});
            child++;
        }
        if (col[to] == 0) {
            dfs(to, v);
            if (!del[to]) {
                edges.pb({v, to});
                child++;
            }
        }
    }
    if (child & 1) {
        edges.pb({v, p});
        del[v] = 1;
    }
    col[v] = 2;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n >> m;
    if (m & 1) {
        cout << -1;
        return 0;
    }
    int x, y;
    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(1, 1);
    for (auto i : edges) {
        cout << i.fi << ' ' << i.se << '\n';
    }
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

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

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

using ld = long double;
using Point = complex<ld>;
using Polygon = vector<Point>;

const ld eps = 1e-10;

Point at(const Polygon &g, int i) {
  i %= (int)g.size();
  return g[i < 0 ? i + g.size() : i];
}

bool comp(const Point& a, const Point& b) {
  return real(a - b) * 1.347589 + imag(a - b) > 0;
}

ld dot(Point a, Point b) { return real(conj(a) * b); }
ld cross(Point a, Point b) { return imag(conj(a) * b); }

struct Segment {
  Point a, b;
  Segment (Point p, Point q) : a(p), b(q) {;}
};

struct Line {
  Point a, b;
  Line (Point p, Point q) : a(p), b(q) {;}
  explicit Line (Segment s) : a(s.a), b(s.b) {;}
};

struct Circle {
  Point p; ld r;
  Circle (Point a, ld b) : p(a), r(b) {;}
};

int ccw (Point a, Point b, Point c) {
  b -= a; c -= a;
  if (cross(b, c) > eps) return 1;   // counter clockwise
  if (cross(b, c) < -eps) return -1; // clockwise
  if (dot(b, c) < 0) return 2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line
  return 0;                          // a--c--b on line
}

vector<Point> unique(vector<Point> ps) {
  sort(begin(ps), end(ps), comp);
  vector<Point> res;
  for (Point p: ps)
    if (res.empty() || abs(res.back() - p) > eps)
      res.push_back(p);
  return res;
}

Polygon convex_hull(vector<Point> ps) {
  int n = ps.size(), k = 0;
  sort(begin(ps), end(ps), comp);
  Polygon res(2 * n);
  for (int i = 0; i < n; res[k++] = ps[i++])
    while (k >= 2 && ccw(res[k - 2], res[k - 1], ps[i]) <= 0) --k;
  for (int i = n - 2, t = k + 1; i >= 0; res[k++] = ps[i--])
    while (k >= t && ccw(res[k - 2], res[k - 1], ps[i]) <= 0) --k;
  res.resize(k - 1);
  return res;
}


int main(){
  int N; cin >> N;
  vector<Point> ps(N);
  map<Point,int,bool(*)(const Point&,const Point&)> mp(comp);
  rep(i,N){
    ld x,y; cin >> x >> y;
    ps[i] = Point(x,y);
    mp[ps[i]] = i;
  }
  auto ch = move(convex_hull(ps));
  int M = ch.size();
  vector<ld> theta(N,0.0);
  rep(i,M){
    auto& p1 = ch[(i-1+M)%M];
    auto& p2 = ch[i];
    auto& p3 = ch[(i+1)%M];
    ld b = arg(p3-p2); ld a = arg(p2-p1);
    if(a>0.0 && b<0.0) b += 2*PI;
    // cout << b/(2*PI) << " " << a/(2*PI)  << endl;
    theta[mp[p2]] = b-a;
  }
  ld ssum = 0.0;
  for(auto i:theta) ssum += i;
  for(auto i:theta) printf("%.10Lf\n",i/ssum);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <array>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
using namespace std;
const ll M = 1e9+7;
ll dp[1000][1000];
char board[1000][1000];
int h,w;

int main(){
    AC
    cin>>h>>w;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>board[i][j];
        }
    }

    dp[0][0] = 1;

    for(int i=1; i<h; i++){
        if(board[i][0]=='.')
            dp[i][0] = dp[i-1][0];
        else
            dp[i][0] = 0;
    }

    for(int i=1; i<w; i++){
        if(board[0][i]=='.')
            dp[0][i] = dp[0][i-1];
        else
            dp[0][i] = 0;
    }

    for(int i=1; i<h; i++){
        for(int j=1; j<w; j++){
            ll res = 0;
            if(i-1>=0 && board[i-1][j]=='.')
                res+=dp[i-1][j];
            if(j-1>=0 && board[i][j-1]=='.')
                res+=dp[i][j-1];
            dp[i][j] = res%M;
        }
    }

    cout<<dp[h-1][w-1]<<endl;

}

Measured memory_bytes: 11932
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll R, ll mod){
  ll ans = 1; R = min(R, N - R);
  for (ll i = 1; i <= R; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

int main(){
  vector <int> A(3);
  for (int i = 0; i < 3; i++) cin >> A[i];
  sort(A.begin(), A.end());

  if (A[0] != A[1] && A[1] != A[2]){
    cout << "No" << endl;
  }else if (A[0] == A[1] && A[1] == A[2]){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long k = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long num = 1;

        if (a+2 >= b) {
            num += k;
        } else {
            if (k >= a+1) {
                num = b;
                k -= a+1;
                num += k / 2 * (b - a);
                num += k % 2;
            } else {
                num += k;
            }
        }

        System.out.println(num);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    int n;
    cin>>n;
    readv(a,n);

    int x = 0;
    for(auto i:a)
        x ^=i;

    for(auto& i:a)
        i = i^x;

    for(auto i:a)
        cout<<i<<" ";



}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include<vector>

using namespace std;

vector<pair<long long, long long>> prime_factorize(long long N) {
	vector<pair<long long, long long>>res;
	for (long long a = 2; a * a <= N; a++) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a,ex });
	}
	if (N != 1) res.push_back({ N,1 });
	return res;
}

int main()
{
	long long N;
	cin >> N;
	
	const int MOD = 1000000007;
	vector<long long> ex(N + 1, 0);
	for (long long n = 2; n <= N; n++) {
		const auto& res = prime_factorize(n);
		for (auto p : res) ex[p.first] += p.second;
	}
	long long res = 1;
	for (int p = 2; p <= N; p++) {
		res *= ex[p] + 1;
		res %= MOD;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int key[10000];
  int h=0,i=0,k=0;

  //入力
  scanf("%d",&h);

  for(i=1;i<=h;i++)
    {
      scanf("%d",&key[i]);
    }

  //計算出力

  for(i=1;i<=h;i++)
    {
      printf("node %d: ",i);
      printf("key = %d, ",key[i]);

      //parent の判定
       if(i!=1)
	{
	  if(i%2==0)
	    {
	      printf("parent key = %d, ",key[i/2]);
	    }
	  else
	    {
	      k=i-1;
	      printf("parent key = %d, ",key[k/2]);
	    }
	}
       //right left key　の判定
       if((i*2)+1 <= h)
	 {
	   printf("left key = %d, ",key[2*i]);
	   printf("right key = %d, ",key[(2*i)+1]);
	 }
       //right keyがない場合
       else if(i*2 == h)
	 {
	   printf("left key = %d, ",key[2*i]);
	 }
       printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main()
{    
    int n;
    cin >> n;
    
    vector<pair<int, int>> a(n);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    
    sort(a.begin(), a.end());
    
    vector<int> rBMin(n, 2000000000);
    
    rBMin[n - 1] = a[n - 1].second;
    
    for (int i = n - 2; i >= 0; --i) {
        rBMin[i] = min(a[i].second, rBMin[i + 1]);   
    }
  
    int ans = 0;
    
    int rMin = a[0].second;
    int rMax = a[0].second;
    
    for (int i = 0; i < n - 1; i++) {
        int lA = a[i].first;
        int rA = a[i].second;
        int lB = a[n - 1].first;
        int rB = rBMin[i + 1];
        
        if (i == 0) {
            ans = max(ans, max(rA - lA + 1, 0) + max(rB - lB + 1, 0));
        } else if (i == 1) {
            ans = max(ans, max(min(a[0].second, rA) - lA + 1, 0) + max(rB - lB + 1, 0));
            ans = max(ans, max(rA - lA + 1, 0) + max(min(rB, a[0].second) - lB + 1, 0));
        } else {
            {
                ans = max(ans, max(min(rA, rMin) - lA + 1, 0) + max(rB - lB + 1, 0));
                ans = max(ans, max(min(rA, rMin) - lA + 1, 0) + max(min(rB, rMax) - lB + 1, 0));
                ans = max(ans, max(min(rA, rMax) - lA + 1, 0) + max(min(rB, rMin) - lB + 1, 0));
                ans = max(ans, max(rA - lA + 1, 0) + max(min(rB, rMin) - lB + 1, 0));
            }
        }
            
        rMin = min(rMin, a[i].second);
        rMax = max(rMax, a[i].second);
    }
    
    cout << ans << endl;
}


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

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	int K;
	cin >> s;
	cin >> K;
	vector<string> subStr;

	for(int i = 0; i < s.size(); i++) {
		for(int j = 1; j <= K; j++) {
			subStr.push_back(s.substr(i, j));
		}
	}
	vsort(subStr);
	vunique(subStr);
	cout << subStr[K - 1] << endl;
}


Measured memory_bytes: 1660
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
vector<pair<string, int>>stor, ordered;
int smallest_lexicog(string s,string s2) {
	for (int i = 0; i < s.length() &&i<s2.length(); i++)
	{
		if (s[i] == s2[i])continue;
		else return (int)s[i] - s2[i];
	}
	if (s.length() < s2.length())return s.length() - s2.length();
	else if (s.length() > s2.length())return s.length() - s2.length();
	else return 0;
}
int main()
{
	El3zba;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		int score;
		cin >> s >> score;
		stor.PB({ s,score });
		ordered.PB({ s, score });
	}
	for (int i = 0; i < n; ++i) {
		string temp;
		for (int j = i + 1; j < n; ++j)
		{
			if (stor[i].ff > stor[j].ff)
			{
				temp = stor[i].ff;
				int val = stor[i].ss;
				stor[i].ff = stor[j].ff;
				stor[i].ss = stor[j].ss;
				stor[j].ff = temp;
				stor[j].ss = val;
			}
			else if (stor[i].ff == stor[j].ff) {
				if (stor[i].ss < stor[j].ss) {
					int t = stor[i].ss;
					stor[i].ss = stor[j].ss;
					stor[j].ss = t;
				}
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (stor[i].ff == ordered[j].ff &&stor[i].ss == ordered[j].ss) {
				cout << j + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
            vars
            (mapcar (constantly '(read))
                vars)))
       ,@body)))

(defsolver solution-b (n x)
  (let ((acc 0)	(ans 1))
    (dotimes (i n)
      (incf acc (read))
      (when (<= acc x)
	(incf ans)))
    (princ ans)))

(solution-b)

Measured memory_bytes: 14948
data = input().split()#lines[0]つまり１行目をスペースで区切る.dataは配列
n = int(data[0])
a = input().split()
count = 0
j = 0
k = 0
flag = True
#型変換
for i in range(n):
    a[i] = int(a[i])

while flag:
    for k in range(n):
        if a[k]%2 == 0:
            a[k] = a[k]/2
        else:
            flag = False
            break
    if flag == False:
        print(j)
    j += 1

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

int main(){
	long long int n;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		a[b]++;
	}
	
	int f=1;
	if(n%2==0){
		for(int i=1;i<n;i+=2){
			if(a[i]!=2)f=0;
		}
	}else{
		for(int i=2;i<n;i+=2){
			if(a[i]!=2)f=0;
		}
		if(a[0]!=1)f=0;
	}
	
	if(f==0){
		cout<<0<<endl;
	}else{
		long long int ans=1;
		for(int i=0;i<n/2;i++){
			ans*=2;
			int m=1e9+7;
			ans%=m;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1024
n=gets.to_i
s=gets.chomp.chars
max=0
(s.size-1).times do|i|
  x=s.slice(0..i).uniq
  y=s.reverse.slice(0..(s.size-i-2)).uniq
  z=(x+y).size-(x+y).uniq.size
  if max<z then max=z end
end
p max

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

int main() {
  int n, m, l;
  cin>>n>>m>>l;
  long long cost[n][n];
  long long inf = 300 * 1e9;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      cost[i][j] = inf;
    }
    cost[i][i] = 0;
  }
  for (int i=0; i<m; i++) {
    int a, b, c;
    cin>>a>>b>>c;
    --a;
    --b;
    cost[a][b] = c;
    cost[b][a] = c;
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (cost[i][k] != inf && cost[k][j] != inf) {
          cost[i][j] = min(cost[i][k] + cost[k][j], cost[i][j]);
        }
      }
    }
  }
  int edge[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i == j) {
        edge[i][j] = 0;
      } else if (cost[i][j] <= l) {
        edge[i][j] = 1;
      } else {
        edge[i][j] = 0;
      }
    }
  }
  int num[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i == j) {
        num[i][j] = 0;
      } else if (edge[i][j] == 1) {
        num[i][j] = 1;
      } else {
        num[i][j] = n;
      }
    }
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (num[i][k] != n && num[k][k] != n) {
          num[i][j] = min(num[i][k] + num[k][j], num[i][j]);
        }
      }
    }
  }
  int q;
  cin>>q;
  for (int i=0; i<q; i++) {
    int s, t;
    cin>>s>>t;
    --s;
    --t;
    if (num[s][t] == n) {
      cout<<-1<<endl;
    } else {
      cout<<num[s][t]-1<<endl;
    }
  }
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(vector<vector<T>> x){cerr<<"\n{"; int f=x.size();for(int i=0;i<f;i++){cerr<<"("; int g=x[i].size(); for(auto j:x[i]){cerr<<j; (--g!=0)?cerr<<",":cerr<<"";}cerr<<")\n";}cerr<<"}";}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void __print(vector<bool> x){cerr<<"{";int f=x.size();for(auto i:x){cerr<<i;(--f !=0)?cerr<<",":cerr<<"";}cerr<<"}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define trace(x...)
#endif
 
template<typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
 
template<typename... T>
void writ(T&&... args) {
    ((cout << args << " "), ...);
}
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define IINF (int)1e9
#define EPS 1e-9

int h,w,ch,cw,dh,dw;
vector<vector<char>> inp;
vector<vector<int>> dp;
static int rw[]={-1,0,0,1};
static int cl[]={0,-1,1,0};
bool issafe(int i,int j){
    return i>=0 && j>=0 && i<h && j<w;
}
int df(){
    deque<pair<int,int>> dq;
    dq.push_back({ch-1,cw-1});
    while(!dq.empty()){
        int i=dq.front().first,j=dq.front().second;
        dq.pop_front();
        for(int k=0;k<4;k++){
            int x=i+rw[k],y=j+cl[k];
            if(issafe(x,y) && inp[x][y]=='.'){
                if(dp[x][y]>dp[i][j]){
                    dp[x][y]=dp[i][j];
                    dq.push_front({x,y});
                }
            }
        }
        for(int k=i-2;k<=i+2;k++){
            for(int l=j-2;l<=j+2;l++){
                if(issafe(k,l) && inp[k][l]=='.'){
                    if(dp[k][l]>dp[i][j]+1){
                        dp[k][l]=dp[i][j]+1;
                        dq.push_back({k,l});
                    }
                }
            }
        }
    }
    return dp[dh-1][dw-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w>>ch>>cw>>dh>>dw;
    inp.resize(h,vector<char> (w));
    dp.resize(h,vector<int> (w,IINF));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>inp[i][j];
        }
    }
    dp[ch-1][cw-1]=0;
    int x=df();
    cout<<((x!=IINF)?x:-1)<<endl;
    return 0;
}

Measured memory_bytes: 8696
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

def f(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5

import math
import itertools
List = [int(i) for i in range(N)]
ans = 0
for P in itertools.permutations(List):
    d = 0
    for j in range(N-1):
        d += f(L[P[j]][0], L[P[j]][1], L[P[j+1]][0], L[P[j+1]][1])
    ans += d
print(ans/math.factorial(N))

Measured memory_bytes: 3188
<?php
fscanf(STDIN, '%d %d', $h, $w);
for ($i  = 0; $i < $h; $i++) {
    $s[] = trim(fgets(STDIN));
}
$g = array_fill(0, $h * $w, []);
for ($i  = 0; $i < $h * $w; $i++) {
    $l = intval(floor($i / $w));
    $m = $i % $w;

    if ($s[$l][$m] === '#') continue;

    if ($m < $w - 1 && $s[$l][$m + 1] === '.') {
        $g[$i][] = $i + 1;
        $g[$i + 1][] = $i;
    }

    if ($l < $h - 1 && $s[$l + 1][$m] === '.') {
        $g[$i][] = $i + $w;
        $g[$i + $w][] = $i;
    }
}
$max_dist = -1;
for ($i = 0; $i < $h * $w; $i++) {
    // BFS（幅優先探索）：最短経路アルゴリズムとして活用
    $q = new SplQueue(); // キューを用意
    $dist = array_fill(0, $h * $w, -1); // 距離を格納する配列（-1の場合はその頂点が未発見）

    $dist[$i] = 0; // 頂点0からの距離格納配列
    $q->enqueue($i); // キューに0を追加

    while (!$q->isEmpty()) {
        $v = $q->dequeue();

        foreach ($g[$v] as $next_v) {
            if ($dist[$next_v] !== -1) continue; // 発見済み

            $dist[$next_v] = $dist[$v] + 1;
            $q->enqueue($next_v);
        }
    }

    foreach ($dist as $v) {
        $max_dist = max($v, $max_dist);
    }
}
echo $max_dist . PHP_EOL;

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

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

  vector<pair<int , int>> p(N);
  
  for(int i = 0; i < N ; i++){
    int a;
    int b = i+1;
    cin >> a;
    p.at(i) = make_pair(a, b);
  }
  
  sort(p.begin(), p.end());
  
  
  for(int i =0; i < N; i++){
    int a;
    int b;
    tie(a, b) = p.at(i);
    cout << p.at(i).second << " ";
  }
  
  cout << endl;
}




Measured memory_bytes: 1664
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define int long long
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 100010;
LL n, m, v, p;
LL a[N];
bool check(int x) {
//	cerr << "CHECK " << x << endl; 
	LL totalVote = 0;
	if (x <= p) return true;
	else if (a[x] + m < a[p]) return false;
	else {
		totalVote += (p - 1) * m;
		totalVote += (n - x + 1) * m;
		for (int i = p; i < x; i++) totalVote += (a[x] + m - a[i]);
	//	cerr << totalVote << endl;
		return totalVote >= m * v;
	}
}
main() {
	cin >> n >> m >> v >> p;
	repn(i, n) cin >> a[i];
	sort(a + 1, a + n + 1, [](LL x, LL y) {
		return x > y;
	});
	int L = 0, R = n + 1;
	while (L + 1 < R) {
		int mid = (L + R) >> 1;
		if (check(mid)) L = mid;
		else R = mid;
	}
	int ans = 0;
	repn(i, n) if (a[i] < a[L]) break; else ans++;
	cout << ans << endl; 
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
lisAB = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for A,B in lisAB[::-1]:
    if (A+ans)%B == 0:
        continue
    else:
        num = B - (A+ans)%B
        ans += num

print(ans) 

Measured memory_bytes: 28148
#include <iostream>
#define MOD 1000000007

using namespace std;

// dp[i][j][k] :=
// i回目の操作まで見た, jは青の個数, k=1なら青が0になったことがある
// このときの積み木の総数
int dp[3100][3100][2];

void modadd(int& a, int& b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

int main()
{
  int N, M;
  cin >> N >> M;

  for (int i = 1; i <= N; i++) {
    dp[0][i][0] = 1;
  }
  dp[0][0][1] = 1;

  for (int i = 0; i < M; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= 1; k++) {
        if (dp[i][j][k] > 0) {
          if (j > 0) {
            if (j == 1) {
              modadd(dp[i+1][j-1][1], dp[i][j][k]);
              modadd(dp[i+1][j][1], dp[i][j][k]);
            } else {
              modadd(dp[i+1][j-1][k], dp[i][j][k]);
              modadd(dp[i+1][j][k], dp[i][j][k]);
            }
          }

          if (j < N) {
            modadd(dp[i+1][j+1][k], dp[i][j][k]);
            modadd(dp[i+1][j][k], dp[i][j][k]);
          }
        }
      }
    }
  }

  int ans = 0;
  for (int i = 0; i <= N; i++) {
    modadd(ans, dp[M][i][1]);
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
	queue<char> S, T;
	int N;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		char s;
		cin >> s;
		S.push(s);
	}

	for (int j = 0; j < N; j++)
	{
		char t;
		cin >> t;
		T.push(t);
	}

	for (int k = 0; k < (N * 2); k++)
	{
		if (k % 2 == 0)
		{
			cout << S.front();
			S.pop();
		}
		else
		{
			cout << T.front();
			T.pop();
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/*
link: 
tags: 
*/
#include<bits/stdc++.h>
#define to_l(a) ((a)<<1)
#define to_r(a) ((a)<<1|1)
#define lowbit(a) ((a)&(-a))
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const int int_inf=0x3f3f3f3f;
const ll ll_inf=0x3f3f3f3f3f3f3f3f;
const int max_n=1e5+5;
const ll mod=1e9+7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;
	int n;
	cin>>n;
	ll ans=1;
	for(i=1;i<=n;i++){
		ans=ans*10%mod;
	}
	ll del=1;
	for(i=1;i<=n;i++){
		del=del*9%mod;
	}
	ll del1=1;
	for(i=1;i<=n;i++){
		del1=del1*8%mod;
	}
	del=(del-del1)*2%mod;
	
	ans=ans-del-del1;
	ans%=mod;
	while(ans<0){
		ans+=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	cin >> n;
	int t;
	cin >> t;
	int a;
	cin >> a;
	vector <double> h(n);
	for (int i = 0; i < n; ++i) cin >> h.at(i);
	for (int i = 0; i < n; ++i) h.at(i) = t - h.at(i) * 0.006;
	double res = 1000001;
	int cnt;
	for (int i = 0; i < n; ++i) {
		h.at(i) = a - h.at(i);
		if (h.at(i) < 0) h.at(i) = h.at(i) * (-1);
		if (h.at(i) < res) {
			res = h.at(i);
			cnt = i;
		}
	}
	cout << cnt + 1 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    a = LI()
    ans = 0
    for i in range(1, N):
        if a[i] >= a[i - 1]:
            continue
        ans += a[i - 1] - a[i]
        a[i] = a[i - 1]

    print(ans)


main()


Measured memory_bytes: 91056
using System;

class Program
{
 static void Main( string[] args )
 {
   int[] num = new int[3];
   int max = 0;
   int ableListneNum = 0;
   
   var str = Console.ReadLine().Split(' ');
   
   for( int cnt =0; cnt < 3; cnt++ )
   {
     num[cnt] = int.Parse(str[cnt]);
   }
  
   max = num[1] / num[0];
   
   if( num[2] >= max )
   {
     ableListneNum = max;
   }
   else
   {
     ableListneNum = num[2];
   }
   
   Console.WriteLine(ableListneNum);
 }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
#include <unordered_map>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


void fact(int n, vector<int>& v)
{
	// 割る数の初期値
	int a = 2;
	// √n ≧ a ( n ≧ a * a ) の間ループ処理
	while (n >= a * a)
	{
		// a で割り切れたら、a は素因数
		// そして、割られる数を a で割る
		// a で割り切れなかったら、 a を 1 増加させる
		if (n % a == 0)
		{
			v.push_back(a);
			n /= a;
		}
		else
		{
			a++;
		}
	}
	// 最後に残った n は素因数
	v.push_back(n);
}


vector<int> a;

bool f(int val, int i, vector<int>& v, int a2)
{
	if (i == v.size())
	{
		if (a2 == val)return false;
		return binary_search(a.begin(), a.end(), val);
	}

	bool ret = false;
	ret |= f(val, i + 1, v, a2);
	ret |= f(val * v[i], i + 1, v, a2);
	return ret;
}


int main()
{
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	a.resize(n);

	REP(i, n)
	{
		cin >> a[i];
	}


	SORT(a);
	int ans = 0;
	REP(i, n)
	{
		if (0 < i && a[i] == a[i - 1])continue;
		if (i < a.size() - 1 && a[i] == a[i + 1])continue;
		vector<int> v;
		fact(a[i], v);

		if (f(1, 0, v, a[i]) == false)
		{
			ans++;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>

#define MAXN 100
int main()
{
  int i, j, n, u, k, v;
  int M[MAXN][MAXN];

  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++) {
    scanf("%d%d",&u,&k);

    for(j = 0; j < k; j++) {
      scanf("%d",&v);
      M[i][v-1] = 1;
    }
  }

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      if(j) printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2148
#include<iostream>
using namespace std;
int main(){
  int n,a[105],j=0;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>a[i];
    if(a[i] % 2 ==0){
      if(a[i] % 3!=0 && a[i] % 5!=0){
        j=1;
      }
    }
  }
  if(j==0){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
}


Measured memory_bytes: 256
import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time

readline = sys.stdin.readline
 
IPS = lambda: readline().rstrip()
IP = lambda: int(readline().rstrip())
MP = lambda: map(int, readline().split())
LS = lambda: list(map(int, readline().split()))

def solve():
    for _ in range(1):
        n = IP()
        n = n%10
        if (n==2 or n==4 or n==5 or n==7 or n==9): print("hon")
        elif (n==0 or n==1 or n==6 or n==8): print("pon")
        else: print("bon")
       
       
if __name__ == "__main__":
    solve()

Measured memory_bytes: 9772
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define inf LLONG_MAX>>2
#define MAX 1000000
#define mod 2019
#define pb push_back
#define f(i,a,n,x) for ((i)=(a);(i)<(n);(i)+=(x))
#define fd(i,a,n,x) for ((i)=(a);(i)>=(n);(i)-=(x))
#define fi first
#define se second
#define mk make_pair
#define pi pair
#define vt vector
using namespace std;
void read(vt<ll> &a,ll n){ll i,temp;f(i,0,n,1){cin>>temp;a.pb(temp);}}
void solve(){
    string s;
    unordered_map<ll,ll> countsuf;
    ll i,val=0,pot=1,answer=0;
    cin>>s;
    countsuf[val]++;
    fd(i,s.length()-1,0,1){
        val=(val+(s[i]-'0')*pot)%mod;
        pot=(pot*10)%mod;
        answer+=countsuf[val];
        countsuf[val]++;
    }
    cout<<answer<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3744