akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nab = readln.split.to!(int[]);
    auto N = nab[0];
    auto A = nab[1];
    auto B = nab[2];

    if (A == 1 && B == N) {
        writeln(1.iota(N+1).array.reverse.to!(string[]).join(" "));
        return;
    } else if (A == N && B == 1) {
        writeln(1.iota(N+1).array.to!(string[]).join(" "));
        return;
    }

    bool rev;
    if (N-A >= B-1 && (N+A-1)/A <= B) {
        rev = false;
    } else if (N-B >= A-1 && (N+B-1)/B <= A) {
        rev = true;
        swap(A, B);
    } else {
        writeln(-1);
        return;
    }
    auto x = (N-A)/(B-1);
    auto r = (N-A)%(B-1);
    int[] res;
    int i = N;
    foreach (_b; 0..B-1) {
        auto n = x + (r > 0 ? 1 : 0);
        foreach_reverse (d; 0..n) res ~= i-d;
        i -= n;
        --r;
    }
    foreach_reverse (d; 0..A) res ~= i-d;
    if (rev) res = res.reverse.array;
    writeln(res.to!(string[]).join(" "));
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define bit(b, i) (((b) >> (i)) & 1)

int n, g, p[10], c[10];

int main() {
	cin >> n >> g;
	g /= 100;
	inc(i, n) { cin >> p[i] >> c[i]; c[i] /= 100; }
	
	int ans = 1e9;
	inc(b, 1 << n) {
		int sum = 0, cnt = 0;
		inc(i, n) { if(bit(b, i)) { sum += (i + 1) * p[i] + c[i]; cnt += p[i]; } }
		dec(i, n) {
			if(bit(b, i)) { continue; }
			inc(j, p[i]) {
				if(sum < g) { sum += (i + 1); cnt++; }
			}
		}
		if(sum >= g) { setmin(ans, cnt); }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const arr = input.split('\n').map(x=>Number(x));
  const a = arr[0];
  const b = arr[1];
  const c = arr[2];
  const x = arr[3];
  var count = 0;

  for (var i = 0; i <= a; i++) {
    for (var j = 0; j <= b; j++) {
      for (var k = 0; k <= c; k++) {
        if (500 * i + 100 * j + 50 * k === x) count++;
      }
    }
  }

  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <numeric>

int main(){
  int K;
  std::cin >> K;
  long sum = 0;
  for(int a = 1; a <= K; ++a){
    for(int b = 1; b <= K; ++b){
      for(int c = 1; c <= K; ++c){
        int gcd = std::gcd(a,b);
        sum += std::gcd(gcd,c);
      }
    }
  }
  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<algorithm>
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define ll long long 
#define mod 998244353
using namespace std;



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

    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    long long sum = 0;
    for(int i=0;i<k;i++){
        sum+= arr[i];
    }
    cout<<sum<<endl;
    

}

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

#define fi first
#define se second
#define pb push_back
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
typedef pair<int, int> ii;

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n;
int a[N], t[N];
priority_queue<int> maxn;
priority_queue<int, vector<int>, greater<int> > minn;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n)    {
        int x; cin >> x;
        t[i] = a[i] - x;
        if(t[i] < 0) minn.push(t[i]);
        else if(t[i] > 0) maxn.push(t[i]);
    }
    while(!maxn.empty())    {
        int cur = maxn.top(); maxn.pop();
        if(minn.empty()) {
            cout << "No"; return 0;
        }
        int val = minn.top(); minn.pop();
        // left the val
        int step = abs(val) / 2;
        step = min(step, cur);
        cur -= step;
        val += 2 * step;
        if(cur > 0) maxn.push(cur);
        if(val < -1) minn.push(val);
    }
    cout << "Yes";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a=0;cin>>n>>k;
  for(int i=0;i<n;i++){
    int x;cin>>x;
    a+=min(abs(x),abs(x-k));
  }
  cout<<a*2<<endl;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (max(a, max(b, c)) == a) cout << 10 * a + b + c << endl;
  else if (max(a, max(b, c)) == b) cout << 10 * b + a + c << endl;
  else cout << 10 * c + a + b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1); // 1-based
	FOR(i,1,n+1) cin >> a[i];
	
	vector<int> sum(n+2,0),rsum(n+2,0);
	sum[2] = a[1];
	FOR(i,2,n+1) sum[i+1] = GCD(sum[i],a[i]);
	rsum[n-1] = a[n];
	for(int i=n-1; i>=1; i--) rsum[i-1] = GCD(rsum[i],a[i]);
	
	int ans = 0;
	FOR(i,1,n+1){
		chmax(ans, GCD(sum[i],rsum[i]));
	}
	
	cout << ans << endl;
	
	return 0;
}

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

