akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>

int main(int argc, char *argv[]) {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> h(n);

  if (n <= k){
    std::cout << 0 << std::endl;
    return 0;
  }

  for (int i = 0; i < n; ++i)
    std::cin >> h.at(i);

  std::sort(h.begin(), h.end(), std::greater<int>());

  std::cout << std::accumulate(h.begin() + k, h.end(), 0ll) << std::endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define MAX_TYPE 4
#define MAX_RANK 13

int main(int argc, char **argv){
	int i,j;
	char buf[256];
	int data[MAX_TYPE][MAX_RANK] = {};
	int len,rank,type;
	char ch_type;
	
	// Input
	fgets( buf, 256, stdin);
	sscanf( buf, "%d",&len);
	for(i=0;i<len;i++){
		fgets( buf, 256, stdin);
		sscanf( buf,"%c %d",&ch_type,&rank);
		// Convert Type
		type = 0;
		switch(ch_type){
		case 'S':
			type = 0;
			break;
		case 'H':
			type = 1;
			break;
		case 'C':
			type = 2;
			break;
		case 'D':
			type = 3;
			break;
		default:
			return 1;
		}
		// Found
		data[type][rank-1] = 1;
	}
	
	// Output
	for(i=0;i<MAX_TYPE;i++){
		for(j=0;j<MAX_RANK;j++){
			if( !data[i][j] ){
				// Convert Type
				ch_type = 'S';
				switch(i){
				case 0:
					ch_type = 'S';
					break;
				case 1:
					ch_type = 'H';
					break;
				case 2:
					ch_type = 'C';
					break;
				case 3:
					ch_type = 'D';
					break;
				default:
					break;
				}
				printf("%c %d\n",ch_type,j+1);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  ll product = 1;
  int divisor = 1e9 + 7;

  cin >> n;

  repf(i, 1, n + 1) {
    product = (product * i) % divisor;
  }

  cout << product << endl;
}

Measured memory_bytes: 3624
#![allow(unused_imports)]
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        mut a: [i64; n],
    }
    let m = 1000000007i64;
    let mod_product = |acc: i64, &value: &i64| {
        (acc * value).rem_euclid(m)
    };

    if k == n || k % 2 == 1 && a.iter().all(|v| *v <= 0) {
        a.sort_by_key(|v| -*v);
        let ans = a.iter().take(k).fold(1, mod_product);
        println!("{}", ans);
        return;
    }

    a.sort_by_key(|v| Reverse(v.abs()));
    let mut plus = Vec::new();
    let mut minus = Vec::new();
    for i in 0..n {
        if a[i] >= 0 {
            plus.push(a[i]);
        } else {
            minus.push(a[i]);
        }
    }

    let mut ppos = 0;
    let mut mpos = 0;
    let mut vals = Vec::new();
    let mut retry = false;
    while vals.len() < k {
        if vals.len() < k - 1 && ppos + 1< plus.len() && mpos + 1 < minus.len() {
            if plus[ppos] * plus[ppos+1] < minus[mpos] * minus[mpos+1] {
                vals.push(minus[mpos]);
                vals.push(minus[mpos+1]);
                mpos += 2;
            } else {
                vals.push(plus[ppos]);
                vals.push(plus[ppos+1]);
                ppos += 2;
            }
        } else if vals.len() < k - 1 && mpos + 1 < minus.len() {
            vals.push(minus[mpos]);
            vals.push(minus[mpos+1]);
            mpos += 2;
        } else if ppos < plus.len() {
            vals.push(plus[ppos]);
            ppos += 1;
        } else {
            retry = true;
            break;
        }
    }
    let ans = if !retry {
        vals.iter().fold(1, mod_product)
    } else {
        a.sort_by_key(|v| v.abs());
        assert!(k % 2 == 1);
        assert!(a.iter().filter(|v| **v > 0).count() == 2);
        a.iter().take(k).fold(1, mod_product)
    };
    println!("{}", ans);
}


Measured memory_bytes: 9780
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    r = N % 1000
    if r == 0:
        print(0)
    else:
        print(1000 - r)

if __name__ == '__main__':
    solve()


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

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

    int n, cnt = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        if(i % 2 == 1)
            cnt++;
    }
    double ans = (double) cnt / n;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3792
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int P = sc.nextInt();
        int[] A = new int[N];
        int even = 0;
        int odd = 0;
        for (int i = 0; i < N; ++i) {
            A[i] = sc.nextInt();
            if (A[i] % 2 == 0) {
                ++even;
            } else {
                ++odd;
            }
        }
        int sum = Arrays.stream(A).sum();

        if (P == 0) {
            long res = 0;
            for (int i = 0; i <= even; ++i) {
                for (int j = 0; j <= odd; j += 2) {
                    res += C(even, i).multiply(C(odd, j)).longValue();
                }
            }
            _out.println(res);
        } else {
            if (odd > 0) {
                long res = 0;
                for (int i = 0; i <= even; ++i) {
                    for (int j = 1; j <= odd; j += 2) {
                        res += C(even, i).multiply(C(odd, j)).longValue();
                    }
                }
                _out.println(res);
            } else {
                _out.println(0);
            }
        }
    }
    private long calc(int d, int p, int[] a, int sum) {
        if (d == a.length) {
            return (sum % 2 == p ? 1 : 0);
        }

        long res1 = calc(d + 1, p, a, sum);
        long res2 = calc(d + 1, p, a, sum + a[d]);
        return res1 + res2;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 28216
def main():
    n = int(input())

    c = 0
    for i in range(n + 1)[1:]:
        if (1 <= i and i <= 9) or (100 <= i and i <= 999) or (10000 <= i and i <= 99999):
            c += 1

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
bool f(int x) {
  	for(int i=2;i*i<=x;i++) if(x%i==0) return 0;
  	return 1;
}
int main() {
	int x;cin>>x;
  	while(1) {
     	if(f(x)) {cout<<x;break;}
      	x++;
    }
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
ll n, t, a;
cin >> n >> t >> a;
vll h(n);
vin(h);

db min = abs(a - t + h.at(0) * 0.006);
ll ans = 1;
rep(i, 2, n + 1){
  if(min > abs(a - t + h.at(i - 1) * 0.006)){
    min = abs(a - t + h.at(i - 1) * 0.006);
    ans = i;
  }
}
cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))

good = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    good[B] = False
  if H[A] <= H[B]:
    good[A] = False
print(sum(good))


Measured memory_bytes: 20032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;
#define SEG_LEN (1 << 20)

int seg[26][SEG_LEN * 2];

void add(int cha, int ind, int v){
    ind += SEG_LEN;
    seg[cha][ind] += v;
    while(true){
        ind /= 2;
        if(ind == 0)break;
        seg[cha][ind] = seg[cha][ind * 2] + seg[cha][ind * 2 + 1];
    }
}

int sum(int cha, int l, int r){
    l += SEG_LEN;
    r += SEG_LEN;
    int ans = 0;
    while(l < r){
        if(l % 2 == 1){
            ans += seg[cha][l];
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            ans += seg[cha][r-1];
            r--;
        }
        r /= 2;
    }
    return ans;
}

int main(){
  int n,q;
  string s;
  cin >> n >> s >> q;
  rep(i,n){
    add(s[i]-'a',i+1,1);
  }
  rep(j,q){
    int id;
    cin >> id;
    if(id==1){
      int i;
      char c;
      cin >> i >> c;
      add(s[i-1]-'a',i,-1);
      add(c-'a',i,1);
      s[i-1]=c;
    }else{
      int ans=0;
      int l,r;
      cin >> l >> r;
      rep(k,26){
        if(sum(k,l,r+1))ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 159620
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {

        Scanner scan = new Scanner(System.in);




        while(true){
            int H = scan.nextInt();
            int W = scan.nextInt();

            if(H == 0 && W == 0){
                break;
            }

            for(int h = 0; h < H; h++){
                for(int w = 0; w < W; w++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");

        }

    }
}



Measured memory_bytes: 38172
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	if(s[0] == 'S') puts("Cloudy");
	if(s[0] == 'C') puts("Rainy");
	if(s[0] == 'R') puts("Sunny");
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    string s; cin>>s;

    vi prev(n+1,-1);
    for(int i=n; i>0;){
        int idx = -1;
        for(int j=max(0,i-m); j<i; j++){
            if (s[j]=='0'){
                idx = j;
                break;
            }
        }
        if (idx==-1){cout<<"-1\n"; return 0;};
        prev[idx] = i;
        i = idx;
    }
    int now=0;
    for(int v=prev[0]; v!=-1; v=prev[v]){
        cout<<v-now<<" ";
        now = v;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1104
class UnionFind:
    def __init__(self, n):
        """ノード数nの配列を作る

        親の番号を格納する
        -> 自分が根だった場合は、-(その集合のサイズ)とする
        作るときはparentの値を全て-1にする
        こうすると全てバラバラになる
        """
        self.parent = [-1 for _ in range(n)]

    def root(self, x):
        """要素xの根の番号を返す
        """
        if self.parent[x] < 0:
            # 自分が根
            return x
        # 要素xの親を要素xの根に変えておく
        # 次の呼び出しが早くなる
        self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def size(self, x):
        """要素xの所属するグループの頂点数を調べる

        根のparentにサイズが格納されている
        """
        return -self.parent[self.root(x)]

    def merge(self, x, y):
        """xとyを結合する
        """
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False

        #大きい方(x)に小さい方(y)をくっつけたい
        if self.size(x) < self.size(y):
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return True

N,M=map(int, input().split())

AB= [list(map(int, input().split())) for _ in range(M)]
ans=0
for i in range(M):
    uf = UnionFind(N)
    hens = AB[0:i]+AB[i+1:]
    for hen in hens:
        x,y = hen
        uf.merge(x-1, y-1)

    if uf.size(0) != N:
        ans+=1
print(ans)


Measured memory_bytes: 41584
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String f = sc.nextLine();
		if(f.equals("SUN")){
			System.out.println(7);
		}
		if(f.equals("MON")){
			System.out.println(6);
		}
		if(f.equals("TUE")){
			System.out.println(5);
		}
		if(f.equals("WED")){
			System.out.println(4);
		}
		if(f.equals("THU")){
			System.out.println(3);
		}
		if(f.equals("FRI")){
			System.out.println(2);
		}
		if(f.equals("SAT")){
			System.out.println(1);
		}
	}
}

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

int A[200];
string s;

set<int> S;
bool sub(void){
	S.clear();
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	cin >> s;
	for(int i = n - 1; i >= 0; i--){
		int x = A[i];
//		cout << "process: ";
//		cout << x << endl;
		for(auto ptr = S.rbegin(); ptr != S.rend(); ptr++){
			if(x != 0 && __builtin_clzll(*ptr) == __builtin_clzll(x)){
//				cout << x << ' ' << *ptr << endl;
				x ^= *ptr;
			}
		}
		
//		cout << "round ";
//		cout << i << ' ' << x <<  endl;
//		for(auto j : S){
//			cout << j << ' ';
//		}
//		cout << endl;
		// cout << x << endl;
		if(x == 0){
			continue;
		}else{
			if(s[i] == '1'){
				return 1;
			}
			
			S.insert(x);
		}
	}
	return 0;
}

int32_t main(){
	int t;
	cin >> t;
	while(t--){
		bool res = sub();
		cout << res << endl;
	}
}

Measured memory_bytes: 3640
#include <stdio.h>
#define MAX 500000
#define S 2000000000

int L[MAX/2+2],R[MAX/2+2];
int c;

void merge(int *A, int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right -mid;
  int i;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=S;
  R[n2]=S;
  i=0;
    int j=0, k=0;
  for(j=left;j<right;j++){
    c++;
    if(L[i]<=R[k]){
      A[j]=L[i];
      i++;
    }else{
      A[j]=R[k];
      k++;
    }
  }
}

void mergeSort(int *A,int n, int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
int main(){
  int A[MAX],n,i;
  c=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else  printf("%d ",A[i]);
  }
  printf("%d\n",c);
  return 0;
}

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

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

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

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

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

    ($next:expr, 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")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        a:i64,
        b:i64,
    }
    let add = a + b;
    let sub = a - b;
    let calc = a * b;
    let ans = max(add,max(sub,calc));
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
/* ex3_4
    suuxxu */

#include <stdio.h>

int main(void){
    int n, i, answer; // n is input number
    
    // get inputs
    scanf("%d", &n);

    // calculate answer
    answer = 0; // answer is no
    for(i = 1; i < 10; i++){ // divide by 1 to 9
        if(n / i < 10 && n % i == 0){ // if divisible by i and Quotient is less than 10
            answer = 1; // answer is yes
        }
    }

    // output answer
    if(answer == 1){ // if answer is yes
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e6 + 5;
ll N, A[MAX];

int main(){
    scanf("%lld" ,&N);
    for(int i = 1; i <= N; i++){
        scanf("%lld", A + i);
    }
    sort(A + 1, A + N + 1);
    deque<ll> dq;
    int l = 2, r = N - 1;
    dq.push_back(A[1]); dq.push_back(A[N]);
    while(l <= r){
        priority_queue<pair<ll, ll>> pq;
        pq.push({abs(dq.front() - A[l]), 0});
        pq.push({abs(dq.front() - A[r]), 1});
        pq.push({abs(dq.back() - A[l]), 2});
        pq.push({abs(dq.back() - A[r]), 3});
        if(pq.top().second == 0){
            dq.push_front(A[l]);
            l++;
        }
        else if(pq.top().second == 1){
            dq.push_front(A[r]);
            r--;
        }
        else if(pq.top().second == 2){
            dq.push_back(A[l]);
            l++;
        }
        else{
            dq.push_back(A[r]);
            r--;
        }
    }
    vector<ll> vt;
    while(!dq.empty()){
        vt.push_back(dq.back());
        dq.pop_back();
    }
    ll ans = 0;
    for(int i = 1; i < N; i++){
        ans += abs(vt[i] - vt[i - 1]);
    }
    printf("%lld\n" ,ans);
    return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b ? "true" : "false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	for(int i = 0; i < (int) v.size(); i++)
		res += char('0' + v[i]);
	return res;
}
 
template<size_t S> string to_string(bitset<S> b) {
	string res;
	for(int i = 0; i < S; i++)
		res += char('0' + b[i]);
	return res;
}

template<class T> string to_string(T v) {
    bool f = 1;
    string res;
    for(auto& x : v) {
		if(!f)
			res += ' ';
		f = 0;
		res += to_string(x);
	}
    return res;
}
 
void DBG() {
	cerr << "]" << endl;
}

template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
		cerr << ", ";
	DBG(t...);
}

#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};

void solve() {
	int n = 20, x = 12, t = 6;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x ) * t;
}	
 
int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++) {
		//cout << "Case #" << i << ": ";
		solve();
	}
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int a,b;

signed main() {
    cin >> a >> b;
    cout << max(a,b) + max(max(a,b)-1,min(a,b)) << endl;
}


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

int main(){
  string s;cin>>s;
  int ans=0;

  REP(i,s.size()){
    ans+=s.at(i)-'0';  
  }

  cout<<(ans%9?"No":"Yes");
}

Measured memory_bytes: 3752
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
	int a,b,c,d;
	scanf("%d",&a);
	if(a/100==7||a/10%10==7||a%10==7)printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n",min(b,a*n));
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
#define ac fstream cin("input.txt");ofstream cout("output.txt");
class ArcadeManao
{
    public:
int shortestLadder(vector <string> level, int coinRow, int coinColumn)
{

   }
};
int A[100005]={};
int main()
{
    int a;
    while(cin>>a){
    for(int i=1;i<=a;i++){
     cin>>A[i];
    }
    int ans=0;
    for(int i=1;i<a;i++){
        if(i==A[i]){
            swap(A[i],A[i+1]);
            ans++;
        }
    }
    if(A[a]==a){
        ans++;
    }
    cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0 ;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(x) x.begin(),x.end()
#define REVERSE(x) reverse(x.begin(),x.end())
#define SORT(x,n) sort(x,x)
#define P pair<int,int>
typedef long long LL;
const int INF=1000000007;
using namespace std;
int gcd(int a,int b){
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
int N;
int h[100]={};
int count(int height,int i){
  if(i==0&&h[i]>=height){
    return count(height,i+1)+1;
  }
  if(i==N-1){
    return 0;
  }
  else{
    if(h[i]<height&&h[i+1]>=height){
     return count(height,i+1)+1;
    }
    else{
      return count(height,i+1);
    }
  }
}
int main(){
  cin>>N; 
  REP(i,N){
    cin>>h[i];
  }
  if(N==1){
    cout<<h[0];
  }
  else{
  int ans=0;
  FOR(x,1,101){
   ans+=count(x,0);
  }
  cout<<ans;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")

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

using l = long int;
using ll =long long int;
using u64 = uint64_t;
// using u128 = __uint128_t;
#define imax INT_MAX
#define lmax LLONG_MAX
#define pb push_back
#define ld long double
#define pii pair<l,l> 
#define pll pair<ll,ll>
#define v vector
#define vl vector<l>
#define vll vector<ll>
#define vvl vector<vector<l>>
#define vvll vector<vector<ll>>
#define vv(a) vector<vector<a>> 
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x)rend()
#define f first
#define s second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define rep(i, begin, end) \
        for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tc l t=0;cin>>t;while(t--)

// ONLINE JUDGE START
#ifndef ONLINE_JUDGE
    // FILE

    #define file ofstream cout; ifstream cin; cout.open("output.txt"); cin.open("input.txt");  
    // DEBUG

    #define debug(x) cout<<"LINE NUMBER:     "<<__LINE__<<"\t :--> \t"<<#x<<"   =   "<<x<<endl;

#else 

    #define debug(x) 

#endif


// SYSTEM
#define DeBuG(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); \
            DeBuG("%s:%.4f s\n",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))

// OVERLOADING
istream& operator >> (istream& cin,vll &a){
    for(auto &i:a)cin>>i;
    return cin;
}
ostream& operator << (ostream& cout,pll &a){
    cout<<a.f<<" "<<a.s<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vl &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,vll &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,v<pll> &a){
    for(auto &i:a)cout<<i<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vvl &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,vvll &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,map<l,l> &a){
    for(auto &i:a){
        cout<<i.f<<" ";
    }
    return cout;
}


// GLOBAL VARIABLE AND FUNTIONS
const ll inf = 1e9+7;

int main()
{
#ifndef ONLINE_JUDGE
    // file;
#endif 
	fast;

     ll n,m;cin>>n>>m;
     string st;
     st= (n==m ? "Yes" : "No");
     cout<<st;

#ifndef ONLINE_JUDGE
    // cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
ans = 10**9

N,K = map(int, input().split())
H = []
for i in range(N):
    x = int(input())
    H.append(x)
H = sorted(H)
for i in range(N-(K-1)):
    y = H[i+(K-1)]-H[i]
    ans = min(y,ans)
print(ans)

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    string s;
    cin>>s;
    int ans;
    vector<int> a,z;
    rep(i,s.size()) {
        if (s[i]=='A') a.push_back(i);
        if (s[i]=='Z') z.push_back(i);
    }
    sort(a.begin(),a.end());
    sort(z.begin(),z.end(),greater<int>());
    ans=z[0]-a[0]+1;
    cout<<ans<<endl;
    return 0;
}


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


N = int(input())

A = list(map(int, input().split()))


ans = 0

for i in range(N - 1):
    if A[i] > A[i + 1]:
        ans += A[i] - A[i + 1]
        A[i + 1] = A[i]

print(ans)

Measured memory_bytes: 92132
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

vector<int> pow2(){
    vector<int> vec(1,1);
    for(int i=0; vec[i]<(int)MOD; i++){
        vec.push_back(2*vec[i]);
    }
    return vec;
}

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

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

    map<int,int> m;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        m[a]++;
    }

    vector<int> vec=pow2();
    //cout_vec(vec);
    int ans=0;
    for(auto it=m.rbegin(); it!=m.rend(); it++){
        int key=it->first;
        int cnt=it->second;
        if(cnt==0)continue;

        auto tg=upper_bound(vec.begin(),vec.end(),key);
        //cout << key << ' ' << *tg-key << endl;
        if(tg!=vec.end() && m.count(*tg-key)){
            if(key==*tg-key && m[*tg-key]>=2){
                int num=m[key]/2;
                m[key]-=2*num;
                ans+=num;
            }else if(key!=*tg-key && m[*tg-key]>0){
                int num=min(m[key],m[*tg-key]);
                m[key]-=num;
                m[*tg-key]-=num;
                ans+=num;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
using System;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] a_asArgs)
		{
			Console.ReadLine();
			long[] l_aiA = ("0 " + Console.ReadLine() + " 0").Split(' ').Select(a => long.Parse(a)).ToArray();

			long l_iTotal = 0;
			long[] l_iDiff = new long[l_aiA.Length - 2];
			for (int l_iIndex = 0; l_iIndex < l_aiA.Length - 1; l_iIndex++)
			{
				l_iTotal += Math.Abs(l_aiA[l_iIndex] - l_aiA[l_iIndex + 1]);
				if (l_iIndex < l_aiA.Length - 2)
				{
					l_iDiff[l_iIndex] = Math.Abs(l_aiA[l_iIndex] - l_aiA[l_iIndex + 1]) + Math.Abs(l_aiA[l_iIndex + 1] - l_aiA[l_iIndex + 2]) - Math.Abs(l_aiA[l_iIndex] - l_aiA[l_iIndex + 2]);
				}
			}

			for (int l_iIndex = 0; l_iIndex < l_aiA.Length - 2; l_iIndex++)
			{
				Console.WriteLine(l_iTotal - l_iDiff[l_iIndex]);
			}
		}
	}
}


Measured memory_bytes: 29020
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>


typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
   /* x, y, z の中間値を返す */
{
   if (x < y)
      if (y < z) return y; else if (z < x) return x; else return z; else
         if (z < y) return y; else if (x < z) return x; else return z;
}


void quicksort(int a[], int left, int right)
{
   if (left < right) {
      int i = left, j = right;
      int tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
      while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
         while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
         while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
         if (i >= j) break;
         tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
         i++; j--;
      }
      quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
      quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
   }
}
long powint(int a,int n)
{
   int i;
   long tmp=1;
   for(i=0;i<n;i++)
      tmp *= a;
   return tmp;
}


int main()
{
   static int i,j,k,l;
   int n;
   int f,g;
   static int a[20];
   int q;
   int m[200];
   int sum=0;

   scanf("%d",&n);
   for (i = 0; i < n; i++) {
      scanf("%d",&a[i]);
      sum += a[i];
   }

   scanf("%d",&q);
   for (i = 0; i < q; i++)
      scanf("%d",&m[i]);

   for (i = 0; i < q; i++) {
      if(sum > m[i]) {
         for (j = 1; j < powint(2,n);j++) {
            g = 0;
            f = j;
            for (k = 0; k < n; k++) {
               if(f % 2) g += a[k];
               f /= 2;
            }
            if(g == m[i]) {
               m[i] = 3000;
               break;
            }
         }
      }
      else if(sum == m[i])
         m[i] == 3000;
   }
   for (i = 0; i < q; i++) {
      if (m[i] == 3000)
         printf("yes\n");
      else 
         printf("no\n");
   }





   return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

public class Main {
	static long calcOneCycle(int A[] , int start){
		int cp = start;
		for(int i = 0 ; i < A.length ;  ++i){
			cp = A[cp];
			if(cp == start){
				return i + 1;
			}
		}
		return A.length;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt() - 1;
		}
		boolean vis[] = new boolean[N];
		int cp = 0;
		vis[cp] = true;
		while(K > 0){		
			cp = A[cp];
			K--;
			if(vis[cp]){
				break;
			}
			vis[cp] = true;
		}
		long l = calcOneCycle(A, cp);
//		System.out.println(cp+" "+K+" "+l);
		K = K % l;
//		System.out.println(cp+" "+K+" "+l);
		while(K > 0){		
			cp = A[cp];
			K--;
		}
		System.out.println(cp+1);
	}
}


Measured memory_bytes: 50280
N,i,t,M;double X[30],Y[30],Z[30],cx,cy,cz,d,m;
#define Q(x)(x)*(x)
double D(i){return sqrt(Q(X[i]-cx)+Q(Y[i]-cy)+Q(Z[i]-cz));}
int longest() { 
	double max = 0; int max_i,i=0;
	for(m=i=0; i<N; ++i)
		if (D(i) > m){
			m=D(i);
			M=i;
		}
		return M;
}
int main() {
	while (scanf("%d",&N) && N) {
		for( i=0; i<N; ++i) scanf("%lf%lf%lf", X+i, Y+i, Z+i);
		cx = cy = cz = 0.5;
		for(d=0.5; d>1e-8; d/=2) {
			for(t=0; t<100; ++t) {
				int i = longest();
				cx += (X[i]-cx)*d;
				cy += (Y[i]-cy)*d;
				cz += (Z[i]-cz)*d;
			}
		}
		printf("%.5f\n",D(longest()));
	}
exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005

void solve(){
    int a,b;
    cin >> a >> b;
    cout << a*b << '\n';
}


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

        int tt;
        tt=1;
       // cin >> tt;
        while(tt--){
            solve();
        }
        

}

Measured memory_bytes: 3652
import heapq

H, W, K=map(int, input().split())
x1, y1, x2, y2=map(int, input().split())
c=['@'*(W+2)]+['@'+input()+'@' for _ in range(H)]+['@'*(W+2)]
l=[[-2]*(W+2) for _ in range(H+2)]
ll=[[-2]*(W+2) for _ in range(H+2)]
q=[[0, x1, y1]]

heapq.heapify(q)
ll[x1][y1]=0

while q:
  tmp=heapq.heappop(q)
  if ll[tmp[1]][tmp[2]]==tmp[0]:
    l[tmp[1]][tmp[2]]=tmp[0]
  else:
    continue
  
  j=1
  while j<=K and c[tmp[1]-j][tmp[2]]=='.':
    if l[tmp[1]-j][tmp[2]]==-2:
      heapq.heappush(q, [tmp[0]+1, tmp[1]-j, tmp[2]])
      l[tmp[1]-j][tmp[2]]=-1
      ll[tmp[1]-j][tmp[2]]=tmp[0]+1
      j+=1
    elif ll[tmp[1]-j][tmp[2]]==tmp[0]+1:
      j+=1
    else:
      j=K+1
    
  j=1
  while j<=K and c[tmp[1]+j][tmp[2]]=='.':
    if l[tmp[1]+j][tmp[2]]==-2:
      heapq.heappush(q, [tmp[0]+1, tmp[1]+j, tmp[2]])
      l[tmp[1]+j][tmp[2]]=-1
      ll[tmp[1]+j][tmp[2]]=tmp[0]+1
      j+=1
    elif ll[tmp[1]+j][tmp[2]]==tmp[0]+1:
      j+=1
    else:
      j=K+1
      
  j=1
  while j<=K and c[tmp[1]][tmp[2]-j]=='.':
    if l[tmp[1]][tmp[2]-j]==-2:
      heapq.heappush(q, [tmp[0]+1, tmp[1], tmp[2]-j])
      l[tmp[1]][tmp[2]-j]=-1
      ll[tmp[1]][tmp[2]-j]=tmp[0]+1
      j+=1
    elif ll[tmp[1]][tmp[2]-j]==tmp[0]+1:
      j+=1
    else:
      j=K+1
      
  j=1
  while j<=K and c[tmp[1]][tmp[2]+j]=='.':
    if l[tmp[1]][tmp[2]+j]==-2:
      heapq.heappush(q, [tmp[0]+1, tmp[1], tmp[2]+j])
      l[tmp[1]][tmp[2]+j]=-1
      ll[tmp[1]][tmp[2]+j]=tmp[0]+1
      j+=1
    elif ll[tmp[1]][tmp[2]+j]==tmp[0]+1:
      j+=1
    else:
      j=K+1

if l[x2][y2]<0:
  print(-1)
else:
  print(l[x2][y2])


Measured memory_bytes: 161832
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;
    ll k;
    cin>>k;
    ll a[n],b[n];
    inp_arr(a,n);
    inp_arr(b,n);

    sort(a,a+n);
    sort(b,b+n);

    vector<ll> v;

    for(int i=0;i<n;++i) {
        v.pb(a[i]*b[n-i-1]);
    }

    ll start = 0, end = 1e18;

    ll ans = 0;

    while(start <= end) {

        ll mid = (start + end)/2;

        ll f = 0;

        for(int i=0;i<n;++i) {

            if(v[i] > mid) {

                ll diff = v[i] - mid;
                ll need = ceil((diff*1.0)/b[n-i-1]);
                f += need;

            }

        }

        // cout<<mid<<" "<<f<<"\n";

        if(f <= k) {
            ans = mid;
            end = mid - 1;
        }
        else
            start = mid + 1;

    }

    cout<<ans<<"\n";




    return 0;
}

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n, d, x;
    scanf("%d %d %d", &n, &d, &x);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    int ans = x;
    rep(i, n)
    {
        int temp = 1;
        temp += (d - 1) / a[i];
        ans += temp;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123456;
const LL MOD = (LL)1e9 + 7;

LL dp[MAXN], sdp[MAXN];

LL cal(LL cur) {
   if (cur < 0) cur += MOD;
   return cur % MOD;
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    sdp[K] = dp[K] = 1;
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);
        for (int j = 0; j <= K; j++) {
            if (j) dp[j] = cal(sdp[min(K, a + j)] - sdp[j - 1]);
            else dp[j] = cal(sdp[a]);
        }
        sdp[0] = dp[0];
        for (int j = 1; j <= K; j++) {
            sdp[j] = cal(dp[j] + sdp[j - 1]);
        }
    }
    printf("%lld\n", dp[0]);
    return 0;
}


Measured memory_bytes: 1792
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,ans,frag,s;
    
    double t;
    cin>>t;
    s=t;
    if(s%2)
    cout<<setprecision(7)<<((t+1)/2)/t<<endl;
    else
    cout<<"0.5000000"<<endl;
    
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());
			List<long> a = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
			while (a.Count != 1) {
				long min = a.Min();
				a = a.Select(x => x % min).Where(x => x != 0).ToList();
				a.Add(min);
			}

			Console.WriteLine(a[0]);
		}
	}
}


