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

int main() {
    int l, r, ans=2019, x, y;
    
    cin >> l >> r;
    if(r-l>=2018) ans=0;
    else {
        for(int i=l; i<r; i++) {
            for(int j=i+1; j<=r; j++) {
                x=i%2019;
                y=j%2019;
                ans=min(ans,x*y%2019);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
// Date: 2020-03-07

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a, b;
pii get(int x, int y) {
    pii ans;
    int tp = x*100/y;
    while(tp*y/100 < x) tp++;
    ans.fi = tp;
    while(tp*y/100 == x) tp++;
    ans.se = tp-1;
    return ans;
}

int main() {
    scanf("%d%d", &a, &b);
    pii ans1 = get(a, 8), ans2 = get(b, 10);
    pii ans = mk(max(ans1.fi, ans2.fi), min(ans1.se, ans2.se));
    if(ans.fi > ans.se) puts("-1");
    else printf("%d\n", ans.fi);

    return 0;
}

Measured memory_bytes: 256
import sys

import bisect

# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd

# import itertools

# from operator import attrgetter, itemgetter
# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    d, g = list(map(int, readline().split()))
    pc = [list(map(int, readline().split())) for _ in range(d)]

    ans = INF

    for bit in range(1 << d):
        solve = 0
        score = 0
        for i in range(d):
            point = (i + 1) * 100
            if (bit >> i) & 1:
                solve += pc[i][0]
                comp = pc[i][1]
                score += (point * pc[i][0] + comp)

        rem = g - score
        if rem > 0:
            for i in range(d - 1, -1, -1):
                point = (i + 1) * 100
                num = pc[i][0] - 1
                if not ((bit >> i) & 1):
                    if rem <= num * point:
                        solve += (rem + point - 1) // point
                        rem = 0
                        break
                    else:
                        solve += num
                        rem -= num * point

        if rem <= 0:
            ans = min(ans, solve)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	string S, T;
	int A, B;
	cin >> S >> T >> A >> B;
	string U;
	cin >> U;
	if (U == S) {
		A--;
	}
	else {
		B--;
	}
	cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

void yes() {
    cout << "Yes" << endl;
}

void no() {
    cout << "No" << endl;
}

int main() {
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--, b--, c--, d--;
    if (b < c && c < d) {  // a,b,c,dの順の場合
        for (int i = a; i < d; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                no();
                return 0;
            }
        }
    } else if (c < b) {  // a,c,b,dの順の場合
        for (int i = a; i < c; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                no();
                return 0;
            }
        }
        for (int i = b; i < d; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                no();
                return 0;
            }
        }
    } else {  // a,b,d,cの順の場合
        //追い越さないといけない
        //内側のやつがゴールできるか
        for (int i = max(a, b); i < min(c, d); i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                no();
                return 0;
            }
        }
        //外側の人がゴールできるか
        bool flag = false;
        //三連続で石のない場所があるか
        for (int i = max(a, b); i <= min(c, d); i++) {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                //追い越すところに石を置いてしまう
                s[i] = '#';
                flag = true;
                break;
            }
        }
        if (!flag) {
            no();
            return 0;
        }
        for (int i = min(a, b); i < max(c, d); i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                no();
                return 0;
            }
        }
    }
    yes();
    return 0;
}

Measured memory_bytes: 640
K = int(input())
count = 1
check = 7

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    while True:
        if check % K == 0:
            print(count)
            break
        else:
            count += 1
            check = (check * 10 + 7) % K