namespace abc090a
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans="";
            for (var i = 0; i !=3; i++)
            {
                ans += Console.ReadLine()[i];
            }
            Console.WriteLine(ans);
        }
    }
}


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

int a[200000];

signed main(){

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

  int flag = 1;
  int cnt = 0;
  while(flag){
    flag = 0;
    for(int j = n-1; j > 0; j--){
      if(a[j] < a[j-1]){
        swap(a[j],a[j-1]);
        flag = 1;
        cnt++;
      }
    }
  }

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    vector<P<int, int>> v(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> v[i].Y;
        if (v[i].Y % 10 == 0)
        {
            v[i].X = 0;
        }
        else
        {
            v[i].X = 10 - v[i].Y % 10;
        }
    }
    vsort(v);
    int ans = v[0].Y, pre = v[0].X;
    for (int i = 1; i < 5; i++)
    {
        ans += v[i].Y + pre;
        pre = v[i].X;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = []
cnt = 0
for i in range(n):
    a.append(int(input()))

def insertionSort(a, n, g):
    global cnt
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt = cnt + 1
        a[j+g] = v

g = []
g.append(1)
m = 0
while g[m] < n:
    if n > 3 * g[m] + 1:
        m = m + 1
        g.append(3 * g[m-1] + 1)
    else:
        break
m = m + 1
g.reverse()

for i in range(m):
    insertionSort(a,n,g[i])

print(m)
print(*g)
print(cnt)
for i in range(n):
    print(a[i])




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

using namespace std;

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

    int ans = 0;
    int aa = 1;
    while (aa < b) {
        aa += a - 1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)
	{
		if(b!=c)
		{
			cout<<"Yes";
			return 0;
		}
		else
		if(b==c)
		{
			cout<<"No";
			return 0;
		}
	}
	else
	if(a==c)
	{
		if(b==c)
		{
			cout<<"No";
			return 0;
		}
		if(b!=c)
		{
			cout<<"Yes";
			return 0;
		}
	}
	else
	if(b==c)
	{
		if(a==c)
		{
			cout<<"No";
			return 0;
		}
		else
		if(a!=c)
		{
			cout<<"Yes";
			return 0;
		}
	}
	else
	if(a!=b&&b!=c)
	cout<<"No";
	
}
    


Measured memory_bytes: 256
// AOJ 0171: Dice Puzzle
// 2017.8.17 bal4u@uu
// 2017.12.29
// ?????????????????¢??¨??????????????????????????°

#include <stdio.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };

int con[8][7][2] = {{{0}},
	{{0},{0},{0},{0},{0,3},{0},{0}},		// ?????????????????¨??¢??????
	{{0},{0},{1,5},{0},{0},{0},{0}},
	{{0},{0},{0,5},{2,4},{0},{0},{0}},
	{{0},{0},{0},{0},{0},{0},{0,1}},
	{{0},{0},{0},{0},{4,3},{0},{1,1}},
	{{0},{0},{5,5},{0},{0},{0},{2,1}},
	{{0},{0},{4,5},{6,4},{0},{0},{3,1}}};

char dice[8][8];
char kari[8][8], f[9];
char tr[128];

int rec(int n)
{
	int i, j, k, m, cnt;
	char tbl[7][2], c;

	if (n == 8) return 1;
	for (i = 0; i < 8; i++) {
		if (f[i]) continue;
		cnt = 0;
		for (j = 1; j <= 6; j++) if (con[n][j][1]) {
			c = tr[kari[con[n][j][0]][con[n][j][1]]];
			for (k = 1; ; k++) {
				if (k > 6) goto next;
				if (dice[i][k] == c) { tbl[cnt][0] = j, tbl[cnt++][1] = c; break; }
			}
		}

		for (j = 0; j < 24; j++) {
			for (k = 0; ; k++) {
				if (k == cnt) {
					for (m = 1; m <= 6; m++) kari[n][m] = dice[i][rot[j][m]];
					f[i] = 1;
					if (rec(n+1)) return 1;
					f[i] = 0;
					break;
				}
				m = tbl[k][0];
				if (dice[i][rot[j][m]] != tbl[k][1]) break;
			}
		}
		next:;
	}
	return 0;
}

int main()
{
	int i, j, k;
	char buf[10];

	for (i = 0; i < 26; i++) tr['a'+i] = 'A'+i, tr['A'+i] = 'a'+i;

	while (1) {
		for (i = 0; i < 8; i++) {
			fgets(buf, 10, stdin);
			if (*buf == '0') return 0;
			for (j = 0; j < 6; j++) dice[i][j+1] = buf[j];
			f[i] = 0;
		}
		for (i = 0; ; i++) {
			if (i == 7) { puts("NO"); break; }
			f[i] = 1;
			for (j = 0; j < 12; j++) {
				for (k = 1; k <= 6; k++) kari[0][k] = dice[i][rot[j][k]];
				if (rec(1)) { puts("YES"); goto next; }
			}
			f[i] = 0;
		}
		next:;
	}
	return 0;
}

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

using namespace std;

int n , fr[300005];

int main()
{
    cin >> n;
    for(int i = 1 ; i <= n - 1 ; i ++)
    {
        int x;
        cin >> x;
        fr[x] ++;
    }
    for(int i = 1 ; i <= n ; i ++)
        cout << fr[i] << '\n';
    return 0;
}


Measured memory_bytes: 4364
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
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 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")
    };
}

