akhauriyash/Code-Regression huggingface dataset:
/*#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

int a[100010];
int main(){
	int n;
	double ans=0;
	cin>>n;
	ans=n%2==0 ? 0.5 :(n-1)/(2*n);
	cout<<ans<<endl;
	return 0;
} */
#include <iostream>
using namespace std;

int main() {
	int H,W;
	string s[60];
	int x[3]={-1,0,1};
	int y[3]={-1,0,1};
	cin>>H>>W;
	for(int i=0;i<H;i++){
		cin>>s[i];
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]!='#'){
				int count=0;
				for(int k=0;k<3;k++){
					for(int l=0;l<3;l++){
						if(k!=1 || l!=1){
							int X=i+x[k],Y=j+y[l];
							if(X>=0 && X<H && Y>=0 && Y<W && s[X][Y]=='#')count++;
						}
					}
				}
				s[i][j]=(char)(count+'0');
			}
		}
	} 
	for(int i=0;i<H;i++){
		cout<<s[i]<<endl;
	}
}




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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (size_t NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (size_t NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

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

	ll r = 0;
	for( ll i =0; i<n;++i )
	{
		if( s[i] == 'R' ) ++r;
	}
	if( r > n - r )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll res,hell=(-pow(10,15));
void f(set<p2> &s,ll y,ll val,ll tr){
    auto it=s.lower_bound({y+1,hell});
	if(it!=s.begin()){
		--it;
		res=max(res,val+(it->second));
	}
	set<p2> dum;
	it=s.lower_bound({y,hell});
	while(it!=s.end()&&it->second<=tr){
		dum.insert(*it);
		it++;
	}
	for(auto ut=dum.begin();ut!=dum.end();ut++)
		s.erase(*ut);
	it=s.lower_bound({y,hell});
	if(s.empty()||it==s.begin()||prev(it,1)->second<tr)
		s.insert({y,tr});
}
void solve(){
	ll n;
	cin>>n;
	vector<p2> v(n);
	for(ll i=0;i<n;i++)
		cin>>v[i].first>>v[i].second;
	sort(v.begin(),v.end());
	set<p2> s1,s2;
	s1.insert({v[0].second,-v[0].first-v[0].second});
	s2.insert({-v[0].second,-v[0].first+v[0].second});
	for(ll i=1;i<n;i++){
		ll x=v[i].first,y=v[i].second;
		f(s1,y,x+y,-x-y);
		f(s2,-y,x-y,-x+y);
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

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

int dp[45];

int fib(int n) {
	if (dp[n] != -1)return dp[n];
	int res;

	if (n == 0 || n == 1) {
		res = 1;
	}
	else {
		res = fib(n - 1) + fib(n - 2);
	}

	dp[n] = res;
	return res;
}

int main() {
	for (int i = 0; i < 45; i++) {
		dp[i] = -1;
	}
	int n;
	cin >> n;
	cout << fib(n) << endl;

	return 0;
}

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        xyss: [[(usize, usize)]; n],
    }
    const SHOJIKI: usize = 1;
    let mut count = 0;
    for i in 0usize..(1 << n) {
        let mut ok = true;
        for (ixys, xys) in xyss.iter().enumerate() {
            let ixys_is_shojiki = (i & (1 << ixys)) != 0;
            if ixys_is_shojiki {
                if xys.iter().any(|xy| {
                    if xy.1 == SHOJIKI {
                        (i & (1 << xy.0 - 1)) == 0
                    } else {
                        (i & (1 << xy.0 - 1)) != 0
                    }
                }) {
                    ok = false;
                    break;
                }
            }
        }
        if !ok {
            continue;
        }
        let icount = i.count_ones();
        if count < icount {
            count = icount;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
from collections import defaultdict
length, types = map(int, input().split(" "))
match = [n for n in input().split(" ")]
cost = {}
cost.update({"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6})

dp = ["-" for n in range(10010)]

def compare_str(a, b):
    if a == "":
        return b
    elif len(a) == len(b):
        return a if a > b else b
    elif len(a) > len(b):
        return a
    return b
    
dp[0] = ""
for i in range(length + 1):
    if dp[i] != "-":
        for m in match:
            dp[i + cost[m]] = compare_str(dp[i + cost[m]], dp[i] + m)
print(dp[length])

Measured memory_bytes: 30452
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a*b/gcd(a,b);
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(llvec array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return -1LL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

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

  	if(s.length()%2) {
      cout<<"No"<<endl;
      return 0;
    }
	for(int i=0; i<s.length()-1; i+=2) {
		if(s.at(i)!='h'||s.at(i+1)!='i') {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;


}


Measured memory_bytes: 256
n, l = gets.split.map(&:to_i)
ropes = gets.split.map(&:to_i)
last = nil
ropes.each_cons(2).with_index do |(a, b), i|
  if a + b >= l
    last = i + 1
    break
  end
end
if last
  puts "Possible"
  former = (1...last).to_a
  latter = (last + 1...n).to_a
  former.each { |n| puts n }
  latter.reverse.each { |n| puts n }
  puts last
else
  puts "Impossible"
end


Measured memory_bytes: 23352
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#define X first
#define Y second
#define all(c) (c).begin(), (c).end()

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

int compress ( VI &va, VI &vb, int wh )
{
	int n = va.size();
	VI vc;
	for (int i = 0; i < n; ++i) {
		for (int d = -1; d <= 1; ++d) {
			int ta = va[i] + d, tb = vb[i] + d;
			if (0 <= ta && ta < wh) { vc.push_back(ta); }
			if (0 <= tb && tb < wh) { vc.push_back(tb); }
		}
	}
	sort(all(vc));
	vc.erase(unique(all(vc)), vc.end());
	for (int i = 0; i < n; ++i) {
		va[i] = find(all(vc), va[i]) - vc.begin();
		vb[i] = find(all(vc), vb[i]) - vc.begin();
	}
	return vc.size();
}

int main ( void )
{
	int dx[] = { 0, 0, -1, 1 }, dy[] = { -1, 1, 0, 0 };
	int w, h, n;
	while (cin >> w >> h, w|h) {
		cin >> n;
		VI xa(n), xb(n), ya(n), yb(n);
		for (int i = 0; i < n; ++i) {
			cin >> xa[i] >> ya[i] >> xb[i] >> yb[i];
		}
		w = compress(xa, xb, w);
		h = compress(ya, yb, h);

		vector<vector<bool> > fld(h, vector<bool>(w, false));
		for (int i = 0; i < n; ++i) {
			for (int y = ya[i]; y < yb[i]; ++y) {
				for (int x = xa[i]; x < xb[i]; ++x) {
					fld[y][x] = true;
				}
			}
		}

		int ans = 0;
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				if (fld[y][x]) { continue; }
				++ans;

				queue<PII> que;
				que.push(PII(x, y));
				while (!que.empty()) {
					PII p = que.front(); que.pop();

					for (int d = 0; d < 4; ++d) {
						PII t(p.X + dx[d], p.Y + dy[d]);
						if (t.X < 0 || t.X >= w || t.Y < 0 || t.Y >= h) { continue; }
						if (fld[t.Y][t.X]) { continue; }
						que.push(t);
						fld[t.Y][t.X] = true;
					}
				}
			}
		}

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

Measured memory_bytes: 1400
def main():
    n, k = map(int, input().split())

    num = 10*100
    nums = [num + i for i in range(0, n+1)]

    # sums = []
    total = 0
    for i in range(k, n+2):
        _min = int((nums[0]+nums[i-1])*(nums[i-1]-nums[0]+1)/2)
        _max = int((nums[-i]+nums[-1])*(nums[-1]-nums[-i]+1)/2)

        total += _max - _min + 1

    print(total%(10**9+7))

if __name__ == "__main__":
    main()

Measured memory_bytes: 81072
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), dup = 1;
        boolean[] a = new boolean[100000];
        for (int i = 0, temp; i < n; i++)
            if (a[temp = scanner.nextInt()]) dup++;
            else a[temp] = true;
        System.out.println(n - dup / 2 * 2);
    }
}

Measured memory_bytes: 50744
#include<bits/stdc++.h>          
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
#define fixed(n) fixed<<setprecision((n))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

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

vector<int> st;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,q;
	string s;
	cin >> n >> q >> s;
	st.resize(n+2);
	rep(i,n-1){
		st[i+2] = st[i+1];
		if(s[i] == 'A' && s[i+1] == 'C'){
			st[i+2]++;
		}
	}
	rep(i,q){
		int a,b;
		cin >> a >> b;
		cout << st[b] - st[a] << '\n';
	}

	return 0;
}


Measured memory_bytes: 1872
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
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;
}
template <class T> inline void in(T &a) { cin >> a; }
template <class T, class U> inline void in(T &a, U &b) { cin >> a >> b; }
template <class T, class U, class V> inline void in(T &a, U &b, V &c) {
  cin >> a >> b >> c;
}
template <class T> inline void out(T a) { std::cout << a << endl; }
template <class T, class U> inline void out(T a, U b) {
  cout << a << ' ' << b << endl;
}
template <class T, class U, class V> inline void out(T a, U b, V c) {
  cout << a << ' ' << b << ' ' << c << endl;
}
#define inf 1e9
using ll = int64_t;
#define waru 1000000007

void Main() {
  int n, k;
  in(n, k);
  std::vector<ll> v(n);
  for (auto &x : v) {
    in(x);
  }

  ll ans = 0;

  for (auto &x : v) {
    ans += abs(k - x) > x ? 2 * x : abs(k - x) * 2;
  }

  out(ans);

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

const inputs = fs.readFileSync('/dev/stdin', 'utf8').split(/[ \n]/);

const startGame = (n: number, cards: string[]): number => {
  let turn = n;
  while (cards[turn].length !== 0) {
    const card = cards[turn][0];
    cards[turn] = cards[turn].slice(1);

    if (card === 'a') {
      turn = 0;
    } else if (card === 'b') {
      turn = 1;
    } else {
      turn = 2;
    }
  }
  return turn;
};

const print = (turn: number) => {
  if (turn === 0) {
    console.log('A');
  } else if (turn === 1) {
    console.log('B');
  } else {
    console.log('C');
  }
};

print(startGame(0, inputs));


Measured memory_bytes: 29640
// AtCoder Beginners Selection
// ABC176B Multiple of 9
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  long number = 0;
  
  //loop
  for (int i = 0; i < N.size(); i++){
    //cout << N.at(i) - 48;
    number += N.at(i) - 48;
    //cout << number << endl;
  }
  
  if (number % 9 == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll h[500005];
ll b[500005];
ll n;
struct BIT
{
	vector<ll>a;
	ll _n;
	void init(ll n)
	{
		_n=n+2;
		a.resize(_n);
	}
	void update(ll pos,ll val)
	{
		pos++;
		while(pos<_n)
		{
			a[pos]=max(a[pos],val);
			pos+=(pos&(-pos));
		}
	}
	ll query(ll pos)
	{
		pos++;
		ll ans=0;
		while(pos>0)
		{
			ans=max(ans,a[pos]);
			pos-=(pos&(-pos));
		}
		return ans;
	}
};
	

int main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cin>>n;
	 for(ll i=1;i<=n;i++)
	 cin>>h[i];
	 for(ll i=1;i<=n;i++)
	 cin>>b[i];
	 BIT tree;
	 tree.init(n+1001);
	 ll dp[n+1];
     ll ans=0;
	 for(ll i=1;i<=n;i++)
	 {
	 	dp[i]=tree.query(h[i]-1)+b[i];
	 	tree.update(h[i],dp[i]);
	 }
	 for(ll i=1;i<=n;i++)
     ans=max(ans,dp[i]);

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

Measured memory_bytes: 9088
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int a,b,k;cin >> a >> b >> k;
    // cout << max(a-k,0LL) << ' ' << (k-a<0?b:b-(k-a)) << endl;
    if(k>a)b-=k-a;
    chmax(b,0LL);
    a-=k;
    chmax(a,0LL);
    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 100005
#define all(x) x.begin(),x.end()
#define l_b lower_bound
#define u_b upper_bound
#define pb push_back
#define MOD 1000000007
void fastio(void);

int main(){
    fastio();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n,la,lb,x=0;
    cin>>n;
    vector<ll> arr(n);
    for(la=0;la<n;la++){
        cin>>arr[la];
        x^=arr[la];
    }

    for(la=0;la<n;la++)
        cout<<(x^arr[la])<<' ';

    return 0;
}

void fastio(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

class Merge {
public:
	Merge() : count(0){}

	void mergeSort(int A[], int left, int right) {
		if (left + 1 >= right) {
			return;
		}
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}

	int getCount() {
		return count;
	}

private:
	void merge(int A[], int left, int mid, int right) {
		int numL = mid - left;
		int numR = right - mid;

		//?????§A??????????????´??°???????????§??\?????????????????????????????????
		//?????¬?????\????????????????????????
		int L[250001];
		int R[250001];
		for (int i = 0; i < numL; i++) {
			L[i] = A[left + i];
		}
		for (int i = 0; i < numR; i++) {
			R[i] = A[mid + i];
		}
		//??????????????¨????????\???????????????
		L[numL] = 1000000001; 
		R[numR] = 1000000001;
		int iL = 0;
		int iR = 0;
		for (int j = left; j < right; j++) {
			if (L[iL] <= R[iR]) {
				A[j] = L[iL];
				iL++;
			}
			else {
				A[j] = R[iR];
				iR++;
			}
			count++;
		}
	}

	int count;
};

int main() {
	int A[500000];
	int numA;
	Merge mer;
	cin >> numA;
	for (int i = 0; i < numA; i++) {
		cin >> A[i];
	}

	mer.mergeSort(A, 0, numA);

	for (int i = 0; i < numA; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << mer.getCount() << endl;
	return 0;
}

Measured memory_bytes: 6868
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

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

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;

int main()
{
	string s,t;

	cin >> s;
	cin >> t;

	string tt = t.erase(t.size() -1);
	if (s == t) {
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3580
first = True
while True:
    P = int(input())
    if P== 0: break
    if first:
        first = False
    else:
        print('')
    c1,c2,c3,c4 = map(int,input().split())
    v = c1*10 + c2*50 + c3*100 + c4*500
    n = c1 + c2 + c3 + c4
    ans = {}
    rem = v - P
    ans[10] = c1 - (rem//10) % 5
    ans[50] = c2 - (rem//50) % 2
    ans[100] = c3 - (rem//100) % 5
    ans[500] = c4 - rem//500
    for k,v in sorted(ans.items()):
        if v <= 0: continue
        print('{0} {1}'.format(k,v))

Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n,x,m;
	cin >> n >> x >> m;
	map<ll,int> pos,mp;
	ll ans = 0;
	vector<ll> elements(m+5,0);
	elements[1] = x;
	++mp[x];
	pos[x] = 1;
	int l = -1,r = -1;
	for(int i = 2; i <= n;++i){
		ll next = (elements[i-1] * elements[i-1])%m;
		if(mp.count(next) == 1){
			l = pos[next];
			r = i-1;
			break;
		}
		++mp[next];
		pos[next] = i;
		elements[i] = next;
	}
	for(int i = 1; i <= l-1;++i){
		ans += elements[i];
	}
	if(l != -1){
		int len = r-l+1;
		ll temp = 0;
		for(int i = l; i <= r;++i){
			temp += elements[i];
		}
		n = n - l + 1;
		ans += (n/len) * temp;
		for(int i = l; i < l + n%len;++i){
			ans += elements[i];
		}
	}
	else{
		for(int i = 1; i <= n;++i){
			ans += elements[i];
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 10220
#include <cmath>
#include <iomanip>
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;

  double hour_rad = (H / 12.0 + M / 60.0 / 12.0) * 2 * M_PI - M_PI;
  double min_rad = (M / 60.0) * 2 * M_PI - M_PI;

  double a_x = A * std::cos(hour_rad);
  double a_y = A * std::sin(hour_rad);
  double b_x = B * std::cos(min_rad);
  double b_y = B * std::sin(min_rad);

  double x_diff_2 = std::pow(a_x - b_x, 2);
  double y_diff_2 = std::pow(a_y - b_y, 2);
  double ans = std::sqrt(x_diff_2 + y_diff_2);
  cout << std::fixed << std::setprecision(12) << ans << endl;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, Q; cin >> N >> Q;
  
  map<int,int> I, J;
  int mi = N, mj = N;
  I[N] = N-2; J[N] = N-2;
  int ans = (N-2)*(N-2);
  
  rep(i, Q) {
    int a, x; cin >> a >> x;
    if(a == 1) {
      auto it = J.lower_bound(x);
      ans -= it->second;
      //cout << it->first << ans << endl;
      if(x < mj) {
        I[mi] = max((int)(0), x-2);
        mj = x;
      }
    }
    if(a == 2) {
      auto it = I.lower_bound(x);
      ans -= it->second;
      //cout << it->first << ans << endl;
      if(x < mi) {
        J[mj] = max((int)(0), x-2);
        mi = x;
      }
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 9840
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int N;
string s;
vector<pair<string, int> > v;
vector<string> ans;
map<string, int> m;

bool cmp(pair<string, int> a, pair<string, int> b) {
    if (a.second == b.second) {
        return a.first < b.first;
    }
    return a.second > b.second;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;
        m[s] += 1;
    }
    map<string, int>::iterator it = m.begin();
    for (; it != m.end(); it++) {
        v.push_back(pair<string, int>(it->first, it->second));
    }
    sort(v.begin(), v.end(), cmp);
    int maxn = v.begin()->second;
    for (it = m.begin(); it != m.end(); it++) {
        if (it->second == maxn) {
            ans.push_back(it->first);
        }
    }
    vector<string>::iterator it_ans = ans.begin();
    for (; it_ans != ans.end(); it_ans++) {
        cout << *it_ans << endl;
    }
  	return 0;
}


Measured memory_bytes: 32748
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class WUFT
  attr_accessor:par,:rank,:weight
  def initialize(n)
    @par=Array.new(n){|i| i}
    @rank=array(n,1,0)
    @weight=array(n,1,0)
  end

  def find(x)
    return x if @par[x]==x
    y=find(@par[x])
    @weight[x]+=@weight[@par[x]]
    @par[x]=y
    return y
  end


  def union(x,y,w)
    rx=find(x)
    ry=find(y)
    if @rank[rx]<@rank[ry]
      @par[rx]=ry
      @weight[rx]=w-@weight[x]+@weight[y]
    else
      @par[ry]=rx
      @weight[ry]=-w-@weight[y]+@weight[x]
      @rank[rx]+=1 if @rank[rx]==@rank[ry]
    end
  end

  def same?(x,y)
    return find(x)==find(y)
  end

  def diff(x,y)
    return @weight[x]-@weight[y]
  end
end

n,m=get_i
wuft=WUFT.new(n)
flag=true
m.times do|i|
  l,r,d=get_i
  unless wuft.same?(l-1,r-1)
    wuft.union(l-1,r-1,d) 
  else
    unless wuft.diff(l-1,r-1)==d
      flag=false
      break
    end
  end
end
puts yn_judge(flag)

Measured memory_bytes: 6140
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9 + 7;

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}


int main(){
    int t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        pi arr[n];
        ll l[n], r[n], k[n];
        FOR0(i, n){
            cin >> k[i] >> l[i] >> r[i];
            k[i]--;
            arr[i].ff = abs(l[i] - r[i]);
            arr[i].ss = i;
        }
        sort(arr, arr + n, greater<pi>());
        set<int> left, right;
        FOR0(i, n){
            left.insert(i);
            right.insert(i);
        }
        ll ans = 0;
        FOR0(i, n){
            ll k1 = k[arr[i].ss];
            ll l1 = l[arr[i].ss];
            ll r1 = r[arr[i].ss];
            if (l1 > r1){
                auto itr = left.upper_bound(k1);
                if (itr!= left.begin()){
                    ans += l1;
					itr--;
				    left.erase(itr);
					right.erase(right.begin());     
                }
                else ans += r1;
            } 
            else{
                auto itr = right.upper_bound(k1);
                if (itr!= right.end()){
                    ans += r1;
				    right.erase(itr);
					left.erase(--left.end());     
                }
                else ans += l1;
            }
        }
        cout << ans << endl;

    }
}

Measured memory_bytes: 30184
#include<bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 3e5 + 10;
int tr[N], n, m, L[N], R[N], st[N], top = 0, sum[N], op[N];

struct P {
	int L, R, len;
}p[N];

inline bool cmp(P a, P b) {
	return a.len < b.len;
}

struct T {
	#define ls (rt << 1)
	#define rs (rt << 1 | 1)
	#define mid ((l) + (((r) - (l)) >> 1))
	int tr[N << 2], tag[N << 2];
	inline void pd(int rt, int l, int r) {
		if(tag[rt]) {
			tr[ls] += tag[rt] * (mid - l + 1);
			tr[rs] += tag[rt] * (r - mid);
			tag[ls] += tag[rt];
			tag[rs] += tag[rt];
			tag[rt] = 0;
		}
	}
	
	inline void A(int L, int R, int C, int l, int r, int rt) {
		if(L <= l && r <= R) {
			tr[rt] += C * (min(r, R) - max(l, L) + 1);
			tag[rt] ++;
			return ;
		}pd(rt, l, r);
		if(L <= mid) A(L, R, C, l, mid, ls);
		if(R > mid) A(L, R, C, mid + 1, r, rs);
		tr[rt] = tr[ls] + tr[rs];
	}
	
	inline int Q(int L, int R, int l, int r, int rt) {
		if(L <= l && r <= R) return tr[rt];
		pd(rt, l, r);
		int ans = 0;
		if(L <= mid) ans += Q(L, R, l, mid, ls);
		if(R > mid) ans += Q(L, R, mid + 1, r, rs);
		return ans;
	}
	
	inline int ADD(int x, int val) {
		for(; x <= n ;x += x & -x) tr[x] += val;
	}
	
	inline int QUE(int x, int ans = 0) {
		for(ans = 0; x >= 1; x -= x & -x) ans += tr[x]; return ans;
	}
	
}s1, s2;


main() {
	read(m), read(n); 
	for(int i = 1; i <= m; i ++) {
		read(p[i].L), read(p[i].R);
		p[i].len = p[i].R - p[i].L + 1;
	}
	sort(p + 1, p + m + 1, cmp);
	int k = 1;
//	for(int i = 1; i <= m; i ++)
//		cout << i << "th " << p[i].L << ' ' << p[i].R << "\n";
	for(int i = 1; i <= n; i ++) {
		for(; k <= m && p[k].len < i; k ++) {
			s1.A(p[k].L, p[k].R, 1, 1, n, 1);
//			s1.ADD(p[k].L, 1);
//			s1.ADD(p[k].R + 1, -1);
		}
		int ans = m - k + 1;
		for(int t = i; t <= n; t += i) ans += s1.Q(t, t, 1, n, 1);//s1.QUE(t);
		cout << ans << "\n";
	}
//	for(int i = 1; i <= n; i ++)
//		printf("%lld\n", s2.Q(i, 1, n, 1));
}

Measured memory_bytes: 19328
#include<iostream>
#include<algorithm>

using namespace std;

int map[1000][1000];
int n;
int ans;
int move_flag;

void serch(int x,int y,int h)
{
	for(int i=0;y+i<n && map[x][y+i]==1;i++)
	{
		h=i+1;
	}
	
	for(int i=0;i<h;i++)
	{
		if(x+i==n)
		{
			h=i;
			break;
		}
		for(int j=0;j<h;j++)
		{
			if(y+j==n)
			{
				h=j;
				break;
			}
			if(map[x+i][y]==0)
			{
				h=i;
				break;
			}
			if(map[x+i][y+j]==0)
			{
				h=j;
				break;
			}
		}
	}
	
	ans=max(ans,h);
	
/*
	map[x][y]=2;
	getchar();
	
	system("cls");
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cout << map[i][j] << " " ;
		}
		cout << endl;
	}
	
	cout << "ans:" << ans << endl;
	cout << "h:" << h << endl;
	map[x][y]=1;
//*/
	return ;
}
int main()
{
	int i,j;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		
		ans=0;
		
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				char a;
				cin >> a ;
				if(a=='.')
					map[i][j]=1;
				else
					map[i][j]=0;
			}
		}
		
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(map[i][j]==1)
				{
					move_flag=1;
					serch(i,j,1);
				}
			}
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, j, n, k, dp[100010], h[100010];
  cin >> n >> k;
  REP(i, n){cin >> h[i]; dp[i] = 1e9;}
  dp[0] = 0;
  FOR(i, 1, n){
    if(i < k){
      REP(j, i) dp[i] = min(dp[0] + abs(h[i] - h[0]), dp[i]);
    }else{
      REP(j, k) dp[i] = min(dp[i+j-k] + abs(h[i] - h[i+j-k]), dp[i]);
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

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

    if (N % 2 == 0) {
        cout << N / 2 << endl;
    } else {
        cout << N / 2 + 1 << endl;
    }
}


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

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int x = (n + a - 1) / a * b;
  int y = (n + c - 1) / c * d;
  cout << min(x, y) << "\n";
}


Measured memory_bytes: 3096
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
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;}
 
const ll mod=2019;

int main(){
    ios;
    string s;
    cin >> s;
    ll n=s.length();
    vector<ll> a(n+1);
    vector<ll> b(n+1);
    vector<ll> p(n+1);
    p[0]=1;
    rep(i,n){
        p[i+1]=(p[i]*10)%mod;
    }
    a[0]=0;
    b[0]=0;
    rep(i,n){
        ll x=s[n-1-i]-'0';
        ll y=s[i]-'0';
        a[i+1]=(a[i]+x*p[i])%2019;
        b[i+1]=(b[i]+p[n-i-1]*y)%2019;
        //cout << a[i+1] << " " << b[i+1] << endl;
    }
    vector<vector<ll>> r(2019);
    vector<vector<ll>> q(2019);
    rep(i,n+1){
        //cout << a[i] << " "<<b[i] << endl;
        r[a[i]].push_back(i);
        q[b[i]].push_back(n-i);
    }
    rep(i,2019){
        sort(r[i].begin(),r[i].end());
        sort(q[i].begin(),q[i].end());
    }
    ll ans=0;
    rep(i,n+1){
        if(i==0){
            for(auto x:q[a[i]]){
                //cout << x << endl;
            }
        }
        if(i==n) continue;
        if(r[a[i]].size()==0) continue;
        
        ll t=upper_bound(r[a[i]].begin(),r[a[i]].end(),i)-r[a[i]].begin();
        ans+=(r[a[i]].size()-t);
        //cout << i << " " << r[a[i]].size() << " " << t << endl;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 13704
import math
N = int(input())
A = []
I = []
cnt=0

for i in range(50000):
  I.append(i)
  A.append(math.floor(1.08*i))

for i in range(len(A)):
  if A[i]==N:
    cnt+=i

if cnt!=0:
  print(cnt)
elif cnt==0:
  print(':(')


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

int main(int argc,char *argv[]){
	if(argc>=2){freopen(argv[1],"r",stdin);}
	if(argc>=3){freopen(argv[2],"w",stdout);}
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	if(b-a+1<=k*2){
		for(int i=a;i<=b;++i)printf("%d\n",i);
	}else{
		for(int i=a;i<=a+k-1;++i)printf("%d\n",i);
		for(int i=b-k+1;i<=b;++i)printf("%d\n",i);
	}
	
	
	fclose(stdin);fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	int* a;
	a = new int[n];
	rep(i, n) cin >> a[i];

	ll ans = 1;

	int stack[3] = {-1, -1, -1};
	rep(i, n) {
		ll t = 0;

		rep(j, 3) {
			if (stack[j] == a[i] - 1) {
				if (t == 0) stack[j]++;
				
				++t;
			}
		}

		ans = (ans*t) % MOD;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
n,h=map(int,input().split())
a=list()
b=list()
for i in range(n):
    j,k=map(int,input().split())
    a.append(j)
    b.append(k)
#sunb=sum(b)
maxa=max(a)
if maxa>max(b):
    print(-h//maxa*-1)
else:
    b.sort(reverse=True)
    p=0
    for i in range(n):
        p+=b[i]
        if p>=h:
            print(i+1)
            break
        if b[i]<maxa:
            print(i+((p-h-b[i])//maxa)*-1)
            #print(maxa,p)
            break
    else:
        print(n+((p-h)//maxa)*-1)


Measured memory_bytes: 11300
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double x1,x2,y1,y2;
	cin>>x1>>x2>>y1>>y2;
	cout<<fixed<<setprecision(4);
	cout<<fixed<<sqrt((y2-x2)*(y2-x2)+(y1-x1)*(y1-x1))<<endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
 
long long solve(long long x, long long k, long long d) {
	x = abs(x);
	if (k == 0) {
		return x;
	}
	if (k % 2 == 1) {
		return min(solve(x - d, k - 1, d), solve(x + d, k - 1, d));
	}
	d *= 2;
	k /= 2;
	if (x / k >= d) {
		return x - d * k;
	}
	x %= d;
	return min(x, d - x);
}
int main()
{
	long long x, k, d;
	cin >> x >> k >> d;
	cout << solve(x, k, d) << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#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 ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    vector<vector<int>> Ds(C, vector<int>(C));
    REP(c1, C) REP(c2, C) cin >> Ds[c1][c2];
    vector<vector<int>> Cs(N, vector<int>(N));
    REP(n1, N) REP(n2, N) {
        int c;
        cin >> c; --c;
        Cs[n1][n2] = c;
    }
    vector<vector<int>> colors(3, vector<int>(C));
    REP(h, N) {
        REP(w, N) {
            auto c = Cs[h][w];
            auto m = (h + w) % 3;
            ++colors[m][c];
        }
    }

    int ans = 1e9;
    REP(c1, C) {
        REP(c2, C) {
            REP(c3, C) {
                if (c1 == c2 || c2 == c3 || c1 == c3) continue;
                auto score = 0;

                REP(c, C) {
                    auto p1 = Ds[c][c1];
                    auto p2 = Ds[c][c2];
                    auto p3 = Ds[c][c3];
                    score += p1 * colors[0][c];
                    score += p2 * colors[1][c];
                    score += p3 * colors[2][c];
                }
                //cout << score << endl;
                ans = min(ans, score);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	int ans=(x-a)%b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(input()) for _ in range(n)]
m1=max(a)
m2=sorted(a)[-2]
l=[i for i, x in enumerate(a) if x == m1]

if len(l)==1:
  for i in range(n):
    if i ==l[0]:
      print(m2)
    else:
      print(m1)
else:
  for i in range(n):
    print(m1)


Measured memory_bytes: 20476
#include <bits/stdc++.h>
using namespace std;
long n;
void solve()
{
    long res=1000000000;
    for (long i=1;i<=n/2;i++)
    {
          long x=i,y=n-i,res1=0,res2=0;
          while(x){res1+=x%10;x/=10;}
          while(y){res2+=y%10;y/=10;}
          res=min(res,res1+res2);
     }
     cout<<res<<endl;
}
int main()
{
     while(cin>>n)
         solve();
}

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

int main(){
	int n;
	cin >> n;
	
	int ans = 0;
	int mi = n+1;
	rep(i, n){
		int d;
		cin >> d;
		mi = min(mi, d);
		if(d == mi) ans++;
	}

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

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lp(i,n)   for(int i=0;i<int(n);i++)
#define ff(i,a,b)  for(int i=a;i<=int(b);++i)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
const ll M  = 1e9+7 ;
//const int N = 111;
const int inf = 2e9+7;
const double EPS = 1e-9;
//////////////////////    Hi    ^_^  hack me if you can :P
string ys = "YES\n";
string no = "NO\n" ;

int a[101][101];
int main()
{
    int n, m, x;
    int c,cl =0;
    cin >> n >> m >> c;
    int i = 1;
    int j = 1;
    int op = 1;
    while (cin >> c)
    {
        cl++;
        while(c--)
        {
            a[i][j] = cl;
            j+=op;
            if (j==m+1)
            {
                op=-1;
                i++;
                j--;
            }
            else if (j==0)
            {
                op=1;
                i++;
                j++;
            }
        }
    }
    ff(i,1,n)
    {
        ff(j,1,m)
        {
            cout << a[i][j] << ' ';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
N,M,Q = map(int,input().split())
abcd = [list(map(int,input().split())) for i in range(Q)]

import itertools

tmp = []
for i in range(1,M+1):
    tmp.append(i)
A = list(itertools.combinations_with_replacement(tmp,N))
tmp2 = []
for i in range(len(A)):
    B = list(A[i])
    B.sort()
    tmp2.append(B)
answer = 0


for i in range(len(A)):
    ans = 0
    for j in range(Q):
        if tmp2[i][ abcd[j][1]-1 ] - tmp2[i][ abcd[j][0]-1 ] == abcd[j][2]:
            ans += abcd[j][3]  
    answer = max(answer,ans)
    
print(answer)

Measured memory_bytes: 35708
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

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

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN64
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=getchar();
		while(!isdigit(s))sign|=s=='-',s=getchar();
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=998244353;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
//using namespace math;

const int N=1e5+5;

int n,m,h[N],ans;
vector <int> e[N];

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		e[u].pb(v),e[v].pb(u);
	}
	for(int i=1;i<=n;i++){
		bool pd=1;
		for(int j:e[i])if(h[j]>=h[i])pd=0;
		ans+=pd;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){

    string s;
    cin >> s;

    char now_char = s[0];
    int count = 0;
    for(int i=0; i < s.length(); i++){
        if(now_char != s[i]){
            count ++;
            now_char = s[i];
        }
    }  

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
struct Edge {
  int source, target, weight;
  Edge(int source, int target, int weight)
      : source(source), target(target), weight(weight) {}
};
struct Graph {
  int V;
  vector<vector<Edge>> g;
  Graph(int V) : V(V), g(V) {}
  void add_edge(int s, int t, int w = 1) { g[s].push_back(Edge(s, t, w)); }
  void dfs(vector<int> &x, int v, int p, int d) {
    x[v] = d;
    rep(i, 0, g[v].size()) {
      Edge e = g[v][i];
      int u = e.target;
      if (u == p)
        continue;
      dfs(x, u, v, d + e.weight);
    }
  }
  int diameter() {
    vector<int> d(V);
    dfs(d, 0, -1, 0);
    int m = max_element(all(d)) - d.begin();
    dfs(d, m, -1, 0);
    return *max_element(all(d));
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  Graph g(N);
  rep(i, 0, N - 1) {
    int s, t, w;
    cin >> s >> t >> w;
    g.add_edge(s, t, w);
    g.add_edge(t, s, w);
  }
  cout << g.diameter() << endl;
  return 0;
}



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

  int main() { 
  int A,B,C;
  cin>>A>>B>>C;
  if(A==5&&B==5&&C==7){
  cout <<"YES"<<endl;
  }
  else if(A==5&&B==7&&C==5){
  cout <<"YES"<<endl;
  }
  else if(A==7&&B==5&&C==5){
  cout <<"YES"<<endl;
  }
  else cout <<"NO"<<endl;
}

Measured memory_bytes: 256