Measured memory_bytes: 22112
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
//全探索
//dfs
int main(){
    int k;
    cin>>k;
    vector<ll> a;
    for(int i = 1;i <=9;i++){
        a.push_back(i);//1桁のものをすべて突っ込む
    }
    while(1){
        if(k <= a.size()){
            cout << a[k-1]<<endl;
            return 0;
        }
        k-=a.size();
        vector<ll> old;
        swap(old,a);
        for(ll x : old){
            for (int i=-1;i<=1;i++){
                int d = x % 10 + i;
                if(d<0 || d>9) continue;
                ll nx=x*10+d;
                a.push_back(nx);
            }
        }    
    }
    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int A,B,T;
  cin>>A>>B>>T;
  int cnt = 0;
  for(int t = A;t<T+1;t+=A){
    cnt+=B;
  }
  cout<<cnt<<endl;



  return 0;
}


Measured memory_bytes: 256
using System;

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] conds = Console.ReadLine().Split(' ');
            int cookie_1 = int.Parse(conds[0]);
            int cookie_2 = int.Parse(conds[1]);
            int cookie_3 = int.Parse(conds[2]);

            if(IsBigger(Plus(cookie_1, cookie_2) + 1, cookie_3))
            {
                Console.WriteLine(cookie_2 + cookie_3);
            }
            else
            {
                Console.WriteLine(cookie_1 + cookie_2 * 2 + 1);
            }
        }

        static int Plus(int a, int b)
        {
            return a + b;
        }

        static bool IsBigger(int a, int b)
        {
            return (a > b);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {

    
    
    string str;
    
    cin>>str;
    
    cout<<str.substr(0,4)<<" "<<str.substr(4,8)<<endl;;
    
    
    return 0;
}


Measured memory_bytes: 256