// solution 
use std::cmp;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
    }
    println!("{}", cmp::min(dfs(N, 0, 9), dfs(N, 0, 6)));
}

fn dfs(n: usize, sum: usize, div: usize) -> usize {
    let mut res = n;
    if res < div {
        return sum + res;
    }
    res /= div;
    let mut count = 0;
    while res > 0 {
        count += 1;
        res /= div;
    }
    res = n - div.pow(count as u32);
    cmp::min(dfs(res, sum+1, 9), dfs(res, sum+1, 6)) 
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<vector<pair<int, int>>> a(n);
	for (auto &i : a)
	{
		int x;
		cin >> x;
		i.resize(x);
		for (auto &j : i)
			cin >> j.F >> j.S;
	}

	int ans = 0;
	for (int m = 1; m < 1<<n; ++m)
	{
		bool ok = true;
		for (int i = 0; i < n; ++i)
			if (m>>i&1)
			{
				for (auto j : a[i])
					if (j.S)
						ok &= m>>(j.F-1)&1;
					else
						ok &= ~m>>(j.F-1)&1;
			}
		if (ok)
			ans = max(ans, __builtin_popcount(m));
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    dsu d(N + 1);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        d.merge(a, b);
    }
    set<int> parents;
    REP(i, 1, N + 1) {
        parents.insert(d.leader(i));
    }
    ll ans = max(0, int(parents.size() - 1));
    cout << ans << endl;
    return 0;
}

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

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