Measured memory_bytes: 63144
#[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 ( 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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ 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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => {
        if $x > $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        h: i64, w: i64
    }

    let mut ret = 1i64 << 60;
    if h%3 == 0 {
        ret = 0;
    } else {
        chmin!(ret, w);
    }
    if w%3 == 0 {
        ret = 0;
    } else {
        chmin!(ret, h);
    }

    for i in 1..w {
        let mut v = vec![i*h, (w-i)*(h/2), (w-i)*ceil_div(h,2)];
        v.sort();
        chmin!(ret, v[2] - v[0]);
    }
    for i in 1..h {
        let mut v = vec![i*w, (h-i)*(w/2), (h-i)*ceil_div(w,2)];
        v.sort();
        chmin!(ret, v[2] - v[0]);
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn ceil_div(x: i64, y: i64) -> i64 {
    (x + y - 1) / y
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	x := readi()

	ans := 0
	for {
		if isPrime(x) {
			ans = x
			break
		}
		x++
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
    long long N,mi=MOD,ma=-1000000,su=0,a;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        if(a<mi) mi=a;
        if(ma<a) ma=a;
        su+=a;
    }
    cout << mi << ' ' << ma << ' ' << su << endl;
	}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

template <typename T>
class SegmentTree {
    public:
        int n;
        vector<T> data;
        T e;
        function<T(T, T)> operation;
        function<T(T, T)> process;

        SegmentTree() {}
        SegmentTree(int n_, T e_, function<T(T, T)> operation_, 
            function<T(T, T)> process_) : e(e_), operation(operation_), process(process_) {
            n = 1;
            while (n < n_) n <<= 1;
            data.assign(2 * n, e);
        }

        T query(int a, int b) {
            return query(a, b + 1, 1, 0, n);
        }

        T query(int a, int b, int k, int l, int r) {
            if (a >= r || b <= l) return e;
            if (a <= l && b >= r) return data[k];
            T c = query(a, b, 2 * k + 0, l, (l + r) / 2);
            T d = query(a, b, 2 * k + 1, (l + r) / 2, r);
            return operation(c, d);
        }

        void update(int idx, T v) {
            idx += n;
            data[idx] = process(data[idx], v);
            while (idx >>= 1) {
                data[idx] = operation(data[2 * idx + 0], data[2 * idx + 1]);
            }
        }

        T operator[](int idx) {
            return data[idx + n];
        }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<SegmentTree<int> > alp;
    rep (i, 26) {
        SegmentTree<int> seg = SegmentTree<int>(n, 0, 
            [](int a, int b) { return max(a, b); }, [](int a, int b) { return b; });
        alp.push_back(seg);
    }
    rep (i, s.size()) alp[s[i] - 'a'].update(i, 1);
    rep (_, q) {
        int t;
        cin >> t;
        if (t == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            idx--;
            rep (i, 26) alp[i].update(idx, 0);
            alp[c - 'a'].update(idx, 1);
        } else {
            int res = 0;
            int l, r;
            cin >> l >> r;
            l--, r--;
            rep (i, 26) res += alp[i].query(l, r);
            cout << res << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 114460
#include<bits/stdc++.h>
using namespace std;
const int MN = 81, LOG = 60, MOD = 1e9+7, ADD = MN*MN*2;
using pii = pair<int,int>;
using ll = long long;
bool dp[MN][MN][MN*MN*4];
int a[MN][MN], b[MN][MN];
int main () {
	int n,m;
	scanf ("%d %d",&n,&m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf ("%d",&a[i][j]);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf ("%d",&b[i][j]);
	dp[1][1][a[1][1]-b[1][1]+ADD] = dp[1][1][b[1][1]-a[1][1]+ADD] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1+(i==1); j <= m; j++) {
			int mx = 80*(i+j);
			for (int k = -mx; k <= mx; k++) {
				dp[i][j][k+ADD] |= dp[i-1][j][k+ADD+a[i][j]-b[i][j]] | dp[i-1][j][k+ADD+b[i][j]-a[i][j]] | dp[i][j-1][k+ADD+a[i][j]-b[i][j]] | dp[i][j-1][k+ADD+b[i][j]-a[i][j]];
			}
		}
	}
	int ans = INT_MAX;
	for (int i = 0; i < (ADD<<1); i++) if (dp[n][m][i]) ans = min(ans,abs(ADD-i));  
	printf ("%d\n",ans);
	return 0;
}

Measured memory_bytes: 166400
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define MAX_N 20
#define WIDTH 100
int OK[5][5] = { {0,0,1,0,0},{0,1,1,1,0},{1,1,1,1,1},{0,1,1,1,0},{0,0,1,0,0} };
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
pair<int, vector<vector<int>>> dp[MAX_N + 2][WIDTH], E[WIDTH * 10];

int score(vector<vector<int>>p) {
	int sum = 0; pair<int, int>a[12], b[12]; int CNT = 0;
	for (int i = 0; i < 25; i++) {
		if (p[i / 5][i % 5] >= 1)a[p[i / 5][i % 5]] = make_pair(i / 5, i % 5);
	}
	for (int i = 5; i < 20; i++) {
		if (OK[i / 5][i % 5] == 1) { CNT++; b[CNT] = make_pair(i / 5, i % 5); }
	}
	for (int i = 1; i <= 11; i++) { sum += abs(a[i].first - b[i].first) + abs(a[i].second - b[i].second); }
	return sum;
}
vector<vector<int>> Move(vector<vector<int>>p, int x, int y,int dir) {
	swap(p[x + dx[dir]][y + dy[dir]], p[x][y]); return p;
}
int BeemSearch(vector<vector<int>>Z) {
	vector<vector<int>>GOAL; int CNT = 0;
	for (int i = 0; i < 5; i++) { vector<int>GOAL2(5, -1); GOAL.push_back(GOAL2); }
	for (int i = 5; i < 20; i++) {
		if (OK[i / 5][i % 5] == 1) { CNT++; GOAL[i / 5][i % 5] = CNT; }
	}
	GOAL[0][2] = 0; GOAL[4][2] = 0;
	if (Z == GOAL)return 0;
	dp[0][0] = make_pair(score(Z), Z);
	for (int i = 0; i < MAX_N; i++) {
		int CNTS = 0;
		for (int j = 0; j < WIDTH; j++) {
			if (dp[i][j].second.size() == 0)continue;
			vector<vector<int>>D = dp[i][j].second;
			for (int k = 0; k < 25; k++) {
				if (D[k / 5][k % 5] != 0)continue;
				for (int l = 0; l < 4; l++) {
					int cx = (k / 5) + dx[l], cy = (k % 5) + dy[l];
					if (cx < 0 || cx >= 5 || cy < 0 || cy >= 5)continue;
					if (D[cx][cy] <= 0)continue;
					vector<vector<int>>D2 = Move(D, k / 5, k % 5, l);
					E[CNTS] = make_pair(score(D2), D2); CNTS++;
				}
			}
		}
		sort(E, E + CNTS); dp[i + 1][0] = E[0]; int CNT2 = 1;
		if (E[0].first == 0)return i + 1;
		for (int j = 1; j < CNTS; j++) {
			if (E[j - 1] != E[j]) { dp[i + 1][CNT2] = E[j]; CNT2++; }
			if (CNT2 == WIDTH)break;
		}
	}
	return -1;
}
int main() {
	while (true) {
		for (int i = 0; i < MAX_N + 2; i++) {
			for (int j = 0; j < WIDTH; j++) {
				vector<vector<int>>ZERO; dp[i][j] = make_pair(0, ZERO);
			}
		}
		for (int i = 0; i < WIDTH * 10; i++) { vector<vector<int>>ZERO; E[i] = make_pair(0, ZERO); }
		vector<vector<int>>C;
		for (int i = 0; i < 5; i++) { vector<int>C2(5, -1); C.push_back(C2); }
		cin >> C[0][2]; if (C[0][2] == -1)break;
		for (int i = 1; i < 4; i++)cin >> C[1][i];
		for (int i = 0; i < 5; i++)cin >> C[2][i];
		for (int i = 1; i < 4; i++)cin >> C[3][i]; cin >> C[4][2];
		int ret = BeemSearch(C);
		if (ret == -1)cout << "NA" << endl; else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3928
N, K = map(int, input().split())
S = input()

largest = 0
largest_left_index = -1

sum_list = list()

count = 0
for i in range(N):
    if S[i] == "L":
        if count <= 0:
            count = count - 1
        else:
            sum_list.append(count)
            count = -1
    elif S[i] == "R":
        if count >= 0:
            count = count + 1
        else:
            sum_list.append(-count)
            count = 1
else:
    sum_list.append(count) if count > 0 else sum_list.append(-count)

happines = 0
for i in range(len(sum_list)):
    happines = happines + sum_list[i] - 1

length = len(sum_list)

for i in range(K):
    if length > 2:
        happines = happines + 2
        length = length - 2
    elif length == 2:
        happines = happines + 1
        length = length - 1

print(happines)

Measured memory_bytes: 4092
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val dic = (0..9).map { (0..9).map { 0 }.toMutableList() }
    for(i in (1..n)) {
        if(i % 10 == 0) {
            continue
        }
        val startNum = i.toString()[0].toString().toInt()
        val endNum = i % 10
        dic[startNum][endNum]++
    }
    var ans = 0L
    for(i in (1..9)) {
        for(j in (1..9)) {
            ans += dic[i][j].toLong() * dic[j][i].toLong()
        }
    }
    println(ans)
}


Measured memory_bytes: 40716
// Problem : B - Minor Change
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int c = 0;
    rep(i, 0, n - 1) {
      if (s[i] != t[i]) c++;
    }
    cout << c << '\n';
  }

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) cin >> P[i];

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] != i + 1) cnt++;
    }
    if (cnt == 0 || cnt == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g;
    g.resize(n);
    int a, b;
    rep(i,0,m){
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<bool> visited(n, false);
    vector<int> path(n);
    queue<int> q;
    q.push(0);
    visited[0] = true;
    path[0] = 1;
    while(!q.empty()){
        auto u = q.front();
        q.pop();
        for(auto v : g[u]){
            if(!visited[v]){
                path[v] = u + 1;
                q.push(v);
                visited[v] = true;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(!visited[i]){
            cout << "No";
            return;
        }
    }
    cout << "Yes\n";
    rep(i,1,n){
        cout << path[i] << "\n";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin >> t; while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 10136
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	map<int,int> mp;
	vi vec(n);
	rep(i,0,n){
		int a; cin>>a;
		mp[a]++;
		vec[i]=a;
	}
	if(mp[1]==0){
		cout<<-1;
		return 0;
	}
	ll ans=0;
	//sort(all(vec));
	int k=1;
	rep(i,0,n){
		if(vec[i]==k){
			k++;
		}
		else ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {

	static int n;
	static int[][] a;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int[2][n];
		for(int i = 0 ; i < 2 ; i++) {
			for(int j = 0 ; j < n ; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int[][] dp = new int[2][n];
		dp[0][0] = a[0][0];
		dp[1][0] = a[0][0] + a[1][0];
		if(n == 2) dp[0][1] = a[0][0] + a[0][1];
		for(int i = 0 ; i < 2 ; i++) {
			for(int j = 1 ; j < n ; j++) {
				if(i == 0) {
					dp[i][j] = Math.max(dp[i][j - 1] + a[i][j], dp[i + 1][j] + a[i][j]);
				} else if(i == 1) {
					dp[i][j] = Math.max(dp[i - 1][j] + a[i][j], dp[i][j - 1] + a[i][j]);
				}
			}
		}
		System.out.println(dp[1][n - 1]);
	}
}


Measured memory_bytes: 21716
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def max_group_members(self):
        return -min([i for i in self.parents if i<0])
    
N,M = map(int,input().split())

uf = UnionFind(N+1)
for _ in range(M):
    a,b = list(map(int, input().split()))
    uf.union(a,b)

print(uf.max_group_members())

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

int main() {
    string num;
    cin >> num;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (num[i] == '1')
        {
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
from collections import Counter
S = input()
S = S[::-1]
# 1桁のmod2019, 2桁の2019, ...
# 0桁のmod2019=0と定めると都合が良いので入れておく
l = [0]
num = 0
for i in range(len(S)):
    # 繰り返し二乗法で累乗の部分を高速化
    # 自分で書かなくてもpow()で既に実装されている
    # 一つ前のmodを利用しても良いが、ボトルネックはクソデカ累乗（のmod計算）の方なのでそこまで意味はない
    num += int(S[i]) * pow(10,i,2019)
    l.append(num % 2019)
# print(l)
ans = 0
c = Counter(l)
for v in c.values():
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 86956
def resolve():
    a, b = input().split()

    ans = str()
    if a == "H":
        if b == "H":
            ans = "H"
        elif b == "D":
            ans = "D"
    elif a == "D":
        if b == "H":
            ans = "D"
        elif b == "D":
            ans = "H"
    
    print(ans)

resolve()

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> v;
    for(int i = 0; i <= n; i++) if(s[i] == '0') v.push_back(i);
    int now = n;
    vector<int> ans;
    while(now > 0){
        int next = *lower_bound(v.begin(), v.end(), max(0, now - m));
        if(next == now){
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(now - next);
        now = next;
    }
    for(int i = (int)ans.size() - 1; i >= 0; i--) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1592
#include<cstdio>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2005;

bitset<N*N> ans;
int n,a[N],m;

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

	for (int i=1;i<=n;i++) scanf("%d",&a[i]),m+=a[i];
	ans.set(0);
	for (int i=1;i<=n;i++) ans=ans|(ans<<a[i]);

	for (int i=(m+1)/2;i<=m;i++) 	if (ans[i]) 
	{
		printf("%d",i);
	//	system("pause");
		return 0;
	}

	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string a, b, c;
  cin >> a >> b >> c;

  if (a[a.size()-1] == b[0]  && b[b.size()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


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

int N;

void dfs(string s, char mx) {
    if(s.length() == N) {
        cout << s <<'\n';
    } else {
        for(char c = 'a'; c <= mx; ++c) {
            dfs(s + c, ((c == mx)?(char)(mx + 1):mx));
        }
    }
}

int main() { 
    cin >> N;
    dfs("", 'a');
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    string s;
    cin >> n >> s;
    vi a(n);
    rep(i, n) {
        if (s[i]=='R') a[i] = 0;
        if (s[i]=='G') a[i] = 1;
        if (s[i]=='B') a[i] = 2;
    }
    vi cnt(3);
    rep(i, n) cnt[a[i]]++;
    ll ans = 1;
    rep(i, 3) ans *= cnt[i];
    rep(i, n) for (int j=i; j+(j-i)<n; ++j) {
        int k = j+(j-i);
        if (a[i]==a[j]) continue;
        if (a[i]==a[k]) continue;
        if (a[j]==a[k]) continue;
        --ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int> > cake(H, vector<int>(W));
    vector<bool> flags(H, false);
    for (int i = 0; i < H; i++) {
        string str; cin >> str;
        bool f = false;
        for (int j = 0; j < W; j++) {
            char c = str[j];
            if (c == '#') {
                cake[i][j] = 0;
                f = true;
            } else {
                cake[i][j] = -1;
            }
        }
        if (f) {
            flags[i] = true;
        }
    }
    int num = 1;
    for (int i = 0; i < H; i++) {
        bool fl = true;
        if (!flags[i] && i != 0) {
            for (int j = 0; j < W; j++) {
                cake[i][j] = cake[i-1][j];
            } 
        } else if(flags[i]) {
            for (int j = 0; j < W; j++) {
            if (cake[i][j] == 0) {
                if (fl) {
                    fl = false;
                } else {
                    num++;
                }
            }
            cake[i][j] = num;
            }
        }
        if (flags[i]) {
            num++;
        }
    }
    for (int i = H-1; i >= 0; i--) {
        for (int j = 0; j < W; j++) {
            if (cake[i][j] == -1) {
                cake[i][j] = cake[i+1][j];
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << cake[i][j] << ' ' << flush;
        }
        cout << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int f[n][5][2];
  int p[n][11];
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++) {
      for (int k = 0; k < 2; k++) {
        cin >> f[i][j][k];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> p[i][j];
    }
  }
  
  int max = -10e7 * n;
  for (int b = 1; b < (1 << 10); b++) {
    int rev = 0;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if ((b >> j) & 1 && f[i][j / 2][j % 2]) {
          cnt++;
        }
      }
      rev += p[i][cnt];
    }
    if (rev > max) {
      max = rev;
    }
  }
  
  cout << max << endl;
}



Measured memory_bytes: 256
# インタラクティブ
n = int(input())

top    = n
bottom = 0
print(0)
s = input()
sex = [-1]*(n+1)
if s == 'Vacant':
    exit(0)
elif s == 'Male':
    sex[0] = sex[n] = 0
else:
    sex[0] = sex[n] = 1

while top - bottom > 1:
    mid = (top+bottom)//2
    print(mid)
    s = input()
    if s  == 'Vacant':
        exit(0)
    elif s == 'Male':
        sex[mid] = 0
    else:
        sex[mid] = 1
    if (sex[top]^sex[mid]) ^ ((top - mid)%2):
        bottom = mid
    else:
        top = mid

print(bottom)
s = input()
if s != 'Vacant':
    print(top%n)
    s = input()


Measured memory_bytes: 4424
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

int INF = 1<<25;
bool solve() {
    int H, W;
    readf("%d %d\n", &H, &W);
    if (H==0 && W==0) return false;

    bool[][] flag = H.iota.map!(_ => readln.chomp.map!(c=>c=='.').array).array;
    int[][] ary = new int[][](H, W+1);
    foreach(j; 0..W) {
        int s = 0;
        foreach_reverse(i; 0..H) {
            if (flag[i][j]) {
                ary[i][j] = ++s;
            } else {
                s = 0;
            }
        }
    }
    
    int ans = 0;
    foreach(i; 0..H) {
        auto list = DList!(int[])([[0, -1]]); // Stack
        foreach(j; 0..W+1) {
            int index = j;
            while(list.back[0]>ary[i][j]) {
                index = list.back[1];
                ans = max(ans, (j-list.back[1])*list.back[0]);
                list.removeBack;
            }
            if (list.back[0]<ary[i][j]) {
                list.insertBack([ary[i][j], index]);
            }
        }
    }
    ans.writeln;
    return true;
}

void main() {
    while(solve()){}
}

Measured memory_bytes: 10860
import bisect as bi

a,b,q=map(int,input().split())

INF=10**15

S=[-INF]+[int(input()) for i in range(a)]+[INF]
T=[-INF]+[int(input()) for i in range(b)]+[INF]
X=[int(input()) for i in range(q)]

for i in range(q):
    d=bi.bisect_right(S,X[i])
    e=bi.bisect_right(T,X[i])
    as0=abs(X[i]-S[d-1])
    as1=abs(X[i]-S[d])
    at0=abs(X[i]-T[e-1])
    at1=abs(X[i]-T[e])
    ans=min(max(as0,at0),max(as1,at1),2*as0+at1,as0+2*at1,2*at0+as1,at0+as1*2)
    print(ans)


Measured memory_bytes: 17552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    string s;
    cin >> s;

    for(int i=0;i<s.size();i++){
        s[i] = 'x';
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans,h;
string s;
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'I')
			h++;
		else
			h--;
		ans = max(ans,h);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }

void searchCC(LL v, vector<vector<LL>>& edge, vector<LL>& memo, vector<LL>& v_set){
    if(memo[v]) return;
    memo[v] = 1;
    v_set.push_back(v);
    for(LL e: edge[v]){
        searchCC(e, edge, memo, v_set);
    }
}

bool checkTurn(LL v, LL v2, LL v3, vector<vector<LL>>& edge, vector<LL>& memo, LL depth=0){
    if(memo[v]) return false;
    memo[v] = 1;
    for(LL u: edge[v]){
        if(u == v2) continue;
        if(depth > 1 && u == v3) return true;
        if(checkTurn(u, v2, v3, edge, memo, depth+1)) return true;
    }
    return false;
}

bool solve(LL n, LL m, vector<vector<LL>>& edge){
    vector<LL> memo(n), memo2(n);
    LL min_v = 0;
    LL max_v = 0;
    for(LL i = 0; i < n; ++i){
        if(memo[i]) continue;
        vector<LL> v_set;
        searchCC(i, edge, memo, v_set);
        vector<LL> four_v;
        vector<LL> six_v;
        for(LL v: v_set){
            LL en = edge[v].size();
            //cerr << "en=" << en << endl;
            if(en % 2 == 1) return false;
            if(en == 4){
                four_v.push_back(v);
            }
            if(en >= 6){
                six_v.push_back(v);
            }
        }
        //cerr << "cnt=" << cnt << endl;
        min_v += 1;
        if(!six_v.empty()){
            max_v += 3;
        }else{
            if(four_v.size() <= 1){
                max_v += 2;
            }else if(four_v.size() == 2){
                //cerr << "debug!" << endl;
                if(checkTurn(four_v[0], four_v[1], four_v[0], edge, memo2)){
                    max_v += 3;
                }else{
                    max_v += 2;
                }
            }else{
                max_v += 3;
            }
        }
    }
    return (min_v <= 3) && (3 <= max_v);
}

int main(){
    LL n, m;
    cin >> n >> m;
    vector<vector<LL>> edge(n);
    for(LL i = 0; i < m; ++i){
        LL u, v;
        cin >> u >> v;
        --u; --v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    if(solve(n, m, edge)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vd vector<double>
#define vull vector<ull>
#define vc vector<char>
#define vs vector<string>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(ll i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(ll i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(ll i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(ll i = a; i >= b; i-=x)
#define tc ll tt; cin >> tt; for(ll cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ld long double
#define reset(x,y) memset(x,y,sizeof x);
#define sqr(x) 1LL*(x)*(x)
#define cube(x) 1LL*(x)*(x)*(x)
#define ub(v, a) upper_bound(all(v), a)
#define lb(v, a) lower_bound(all(v), a)
#define EPS 1e-10
#define INF 2000000000
#define mod 1000000007
#define minof(a) min_element(all(a))
#define maxof(a) max_element(all(a))
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";

int main() {
	IOS
	int n,k;
	cin>>n>>k;
	int a[n+5];
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	for(int i = k; i < n; i++) {
		cout<<(a[i-k]>=a[i]?"No\n":"Yes\n");
	}
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename T>
void printvec(vector<T> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    ll n, m; cin >> n >> m;
    ll ans = 0;
    reppl(i,n+2,m){
        ll ma = i * n - (i-1) * i / 2LL;
        ll mi = (i-1) * i / 2LL;
        ll pl = (ma - mi + 1LL) % MOD;
        ans += pl;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
<?php
fscanf(STDIN, '%d', $N);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
foreach ($A as $k => $v) {
    $A[$k] = $v - $k - 1;
}
sort($A);
if ($N % 2 === 0) {
    $m1 = $A[($N / 2) - 1];    
    $m2 = $A[($N / 2)];
    $med = round(($m1 + $m2) / 2);
} else {
    $med = $A[($N - 1) / 2];
}
$ans = 0;
foreach ($A as $v) {
    $ans += abs($v - $med);
}
printf('%d', $ans);


Measured memory_bytes: 31220
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>
#include <ratio>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << "\n";
}

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

    int T = 1;
    //cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3648
s = input()
n = len(s)

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    
    #＋を入れるか入れないか
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])

print(dfs(0, s[0]))


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int a[106], flag[105];

int main()
{
	int n;
	int al, bob;
	al = bob = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++)
	{
		int MAX = -1;
		for(int j = 1; j <= n; j++)
		{
			if(flag[j] == 0) {
				MAX = max(MAX, a[j]);
			}
		}
		if(i % 2 == 1) al += MAX;
		else bob += MAX;
		for(int j = 1; j <= n; j++)
		{
			if(a[j] == MAX && flag[j] == 0) {
				flag[j] = 1;
				break;
			}
		}
	}
	printf("%d\n", al - bob);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
    int nt,nh,i,temp;
    while (1) {
        scanf("%d %d",&nt,&nh);
        if (nt==0&&nh==0) break;
        int ct[101]={0},ch[101]={0},st=0,sh=0,flag[2]={0};
        for (i=0; i<nt; i++) {
            scanf("%d",&temp);
            st+=temp;
            ct[temp]=1;
        }
        for (i=0; i<nh; i++) {
            scanf("%d",&temp);
            sh+=temp;
            ch[temp]=1;
        }
        if ((st+sh)%2==1) {
            printf("-1\n");
            continue;
        }
        if (nt<nh) {
            for (i=1; i<=100; i++) {
                if (ct[i]==1&&ch[(sh-st)/2+i]==1) {
                    flag[0]=i,flag[1]=(sh-st)/2+i;
                    break;
                }
            }
        } else {
            for (i=1; i<=100; i++) {
                if (ch[i]==1&&ct[(st-sh)/2+i]==1) {
                    flag[0]=(st-sh)/2+i,flag[1]=i;
                    break;
                }
            }
        }
        if (flag[0]==0) {
            printf("-1\n");
        } else {
            printf("%d %d\n",flag[0],flag[1]);
        }
    }
    return 0;
}

Measured memory_bytes: 608
X, Y = map(int, input().split())

x = 0
y = 0
z = 0

if X == 1:
    x = 300000
elif X == 2:
    x = 200000
elif X == 3:
    x = 100000

if Y == 1:
    y = 300000
elif Y == 2:
    y = 200000
elif Y == 3:
    y = 100000

if X == 1 and Y == 1:
    z = 400000

print(x + y + z)

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

void solve(){
    int d,t,s;
    cin >> d >> t >> s;
    if((double)d/s <= t)
        cout << "Yes\n";
    else 
        cout << "No\n";
}

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


Measured memory_bytes: 3632
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_set>
#include<algorithm>
#include<chrono>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
		
#define ii pair	<long long ,long long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;

typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;
		
typedef  pair <ii, ii > iiii;
typedef vector < ii > vii;

const int MAX = 1e2;
const int maxn = 1e6 + 100;
 

int h , n, a[maxn], b[maxn] ,dp[maxn];

int main (){
	
	
	scanf("%d %d",&h, &n );
	memset ( dp, inf, sizeof dp );
	
	for(int i = 0;i < n;i++){
		scanf("%d %d", &a[i],&b[i]);
	}
	
	dp[0] = 0;
	int ans = inf;
	
	for(int i = 0 ;i < n;i++){
		for(int v = 0; v <= h;v++){
			int dmg = a[i];
			int cost = b[i];
			if ( dp[v+dmg] > dp[v]+cost){
				dp[v+dmg] = dp[v]+cost;
				if ( v+dmg >= h && dp[v+dmg] < ans )
					ans = dp[v+dmg];
			}
			
		}
	}
	printf("%d\n", ans );
	
	
	return 0;
}


Measured memory_bytes: 6400
s = input()

if len(s) % 2 == 0:
    c = 0
    m = len(s) // 2 - 1
    x = s[m]
    while c <= m and x == s[m-c] and x == s[m+1+c]:
        c += 1
    print(len(s) // 2 + c)
else:
    c = 0
    m = len(s) // 2
    x = s[m]
    while c < m and x == s[m-1-c] and x == s[m+1+c]:
        c += 1
    print(len(s) // 2 + c + 1)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int egcd(int a, int b, int &x, int &y)
{
	int xx = y = 0;
	int yy = x = 1;
	while (b)
	{
		int q = a/b;
		int t = b; b = a%b; a = t;
		t = xx; xx = x - q*xx; x = t;
		t = yy; yy = y - q*yy; y = t;
	}
	return a;
}

ll inverse(ll a)
{
	a = a % MOD;
	int x, y;
	egcd(a, MOD, x, y);
	return (x % MOD + MOD) % MOD;
}

ll h, w, a, b;

ll f[112123], g[112123];

int main()
{
	cin >> h >> w >> a >> b;
	f[0] = g[0] = 1;
	for (int i = 1; i < h - a; i++)
		f[i] = f[i-1] * (b - 1 + i) % MOD * inverse(i) % MOD;
	for (int i = 1; i < h; i++)
		g[i] = g[i-1] * (w - b - 1 + i) % MOD * inverse(i) % MOD;
	ll ans = 0;
	for (int i = 0; i < h - a; i++) ans = (ans + f[i] * g[h - 1 - i] % MOD) % MOD;
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 1792