int main(int argc, const char* argv[]) {
	int N;
	scanf("%d", &N);
	VI a(N);
	foreach (x, a)
		scanf("%d", &x);
	VI o(a);
	sort(all(a));
	int m2 = a[a.size() / 2];
	int m1 = a[a.size() / 2 - 1];
	foreach (x, o) {
		if (x <= m1)
			printf("%d\n", m2);
		else
			printf("%d\n", m1);
	}

	return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int i, j, n;
	string s;
	cin >> s;
	s = "0" + s;
	n = s.length()-1;
	for (i = 1, j = (n - 1) / 2 ; i < j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (i = (n + 3) / 2 , j = n; i < j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (i = 1, j = n; i < j; i++, j--) {
		if (s[i] != s[j]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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


int main() {
  string a;
  cin >> a;
  string ans = "No";
  if(a[0] == a[1] && a[1] == a[2]) ans = "Yes";
  else if(a[1] == a[2] && a[2] == a[3]) ans = "Yes";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)&1)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n")
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n) rep(j,0,m) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const ll ooo=9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
//const int _p = 1000 * 1000 * 1000 + 7;
const int _p=1000003;
const int N=301005;
const double PI=acos(-1.0);
const double eps=1e-9;
int o(int x) { return x%_p; }
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; }

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

int a,b,c;

int main() {
    //file_put();

    scanf("%d%d%d",&a,&b,&c);
    if (a==b && b!=c) return 0*printf("%d\n",c);
    if (a!=b && b==c) return 0*printf("%d\n",a);
    if (a==c && b!=c) return 0*printf("%d\n",b);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int cul(LL x){
    int res = 0;
    while(x){
        x/=10;
        ++res;
    }
    return res;
}

int main(){
    LL N;
    cin >> N;
    int ans = 100;
    for(LL i=1;i*i<=N;++i){
        if(N%i)continue;
        ans = min(ans, max(cul(N/i), cul(i)));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
int min(int a,int b) {return a<b?a:b;}
int max(int a,int b) {return a<b?b:a;}
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    a=max(a,c);b=min(b,d);
    a=b-a;
    printf("%d\n",a>0?a:0);
    return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
    x,y = map(int,input().split())
    l.append(x)
    r.append(y)
ll = max(l)
rr = min(r)

if ll>rr:
    print(0)
else:
    print(rr-ll+1)


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

int main() {
	int n;
	double mean, std_dev, scores[1000];

	while( true ){
	 	cin >> n;
	 	if(!n) break;

	 	mean = 0.0; std_dev = 0.0;
		for(int i=0; i<n; i++) { 
			cin >> scores[i];
			mean += scores[i];
		}

		mean /= (double)n;
		for(int i=0; i<n; i++) std_dev += pow( scores[i] - mean, 2) / (double)n;

		cout << fixed << setprecision(8) << sqrt(std_dev) << endl;
	}

	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 200005;
const LL MOD = 998244353;

struct BIT {
	LL c[MAXN];
	void set(int p, LL v) {
		while (p < MAXN) {
			c[p] = max(c[p], v);
			p += p & -p;
		}
	}
	LL RMQ(int p) {
		LL res = 0;
		while (p) {
			res = max(res, c[p]);
			p -= p & -p;
		}
		return res;
	}
} tree;

int N, h[MAXN], a[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> h[i];
	for (int i = 1; i <= N; i++) cin >> a[i];
	for (int i = 1; i <= N; i++) tree.set(h[i], tree.RMQ(h[i]) + a[i]);
	cout << tree.RMQ(N) << "\n";
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define re register
#define in re int
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define rr read()
#define il inline
#define wr putchar('\n')
#define bl putchar(' ')
il int read()
{
	re char ch;re bool f=1;while((ch=getchar())<'0'||ch>'9')(ch=='-')&&(f=0);
	in x=ch^'0';while((ch=getchar())>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^'0');
	return f?x:-x;
}
il void print(in x)
{
	if(x<0)x=-x,putchar('-');
	if(x>=10)print(x/10);
	putchar(x%10+'0');
}
#define mm 250001
int ma[mm],cnt[501],X[501],c[501],pos[501][501];
il bool cmp(const in &x,const in &y){return X[x]<X[y];}
signed main()
{
	in n=rr,m=n*n;
	for(in i=1;i<=n;++i)ma[X[i]=rr]=i,c[i]=i,cnt[i]=i-1;
	sort(c+1,c+1+n,cmp);
	for(in i=1;i<=m;++i)
	{
		if(ma[i])continue;
		for(in j=1;j<=n;++j)
			if(cnt[c[j]])
			{
				ma[i]=c[j];
				--cnt[c[j]];
				break;
			}
	}
	for(in i=1;i<=n;++i)cnt[i]=n-i;
	for(in i=m;i>0;--i)
	{
		if(ma[i])continue;
		for(in j=n;j>0;--j)
			if(cnt[c[j]])
			{
				ma[i]=c[j];
				--cnt[c[j]];
				break;
			}
	}
	for(in i=1;i<=m;++i)pos[ma[i]][++cnt[ma[i]]]=i;
	for(in i=1;i<=n;++i)
		if(pos[i][i]!=X[i])
		{
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	for(in i=1;i<=m;++i)print(ma[i]),bl;
	wr;
	return 0;
}

Measured memory_bytes: 3072
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, W, totval = 0; cin >> n >> W;
    vector<pair<int, int>> items(n);
    for (auto& p : items)cin >> p.first >> p.second;
    for (auto& p : items)totval += p.second;
    vector<vector<int>> dp(n + 1, vector<int>(totval + 1));
    for (int i = 0; i <= totval; ++i)dp[1][i] = 1000000000+1;
    //for (int i = 0; i <= n; ++i)dp[i][0] = 0;
    dp[1][0] = 0;
    dp[1][items[0].second] = items[0].first;
    for (int i = 2; i <= n; ++i)
        for (int j = 0; j <= totval; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j>=items[i - 1].second) {
                dp[i][j] = min(dp[i][j], items[i - 1].first + dp[i - 1][j - items[i - 1].second]);
            }

        }
    for (int i = totval; i > -1; --i)if (dp[n][i] <= W) {
        cout << i << '\n'; break;
    }
    // printtable(dp);
    return 0;

}


Measured memory_bytes: 40192
import java.util.Scanner;
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H == 0 && W == 0)
      break;
      for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
          if(i == 0 || i == H-1 || j == 0 || j == W-1){
          System.out.print("#");
        }
        else{
          System.out.print(".");
        }
        }
        System.out.print("\n");
      }
      System.out.println("");
    }
}
}


Measured memory_bytes: 34772
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn(1e6 + 5);
const int mod(1e9 + 7);

inline void Inc(int &x, const int y) {
    x = x + y >= mod ? x + y - mod : x + y;
}

inline void Dec(int &x, const int y) {
    x = x - y < 0 ? x - y + mod : x - y;
}

inline int Add(const int x, const int y) {
    return x + y >= mod ? x + y - mod : x + y;
}

inline int Sub(const int x, const int y) {
    return x - y < 0 ? x - y + mod : x - y;
}

inline int Pow(ll x, int y) {
    int ret = 1;
    for (; y; y >>= 1, x = x * x % mod)
        if (y & 1) ret = ret * x % mod;
    return ret;
}

int n, f[maxn], ans;

inline void Solve() {
	int i, sum = 0;
	ans = 0, memset(f, 0, sizeof(f));
	for (i = 1; i <= n; ++i) {
		if (i < 3) f[i] = 1;
		else f[i] = Add(Sub(f[i - 1], f[i - 2]), f[i - 3]);
		if (i <= n - 1) Inc(ans, (ll)f[i] * Add((ll)(n - 1) * (n - 1) % mod, min(n - 1, i + 1)) % mod);
		else Inc(ans, (ll)f[i] * n % mod);
		Inc(f[i], f[i - 1]);
	}
	printf("%d\n", ans);
}

int main() {
	while (scanf("%d", &n) != EOF) Solve();
	return 0;
}

Measured memory_bytes: 4096
// A / B Problem
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_A
//
// Accepted

use std::io::{BufRead,Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();

    let mut data = buf.split_whitespace();

    let a: u64 = data.next().unwrap().parse().unwrap();
    let b: u64 = data.next().unwrap().parse().unwrap();

    println!("{} {} {}", a / b, a % b, a as f64 / b as f64);
}


Measured memory_bytes: 5044
#pragma GCC optimize ("O3")
#include <iostream>
#include <algorithm>
 
inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}
 
inline void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
 
int main(){
    int n, c, k; fastin(n); fastin(c); fastin(k);
    int t[n];
    for (int i = 0; i < n; ++i) fastin(t[i]);
 
    std::sort(t, t + n);
 
    int ans = 0;
    int beg = 0;
    while (beg < n){
        int end = beg;
        while (end - beg + 1 < c && t[end + 1] - t[beg] <= k){
            ++end;
            if (end == n - 1) break;
        }
        ++ans; beg = end + 1;
    }
    fastout(ans);
    
    return 0;
}

Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
//#pragma GCC optimize(2)

int main(){
    int a[5][5],aa[5][5];
    for(int i=0;i<5;i++)
        for(int j=0;j<5;j++)a[i][j]=aa[i][j]=0;
    for(int i=1;i<=3;i++)for(int j=1;j<=3;j++)cin>>a[i][j];
    int t,s;
    cin>>t;
    while(t--){
        cin>>s;
        for(int i=1;i<=3;i++)for(int j=1;j<=3;j++){
            if(s==a[i][j]){
                aa[i][j]=1;
            }
        }
    }
    int k=0,jk=0,lk=0;
    if(aa[1][1] && aa[2][2] && aa[3][3] || aa[1][3] && aa[2][2] && aa[3][1])k=1;
    if(aa[1][1] && aa[1][2] && aa[1][3])k=1;
    if(aa[2][1] && aa[2][2] && aa[2][3])k=1;
    if(aa[3][1] && aa[3][2] && aa[3][3])k=1;
    
    if(aa[1][1] && aa[2][1] && aa[3][1])k=1;
    if(aa[1][2] && aa[2][2] && aa[3][2])k=1;
    if(aa[1][3] && aa[2][3] && aa[3][3])k=1;
    
    /*if(aa[1][i] && aa[2][i] && aa[3][i])lk=1;
    if(jk && lk)k=1;*/
    cout<<(k?"Yes\n":"No\n");
}

Measured memory_bytes: 256
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a, b, c = map(int, readline().split())
  print(max(c-(a-b),0))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
s = input()
ans = 0
a = [0] * 2019
a[0] = 1
k = 0
mod = 1
for i in range(len(s) - 1, -1, -1):
    k = (k + int(s[i]) * mod) % 2019
    mod = (mod * 10) % 2019
    a[k] += 1
for i in a:
    ans += i * (i - 1) * 0.5
print(int(ans))

Measured memory_bytes: 9284
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
strength = [0] * (n + 1)
for i in range(1, n):
    strength[i] = strength[i - 1] + a[i - 1]
for i in range(len(a) - 1, -1, -1):
    if strength[i] * 2 < a[i]:
        break
    ans += 1
print(ans)

Measured memory_bytes: 14224
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}

#define NUM_MAX 2000
#define min(a,b) ((a) > (b) ? (b) : (a))
#define INF 0x7f7f7f7f

int main(void) {
    int num, v1, v2;
    int i, j;
    get_int3(&num, &v1, &v2);
    // 1-indexed -> 0-indexed
    v1--; v2--; // v1 < v2

    static int map[NUM_MAX];
    for(i = 0; i < num; i++) {
        for(j = i+1; j < num; j++) {
            int dist = 0;
            dist = abs(j-i);
            int src_v1 = abs(i-v1);
            int src_v2 = src_v1+1;
            dist = min(dist, src_v2 + abs(v2-j));
#ifdef DEBUG
            printf("[%d] (%d, %d) -> %d\n", src_v2, i, j, dist);
#endif
            map[dist]++;
        }
    }

    for(i = 1; i < num; i++) {
        printf("%d\n", map[i]);
    }
    return 0;
}

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

typedef unsigned long long u64;

std::ostream&
operator<<(std::ostream& dest, __int128_t value)
{
    std::ostream::sentry s(dest);
    if (s)
    {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[ 128 ];
        char* d = std::end(buffer);
        do
        {
            -- d;
            *d = "0123456789"[ tmp % 10 ];
            tmp /= 10;
        }
        while (tmp != 0);
        if (value < 0)
        {
            -- d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len)
        {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

typedef __int128 i128;
i128 pw[21];
i128 c[21], L[21], R[21], v[21];
i128 smin[21], smax[21];
i128 ans;
map<int, i128> cnt0, cnt1;
i128 d;

i128 dfs(int step, int tot, i128 sum)
{
    if (step == tot + 1)
    {
        if (sum == d)
        {
            i128 ret = cnt1[v[1]];
            for (int i = 2; i <= tot; i++)
            {
                ret = ret * cnt0[v[i]];
            }
            return ret;
        }
        return 0;
    }
    if (sum + smin[step] > d)
    {
        return 0;
    }
    if (sum + smax[step] < d)
    {
        return 0;
    }
    i128 ret = 0;
    for (int i = L[step]; i <= R[step]; i++)
    {
        v[step] = i;
        ret += dfs(step + 1, tot, sum + c[step] * i);
    }
    return ret;
}

i128 solve(int len)
{
    if (len == 1)
    {
        return 0;
    }
    for (int i = 1; i <= len / 2; i++)
    {
        c[i] = pw[len - i] - pw[i - 1];
    }
    L[1] = -8;
    R[1] = 9;
    for (int i = 2; i <= len / 2; i++)
    {
        L[i] = -9, R[i] = 9;
    }
    for (int i = 1; i <= len / 2; i++)
    {
        smin[i] = smax[i] = 0;
        for (int j = i; j <= len / 2; j++)
        {
            smin[i] += L[j] * c[j];
            smax[i] += R[j] * c[j];
        }
    }
    i128 ans = dfs(1, len / 2, 0);
    if (len & 1)
    {
        ans = ans * 10;
    }
    return ans;
}

int main()
{
    u64 td;
    cin >> td;
    d = td;

    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cnt0[i - j]++;
            if (j)
            {
                cnt1[i - j]++;
            }
        }
    }

    pw[0] = 1;
    for (int i = 1; i < 20; i++)
    {
        pw[i] = pw[i - 1] * 10;
    }

    for (int i = 1; i <= 20; i++)
    {
        ans += solve(i);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<string> S(N);
  for(auto &s: S)
    cin >> s;
  
  sort(S.begin(), S.end());
  for(auto &s: S) cout << s;
  return 0;
}

Measured memory_bytes: 256
MODE = "stdio"
require 'matrix'
include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '5
  70 80 100 90 20
  3
  80 80 80
  0'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n=0
while true
  k = line[n].to_i
  break if k == 0
  n += 1
  s = line[n].split(" ").map(&:to_f)
  m = s.inject(&:+)/k
  
  sum = 0
  s.each do |s|
    sum += (s-m)**2
  end
  
  printf("%.10f\n", (sum/k)**0.5)
  n += 1
end

Measured memory_bytes: 9404
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;

void solve() {
    repone(h, 3500) {
        repone(w, 3500) {
            double temp = double(N * h * w) / double(4 * h * w - N * h - N * w);
            auto t = temp - ll(temp);
            if (t == 0 && ll(temp) > 0) {
                printf("%lli %lli %lli", h, ll(temp), w);
                return;
            }
        }
    }
}

int main() {
    cin >> N;
    solve();
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 1e9

int main(int argc, char const *argv[])
{
    ll res = 0;
    ll a, b, c, x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;
    REP(i, a + 1)
    {
        REP(j, b + 1)
        {
            REP(k, c + 1)
            {
                if (500 * i + 100 * j + 50 * k == x)
                {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
class UFT():
    def __init__(self):
        self.par = {}
        self.rank = {}

    def find(self, x):
        if self.par.get(x, x) == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

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

        self.rank[x] = self.rank.get(x, 0)
        self.rank[y] = self.rank.get(y, 0)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

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

N, K, L = [int(_) for _ in input().split()]

Road = UFT()
for _ in range(K):
    p, q = [int(_) for _ in input().split()]
    Road.unite(p, q)
Railway = UFT()
for _ in range(L):
    r, s = [int(_) for _ in input().split()]
    Railway.unite(r, s)
memo = {}
for i in range(1, N + 1):
    memo[Road.find(i), Railway.find(i)] = memo.get((Road.find(i), Railway.find(i)), 0) + 1
print(' '.join(str(memo[Road.find(i), Railway.find(i)]) for i in range(1, N + 1)))


Measured memory_bytes: 64212
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
// template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
// template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       ll n,a=0,b=0,c=0,d=0;
        cin>>n; 
       for(ll i=0; i<n ;i++){
           string s;
           cin>>s;
           if(s=="AC")a++;
           else if(s=="WA")b++;
           else if(s=="TLE")c++;
           else d++;
       }
       cout<<"AC x "<<a<<endl;
       cout<<"WA x "<<b<<endl;
       cout<<"TLE x "<<c<<endl;
       cout<<"RE x "<<d<<endl;
     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 3656
(let ((n (read)))
  (loop with c = 0
        for i from 1 to n
        do (if (eql (read) (read))
               (incf c)
               (setf c 0))
        do (when (eql c 3)
             (format t "Yes~%")
             (quit)))
  (format t "No~%"))

Measured memory_bytes: 23716
import bisect

n, k, *lst = map(int, open(0).read().split())
z = bisect.bisect_left(lst, 0)
if not z:
  print(lst[k - 1])
  quit()
if z >= n - 1:
  print(-lst[-k])
  quit()
res = float('inf')
for i in range(max(z - k + 1, 0), min(z, n - k) + 1):
  tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1])
  if tmp < res:
    res = tmp
print(res)


Measured memory_bytes: 14052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

double A[109];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	double ans = 0;

	for (int i = 0; i < N; i++) ans += ((double)1 / A[i]);
	cout << setprecision(15) << (double)1 / ans << endl;


	return 0;
}

Measured memory_bytes: 256
import bisect
from collections import deque

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    bc.append(tmp[::-1])

a.sort()
a = deque(a)
bc.sort(reverse=True)

ans = 0
num = 0
for i in range(m):
    index = bisect.bisect_left(a,bc[i][0])
    if index == 0:
        break
    if bc[i][1] > index:
        ans += bc[i][0] * index
        num = index
    else:
        ans += bc[i][0] * bc[i][1]
        num = bc[i][1]
    for _ in range(num):
        a.popleft()

print(ans + sum(a))


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

int main(){
	long long N,ans=0,F=0;
	cin >> N;
	vector<long long> D(N);
	long long loop,loop2;
	for(loop=0;loop<N;loop++){
		cin >> D[loop];
	}
	vector<long long> Num(N,0);
	if(D[0]==0){
		Num[0] = 1;
		long long NumMax = 1;
		for(loop=1;loop<N;loop++){
			if(D[loop]){
				Num[D[loop]]++;
				if(NumMax < D[loop]){
					NumMax = D[loop];
				}
			}else{
				F=1;
				break;
			}
		}
		if(F == 0){
			ans = 1;
			for(loop=1;loop<=NumMax;loop++){
				for(loop2=0;loop2<Num[loop];loop2++){
					ans = (ans * Num[loop-1]) % 998244353;
				}
			}
		}
	}
	cout << ans%998244353 << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
int n,a,b;

//aのb乗
ll ksm(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}

//nCb
ll C(ll n,ll b){
	ll ret=1;
	for(int i=1;i<=b;i++){
		ret=ret*(n-i+1)%mod*ksm(i,mod-2)%mod;
	}
	return ret;
}

int main(){
	cin>>n>>a>>b;
	ll ans=ksm(2,n)-C(n,a)-C(n,b)-1;
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = sorted(il())
    mx = max(A)
    st = set()
    cnt = collections.Counter(A)
    ret = 0
    for n in range(N):
        if A[n] not in st and cnt[A[n]] == 1:
            st.add(A[n])
            ret += 1

        a = 1
        while A[n] * a <= mx:
            st.add(A[n] * a)
            a+=1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 103352
n=int(input())
a=list(map(int,input().split()))
up=False
down=False
ans=0
for i in range(n-1):
    if(not up and not down):
        if(a[i]<a[i+1]):
            up=True
        elif(a[i]>a[i+1]):
            down=True
    elif(up):
        if(a[i]>a[i+1]):
            ans+=1
            up=False
    elif(down):
        if(a[i]<a[i+1]):
            ans+=1
            down=False
ans+=1
print(ans)

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

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    n = n * 2 + 1;
    int m;
    cin >> m;

    char bfr = ' ';
    int length = 0;
    int cnt = 0;
    for(int i = 0; i < m; i++) {
      char c;
      cin >> c;
      if(c != bfr) {
	length++;
      } else {
	length = 0;
      }
      if(length == 0) {
	if(c == 'I') {
	  length = 1;
	}
      }
      if(c == 'I' && length >= n) cnt++;

      bfr = c;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
	P res = P(-1,-1);
	for (int x = 0; 100 * x <= F; ++x){
		for (int y = 0; 100 * y <= F; ++y){
			if (x == 0 && y == 0) continue;
			int water = 100 * A * x + 100 * B * y;
			
			for (int u = 0; u <= (F - water)/C; ++u){
				for (int v = 0; v <= (F - water)/D; ++v){
					int sugar = C * u + D * v;
					if (water * E < sugar * 100){
						break;
					} // end if
					if (F < water + sugar){
						break;
					} // end if
					if (res.first == -1 || (sugar * res.first > (water + sugar) * res.second)){
						res = P(water + sugar, sugar);
					} // end if
				} // end if
			} // end for
		} // end for
	} // end for

	cout << res.first << ' ' << res.second << endl;
	
	return 0;
}

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

void solve(){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];

    ll sum = 0, tmpmax = -1;
    REP(i, k) sum += p[i];
    tmpmax = max(sum, tmpmax);
    int i = 0;
    while(i < n-k){
        sum = sum - p[i] + p[i+k];
        tmpmax = max(sum, tmpmax); 
        i++;
    }

    double ans = (double)(tmpmax+k)/2;
    printf("%.9f\n", ans);    
}

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

Measured memory_bytes: 1792